@aws-amplify/core 5.2.1-unstable.eca5078.2 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Platform/version.js.map +1 -1
- package/lib/Signer.d.ts +1 -1
- package/lib/Signer.js +59 -256
- package/lib/Signer.js.map +1 -1
- package/lib/clients/middleware/signing/signer/signatureV4/constants.d.ts +17 -0
- package/lib/clients/middleware/signing/signer/signatureV4/constants.js +26 -0
- package/lib/clients/middleware/signing/signer/signatureV4/constants.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/index.d.ts +3 -0
- package/lib/clients/middleware/signing/signer/signatureV4/index.js +12 -0
- package/lib/clients/middleware/signing/signer/signatureV4/index.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/index.native.d.ts +4 -0
- package/lib/clients/middleware/signing/signer/signatureV4/index.native.js +13 -0
- package/lib/clients/middleware/signing/signer/signatureV4/index.native.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.d.ts +9 -0
- package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.js +40 -0
- package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/signRequest.d.ts +10 -0
- package/lib/clients/middleware/signing/signer/signatureV4/signRequest.js +36 -0
- package/lib/clients/middleware/signing/signer/signatureV4/signRequest.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/types/index.d.ts +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/types/index.js +5 -0
- package/lib/clients/middleware/signing/signer/signatureV4/types/index.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/types/signer.d.ts +20 -0
- package/lib/clients/middleware/signing/signer/signatureV4/types/signer.js +5 -0
- package/lib/clients/middleware/signing/signer/signatureV4/types/signer.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.d.ts +18 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +35 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.d.ts +12 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js +31 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.d.ts +12 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js +39 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.d.ts +16 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +35 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.d.ts +10 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +17 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.d.ts +12 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js +18 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.d.ts +12 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js +22 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.d.ts +10 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js +35 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignature.d.ts +13 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +31 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignature.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.d.ts +10 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js +20 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.d.ts +13 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js +27 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.d.ts +11 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +34 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js.map +1 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.d.ts +16 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js +24 -0
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js.map +1 -0
- package/lib/clients/types/aws.d.ts +2 -0
- package/lib/clients/types/aws.js +5 -0
- package/lib/clients/types/aws.js.map +1 -0
- package/lib/clients/types/core.d.ts +13 -0
- package/lib/clients/types/core.js +5 -0
- package/lib/clients/types/core.js.map +1 -0
- package/lib/clients/types/http.d.ts +26 -0
- package/lib/clients/types/http.js +5 -0
- package/lib/clients/types/http.js.map +1 -0
- package/lib/clients/types/index.d.ts +2 -0
- package/lib/clients/types/index.js +5 -0
- package/lib/clients/types/index.js.map +1 -0
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Platform/version.js.map +1 -1
- package/lib-esm/Signer.d.ts +1 -1
- package/lib-esm/Signer.js +60 -257
- package/lib-esm/Signer.js.map +1 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/constants.d.ts +17 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/constants.js +24 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/constants.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.d.ts +3 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js +7 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.d.ts +4 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.js +8 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.d.ts +9 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.js +38 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/signRequest.d.ts +10 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/signRequest.js +34 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/signRequest.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/types/index.d.ts +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/types/index.js +3 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/types/index.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/types/signer.d.ts +20 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/types/signer.js +3 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/types/signer.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.d.ts +18 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +33 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.d.ts +12 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js +29 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.d.ts +12 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js +37 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.d.ts +16 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +33 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.d.ts +10 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +15 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.d.ts +12 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js +16 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.d.ts +12 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js +20 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.d.ts +10 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js +33 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignature.d.ts +13 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +29 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignature.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.d.ts +10 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js +18 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.d.ts +13 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js +25 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.d.ts +11 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +32 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js.map +1 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.d.ts +16 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js +22 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js.map +1 -0
- package/lib-esm/clients/types/aws.d.ts +2 -0
- package/lib-esm/clients/types/aws.js +3 -0
- package/lib-esm/clients/types/aws.js.map +1 -0
- package/lib-esm/clients/types/core.d.ts +13 -0
- package/lib-esm/clients/types/core.js +3 -0
- package/lib-esm/clients/types/core.js.map +1 -0
- package/lib-esm/clients/types/http.d.ts +26 -0
- package/lib-esm/clients/types/http.js +3 -0
- package/lib-esm/clients/types/http.js.map +1 -0
- package/lib-esm/clients/types/index.d.ts +2 -0
- package/lib-esm/clients/types/index.js +3 -0
- package/lib-esm/clients/types/index.js.map +1 -0
- package/package.json +6 -2
- package/src/Platform/version.ts +1 -1
- package/src/Signer.ts +89 -344
- package/src/clients/middleware/signing/signer/signatureV4/constants.ts +28 -0
- package/src/clients/middleware/signing/signer/signatureV4/index.native.ts +9 -0
- package/src/clients/middleware/signing/signer/signatureV4/index.ts +7 -0
- package/src/clients/middleware/signing/signer/signatureV4/presignUrl.ts +59 -0
- package/src/clients/middleware/signing/signer/signatureV4/signRequest.ts +51 -0
- package/src/clients/middleware/signing/signer/signatureV4/types/index.ts +4 -0
- package/src/clients/middleware/signing/signer/signatureV4/types/signer.ts +31 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.ts +42 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.ts +25 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.ts +32 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.ts +38 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.ts +14 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.ts +21 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.ts +22 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.ts +38 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/getSignature.ts +52 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.ts +19 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.ts +31 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.ts +43 -0
- package/src/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.ts +28 -0
- package/src/clients/types/aws.ts +6 -0
- package/src/clients/types/core.ts +17 -0
- package/src/clients/types/http.ts +33 -0
- package/src/clients/types/index.ts +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/types/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Credentials, HttpRequest } from '../../../../../types';
|
|
2
|
+
export interface SignRequestOptions {
|
|
3
|
+
credentials: Credentials;
|
|
4
|
+
signingDate?: Date;
|
|
5
|
+
signingRegion: string;
|
|
6
|
+
signingService: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PresignUrlOptions extends SignRequestOptions {
|
|
9
|
+
expiration?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface Presignable extends Pick<HttpRequest, 'body' | 'url'> {
|
|
12
|
+
method?: HttpRequest['method'];
|
|
13
|
+
}
|
|
14
|
+
export interface FormattedDates {
|
|
15
|
+
longDate: string;
|
|
16
|
+
shortDate: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SigningValues extends Credentials, FormattedDates, Pick<SignRequestOptions, 'signingRegion' | 'signingService'> {
|
|
19
|
+
credentialScope: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/types/signer.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the hashed data a `Uint8Array`.
|
|
3
|
+
*
|
|
4
|
+
* @param key `SourceData` to be used as hashing key.
|
|
5
|
+
* @param data Hashable `SourceData`.
|
|
6
|
+
* @returns `Uint8Array` created from the data as input to a hash function.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getHashedData: (key: string | ArrayBuffer | ArrayBufferView, data: string | ArrayBuffer | ArrayBufferView) => Uint8Array;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the hashed data as a hex string.
|
|
11
|
+
*
|
|
12
|
+
* @param key `SourceData` to be used as hashing key.
|
|
13
|
+
* @param data Hashable `SourceData`.
|
|
14
|
+
* @returns String using lowercase hexadecimal characters created from the data as input to a hash function.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare const getHashedDataAsHex: (key: string | ArrayBuffer | ArrayBufferView, data: string | ArrayBuffer | ArrayBufferView) => string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
// TODO: V6 update to different crypto dependency?
|
|
6
|
+
var sha256_js_1 = require("@aws-crypto/sha256-js");
|
|
7
|
+
var util_hex_encoding_1 = require("@aws-sdk/util-hex-encoding");
|
|
8
|
+
/**
|
|
9
|
+
* Returns the hashed data a `Uint8Array`.
|
|
10
|
+
*
|
|
11
|
+
* @param key `SourceData` to be used as hashing key.
|
|
12
|
+
* @param data Hashable `SourceData`.
|
|
13
|
+
* @returns `Uint8Array` created from the data as input to a hash function.
|
|
14
|
+
*/
|
|
15
|
+
exports.getHashedData = function (key, data) {
|
|
16
|
+
var sha256 = new sha256_js_1.Sha256(key);
|
|
17
|
+
sha256.update(data);
|
|
18
|
+
// TODO: V6 flip to async digest
|
|
19
|
+
var hashedData = sha256.digestSync();
|
|
20
|
+
return hashedData;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Returns the hashed data as a hex string.
|
|
24
|
+
*
|
|
25
|
+
* @param key `SourceData` to be used as hashing key.
|
|
26
|
+
* @param data Hashable `SourceData`.
|
|
27
|
+
* @returns String using lowercase hexadecimal characters created from the data as input to a hash function.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
exports.getHashedDataAsHex = function (key, data) {
|
|
32
|
+
var hashedData = exports.getHashedData(key, data);
|
|
33
|
+
return util_hex_encoding_1.toHex(hashedData);
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=dataHashHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataHashHelpers.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,kDAAkD;AAClD,mDAA+C;AAE/C,gEAAmD;AAEnD;;;;;;GAMG;AACU,QAAA,aAAa,GAAG,UAC5B,GAAsB,EACtB,IAAgB;IAEhB,IAAM,MAAM,GAAG,IAAI,kBAAM,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACpB,gCAAgC;IAChC,IAAM,UAAU,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IACvC,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAG,UACjC,GAAsB,EACtB,IAAgB;IAEhB,IAAM,UAAU,GAAG,qBAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC5C,OAAO,yBAAK,CAAC,UAAU,CAAC,CAAC;AAC1B,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns canonical headers.
|
|
3
|
+
*
|
|
4
|
+
* @param headers Headers from the request.
|
|
5
|
+
* @returns Request headers that will be signed, and their values, separated by newline characters. Header names must
|
|
6
|
+
* use lowercase characters, must appear in alphabetical order, and must be followed by a colon (:). For the values,
|
|
7
|
+
* trim any leading or trailing spaces, convert sequential spaces to a single space, and separate the values
|
|
8
|
+
* for a multi-value header using commas.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const getCanonicalHeaders: (headers: Record<string, string>) => string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
var tslib_1 = require("tslib");
|
|
6
|
+
/**
|
|
7
|
+
* Returns canonical headers.
|
|
8
|
+
*
|
|
9
|
+
* @param headers Headers from the request.
|
|
10
|
+
* @returns Request headers that will be signed, and their values, separated by newline characters. Header names must
|
|
11
|
+
* use lowercase characters, must appear in alphabetical order, and must be followed by a colon (:). For the values,
|
|
12
|
+
* trim any leading or trailing spaces, convert sequential spaces to a single space, and separate the values
|
|
13
|
+
* for a multi-value header using commas.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
exports.getCanonicalHeaders = function (headers) {
|
|
18
|
+
return Object.entries(headers)
|
|
19
|
+
.map(function (_a) {
|
|
20
|
+
var _b = tslib_1.__read(_a, 2), key = _b[0], value = _b[1];
|
|
21
|
+
var _c;
|
|
22
|
+
return ({
|
|
23
|
+
key: key.toLowerCase(),
|
|
24
|
+
value: (_c = value === null || value === void 0 ? void 0 : value.trim().replace(/\s+/g, ' ')) !== null && _c !== void 0 ? _c : '',
|
|
25
|
+
});
|
|
26
|
+
})
|
|
27
|
+
.sort(function (a, b) { return (a.key < b.key ? -1 : 1); })
|
|
28
|
+
.map(function (entry) { return entry.key + ":" + entry.value + "\n"; })
|
|
29
|
+
.join('');
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=getCanonicalHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCanonicalHeaders.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;;AAItC;;;;;;;;;;GAUG;AACU,QAAA,mBAAmB,GAAG,UAAC,OAA+B;IAClE,OAAA,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;SACrB,GAAG,CAAC,UAAC,EAAY;YAAZ,0BAAY,EAAX,WAAG,EAAE,aAAK;;QAAM,OAAA,CAAC;YACvB,GAAG,EAAE,GAAG,CAAC,WAAW,EAAE;YACtB,KAAK,QAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,oCAAK,EAAE;SAC/C,CAAC,CAAA;KAAA,CAAC;SACF,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAxB,CAAwB,CAAC;SACxC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAG,KAAK,CAAC,GAAG,SAAI,KAAK,CAAC,KAAK,OAAI,EAA/B,CAA+B,CAAC;SAC7C,IAAI,CAAC,EAAE,CAAC;AAPV,CAOU,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a canonical query string.
|
|
3
|
+
*
|
|
4
|
+
* @param searchParams `searchParams` from the request url.
|
|
5
|
+
* @returns URL-encoded query string parameters, separated by ampersands (&). Percent-encode reserved characters,
|
|
6
|
+
* including the space character. Encode names and values separately. If there are empty parameters, append the equals
|
|
7
|
+
* sign to the parameter name before encoding. After encoding, sort the parameters alphabetically by key name. If there
|
|
8
|
+
* is no query string, use an empty string ("").
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const getCanonicalQueryString: (searchParams: URLSearchParams) => string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
var tslib_1 = require("tslib");
|
|
6
|
+
/**
|
|
7
|
+
* Returns a canonical query string.
|
|
8
|
+
*
|
|
9
|
+
* @param searchParams `searchParams` from the request url.
|
|
10
|
+
* @returns URL-encoded query string parameters, separated by ampersands (&). Percent-encode reserved characters,
|
|
11
|
+
* including the space character. Encode names and values separately. If there are empty parameters, append the equals
|
|
12
|
+
* sign to the parameter name before encoding. After encoding, sort the parameters alphabetically by key name. If there
|
|
13
|
+
* is no query string, use an empty string ("").
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
exports.getCanonicalQueryString = function (searchParams) {
|
|
18
|
+
return Array.from(searchParams)
|
|
19
|
+
.sort(function (_a, _b) {
|
|
20
|
+
var _c = tslib_1.__read(_a, 2), keyA = _c[0], valA = _c[1];
|
|
21
|
+
var _d = tslib_1.__read(_b, 2), keyB = _d[0], valB = _d[1];
|
|
22
|
+
if (keyA === keyB) {
|
|
23
|
+
return valA < valB ? -1 : 1;
|
|
24
|
+
}
|
|
25
|
+
return keyA < keyB ? -1 : 1;
|
|
26
|
+
})
|
|
27
|
+
.map(function (_a) {
|
|
28
|
+
var _b = tslib_1.__read(_a, 2), key = _b[0], val = _b[1];
|
|
29
|
+
return escapeUri(key) + "=" + escapeUri(val);
|
|
30
|
+
})
|
|
31
|
+
.join('&');
|
|
32
|
+
};
|
|
33
|
+
var escapeUri = function (uri) {
|
|
34
|
+
return encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode);
|
|
35
|
+
};
|
|
36
|
+
var hexEncode = function (c) {
|
|
37
|
+
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=getCanonicalQueryString.js.map
|
package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCanonicalQueryString.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;;AAEtC;;;;;;;;;;GAUG;AACU,QAAA,uBAAuB,GAAG,UACtC,YAA6B;IAE7B,OAAA,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC;SACtB,IAAI,CAAC,UAAC,EAAY,EAAE,EAAY;YAA1B,0BAAY,EAAX,YAAI,EAAE,YAAI;YAAG,0BAAY,EAAX,YAAI,EAAE,YAAI;QAC/B,IAAI,IAAI,KAAK,IAAI,EAAE;YAClB,OAAO,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC5B;QACD,OAAO,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC,CAAC;SACD,GAAG,CAAC,UAAC,EAAU;YAAV,0BAAU,EAAT,WAAG,EAAE,WAAG;QAAM,OAAG,SAAS,CAAC,GAAG,CAAC,SAAI,SAAS,CAAC,GAAG,CAAG;IAArC,CAAqC,CAAC;SAC1D,IAAI,CAAC,GAAG,CAAC;AARX,CAQW,CAAC;AAEb,IAAM,SAAS,GAAG,UAAC,GAAW;IAC7B,OAAA,kBAAkB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC;AAAtD,CAAsD,CAAC;AAExD,IAAM,SAAS,GAAG,UAAC,CAAS;IAC3B,OAAA,MAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAI;AAAhD,CAAgD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HttpRequest } from '../../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a canonical request.
|
|
4
|
+
*
|
|
5
|
+
* @param request `HttpRequest` from which to create the canonical request from.
|
|
6
|
+
* @returns String created by by concatenating the following strings, separated by newline characters:
|
|
7
|
+
* - HTTPMethod
|
|
8
|
+
* - CanonicalUri
|
|
9
|
+
* - CanonicalQueryString
|
|
10
|
+
* - CanonicalHeaders
|
|
11
|
+
* - SignedHeaders
|
|
12
|
+
* - HashedPayload
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare const getCanonicalRequest: ({ body, headers, method, url, }: HttpRequest) => string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
var getCanonicalHeaders_1 = require("./getCanonicalHeaders");
|
|
6
|
+
var getCanonicalQueryString_1 = require("./getCanonicalQueryString");
|
|
7
|
+
var getCanonicalUri_1 = require("./getCanonicalUri");
|
|
8
|
+
var getHashedPayload_1 = require("./getHashedPayload");
|
|
9
|
+
var getSignedHeaders_1 = require("./getSignedHeaders");
|
|
10
|
+
/**
|
|
11
|
+
* Returns a canonical request.
|
|
12
|
+
*
|
|
13
|
+
* @param request `HttpRequest` from which to create the canonical request from.
|
|
14
|
+
* @returns String created by by concatenating the following strings, separated by newline characters:
|
|
15
|
+
* - HTTPMethod
|
|
16
|
+
* - CanonicalUri
|
|
17
|
+
* - CanonicalQueryString
|
|
18
|
+
* - CanonicalHeaders
|
|
19
|
+
* - SignedHeaders
|
|
20
|
+
* - HashedPayload
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
exports.getCanonicalRequest = function (_a) {
|
|
25
|
+
var body = _a.body, headers = _a.headers, method = _a.method, url = _a.url;
|
|
26
|
+
return [
|
|
27
|
+
method,
|
|
28
|
+
getCanonicalUri_1.getCanonicalUri(url.pathname),
|
|
29
|
+
getCanonicalQueryString_1.getCanonicalQueryString(url.searchParams),
|
|
30
|
+
getCanonicalHeaders_1.getCanonicalHeaders(headers),
|
|
31
|
+
getSignedHeaders_1.getSignedHeaders(headers),
|
|
32
|
+
getHashedPayload_1.getHashedPayload(body),
|
|
33
|
+
].join('\n');
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=getCanonicalRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCanonicalRequest.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAGtC,6DAA4D;AAC5D,qEAAoE;AACpE,qDAAoD;AACpD,uDAAsD;AACtD,uDAAsD;AAEtD;;;;;;;;;;;;;GAaG;AACU,QAAA,mBAAmB,GAAG,UAAC,EAKtB;QAJb,cAAI,EACJ,oBAAO,EACP,kBAAM,EACN,YAAG;IAEH,OAAA;QACC,MAAM;QACN,iCAAe,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC7B,iDAAuB,CAAC,GAAG,CAAC,YAAY,CAAC;QACzC,yCAAmB,CAAC,OAAO,CAAC;QAC5B,mCAAgB,CAAC,OAAO,CAAC;QACzB,mCAAgB,CAAC,IAAI,CAAC;KACtB,CAAC,IAAI,CAAC,IAAI,CAAC;AAPZ,CAOY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a canonical uri.
|
|
3
|
+
*
|
|
4
|
+
* @param pathname `pathname` from request url.
|
|
5
|
+
* @returns URI-encoded version of the absolute path component URL (everything between the host and the question mark
|
|
6
|
+
* character (?) that starts the query string parameters). If the absolute path is empty, a forward slash character (/).
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const getCanonicalUri: (pathname: string) => string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
/**
|
|
6
|
+
* Returns a canonical uri.
|
|
7
|
+
*
|
|
8
|
+
* @param pathname `pathname` from request url.
|
|
9
|
+
* @returns URI-encoded version of the absolute path component URL (everything between the host and the question mark
|
|
10
|
+
* character (?) that starts the query string parameters). If the absolute path is empty, a forward slash character (/).
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
exports.getCanonicalUri = function (pathname) {
|
|
15
|
+
return pathname ? encodeURIComponent(pathname).replace(/%2F/g, '/') : '/';
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=getCanonicalUri.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCanonicalUri.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC;;;;;;;;GAQG;AACU,QAAA,eAAe,GAAG,UAAC,QAAgB;IAC/C,OAAA,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG;AAAlE,CAAkE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the credential scope which restricts the resulting signature to the specified region and service.
|
|
3
|
+
*
|
|
4
|
+
* @param date Current date in the format 'YYYYMMDD'.
|
|
5
|
+
* @param region AWS region in which the service resides.
|
|
6
|
+
* @param service Service to which the signed request is being sent.
|
|
7
|
+
*
|
|
8
|
+
* @returns A string representing the credential scope with format 'YYYYMMDD/region/service/aws4_request'.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const getCredentialScope: (date: string, region: string, service: string) => string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
var constants_1 = require("../constants");
|
|
6
|
+
/**
|
|
7
|
+
* Returns the credential scope which restricts the resulting signature to the specified region and service.
|
|
8
|
+
*
|
|
9
|
+
* @param date Current date in the format 'YYYYMMDD'.
|
|
10
|
+
* @param region AWS region in which the service resides.
|
|
11
|
+
* @param service Service to which the signed request is being sent.
|
|
12
|
+
*
|
|
13
|
+
* @returns A string representing the credential scope with format 'YYYYMMDD/region/service/aws4_request'.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
exports.getCredentialScope = function (date, region, service) { return date + "/" + region + "/" + service + "/" + constants_1.KEY_TYPE_IDENTIFIER; };
|
|
18
|
+
//# sourceMappingURL=getCredentialScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCredentialScope.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,0CAAmD;AAEnD;;;;;;;;;;GAUG;AACU,QAAA,kBAAkB,GAAG,UACjC,IAAY,EACZ,MAAc,EACd,OAAe,IACH,OAAG,IAAI,SAAI,MAAM,SAAI,OAAO,SAAI,+BAAqB,EAArD,CAAqD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FormattedDates } from '../types/signer';
|
|
2
|
+
/**
|
|
3
|
+
* Returns expected date strings to be used in signing.
|
|
4
|
+
*
|
|
5
|
+
* @param date JavaScript `Date` object.
|
|
6
|
+
* @returns `FormattedDates` object containing the following:
|
|
7
|
+
* - longDate: A date string in 'YYYYMMDDThhmmssZ' format
|
|
8
|
+
* - shortDate: A date string in 'YYYYMMDD' format
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const getFormattedDates: (date: Date) => FormattedDates;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
/**
|
|
6
|
+
* Returns expected date strings to be used in signing.
|
|
7
|
+
*
|
|
8
|
+
* @param date JavaScript `Date` object.
|
|
9
|
+
* @returns `FormattedDates` object containing the following:
|
|
10
|
+
* - longDate: A date string in 'YYYYMMDDThhmmssZ' format
|
|
11
|
+
* - shortDate: A date string in 'YYYYMMDD' format
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
exports.getFormattedDates = function (date) {
|
|
16
|
+
var longDate = date.toISOString().replace(/[:\-]|\.\d{3}/g, '');
|
|
17
|
+
return {
|
|
18
|
+
longDate: longDate,
|
|
19
|
+
shortDate: longDate.slice(0, 8),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=getFormattedDates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFormattedDates.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAItC;;;;;;;;;GASG;AACU,QAAA,iBAAiB,GAAG,UAAC,IAAU;IAC3C,IAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAClE,OAAO;QACN,QAAQ,UAAA;QACR,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;KAC/B,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the hashed payload.
|
|
3
|
+
*
|
|
4
|
+
* @param body `body` (payload) from the request.
|
|
5
|
+
* @returns String created using the payload in the body of the HTTP request as input to a hash function. This string
|
|
6
|
+
* uses lowercase hexadecimal characters. If the payload is empty, return precalculated result of an empty hash.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const getHashedPayload: (body: BodyInit) => string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
var constants_1 = require("../constants");
|
|
6
|
+
var dataHashHelpers_1 = require("./dataHashHelpers");
|
|
7
|
+
/**
|
|
8
|
+
* Returns the hashed payload.
|
|
9
|
+
*
|
|
10
|
+
* @param body `body` (payload) from the request.
|
|
11
|
+
* @returns String created using the payload in the body of the HTTP request as input to a hash function. This string
|
|
12
|
+
* uses lowercase hexadecimal characters. If the payload is empty, return precalculated result of an empty hash.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
exports.getHashedPayload = function (body) {
|
|
17
|
+
// return precalculated empty hash if body is undefined or null
|
|
18
|
+
if (body == null) {
|
|
19
|
+
return constants_1.EMPTY_HASH;
|
|
20
|
+
}
|
|
21
|
+
if (isSourceData(body)) {
|
|
22
|
+
var hashedData = dataHashHelpers_1.getHashedDataAsHex(null, body);
|
|
23
|
+
return hashedData;
|
|
24
|
+
}
|
|
25
|
+
// Defined body is not signable. Return unsigned payload which may or may not be accepted by the service.
|
|
26
|
+
return constants_1.UNSIGNED_PAYLOAD;
|
|
27
|
+
};
|
|
28
|
+
var isSourceData = function (body) {
|
|
29
|
+
return typeof body === 'string' || ArrayBuffer.isView(body) || isArrayBuffer(body);
|
|
30
|
+
};
|
|
31
|
+
var isArrayBuffer = function (arg) {
|
|
32
|
+
return (typeof ArrayBuffer === 'function' && arg instanceof ArrayBuffer) ||
|
|
33
|
+
Object.prototype.toString.call(arg) === '[object ArrayBuffer]';
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=getHashedPayload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHashedPayload.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAItC,0CAA4D;AAC5D,qDAAuD;AAEvD;;;;;;;;GAQG;AACU,QAAA,gBAAgB,GAAG,UAAC,IAAyB;IACzD,+DAA+D;IAC/D,IAAI,IAAI,IAAI,IAAI,EAAE;QACjB,OAAO,sBAAU,CAAC;KAClB;IAED,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE;QACvB,IAAM,UAAU,GAAG,oCAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAClD,OAAO,UAAU,CAAC;KAClB;IAED,yGAAyG;IACzG,OAAO,4BAAgB,CAAC;AACzB,CAAC,CAAC;AAEF,IAAM,YAAY,GAAG,UAAC,IAAyB;IAC9C,OAAA,OAAO,IAAI,KAAK,QAAQ,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC;AAA3E,CAA2E,CAAC;AAE7E,IAAM,aAAa,GAAG,UAAC,GAAQ;IAC9B,OAAA,CAAC,OAAO,WAAW,KAAK,UAAU,IAAI,GAAG,YAAY,WAAW,CAAC;QACjE,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,sBAAsB;AAD9D,CAC8D,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpRequest } from '../../../../../types';
|
|
2
|
+
import { SigningValues } from '../types/signer';
|
|
3
|
+
/**
|
|
4
|
+
* Calculates and returns an AWS API Signature.
|
|
5
|
+
* https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html
|
|
6
|
+
*
|
|
7
|
+
* @param request `HttpRequest` to be signed.
|
|
8
|
+
* @param signRequestOptions `SignRequestOptions` object containing values used to construct the signature.
|
|
9
|
+
* @returns AWS API Signature to sign a request or url with.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const getSignature: (request: HttpRequest, { credentialScope, longDate, secretAccessKey, shortDate, signingRegion, signingService, }: SigningValues) => string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
var dataHashHelpers_1 = require("./dataHashHelpers");
|
|
6
|
+
var getCanonicalRequest_1 = require("./getCanonicalRequest");
|
|
7
|
+
var getSigningKey_1 = require("./getSigningKey");
|
|
8
|
+
var getStringToSign_1 = require("./getStringToSign");
|
|
9
|
+
/**
|
|
10
|
+
* Calculates and returns an AWS API Signature.
|
|
11
|
+
* https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html
|
|
12
|
+
*
|
|
13
|
+
* @param request `HttpRequest` to be signed.
|
|
14
|
+
* @param signRequestOptions `SignRequestOptions` object containing values used to construct the signature.
|
|
15
|
+
* @returns AWS API Signature to sign a request or url with.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
exports.getSignature = function (request, _a) {
|
|
20
|
+
var credentialScope = _a.credentialScope, longDate = _a.longDate, secretAccessKey = _a.secretAccessKey, shortDate = _a.shortDate, signingRegion = _a.signingRegion, signingService = _a.signingService;
|
|
21
|
+
// step 1: create a canonical request
|
|
22
|
+
var canonicalRequest = getCanonicalRequest_1.getCanonicalRequest(request);
|
|
23
|
+
// step 2: create a hash of the canonical request
|
|
24
|
+
var hashedRequest = dataHashHelpers_1.getHashedDataAsHex(null, canonicalRequest);
|
|
25
|
+
// step 3: create a string to sign
|
|
26
|
+
var stringToSign = getStringToSign_1.getStringToSign(longDate, credentialScope, hashedRequest);
|
|
27
|
+
// step 4: calculate the signature
|
|
28
|
+
var signature = dataHashHelpers_1.getHashedDataAsHex(getSigningKey_1.getSigningKey(secretAccessKey, shortDate, signingRegion, signingService), stringToSign);
|
|
29
|
+
return signature;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=getSignature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSignature.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/utils/getSignature.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAItC,qDAAuD;AACvD,6DAA4D;AAC5D,iDAAgD;AAChD,qDAAoD;AAEpD;;;;;;;;;GASG;AACU,QAAA,YAAY,GAAG,UAC3B,OAAoB,EACpB,EAOgB;QANf,oCAAe,EACf,sBAAQ,EACR,oCAAe,EACf,wBAAS,EACT,gCAAa,EACb,kCAAc;IAGf,qCAAqC;IACrC,IAAM,gBAAgB,GAAG,yCAAmB,CAAC,OAAO,CAAC,CAAC;IAEtD,iDAAiD;IACjD,IAAM,aAAa,GAAG,oCAAkB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAEjE,kCAAkC;IAClC,IAAM,YAAY,GAAG,iCAAe,CACnC,QAAQ,EACR,eAAe,EACf,aAAa,CACb,CAAC;IAEF,kCAAkC;IAClC,IAAM,SAAS,GAAG,oCAAkB,CACnC,6BAAa,CAAC,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,CAAC,EACxE,YAAY,CACZ,CAAC;IAEF,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns signed headers.
|
|
3
|
+
*
|
|
4
|
+
* @param headers `headers` from the request.
|
|
5
|
+
* @returns List of headers included in canonical headers, separated by semicolons (;). This indicates which headers
|
|
6
|
+
* are part of the signing process. Header names must use lowercase characters and must appear in alphabetical order.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const getSignedHeaders: (headers: Record<string, string>) => string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
/**
|
|
6
|
+
* Returns signed headers.
|
|
7
|
+
*
|
|
8
|
+
* @param headers `headers` from the request.
|
|
9
|
+
* @returns List of headers included in canonical headers, separated by semicolons (;). This indicates which headers
|
|
10
|
+
* are part of the signing process. Header names must use lowercase characters and must appear in alphabetical order.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
exports.getSignedHeaders = function (headers) {
|
|
15
|
+
return Object.keys(headers)
|
|
16
|
+
.map(function (key) { return key.toLowerCase(); })
|
|
17
|
+
.sort()
|
|
18
|
+
.join(';');
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=getSignedHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSignedHeaders.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAItC;;;;;;;;GAQG;AACU,QAAA,gBAAgB,GAAG,UAAC,OAA+B;IAC/D,OAAA,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;SAClB,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,WAAW,EAAE,EAAjB,CAAiB,CAAC;SAC7B,IAAI,EAAE;SACN,IAAI,CAAC,GAAG,CAAC;AAHX,CAGW,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a signing key to be used for signing requests.
|
|
3
|
+
*
|
|
4
|
+
* @param secretAccessKey AWS secret access key from credentials.
|
|
5
|
+
* @param date Current date in the format 'YYYYMMDD'.
|
|
6
|
+
* @param region AWS region in which the service resides.
|
|
7
|
+
* @param service Service to which the signed request is being sent.
|
|
8
|
+
*
|
|
9
|
+
* @returns `Uint8Array` calculated from its composite parts.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const getSigningKey: (secretAccessKey: string, date: string, region: string, service: string) => Uint8Array;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
var constants_1 = require("../constants");
|
|
6
|
+
var dataHashHelpers_1 = require("./dataHashHelpers");
|
|
7
|
+
/**
|
|
8
|
+
* Returns a signing key to be used for signing requests.
|
|
9
|
+
*
|
|
10
|
+
* @param secretAccessKey AWS secret access key from credentials.
|
|
11
|
+
* @param date Current date in the format 'YYYYMMDD'.
|
|
12
|
+
* @param region AWS region in which the service resides.
|
|
13
|
+
* @param service Service to which the signed request is being sent.
|
|
14
|
+
*
|
|
15
|
+
* @returns `Uint8Array` calculated from its composite parts.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
exports.getSigningKey = function (secretAccessKey, date, region, service) {
|
|
20
|
+
var key = "" + constants_1.SIGNATURE_IDENTIFIER + secretAccessKey;
|
|
21
|
+
var dateKey = dataHashHelpers_1.getHashedData(key, date);
|
|
22
|
+
var regionKey = dataHashHelpers_1.getHashedData(dateKey, region);
|
|
23
|
+
var serviceKey = dataHashHelpers_1.getHashedData(regionKey, service);
|
|
24
|
+
var signingKey = dataHashHelpers_1.getHashedData(serviceKey, constants_1.KEY_TYPE_IDENTIFIER);
|
|
25
|
+
return signingKey;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=getSigningKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSigningKey.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,0CAAyE;AACzE,qDAAkD;AAElD;;;;;;;;;;;GAWG;AACU,QAAA,aAAa,GAAG,UAC5B,eAAuB,EACvB,IAAY,EACZ,MAAc,EACd,OAAe;IAEf,IAAM,GAAG,GAAG,KAAG,gCAAoB,GAAG,eAAiB,CAAC;IACxD,IAAM,OAAO,GAAG,+BAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACzC,IAAM,SAAS,GAAG,+BAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACjD,IAAM,UAAU,GAAG,+BAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACrD,IAAM,UAAU,GAAG,+BAAa,CAAC,UAAU,EAAE,+BAAmB,CAAC,CAAC;IAClE,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SignRequestOptions } from '../types';
|
|
2
|
+
import { SigningValues } from '../types/signer';
|
|
3
|
+
/**
|
|
4
|
+
* Extracts common values used for signing both requests and urls.
|
|
5
|
+
*
|
|
6
|
+
* @param options `SignRequestOptions` object containing values used to construct the signature.
|
|
7
|
+
* @returns Common `SigningValues` used for signing.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare const getSigningValues: ({ credentials, signingDate, signingRegion, signingService, }: SignRequestOptions) => SigningValues;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
var getCredentialScope_1 = require("./getCredentialScope");
|
|
6
|
+
var getFormattedDates_1 = require("./getFormattedDates");
|
|
7
|
+
/**
|
|
8
|
+
* Extracts common values used for signing both requests and urls.
|
|
9
|
+
*
|
|
10
|
+
* @param options `SignRequestOptions` object containing values used to construct the signature.
|
|
11
|
+
* @returns Common `SigningValues` used for signing.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
exports.getSigningValues = function (_a) {
|
|
16
|
+
var credentials = _a.credentials, _b = _a.signingDate, signingDate = _b === void 0 ? new Date() : _b, signingRegion = _a.signingRegion, signingService = _a.signingService;
|
|
17
|
+
// get properties from credentials
|
|
18
|
+
var accessKeyId = credentials.accessKeyId, secretAccessKey = credentials.secretAccessKey, sessionToken = credentials.sessionToken;
|
|
19
|
+
// get formatted dates for signing
|
|
20
|
+
var _c = getFormattedDates_1.getFormattedDates(signingDate), longDate = _c.longDate, shortDate = _c.shortDate;
|
|
21
|
+
// copy header and set signing properties
|
|
22
|
+
var credentialScope = getCredentialScope_1.getCredentialScope(shortDate, signingRegion, signingService);
|
|
23
|
+
return {
|
|
24
|
+
accessKeyId: accessKeyId,
|
|
25
|
+
credentialScope: credentialScope,
|
|
26
|
+
longDate: longDate,
|
|
27
|
+
secretAccessKey: secretAccessKey,
|
|
28
|
+
sessionToken: sessionToken,
|
|
29
|
+
shortDate: shortDate,
|
|
30
|
+
signingRegion: signingRegion,
|
|
31
|
+
signingService: signingService,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=getSigningValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSigningValues.js","sourceRoot":"","sources":["../../../../../../../src/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAItC,2DAA0D;AAC1D,yDAAwD;AAExD;;;;;;;GAOG;AACU,QAAA,gBAAgB,GAAG,UAAC,EAKZ;QAJpB,4BAAW,EACX,mBAAwB,EAAxB,6CAAwB,EACxB,gCAAa,EACb,kCAAc;IAEd,kCAAkC;IAC1B,IAAA,qCAAW,EAAE,6CAAe,EAAE,uCAAY,CAAiB;IACnE,kCAAkC;IAC5B,IAAA,uDAAwD,EAAtD,sBAAQ,EAAE,wBAA4C,CAAC;IAC/D,yCAAyC;IACzC,IAAM,eAAe,GAAG,uCAAkB,CACzC,SAAS,EACT,aAAa,EACb,cAAc,CACd,CAAC;IACF,OAAO;QACN,WAAW,aAAA;QACX,eAAe,iBAAA;QACf,QAAQ,UAAA;QACR,eAAe,iBAAA;QACf,YAAY,cAAA;QACZ,SAAS,WAAA;QACT,aAAa,eAAA;QACb,cAAc,gBAAA;KACd,CAAC;AACH,CAAC,CAAC"}
|