@smithy/signature-v4 5.3.12 → 5.3.13

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-cjs/index.js CHANGED
@@ -186,6 +186,19 @@ class HeaderFormatter {
186
186
  }
187
187
  }
188
188
  }
189
+ var HEADER_VALUE_TYPE;
190
+ (function (HEADER_VALUE_TYPE) {
191
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["boolTrue"] = 0] = "boolTrue";
192
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["boolFalse"] = 1] = "boolFalse";
193
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["byte"] = 2] = "byte";
194
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["short"] = 3] = "short";
195
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["integer"] = 4] = "integer";
196
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["long"] = 5] = "long";
197
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["byteArray"] = 6] = "byteArray";
198
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["string"] = 7] = "string";
199
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["timestamp"] = 8] = "timestamp";
200
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["uuid"] = 9] = "uuid";
201
+ })(HEADER_VALUE_TYPE || (HEADER_VALUE_TYPE = {}));
189
202
  const UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
190
203
  class Int64 {
191
204
  bytes;
package/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "@smithy/signature-v4",
3
- "version": "5.3.12",
3
+ "version": "5.3.13",
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 && yarn build:types:downlevel'",
10
- "build:cjs": "node ../../scripts/inline signature-v4",
11
- "build:es": "yarn g:tsc -p tsconfig.es.json",
9
+ "build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
10
+ "build:es:cjs": "yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline signature-v4",
12
11
  "build:types": "yarn g:tsc -p tsconfig.types.json",
13
12
  "build:types:downlevel": "premove dist-types/ts3.4 && downlevel-dts dist-types dist-types/ts3.4",
14
- "stage-release": "premove .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
15
13
  "clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
16
- "lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
17
- "format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"",
18
14
  "extract:docs": "api-extractor run --local",
15
+ "format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"",
16
+ "lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
17
+ "stage-release": "premove .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
19
18
  "test": "yarn g:vitest run",
20
19
  "test:watch": "yarn g:vitest watch"
21
20
  },
@@ -27,10 +26,10 @@
27
26
  "sideEffects": false,
