include node_modules so release .zip is deployable
This commit is contained in:
+194
@@ -0,0 +1,194 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SignatureV4 = void 0;
|
||||
const eventstream_codec_1 = require("@smithy/eventstream-codec");
|
||||
const util_hex_encoding_1 = require("@smithy/util-hex-encoding");
|
||||
const util_middleware_1 = require("@smithy/util-middleware");
|
||||
const util_utf8_1 = require("@smithy/util-utf8");
|
||||
const constants_1 = require("./constants");
|
||||
const credentialDerivation_1 = require("./credentialDerivation");
|
||||
const getCanonicalHeaders_1 = require("./getCanonicalHeaders");
|
||||
const getCanonicalQuery_1 = require("./getCanonicalQuery");
|
||||
const getPayloadHash_1 = require("./getPayloadHash");
|
||||
const headerUtil_1 = require("./headerUtil");
|
||||
const moveHeadersToQuery_1 = require("./moveHeadersToQuery");
|
||||
const prepareRequest_1 = require("./prepareRequest");
|
||||
const utilDate_1 = require("./utilDate");
|
||||
class SignatureV4 {
|
||||
constructor({ applyChecksum, credentials, region, service, sha256, uriEscapePath = true, }) {
|
||||
this.headerMarshaller = new eventstream_codec_1.HeaderMarshaller(util_utf8_1.toUtf8, util_utf8_1.fromUtf8);
|
||||
this.service = service;
|
||||
this.sha256 = sha256;
|
||||
this.uriEscapePath = uriEscapePath;
|
||||
this.applyChecksum = typeof applyChecksum === "boolean" ? applyChecksum : true;
|
||||
this.regionProvider = (0, util_middleware_1.normalizeProvider)(region);
|
||||
this.credentialProvider = (0, util_middleware_1.normalizeProvider)(credentials);
|
||||
}
|
||||
async presign(originalRequest, options = {}) {
|
||||
const { signingDate = new Date(), expiresIn = 3600, unsignableHeaders, unhoistableHeaders, signableHeaders, signingRegion, signingService, } = options;
|
||||
const credentials = await this.credentialProvider();
|
||||
this.validateResolvedCredentials(credentials);
|
||||
const region = signingRegion !== null && signingRegion !== void 0 ? signingRegion : (await this.regionProvider());
|
||||
const { longDate, shortDate } = formatDate(signingDate);
|
||||
if (expiresIn > constants_1.MAX_PRESIGNED_TTL) {
|
||||
return Promise.reject("Signature version 4 presigned URLs" + " must have an expiration date less than one week in" + " the future");
|
||||
}
|
||||
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) {
|
||||
request.query[constants_1.TOKEN_QUERY_PARAM] = credentials.sessionToken;
|
||||
}
|
||||
request.query[constants_1.ALGORITHM_QUERY_PARAM] = constants_1.ALGORITHM_IDENTIFIER;
|
||||
request.query[constants_1.CREDENTIAL_QUERY_PARAM] = `${credentials.accessKeyId}/${scope}`;
|
||||
request.query[constants_1.AMZ_DATE_QUERY_PARAM] = longDate;
|
||||
request.query[constants_1.EXPIRES_QUERY_PARAM] = expiresIn.toString(10);
|
||||
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 (0, getPayloadHash_1.getPayloadHash)(originalRequest, this.sha256)));
|
||||
return request;
|
||||
}
|
||||
async sign(toSign, options) {
|
||||
if (typeof toSign === "string") {
|
||||
return this.signString(toSign, options);
|
||||
}
|
||||
else if (toSign.headers && toSign.payload) {
|
||||
return this.signEvent(toSign, options);
|
||||
}
|
||||
else if (toSign.message) {
|
||||
return this.signMessage(toSign, options);
|
||||
}
|
||||
else {
|
||||
return this.signRequest(toSign, options);
|
||||
}
|
||||
}
|
||||
async signEvent({ headers, payload }, { signingDate = new Date(), priorSignature, signingRegion, signingService }) {
|
||||
const region = signingRegion !== null && signingRegion !== void 0 ? signingRegion : (await this.regionProvider());
|
||||
const { shortDate, longDate } = formatDate(signingDate);
|
||||
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 = (0, util_hex_encoding_1.toHex)(await hash.digest());
|
||||
const stringToSign = [
|
||||
constants_1.EVENT_ALGORITHM_IDENTIFIER,
|
||||
longDate,
|
||||
scope,
|
||||
priorSignature,
|
||||
hashedHeaders,
|
||||
hashedPayload,
|
||||
].join("\n");
|
||||
return this.signString(stringToSign, { signingDate, signingRegion: region, signingService });
|
||||
}
|
||||
async signMessage(signableMessage, { signingDate = new Date(), signingRegion, signingService }) {
|
||||
const promise = this.signEvent({
|
||||
headers: this.headerMarshaller.format(signableMessage.message.headers),
|
||||
payload: signableMessage.message.body,
|
||||
}, {
|
||||
signingDate,
|
||||
signingRegion,
|
||||
signingService,
|
||||
priorSignature: signableMessage.priorSignature,
|
||||
});
|
||||
return promise.then((signature) => {
|
||||
return { message: signableMessage.message, signature };
|
||||
});
|
||||
}
|
||||
async signString(stringToSign, { signingDate = new Date(), signingRegion, signingService } = {}) {
|
||||
const credentials = await this.credentialProvider();
|
||||
this.validateResolvedCredentials(credentials);
|
||||
const region = signingRegion !== null && signingRegion !== void 0 ? signingRegion : (await this.regionProvider());
|
||||
const { shortDate } = formatDate(signingDate);
|
||||
const hash = new this.sha256(await this.getSigningKey(credentials, region, shortDate, signingService));
|
||||
hash.update((0, util_utf8_1.toUint8Array)(stringToSign));
|
||||
return (0, util_hex_encoding_1.toHex)(await hash.digest());
|
||||
}
|
||||
async signRequest(requestToSign, { signingDate = new Date(), signableHeaders, unsignableHeaders, signingRegion, signingService, } = {}) {
|
||||
const credentials = await this.credentialProvider();
|
||||
this.validateResolvedCredentials(credentials);
|
||||
const region = signingRegion !== null && signingRegion !== void 0 ? signingRegion : (await this.regionProvider());
|
||||
const request = (0, prepareRequest_1.prepareRequest)(requestToSign);
|
||||
const { longDate, shortDate } = formatDate(signingDate);
|
||||
const scope = (0, credentialDerivation_1.createScope)(shortDate, region, signingService !== null && signingService !== void 0 ? signingService : this.service);
|
||||
request.headers[constants_1.AMZ_DATE_HEADER] = longDate;
|
||||
if (credentials.sessionToken) {
|
||||
request.headers[constants_1.TOKEN_HEADER] = credentials.sessionToken;
|
||||
}
|
||||
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 = (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));
|
||||
request.headers[constants_1.AUTH_HEADER] =
|
||||
`${constants_1.ALGORITHM_IDENTIFIER} ` +
|
||||
`Credential=${credentials.accessKeyId}/${scope}, ` +
|
||||
`SignedHeaders=${getCanonicalHeaderList(canonicalHeaders)}, ` +
|
||||
`Signature=${signature}`;
|
||||
return request;
|
||||
}
|
||||
createCanonicalRequest(request, canonicalHeaders, payloadHash) {
|
||||
const sortedHeaders = Object.keys(canonicalHeaders).sort();
|
||||
return `${request.method}
|
||||
${this.getCanonicalPath(request)}
|
||||
${(0, getCanonicalQuery_1.getCanonicalQuery)(request)}
|
||||
${sortedHeaders.map((name) => `${name}:${canonicalHeaders[name]}`).join("\n")}
|
||||
|
||||
${sortedHeaders.join(";")}
|
||||
${payloadHash}`;
|
||||
}
|
||||
async createStringToSign(longDate, credentialScope, canonicalRequest) {
|
||||
const hash = new this.sha256();
|
||||
hash.update((0, util_utf8_1.toUint8Array)(canonicalRequest));
|
||||
const hashedRequest = await hash.digest();
|
||||
return `${constants_1.ALGORITHM_IDENTIFIER}
|
||||
${longDate}
|
||||
${credentialScope}
|
||||
${(0, util_hex_encoding_1.toHex)(hashedRequest)}`;
|
||||
}
|
||||
getCanonicalPath({ path }) {
|
||||
if (this.uriEscapePath) {
|
||||
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, "/");
|
||||
}
|
||||
return path;
|
||||
}
|
||||
async getSignature(longDate, credentialScope, keyPromise, canonicalRequest) {
|
||||
const stringToSign = await this.createStringToSign(longDate, credentialScope, canonicalRequest);
|
||||
const hash = new this.sha256(await keyPromise);
|
||||
hash.update((0, util_utf8_1.toUint8Array)(stringToSign));
|
||||
return (0, util_hex_encoding_1.toHex)(await hash.digest());
|
||||
}
|
||||
getSigningKey(credentials, region, shortDate, service) {
|
||||
return (0, credentialDerivation_1.getSigningKey)(this.sha256, credentials, shortDate, region, service || this.service);
|
||||
}
|
||||
validateResolvedCredentials(credentials) {
|
||||
if (typeof credentials !== "object" ||
|
||||
typeof credentials.accessKeyId !== "string" ||
|
||||
typeof credentials.secretAccessKey !== "string") {
|
||||
throw new Error("Resolved credential object is not valid");
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.SignatureV4 = SignatureV4;
|
||||
const formatDate = (now) => {
|
||||
const longDate = (0, utilDate_1.iso8601)(now).replace(/[\-:]/g, "");
|
||||
return {
|
||||
longDate,
|
||||
shortDate: longDate.slice(0, 8),
|
||||
};
|
||||
};
|
||||
const getCanonicalHeaderList = (headers) => Object.keys(headers).sort().join(";");
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cloneQuery = exports.cloneRequest = void 0;
|
||||
const cloneRequest = ({ headers, query, ...rest }) => ({
|
||||
...rest,
|
||||
headers: { ...headers },
|
||||
query: query ? (0, exports.cloneQuery)(query) : undefined,
|
||||
});
|
||||
exports.cloneRequest = cloneRequest;
|
||||
const cloneQuery = (query) => Object.keys(query).reduce((carry, paramName) => {
|
||||
const param = query[paramName];
|
||||
return {
|
||||
...carry,
|
||||
[paramName]: Array.isArray(param) ? [...param] : param,
|
||||
};
|
||||
}, {});
|
||||
exports.cloneQuery = cloneQuery;
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MAX_PRESIGNED_TTL = exports.KEY_TYPE_IDENTIFIER = exports.MAX_CACHE_SIZE = exports.UNSIGNED_PAYLOAD = exports.EVENT_ALGORITHM_IDENTIFIER = exports.ALGORITHM_IDENTIFIER_V4A = exports.ALGORITHM_IDENTIFIER = exports.UNSIGNABLE_PATTERNS = exports.SEC_HEADER_PATTERN = exports.PROXY_HEADER_PATTERN = exports.ALWAYS_UNSIGNABLE_HEADERS = exports.HOST_HEADER = exports.TOKEN_HEADER = exports.SHA256_HEADER = exports.SIGNATURE_HEADER = exports.GENERATED_HEADERS = exports.DATE_HEADER = exports.AMZ_DATE_HEADER = exports.AUTH_HEADER = exports.REGION_SET_PARAM = exports.TOKEN_QUERY_PARAM = exports.SIGNATURE_QUERY_PARAM = exports.EXPIRES_QUERY_PARAM = exports.SIGNED_HEADERS_QUERY_PARAM = exports.AMZ_DATE_QUERY_PARAM = exports.CREDENTIAL_QUERY_PARAM = exports.ALGORITHM_QUERY_PARAM = void 0;
|
||||
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.REGION_SET_PARAM = "X-Amz-Region-Set";
|
||||
exports.AUTH_HEADER = "authorization";
|
||||
exports.AMZ_DATE_HEADER = exports.AMZ_DATE_QUERY_PARAM.toLowerCase();
|
||||
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.TOKEN_HEADER = exports.TOKEN_QUERY_PARAM.toLowerCase();
|
||||
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,
|
||||
};
|
||||
exports.PROXY_HEADER_PATTERN = /^proxy-/;
|
||||
exports.SEC_HEADER_PATTERN = /^sec-/;
|
||||
exports.UNSIGNABLE_PATTERNS = [/^proxy-/i, /^sec-/i];
|
||||
exports.ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256";
|
||||
exports.ALGORITHM_IDENTIFIER_V4A = "AWS4-ECDSA-P256-SHA256";
|
||||
exports.EVENT_ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256-PAYLOAD";
|
||||
exports.UNSIGNED_PAYLOAD = "UNSIGNED-PAYLOAD";
|
||||
exports.MAX_CACHE_SIZE = 50;
|
||||
exports.KEY_TYPE_IDENTIFIER = "aws4_request";
|
||||
exports.MAX_PRESIGNED_TTL = 60 * 60 * 24 * 7;
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.clearCredentialCache = exports.getSigningKey = exports.createScope = void 0;
|
||||
const util_hex_encoding_1 = require("@smithy/util-hex-encoding");
|
||||
const util_utf8_1 = require("@smithy/util-utf8");
|
||||
const constants_1 = require("./constants");
|
||||
const signingKeyCache = {};
|
||||
const cacheQueue = [];
|
||||
const createScope = (shortDate, region, service) => `${shortDate}/${region}/${service}/${constants_1.KEY_TYPE_IDENTIFIER}`;
|
||||
exports.createScope = createScope;
|
||||
const getSigningKey = async (sha256Constructor, credentials, shortDate, region, service) => {
|
||||
const credsHash = await hmac(sha256Constructor, credentials.secretAccessKey, credentials.accessKeyId);
|
||||
const cacheKey = `${shortDate}:${region}:${service}:${(0, util_hex_encoding_1.toHex)(credsHash)}:${credentials.sessionToken}`;
|
||||
if (cacheKey in signingKeyCache) {
|
||||
return signingKeyCache[cacheKey];
|
||||
}
|
||||
cacheQueue.push(cacheKey);
|
||||
while (cacheQueue.length > constants_1.MAX_CACHE_SIZE) {
|
||||
delete signingKeyCache[cacheQueue.shift()];
|
||||
}
|
||||
let key = `AWS4${credentials.secretAccessKey}`;
|
||||
for (const signable of [shortDate, region, service, constants_1.KEY_TYPE_IDENTIFIER]) {
|
||||
key = await hmac(sha256Constructor, key, signable);
|
||||
}
|
||||
return (signingKeyCache[cacheKey] = key);
|
||||
};
|
||||
exports.getSigningKey = getSigningKey;
|
||||
const clearCredentialCache = () => {
|
||||
cacheQueue.length = 0;
|
||||
Object.keys(signingKeyCache).forEach((cacheKey) => {
|
||||
delete signingKeyCache[cacheKey];
|
||||
});
|
||||
};
|
||||
exports.clearCredentialCache = clearCredentialCache;
|
||||
const hmac = (ctor, secret, data) => {
|
||||
const hash = new ctor(secret);
|
||||
hash.update((0, util_utf8_1.toUint8Array)(data));
|
||||
return hash.digest();
|
||||
};
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getCanonicalHeaders = void 0;
|
||||
const constants_1 = require("./constants");
|
||||
const getCanonicalHeaders = ({ headers }, unsignableHeaders, signableHeaders) => {
|
||||
const canonical = {};
|
||||
for (const headerName of Object.keys(headers).sort()) {
|
||||
if (headers[headerName] == undefined) {
|
||||
continue;
|
||||
}
|
||||
const canonicalHeaderName = headerName.toLowerCase();
|
||||
if (canonicalHeaderName in constants_1.ALWAYS_UNSIGNABLE_HEADERS ||
|
||||
(unsignableHeaders === null || unsignableHeaders === void 0 ? void 0 : unsignableHeaders.has(canonicalHeaderName)) ||
|
||||
constants_1.PROXY_HEADER_PATTERN.test(canonicalHeaderName) ||
|
||||
constants_1.SEC_HEADER_PATTERN.test(canonicalHeaderName)) {
|
||||
if (!signableHeaders || (signableHeaders && !signableHeaders.has(canonicalHeaderName))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
canonical[canonicalHeaderName] = headers[headerName].trim().replace(/\s+/g, " ");
|
||||
}
|
||||
return canonical;
|
||||
};
|
||||
exports.getCanonicalHeaders = getCanonicalHeaders;
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getCanonicalQuery = void 0;
|
||||
const util_uri_escape_1 = require("@smithy/util-uri-escape");
|
||||
const constants_1 = require("./constants");
|
||||
const getCanonicalQuery = ({ query = {} }) => {
|
||||
const keys = [];
|
||||
const serialized = {};
|
||||
for (const key of Object.keys(query).sort()) {
|
||||
if (key.toLowerCase() === constants_1.SIGNATURE_HEADER) {
|
||||
continue;
|
||||
}
|
||||
keys.push(key);
|
||||
const value = query[key];
|
||||
if (typeof value === "string") {
|
||||
serialized[key] = `${(0, util_uri_escape_1.escapeUri)(key)}=${(0, util_uri_escape_1.escapeUri)(value)}`;
|
||||
}
|
||||
else if (Array.isArray(value)) {
|
||||
serialized[key] = value
|
||||
.slice(0)
|
||||
.reduce((encoded, value) => encoded.concat([`${(0, util_uri_escape_1.escapeUri)(key)}=${(0, util_uri_escape_1.escapeUri)(value)}`]), [])
|
||||
.sort()
|
||||
.join("&");
|
||||
}
|
||||
}
|
||||
return keys
|
||||
.map((key) => serialized[key])
|
||||
.filter((serialized) => serialized)
|
||||
.join("&");
|
||||
};
|
||||
exports.getCanonicalQuery = getCanonicalQuery;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getPayloadHash = void 0;
|
||||
const is_array_buffer_1 = require("@smithy/is-array-buffer");
|
||||
const util_hex_encoding_1 = require("@smithy/util-hex-encoding");
|
||||
const util_utf8_1 = require("@smithy/util-utf8");
|
||||
const constants_1 = require("./constants");
|
||||
const getPayloadHash = async ({ headers, body }, hashConstructor) => {
|
||||
for (const headerName of Object.keys(headers)) {
|
||||
if (headerName.toLowerCase() === constants_1.SHA256_HEADER) {
|
||||
return headers[headerName];
|
||||
}
|
||||
}
|
||||
if (body == undefined) {
|
||||
return "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
||||
}
|
||||
else if (typeof body === "string" || ArrayBuffer.isView(body) || (0, is_array_buffer_1.isArrayBuffer)(body)) {
|
||||
const hashCtor = new hashConstructor();
|
||||
hashCtor.update((0, util_utf8_1.toUint8Array)(body));
|
||||
return (0, util_hex_encoding_1.toHex)(await hashCtor.digest());
|
||||
}
|
||||
return constants_1.UNSIGNED_PAYLOAD;
|
||||
};
|
||||
exports.getPayloadHash = getPayloadHash;
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.deleteHeader = exports.getHeaderValue = exports.hasHeader = void 0;
|
||||
const hasHeader = (soughtHeader, headers) => {
|
||||
soughtHeader = soughtHeader.toLowerCase();
|
||||
for (const headerName of Object.keys(headers)) {
|
||||
if (soughtHeader === headerName.toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
exports.hasHeader = hasHeader;
|
||||
const getHeaderValue = (soughtHeader, headers) => {
|
||||
soughtHeader = soughtHeader.toLowerCase();
|
||||
for (const headerName of Object.keys(headers)) {
|
||||
if (soughtHeader === headerName.toLowerCase()) {
|
||||
return headers[headerName];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
exports.getHeaderValue = getHeaderValue;
|
||||
const deleteHeader = (soughtHeader, headers) => {
|
||||
soughtHeader = soughtHeader.toLowerCase();
|
||||
for (const headerName of Object.keys(headers)) {
|
||||
if (soughtHeader === headerName.toLowerCase()) {
|
||||
delete headers[headerName];
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.deleteHeader = deleteHeader;
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.prepareRequest = exports.moveHeadersToQuery = exports.getPayloadHash = exports.getCanonicalQuery = exports.getCanonicalHeaders = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./SignatureV4"), exports);
|
||||
var getCanonicalHeaders_1 = require("./getCanonicalHeaders");
|
||||
Object.defineProperty(exports, "getCanonicalHeaders", { enumerable: true, get: function () { return getCanonicalHeaders_1.getCanonicalHeaders; } });
|
||||
var getCanonicalQuery_1 = require("./getCanonicalQuery");
|
||||
Object.defineProperty(exports, "getCanonicalQuery", { enumerable: true, get: function () { return getCanonicalQuery_1.getCanonicalQuery; } });
|
||||
var getPayloadHash_1 = require("./getPayloadHash");
|
||||
Object.defineProperty(exports, "getPayloadHash", { enumerable: true, get: function () { return getPayloadHash_1.getPayloadHash; } });
|
||||
var moveHeadersToQuery_1 = require("./moveHeadersToQuery");
|
||||
Object.defineProperty(exports, "moveHeadersToQuery", { enumerable: true, get: function () { return moveHeadersToQuery_1.moveHeadersToQuery; } });
|
||||
var prepareRequest_1 = require("./prepareRequest");
|
||||
Object.defineProperty(exports, "prepareRequest", { enumerable: true, get: function () { return prepareRequest_1.prepareRequest; } });
|
||||
tslib_1.__exportStar(require("./credentialDerivation"), exports);
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.moveHeadersToQuery = void 0;
|
||||
const cloneRequest_1 = require("./cloneRequest");
|
||||
const moveHeadersToQuery = (request, options = {}) => {
|
||||
var _a;
|
||||
const { headers, query = {} } = typeof request.clone === "function" ? request.clone() : (0, cloneRequest_1.cloneRequest)(request);
|
||||
for (const name of Object.keys(headers)) {
|
||||
const lname = name.toLowerCase();
|
||||
if (lname.slice(0, 6) === "x-amz-" && !((_a = options.unhoistableHeaders) === null || _a === void 0 ? void 0 : _a.has(lname))) {
|
||||
query[name] = headers[name];
|
||||
delete headers[name];
|
||||
}
|
||||
}
|
||||
return {
|
||||
...request,
|
||||
headers,
|
||||
query,
|
||||
};
|
||||
};
|
||||
exports.moveHeadersToQuery = moveHeadersToQuery;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.prepareRequest = void 0;
|
||||
const cloneRequest_1 = require("./cloneRequest");
|
||||
const constants_1 = require("./constants");
|
||||
const prepareRequest = (request) => {
|
||||
request = typeof request.clone === "function" ? request.clone() : (0, cloneRequest_1.cloneRequest)(request);
|
||||
for (const headerName of Object.keys(request.headers)) {
|
||||
if (constants_1.GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) {
|
||||
delete request.headers[headerName];
|
||||
}
|
||||
}
|
||||
return request;
|
||||
};
|
||||
exports.prepareRequest = prepareRequest;
|
||||
+402
@@ -0,0 +1,402 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.requests = exports.signingDate = exports.credentials = exports.service = exports.region = void 0;
|
||||
exports.region = "us-east-1";
|
||||
exports.service = "service";
|
||||
exports.credentials = {
|
||||
accessKeyId: "AKIDEXAMPLE",
|
||||
secretAccessKey: "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY",
|
||||
};
|
||||
exports.signingDate = new Date("2015-08-30T12:36:00Z");
|
||||
exports.requests = [
|
||||
{
|
||||
name: "get-header-key-duplicate",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "GET",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"my-header1": "value2,value2,value1",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=c9d5ea9f3f72853aea855b47ea873832890dbdd183b4468f858259531a5138ea",
|
||||
},
|
||||
{
|
||||
name: "get-header-value-multiline",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "GET",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"my-header1": "value1,value2,value3",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=ba17b383a53190154eb5fa66a1b836cc297cc0a3d70a5d00705980573d8ff790",
|
||||
},
|
||||
{
|
||||
name: "get-header-value-order",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "GET",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"my-header1": "value4,value1,value3,value2",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=08c7e5a9acfcfeb3ab6b2185e75ce8b1deb5e634ec47601a50643f830c755c01",
|
||||
},
|
||||
{
|
||||
name: "get-header-value-trim",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "GET",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"my-header1": "value1",
|
||||
"my-header2": '"a b c"',
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;my-header2;x-amz-date, Signature=acc3ed3afb60bb290fc8d2dd0098b9911fcaa05412b367055dee359757a9c736",
|
||||
},
|
||||
{
|
||||
name: "get-unreserved",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "GET",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=07ef7494c76fa4850883e2b006601f940f8a34d404d0cfa977f52a65bbf5f24f",
|
||||
},
|
||||
{
|
||||
name: "get-utf8",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "GET",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/ሴ",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=8318018e0b0f223aa2bbf98705b62bb787dc9c0e678f255a891fd03141be5d85",
|
||||
},
|
||||
{
|
||||
name: "get-vanilla",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "GET",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5fa00fa31553b73ebf1942676e86291e8372ff2a2260956d9b8aae1d763fbf31",
|
||||
},
|
||||
{
|
||||
name: "get-vanilla-empty-query-key",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "GET",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {
|
||||
Param1: "value1",
|
||||
},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=a67d582fa61cc504c4bae71f336f98b97f1ea3c7a6bfe1b6e45aec72011b9aeb",
|
||||
},
|
||||
{
|
||||
name: "get-vanilla-query",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "GET",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5fa00fa31553b73ebf1942676e86291e8372ff2a2260956d9b8aae1d763fbf31",
|
||||
},
|
||||
{
|
||||
name: "get-vanilla-query-order-key-case",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "GET",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {
|
||||
Param2: "value2",
|
||||
Param1: "value1",
|
||||
},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=b97d918cfa904a5beff61c982a1b6f458b799221646efd99d3219ec94cdf2500",
|
||||
},
|
||||
{
|
||||
name: "get-vanilla-query-unreserved",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "GET",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {
|
||||
"-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz": "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
||||
},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=9c3e54bfcdf0b19771a7f523ee5669cdf59bc7cc0884027167c21bb143a40197",
|
||||
},
|
||||
{
|
||||
name: "get-vanilla-utf8-query",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "GET",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {
|
||||
ሴ: "bar",
|
||||
},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=2cdec8eed098649ff3a119c94853b13c643bcf08f8b0a1d91e12c9027818dd04",
|
||||
},
|
||||
{
|
||||
name: "post-header-key-case",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "POST",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5da7c1a2acd57cee7505fc6676e4e544621c30862966e37dddb68e92efbe5d6b",
|
||||
},
|
||||
{
|
||||
name: "post-header-key-sort",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "POST",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"my-header1": "value1",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=c5410059b04c1ee005303aed430f6e6645f61f4dc9e1461ec8f8916fdf18852c",
|
||||
},
|
||||
{
|
||||
name: "post-header-value-case",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "POST",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"my-header1": "VALUE1",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=cdbc9802e29d2942e5e10b5bccfdd67c5f22c7c4e8ae67b53629efa58b974b7d",
|
||||
},
|
||||
{
|
||||
name: "post-sts-header-after",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "POST",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5da7c1a2acd57cee7505fc6676e4e544621c30862966e37dddb68e92efbe5d6b",
|
||||
},
|
||||
{
|
||||
name: "post-sts-header-before",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "POST",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
"x-amz-security-token": "AQoDYXdzEPT//////////wEXAMPLEtc764bNrC9SAPBSM22wDOk4x4HIZ8j4FZTwdQWLWsKWHGBuFqwAeMicRXmxfpSPfIeoIYRqTflfKD8YUuwthAx7mSEI/qkPpKPi/kMcGdQrmGdeehM4IC1NtBmUpp2wUE8phUZampKsburEDy0KPkyQDYwT7WZ0wq5VSXDvp75YU9HFvlRd8Tx6q6fE8YQcHNVXAkiY9q6d+xo0rKwT38xVqr7ZD0u0iPPkUL64lIZbqBAz+scqKmlzm8FDrypNC9Yjc8fPOLn9FX9KSYvKTr4rvx3iSIlTJabIQwj2ICCR/oLxBA==",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date;x-amz-security-token, Signature=85d96828115b5dc0cfc3bd16ad9e210dd772bbebba041836c64533a82be05ead",
|
||||
},
|
||||
{
|
||||
name: "post-vanilla",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "POST",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5da7c1a2acd57cee7505fc6676e4e544621c30862966e37dddb68e92efbe5d6b",
|
||||
},
|
||||
{
|
||||
name: "post-vanilla-empty-query-value",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "POST",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {
|
||||
Param1: "value1",
|
||||
},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=28038455d6de14eafc1f9222cf5aa6f1a96197d7deb8263271d420d138af7f11",
|
||||
},
|
||||
{
|
||||
name: "post-vanilla-query",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "POST",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {
|
||||
Param1: "value1",
|
||||
},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=28038455d6de14eafc1f9222cf5aa6f1a96197d7deb8263271d420d138af7f11",
|
||||
},
|
||||
{
|
||||
name: "post-vanilla-query-nonunreserved",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "POST",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {
|
||||
"@#$%^": "",
|
||||
"+": '/,?><`";:\\|][{}',
|
||||
},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=66c82657c86e26fb25238d0e69f011edc4c6df5ae71119d7cb98ed9b87393c1e",
|
||||
},
|
||||
{
|
||||
name: "post-vanilla-query-space",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "POST",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {
|
||||
p: "",
|
||||
},
|
||||
headers: {
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=e71688addb58a26418614085fb730ba3faa623b461c17f48f2fbdb9361b94a9b",
|
||||
},
|
||||
{
|
||||
name: "post-x-www-form-urlencoded",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "POST",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
body: "Param1=value1",
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=ff11897932ad3f4e8b18135d722051e5ac45fc38421b1da7b9d196a0fe09473a",
|
||||
},
|
||||
{
|
||||
name: "post-x-www-form-urlencoded-parameters",
|
||||
request: {
|
||||
protocol: "https:",
|
||||
method: "POST",
|
||||
hostname: "example.amazonaws.com",
|
||||
query: {},
|
||||
headers: {
|
||||
"content-type": "application/x-www-form-urlencoded; charset=utf8",
|
||||
host: "example.amazonaws.com",
|
||||
"x-amz-date": "20150830T123600Z",
|
||||
},
|
||||
body: "Param1=value1",
|
||||
path: "/",
|
||||
},
|
||||
authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=1a72ec8f64bd914b0e42e42607c7fbce7fb2c7465f63e3092b3b0d39fa77a6fe",
|
||||
},
|
||||
];
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.toDate = exports.iso8601 = void 0;
|
||||
const iso8601 = (time) => (0, exports.toDate)(time)
|
||||
.toISOString()
|
||||
.replace(/\.\d{3}Z$/, "Z");
|
||||
exports.iso8601 = iso8601;
|
||||
const toDate = (time) => {
|
||||
if (typeof time === "number") {
|
||||
return new Date(time * 1000);
|
||||
}
|
||||
if (typeof time === "string") {
|
||||
if (Number(time)) {
|
||||
return new Date(Number(time) * 1000);
|
||||
}
|
||||
return new Date(time);
|
||||
}
|
||||
return time;
|
||||
};
|
||||
exports.toDate = toDate;
|
||||
Reference in New Issue
Block a user