@cdk8s/awscdk-resolver 0.0.101 → 0.0.103

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.
Files changed (153) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/package.json +14 -14
  4. package/node_modules/@aws-sdk/client-sso/package.json +11 -11
  5. package/node_modules/@aws-sdk/client-sso-oidc/package.json +13 -13
  6. package/node_modules/@aws-sdk/client-sts/package.json +13 -13
  7. package/node_modules/@aws-sdk/core/README.md +35 -1
  8. package/node_modules/@aws-sdk/core/client.js +5 -0
  9. package/node_modules/@aws-sdk/core/dist-cjs/index.js +5 -437
  10. package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js +38 -0
  11. package/node_modules/@aws-sdk/core/dist-cjs/submodules/httpAuthSchemes/index.js +226 -0
  12. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +228 -0
  13. package/node_modules/@aws-sdk/core/dist-es/index.js +3 -3
  14. package/node_modules/@aws-sdk/core/dist-types/index.d.ts +22 -3
  15. package/node_modules/@aws-sdk/core/dist-types/ts3.4/index.d.ts +3 -3
  16. package/node_modules/@aws-sdk/core/httpAuthSchemes.js +5 -0
  17. package/node_modules/@aws-sdk/core/package.json +39 -2
  18. package/node_modules/@aws-sdk/core/protocols.js +5 -0
  19. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  20. package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
  21. package/node_modules/@aws-sdk/credential-provider-ini/package.json +7 -7
  22. package/node_modules/@aws-sdk/credential-provider-node/package.json +8 -8
  23. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  24. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  25. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  26. package/node_modules/@aws-sdk/middleware-host-header/package.json +2 -2
  27. package/node_modules/@aws-sdk/middleware-logger/package.json +2 -2
  28. package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +2 -2
  29. package/node_modules/@aws-sdk/middleware-user-agent/package.json +3 -3
  30. package/node_modules/@aws-sdk/region-config-resolver/package.json +2 -2
  31. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  32. package/node_modules/@aws-sdk/types/dist-cjs/index.js +0 -4
  33. package/node_modules/@aws-sdk/types/dist-types/logger.d.ts +2 -2
  34. package/node_modules/@aws-sdk/types/package.json +1 -1
  35. package/node_modules/@aws-sdk/util-endpoints/package.json +2 -2
  36. package/node_modules/@aws-sdk/util-user-agent-browser/package.json +2 -2
  37. package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
  38. package/node_modules/@smithy/core/package.json +3 -3
  39. package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +10 -3
  40. package/node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js +10 -3
  41. package/node_modules/@smithy/fetch-http-handler/package.json +1 -1
  42. package/node_modules/@smithy/middleware-retry/package.json +2 -2
  43. package/node_modules/@smithy/smithy-client/package.json +2 -2
  44. package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
  45. package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
  46. package/node_modules/@smithy/util-stream/package.json +2 -2
  47. package/package.json +5 -5
  48. package/node_modules/@aws-sdk/core/CHANGELOG.md +0 -323
  49. package/node_modules/@aws-sdk/core/api-extractor.json +0 -4
  50. package/node_modules/@aws-sdk/core/dist-cjs/client/emitWarningIfUnsupportedVersion.js +0 -1
  51. package/node_modules/@aws-sdk/core/dist-cjs/client/index.js +0 -1
  52. package/node_modules/@aws-sdk/core/dist-cjs/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js +0 -1
  53. package/node_modules/@aws-sdk/core/dist-cjs/httpAuthSchemes/aws_sdk/index.js +0 -1
  54. package/node_modules/@aws-sdk/core/dist-cjs/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js +0 -1
  55. package/node_modules/@aws-sdk/core/dist-cjs/httpAuthSchemes/index.js +0 -1
  56. package/node_modules/@aws-sdk/core/dist-cjs/httpAuthSchemes/utils/getDateHeader.js +0 -1
  57. package/node_modules/@aws-sdk/core/dist-cjs/httpAuthSchemes/utils/getSkewCorrectedDate.js +0 -1
  58. package/node_modules/@aws-sdk/core/dist-cjs/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js +0 -1
  59. package/node_modules/@aws-sdk/core/dist-cjs/httpAuthSchemes/utils/index.js +0 -1
  60. package/node_modules/@aws-sdk/core/dist-cjs/httpAuthSchemes/utils/isClockSkewed.js +0 -1
  61. package/node_modules/@aws-sdk/core/dist-cjs/protocols/coercing-serializers.js +0 -1
  62. package/node_modules/@aws-sdk/core/dist-cjs/protocols/common.js +0 -1
  63. package/node_modules/@aws-sdk/core/dist-cjs/protocols/index.js +0 -1
  64. package/node_modules/@aws-sdk/core/dist-cjs/protocols/json/awsExpectUnion.js +0 -1
  65. package/node_modules/@aws-sdk/core/dist-cjs/protocols/json/parseJsonBody.js +0 -1
  66. package/node_modules/@aws-sdk/core/dist-cjs/protocols/xml/parseXmlBody.js +0 -1
  67. package/node_modules/@aws-sdk/core/integ/request-handlers/request-handlers.integ.spec.ts +0 -158
  68. package/node_modules/@aws-sdk/core/jest.config.integ.js +0 -4
  69. package/node_modules/@aws-sdk/core/jest.config.js +0 -6
  70. package/node_modules/@aws-sdk/core/scripts/lint.js +0 -24
  71. package/node_modules/@aws-sdk/core/src/client/emitWarningIfUnsupportedVersion.spec.ts +0 -70
  72. package/node_modules/@aws-sdk/core/src/client/emitWarningIfUnsupportedVersion.ts +0 -26
  73. package/node_modules/@aws-sdk/core/src/client/index.ts +0 -1
  74. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.spec.ts +0 -30
  75. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.ts +0 -134
  76. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/aws_sdk/index.ts +0 -2
  77. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.ts +0 -244
  78. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/index.ts +0 -1
  79. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/utils/getDateHeader.ts +0 -7
  80. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/utils/getSkewCorrectedDate.spec.ts +0 -17
  81. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/utils/getSkewCorrectedDate.ts +0 -8
  82. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/utils/getUpdatedSystemClockOffset.spec.ts +0 -37
  83. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/utils/getUpdatedSystemClockOffset.ts +0 -18
  84. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/utils/index.ts +0 -3
  85. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/utils/isClockSkewed.spec.ts +0 -32
  86. package/node_modules/@aws-sdk/core/src/httpAuthSchemes/utils/isClockSkewed.ts +0 -12
  87. package/node_modules/@aws-sdk/core/src/index.ts +0 -3
  88. package/node_modules/@aws-sdk/core/src/protocols/coercing-serializers.spec.ts +0 -76
  89. package/node_modules/@aws-sdk/core/src/protocols/coercing-serializers.ts +0 -72
  90. package/node_modules/@aws-sdk/core/src/protocols/common.ts +0 -5
  91. package/node_modules/@aws-sdk/core/src/protocols/index.ts +0 -4
  92. package/node_modules/@aws-sdk/core/src/protocols/json/awsExpectUnion.spec.ts +0 -30
  93. package/node_modules/@aws-sdk/core/src/protocols/json/awsExpectUnion.ts +0 -17
  94. package/node_modules/@aws-sdk/core/src/protocols/json/parseJsonBody.ts +0 -60
  95. package/node_modules/@aws-sdk/core/src/protocols/xml/parseXmlBody.spec.ts +0 -60
  96. package/node_modules/@aws-sdk/core/src/protocols/xml/parseXmlBody.ts +0 -64
  97. package/node_modules/@aws-sdk/core/tsconfig.cjs.json +0 -9
  98. package/node_modules/@aws-sdk/core/tsconfig.cjs.tsbuildinfo +0 -1
  99. package/node_modules/@aws-sdk/core/tsconfig.es.json +0 -9
  100. package/node_modules/@aws-sdk/core/tsconfig.es.tsbuildinfo +0 -1
  101. package/node_modules/@aws-sdk/core/tsconfig.types.json +0 -9
  102. package/node_modules/@aws-sdk/core/tsconfig.types.tsbuildinfo +0 -1
  103. /package/node_modules/@aws-sdk/core/dist-es/{client → submodules/client}/emitWarningIfUnsupportedVersion.js +0 -0
  104. /package/node_modules/@aws-sdk/core/dist-es/{client → submodules/client}/index.js +0 -0
  105. /package/node_modules/@aws-sdk/core/dist-es/{httpAuthSchemes → submodules/httpAuthSchemes}/aws_sdk/AwsSdkSigV4Signer.js +0 -0
  106. /package/node_modules/@aws-sdk/core/dist-es/{httpAuthSchemes → submodules/httpAuthSchemes}/aws_sdk/index.js +0 -0
  107. /package/node_modules/@aws-sdk/core/dist-es/{httpAuthSchemes → submodules/httpAuthSchemes}/aws_sdk/resolveAwsSdkSigV4Config.js +0 -0
  108. /package/node_modules/@aws-sdk/core/dist-es/{httpAuthSchemes → submodules/httpAuthSchemes}/index.js +0 -0
  109. /package/node_modules/@aws-sdk/core/dist-es/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/getDateHeader.js +0 -0
  110. /package/node_modules/@aws-sdk/core/dist-es/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/getSkewCorrectedDate.js +0 -0
  111. /package/node_modules/@aws-sdk/core/dist-es/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/getUpdatedSystemClockOffset.js +0 -0
  112. /package/node_modules/@aws-sdk/core/dist-es/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/index.js +0 -0
  113. /package/node_modules/@aws-sdk/core/dist-es/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/isClockSkewed.js +0 -0
  114. /package/node_modules/@aws-sdk/core/dist-es/{protocols → submodules/protocols}/coercing-serializers.js +0 -0
  115. /package/node_modules/@aws-sdk/core/dist-es/{protocols → submodules/protocols}/common.js +0 -0
  116. /package/node_modules/@aws-sdk/core/dist-es/{protocols → submodules/protocols}/index.js +0 -0
  117. /package/node_modules/@aws-sdk/core/dist-es/{protocols → submodules/protocols}/json/awsExpectUnion.js +0 -0
  118. /package/node_modules/@aws-sdk/core/dist-es/{protocols → submodules/protocols}/json/parseJsonBody.js +0 -0
  119. /package/node_modules/@aws-sdk/core/dist-es/{protocols → submodules/protocols}/xml/parseXmlBody.js +0 -0
  120. /package/node_modules/@aws-sdk/core/dist-types/{client → submodules/client}/emitWarningIfUnsupportedVersion.d.ts +0 -0
  121. /package/node_modules/@aws-sdk/core/dist-types/{client → submodules/client}/index.d.ts +0 -0
  122. /package/node_modules/@aws-sdk/core/dist-types/{httpAuthSchemes → submodules/httpAuthSchemes}/aws_sdk/AwsSdkSigV4Signer.d.ts +0 -0
  123. /package/node_modules/@aws-sdk/core/dist-types/{httpAuthSchemes → submodules/httpAuthSchemes}/aws_sdk/index.d.ts +0 -0
  124. /package/node_modules/@aws-sdk/core/dist-types/{httpAuthSchemes → submodules/httpAuthSchemes}/aws_sdk/resolveAwsSdkSigV4Config.d.ts +0 -0
  125. /package/node_modules/@aws-sdk/core/dist-types/{httpAuthSchemes → submodules/httpAuthSchemes}/index.d.ts +0 -0
  126. /package/node_modules/@aws-sdk/core/dist-types/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/getDateHeader.d.ts +0 -0
  127. /package/node_modules/@aws-sdk/core/dist-types/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/getSkewCorrectedDate.d.ts +0 -0
  128. /package/node_modules/@aws-sdk/core/dist-types/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/getUpdatedSystemClockOffset.d.ts +0 -0
  129. /package/node_modules/@aws-sdk/core/dist-types/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/index.d.ts +0 -0
  130. /package/node_modules/@aws-sdk/core/dist-types/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/isClockSkewed.d.ts +0 -0
  131. /package/node_modules/@aws-sdk/core/dist-types/{protocols → submodules/protocols}/coercing-serializers.d.ts +0 -0
  132. /package/node_modules/@aws-sdk/core/dist-types/{protocols → submodules/protocols}/common.d.ts +0 -0
  133. /package/node_modules/@aws-sdk/core/dist-types/{protocols → submodules/protocols}/index.d.ts +0 -0
  134. /package/node_modules/@aws-sdk/core/dist-types/{protocols → submodules/protocols}/json/awsExpectUnion.d.ts +0 -0
  135. /package/node_modules/@aws-sdk/core/dist-types/{protocols → submodules/protocols}/json/parseJsonBody.d.ts +0 -0
  136. /package/node_modules/@aws-sdk/core/dist-types/{protocols → submodules/protocols}/xml/parseXmlBody.d.ts +0 -0
  137. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{client → submodules/client}/emitWarningIfUnsupportedVersion.d.ts +0 -0
  138. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{client → submodules/client}/index.d.ts +0 -0
  139. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{httpAuthSchemes → submodules/httpAuthSchemes}/aws_sdk/AwsSdkSigV4Signer.d.ts +0 -0
  140. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{httpAuthSchemes → submodules/httpAuthSchemes}/aws_sdk/index.d.ts +0 -0
  141. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{httpAuthSchemes → submodules/httpAuthSchemes}/aws_sdk/resolveAwsSdkSigV4Config.d.ts +0 -0
  142. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{httpAuthSchemes → submodules/httpAuthSchemes}/index.d.ts +0 -0
  143. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/getDateHeader.d.ts +0 -0
  144. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/getSkewCorrectedDate.d.ts +0 -0
  145. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/getUpdatedSystemClockOffset.d.ts +0 -0
  146. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/index.d.ts +0 -0
  147. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{httpAuthSchemes → submodules/httpAuthSchemes}/utils/isClockSkewed.d.ts +0 -0
  148. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{protocols → submodules/protocols}/coercing-serializers.d.ts +0 -0
  149. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{protocols → submodules/protocols}/common.d.ts +0 -0
  150. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{protocols → submodules/protocols}/index.d.ts +0 -0
  151. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{protocols → submodules/protocols}/json/awsExpectUnion.d.ts +0 -0
  152. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{protocols → submodules/protocols}/json/parseJsonBody.d.ts +0 -0
  153. /package/node_modules/@aws-sdk/core/dist-types/ts3.4/{protocols → submodules/protocols}/xml/parseXmlBody.d.ts +0 -0
