@aws-amplify/core 5.5.3-api-v6.2 → 5.5.3-api-v6.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.
Files changed (146) hide show
  1. package/internals/aws-client-utils/composers/package.json +8 -0
  2. package/internals/aws-client-utils/package.json +4 -4
  3. package/lib/Amplify.js +2 -0
  4. package/lib/AwsClients/CognitoIdentity/base.d.ts +1 -1
  5. package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +14 -3
  6. package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +2 -1
  7. package/lib/AwsClients/CognitoIdentity/getId.d.ts +14 -3
  8. package/lib/AwsClients/CognitoIdentity/getId.js +2 -1
  9. package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +13 -3
  10. package/lib/AwsClients/Pinpoint/putEvents.d.ts +13 -3
  11. package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +13 -3
  12. package/lib/Credentials.js +2 -0
  13. package/lib/Platform/version.d.ts +1 -1
  14. package/lib/Platform/version.js +1 -1
  15. package/lib/Providers/index.js +2 -0
  16. package/lib/ServiceWorker/ServiceWorker.js +2 -0
  17. package/lib/ServiceWorker/index.js +2 -0
  18. package/lib/UniversalStorage/index.js +2 -0
  19. package/lib/Util/BackgroundProcessManager.js +2 -0
  20. package/lib/Util/DateUtils.js +2 -0
  21. package/lib/Util/Mutex.js +2 -0
  22. package/lib/Util/Reachability.js +2 -0
  23. package/lib/Util/Reachability.native.js +2 -0
  24. package/lib/Util/StringUtils.js +2 -0
  25. package/lib/Util/index.js +2 -0
  26. package/lib/clients/handlers/fetch.js +4 -21
  27. package/lib/clients/index.d.ts +7 -2
  28. package/lib/clients/index.js +17 -4
  29. package/lib/clients/internal/composeServiceApi.d.ts +1 -1
  30. package/lib/clients/internal/composeServiceApi.js +6 -6
  31. package/lib/clients/internal/index.d.ts +7 -0
  32. package/lib/clients/internal/index.js +14 -0
  33. package/lib/clients/middleware/retry/middleware.d.ts +0 -7
  34. package/lib/clients/middleware/retry/middleware.js +37 -26
  35. package/lib/clients/middleware/signing/middleware.d.ts +9 -2
  36. package/lib/clients/middleware/signing/middleware.js +25 -14
  37. package/lib/clients/middleware/signing/signer/signatureV4/index.d.ts +2 -0
  38. package/lib/clients/middleware/signing/signer/signatureV4/index.js +3 -1
  39. package/lib/clients/middleware/signing/signer/signatureV4/index.native.d.ts +1 -0
  40. package/lib/clients/middleware/signing/signer/signatureV4/index.native.js +3 -1
  41. package/lib/clients/middleware/signing/signer/signatureV4/types/signer.d.ts +10 -1
  42. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.d.ts +3 -1
  43. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +5 -2
  44. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.d.ts +3 -1
  45. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +9 -2
  46. package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignature.d.ts +1 -1
  47. package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +2 -2
  48. package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.d.ts +1 -1
  49. package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +3 -2
  50. package/lib/clients/serde/responseInfo.js +4 -2
  51. package/lib/clients/types/aws.d.ts +4 -3
  52. package/lib/clients/utils/memoization.d.ts +9 -0
  53. package/lib/clients/utils/memoization.js +26 -0
  54. package/lib/tsconfig.tsbuildinfo +1 -1
  55. package/lib/types/index.js +2 -0
  56. package/lib-esm/Amplify.js +2 -0
  57. package/lib-esm/AwsClients/CognitoIdentity/base.d.ts +1 -1
  58. package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +14 -3
  59. package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +2 -1
  60. package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +14 -3
  61. package/lib-esm/AwsClients/CognitoIdentity/getId.js +2 -1
  62. package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +13 -3
  63. package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +13 -3
  64. package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +13 -3
  65. package/lib-esm/Credentials.js +2 -0
  66. package/lib-esm/Platform/version.d.ts +1 -1
  67. package/lib-esm/Platform/version.js +1 -1
  68. package/lib-esm/Providers/index.js +2 -0
  69. package/lib-esm/ServiceWorker/ServiceWorker.js +2 -0
  70. package/lib-esm/ServiceWorker/index.js +2 -0
  71. package/lib-esm/UniversalStorage/index.js +2 -0
  72. package/lib-esm/Util/BackgroundProcessManager.js +2 -0
  73. package/lib-esm/Util/DateUtils.js +2 -0
  74. package/lib-esm/Util/Mutex.js +2 -0
  75. package/lib-esm/Util/Reachability.js +2 -0
  76. package/lib-esm/Util/Reachability.native.js +2 -0
  77. package/lib-esm/Util/StringUtils.js +2 -0
  78. package/lib-esm/Util/index.js +2 -0
  79. package/lib-esm/clients/handlers/fetch.js +1 -18
  80. package/lib-esm/clients/index.d.ts +7 -2
  81. package/lib-esm/clients/index.js +7 -2
  82. package/lib-esm/clients/internal/composeServiceApi.d.ts +1 -1
  83. package/lib-esm/clients/internal/composeServiceApi.js +6 -6
  84. package/lib-esm/clients/internal/index.d.ts +7 -0
  85. package/lib-esm/clients/internal/index.js +9 -0
  86. package/lib-esm/clients/middleware/retry/middleware.d.ts +0 -7
  87. package/lib-esm/clients/middleware/retry/middleware.js +36 -24
  88. package/lib-esm/clients/middleware/signing/middleware.d.ts +9 -2
  89. package/lib-esm/clients/middleware/signing/middleware.js +25 -14
  90. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.d.ts +2 -0
  91. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js +1 -0
  92. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.d.ts +1 -0
  93. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.js +1 -0
  94. package/lib-esm/clients/middleware/signing/signer/signatureV4/types/signer.d.ts +10 -1
  95. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.d.ts +3 -1
  96. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +5 -2
  97. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.d.ts +3 -1
  98. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +9 -2
  99. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignature.d.ts +1 -1
  100. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +2 -2
  101. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.d.ts +1 -1
  102. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +3 -2
  103. package/lib-esm/clients/serde/responseInfo.js +3 -1
  104. package/lib-esm/clients/types/aws.d.ts +4 -3
  105. package/lib-esm/clients/utils/memoization.d.ts +9 -0
  106. package/lib-esm/clients/utils/memoization.js +22 -0
  107. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  108. package/lib-esm/types/index.js +2 -0
  109. package/package.json +8 -8
  110. package/polyfills/URL/index.ts +2 -0
  111. package/src/Amplify.ts +2 -0
  112. package/src/AwsClients/CognitoIdentity/getCredentialsForIdentity.ts +1 -1
  113. package/src/AwsClients/CognitoIdentity/getId.ts +1 -1
  114. package/src/Credentials.ts +2 -0
  115. package/src/Platform/version.ts +1 -1
  116. package/src/Providers/index.ts +2 -0
  117. package/src/ServiceWorker/ServiceWorker.ts +2 -0
  118. package/src/ServiceWorker/index.ts +2 -0
  119. package/src/UniversalStorage/index.ts +2 -0
  120. package/src/Util/BackgroundProcessManager.ts +2 -0
  121. package/src/Util/DateUtils.ts +2 -0
  122. package/src/Util/Mutex.ts +2 -0
  123. package/src/Util/Reachability.native.ts +2 -0
  124. package/src/Util/Reachability.ts +2 -0
  125. package/src/Util/Retry.ts +2 -0
  126. package/src/Util/StringUtils.ts +2 -0
  127. package/src/Util/index.ts +2 -0
  128. package/src/clients/handlers/fetch.ts +1 -19
  129. package/src/clients/index.ts +15 -2
  130. package/src/clients/internal/composeServiceApi.ts +12 -6
  131. package/src/clients/internal/index.ts +10 -0
  132. package/src/clients/middleware/retry/middleware.ts +28 -24
  133. package/src/clients/middleware/signing/middleware.ts +13 -2
  134. package/src/clients/middleware/signing/signer/signatureV4/index.native.ts +1 -0
  135. package/src/clients/middleware/signing/signer/signatureV4/index.ts +2 -0
  136. package/src/clients/middleware/signing/signer/signatureV4/types/signer.ts +14 -1
  137. package/src/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.ts +7 -7
  138. package/src/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.ts +11 -2
  139. package/src/clients/middleware/signing/signer/signatureV4/utils/getSignature.ts +2 -1
  140. package/src/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.ts +2 -0
  141. package/src/clients/serde/responseInfo.ts +4 -2
  142. package/src/clients/types/aws.ts +4 -3
  143. package/src/clients/utils/memoization.ts +23 -0
  144. package/src/parseAWSExports.ts +2 -0
  145. package/src/types/index.ts +2 -0
  146. package/src/types/types.ts +2 -0
