@trivikr-test/signature-v4
Advanced tools
Comparing version 3.52.0 to 3.55.0-node.cjs
@@ -7,3 +7,3 @@ "use strict"; | ||
headers: { ...headers }, | ||
query: query ? exports.cloneQuery(query) : undefined, | ||
query: query ? (0, exports.cloneQuery)(query) : undefined, | ||
}); | ||
@@ -10,0 +10,0 @@ exports.cloneRequest = cloneRequest; |
@@ -12,3 +12,3 @@ "use strict"; | ||
const credsHash = await hmac(sha256Constructor, credentials.secretAccessKey, credentials.accessKeyId); | ||
const cacheKey = `${shortDate}:${region}:${service}:${util_hex_encoding_1.toHex(credsHash)}:${credentials.sessionToken}`; | ||
const cacheKey = `${shortDate}:${region}:${service}:${(0, util_hex_encoding_1.toHex)(credsHash)}:${credentials.sessionToken}`; | ||
if (cacheKey in signingKeyCache) { | ||
@@ -15,0 +15,0 @@ return signingKeyCache[cacheKey]; |
@@ -16,3 +16,3 @@ "use strict"; | ||
if (typeof value === "string") { | ||
serialized[key] = `${util_uri_escape_1.escapeUri(key)}=${util_uri_escape_1.escapeUri(value)}`; | ||
serialized[key] = `${(0, util_uri_escape_1.escapeUri)(key)}=${(0, util_uri_escape_1.escapeUri)(value)}`; | ||
} | ||
@@ -23,3 +23,3 @@ else if (Array.isArray(value)) { | ||
.sort() | ||
.reduce((encoded, value) => encoded.concat([`${util_uri_escape_1.escapeUri(key)}=${util_uri_escape_1.escapeUri(value)}`]), []) | ||
.reduce((encoded, value) => encoded.concat([`${(0, util_uri_escape_1.escapeUri)(key)}=${(0, util_uri_escape_1.escapeUri)(value)}`]), []) | ||
.join("&"); | ||
@@ -26,0 +26,0 @@ } |
@@ -16,6 +16,6 @@ "use strict"; | ||
} | ||
else if (typeof body === "string" || ArrayBuffer.isView(body) || is_array_buffer_1.isArrayBuffer(body)) { | ||
else if (typeof body === "string" || ArrayBuffer.isView(body) || (0, is_array_buffer_1.isArrayBuffer)(body)) { | ||
const hashCtor = new hashConstructor(); | ||
hashCtor.update(body); | ||
return util_hex_encoding_1.toHex(await hashCtor.digest()); | ||
return (0, util_hex_encoding_1.toHex)(await hashCtor.digest()); | ||
} | ||
@@ -22,0 +22,0 @@ return constants_1.UNSIGNED_PAYLOAD; |
@@ -7,3 +7,3 @@ "use strict"; | ||
var _a; | ||
const { headers, query = {} } = typeof request.clone === "function" ? request.clone() : cloneRequest_1.cloneRequest(request); | ||
const { headers, query = {} } = typeof request.clone === "function" ? request.clone() : (0, cloneRequest_1.cloneRequest)(request); | ||
for (const name of Object.keys(headers)) { | ||
@@ -10,0 +10,0 @@ const lname = name.toLowerCase(); |
@@ -7,3 +7,3 @@ "use strict"; | ||
const prepareRequest = (request) => { | ||
request = typeof request.clone === "function" ? request.clone() : cloneRequest_1.cloneRequest(request); | ||
request = typeof request.clone === "function" ? request.clone() : (0, cloneRequest_1.cloneRequest)(request); | ||
for (const headerName of Object.keys(request.headers)) { | ||
@@ -10,0 +10,0 @@ if (constants_1.GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) { |
@@ -21,4 +21,4 @@ "use strict"; | ||
this.applyChecksum = typeof applyChecksum === "boolean" ? applyChecksum : true; | ||
this.regionProvider = normalizeProvider_1.normalizeRegionProvider(region); | ||
this.credentialProvider = normalizeProvider_1.normalizeCredentialsProvider(credentials); | ||
this.regionProvider = (0, normalizeProvider_1.normalizeRegionProvider)(region); | ||
this.credentialProvider = (0, normalizeProvider_1.normalizeCredentialsProvider)(credentials); | ||
} | ||
@@ -33,4 +33,4 @@ async presign(originalRequest, options = {}) { | ||
} | ||
const scope = credentialDerivation_1.createScope(shortDate, region, signingService !== null && signingService !== void 0 ? signingService : this.service); | ||
const request = moveHeadersToQuery_1.moveHeadersToQuery(prepareRequest_1.prepareRequest(originalRequest), { unhoistableHeaders }); | ||
const scope = (0, credentialDerivation_1.createScope)(shortDate, region, signingService !== null && signingService !== void 0 ? signingService : this.service); | ||
const request = (0, moveHeadersToQuery_1.moveHeadersToQuery)((0, prepareRequest_1.prepareRequest)(originalRequest), { unhoistableHeaders }); | ||
if (credentials.sessionToken) { | ||
@@ -43,5 +43,5 @@ request.query[constants_1.TOKEN_QUERY_PARAM] = credentials.sessionToken; | ||
request.query[constants_1.EXPIRES_QUERY_PARAM] = expiresIn.toString(10); | ||
const canonicalHeaders = getCanonicalHeaders_1.getCanonicalHeaders(request, unsignableHeaders, signableHeaders); | ||
const canonicalHeaders = (0, getCanonicalHeaders_1.getCanonicalHeaders)(request, unsignableHeaders, signableHeaders); | ||
request.query[constants_1.SIGNED_HEADERS_QUERY_PARAM] = getCanonicalHeaderList(canonicalHeaders); | ||
request.query[constants_1.SIGNATURE_QUERY_PARAM] = await this.getSignature(longDate, scope, this.getSigningKey(credentials, region, shortDate, signingService), this.createCanonicalRequest(request, canonicalHeaders, await getPayloadHash_1.getPayloadHash(originalRequest, this.sha256))); | ||
request.query[constants_1.SIGNATURE_QUERY_PARAM] = await this.getSignature(longDate, scope, this.getSigningKey(credentials, region, shortDate, signingService), this.createCanonicalRequest(request, canonicalHeaders, await (0, getPayloadHash_1.getPayloadHash)(originalRequest, this.sha256))); | ||
return request; | ||
@@ -63,7 +63,7 @@ } | ||
const { shortDate, longDate } = formatDate(signingDate); | ||
const scope = credentialDerivation_1.createScope(shortDate, region, signingService !== null && signingService !== void 0 ? signingService : this.service); | ||
const hashedPayload = await getPayloadHash_1.getPayloadHash({ headers: {}, body: payload }, this.sha256); | ||
const scope = (0, credentialDerivation_1.createScope)(shortDate, region, signingService !== null && signingService !== void 0 ? signingService : this.service); | ||
const hashedPayload = await (0, getPayloadHash_1.getPayloadHash)({ headers: {}, body: payload }, this.sha256); | ||
const hash = new this.sha256(); | ||
hash.update(headers); | ||
const hashedHeaders = util_hex_encoding_1.toHex(await hash.digest()); | ||
const hashedHeaders = (0, util_hex_encoding_1.toHex)(await hash.digest()); | ||
const stringToSign = [ | ||
@@ -85,3 +85,3 @@ constants_1.EVENT_ALGORITHM_IDENTIFIER, | ||
hash.update(stringToSign); | ||
return util_hex_encoding_1.toHex(await hash.digest()); | ||
return (0, util_hex_encoding_1.toHex)(await hash.digest()); | ||
} | ||
@@ -91,5 +91,5 @@ async signRequest(requestToSign, { signingDate = new Date(), signableHeaders, unsignableHeaders, signingRegion, signingService, } = {}) { | ||
const region = signingRegion !== null && signingRegion !== void 0 ? signingRegion : (await this.regionProvider()); | ||
const request = prepareRequest_1.prepareRequest(requestToSign); | ||
const request = (0, prepareRequest_1.prepareRequest)(requestToSign); | ||
const { longDate, shortDate } = formatDate(signingDate); | ||
const scope = credentialDerivation_1.createScope(shortDate, region, signingService !== null && signingService !== void 0 ? signingService : this.service); | ||
const scope = (0, credentialDerivation_1.createScope)(shortDate, region, signingService !== null && signingService !== void 0 ? signingService : this.service); | ||
request.headers[constants_1.AMZ_DATE_HEADER] = longDate; | ||
@@ -99,7 +99,7 @@ if (credentials.sessionToken) { | ||
} | ||
const payloadHash = await getPayloadHash_1.getPayloadHash(request, this.sha256); | ||
if (!headerUtil_1.hasHeader(constants_1.SHA256_HEADER, request.headers) && this.applyChecksum) { | ||
const payloadHash = await (0, getPayloadHash_1.getPayloadHash)(request, this.sha256); | ||
if (!(0, headerUtil_1.hasHeader)(constants_1.SHA256_HEADER, request.headers) && this.applyChecksum) { | ||
request.headers[constants_1.SHA256_HEADER] = payloadHash; | ||
} | ||
const canonicalHeaders = getCanonicalHeaders_1.getCanonicalHeaders(request, unsignableHeaders, signableHeaders); | ||
const canonicalHeaders = (0, getCanonicalHeaders_1.getCanonicalHeaders)(request, unsignableHeaders, signableHeaders); | ||
const signature = await this.getSignature(longDate, scope, this.getSigningKey(credentials, region, shortDate, signingService), this.createCanonicalRequest(request, canonicalHeaders, payloadHash)); | ||
@@ -117,3 +117,3 @@ request.headers[constants_1.AUTH_HEADER] = | ||
${this.getCanonicalPath(request)} | ||
${getCanonicalQuery_1.getCanonicalQuery(request)} | ||
${(0, getCanonicalQuery_1.getCanonicalQuery)(request)} | ||
${sortedHeaders.map((name) => `${name}:${canonicalHeaders[name]}`).join("\n")} | ||
@@ -131,8 +131,22 @@ | ||
${credentialScope} | ||
${util_hex_encoding_1.toHex(hashedRequest)}`; | ||
${(0, util_hex_encoding_1.toHex)(hashedRequest)}`; | ||
} | ||
getCanonicalPath({ path }) { | ||
if (this.uriEscapePath) { | ||
const doubleEncoded = encodeURIComponent(path.replace(/^\//, "")); | ||
return `/${doubleEncoded.replace(/%2F/g, "/")}`; | ||
const normalizedPathSegments = []; | ||
for (const pathSegment of path.split("/")) { | ||
if ((pathSegment === null || pathSegment === void 0 ? void 0 : pathSegment.length) === 0) | ||
continue; | ||
if (pathSegment === ".") | ||
continue; | ||
if (pathSegment === "..") { | ||
normalizedPathSegments.pop(); | ||
} | ||
else { | ||
normalizedPathSegments.push(pathSegment); | ||
} | ||
} | ||
const normalizedPath = `${(path === null || path === void 0 ? void 0 : path.startsWith("/")) ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && (path === null || path === void 0 ? void 0 : path.endsWith("/")) ? "/" : ""}`; | ||
const doubleEncoded = encodeURIComponent(normalizedPath); | ||
return doubleEncoded.replace(/%2F/g, "/"); | ||
} | ||
@@ -145,6 +159,6 @@ return path; | ||
hash.update(stringToSign); | ||
return util_hex_encoding_1.toHex(await hash.digest()); | ||
return (0, util_hex_encoding_1.toHex)(await hash.digest()); | ||
} | ||
getSigningKey(credentials, region, shortDate, service) { | ||
return credentialDerivation_1.getSigningKey(this.sha256, credentials, shortDate, region, service || this.service); | ||
return (0, credentialDerivation_1.getSigningKey)(this.sha256, credentials, shortDate, region, service || this.service); | ||
} | ||
@@ -154,3 +168,3 @@ } | ||
const formatDate = (now) => { | ||
const longDate = utilDate_1.iso8601(now).replace(/[\-:]/g, ""); | ||
const longDate = (0, utilDate_1.iso8601)(now).replace(/[\-:]/g, ""); | ||
return { | ||
@@ -157,0 +171,0 @@ longDate, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toDate = exports.iso8601 = void 0; | ||
const iso8601 = (time) => exports.toDate(time) | ||
const iso8601 = (time) => (0, exports.toDate)(time) | ||
.toISOString() | ||
@@ -6,0 +6,0 @@ .replace(/\.\d{3}Z$/, "Z"); |
{ | ||
"name": "@trivikr-test/signature-v4", | ||
"version": "3.52.0", | ||
"version": "3.55.0-node.cjs", | ||
"description": "A standalone implementation of the AWS Signature V4 request signing algorithm", | ||
"main": "./dist-cjs/index.js", | ||
"module": "./dist-es/index.js", | ||
"types": "./dist-types/index.d.ts", | ||
"scripts": { | ||
@@ -23,12 +21,12 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", | ||
"dependencies": { | ||
"@trivikr-test/is-array-buffer": "3.52.0", | ||
"@trivikr-test/types": "3.52.0", | ||
"@trivikr-test/util-hex-encoding": "3.52.0", | ||
"@trivikr-test/util-uri-escape": "3.52.0", | ||
"tslib": "^2.3.0" | ||
"@trivikr-test/is-array-buffer": "3.55.0-node.cjs", | ||
"@trivikr-test/types": "3.55.0-node.cjs", | ||
"@trivikr-test/util-hex-encoding": "3.55.0-node.cjs", | ||
"@trivikr-test/util-uri-escape": "3.55.0-node.cjs", | ||
"tslib": "^2.3.1" | ||
}, | ||
"devDependencies": { | ||
"@aws-crypto/sha256-js": "2.0.0", | ||
"@trivikr-test/protocol-http": "3.52.0", | ||
"@trivikr-test/util-buffer-from": "3.52.0", | ||
"@trivikr-test/protocol-http": "3.55.0-node.cjs", | ||
"@trivikr-test/util-buffer-from": "3.55.0-node.cjs", | ||
"@tsconfig/recommended": "1.0.1", | ||
@@ -39,3 +37,3 @@ "concurrently": "7.0.0", | ||
"typedoc": "0.19.2", | ||
"typescript": "~4.3.5" | ||
"typescript": "~4.6.2" | ||
}, | ||
@@ -53,3 +51,3 @@ "engines": { | ||
"files": [ | ||
"dist-*" | ||
"dist-cjs" | ||
], | ||
@@ -56,0 +54,0 @@ "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages/signature-v4", |
@@ -1,4 +0,1 @@ | ||
# @aws-sdk/signature-v4 | ||
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/signature-v4/latest.svg)](https://www.npmjs.com/package/@aws-sdk/signature-v4) | ||
[![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/signature-v4.svg)](https://www.npmjs.com/package/@aws-sdk/signature-v4) | ||
Please refer [README.md](https://github.com/aws/aws-sdk-js-v3/blob/v3.55.0/packages/signature-v4/README.md) for v3.55.0. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52807
17
875
2
2
+ Added@trivikr-test/is-array-buffer@3.55.0-node.cjs(transitive)
+ Added@trivikr-test/types@3.55.0-node.cjs(transitive)
+ Added@trivikr-test/util-hex-encoding@3.55.0-node.cjs(transitive)
+ Added@trivikr-test/util-uri-escape@3.55.0-node.cjs(transitive)
- Removed@trivikr-test/is-array-buffer@3.52.0(transitive)
- Removed@trivikr-test/types@3.52.0(transitive)
- Removed@trivikr-test/util-hex-encoding@3.52.0(transitive)
- Removed@trivikr-test/util-uri-escape@3.52.0(transitive)
Updatedtslib@^2.3.1