Skip to content

Commit 5e6113e

Browse files
authored
Merge pull request #15 from oracle/release_2020-07-28
Releasing version 1.3.0
2 parents ac58c85 + dc62a78 commit 5e6113e

File tree

129 files changed

+3263
-140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+3263
-140
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/).
55

6+
## 1.3.0 - 2020-07-28
7+
### Added
8+
- Support for calling Oracle Cloud Infrastructure services in the us-sanjose-1 region
9+
- Support for updating the fault domain and launch options of VM instances in the Compute service
10+
- Support for image capability schemas and schema versions in the Compute service
11+
- Support for 'Patch Now' maintenance runs for autonomous Exadata infrastructure and autonomous container database resources in the Database service
12+
- Support for automatic performance and cost tuning on volumes in the Block Storage service
13+
- Support for Ephemeral Resource Principal
14+
15+
16+
### Breaking
17+
- Removed the accessToken field from the GitlabAccessTokenConfigurationSourceProvider model in the Resource Manager service
18+
619
## 1.2.4 - 2020-07-21
720
### Added
821
- Support for license types on instances in the Content and Experience service
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
4+
*/
5+
6+
const identity = require("oci-identity");
7+
const common = require("oci-common");
8+
9+
(async () => {
10+
const authenticationProvider = await common.ResourcePrincipalAuthenticationDetailsProvider.builder();
11+
try {
12+
const identityClient = await new identity.IdentityClient({
13+
authenticationDetailsProvider: authenticationProvider
14+
});
15+
const regions = await identityClient.listRegions({});
16+
console.log("Regions: ", JSON.stringify(regions));
17+
} catch (e) {
18+
throw Error(`Failed with error: ${e}`);
19+
}
20+
})();
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
4+
*/
5+
6+
import * as identity from "oci-identity";
7+
import common = require("oci-common");
8+
9+
(async () => {
10+
const authenticationProvider = await common.ResourcePrincipalAuthenticationDetailsProvider.builder();
11+
try {
12+
const identityClient = await new identity.IdentityClient({
13+
authenticationDetailsProvider: authenticationProvider
14+
});
15+
const regions = await identityClient.listRegions({});
16+
console.log("Regions: ", JSON.stringify(regions));
17+
} catch (e) {
18+
throw Error(`Failed with error: ${e}`);
19+
}
20+
})();