@@ -4,10 +4,20 @@ export type { PutEventsInput, PutEventsOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const putEvents: (config: Omit<import("../../clients/middleware/userAgent").UserAgentOptions & import("../../clients/middleware/retry").RetryOptions<HttpResponse> & import("../../clients/middleware/signing").SigningOptions & import("../../clients/types").ServiceClientOptions, "retryDecider" | "computeDelay" | "userAgentValue" | "service" | "endpointResolver"> & {
8
- retryDecider?: (response?: HttpResponse, error?: unknown) => Promise<boolean>;
7
+ export declare const putEvents: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").SigningOptions & import("../../clients/types").ServiceClientOptions & {
8
+ service: string;
9
+ endpointResolver: ({ region }: import("../../clients/types").EndpointResolverOptions) => {
10
+ url: URL;
11
+ };
12
+ retryDecider: (response?: HttpResponse, error?: Error) => Promise<boolean>;
13
+ computeDelay: (attempt: number) => number;
14
+ userAgentValue: string;
15
+ }, "retryDecider" | "computeDelay" | "userAgentValue" | "service" | "endpointResolver"> & {
16
+ retryDecider?: ((response?: HttpResponse, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse, error?: Error) => Promise<boolean>);
9
17
  computeDelay?: (attempt: number) => number;
10
18
  userAgentValue?: string;
11
19
  service?: string;
12
- endpointResolver?: (options: import("../../clients/types").EndpointResolverOptions) => Endpoint;
20
+ endpointResolver?: ((options: import("../../clients/types").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients/types").EndpointResolverOptions) => {
21
+ url: URL;
22
+ });
13
23
  }, input: PutEventsInput) => Promise<PutEventsOutput>;
@@ -4,10 +4,20 @@ export type { UpdateEndpointInput, UpdateEndpointOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const updateEndpoint: (config: Omit<import("../../clients/middleware/userAgent").UserAgentOptions & import("../../clients/middleware/retry").RetryOptions<HttpResponse> & import("../../clients/middleware/signing").SigningOptions & import("../../clients/types").ServiceClientOptions, "retryDecider" | "computeDelay" | "userAgentValue" | "service" | "endpointResolver"> & {
8
- retryDecider?: (response?: HttpResponse, error?: unknown) => Promise<boolean>;
7
+ export declare const updateEndpoint: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").SigningOptions & import("../../clients/types").ServiceClientOptions & {
8
+ service: string;
9
+ endpointResolver: ({ region }: import("../../clients/types").EndpointResolverOptions) => {
10
+ url: URL;
11
+ };
12
+ retryDecider: (response?: HttpResponse, error?: Error) => Promise<boolean>;
13
+ computeDelay: (attempt: number) => number;
14
+ userAgentValue: string;
15
+ }, "retryDecider" | "computeDelay" | "userAgentValue" | "service" | "endpointResolver"> & {
16
+ retryDecider?: ((response?: HttpResponse, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse, error?: Error) => Promise<boolean>);
9
17
  computeDelay?: (attempt: number) => number;
10
18
  userAgentValue?: string;
11
19
  service?: string;
12
- endpointResolver?: (options: import("../../clients/types").EndpointResolverOptions) => Endpoint;
20
+ endpointResolver?: ((options: import("../../clients/types").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients/types").EndpointResolverOptions) => {
21
+ url: URL;
22
+ });
13
23
  }, input: UpdateEndpointInput) => Promise<UpdateEndpointOutput>;
@@ -45,6 +45,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
49
+ // SPDX-License-Identifier: Apache-2.0
48
50
  import { ConsoleLogger as Logger } from './Logger';
49
51
  import { StorageHelper } from './StorageHelper';
50
52
  import { makeQuerablePromise } from './JS';
@@ -1 +1 @@
1
- export declare const version = "5.3.4-api-v6.2+366313460";
1
+ export declare const version = "5.3.4-api-v6.13+5927d05d2";
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export var version = '5.3.4-api-v6.2+366313460';
2
+ export var version = '5.3.4-api-v6.13+5927d05d2';
@@ -1 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  export { AWSCloudWatchProvider } from './AWSCloudWatchProvider';
@@ -1,3 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  /**
2
4
  * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
5
  *
@@ -1,3 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  /**
2
4
  * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
5
  *
@@ -9,6 +9,8 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
13
+ // SPDX-License-Identifier: Apache-2.0
12
14
  import Cookies from 'universal-cookie';
13
15
  import { browserOrNode } from '../JS';
14
16
  var isBrowser = browserOrNode().isBrowser;
@@ -60,6 +60,8 @@ var __values = (this && this.__values) || function(o) {
60
60
  };
61
61
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
62
62
  };
63
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
64
+ // SPDX-License-Identifier: Apache-2.0
63
65
  /**
64
66
  * @private For internal Amplify use.
65
67
  *
@@ -1,3 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  /**
2
4
  * Date & time utility functions to abstract the `aws-sdk` away from users.
3
5
  * (v2 => v3 modularization is a breaking change)
@@ -1,3 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  /*!
2
4
  * The MIT License (MIT)
3
5
  *
@@ -9,6 +9,8 @@ var __values = (this && this.__values) || function(o) {
9
9
  };
10
10
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
11
  };
12
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
13
+ // SPDX-License-Identifier: Apache-2.0
12
14
  import { browserOrNode, isWebWorker } from '@aws-amplify/core';
13
15
  import Observable from 'zen-observable-ts';
14
16
  var ReachabilityNavigator = /** @class */ (function () {
@@ -1,3 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  import Observable from 'zen-observable-ts';
2
4
  import { ConsoleLogger as Logger } from '../Logger';
3
5
  var logger = new Logger('Reachability', 'DEBUG');
@@ -1,3 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  export function urlSafeEncode(str) {
2
4
  return str
3
5
  .split('')
@@ -1,3 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  export { NonRetryableError, isNonRetryableError, jitteredBackoff, jitteredExponentialRetry, retry, } from './Retry';
2
4
  export { default as Mutex } from './Mutex';
3
5
  export { default as Reachability } from './Reachability';
@@ -48,6 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  }
49
49
  };
50
50
  import 'isomorphic-unfetch'; // TODO: remove this dependency in v6
51
+ import { withMemoization } from '../utils/memoization';
51
52
  var shouldSendBody = function (method) {
52
53
  return !['HEAD', 'GET', 'DELETE'].includes(method.toUpperCase());
53
54
  };
@@ -99,21 +100,3 @@ export var fetchTransferHandler = function (_a, _b) {
99
100
  });
100
101
  });
