Socket
Socket
Sign inDemoInstall

@aws-sdk/signature-v4

Package Overview
Dependencies
Maintainers
4
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/signature-v4 - npm Package Compare versions

Comparing version 0.1.0-preview.4 to 0.1.0-preview.5

jest.config.js

6

build/cloneRequest.js

@@ -13,10 +13,8 @@ "use strict";

function cloneQuery(query) {
return Object.keys(query)
.reduce(function (carry, paramName) {
return Object.keys(query).reduce(function (carry, paramName) {
var _a;
var param = query[paramName];
return tslib_1.__assign({}, carry, (_a = {}, _a[paramName] = Array.isArray(param)
? param.slice() : param, _a));
return tslib_1.__assign({}, carry, (_a = {}, _a[paramName] = Array.isArray(param) ? param.slice() : param, _a));
}, {});
}
//# sourceMappingURL=cloneRequest.js.map

@@ -17,17 +17,17 @@ export declare const ALGORITHM_QUERY_PARAM = "X-Amz-Algorithm";

export declare const ALWAYS_UNSIGNABLE_HEADERS: {
'authorization': boolean;
'cache-control': boolean;
'connection': boolean;
'expect': boolean;
'from': boolean;
'keep-alive': boolean;
'max-forwards': boolean;
'pragma': boolean;
'referer': boolean;
'te': boolean;
'trailer': boolean;
'transfer-encoding': boolean;
'upgrade': boolean;
'user-agent': boolean;
'x-amzn-trace-id': boolean;
authorization: boolean;
"cache-control": boolean;
connection: boolean;
expect: boolean;
from: boolean;
"keep-alive": boolean;
"max-forwards": boolean;
pragma: boolean;
referer: boolean;
te: boolean;
trailer: boolean;
"transfer-encoding": boolean;
upgrade: boolean;
"user-agent": boolean;
"x-amzn-trace-id": boolean;
};

@@ -34,0 +34,0 @@ export declare const PROXY_HEADER_PATTERN: RegExp;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ALGORITHM_QUERY_PARAM = 'X-Amz-Algorithm';
exports.CREDENTIAL_QUERY_PARAM = 'X-Amz-Credential';
exports.AMZ_DATE_QUERY_PARAM = 'X-Amz-Date';
exports.SIGNED_HEADERS_QUERY_PARAM = 'X-Amz-SignedHeaders';
exports.EXPIRES_QUERY_PARAM = 'X-Amz-Expires';
exports.SIGNATURE_QUERY_PARAM = 'X-Amz-Signature';
exports.TOKEN_QUERY_PARAM = 'X-Amz-Security-Token';
exports.AUTH_HEADER = 'authorization';
exports.ALGORITHM_QUERY_PARAM = "X-Amz-Algorithm";
exports.CREDENTIAL_QUERY_PARAM = "X-Amz-Credential";
exports.AMZ_DATE_QUERY_PARAM = "X-Amz-Date";
exports.SIGNED_HEADERS_QUERY_PARAM = "X-Amz-SignedHeaders";
exports.EXPIRES_QUERY_PARAM = "X-Amz-Expires";
exports.SIGNATURE_QUERY_PARAM = "X-Amz-Signature";
exports.TOKEN_QUERY_PARAM = "X-Amz-Security-Token";
exports.AUTH_HEADER = "authorization";
exports.AMZ_DATE_HEADER = exports.AMZ_DATE_QUERY_PARAM.toLowerCase();
exports.DATE_HEADER = 'date';
exports.DATE_HEADER = "date";
exports.GENERATED_HEADERS = [exports.AUTH_HEADER, exports.AMZ_DATE_HEADER, exports.DATE_HEADER];
exports.SIGNATURE_HEADER = exports.SIGNATURE_QUERY_PARAM.toLowerCase();
exports.SHA256_HEADER = 'x-amz-content-sha256';
exports.SHA256_HEADER = "x-amz-content-sha256";
exports.TOKEN_HEADER = exports.TOKEN_QUERY_PARAM.toLowerCase();
exports.HOST_HEADER = 'host';
exports.HOST_HEADER = "host";
exports.ALWAYS_UNSIGNABLE_HEADERS = {
'authorization': true,
'cache-control': true,
'connection': true,
'expect': true,
'from': true,
'keep-alive': true,
'max-forwards': true,
'pragma': true,
'referer': true,
'te': true,
'trailer': true,
'transfer-encoding': true,
'upgrade': true,
'user-agent': true,
'x-amzn-trace-id': true,
authorization: true,
"cache-control": true,
connection: true,
expect: true,
from: true,
"keep-alive": true,
"max-forwards": true,
pragma: true,
referer: true,
te: true,
trailer: true,
"transfer-encoding": true,
upgrade: true,
"user-agent": true,
"x-amzn-trace-id": true
};
exports.PROXY_HEADER_PATTERN = /^proxy-/;
exports.SEC_HEADER_PATTERN = /^sec-/;
exports.UNSIGNABLE_PATTERNS = [
/^proxy-/i,
/^sec-/i,
];
exports.ALGORITHM_IDENTIFIER = 'AWS4-HMAC-SHA256';
exports.UNSIGNED_PAYLOAD = 'UNSIGNED-PAYLOAD';
exports.UNSIGNABLE_PATTERNS = [/^proxy-/i, /^sec-/i];
exports.ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256";
exports.UNSIGNED_PAYLOAD = "UNSIGNED-PAYLOAD";
exports.MAX_CACHE_SIZE = 50;
exports.KEY_TYPE_IDENTIFIER = 'aws4_request';
exports.KEY_TYPE_IDENTIFIER = "aws4_request";
exports.MAX_PRESIGNED_TTL = 60 * 60 * 24 * 7;
//# sourceMappingURL=constants.js.map

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

import { Credentials, HashConstructor } from '@aws-sdk/types';
import { Credentials, HashConstructor } from "@aws-sdk/types";
/**

@@ -3,0 +3,0 @@ * Create a string describing the scope of credentials used to sign a request.

@@ -30,4 +30,4 @@ "use strict";

function getSigningKey(sha256Constructor, credentials, shortDate, region, service) {
var cacheKey = shortDate + ":" + region + ":" + service + ":"
+ (credentials.accessKeyId + ":" + credentials.sessionToken);
var cacheKey = shortDate + ":" + region + ":" + service + ":" +
(credentials.accessKeyId + ":" + credentials.sessionToken);
if (cacheKey in signingKeyCache) {

@@ -40,6 +40,8 @@ return signingKeyCache[cacheKey];

}
return signingKeyCache[cacheKey] = new Promise(function (resolve, reject) {
return (signingKeyCache[cacheKey] = new Promise(function (resolve, reject) {
var keyPromise = Promise.resolve("AWS4" + credentials.secretAccessKey);
var _loop_1 = function (signable) {
keyPromise = keyPromise.then(function (intermediateKey) { return hmac(sha256Constructor, intermediateKey, signable); });
keyPromise = keyPromise.then(function (intermediateKey) {
return hmac(sha256Constructor, intermediateKey, signable);
});
keyPromise.catch(function () { });

@@ -55,3 +57,3 @@ };

});
});
}));
}

@@ -58,0 +60,0 @@ exports.getSigningKey = getSigningKey;

@@ -21,3 +21,3 @@ "use strict";

.trim()
.replace(/\s+/g, ' ');
.replace(/\s+/g, " ");
}

@@ -24,0 +24,0 @@ return canonical;

@@ -17,9 +17,15 @@ "use strict";

var value = query[key];
if (typeof value === 'string') {
if (typeof value === "string") {
serialized[key] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
}
else if (Array.isArray(value)) {
serialized[key] = value.slice(0).sort().reduce(function (encoded, value) { return encoded.concat([
encodeURIComponent(key) + "=" + encodeURIComponent(value)
]); }, []).join('&');
serialized[key] = value
.slice(0)
.sort()
.reduce(function (encoded, value) {
return encoded.concat([
encodeURIComponent(key) + "=" + encodeURIComponent(value)
]);
}, [])
.join("&");
}

@@ -34,5 +40,5 @@ };

.filter(function (serialized) { return serialized; }) // omit any falsy values
.join('&');
.join("&");
}
exports.getCanonicalQuery = getCanonicalQuery;
//# sourceMappingURL=getCanonicalQuery.js.map

@@ -24,7 +24,7 @@ "use strict";

if (!(body == undefined)) return [3 /*break*/, 1];
return [2 /*return*/, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'];
return [2 /*return*/, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"];
case 1:
if (!(typeof body === 'string'
|| ArrayBuffer.isView(body)
|| is_array_buffer_1.isArrayBuffer(body))) return [3 /*break*/, 3];
if (!(typeof body === "string" ||
ArrayBuffer.isView(body) ||
is_array_buffer_1.isArrayBuffer(body))) return [3 /*break*/, 3];
hashCtor = new hashConstructor();

@@ -31,0 +31,0 @@ hashCtor.update(body);

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

import { HeaderBag } from '@aws-sdk/types';
import { HeaderBag } from "@aws-sdk/types";
export declare function hasHeader(soughtHeader: string, headers: HeaderBag): boolean;

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

export * from './credentialDerivation';
export * from './SignatureV4';
export * from "./credentialDerivation";
export * from "./SignatureV4";

@@ -13,3 +13,3 @@ "use strict";

var lname = name.toLowerCase();
if (lname.substr(0, 6) === 'x-amz-') {
if (lname.substr(0, 6) === "x-amz-") {
query[name] = headers[name];

@@ -16,0 +16,0 @@ delete headers[name];

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

import { Credentials, DateInput, HashConstructor, HttpRequest, Provider, RequestPresigner, RequestSigner, RequestSigningArguments as RequestSigningArguments, SigningArguments, StringSigner } from '@aws-sdk/types';
import { Credentials, DateInput, HashConstructor, HttpRequest, Provider, RequestPresigner, RequestSigner, RequestSigningArguments, SigningArguments, StringSigner } from "@aws-sdk/types";
export interface SignatureV4Init {

@@ -50,3 +50,3 @@ /**

private readonly applyChecksum;
constructor({ applyChecksum, credentials, region, service, sha256, uriEscapePath, }: SignatureV4Init & SignatureV4CryptoInit);
constructor({ applyChecksum, credentials, region, service, sha256, uriEscapePath }: SignatureV4Init & SignatureV4CryptoInit);
presignRequest<StreamType>(originalRequest: HttpRequest<StreamType>, expiration: DateInput, options?: RequestSigningArguments): Promise<HttpRequest<StreamType>>;

@@ -53,0 +53,0 @@ sign(stringToSign: string, options?: SigningArguments): Promise<string>;

@@ -21,4 +21,5 @@ "use strict";

// default to true if applyChecksum isn't set
this.applyChecksum = typeof applyChecksum === 'boolean' ? applyChecksum : true;
if (typeof region === 'string') {
this.applyChecksum =
typeof applyChecksum === "boolean" ? applyChecksum : true;
if (typeof region === "string") {
var promisified_1 = Promise.resolve(region);

@@ -30,3 +31,3 @@ this.regionProvider = function () { return promisified_1; };

}
if (typeof credentials === 'object') {
if (typeof credentials === "object") {
var promisified_2 = Promise.resolve(credentials);

@@ -55,5 +56,5 @@ this.credentialProvider = function () { return promisified_2; };

if (ttl > constants_1.MAX_PRESIGNED_TTL) {
return [2 /*return*/, Promise.reject('Signature version 4 presigned URLs'
+ ' must have an expiration date less than one week in'
+ ' the future')];
return [2 /*return*/, Promise.reject("Signature version 4 presigned URLs" +
" must have an expiration date less than one week in" +
" the future")];
}

@@ -102,3 +103,3 @@ scope = credentialDerivation_1.createScope(shortDate, region, this.service);

_c = _d.sent(), region = _c[0], credentials = _c[1];
if (typeof toSign === 'string') {
if (typeof toSign === "string") {
return [2 /*return*/, this.signString(toSign, signingDate, region, credentials)];

@@ -157,6 +158,7 @@ }

signature = _b.sent();
request.headers[constants_1.AUTH_HEADER] = constants_1.ALGORITHM_IDENTIFIER + " "
+ ("Credential=" + credentials.accessKeyId + "/" + scope + ", ")
+ ("SignedHeaders=" + getCanonicalHeaderList(canonicalHeaders) + ", ")
+ ("Signature=" + signature);
request.headers[constants_1.AUTH_HEADER] =
constants_1.ALGORITHM_IDENTIFIER + " " +
("Credential=" + credentials.accessKeyId + "/" + scope + ", ") +
("SignedHeaders=" + getCanonicalHeaderList(canonicalHeaders) + ", ") +
("Signature=" + signature);
return [2 /*return*/, request];

@@ -169,3 +171,3 @@ }

var sortedHeaders = Object.keys(canonicalHeaders).sort();
return request.method + "\n" + this.getCanonicalPath(request) + "\n" + getCanonicalQuery_1.getCanonicalQuery(request) + "\n" + sortedHeaders.map(function (name) { return name + ":" + canonicalHeaders[name]; }).join('\n') + "\n\n" + sortedHeaders.join(';') + "\n" + payloadHash;
return request.method + "\n" + this.getCanonicalPath(request) + "\n" + getCanonicalQuery_1.getCanonicalQuery(request) + "\n" + sortedHeaders.map(function (name) { return name + ":" + canonicalHeaders[name]; }).join("\n") + "\n\n" + sortedHeaders.join(";") + "\n" + payloadHash;
};

@@ -191,4 +193,4 @@ SignatureV4.prototype.createStringToSign = function (longDate, credentialScope, canonicalRequest) {

if (this.uriEscapePath) {
var doubleEncoded = encodeURIComponent(path.replace(/^\//, ''));
return "/" + doubleEncoded.replace(/%2F/g, '/');
var doubleEncoded = encodeURIComponent(path.replace(/^\//, ""));
return "/" + doubleEncoded.replace(/%2F/g, "/");
}

@@ -224,6 +226,6 @@ return path;

function formatDate(now) {
var longDate = protocol_timestamp_1.iso8601(now).replace(/[\-:]/g, '');
var longDate = protocol_timestamp_1.iso8601(now).replace(/[\-:]/g, "");
return {
longDate: longDate,
shortDate: longDate.substr(0, 8),
shortDate: longDate.substr(0, 8)
};

@@ -234,3 +236,3 @@ }

.sort()
.join(';');
.join(";");
}

@@ -237,0 +239,0 @@ function getTtl(start, expiration) {

@@ -6,12 +6,24 @@ # Change Log

# [0.1.0-preview.4](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/signature-v4@0.1.0-preview.3...@aws-sdk/signature-v4@0.1.0-preview.4) (2019-04-19)
# [0.1.0-preview.5](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/signature-v4@0.1.0-preview.3...@aws-sdk/signature-v4@0.1.0-preview.5) (2019-07-12)
**Note:** Version bump only for package @aws-sdk/signature-v4
### Features
* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10c))
* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab))
# 0.1.0 (2019-04-19)
# [0.1.0-preview.4](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/signature-v4@0.1.0-preview.3...@aws-sdk/signature-v4@0.1.0-preview.4) (2019-04-19)
**Note:** Version bump only for package @aws-sdk/signature-v4
# [0.1.0-preview.3](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/signature-v4@0.1.0-preview.2...@aws-sdk/signature-v4@0.1.0-preview.3) (2019-03-27)
**Note:** Version bump only for package @aws-sdk/signature-v4
{
"name": "@aws-sdk/signature-v4",
"version": "0.1.0-preview.4",
"description": "A standalone implementation of the AWS Signature V4 request signing algorithm",
"main": "./build/index.js",
"scripts": {
"build": "node scripts/buildSuiteFixture.js && tsc",
"prepublishOnly": "npm run build",
"pretest": "tsc -p tsconfig.test.json",
"test": "jest --coverage --mapCoverage"
},
"author": {
"name": "AWS SDK for JavaScript Team",
"email": "aws-sdk-js@amazon.com",
"url": "https://aws.amazon.com/javascript/"
},
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/is-array-buffer": "^0.1.0-preview.1",
"@aws-sdk/protocol-timestamp": "^0.1.0-preview.3",
"@aws-sdk/types": "^0.1.0-preview.3",
"@aws-sdk/util-hex-encoding": "^0.1.0-preview.1",
"tslib": "^1.8.0"
},
"devDependencies": {
"@aws-crypto/sha256-js": "^0.1.0-preview.1",
"@aws-sdk/http-serialization": "^0.1.0-preview.3",
"@aws-sdk/util-buffer-from": "^0.1.0-preview.1",
"@types/jest": "^20.0.2",
"jest": "^20.0.4",
"typescript": "^3.0.0"
},
"types": "./build/index.d.ts"
"name": "@aws-sdk/signature-v4",
"version": "0.1.0-preview.5",
"description": "A standalone implementation of the AWS Signature V4 request signing algorithm",
"main": "./build/index.js",
"scripts": {
"build": "node scripts/buildSuiteFixture.js && tsc",
"prepublishOnly": "npm run build",
"pretest": "tsc -p tsconfig.test.json",
"test": "jest --coverage"
},
"author": {
"name": "AWS SDK for JavaScript Team",
"email": "",
"url": "https://aws.amazon.com/javascript/"
},
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/is-array-buffer": "^0.1.0-preview.2",
"@aws-sdk/protocol-timestamp": "^0.1.0-preview.4",
"@aws-sdk/types": "^0.1.0-preview.4",
"@aws-sdk/util-hex-encoding": "^0.1.0-preview.2",
"tslib": "^1.8.0"
},
"devDependencies": {
"@aws-crypto/sha256-js": "^0.1.0-preview.1",
"@aws-sdk/http-serialization": "^0.1.0-preview.4",
"@aws-sdk/util-buffer-from": "^0.1.0-preview.2",
"@types/jest": "^24.0.12",
"jest": "^24.7.1",
"typescript": "~3.4.0"
},
"types": "./build/index.d.ts"
}
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": [
"es5",
"es2015.promise",
"es2015.collection"
],
"declaration": true,
"sourceMap": true,
"strict": true,
"stripInternal": true,
"rootDir": "./src",
"outDir": "./build",
"importHelpers": true,
"noEmitHelpers": true,
"noUnusedLocals": true
}
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": ["es5", "es2015.promise", "es2015.collection"],
"declaration": true,
"sourceMap": true,
"strict": true,
"stripInternal": true,
"rootDir": "./src",
"outDir": "./build",
"importHelpers": true,
"noEmitHelpers": true,
"noUnusedLocals": true
}
}

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 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

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