@@ -1 +0,0 @@
1
- export * from "./emitWarningIfUnsupportedVersion";
@@ -1,30 +0,0 @@
1
- import { AwsSdkSigV4Signer } from "./AwsSdkSigV4Signer";
2
-
3
- describe(AwsSdkSigV4Signer.name, () => {
4
- it("sets clockSkewCorrected metadata in error handler if systemClockOffset was updated", async () => {
5
- const signer = new AwsSdkSigV4Signer();
6
-
7
- let error: Error | any;
8
- try {
9
- signer.errorHandler({
10
- config: {
11
- systemClockOffset: 30 * 60 * 1000,
12
- },
13
- })(
14
- Object.assign(new Error("uh oh"), {
15
- $metadata: {},
16
- $response: {
17
- headers: {
18
- date: new Date().toISOString(),
19
- },
20
- statusCode: 500,
21
- },
22
- })
23
- );
24
- } catch (e) {
25
- error = e as Error;
26
- }
27
-
28
- expect((error as any).$metadata.clockSkewCorrected).toBe(true);
29
- });
30
- });
@@ -1,134 +0,0 @@
1
- import { HttpRequest } from "@smithy/protocol-http";
2
- import { ServiceException } from "@smithy/smithy-client";
3
- import {
4
- AuthScheme,
5
- AwsCredentialIdentity,
6
- HandlerExecutionContext,
7
- HttpRequest as IHttpRequest,
8
- HttpResponse,
9
- HttpSigner,
10
- RequestSigner,
11
- } from "@smithy/types";
12
-
13
- import { getDateHeader, getSkewCorrectedDate, getUpdatedSystemClockOffset } from "../utils";
14
-
15
- /**
16
- * @internal
17
- */
18
- const throwSigningPropertyError = <T>(name: string, property: T | undefined): T | never => {
19
- if (!property) {
20
- throw new Error(`Property \`${name}\` is not resolved for AWS SDK SigV4Auth`);
21
- }
22
- return property;
23
- };
24
-
25
- /**
26
- * @internal
27
- */
28
- interface AwsSdkSigV4Config {
29
- systemClockOffset: number;
30
- signer: (authScheme?: AuthScheme) => Promise<RequestSigner>;
31
- }
32
-
33
- /**
34
- * @internal
35
- */
36
- interface AwsSdkSigV4AuthSigningProperties {
37
- config: AwsSdkSigV4Config;
38
- signer: RequestSigner;
39
- signingRegion?: string;
40
- signingName?: string;
41
- }
42
-
43
- /**
44
- * @internal
45
- */
46
- interface AwsSdkSigV4Exception extends ServiceException {
47
- ServerTime?: string;
48
- $metadata: ServiceException["$metadata"] & {
49
- clockSkewCorrected?: boolean;
50
- };
51
- }
52
-
53
- /**
54
- * @internal
55
- */
56
- const validateSigningProperties = async (
57
- signingProperties: Record<string, unknown>
58
- ): Promise<AwsSdkSigV4AuthSigningProperties> => {
59
- const context = throwSigningPropertyError(
60
- "context",
61
- signingProperties.context as HandlerExecutionContext | undefined
62
- );
63
- const config = throwSigningPropertyError("config", signingProperties.config as AwsSdkSigV4Config | undefined);
64
- const authScheme = context.endpointV2?.properties?.authSchemes?.[0];
65
- const signerFunction = throwSigningPropertyError(
66
- "signer",
67
- config.signer as ((authScheme?: AuthScheme) => Promise<RequestSigner>) | undefined
68
- );
69
- const signer = await signerFunction(authScheme);
70
- const signingRegion: string | undefined = signingProperties?.signingRegion as string | undefined;
71
- const signingName = signingProperties?.signingName as string | undefined;
72
- return {
73
- config,
74
- signer,
75
- signingRegion,
76
- signingName,
77
- };
78
- };
79
-
80
- /**
81
- * @internal
82
- */
83
- export class AwsSdkSigV4Signer implements HttpSigner {
84
- async sign(
85
- httpRequest: IHttpRequest,
86
- /**
87
- * `identity` is bound in {@link resolveAWSSDKSigV4Config}
88
- */
89
- identity: AwsCredentialIdentity,
90
- signingProperties: Record<string, unknown>
91
- ): Promise<IHttpRequest> {
92
- if (!HttpRequest.isInstance(httpRequest)) {
93
- throw new Error("The request is not an instance of `HttpRequest` and cannot be signed");
94
- }
95
- const { config, signer, signingRegion, signingName } = await validateSigningProperties(signingProperties);
96
-
97
- const signedRequest = await signer.sign(httpRequest, {
98
- signingDate: getSkewCorrectedDate(config.systemClockOffset),
99
- signingRegion: signingRegion,
100
- signingService: signingName,
101
- });
102
- return signedRequest;
103
- }
104
-
105
- errorHandler(signingProperties: Record<string, unknown>): (error: Error) => never {
106
- return (error: Error) => {
107
- const serverTime: string | undefined =
108
- (error as AwsSdkSigV4Exception).ServerTime ?? getDateHeader((error as AwsSdkSigV4Exception).$response);
109
- if (serverTime) {
110
- const config = throwSigningPropertyError("config", signingProperties.config as AwsSdkSigV4Config | undefined);
111
- const initialSystemClockOffset = config.systemClockOffset;
112
- config.systemClockOffset = getUpdatedSystemClockOffset(serverTime, config.systemClockOffset);
113
- const clockSkewCorrected = config.systemClockOffset !== initialSystemClockOffset;
114
- if (clockSkewCorrected && (error as AwsSdkSigV4Exception).$metadata) {
115
- (error as AwsSdkSigV4Exception).$metadata.clockSkewCorrected = true;
116
- }
117
- }
118
- throw error;
119
- };
120
- }
121
-
122
- successHandler(httpResponse: HttpResponse | unknown, signingProperties: Record<string, unknown>): void {
123
- const dateHeader = getDateHeader(httpResponse);
124
- if (dateHeader) {
125
- const config = throwSigningPropertyError("config", signingProperties.config as AwsSdkSigV4Config | undefined);
126
- config.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, config.systemClockOffset);
127
- }
128
- }
129
- }
130
-
131
- /**
132
- * @deprecated renamed to {@link AwsSdkSigV4Signer}
133
- */
134
- export const AWSSDKSigV4Signer = AwsSdkSigV4Signer;
@@ -1,2 +0,0 @@
1
- export * from "./AwsSdkSigV4Signer";
2
- export * from "./resolveAwsSdkSigV4Config";
@@ -1,244 +0,0 @@
1
- import {
2
- doesIdentityRequireRefresh,
3
- isIdentityExpired,
4
- memoizeIdentityProvider,
5
- normalizeProvider,
6
- } from "@smithy/core";
7
- import { SignatureV4, SignatureV4CryptoInit, SignatureV4Init } from "@smithy/signature-v4";
8
- import {
9
- AuthScheme,
10
- AwsCredentialIdentity,
11
- AwsCredentialIdentityProvider,
12
- ChecksumConstructor,
13
- HashConstructor,
14
- MemoizedProvider,
15
- Provider,
16
- RegionInfo,
17
- RegionInfoProvider,
18
- RequestSigner,
19
- } from "@smithy/types";
20
-
21
- /**
22
- * @internal
23
- */
24
- export interface AwsSdkSigV4AuthInputConfig {
25
- /**
26
- * The credentials used to sign requests.
27
- */
28
- credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider;
29
-
30
- /**
31
- * The signer to use when signing requests.
32
- */
33
- signer?: RequestSigner | ((authScheme?: AuthScheme) => Promise<RequestSigner>);
34
-
35
- /**
36
- * Whether to escape request path when signing the request.
37
- */
38
- signingEscapePath?: boolean;
39
-
40
- /**
41
- * An offset value in milliseconds to apply to all signing times.
42
- */
43
- systemClockOffset?: number;
44
-
45
- /**
46
- * The region where you want to sign your request against. This
47
- * can be different to the region in the endpoint.
48
- */
49
- signingRegion?: string;
50
-
51
- /**
52
- * The injectable SigV4-compatible signer class constructor. If not supplied,
53
- * regular SignatureV4 constructor will be used.
54
- *
55
- * @internal
56
- */
57
- signerConstructor?: new (options: SignatureV4Init & SignatureV4CryptoInit) => RequestSigner;
58
- }
59
-
60
- /**
61
- * @internal
62
- */
63
- export interface AwsSdkSigV4PreviouslyResolved {
64
- credentialDefaultProvider?: (input: any) => MemoizedProvider<AwsCredentialIdentity>;
65
- region: string | Provider<string>;
66
- sha256: ChecksumConstructor | HashConstructor;
67
- signingName?: string;
68
- regionInfoProvider?: RegionInfoProvider;
69
- defaultSigningName?: string;
70
- serviceId: string;
71
- useFipsEndpoint: Provider<boolean>;
72
- useDualstackEndpoint: Provider<boolean>;
73
- }
74
-
75
- /**
76
- * @internal
77
- */
78
- export interface AwsSdkSigV4AuthResolvedConfig {
79
- /**
80
- * Resolved value for input config {@link AwsSdkSigV4AuthInputConfig.credentials}
81
- * This provider MAY memoize the loaded credentials for certain period.
82
- * See {@link MemoizedProvider} for more information.
83
- */
84
- credentials: AwsCredentialIdentityProvider;
85
- /**
86
- * Resolved value for input config {@link AwsSdkSigV4AuthInputConfig.signer}
87
- */
88
- signer: (authScheme?: AuthScheme) => Promise<RequestSigner>;
89
- /**
90
- * Resolved value for input config {@link AwsSdkSigV4AuthInputConfig.signingEscapePath}
91
- */
92
- signingEscapePath: boolean;
93
- /**
94
- * Resolved value for input config {@link AwsSdkSigV4AuthInputConfig.systemClockOffset}
95
- */
96
- systemClockOffset: number;
97
- }
98
-
99
- /**
100
- * @internal
101
- */
102
- export const resolveAwsSdkSigV4Config = <T>(
103
- config: T & AwsSdkSigV4AuthInputConfig & AwsSdkSigV4PreviouslyResolved
104
- ): T & AwsSdkSigV4AuthResolvedConfig => {
105
- // Normalize credentials
106
- let normalizedCreds: AwsCredentialIdentityProvider | undefined;
107
- if (config.credentials) {
108
- normalizedCreds = memoizeIdentityProvider(config.credentials, isIdentityExpired, doesIdentityRequireRefresh);
109
- }
110
- if (!normalizedCreds) {
111
- // credentialDefaultProvider should always be populated, but in case
112
- // it isn't, set a default identity provider that throws an error
113
- if (config.credentialDefaultProvider) {
114
- normalizedCreds = normalizeProvider(
115
- config.credentialDefaultProvider(
116
- Object.assign({}, config as any, {
117
- parentClientConfig: config,
118
- })
119
- )
120
- );
121
- } else {
122
- normalizedCreds = async () => {
123
- throw new Error("`credentials` is missing");
124
- };
125
- }
126
- }
127
-
128
- // Populate sigv4 arguments
129
- const {
130
- // Default for signingEscapePath
131
- signingEscapePath = true,
132
- // Default for systemClockOffset
133
- systemClockOffset = config.systemClockOffset || 0,
134
- // No default for sha256 since it is platform dependent
135
- sha256,
136
- } = config;
137
-
138
- // Resolve signer
139
- let signer: (authScheme?: AuthScheme) => Promise<RequestSigner>;
140
- if (config.signer) {
141
- // if signer is supplied by user, normalize it to a function returning a promise for signer.
142
- signer = normalizeProvider(config.signer);
143
- } else if (config.regionInfoProvider) {
144
- // This branch is for endpoints V1.
145
- // construct a provider inferring signing from region.
146
- signer = () =>
147
- normalizeProvider(config.region)()
148
- .then(
149
- async (region) =>
150
- [
151
- (await config.regionInfoProvider!(region, {
152
- useFipsEndpoint: await config.useFipsEndpoint(),
153
- useDualstackEndpoint: await config.useDualstackEndpoint(),
154
- })) || {},
155
- region,
156
- ] as [RegionInfo, string]
157
- )
158
- .then(([regionInfo, region]) => {
159
- const { signingRegion, signingService } = regionInfo;
160
- // update client's singing region and signing service config if they are resolved.
161
- // signing region resolving order: user supplied signingRegion -> endpoints.json inferred region -> client region
162
- config.signingRegion = config.signingRegion || signingRegion || region;
163
- // signing name resolving order:
164
- // user supplied signingName -> endpoints.json inferred (credential scope -> model arnNamespace) -> model service id
165
- config.signingName = config.signingName || signingService || config.serviceId;
166
-
167
- const params: SignatureV4Init & SignatureV4CryptoInit = {
168
- ...config,
169
- credentials: normalizedCreds!,
170
- region: config.signingRegion,
171
- service: config.signingName,
172
- sha256,
173
- uriEscapePath: signingEscapePath,
174
- };
175
- const SignerCtor = config.signerConstructor || SignatureV4;
176
- return new SignerCtor(params);
177
- });
178
- } else {
179
- // This branch is for endpoints V2.
180
- // Handle endpoints v2 that resolved per-command
181
- // TODO: need total refactor for reference auth architecture.
182
- signer = async (authScheme?: AuthScheme) => {
183
- authScheme = Object.assign(
184
- {},
185
- {
186
- name: "sigv4",
187
- signingName: config.signingName || config.defaultSigningName!,
188
- signingRegion: await normalizeProvider(config.region)(),
189
- properties: {},
190
- },
191
- authScheme
192
- );
193
-
194
- const signingRegion = authScheme.signingRegion;
195
- const signingService = authScheme.signingName;
196
- // update client's singing region and signing service config if they are resolved.
197
- // signing region resolving order: user supplied signingRegion -> endpoints.json inferred region -> client region
198
- config.signingRegion = config.signingRegion || signingRegion;
199
- // signing name resolving order:
200
- // user supplied signingName -> endpoints.json inferred (credential scope -> model arnNamespace) -> model service id
201
- config.signingName = config.signingName || signingService || config.serviceId;
202
-
203
- const params: SignatureV4Init & SignatureV4CryptoInit = {
204
- ...config,
205
- credentials: normalizedCreds!,
206
- region: config.signingRegion,
207
- service: config.signingName,
208
- sha256,
209
- uriEscapePath: signingEscapePath,
210
- };
211
-
212
- const SignerCtor = config.signerConstructor || SignatureV4;
213
- return new SignerCtor(params);
214
- };
215
- }
216
-
217
- return {
218
- ...config,
219
- systemClockOffset,
220
- signingEscapePath,
221
- credentials: normalizedCreds!,
222
- signer,
223
- };
224
- };
225
-
226
- /**
227
- * @deprecated renamed to {@link AwsSdkSigV4AuthInputConfig}
228
- */
229
- export interface AWSSDKSigV4AuthInputConfig extends AwsSdkSigV4AuthInputConfig {}
230
-
231
- /**
232
- * @deprecated renamed to {@link AwsSdkSigV4PreviouslyResolved}
233
- */
234
- export interface AWSSDKSigV4PreviouslyResolved extends AwsSdkSigV4PreviouslyResolved {}
235
-
236
- /**
237
- * @deprecated renamed to {@link AwsSdkSigV4AuthResolvedConfig}
238
- */
239
- export interface AWSSDKSigV4AuthResolvedConfig extends AwsSdkSigV4AuthResolvedConfig {}
240
-
241
- /**
242
- * @deprecated renamed to {@link resolveAwsSdkSigV4Config}
243
- */
244
- export const resolveAWSSDKSigV4Config = resolveAwsSdkSigV4Config;
@@ -1 +0,0 @@
1
- export * from "./aws_sdk";
@@ -1,7 +0,0 @@
1
- import { HttpResponse } from "@smithy/protocol-http";
2
-
3
- /**
4
- * @internal
5
- */
6
- export const getDateHeader = (response: unknown): string | undefined =>
7
- HttpResponse.isInstance(response) ? response.headers?.date ?? response.headers?.Date : undefined;
@@ -1,17 +0,0 @@
1
- import { getSkewCorrectedDate } from "./getSkewCorrectedDate";
2
-
3
- describe(getSkewCorrectedDate.name, () => {
4
- const mockDateNow = Date.now();
5
-
6
- beforeEach(() => {
7
- jest.spyOn(Date, "now").mockReturnValue(mockDateNow);
8
- });
9
-
10
- afterEach(() => {
11
- jest.clearAllMocks();
12
- });
13
-
14
- it.each([-100000, -100, 0, 100, 100000])("systemClockOffset: %d", (systemClockOffset) => {
15
- expect(getSkewCorrectedDate(systemClockOffset)).toStrictEqual(new Date(mockDateNow + systemClockOffset));
16
- });
17
- });
@@ -1,8 +0,0 @@
1
- /**
2
- * @internal
3
- *
4
- * Returns a date that is corrected for clock skew.
5
- *
6
- * @param systemClockOffset The offset of the system clock in milliseconds.
7
- */
8
- export const getSkewCorrectedDate = (systemClockOffset: number) => new Date(Date.now() + systemClockOffset);
@@ -1,37 +0,0 @@
1
- import { getUpdatedSystemClockOffset } from "./getUpdatedSystemClockOffset";
2
- import { isClockSkewed } from "./isClockSkewed";
3
-
4
- jest.mock("./isClockSkewed");
5
-
6
- describe(getUpdatedSystemClockOffset.name, () => {
7
- // Mock ServerTime is accurate to last second, to remove milliseconds information.
8
- const mockClockTime = new Date(Math.floor(Date.now() / 1000) * 1000);
9
- const mockSystemClockOffset = 100;
10
-
11
- afterEach(() => {
12
- jest.clearAllMocks();
13
- });
14
-
15
- it("returns passed systemClockOffset when clock is not skewed", () => {
16
- (isClockSkewed as jest.Mock).mockReturnValue(false);
17
- expect(getUpdatedSystemClockOffset(mockClockTime.toString(), mockSystemClockOffset)).toEqual(mockSystemClockOffset);
18
- });
19
-
20
- describe("returns difference between serverTime and current time when clock is skewed", () => {
21
- const dateDotNowFn = Date.now;
22
-
23
- beforeEach(() => {
24
- (isClockSkewed as jest.Mock).mockReturnValue(true);
25
- jest.spyOn(Date, "now").mockReturnValueOnce(mockClockTime.getTime());
26
- });
27
-
28
- afterEach(() => {
29
- Date.now = dateDotNowFn;
30
- });
31
-
32
- it.each([1000, 100000])("difference: %d", (difference) => {
33
- const updatedClockTime = new Date(mockClockTime.getTime() + difference);
34
- expect(getUpdatedSystemClockOffset(updatedClockTime.toString(), mockSystemClockOffset)).toEqual(difference);
35
- });
36
- });
37
- });
@@ -1,18 +0,0 @@
1
- import { isClockSkewed } from "./isClockSkewed";
2
-
3
- /**
4
- * @internal
5
- *
6
- * If clock is skewed, it returns the difference between serverTime and current time.
7
- * If clock is not skewed, it returns currentSystemClockOffset.
8
- *
9
- * @param clockTime The string value of the server time.
10
- * @param currentSystemClockOffset The current system clock offset.
11
- */
12
- export const getUpdatedSystemClockOffset = (clockTime: string, currentSystemClockOffset: number): number => {
13
- const clockTimeInMs = Date.parse(clockTime);
14
- if (isClockSkewed(clockTimeInMs, currentSystemClockOffset)) {
15
- return clockTimeInMs - Date.now();
16
- }
17
- return currentSystemClockOffset;
18
- };
@@ -1,3 +0,0 @@
1
- export * from "./getDateHeader";
2
- export * from "./getSkewCorrectedDate";
3
- export * from "./getUpdatedSystemClockOffset";
@@ -1,32 +0,0 @@
1
- import { getSkewCorrectedDate } from "./getSkewCorrectedDate";
2
- import { isClockSkewed } from "./isClockSkewed";
3
-
4
- jest.mock("./getSkewCorrectedDate");
5
-
6
- describe(isClockSkewed.name, () => {
7
- const mockSystemClockOffset = 100;
8
- const mockSkewCorrectedDate = new Date();
9
-
10
- beforeEach(() => {
11
- (getSkewCorrectedDate as jest.Mock).mockReturnValue(mockSkewCorrectedDate);
12
- });
13
-
14
- afterEach(() => {
15
- expect(getSkewCorrectedDate).toHaveBeenCalledWith(mockSystemClockOffset);
16
- jest.clearAllMocks();
17
- });
18
-
19
- describe("returns true for time difference >=300000", () => {
20
- it.each([300000, 500000])("difference: %d", (difference) => {
21
- expect(isClockSkewed(mockSkewCorrectedDate.getTime() + difference, mockSystemClockOffset)).toBe(true);
22
- expect(isClockSkewed(mockSkewCorrectedDate.getTime() - difference, mockSystemClockOffset)).toBe(true);
23
- });
24
- });
25
-
26
- describe("returns false for time difference <300000", () => {
27
- it.each([299999, 100000, 0])("difference: %d", (difference) => {
28
- expect(isClockSkewed(mockSkewCorrectedDate.getTime() + difference, mockSystemClockOffset)).toBe(false);
29
- expect(isClockSkewed(mockSkewCorrectedDate.getTime() - difference, mockSystemClockOffset)).toBe(false);
30
- });
31
- });
32
- });
@@ -1,12 +0,0 @@
1
- import { getSkewCorrectedDate } from "./getSkewCorrectedDate";
2
-
3
- /**
4
- * @internal
5
- *
6
- * Checks if the provided date is within the skew window of 300000ms.
7
- *
8
- * @param clockTime - The time to check for skew in milliseconds.
9
- * @param systemClockOffset - The offset of the system clock in milliseconds.
10
- */
11
- export const isClockSkewed = (clockTime: number, systemClockOffset: number) =>
12
- Math.abs(getSkewCorrectedDate(systemClockOffset).getTime() - clockTime) >= 300000;
@@ -1,3 +0,0 @@
1
- export * from "./client/index";
2
- export * from "./httpAuthSchemes/index";
3
- export * from "./protocols/index";
@@ -1,76 +0,0 @@
1
- import { _toBool, _toNum, _toStr } from "./coercing-serializers";
2
-
3
- const consoleWarn = console.warn;
4
-
5
- beforeAll(() => {
6
- console.warn = () => {};
7
- });
8
-
9
- afterAll(() => {
10
- console.warn = consoleWarn;
11
- });
12
-
13
- describe(_toBool.name, () => {
14
- it("ignores nullish", () => {
15
- expect(_toBool(null)).toBe(null);
16
- expect(_toBool(undefined)).toBe(undefined);
17
- });
18
-
19
- it("converts strings", () => {
20
- expect(_toBool("false")).toEqual(false);
21
- expect(_toBool("true")).toEqual(true);
22
-
23
- expect(_toBool("False")).toEqual(false);
24
- expect(_toBool("True")).toEqual(true);
25
-
26
- expect(_toBool("")).toEqual(false);
27
- expect(_toBool("a")).toEqual(true); // warns
28
- });
29
-
30
- it("does not convert numbers", () => {
31
- expect(_toBool(0)).toEqual(0);
32
- expect(_toBool(1)).toEqual(1);
33
- });
34
- });
35
-
36
- describe(_toStr.name, () => {
37
- it("ignores nullish", () => {
38
- expect(_toStr(null)).toBe(null);
39
- expect(_toStr(undefined)).toBe(undefined);
40
- });
41
-
42
- it("converts numbers", () => {
43
- expect(_toStr(0)).toEqual("0");
44
- expect(_toStr(1)).toEqual("1");
45
- });
46
-
47
- it("converts booleans", () => {
48
- expect(_toStr(false)).toEqual("false");
49
- expect(_toStr(true)).toEqual("true");
50
- });
51
- });
52
-
53
- describe(_toNum.name, () => {
54
- it("ignores nullish", () => {
55
- expect(_toNum(null)).toBe(null);
56
- expect(_toNum(undefined)).toBe(undefined);
57
- });
58
-
59
- it("converts numeric strings", () => {
60
- expect(_toNum("1234")).toEqual(1234);
61
- expect(_toNum("1234.56")).toEqual(1234.56);
62
- });
63
-
64
- it("does not convert prefix-numeric strings", () => {
65
- expect(_toNum("1234abc")).toEqual("1234abc");
66
- expect(_toNum("1234.56abc")).toEqual("1234.56abc");
67
- });
68
-
69
- it("does not convert non-numeric strings", () => {
70
- expect(_toNum("abcdef")).toEqual("abcdef");
71
- });
72
- it("does not convert bools", () => {
73
- expect(_toNum(false)).toEqual(false);
74
- expect(_toNum(true)).toEqual(true);
75
- });
76
- });