101
102
  };
102
- /**
103
- * Cache the payload of a response body. It allows multiple calls to the body,
104
- * for example, when reading the body in both retry decider and error deserializer.
105
- * Caching body is allowed here because we call the body accessor(blob(), json(),
106
- * etc.) when body is small or streaming implementation is not available(RN).
107
- */
108
- var withMemoization = function (payloadAccessor) {
109
- var cached;
110
- return function () {
111
- if (!cached) {
112
- // Explicitly not awaiting. Intermediate await would add overhead and
113
- // introduce a possible race in the event that this wrapper is called
114
- // again before the first `payloadAccessor` call resolves.
115
- cached = payloadAccessor();
116
- }
117
- return cached;
118
- };
119
- };
@@ -2,7 +2,12 @@ export { getDnsSuffix } from './endpoints';
2
2
  export { fetchTransferHandler } from './handlers/fetch';
3
3
  export { unauthenticatedHandler } from './handlers/unauthenticated';
4
4
  export { authenticatedHandler } from './handlers/authenticated';
5
- export { composeServiceApi } from './internal/composeServiceApi';
6
- export { signRequest, presignUrl, } from './middleware/signing/signer/signatureV4';
5
+ export { getHashedPayload, presignUrl, PresignUrlOptions, signRequest, SignRequestOptions, } from './middleware/signing/signer/signatureV4';
6
+ export { EMPTY_HASH as EMPTY_SHA256_HASH } from './middleware/signing/signer/signatureV4/constants';
7
+ export { extendedEncodeURIComponent } from './middleware/signing/utils/extendedEncodeURIComponent';
8
+ export { signingMiddleware, SigningOptions } from './middleware/signing';
9
+ export { getRetryDecider, jitteredBackoff, retryMiddleware, RetryOptions, } from './middleware/retry';
10
+ export { userAgentMiddleware, UserAgentOptions } from './middleware/userAgent';
7
11
  export { parseJsonBody, parseJsonError, parseMetadata } from './serde';