lib/analytics/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oci-analytics",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "OCI NodeJS client for Analytics Service",
55
"repository": {
66
"type": "git",

lib/announcementsservice/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oci-announcementsservice",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "OCI NodeJS client for Announcement Service",
55
"repository": {
66
"type": "git",

lib/apigateway/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oci-apigateway",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "OCI NodeJS client for API gateway service",
55
"repository": {
66
"type": "git",

lib/applicationmigration/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oci-applicationmigration",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "OCI NodeJS client for Application Migration service",
55
"repository": {
66
"type": "git",

lib/audit/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oci-audit",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "OCI NodeJS client for Audit Service",
55
"repository": {
66
"type": "git",

lib/autoscaling/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oci-autoscaling",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "OCI NodeJS client for Autoscaling Service",
55
"repository": {
66
"type": "git",

lib/bds/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oci-bds",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "OCI NodeJS client for BDS Service",
55
"repository": {
66
"type": "git",

lib/blockchain/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oci-blockchain",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "OCI NodeJS client for Blockchain Service",
55
"repository": {
66
"type": "git",

lib/budget/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oci-budget",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "OCI NodeJS client for Budget Service",
55
"repository": {
66
"type": "git",

lib/cims/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oci-cims",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "OCI NodeJS client for Cims ",
55
"repository": {
66
"type": "git",

lib/common/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
import { RequireOnlyOne, AuthParams } from "./lib/types";
2727
import { HttpRequest } from "./lib/http-request";
2828
import InstancePrincipalsAuthenticationDetailsProviderBuilder from "./lib/auth/instance-principals-authentication-detail-provider";
29+
import ResourcePrincipalAuthenticationDetailsProvider from "./lib/auth/resource-principal-authentication-details-provider";
2930
import {
3031
paginateRecords,
3132
genericPaginateRecords,
@@ -85,5 +86,6 @@ export {
8586
ConfigFileAuthenticationDetailsProvider,
8687
ConfigFileReader,
8788
InstancePrincipalsAuthenticationDetailsProviderBuilder,
89+
ResourcePrincipalAuthenticationDetailsProvider,
8890
LOG
8991
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
4+
*/
5+
6+
import SessionKeySupplier from "./models/session-key-supplier";
7+
import KeyPair from "./key-pair";
8+
import { loadPrivateKeyFromFile } from "./helpers/load-private-key-from-file";
9+
10+
export default class FileBasedKeySupplier implements SessionKeySupplier {
11+
private keyPair!: KeyPair;
12+
13+
constructor(private privateKeyPath: string, private passphrasePath?: string) {
14+
this.refreshKeys();
15+
}
16+
17+
// Getter: KeyPair
18+
public getKeyPair(): KeyPair {
19+
return this.keyPair;
20+
}
21+
22+
// Getter: Public Key
23+
public get publicKey(): string {
24+
return this.getKeyPair().getPublic();
25+
}
26+
27+
// Getter Private Key
28+
public get privateKey(): string {
29+
return this.getKeyPair().getPrivate();
30+
}
31+
32+
public refreshKeys(): void {
33+
if (!this.privateKeyPath) {
34+
throw Error("privateKeyPath not set");
35+
}
36+
37+
// Try to create a privateKey & publicKey from the given privateKeyPath & passphrasePath
38+
try {
39+
const { publicKey, privateKey } = loadPrivateKeyFromFile(
40+
this.privateKeyPath,
41+
this.passphrasePath
42+
);
43+
this.keyPair = new KeyPair(publicKey, privateKey);
44+
} catch (e) {
45+
throw Error(`Problem occured trying to create KeyPairs from given paths with error: ${e}`);
46+
}
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
4+
*/
5+
import { readFileSync } from "fs";
6+
import FederationClient from "./models/federation-client";
7+
import SessionKeySupplier from "./models/session-key-supplier";
8+
import SecurityTokenAdapter from "./security-token-adapter";
9+
10+
/**
11+
* This class gets a security token from file.
12+
*/
13+
export default class FileBasedResourcePrincipalFederationClient implements FederationClient {
14+
private securityTokenAdapter: SecurityTokenAdapter;
15+
constructor(
16+
private sessionKeySupplier: SessionKeySupplier,
17+
private resourcePrincipalSessionTokenPath: string
18+
) {
19+
this.sessionKeySupplier = sessionKeySupplier;
20+
this.securityTokenAdapter = new SecurityTokenAdapter("", sessionKeySupplier);
21+
this.resourcePrincipalSessionTokenPath = resourcePrincipalSessionTokenPath;
22+
}
23+
24+
/**
25+
* Gets a security token. If there is already a valid token cached, it will be returned. Else this will make a call
26+
* to the auth service to get a new token, using the provided suppliers.
27+
*
28+
* This method is thread-safe.
29+
* @return the security token
30+
* @throws OciError If there is any issue with getting a token from the auth server
31+
*/
32+
async getSecurityToken(): Promise<string> {
33+
if (this.securityTokenAdapter.isValid()) {
34+
return this.securityTokenAdapter.getSecurityToken();
35+
}
36+
return await this.refreshAndGetSecurityTokenInner(true);
37+
}
38+
39+
/**
40+
* Return a claim embedded in the security token
41+
* @param key the name of the claim
42+
* @return the value of the claim or null if unable to find
43+
*/
44+
async getStringClaim(key: string): Promise<string | null> {
45+
await this.refreshAndGetSecurityToken();
46+
return this.securityTokenAdapter.getStringClaim(key);
47+
}
48+
49+
async refreshAndGetSecurityToken(): Promise<string> {
50+
return await this.refreshAndGetSecurityTokenInner(false);
51+
}
52+
53+
private async refreshAndGetSecurityTokenInner(
54+
doFinalTokenValidityCheck: boolean
55+
): Promise<string> {
56+
// Check again to see if the JWT is still invalid, unless we want to skip that check
57+
if (!doFinalTokenValidityCheck || !this.securityTokenAdapter.isValid()) {
58+
this.sessionKeySupplier.refreshKeys();
59+
this.securityTokenAdapter = this.getSecurityTokenFromFile();
60+
return this.securityTokenAdapter.getSecurityToken();
61+
}
62+
return this.securityTokenAdapter.getSecurityToken();
63+
}
64+
65+
/**
66+
* Gets a security token from file
67+
* @return the security token, which is basically a JWT token string
68+
*/
69+
protected getSecurityTokenFromFile(): SecurityTokenAdapter {
70+
const keyPair = this.sessionKeySupplier.getKeyPair();
71+
if (!keyPair) {
72+
throw Error("Keypair for session was not provided");
73+
}
74+
let securityToken = "";
75+
try {
76+
securityToken = readFileSync(this.resourcePrincipalSessionTokenPath, "utf8");
77+
} catch (e) {
78+
throw Error(`Failed to read token due to error: ${e}`);
79+
}
80+
return new SecurityTokenAdapter(securityToken, this.sessionKeySupplier);
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
4+
*/
5+
6+
import SessionKeySupplier from "./models/session-key-supplier";
7+
import KeyPair from "./key-pair";
8+
import { parsePrivateKey } from "sshpk";
9+
10+
/**
11+
* This is a SessionKeySupplier which fakes the ability to refresh its contained key.
12+
* It is initialised once with fixed values of private key and (optional) passphrase; that key is always returned.
13+
*/
14+
15+
export default class FixedContentKeySupplier implements SessionKeySupplier {
16+
private keyPair: KeyPair;
17+
constructor(private privateKeyContent: string, private passphrase?: string) {
18+
try {
19+
let options = {};
20+
// parse privateKeyContent with passphrase (if it exist) into a PrivateKey
21+
if (passphrase) {
22+
Object.assign(options, { passphrase: passphrase });
23+
}
24+
const privateKey = parsePrivateKey(privateKeyContent, "auto", options);
25+
const publicKey = privateKey.toPublic();
26+
this.keyPair = new KeyPair(
27+
publicKey.toString("pem"),
28+
privateKey.toBuffer("pem", {}).toString()
29+
);
30+
} catch (e) {
31+
throw Error(`Failed to read file contents, error: ${e}`);
32+
}
33+
}
34+
35+
// Getter: KeyPair
36+
public getKeyPair(): KeyPair {
37+
return this.keyPair;
38+
}
39+
40+
// Getter: Public Key
41+
public get publicKey(): string {
42+
return this.getKeyPair().getPublic();
43+
}
44+
45+
// Getter Private Key
46+
public get privateKey(): string {
47+
return this.getKeyPair().getPrivate();
48+
}
49+
50+
public refreshKeys(): void {}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
4+
*/
5+
6+
import SessionKeySupplier from "./models/session-key-supplier";
7+
import SecurityTokenAdapter from "./security-token-adapter";
8+
import FederationClient from "./models/federation-client";
9+
10+
/**
11+
* This class returns a security token, supplied as a fixed value.
12+
*/
13+
export default class FixedContentResourcePrincipalFederationClient implements FederationClient {
14+
private securityTokenAdapter: SecurityTokenAdapter;
15+
16+
/**
17+
* Constructor of FixedContentResourcePrincipalFederationClient.
18+
*
19+
* @param resourcePrincipalSessionToken the constant value for the RPST
20+
* @param sessionKeySupplier the associated SessionKeySupplier
21+
*/
22+
constructor(resourcePrincipalSessionToken: string, sessionKeySupplier: SessionKeySupplier) {
23+
this.securityTokenAdapter = new SecurityTokenAdapter(
24+
resourcePrincipalSessionToken,
25+
sessionKeySupplier
26+
);
27+
}
28+
29+
async getSecurityToken(): Promise<string> {
30+
return this.securityTokenAdapter.getSecurityToken();
31+
}
32+
33+
async refreshAndGetSecurityToken(): Promise<string> {
34+
return this.securityTokenAdapter.getSecurityToken();
35+
}
36+
37+
async getStringClaim(key: string): Promise<string | null> {
38+
return this.securityTokenAdapter.getStringClaim(key);
39+
}
40+
}

0 commit comments

Comments
 (0)