@aws-sdk/signature-v4
Advanced tools
Comparing version 3.54.1 to 3.55.0
@@ -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,3 +131,3 @@ | ||
${credentialScope} | ||
${util_hex_encoding_1.toHex(hashedRequest)}`; | ||
${(0, util_hex_encoding_1.toHex)(hashedRequest)}`; | ||
} | ||
@@ -159,6 +159,6 @@ getCanonicalPath({ 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); | ||
} | ||
@@ -168,3 +168,3 @@ } | ||
const formatDate = (now) => { | ||
const longDate = utilDate_1.iso8601(now).replace(/[\-:]/g, ""); | ||
const longDate = (0, utilDate_1.iso8601)(now).replace(/[\-:]/g, ""); | ||
return { | ||
@@ -171,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"); |
@@ -10,4 +10,4 @@ import { __assign, __read, __rest, __spreadArray } from "tslib"; | ||
var param = query[paramName]; | ||
return __assign(__assign({}, carry), (_a = {}, _a[paramName] = Array.isArray(param) ? __spreadArray([], __read(param)) : param, _a)); | ||
return __assign(__assign({}, carry), (_a = {}, _a[paramName] = Array.isArray(param) ? __spreadArray([], __read(param), false) : param, _a)); | ||
}, {}); | ||
}; |
@@ -7,3 +7,3 @@ import { __awaiter, __generator, __values } from "tslib"; | ||
export var createScope = function (shortDate, region, service) { | ||
return shortDate + "/" + region + "/" + service + "/" + KEY_TYPE_IDENTIFIER; | ||
return "".concat(shortDate, "/").concat(region, "/").concat(service, "/").concat(KEY_TYPE_IDENTIFIER); | ||
}; | ||
@@ -18,3 +18,3 @@ export var getSigningKey = function (sha256Constructor, credentials, shortDate, region, service) { return __awaiter(void 0, void 0, void 0, function () { | ||
credsHash = _d.sent(); | ||
cacheKey = shortDate + ":" + region + ":" + service + ":" + toHex(credsHash) + ":" + credentials.sessionToken; | ||
cacheKey = "".concat(shortDate, ":").concat(region, ":").concat(service, ":").concat(toHex(credsHash), ":").concat(credentials.sessionToken); | ||
if (cacheKey in signingKeyCache) { | ||
@@ -27,3 +27,3 @@ return [2, signingKeyCache[cacheKey]]; | ||
} | ||
key = "AWS4" + credentials.secretAccessKey; | ||
key = "AWS4".concat(credentials.secretAccessKey); | ||
_d.label = 2; | ||
@@ -30,0 +30,0 @@ case 2: |
@@ -16,3 +16,3 @@ import { __values } from "tslib"; | ||
if (typeof value === "string") { | ||
serialized[key] = escapeUri(key) + "=" + escapeUri(value); | ||
serialized[key] = "".concat(escapeUri(key), "=").concat(escapeUri(value)); | ||
} | ||
@@ -23,3 +23,3 @@ else if (Array.isArray(value)) { | ||
.sort() | ||
.reduce(function (encoded, value) { return encoded.concat([escapeUri(key) + "=" + escapeUri(value)]); }, []) | ||
.reduce(function (encoded, value) { return encoded.concat(["".concat(escapeUri(key), "=").concat(escapeUri(value))]); }, []) | ||
.join("&"); | ||
@@ -26,0 +26,0 @@ } |
@@ -53,3 +53,3 @@ import { __awaiter, __generator, __values } from "tslib"; | ||
request.query[ALGORITHM_QUERY_PARAM] = ALGORITHM_IDENTIFIER; | ||
request.query[CREDENTIAL_QUERY_PARAM] = credentials.accessKeyId + "/" + scope; | ||
request.query[CREDENTIAL_QUERY_PARAM] = "".concat(credentials.accessKeyId, "/").concat(scope); | ||
request.query[AMZ_DATE_QUERY_PARAM] = longDate; | ||
@@ -200,6 +200,6 @@ request.query[EXPIRES_QUERY_PARAM] = expiresIn.toString(10); | ||
request.headers[AUTH_HEADER] = | ||
ALGORITHM_IDENTIFIER + " " + | ||
("Credential=" + credentials.accessKeyId + "/" + scope + ", ") + | ||
("SignedHeaders=" + getCanonicalHeaderList(canonicalHeaders) + ", ") + | ||
("Signature=" + signature); | ||
"".concat(ALGORITHM_IDENTIFIER, " ") + | ||
"Credential=".concat(credentials.accessKeyId, "/").concat(scope, ", ") + | ||
"SignedHeaders=".concat(getCanonicalHeaderList(canonicalHeaders), ", ") + | ||
"Signature=".concat(signature); | ||
return [2, request]; | ||
@@ -212,3 +212,3 @@ } | ||
var sortedHeaders = Object.keys(canonicalHeaders).sort(); | ||
return request.method + "\n" + this.getCanonicalPath(request) + "\n" + getCanonicalQuery(request) + "\n" + sortedHeaders.map(function (name) { return name + ":" + canonicalHeaders[name]; }).join("\n") + "\n\n" + sortedHeaders.join(";") + "\n" + payloadHash; | ||
return "".concat(request.method, "\n").concat(this.getCanonicalPath(request), "\n").concat(getCanonicalQuery(request), "\n").concat(sortedHeaders.map(function (name) { return "".concat(name, ":").concat(canonicalHeaders[name]); }).join("\n"), "\n\n").concat(sortedHeaders.join(";"), "\n").concat(payloadHash); | ||
}; | ||
@@ -226,3 +226,3 @@ SignatureV4.prototype.createStringToSign = function (longDate, credentialScope, canonicalRequest) { | ||
hashedRequest = _a.sent(); | ||
return [2, ALGORITHM_IDENTIFIER + "\n" + longDate + "\n" + credentialScope + "\n" + toHex(hashedRequest)]; | ||
return [2, "".concat(ALGORITHM_IDENTIFIER, "\n").concat(longDate, "\n").concat(credentialScope, "\n").concat(toHex(hashedRequest))]; | ||
} | ||
@@ -259,3 +259,3 @@ }); | ||
} | ||
var normalizedPath = "" + ((path === null || path === void 0 ? void 0 : path.startsWith("/")) ? "/" : "") + normalizedPathSegments.join("/") + (normalizedPathSegments.length > 0 && (path === null || path === void 0 ? void 0 : path.endsWith("/")) ? "/" : ""); | ||
var normalizedPath = "".concat((path === null || path === void 0 ? void 0 : path.startsWith("/")) ? "/" : "").concat(normalizedPathSegments.join("/")).concat(normalizedPathSegments.length > 0 && (path === null || path === void 0 ? void 0 : path.endsWith("/")) ? "/" : ""); | ||
var doubleEncoded = encodeURIComponent(normalizedPath); | ||
@@ -262,0 +262,0 @@ return doubleEncoded.replace(/%2F/g, "/"); |
{ | ||
"name": "@aws-sdk/signature-v4", | ||
"version": "3.54.1", | ||
"version": "3.55.0", | ||
"description": "A standalone implementation of the AWS Signature V4 request signing algorithm", | ||
@@ -23,12 +23,12 @@ "main": "./dist-cjs/index.js", | ||
"dependencies": { | ||
"@aws-sdk/is-array-buffer": "3.52.0", | ||
"@aws-sdk/types": "3.54.1", | ||
"@aws-sdk/util-hex-encoding": "3.52.0", | ||
"@aws-sdk/util-uri-escape": "3.52.0", | ||
"tslib": "^2.3.0" | ||
"@aws-sdk/is-array-buffer": "3.55.0", | ||
"@aws-sdk/types": "3.55.0", | ||
"@aws-sdk/util-hex-encoding": "3.55.0", | ||
"@aws-sdk/util-uri-escape": "3.55.0", | ||
"tslib": "^2.3.1" | ||
}, | ||
"devDependencies": { | ||
"@aws-crypto/sha256-js": "2.0.0", | ||
"@aws-sdk/protocol-http": "3.54.1", | ||
"@aws-sdk/util-buffer-from": "3.52.0", | ||
"@aws-sdk/protocol-http": "3.55.0", | ||
"@aws-sdk/util-buffer-from": "3.55.0", | ||
"@tsconfig/recommended": "1.0.1", | ||
@@ -39,3 +39,3 @@ "concurrently": "7.0.0", | ||
"typedoc": "0.19.2", | ||
"typescript": "~4.3.5" | ||
"typescript": "~4.6.2" | ||
}, | ||
@@ -42,0 +42,0 @@ "engines": { |
Sorry, the diff of this file is too big to display
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
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
192524
2291
+ Added@aws-sdk/is-array-buffer@3.55.0(transitive)
+ Added@aws-sdk/types@3.55.0(transitive)
+ Added@aws-sdk/util-hex-encoding@3.55.0(transitive)
+ Added@aws-sdk/util-uri-escape@3.55.0(transitive)
- Removed@aws-sdk/is-array-buffer@3.52.0(transitive)
- Removed@aws-sdk/types@3.54.1(transitive)
- Removed@aws-sdk/util-hex-encoding@3.52.0(transitive)
- Removed@aws-sdk/util-uri-escape@3.52.0(transitive)
Updated@aws-sdk/types@3.55.0
Updatedtslib@^2.3.1