28
27
  "dependencies": {
29
28
  "@smithy/is-array-buffer": "^4.2.2",
30
- "@smithy/protocol-http": "^5.3.12",
31
- "@smithy/types": "^4.13.1",
29
+ "@smithy/protocol-http": "^5.3.13",
30
+ "@smithy/types": "^4.14.0",
32
31
  "@smithy/util-hex-encoding": "^4.2.2",
33
- "@smithy/util-middleware": "^4.2.12",
32
+ "@smithy/util-middleware": "^4.2.13",
34
33
  "@smithy/util-uri-escape": "^4.2.2",
35
34
  "@smithy/util-utf8": "^4.2.2",
36
35
  "tslib": "^2.6.2"
@@ -1,24 +0,0 @@
1
- import { Int64 as IInt64, MessageHeaders } from "@smithy/types";
2
- /**
3
- * @internal
4
- * TODO: duplicated from @smithy/eventstream-codec to break large dependency.
5
- * TODO: This should be moved to its own deduped submodule in @smithy/core when submodules are implemented.
6
- */
7
- export declare class HeaderFormatter {
8
- format(headers: MessageHeaders): Uint8Array;
9
- private formatHeaderValue;
10
- }
11
- /**
12
- * TODO: duplicated from @smithy/eventstream-codec to break large dependency.
13
- * TODO: This should be moved to its own deduped submodule in @smithy/core when submodules are implemented.
14
- */
15
- export declare class Int64 implements IInt64 {
16
- readonly bytes: Uint8Array;
17
- constructor(bytes: Uint8Array);
18
- static fromNumber(number: number): Int64;
19
- /**
20
- * Called implicitly by infix arithmetic operators.
21
- */
22
- valueOf(): number;
23
- toString(): string;
24
- }
@@ -1,21 +0,0 @@
1
- import { EventSigner, EventSigningArguments, FormattedEvent, HttpRequest, MessageSigner, RequestPresigner, RequestPresigningArguments, RequestSigner, RequestSigningArguments, SignableMessage, SignedMessage, SigningArguments, StringSigner } from "@smithy/types";
2
- import { SignatureV4CryptoInit, SignatureV4Init } from "./SignatureV4Base";
3
- import { SignatureV4Base } from "./SignatureV4Base";
4
- /**
5
- * @public
6
- */
7
- export declare class SignatureV4 extends SignatureV4Base implements RequestPresigner, RequestSigner, StringSigner, EventSigner, MessageSigner {
8
- private readonly headerFormatter;
9
- constructor({ applyChecksum, credentials, region, service, sha256, uriEscapePath, }: SignatureV4Init & SignatureV4CryptoInit);
10
- presign(originalRequest: HttpRequest, options?: RequestPresigningArguments): Promise<HttpRequest>;
11
- sign(stringToSign: string, options?: SigningArguments): Promise<string>;
12
- sign(event: FormattedEvent, options: EventSigningArguments): Promise<string>;
13
- sign(event: SignableMessage, options: SigningArguments): Promise<SignedMessage>;
14
- sign(requestToSign: HttpRequest, options?: RequestSigningArguments): Promise<HttpRequest>;
15
- private signEvent;
16
- signMessage(signableMessage: SignableMessage, { signingDate, signingRegion, signingService }: SigningArguments): Promise<SignedMessage>;
17
- private signString;
18
- private signRequest;
19
- private getSignature;
20
- private getSigningKey;
21
- }
@@ -1,69 +0,0 @@
1
- import { AwsCredentialIdentity, ChecksumConstructor, DateInput, HashConstructor, HeaderBag, HttpRequest, Provider } from "@smithy/types";
2
- /**
3
- * @public
4
- */
5
- export interface SignatureV4Init {
6
- /**
7
- * The service signing name.
8
- */
9
- service: string;
10
- /**
11
- * The region name or a function that returns a promise that will be
12
- * resolved with the region name.
13
- */
14
- region: string | Provider<string>;
15
- /**
16
- * The credentials with which the request should be signed or a function
17
- * that returns a promise that will be resolved with credentials.
18
- */
19
- credentials: AwsCredentialIdentity | Provider<AwsCredentialIdentity>;
20
- /**
21
- * A constructor function for a hash object that will calculate SHA-256 HMAC
22
- * checksums.
23
- */
24
- sha256?: ChecksumConstructor | HashConstructor;
25
- /**
26
- * Whether to uri-escape the request URI path as part of computing the
27
- * canonical request string. This is required for every AWS service, except
28
- * Amazon S3, as of late 2017.
29
- *
30
- * @default [true]
31
- */
32
- uriEscapePath?: boolean;
33
- /**
34
- * Whether to calculate a checksum of the request body and include it as
35
- * either a request header (when signing) or as a query string parameter
36
- * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for
37
- * every other AWS service as of late 2017.
38
- *
39
- * @default [true]
40
- */
41
- applyChecksum?: boolean;
42
- }
43
- /**
44
- * @public
45
- */
46
- export interface SignatureV4CryptoInit {
47
- sha256: ChecksumConstructor | HashConstructor;
48
- }
49
- /**
50
- * @internal
51
- */
52
- export declare abstract class SignatureV4Base {
53
- protected readonly service: string;
54
- protected readonly regionProvider: Provider<string>;
55
- protected readonly credentialProvider: Provider<AwsCredentialIdentity>;
56
- protected readonly sha256: ChecksumConstructor | HashConstructor;
57
- private readonly uriEscapePath;
58
- protected readonly applyChecksum: boolean;
59
- protected constructor({ applyChecksum, credentials, region, service, sha256, uriEscapePath, }: SignatureV4Init & SignatureV4CryptoInit);
60
- protected createCanonicalRequest(request: HttpRequest, canonicalHeaders: HeaderBag, payloadHash: string): string;
61
- protected createStringToSign(longDate: string, credentialScope: string, canonicalRequest: string, algorithmIdentifier: string): Promise<string>;
62
- private getCanonicalPath;
63
- protected validateResolvedCredentials(credentials: unknown): void;
64
- protected formatDate(now: DateInput): {
65
- longDate: string;
66
- shortDate: string;
67
- };
68
- protected getCanonicalHeaderList(headers: object): string;
69
- }
@@ -1,43 +0,0 @@
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;
@@ -1,30 +0,0 @@
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
- * @internal
6
- *
7
- * @param shortDate - the current calendar date in the form YYYYMMDD.
8
- * @param region - the AWS region in which the service resides.
9
- * @param service - the service to which the signed request is being sent.
10
- */
11
- export declare const createScope: (shortDate: string, region: string, service: string) => string;
12
- /**
13
- * Derive a signing key from its composite parts.
14
- *
15
- * @internal
16
- *
17
- * @param sha256Constructor - a constructor function that can instantiate SHA-256
18
- * hash objects.
19
- * @param credentials - the credentials with which the request will be
20
- * signed.
21
- * @param shortDate - the current calendar date in the form YYYYMMDD.
22
- * @param region - the AWS region in which the service resides.
23
- * @param service - the service to which the signed request is being
24
- * sent.
25
- */
26
- export declare const getSigningKey: (sha256Constructor: ChecksumConstructor | HashConstructor, credentials: AwsCredentialIdentity, shortDate: string, region: string, service: string) => Promise<Uint8Array>;
27
- /**
28
- * @internal
29
- */
30
- export declare const clearCredentialCache: () => void;
@@ -1,5 +0,0 @@
1
- import { HeaderBag, HttpRequest } from "@smithy/types";
2
- /**
3
- * @internal
4
- */
5
- export declare const getCanonicalHeaders: ({ headers }: HttpRequest, unsignableHeaders?: Set<string>, signableHeaders?: Set<string>) => HeaderBag;
@@ -1,5 +0,0 @@
1
- import { HttpRequest } from "@smithy/types";
2
- /**
3
- * @internal
4
- */
5
- export declare const getCanonicalQuery: ({ query }: HttpRequest) => string;
@@ -1,5 +0,0 @@
1
- import { ChecksumConstructor, HashConstructor, HttpRequest } from "@smithy/types";
2
- /**
3
- * @internal
4
- */
5
- export declare const getPayloadHash: ({ headers, body }: HttpRequest, hashConstructor: ChecksumConstructor | HashConstructor) => Promise<string>;
@@ -1,4 +0,0 @@
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;
@@ -1,11 +0,0 @@
1
- export * from "./SignatureV4";
2
- export * from "./constants";
3
- export { getCanonicalHeaders } from "./getCanonicalHeaders";
4
- export { getCanonicalQuery } from "./getCanonicalQuery";
5
- export { getPayloadHash } from "./getPayloadHash";
6
- export { moveHeadersToQuery } from "./moveHeadersToQuery";
7
- export { prepareRequest } from "./prepareRequest";
8
- export * from "./credentialDerivation";
9
- export { SignatureV4Init, SignatureV4CryptoInit, SignatureV4Base } from "./SignatureV4Base";
10
- export { hasHeader } from "./headerUtil";
11
- export * from "./signature-v4a-container";
@@ -1,10 +0,0 @@
1
- import { HttpRequest as IHttpRequest, QueryParameterBag } from "@smithy/types";
2
- /**
3
- * @internal
4
- */
5
- export declare const moveHeadersToQuery: (request: IHttpRequest, options?: {
6
- unhoistableHeaders?: Set<string>;
7
- hoistableHeaders?: Set<string>;
8
- }) => IHttpRequest & {
9
- query: QueryParameterBag;
10
- };
@@ -1,5 +0,0 @@
1
- import { HttpRequest as IHttpRequest } from "@smithy/types";
2
- /**
3
- * @internal
4
- */
5
- export declare const prepareRequest: (request: IHttpRequest) => IHttpRequest;
@@ -1,24 +0,0 @@
1
- import { RequestSigner } from "@smithy/types";
2
- /**
3
- * @public
4
- */
5
- export type OptionalSigV4aSigner = {
6
- /**
7
- * This constructor is not typed so as not to require a type import
8
- * from the signature-v4a package.
9
- *
10
- * The true type is SignatureV4a from @smithy/signature-v4a.
11
- */
12
- new (options: any): RequestSigner;
13
- };
14
- /**
15
- * @public
16
- *
17
- * \@smithy/signature-v4a will install the constructor in this
18
- * container if it's installed.
19
- *
20
- * This avoids a runtime-require being interpreted statically by bundlers.
21
- */
22
- export declare const signatureV4aContainer: {
23
- SignatureV4a: null | OptionalSigV4aSigner;
24
- };
@@ -1,14 +0,0 @@
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>;
@@ -1,2 +0,0 @@
1
- export declare const iso8601: (time: number | string | Date) => string;
2
- export declare const toDate: (time: number | string | Date) => Date;