Socket
Socket
Sign inDemoInstall

oci-common

Package Overview
Dependencies
Maintainers
2
Versions
192
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oci-common - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

lib/auth/abstract-federation-client-authenticated-details-provider-builder.d.ts

3

index.d.ts

@@ -19,2 +19,3 @@ /**

import { HttpRequest } from "./lib/http-request";
import InstancePrincipalsAuthenticationDetailsProviderBuilder from "./lib/auth/instance-principals-authentication-detail-provider";
import { paginateRecords, genericPaginateRecords, paginatedRecordsWithLimit, paginateResponses, genericPaginateResponses, paginatedResponsesWithLimit } from "./lib/paginators";

@@ -40,2 +41,2 @@ import { ConfigFileAuthenticationDetailsProvider } from "./lib/auth/config-file-auth";

export import Range = range.Range;
export { Region, Realm, EndpointBuilder, DelayStrategy, TerminationStrategy, ExponentialBackoffDelayStrategy, MaxTimeTerminationStrategy, genericWaiter, genericTerminalConditionWaiter, WaiterConfiguration, RequireOnlyOne, AuthParams, paginateRecords, paginatedResponsesWithLimit, paginatedRecordsWithLimit, genericPaginateRecords, paginateResponses, genericPaginateResponses, Method, composeRequest, composeResponse, HttpRequest, ConfigFileAuthenticationDetailsProvider, ConfigFileReader, LOG };
export { Region, Realm, EndpointBuilder, DelayStrategy, TerminationStrategy, ExponentialBackoffDelayStrategy, MaxTimeTerminationStrategy, genericWaiter, genericTerminalConditionWaiter, WaiterConfiguration, RequireOnlyOne, AuthParams, paginateRecords, paginatedResponsesWithLimit, paginatedRecordsWithLimit, genericPaginateRecords, paginateResponses, genericPaginateResponses, Method, composeRequest, composeResponse, HttpRequest, ConfigFileAuthenticationDetailsProvider, ConfigFileReader, InstancePrincipalsAuthenticationDetailsProviderBuilder, LOG };

@@ -13,2 +13,5 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -35,2 +38,4 @@ const auth = __importStar(require("./lib/auth/auth"));

exports.genericTerminalConditionWaiter = waiter_1.genericTerminalConditionWaiter;
const instance_principals_authentication_detail_provider_1 = __importDefault(require("./lib/auth/instance-principals-authentication-detail-provider"));
exports.InstancePrincipalsAuthenticationDetailsProviderBuilder = instance_principals_authentication_detail_provider_1.default;
const paginators_1 = require("./lib/paginators");

@@ -37,0 +42,0 @@ exports.paginateRecords = paginators_1.paginateRecords;

@@ -1,2 +0,1 @@

import { Region } from "../region";
/**

@@ -6,10 +5,12 @@ * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.

*/
import { Region } from "../region";
import AbstractAuthenticationDetailsProvider from "./models/abstract-authentication-details-provider";
/**
* An interface provides the authentication details.
*/
export interface AuthenticationDetailsProvider {
export interface AuthenticationDetailsProvider extends AbstractAuthenticationDetailsProvider {
/**
* Get the key id to sign the http request.
*/
getKeyId(): string;
getKeyId(): Promise<string>;
/**

@@ -55,3 +56,3 @@ * Get the private key to sign the http request.

*/
getKeyId(): string;
getKeyId(): Promise<string>;
/**

@@ -58,0 +59,0 @@ * Get the private key to sign the http request.

"use strict";
/**
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* 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.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -35,3 +48,5 @@ /*

getKeyId() {
return this.tenancy + "/" + this.user + "/" + this.fingerprint;
return __awaiter(this, void 0, void 0, function* () {
return this.tenancy + "/" + this.user + "/" + this.fingerprint;
});
}

@@ -38,0 +53,0 @@ /**

@@ -27,3 +27,3 @@ /**

*/
getKeyId(): string;
getKeyId(): Promise<string>;
/**

@@ -30,0 +30,0 @@ * Get the private key to sign the http request.

@@ -6,2 +6,11 @@ "use strict";

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -67,3 +76,5 @@ const auth_1 = require("./auth");

getKeyId() {
return this.delegate.getKeyId();
return __awaiter(this, void 0, void 0, function* () {
return yield this.delegate.getKeyId();
});
}

@@ -70,0 +81,0 @@ /**

@@ -14,2 +14,3 @@ /**

export declare function convertStringToType(str: string | null, expectedType: string): any;
export declare function getStringFromResponseBody(body: any): Promise<string>;
export declare function readStringFromReadable(readable: Readable): Promise<string>;

@@ -24,1 +25,2 @@ export declare function readStringFromFetchReadableStream(readable: ReadableStream): Promise<string>;

export declare function formatDateToRFC3339(date: Date): string;
export declare function getStringFromRequestBody(body: any): Promise<string>;

@@ -74,2 +74,27 @@ "use strict";

exports.convertStringToType = convertStringToType;
// get string content from response body
function getStringFromResponseBody(body) {
return __awaiter(this, void 0, void 0, function* () {
if (typeof body === "string") {
return body;
}
if (body instanceof stream_1.Readable) {
// body is a stream type
return readStringFromReadable(body);
}
else if (body instanceof Blob) {
// body is a blob type
return readStringFromBlob(body);
}
else if (body instanceof ReadableStream) {
// body is a fetch readableStream type
return readStringFromFetchReadableStream(body);
}
else {
// unknown type, unable to read body content for signing, reject it
throw new Error("Unable to read body content to sign the request");
}
});
}
exports.getStringFromResponseBody = getStringFromResponseBody;
// read string from Readable asynchronously, return a string content of it

@@ -202,2 +227,27 @@ function readStringFromReadable(readable) {

exports.formatDateToRFC3339 = formatDateToRFC3339;
// get string content from body
function getStringFromRequestBody(body) {
return __awaiter(this, void 0, void 0, function* () {
if (typeof body === "string") {
return body;
}
if (body instanceof stream_1.Readable) {
// body is a stream type
return readStringFromReadable(body);
}
else if (body instanceof Blob) {
// body is a blob type
return readStringFromBlob(body);
}
else if (body instanceof ReadableStream) {
// body is a fetch readableStream type
return readStringFromFetchReadableStream(body);
}
else {
// unknown type, unable to read body content for signing, reject it
throw new Error("Unable to read body content to sign the request");
}
});
}
exports.getStringFromRequestBody = getStringFromRequestBody;
//# sourceMappingURL=helper.js.map

@@ -17,2 +17,3 @@ /**

readonly regionId: string;
private static REGIONS_SHORT_NAMES;
private static KNOWN_REGIONS;

@@ -46,2 +47,9 @@ private constructor();

static register(regionId: string, realm: Realm): Region;
/**
* Function to get regionId based regionStr: regionStr can be a short code or regionId
* if it is a regionStr then we want to return the corresponding regionId
* @param regionStr
* @return regionId
*/
static getRegionIdFromShortCode(regionStr: string): string;
}

@@ -43,4 +43,42 @@ "use strict";

}
/**
* Function to get regionId based regionStr: regionStr can be a short code or regionId
* if it is a regionStr then we want to return the corresponding regionId
* @param regionStr
* @return regionId
*/
static getRegionIdFromShortCode(regionStr) {
regionStr = regionStr.toLocaleLowerCase();
return Region.REGIONS_SHORT_NAMES[regionStr]
? Region.REGIONS_SHORT_NAMES[regionStr]
: regionStr;
}
}
exports.Region = Region;
Region.REGIONS_SHORT_NAMES = {
"phx": "us-phoenix-1",
"iad": "us-ashburn-1",
"fra": "eu-frankfurt-1",
"lhr": "uk-london-1",
"yyz": "ca-toronto-1",
"gru": "sa-saopaulo-1",
"ams": "eu-amsterdam-1",
"jed": "me-jeddah-1",
"kix": "ap-osaka-1",
"ltn": "uk-gov-london-1",
"nrt": "ap-tokyo-1",
"icn": "ap-seoul-1",
"hyd": "ap-hyderabad-1",
"bom": "ap-mumbai-1",
"yny": "ap-chuncheon-1",
"syd": "ap-sydney-1",
"mel": "ap-melbourne-1",
"yul": "ca-montreal-1",
"zrh": "eu-zurich-1",
"lfi": "us-langley-1",
"luf": "us-luke-1",
"ric": "us-gov-ashburn-1",
"pia": "us-gov-chicago-1",
"tus": "us-gov-phoenix-1"
};
Region.KNOWN_REGIONS = new Map();

