@smithy/signature-v4 1.0.0 → 1.0.2
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/dist-types/ts3.4/SignatureV4.d.ts +67 -0
- package/dist-types/ts3.4/cloneRequest.d.ts +6 -0
- package/dist-types/ts3.4/constants.d.ts +43 -0
- package/dist-types/ts3.4/credentialDerivation.d.ts +26 -0
- package/dist-types/ts3.4/getCanonicalHeaders.d.ts +5 -0
- package/dist-types/ts3.4/getCanonicalQuery.d.ts +5 -0
- package/dist-types/ts3.4/getPayloadHash.d.ts +5 -0
- package/dist-types/ts3.4/headerUtil.d.ts +4 -0
- package/dist-types/ts3.4/index.d.ts +7 -0
- package/dist-types/ts3.4/moveHeadersToQuery.d.ts +9 -0
- package/dist-types/ts3.4/prepareRequest.d.ts +5 -0
- package/dist-types/ts3.4/suite.fixture.d.ts +14 -0
- package/dist-types/ts3.4/utilDate.d.ts +2 -0
- package/package.json +14 -11
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { AwsCredentialIdentity, ChecksumConstructor, EventSigner, EventSigningArguments, FormattedEvent, HashConstructor, HttpRequest, MessageSigner, Provider, RequestPresigner, RequestPresigningArguments, RequestSigner, RequestSigningArguments, SignableMessage, SignedMessage, SigningArguments, StringSigner } from "@smithy/types";
|
|
2
|
+
export interface SignatureV4Init {
|
|
3
|
+
/**
|
|
4
|
+
* The service signing name.
|
|
5
|
+
*/
|
|
6
|
+
service: string;
|
|
7
|
+
/**
|
|
8
|
+
* The region name or a function that returns a promise that will be
|
|
9
|
+
* resolved with the region name.
|
|
10
|
+
*/
|
|
11
|
+
region: string | Provider<string>;
|
|
12
|
+
/**
|
|
13
|
+
* The credentials with which the request should be signed or a function
|
|
14
|
+
* that returns a promise that will be resolved with credentials.
|
|
15
|
+
*/
|
|
16
|
+
credentials: AwsCredentialIdentity | Provider<AwsCredentialIdentity>;
|
|
17
|
+
/**
|
|
18
|
+
* A constructor function for a hash object that will calculate SHA-256 HMAC
|
|
19
|
+
* checksums.
|
|
20
|
+
*/
|
|
21
|
+
sha256?: ChecksumConstructor | HashConstructor;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to uri-escape the request URI path as part of computing the
|
|
24
|
+
* canonical request string. This is required for every AWS service, except
|
|
25
|
+
* Amazon S3, as of late 2017.
|
|
26
|
+
*
|
|
27
|
+
* @default [true]
|
|
28
|
+
*/
|
|
29
|
+
uriEscapePath?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to calculate a checksum of the request body and include it as
|
|
32
|
+
* either a request header (when signing) or as a query string parameter
|
|
33
|
+
* (when presigning). This is required for AWS Glacier and Amazon S3 and optional for
|
|
34
|
+
* every other AWS service as of late 2017.
|
|
35
|
+
*
|
|
36
|
+
* @default [true]
|
|
37
|
+
*/
|
|
38
|
+
applyChecksum?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface SignatureV4CryptoInit {
|
|
41
|
+
sha256: ChecksumConstructor | HashConstructor;
|
|
42
|
+
}
|
|
43
|
+
export declare class SignatureV4 implements RequestPresigner, RequestSigner, StringSigner, EventSigner, MessageSigner {
|
|
44
|
+
private readonly service;
|
|
45
|
+
private readonly regionProvider;
|
|
46
|
+
private readonly credentialProvider;
|
|
47
|
+
private readonly sha256;
|
|
48
|
+
private readonly uriEscapePath;
|
|
49
|
+
private readonly applyChecksum;
|
|
50
|
+
private readonly headerMarshaller;
|
|
51
|
+
constructor({ applyChecksum, credentials, region, service, sha256, uriEscapePath, }: SignatureV4Init & SignatureV4CryptoInit);
|
|
52
|
+
presign(originalRequest: HttpRequest, options?: RequestPresigningArguments): Promise<HttpRequest>;
|
|
53
|
+
sign(stringToSign: string, options?: SigningArguments): Promise<string>;
|
|
54
|
+
sign(event: FormattedEvent, options: EventSigningArguments): Promise<string>;
|
|
55
|
+
sign(event: SignableMessage, options: SigningArguments): Promise<SignedMessage>;
|
|
56
|
+
sign(requestToSign: HttpRequest, options?: RequestSigningArguments): Promise<HttpRequest>;
|
|
57
|
+
private signEvent;
|
|
58
|
+
signMessage(signableMessage: SignableMessage, { signingDate, signingRegion, signingService }: SigningArguments): Promise<SignedMessage>;
|
|
59
|
+
private signString;
|
|
60
|
+
private signRequest;
|
|
61
|
+
private createCanonicalRequest;
|
|
62
|
+
private createStringToSign;
|
|
63
|
+
private getCanonicalPath;
|
|
64
|
+
private getSignature;
|
|
65
|
+
private getSigningKey;
|
|
66
|
+
private validateResolvedCredentials;
|
|
67
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare const ALGORITHM_QUERY_PARAM = "X-Amz-Algorithm";
|
|
2
|
+
export declare const CREDENTIAL_QUERY_PARAM = "X-Amz-Credential";
|
|
3
|
+
export declare const AMZ_DATE_QUERY_PARAM = "X-Amz-Date";
|
|
4
|
+
export declare const SIGNED_HEADERS_QUERY_PARAM = "X-Amz-SignedHeaders";
|
|
5
|
+
export declare const EXPIRES_QUERY_PARAM = "X-Amz-Expires";
|
|
6
|
+
export declare const SIGNATURE_QUERY_PARAM = "X-Amz-Signature";
|
|
7
|
+
export declare const TOKEN_QUERY_PARAM = "X-Amz-Security-Token";
|
|
8
|
+
export declare const REGION_SET_PARAM = "X-Amz-Region-Set";
|
|
9
|
+
export declare const AUTH_HEADER = "authorization";
|
|
10
|
+
export declare const AMZ_DATE_HEADER: string;
|
|
11
|
+
export declare const DATE_HEADER = "date";
|
|
12
|
+
export declare const GENERATED_HEADERS: string[];
|
|
13
|
+
export declare const SIGNATURE_HEADER: string;
|
|
14
|
+
export declare const SHA256_HEADER = "x-amz-content-sha256";
|
|
15
|
+
export declare const TOKEN_HEADER: string;
|
|
16
|
+
export declare const HOST_HEADER = "host";
|
|
17
|
+
export declare const ALWAYS_UNSIGNABLE_HEADERS: {
|
|
18
|
+
authorization: boolean;
|
|
19
|
+
"cache-control": boolean;
|
|
20
|
+
connection: boolean;
|
|
21
|
+
expect: boolean;
|
|
22
|
+
from: boolean;
|
|
23
|
+
"keep-alive": boolean;
|
|
24
|
+
"max-forwards": boolean;
|
|
25
|
+
pragma: boolean;
|
|
26
|
+
referer: boolean;
|
|
27
|
+
te: boolean;
|
|
28
|
+
trailer: boolean;
|
|
29
|
+
"transfer-encoding": boolean;
|
|
30
|
+
upgrade: boolean;
|
|
31
|
+
"user-agent": boolean;
|
|
32
|
+
"x-amzn-trace-id": boolean;
|
|
33
|
+
};
|
|
34
|
+
export declare const PROXY_HEADER_PATTERN: RegExp;
|
|
35
|
+
export declare const SEC_HEADER_PATTERN: RegExp;
|
|
36
|
+
export declare const UNSIGNABLE_PATTERNS: RegExp[];
|
|
37
|
+
export declare const ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256";
|
|
38
|
+
export declare const ALGORITHM_IDENTIFIER_V4A = "AWS4-ECDSA-P256-SHA256";
|
|
39
|
+
export declare const EVENT_ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256-PAYLOAD";
|
|
40
|
+
export declare const UNSIGNED_PAYLOAD = "UNSIGNED-PAYLOAD";
|
|
41
|
+
export declare const MAX_CACHE_SIZE = 50;
|
|
42
|
+
export declare const KEY_TYPE_IDENTIFIER = "aws4_request";
|
|
43
|
+
export declare const MAX_PRESIGNED_TTL: number;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AwsCredentialIdentity, ChecksumConstructor, HashConstructor } from "@smithy/types";
|
|
2
|
+
/**
|
|
3
|
+
* Create a string describing the scope of credentials used to sign a request.
|
|
4
|
+
*
|
|
5
|
+
* @param shortDate The current calendar date in the form YYYYMMDD.
|
|
6
|
+
* @param region The AWS region in which the service resides.
|
|
7
|
+
* @param service The service to which the signed request is being sent.
|
|
8
|
+
*/
|
|
9
|
+
export declare const createScope: (shortDate: string, region: string, service: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Derive a signing key from its composite parts
|
|
12
|
+
*
|
|
13
|
+
* @param sha256Constructor A constructor function that can instantiate SHA-256
|
|
14
|
+
* hash objects.
|
|
15
|
+
* @param credentials The credentials with which the request will be
|
|
16
|
+
* signed.
|
|
17
|
+
* @param shortDate The current calendar date in the form YYYYMMDD.
|
|
18
|
+
* @param region The AWS region in which the service resides.
|
|
19
|
+
* @param service The service to which the signed request is being
|
|
20
|
+
* sent.
|
|
21
|
+
*/
|
|
22
|
+
export declare const getSigningKey: (sha256Constructor: ChecksumConstructor | HashConstructor, credentials: AwsCredentialIdentity, shortDate: string, region: string, service: string) => Promise<Uint8Array>;
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare const clearCredentialCache: () => void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { HeaderBag } from "@smithy/types";
|
|
2
|
+
export declare const hasHeader: (soughtHeader: string, headers: HeaderBag) => boolean;
|
|
3
|
+
export declare const getHeaderValue: (soughtHeader: string, headers: HeaderBag) => string | undefined;
|
|
4
|
+
export declare const deleteHeader: (soughtHeader: string, headers: HeaderBag) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./SignatureV4";
|
|
2
|
+
export { getCanonicalHeaders } from "./getCanonicalHeaders";
|
|
3
|
+
export { getCanonicalQuery } from "./getCanonicalQuery";
|
|
4
|
+
export { getPayloadHash } from "./getPayloadHash";
|
|
5
|
+
export { moveHeadersToQuery } from "./moveHeadersToQuery";
|
|
6
|
+
export { prepareRequest } from "./prepareRequest";
|
|
7
|
+
export * from "./credentialDerivation";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HttpRequest } from "@smithy/types";
|
|
2
|
+
export interface TestCase {
|
|
3
|
+
name: string;
|
|
4
|
+
request: HttpRequest;
|
|
5
|
+
authorization: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const region = "us-east-1";
|
|
8
|
+
export declare const service = "service";
|
|
9
|
+
export declare const credentials: {
|
|
10
|
+
accessKeyId: string;
|
|
11
|
+
secretAccessKey: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const signingDate: Date;
|
|
14
|
+
export declare const requests: Array<TestCase>;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/signature-v4",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A standalone implementation of the AWS Signature V4 request signing algorithm",
|
|
5
5
|
"main": "./dist-cjs/index.js",
|
|
6
6
|
"module": "./dist-es/index.js",
|
|
7
7
|
"types": "./dist-types/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
9
|
+
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
10
10
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
11
11
|
"build:es": "tsc -p tsconfig.es.json",
|
|
12
12
|
"build:types": "tsc -p tsconfig.types.json",
|
|
@@ -24,18 +24,18 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@smithy/eventstream-codec": "
|
|
28
|
-
"@smithy/is-array-buffer": "
|
|
29
|
-
"@smithy/types": "
|
|
30
|
-
"@smithy/util-hex-encoding": "
|
|
31
|
-
"@smithy/util-middleware": "
|
|
32
|
-
"@smithy/util-uri-escape": "
|
|
33
|
-
"@smithy/util-utf8": "
|
|
27
|
+
"@smithy/eventstream-codec": "^1.0.2",
|
|
28
|
+
"@smithy/is-array-buffer": "^1.0.2",
|
|
29
|
+
"@smithy/types": "^1.1.1",
|
|
30
|
+
"@smithy/util-hex-encoding": "^1.0.2",
|
|
31
|
+
"@smithy/util-middleware": "^1.0.2",
|
|
32
|
+
"@smithy/util-uri-escape": "^1.0.2",
|
|
33
|
+
"@smithy/util-utf8": "^1.0.2",
|
|
34
34
|
"tslib": "^2.5.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@aws-crypto/sha256-js": "3.0.0",
|
|
38
|
-
"@smithy/protocol-http": "
|
|
38
|
+
"@smithy/protocol-http": "^1.1.1",
|
|
39
39
|
"@tsconfig/recommended": "1.0.1",
|
|
40
40
|
"concurrently": "7.0.0",
|
|
41
41
|
"downlevel-dts": "0.10.1",
|
|
@@ -65,5 +65,8 @@
|
|
|
65
65
|
},
|
|
66
66
|
"typedoc": {
|
|
67
67
|
"entryPoint": "src/index.ts"
|
|
68
|
+
},
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"directory": ".release/package"
|
|
68
71
|
}
|
|
69
|
-
}
|
|
72
|
+
}
|