12
+ export { withMemoization } from './utils/memoization';
8
13
  export * from './types';
@@ -4,7 +4,12 @@ export { getDnsSuffix } from './endpoints';
4
4
  export { fetchTransferHandler } from './handlers/fetch';
5
5
  export { unauthenticatedHandler } from './handlers/unauthenticated';
6
6
  export { authenticatedHandler } from './handlers/authenticated';
7
- export { composeServiceApi } from './internal/composeServiceApi';
8
- export { signRequest, presignUrl, } from './middleware/signing/signer/signatureV4';
7
+ export { getHashedPayload, presignUrl, signRequest, } from './middleware/signing/signer/signatureV4';
8
+ export { EMPTY_HASH as EMPTY_SHA256_HASH } from './middleware/signing/signer/signatureV4/constants';
9
+ export { extendedEncodeURIComponent } from './middleware/signing/utils/extendedEncodeURIComponent';
10
+ export { signingMiddleware } from './middleware/signing';
11
+ export { getRetryDecider, jitteredBackoff, retryMiddleware, } from './middleware/retry';
12
+ export { userAgentMiddleware } from './middleware/userAgent';
9
13
  export { parseJsonBody, parseJsonError, parseMetadata } from './serde';
14
+ export { withMemoization } from './utils/memoization';
10
15
  export * from './types';
@@ -1,7 +1,7 @@
1
1
  import { ServiceClientOptions } from '../types/aws';
2
2
  import { TransferHandler, Endpoint } from '../types/core';
3
3
  import { HttpRequest, HttpResponse } from '../types/http';
4
- export declare const composeServiceApi: <TransferHandlerOptions, Input, Output, DefaultConfig extends Partial<TransferHandlerOptions & ServiceClientOptions>>(transferHandler: TransferHandler<HttpRequest, HttpResponse, TransferHandlerOptions>, serializer: (input: Input, endpoint: Endpoint) => HttpRequest, deserializer: (output: HttpResponse) => Promise<Output>, defaultConfig: DefaultConfig) => (config: OptionalizeKey<TransferHandlerOptions & ServiceClientOptions, keyof DefaultConfig>, input: Input) => Promise<Output>;
4
+ export declare const composeServiceApi: <TransferHandlerOptions, Input, Output, DefaultConfig extends Partial<TransferHandlerOptions & ServiceClientOptions>>(transferHandler: TransferHandler<HttpRequest, HttpResponse, TransferHandlerOptions>, serializer: (input: Input, endpoint: Endpoint) => Promise<HttpRequest> | HttpRequest, deserializer: (output: HttpResponse) => Promise<Output>, defaultConfig: DefaultConfig) => (config: OptionalizeKey<TransferHandlerOptions & ServiceClientOptions & DefaultConfig, keyof DefaultConfig>, input: Input) => Promise<Output>;
5
5
  type OptionalizeKey<T, K> = Omit<T, K & keyof T> & {
6
6
  [P in K & keyof T]?: T[P];
7
7
  };
@@ -54,17 +54,17 @@ export var composeServiceApi = function (transferHandler, serializer, deserializ
54
54
  switch (_a.label) {
55
55
  case 0:
56
56
  resolvedConfig = __assign(__assign({}, defaultConfig), config);
57
- return [4 /*yield*/, resolvedConfig.endpointResolver({
58
- region: resolvedConfig.region,
59
- })];
57
+ return [4 /*yield*/, resolvedConfig.endpointResolver(resolvedConfig, input)];
60
58
  case 1:
61
59
  endpoint = _a.sent();
62
- request = serializer(input, endpoint);
63
- return [4 /*yield*/, transferHandler(request, __assign({}, resolvedConfig))];
60
+ return [4 /*yield*/, serializer(input, endpoint)];
64
61
  case 2:
62
+ request = _a.sent();
63
+ return [4 /*yield*/, transferHandler(request, __assign({}, resolvedConfig))];
64
+ case 3:
65
65
  response = _a.sent();
66
66
  return [4 /*yield*/, deserializer(response)];
67
- case 3: return [2 /*return*/, _a.sent()];
67
+ case 4: return [2 /*return*/, _a.sent()];
68
68
  }
69
69
  });
70
70
  }); };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This index should NOT be included in the ../index.ts because the composer functions
3
+ * here requires TypeScript >= 4. Given other scoped packages may use TypeScript < 4,
4
+ * they should not be exposed to upper level index.
5
+ */
6
+ export { composeServiceApi } from './composeServiceApi';
7
+ export { composeTransferHandler } from './composeTransferHandler';
@@ -0,0 +1,9 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ /**
4
+ * This index should NOT be included in the ../index.ts because the composer functions
5
+ * here requires TypeScript >= 4. Given other scoped packages may use TypeScript < 4,
6
+ * they should not be exposed to upper level index.
7
+ */
8
+ export { composeServiceApi } from './composeServiceApi';
9
+ export { composeTransferHandler } from './composeTransferHandler';
@@ -1,4 +1,3 @@
1
- import { MetadataBearer } from '@aws-sdk/types';
2
1
  import { MiddlewareContext, MiddlewareHandler, Request, Response } from '../../types/core';
3
2
  /**
4
3
  * Configuration of the retry middleware
@@ -32,9 +31,3 @@ export interface RetryOptions<TResponse = Response> {
32
31
  * Retry middleware
33
32
  */
34
33
  export declare const retryMiddleware: <TInput = Request, TOutput = Response>({ maxAttempts, retryDecider, computeDelay, abortSignal, }: RetryOptions<TOutput>) => (next: MiddlewareHandler<TInput, TOutput>, context: MiddlewareContext) => (request: TInput) => Promise<TOutput>;
35
- /**
36
- * Check if the response is a contains `$metadata` property.
37
- *
38
- * @internal Amplify internal use only
39
- */
40
- export declare const isMetadataBearer: (response: unknown) => response is MetadataBearer;
@@ -1,5 +1,16 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ var __assign = (this && this.__assign) || function () {
4
+ __assign = Object.assign || function(t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
+ t[p] = s[p];
9
+ }
10
+ return t;
11
+ };
12
+ return __assign.apply(this, arguments);
13
+ };
3
14
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
15
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
16
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -49,26 +60,36 @@ export var retryMiddleware = function (_a) {
49
60
  return function retryMiddleware(request) {
50
61
  var _a;
51
62
  return __awaiter(this, void 0, void 0, function () {
52
- var error, attemptsCount, response, e_1, delay;
63
+ var error, attemptsCount, response, handleTerminalErrorOrResponse, e_1, delay;
53
64
  return __generator(this, function (_b) {
54
65
  switch (_b.label) {
55
66
  case 0:
56
67
  attemptsCount = (_a = context.attemptsCount) !== null && _a !== void 0 ? _a : 0;
68
+ handleTerminalErrorOrResponse = function () {
69
+ if (response) {
70
+ addOrIncrementMetadataAttempts(response, attemptsCount);
71
+ return response;
72
+ }
73
+ else {
74
+ addOrIncrementMetadataAttempts(error, attemptsCount);
75
+ throw error;
76
+ }
77
+ };
57
78
  _b.label = 1;
58
79
  case 1:
59
80
  if (!(!(abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) && attemptsCount < maxAttempts)) return [3 /*break*/, 11];
60
- error = undefined;
61
- response = undefined;
62
81
  _b.label = 2;
63
82
  case 2:
64
83
  _b.trys.push([2, 4, , 5]);
65
84
  return [4 /*yield*/, next(request)];
66
85
  case 3:
67
86
  response = _b.sent();
87
+ error = undefined;
68
88
  return [3 /*break*/, 5];
69
89
  case 4:
70
90
  e_1 = _b.sent();
71
91
  error = e_1;
92
+ response = undefined;
72
93
  return [3 /*break*/, 5];
73
94
  case 5:
74
95
  // context.attemptsCount may be updated after calling next handler which may retry the request by itself.
@@ -87,20 +108,16 @@ export var retryMiddleware = function (_a) {
87
108
  _b.sent();
88
109
  _b.label = 8;
89
110
  case 8: return [3 /*break*/, 1];
90
- case 9:
91
- if (response) {
92
- updateMetadataAttempts(response, attemptsCount);
93
- return [2 /*return*/, response];
111
+ case 9: return [2 /*return*/, handleTerminalErrorOrResponse()];
112
+ case 10: return [3 /*break*/, 1];
113
+ case 11:
114
+ if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
115
+ throw new Error('Request aborted.');
94
116
  }
95
117
  else {
96
- updateMetadataAttempts(error, attemptsCount);
97
- throw error;
118
+ return [2 /*return*/, handleTerminalErrorOrResponse()];
98
119
  }
99
- _b.label = 10;
100
- case 10: return [3 /*break*/, 1];
101
- case 11: throw (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted)
102
- ? new Error('Request aborted')
103
- : error !== null && error !== void 0 ? error : new Error('Retry attempts exhausted');
120
+ return [2 /*return*/];
104
121
  }
105
122
  });
106
123
  });
@@ -124,15 +141,10 @@ var cancellableSleep = function (timeoutMs, abortSignal) {
124
141
  });
125
142
  return sleepPromise;
126
143
  };
127
- /**
128
- * Check if the response is a contains `$metadata` property.
129
- *
130
- * @internal Amplify internal use only
131
- */
132
- export var isMetadataBearer = function (response) { return typeof (response === null || response === void 0 ? void 0 : response['$metadata']) === 'object'; };
133
- var updateMetadataAttempts = function (nextHandlerOutput, attempts) {
134
- if (isMetadataBearer(nextHandlerOutput)) {
135
- nextHandlerOutput.$metadata.attempts = attempts;
144
+ var addOrIncrementMetadataAttempts = function (nextHandlerOutput, attempts) {
145
+ var _a;
146
+ if (Object.prototype.toString.call(nextHandlerOutput) !== '[object Object]') {
147
+ return;
136
148
  }
137
- nextHandlerOutput['$metadata'] = { attempts: attempts };
149
+ nextHandlerOutput['$metadata'] = __assign(__assign({}, ((_a = nextHandlerOutput['$metadata']) !== null && _a !== void 0 ? _a : {})), { attempts: attempts });
138
150
  };
@@ -3,12 +3,19 @@ import { Credentials, HttpRequest, HttpResponse, MiddlewareHandler } from '../..
3
3
  * Configuration of the signing middleware
4
4
  */
5
5
  export interface SigningOptions {
6
- credentials: Credentials;
6
+ credentials: Credentials | (() => Promise<Credentials>);
7
7
  region: string;
8
8
  service: string;
9
+ /**
10
+ * Whether to uri encode the path as part of canonical uri. It's used for S3 only where the pathname
11
+ * is already uri encoded, and the signing process is not expected to uri encode it again.
12
+ *
13
+ * @default true
14
+ */
15
+ uriEscapePath?: boolean;
9
16
  }
10
17
  /**
11
18
  * Middleware that SigV4 signs request with AWS credentials, and correct system clock offset.
12
19
  * This middleware is expected to be placed after retry middleware.
13
20
  */
14
- export declare const signingMiddleware: ({ credentials, region, service, }: SigningOptions) => (next: MiddlewareHandler<HttpRequest, HttpResponse>) => (request: HttpRequest) => Promise<HttpResponse>;
21
+ export declare const signingMiddleware: ({ credentials, region, service, uriEscapePath, }: SigningOptions) => (next: MiddlewareHandler<HttpRequest, HttpResponse>) => (request: HttpRequest) => Promise<HttpResponse>;
@@ -44,28 +44,39 @@ import { getUpdatedSystemClockOffset } from './utils/getUpdatedSystemClockOffset
44
44
  * This middleware is expected to be placed after retry middleware.
45
45
  */
46
46
  export var signingMiddleware = function (_a) {
47
- var credentials = _a.credentials, region = _a.region, service = _a.service;
47
+ var credentials = _a.credentials, region = _a.region, service = _a.service, _b = _a.uriEscapePath, uriEscapePath = _b === void 0 ? true : _b;
48
48
  var currentSystemClockOffset;
49
49
  return function (next) {
50
50
  return function signingMiddleware(request) {
51
51
  return __awaiter(this, void 0, void 0, function () {
52
- var signRequestOptions, signedRequest, response, dateString;
53
- return __generator(this, function (_a) {
54
- switch (_a.label) {
52
+ var signRequestOptions, _a, signedRequest, response, dateString;
53
+ var _b;
54
+ return __generator(this, function (_c) {
55
+ switch (_c.label) {
55
56
  case 0:
56
57
  currentSystemClockOffset = currentSystemClockOffset !== null && currentSystemClockOffset !== void 0 ? currentSystemClockOffset : 0;
57
- signRequestOptions = {
58
- credentials: credentials,
59
- signingDate: getSkewCorrectedDate(currentSystemClockOffset),
60
- signingRegion: region,
61
- signingService: service,
62
- };
63
- return [4 /*yield*/, signRequest(request, signRequestOptions)];
58
+ _b = {};
59
+ if (!(typeof credentials === 'function')) return [3 /*break*/, 2];
60
+ return [4 /*yield*/, credentials()];
64
61
  case 1:
65
- signedRequest = _a.sent();
66
- return [4 /*yield*/, next(signedRequest)];
62
+ _a = _c.sent();
63
+ return [3 /*break*/, 3];
67
64
  case 2:
68
- response = _a.sent();
65
+ _a = credentials;
66
+ _c.label = 3;
67
+ case 3:
68
+ signRequestOptions = (_b.credentials = _a,
69
+ _b.signingDate = getSkewCorrectedDate(currentSystemClockOffset),
70
+ _b.signingRegion = region,
71
+ _b.signingService = service,
72
+ _b.uriEscapePath = uriEscapePath,
73
+ _b);
74
+ return [4 /*yield*/, signRequest(request, signRequestOptions)];
75
+ case 4:
76
+ signedRequest = _c.sent();
77
+ return [4 /*yield*/, next(signedRequest)];
78
+ case 5:
79
+ response = _c.sent();
69
80
  dateString = getDateHeader(response);
70
81
  if (dateString) {
71
82
  currentSystemClockOffset = getUpdatedSystemClockOffset(Date.parse(dateString), currentSystemClockOffset);
@@ -1,3 +1,5 @@
1
1
  export { signRequest } from './signRequest';
2
2
  export { presignUrl } from './presignUrl';
3
3
  export { TOKEN_QUERY_PARAM } from './constants';
4
+ export { getHashedPayload } from './utils/getHashedPayload';
5
+ export type { SignRequestOptions, PresignUrlOptions } from './types';
@@ -4,3 +4,4 @@
4
4
  export { signRequest } from './signRequest';
5
5
  export { presignUrl } from './presignUrl';
6
6
  export { TOKEN_QUERY_PARAM } from './constants';
7
+ export { getHashedPayload } from './utils/getHashedPayload';
@@ -2,3 +2,4 @@ import '@aws-amplify/core/polyfills/URL';
2
2
  export { signRequest } from './signRequest';
3
3
  export { presignUrl } from './presignUrl';
4
4
  export { TOKEN_QUERY_PARAM } from './constants';
5
+ export { getHashedPayload } from './utils/getHashedPayload';
@@ -5,3 +5,4 @@ import '@aws-amplify/core/polyfills/URL';
5
5
  export { signRequest } from './signRequest';
6
6
  export { presignUrl } from './presignUrl';
7
7
  export { TOKEN_QUERY_PARAM } from './constants';
8
+ export { getHashedPayload } from './utils/getHashedPayload';
@@ -4,6 +4,15 @@ export interface SignRequestOptions {
4
4
  signingDate?: Date;
5
5
  signingRegion: string;
6
6
  signingService: string;
7
+ /**
8
+ * Whether to uri encode the path as part of canonical uri. It's used for S3 only where the pathname
9
+ * is already uri encoded, and the signing process is not expected to uri encode it again.
10
+ *
11
+ * @default true
12
+ *
13
+ * @see https://github.com/aws/aws-sdk-js-v3/blob/9ba012dfa3a3429aa2db0f90b3b0b3a7a31f9bc3/packages/signature-v4/src/SignatureV4.ts#L76-L83
14
+ */
15
+ uriEscapePath?: boolean;
7
16
  }
8
17
  export interface PresignUrlOptions extends SignRequestOptions {
9
18
  expiration?: number;
@@ -15,6 +24,6 @@ export interface FormattedDates {
15
24
  longDate: string;
16
25
  shortDate: string;
17
26
  }
18
- export interface SigningValues extends Credentials, FormattedDates, Pick<SignRequestOptions, 'signingRegion' | 'signingService'> {
27
+ export interface SigningValues extends Credentials, FormattedDates, Pick<SignRequestOptions, 'signingRegion' | 'signingService' | 'uriEscapePath'> {
19
28
  credentialScope: string;
20
29
  }
@@ -3,6 +3,8 @@ import { HttpRequest } from '../../../../../types';
3
3
  * Returns a canonical request.
4
4
  *
5
5
  * @param request `HttpRequest` from which to create the canonical request from.
6
+ * @param uriEscapePath Whether to uri encode the path as part of canonical uri. It's used for S3 only where the
7
+ * pathname is already uri encoded, and the signing process is not expected to uri encode it again. Defaults to true.
6
8
  * @returns String created by by concatenating the following strings, separated by newline characters:
7
9
  * - HTTPMethod
8
10
  * - CanonicalUri
@@ -13,4 +15,4 @@ import { HttpRequest } from '../../../../../types';
13
15
  *
14
16
  * @internal
15
17
  */
16
- export declare const getCanonicalRequest: ({ body, headers, method, url, }: HttpRequest) => string;
18
+ export declare const getCanonicalRequest: ({ body, headers, method, url }: HttpRequest, uriEscapePath?: boolean) => string;
@@ -9,6 +9,8 @@ import { getSignedHeaders } from './getSignedHeaders';
9
9
  * Returns a canonical request.
10
10
  *
11
11
  * @param request `HttpRequest` from which to create the canonical request from.
12
+ * @param uriEscapePath Whether to uri encode the path as part of canonical uri. It's used for S3 only where the
13
+ * pathname is already uri encoded, and the signing process is not expected to uri encode it again. Defaults to true.
12
14
  * @returns String created by by concatenating the following strings, separated by newline characters:
13
15
  * - HTTPMethod
14
16
  * - CanonicalUri
@@ -19,11 +21,12 @@ import { getSignedHeaders } from './getSignedHeaders';
19
21
  *
20
22
  * @internal
21
23
  */
22
- export var getCanonicalRequest = function (_a) {
24
+ export var getCanonicalRequest = function (_a, uriEscapePath) {
23
25
  var body = _a.body, headers = _a.headers, method = _a.method, url = _a.url;
26
+ if (uriEscapePath === void 0) { uriEscapePath = true; }
24
27
  return [
25
28
  method,
26
- getCanonicalUri(url.pathname),
29
+ getCanonicalUri(url.pathname, uriEscapePath),
27
30
  getCanonicalQueryString(url.searchParams),
28
31
  getCanonicalHeaders(headers),
29
32
  getSignedHeaders(headers),
@@ -2,9 +2,11 @@
2
2
  * Returns a canonical uri.
3
3
  *
4
4
  * @param pathname `pathname` from request url.
5
+ * @param uriEscapePath Whether to uri encode the path as part of canonical uri. It's used for S3 only where the
6
+ * pathname is already uri encoded, and the signing process is not expected to uri encode it again. Defaults to true.
5
7
  * @returns URI-encoded version of the absolute path component URL (everything between the host and the question mark
6
8
  * character (?) that starts the query string parameters). If the absolute path is empty, a forward slash character (/).
7
9
  *
8
10
  * @internal
9
11
  */
10
- export declare const getCanonicalUri: (pathname: string) => string;
12
+ export declare const getCanonicalUri: (pathname: string, uriEscapePath?: boolean) => string;
@@ -4,11 +4,18 @@
4
4
  * Returns a canonical uri.
5
5
  *
6
6
  * @param pathname `pathname` from request url.
7
+ * @param uriEscapePath Whether to uri encode the path as part of canonical uri. It's used for S3 only where the
8
+ * pathname is already uri encoded, and the signing process is not expected to uri encode it again. Defaults to true.
7
9
  * @returns URI-encoded version of the absolute path component URL (everything between the host and the question mark
8
10
  * character (?) that starts the query string parameters). If the absolute path is empty, a forward slash character (/).
9
11
  *
10
12
  * @internal
11
13
  */
12
- export var getCanonicalUri = function (pathname) {
13
- return pathname ? encodeURIComponent(pathname).replace(/%2F/g, '/') : '/';
14
+ export var getCanonicalUri = function (pathname, uriEscapePath) {
15
+ if (uriEscapePath === void 0) { uriEscapePath = true; }
16
+ return pathname
17
+ ? uriEscapePath
18
+ ? encodeURIComponent(pathname).replace(/%2F/g, '/')
19
+ : pathname
20
+ : '/';
14
21
  };
@@ -10,4 +10,4 @@ import { SigningValues } from '../types/signer';
10
10
  *
11
11
  * @internal
12
12
  */
13
- export declare const getSignature: (request: HttpRequest, { credentialScope, longDate, secretAccessKey, shortDate, signingRegion, signingService, }: SigningValues) => string;
13
+ export declare const getSignature: (request: HttpRequest, { credentialScope, longDate, secretAccessKey, shortDate, signingRegion, signingService, uriEscapePath, }: SigningValues) => string;