@@ -47,0 +85,0 @@ // OC1

@@ -6,3 +6,12 @@ /**

import auth = require("./auth/auth");
import { Method } from "./request-generator";
import { HttpRequest } from "./http-request";
export declare class SignerRequest {
private headers;
method: string;
path?: string | null;
constructor(method: Method, url: string, headers: Headers);
getHeader(name: string): string | null;
setHeader(name: string, value: any): void;
}
/**

@@ -26,3 +35,3 @@ * An interface signs the http request.

private static readonly methodsThatRequireExtraHeaders;
private readonly privateKeyBuffer;
private privateKeyBuffer;
/**

@@ -29,0 +38,0 @@ * Construct an instance of [[DefaultRequestSigner]].

@@ -16,7 +16,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const helper = require("./helper");
const helper_1 = require("./helper");
const jssha = require("jssha");
const sshpk_1 = require("sshpk");
const UrlParser = require("url");
const stream_1 = require("stream");
// tslint:disable-next-line:no-var-requires

@@ -43,2 +42,3 @@ const httpSignature = require("http-signature");

}
exports.SignerRequest = SignerRequest;
/**

@@ -68,2 +68,6 @@ * The default implementation of [[RequestSigner]].

// Populate missing headers required for signing
let options = {};
if (this.authenticationDetailsProvider.getPassphrase()) {
Object.assign(options, { passphrase: this.authenticationDetailsProvider.getPassphrase() });
}
if (!request.headers.has("host")) {

@@ -91,3 +95,3 @@ const url = UrlParser.parse(request.uri);

if (request.body) {
const bodyStringContent = yield getStringFromRequestBody(request.body);
const bodyStringContent = yield helper_1.getStringFromRequestBody(request.body);
shaObj.update(bodyStringContent);

@@ -106,5 +110,7 @@ request.headers.set(HEADER_CONTENT_SHA, shaObj.getHash("B64"));

}
const keyId = yield this.authenticationDetailsProvider.getKeyId();
this.privateKeyBuffer = sshpk_1.parsePrivateKey(this.authenticationDetailsProvider.getPrivateKey(), "auto", options).toBuffer("pem", {});
httpSignature.sign(new SignerRequest(request.method, request.uri, request.headers), {
key: this.privateKeyBuffer,
keyId: this.authenticationDetailsProvider.getKeyId(),
keyId: keyId,
headers: headersToSign

@@ -125,26 +131,2 @@ });

DefaultRequestSigner.methodsThatRequireExtraHeaders = ["POST", "PUT", "PATCH"];
// get string content from body
function getStringFromRequestBody(body) {
return __awaiter(this, void 0, void 0, function* () {
if (typeof body === "string") {
return body;
}
if (body instanceof stream_1.Readable) {
// body is a stream type
return helper.readStringFromReadable(body);
}
else if (body instanceof Blob) {
// body is a blob type
return helper.readStringFromBlob(body);
}
else if (body instanceof ReadableStream) {
// body is a fetch readableStream type
return helper.readStringFromFetchReadableStream(body);
}
else {
// unknown type, unable to read body content for signing, reject it
throw new Error("Unable to read body content to sign the request");
}
});
}
//# sourceMappingURL=signer.js.map
{
"name": "oci-common",
"version": "1.2.2",
"version": "1.2.3",
"description": "OCI Common module for NodeJS",

@@ -22,2 +22,3 @@ "repository": {

"isomorphic-fetch": "2.2.1",
"jsonwebtoken": "8.5.1",
"jssha": "2.4.1",

@@ -29,2 +30,3 @@ "sshpk": "1.16.1",

"@types/chai": "^4.1.7",
"@types/jsonwebtoken": "^8.5.0",
"@types/jssha": "^2.0.0",

@@ -31,0 +33,0 @@ "@types/mocha": "^5.2.5",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc