@aws-amplify/core 6.5.3 → 6.5.4-storage-browser-integrity.34fba2d.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/cjs/Platform/types.js +2 -0
  2. package/dist/cjs/Platform/types.js.map +1 -1
  3. package/dist/cjs/Platform/version.js +1 -1
  4. package/dist/cjs/Platform/version.js.map +1 -1
  5. package/dist/cjs/clients/internal/composeServiceApi.js +38 -2
  6. package/dist/cjs/clients/internal/composeServiceApi.js.map +1 -1
  7. package/dist/cjs/clients/middleware/retry/defaultRetryDecider.js +5 -2
  8. package/dist/cjs/clients/middleware/retry/defaultRetryDecider.js.map +1 -1
  9. package/dist/cjs/clients/middleware/retry/middleware.js +4 -1
  10. package/dist/cjs/clients/middleware/retry/middleware.js.map +1 -1
  11. package/dist/cjs/clients/middleware/retry/types.js +6 -0
  12. package/dist/cjs/clients/middleware/retry/types.js.map +1 -0
  13. package/dist/cjs/clients/middleware/signing/middleware.js +6 -2
  14. package/dist/cjs/clients/middleware/signing/middleware.js.map +1 -1
  15. package/dist/cjs/parseAmplifyOutputs.js +4 -2
  16. package/dist/cjs/parseAmplifyOutputs.js.map +1 -1
  17. package/dist/esm/Platform/types.d.ts +3 -1
  18. package/dist/esm/Platform/types.mjs +2 -0
  19. package/dist/esm/Platform/types.mjs.map +1 -1
  20. package/dist/esm/Platform/version.d.ts +1 -1
  21. package/dist/esm/Platform/version.mjs +1 -1
  22. package/dist/esm/Platform/version.mjs.map +1 -1
  23. package/dist/esm/awsClients/cognitoIdentity/base.d.ts +1 -1
  24. package/dist/esm/awsClients/cognitoIdentity/getCredentialsForIdentity.d.ts +1 -1
  25. package/dist/esm/awsClients/cognitoIdentity/getId.d.ts +1 -1
  26. package/dist/esm/awsClients/pinpoint/base.d.ts +1 -1
  27. package/dist/esm/awsClients/pinpoint/getInAppMessages.d.ts +2 -2
  28. package/dist/esm/awsClients/pinpoint/putEvents.d.ts +2 -2
  29. package/dist/esm/awsClients/pinpoint/updateEndpoint.d.ts +2 -2
  30. package/dist/esm/clients/index.d.ts +2 -2
  31. package/dist/esm/clients/internal/composeServiceApi.d.ts +62 -2
  32. package/dist/esm/clients/internal/composeServiceApi.mjs +38 -2
  33. package/dist/esm/clients/internal/composeServiceApi.mjs.map +1 -1
  34. package/dist/esm/clients/middleware/retry/defaultRetryDecider.d.ts +2 -1
  35. package/dist/esm/clients/middleware/retry/defaultRetryDecider.mjs +5 -2
  36. package/dist/esm/clients/middleware/retry/defaultRetryDecider.mjs.map +1 -1
  37. package/dist/esm/clients/middleware/retry/index.d.ts +1 -0
  38. package/dist/esm/clients/middleware/retry/middleware.d.ts +3 -1
  39. package/dist/esm/clients/middleware/retry/middleware.mjs +4 -1
  40. package/dist/esm/clients/middleware/retry/middleware.mjs.map +1 -1
  41. package/dist/esm/clients/middleware/retry/types.d.ts +4 -0
  42. package/dist/esm/clients/middleware/retry/types.mjs +2 -0
  43. package/dist/esm/clients/middleware/retry/types.mjs.map +1 -0
  44. package/dist/esm/clients/middleware/signing/index.d.ts +1 -1
  45. package/dist/esm/clients/middleware/signing/middleware.d.ts +10 -2
  46. package/dist/esm/clients/middleware/signing/middleware.mjs +6 -2
  47. package/dist/esm/clients/middleware/signing/middleware.mjs.map +1 -1
  48. package/dist/esm/clients/types/core.d.ts +5 -0
  49. package/dist/esm/clients/types/index.d.ts +1 -1
  50. package/dist/esm/parseAmplifyOutputs.mjs +4 -2
  51. package/dist/esm/parseAmplifyOutputs.mjs.map +1 -1
  52. package/dist/esm/singleton/AmplifyOutputs/types.d.ts +6 -0
  53. package/dist/esm/singleton/Auth/types.d.ts +4 -0
  54. package/dist/esm/singleton/Storage/types.d.ts +2 -0
  55. package/package.json +3 -3
  56. package/src/Platform/types.ts +2 -0
  57. package/src/Platform/version.ts +1 -1
  58. package/src/clients/index.ts +6 -1
  59. package/src/clients/internal/composeServiceApi.ts +66 -6
  60. package/src/clients/middleware/retry/defaultRetryDecider.ts +11 -4
  61. package/src/clients/middleware/retry/index.ts +1 -0
  62. package/src/clients/middleware/retry/middleware.ts +16 -2
  63. package/src/clients/middleware/retry/types.ts +7 -0
  64. package/src/clients/middleware/signing/index.ts +5 -1
  65. package/src/clients/middleware/signing/middleware.ts +21 -3
  66. package/src/clients/types/core.ts +5 -0
  67. package/src/clients/types/index.ts +1 -0
  68. package/src/parseAmplifyOutputs.ts +17 -12
  69. package/src/singleton/AmplifyOutputs/types.ts +5 -1
  70. package/src/singleton/Auth/types.ts +5 -0
  71. package/src/singleton/Storage/types.ts +2 -0
@@ -9,7 +9,7 @@ export declare const getInAppMessages: (config: {
9
9
  endpointResolver?: (((options: import("../../clients/types").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients/types").EndpointResolverOptions) => {
10
10
  url: URL;
11
11
  })) | undefined;
12
- retryDecider?: (((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>)) | undefined;
12
+ retryDecider?: (((response?: HttpResponse | undefined, error?: unknown, middlewareContext?: import("../../clients/types").MiddlewareContext | undefined) => Promise<import("../../clients").RetryDeciderOutput>) & ((response?: HttpResponse | undefined, error?: unknown) => Promise<import("../../clients").RetryDeciderOutput>)) | undefined;
13
13
  computeDelay?: ((attempt: number) => number) | undefined;
14
14
  userAgentValue?: string | undefined;
15
15
  } & {
@@ -19,6 +19,6 @@ export declare const getInAppMessages: (config: {
19
19
  maxAttempts?: number | undefined;
20
20
  userAgentHeader?: string | undefined;
21
21
  uriEscapePath?: boolean | undefined;
22
- credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | (() => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
22
+ credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | ((options?: import("../../clients").CredentialsProviderOptions | undefined) => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
23
23
  region: string;
24
24
  }, input: import("./types").GetInAppMessagesRequest) => Promise<GetInAppMessagesOutput>;
@@ -9,7 +9,7 @@ export declare const putEvents: (config: {
9
9
  endpointResolver?: (((options: import("../../clients/types").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients/types").EndpointResolverOptions) => {
10
10
  url: URL;
11
11
  })) | undefined;
12
- retryDecider?: (((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>)) | undefined;
12
+ retryDecider?: (((response?: HttpResponse | undefined, error?: unknown, middlewareContext?: import("../../clients/types").MiddlewareContext | undefined) => Promise<import("../../clients").RetryDeciderOutput>) & ((response?: HttpResponse | undefined, error?: unknown) => Promise<import("../../clients").RetryDeciderOutput>)) | undefined;
13
13
  computeDelay?: ((attempt: number) => number) | undefined;
14
14
  userAgentValue?: string | undefined;
15
15
  } & {
@@ -19,6 +19,6 @@ export declare const putEvents: (config: {
19
19
  maxAttempts?: number | undefined;
20
20
  userAgentHeader?: string | undefined;
21
21
  uriEscapePath?: boolean | undefined;
22
- credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | (() => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
22
+ credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | ((options?: import("../../clients").CredentialsProviderOptions | undefined) => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
23
23
  region: string;
24
24
  }, input: import("./types").PutEventsRequest) => Promise<PutEventsOutput>;
@@ -9,7 +9,7 @@ export declare const updateEndpoint: (config: {
9
9
  endpointResolver?: (((options: import("../../clients/types").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients/types").EndpointResolverOptions) => {
10
10
  url: URL;
11
11
  })) | undefined;
12
- retryDecider?: (((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>)) | undefined;
12
+ retryDecider?: (((response?: HttpResponse | undefined, error?: unknown, middlewareContext?: import("../../clients/types").MiddlewareContext | undefined) => Promise<import("../../clients").RetryDeciderOutput>) & ((response?: HttpResponse | undefined, error?: unknown) => Promise<import("../../clients").RetryDeciderOutput>)) | undefined;
13
13
  computeDelay?: ((attempt: number) => number) | undefined;
14
14
  userAgentValue?: string | undefined;
15
15
  } & {
@@ -19,6 +19,6 @@ export declare const updateEndpoint: (config: {
19
19
  maxAttempts?: number | undefined;
20
20
  userAgentHeader?: string | undefined;
21
21
  uriEscapePath?: boolean | undefined;
22
- credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | (() => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
22
+ credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | ((options?: import("../../clients").CredentialsProviderOptions | undefined) => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
23
23
  region: string;
24
24
  }, input: import("./types").UpdateEndpointRequest) => Promise<UpdateEndpointOutput>;
@@ -5,8 +5,8 @@ export { authenticatedHandler } from './handlers/authenticated';
5
5
  export { getHashedPayload, presignUrl, PresignUrlOptions, signRequest, SignRequestOptions, } from './middleware/signing/signer/signatureV4';
6
6
  export { EMPTY_HASH as EMPTY_SHA256_HASH } from './middleware/signing/signer/signatureV4/constants';
7
7
  export { extendedEncodeURIComponent } from './middleware/signing/utils/extendedEncodeURIComponent';
8
- export { signingMiddlewareFactory, SigningOptions } from './middleware/signing';
9
- export { getRetryDecider, jitteredBackoff, retryMiddlewareFactory, RetryOptions, } from './middleware/retry';
8
+ export { signingMiddlewareFactory, SigningOptions, CredentialsProviderOptions, } from './middleware/signing';
9
+ export { getRetryDecider, RetryDeciderOutput, jitteredBackoff, retryMiddlewareFactory, RetryOptions, } from './middleware/retry';
10
10
  export { userAgentMiddlewareFactory, UserAgentOptions, } from './middleware/userAgent';
11
11
  export { parseJsonBody, parseJsonError, parseMetadata } from './serde';
12
12
  export { withMemoization } from './utils/memoization';
@@ -1,13 +1,73 @@
1
1
  import { ServiceClientOptions } from '../types/aws';
2
2
  import { Endpoint, TransferHandler } from '../types/core';
3
3
  import { HttpRequest, HttpResponse } from '../types/http';
4
- export declare const composeServiceApi: <TransferHandlerOptions, Input, Output, DefaultConfig>(transferHandler: TransferHandler<HttpRequest, HttpResponse, TransferHandlerOptions>, serializer: (input: Input, endpoint: Endpoint) => Promise<HttpRequest> | HttpRequest, deserializer: (output: HttpResponse) => Promise<Output>, defaultConfig: Partial<DefaultConfig>) => (config: OptionalizeKey<TransferHandlerOptions & ServiceClientOptions & Partial<DefaultConfig> & InferEndpointResolverOptionType<DefaultConfig>, DefaultConfig>, input: Input) => Promise<Output>;
4
+ /**
5
+ * Compose a service API handler that accepts input as defined shape and responds conforming to defined output shape.
6
+ * A service API handler is composed with:
7
+ * * A transfer handler
8
+ * * A serializer function
9
+ * * A deserializer function
10
+ * * A default config object
11
+ *
12
+ * The returned service API handler, when called, will trigger the following workflow:
13
+ * 1. When calling the service API handler function, the default config object is merged into the input config
14
+ * object to assign the default values of some omitted configs, resulting to a resolved config object.
15
+ * 2. The `endpointResolver` function from the default config object will be invoked with the resolved config object and
16
+ * API input object resulting to an endpoint instance.
17
+ * 3. The serializer function is invoked with API input object and the endpoint instance resulting to an HTTP request
18
+ * instance.
19
+ * 4. The HTTP request instance and the resolved config object is passed to the transfer handler function.
20
+ * 5. The transfer handler function resolves to an HTTP response instance(can be either successful or failed status code).
21
+ * 6. The deserializer function is invoked with the HTTP response instance resulting to the API output object, and
22
+ * return to the caller.
23
+ *
24
+ *
25
+ * @param transferHandler Async function for dispatching HTTP requests and returning HTTP response.
26
+ * @param serializer Async function for converting object in defined input shape into HTTP request targeting a given
27
+ * endpoint.
28
+ * @param deserializer Async function for converting HTTP response into output object in defined output shape, or error
29
+ * shape.
30
+ * @param defaultConfig object containing default options to be consumed by transfer handler, serializer and
31
+ * deserializer.
32
+ * @returns a async service API handler function that accepts a config object and input object in defined shape, returns
33
+ * an output object in defined shape. It may also throw error instance in defined shape in deserializer. The config
34
+ * object type is composed with options type of transferHandler, endpointResolver function as well as endpointResolver
35
+ * function's input options type, region string. The config object property will be marked as optional if it's also
36
+ * defined in defaultConfig.
37
+ *
38
+ * @internal
39
+ */
40
+ export declare const composeServiceApi: <TransferHandlerOptions, Input, Output, DefaultConfig>(transferHandler: TransferHandler<HttpRequest, HttpResponse, TransferHandlerOptions>, serializer: (input: Input, endpoint: Endpoint) => Promise<HttpRequest> | HttpRequest, deserializer: (output: HttpResponse) => Promise<Output>, defaultConfig: Partial<DefaultConfig>) => (config: OptionalizeKey<TransferHandlerOptions & ServiceClientOptions & InferEndpointResolverOptionType<DefaultConfig> & Partial<DefaultConfig>, DefaultConfig>, input: Input) => Promise<Output>;
41
+ /**
42
+ * Type helper to make a given key optional in a given type. For all the keys in the `InputDefaultsType`, if its value
43
+ * is assignable to the value of the same key in `InputType`, we will mark the key in `InputType` is optional. If
44
+ * the `InputType` and `InputDefaultsType` has the same key but un-assignable types, the resulting type is `never` to
45
+ * trigger a type error down the line.
46
+ *
47
+ * @example
48
+ * type InputType = {
49
+ * a: string;
50
+ * b: number;
51
+ * c: string;
52
+ * };
53
+ * type InputDefaultsType = {
54
+ * a: string;
55
+ * b: number;
56
+ * };
57
+ * type OutputType = OptionalizeKey<InputType, InputDefaultsType>;
58
+ * OutputType equals to:
59
+ * {
60
+ * a?: string;
61
+ * b?: number;
62
+ * c: string;
63
+ * }
64
+ */
5
65
  type OptionalizeKey<InputType, InputDefaultsType> = {
6
66
  [KeyWithDefaultValue in keyof InputDefaultsType]?: KeyWithDefaultValue extends keyof InputType ? InputType[KeyWithDefaultValue] : never;
7
67
  } & {
8
68
  [KeyWithoutDefaultValue in keyof Omit<InputType, keyof InputDefaultsType>]: InputType[KeyWithoutDefaultValue];
9
69
  };
10
70
  type InferEndpointResolverOptionType<T> = T extends {
11
- endpointResolver(options: infer EndpointOptions): any;
71
+ endpointResolver(options: infer EndpointOptions, input: any): any;
12
72
  } ? EndpointOptions : never;
13
73
  export {};
@@ -1,13 +1,49 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ /**
4
+ * Compose a service API handler that accepts input as defined shape and responds conforming to defined output shape.
5
+ * A service API handler is composed with:
6
+ * * A transfer handler
7
+ * * A serializer function
8
+ * * A deserializer function
9
+ * * A default config object
10
+ *
11
+ * The returned service API handler, when called, will trigger the following workflow:
12
+ * 1. When calling the service API handler function, the default config object is merged into the input config
13
+ * object to assign the default values of some omitted configs, resulting to a resolved config object.
14
+ * 2. The `endpointResolver` function from the default config object will be invoked with the resolved config object and
15
+ * API input object resulting to an endpoint instance.
16
+ * 3. The serializer function is invoked with API input object and the endpoint instance resulting to an HTTP request
17
+ * instance.
18
+ * 4. The HTTP request instance and the resolved config object is passed to the transfer handler function.
19
+ * 5. The transfer handler function resolves to an HTTP response instance(can be either successful or failed status code).
20
+ * 6. The deserializer function is invoked with the HTTP response instance resulting to the API output object, and
21
+ * return to the caller.
22
+ *
23
+ *
24
+ * @param transferHandler Async function for dispatching HTTP requests and returning HTTP response.
25
+ * @param serializer Async function for converting object in defined input shape into HTTP request targeting a given
26
+ * endpoint.
27
+ * @param deserializer Async function for converting HTTP response into output object in defined output shape, or error
28
+ * shape.
29
+ * @param defaultConfig object containing default options to be consumed by transfer handler, serializer and
30
+ * deserializer.
31
+ * @returns a async service API handler function that accepts a config object and input object in defined shape, returns
32
+ * an output object in defined shape. It may also throw error instance in defined shape in deserializer. The config
33
+ * object type is composed with options type of transferHandler, endpointResolver function as well as endpointResolver
34
+ * function's input options type, region string. The config object property will be marked as optional if it's also
35
+ * defined in defaultConfig.
36
+ *
37
+ * @internal
38
+ */
3
39
  const composeServiceApi = (transferHandler, serializer, deserializer, defaultConfig) => {
4
40
  return async (config, input) => {
5
41
  const resolvedConfig = {
6
42
  ...defaultConfig,
7
43
  ...config,
8
44
  };
9
- // We may want to allow different endpoints from given config(other than region) and input.
10
- // Currently S3 supports additional `useAccelerateEndpoint` option to use accelerate endpoint.
45
+ // We need to allow different endpoints based on both given config(other than region) and input.
46
+ // However for most of non-S3 services, region is the only input for endpoint resolver.
11
47
  const endpoint = await resolvedConfig.endpointResolver(resolvedConfig, input);
12
48
  // Unlike AWS SDK clients, a serializer should NOT populate the `host` or `content-length` headers.
13
49
  // Both of these headers are prohibited per Spec(https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name).
@@ -1 +1 @@
1
- {"version":3,"file":"composeServiceApi.mjs","sources":["../../../../src/clients/internal/composeServiceApi.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport const composeServiceApi = (transferHandler, serializer, deserializer, defaultConfig) => {\n return async (config, input) => {\n const resolvedConfig = {\n ...defaultConfig,\n ...config,\n };\n // We may want to allow different endpoints from given config(other than region) and input.\n // Currently S3 supports additional `useAccelerateEndpoint` option to use accelerate endpoint.\n const endpoint = await resolvedConfig.endpointResolver(resolvedConfig, input);\n // Unlike AWS SDK clients, a serializer should NOT populate the `host` or `content-length` headers.\n // Both of these headers are prohibited per Spec(https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name).\n // They will be populated automatically by browser, or node-fetch polyfill.\n const request = await serializer(input, endpoint);\n const response = await transferHandler(request, {\n ...resolvedConfig,\n });\n return deserializer(response);\n };\n};\n"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,iBAAiB,GAAG,CAAC,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,KAAK;AAC/F,IAAI,OAAO,OAAO,MAAM,EAAE,KAAK,KAAK;AACpC,QAAQ,MAAM,cAAc,GAAG;AAC/B,YAAY,GAAG,aAAa;AAC5B,YAAY,GAAG,MAAM;AACrB,SAAS,CAAC;AACV;AACA;AACA,QAAQ,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,gBAAgB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;AACtF;AACA;AACA;AACA,QAAQ,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC1D,QAAQ,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE;AACxD,YAAY,GAAG,cAAc;AAC7B,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;AACtC,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"composeServiceApi.mjs","sources":["../../../../src/clients/internal/composeServiceApi.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Compose a service API handler that accepts input as defined shape and responds conforming to defined output shape.\n * A service API handler is composed with:\n * * A transfer handler\n * * A serializer function\n * * A deserializer function\n * * A default config object\n *\n * The returned service API handler, when called, will trigger the following workflow:\n * 1. When calling the service API handler function, the default config object is merged into the input config\n * object to assign the default values of some omitted configs, resulting to a resolved config object.\n * 2. The `endpointResolver` function from the default config object will be invoked with the resolved config object and\n * API input object resulting to an endpoint instance.\n * 3. The serializer function is invoked with API input object and the endpoint instance resulting to an HTTP request\n * instance.\n * 4. The HTTP request instance and the resolved config object is passed to the transfer handler function.\n * 5. The transfer handler function resolves to an HTTP response instance(can be either successful or failed status code).\n * 6. The deserializer function is invoked with the HTTP response instance resulting to the API output object, and\n * return to the caller.\n *\n *\n * @param transferHandler Async function for dispatching HTTP requests and returning HTTP response.\n * @param serializer Async function for converting object in defined input shape into HTTP request targeting a given\n * \tendpoint.\n * @param deserializer Async function for converting HTTP response into output object in defined output shape, or error\n * \tshape.\n * @param defaultConfig object containing default options to be consumed by transfer handler, serializer and\n * deserializer.\n * @returns a async service API handler function that accepts a config object and input object in defined shape, returns\n * \tan output object in defined shape. It may also throw error instance in defined shape in deserializer. The config\n * object type is composed with options type of transferHandler, endpointResolver function as well as endpointResolver\n * function's input options type, region string. The config object property will be marked as optional if it's also\n * \tdefined in defaultConfig.\n *\n * @internal\n */\nexport const composeServiceApi = (transferHandler, serializer, deserializer, defaultConfig) => {\n return async (config, input) => {\n const resolvedConfig = {\n ...defaultConfig,\n ...config,\n };\n // We need to allow different endpoints based on both given config(other than region) and input.\n // However for most of non-S3 services, region is the only input for endpoint resolver.\n const endpoint = await resolvedConfig.endpointResolver(resolvedConfig, input);\n // Unlike AWS SDK clients, a serializer should NOT populate the `host` or `content-length` headers.\n // Both of these headers are prohibited per Spec(https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name).\n // They will be populated automatically by browser, or node-fetch polyfill.\n const request = await serializer(input, endpoint);\n const response = await transferHandler(request, {\n ...resolvedConfig,\n });\n return deserializer(response);\n };\n};\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,iBAAiB,GAAG,CAAC,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,KAAK;AAC/F,IAAI,OAAO,OAAO,MAAM,EAAE,KAAK,KAAK;AACpC,QAAQ,MAAM,cAAc,GAAG;AAC/B,YAAY,GAAG,aAAa;AAC5B,YAAY,GAAG,MAAM;AACrB,SAAS,CAAC;AACV;AACA;AACA,QAAQ,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,gBAAgB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;AACtF;AACA;AACA;AACA,QAAQ,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC1D,QAAQ,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE;AACxD,YAAY,GAAG,cAAc;AAC7B,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;AACtC,KAAK,CAAC;AACN;;;;"}
@@ -1,6 +1,7 @@
1
1
  import { ErrorParser, HttpResponse } from '../../types';
2
+ import { RetryDeciderOutput } from './types';
2
3
  /**
3
4
  * Get retry decider function
4
5
  * @param errorParser Function to load JavaScript error from HTTP response
5
6
  */
6
- export declare const getRetryDecider: (errorParser: ErrorParser) => (response?: HttpResponse, error?: unknown) => Promise<boolean>;
7
+ export declare const getRetryDecider: (errorParser: ErrorParser) => (response?: HttpResponse, error?: unknown) => Promise<RetryDeciderOutput>;
@@ -13,10 +13,13 @@ const getRetryDecider = (errorParser) => async (response, error) => {
13
13
  undefined;
14
14
  const errorCode = parsedError?.code || parsedError?.name;
15
15
  const statusCode = response?.statusCode;
16
- return (isConnectionError(error) ||
16
+ const isRetryable = isConnectionError(error) ||
17
17
  isThrottlingError(statusCode, errorCode) ||
18
18
  isClockSkewError(errorCode) ||
19
- isServerSideError(statusCode, errorCode));
19
+ isServerSideError(statusCode, errorCode);
20
+ return {
21
+ retryable: isRetryable,
22
+ };
20
23
  };
21
24
  // reference: https://github.com/aws/aws-sdk-js-v3/blob/ab0e7be36e7e7f8a0c04834357aaad643c7912c3/packages/service-error-classification/src/constants.ts#L22-L37
22
25
  const THROTTLING_ERROR_CODES = [
@@ -1 +1 @@
1
- {"version":3,"file":"defaultRetryDecider.mjs","sources":["../../../../../src/clients/middleware/retry/defaultRetryDecider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyErrorCode } from '../../../types';\nimport { isClockSkewError } from './isClockSkewError';\n/**\n * Get retry decider function\n * @param errorParser Function to load JavaScript error from HTTP response\n */\nexport const getRetryDecider = (errorParser) => async (response, error) => {\n const parsedError = error ??\n (await errorParser(response)) ??\n undefined;\n const errorCode = parsedError?.code || parsedError?.name;\n const statusCode = response?.statusCode;\n return (isConnectionError(error) ||\n isThrottlingError(statusCode, errorCode) ||\n isClockSkewError(errorCode) ||\n isServerSideError(statusCode, errorCode));\n};\n// reference: https://github.com/aws/aws-sdk-js-v3/blob/ab0e7be36e7e7f8a0c04834357aaad643c7912c3/packages/service-error-classification/src/constants.ts#L22-L37\nconst THROTTLING_ERROR_CODES = [\n 'BandwidthLimitExceeded',\n 'EC2ThrottledException',\n 'LimitExceededException',\n 'PriorRequestNotComplete',\n 'ProvisionedThroughputExceededException',\n 'RequestLimitExceeded',\n 'RequestThrottled',\n 'RequestThrottledException',\n 'SlowDown',\n 'ThrottledException',\n 'Throttling',\n 'ThrottlingException',\n 'TooManyRequestsException',\n];\nconst TIMEOUT_ERROR_CODES = [\n 'TimeoutError',\n 'RequestTimeout',\n 'RequestTimeoutException',\n];\nconst isThrottlingError = (statusCode, errorCode) => statusCode === 429 ||\n (!!errorCode && THROTTLING_ERROR_CODES.includes(errorCode));\nconst isConnectionError = (error) => [\n AmplifyErrorCode.NetworkError,\n // TODO(vNext): unify the error code `ERR_NETWORK` used by the Storage XHR handler\n 'ERR_NETWORK',\n].includes(error?.name);\nconst isServerSideError = (statusCode, errorCode) => (!!statusCode && [500, 502, 503, 504].includes(statusCode)) ||\n (!!errorCode && TIMEOUT_ERROR_CODES.includes(errorCode));\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACY,MAAC,eAAe,GAAG,CAAC,WAAW,KAAK,OAAO,QAAQ,EAAE,KAAK,KAAK;AAC3E,IAAI,MAAM,WAAW,GAAG,KAAK;AAC7B,SAAS,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAC;AACrC,QAAQ,SAAS,CAAC;AAClB,IAAI,MAAM,SAAS,GAAG,WAAW,EAAE,IAAI,IAAI,WAAW,EAAE,IAAI,CAAC;AAC7D,IAAI,MAAM,UAAU,GA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CAAC;;;;"}
1
+ {"version":3,"file":"defaultRetryDecider.mjs","sources":["../../../../../src/clients/middleware/retry/defaultRetryDecider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyErrorCode } from '../../../types';\nimport { isClockSkewError } from './isClockSkewError';\n/**\n * Get retry decider function\n * @param errorParser Function to load JavaScript error from HTTP response\n */\nexport const getRetryDecider = (errorParser) => async (response, error) => {\n const parsedError = error ??\n (await errorParser(response)) ??\n undefined;\n const errorCode = parsedError?.code || parsedError?.name;\n const statusCode = response?.statusCode;\n const isRetryable = isConnectionError(error) ||\n isThrottlingError(statusCode, errorCode) ||\n isClockSkewError(errorCode) ||\n isServerSideError(statusCode, errorCode);\n return {\n retryable: isRetryable,\n };\n};\n// reference: https://github.com/aws/aws-sdk-js-v3/blob/ab0e7be36e7e7f8a0c04834357aaad643c7912c3/packages/service-error-classification/src/constants.ts#L22-L37\nconst THROTTLING_ERROR_CODES = [\n 'BandwidthLimitExceeded',\n 'EC2ThrottledException',\n 'LimitExceededException',\n 'PriorRequestNotComplete',\n 'ProvisionedThroughputExceededException',\n 'RequestLimitExceeded',\n 'RequestThrottled',\n 'RequestThrottledException',\n 'SlowDown',\n 'ThrottledException',\n 'Throttling',\n 'ThrottlingException',\n 'TooManyRequestsException',\n];\nconst TIMEOUT_ERROR_CODES = [\n 'TimeoutError',\n 'RequestTimeout',\n 'RequestTimeoutException',\n];\nconst isThrottlingError = (statusCode, errorCode) => statusCode === 429 ||\n (!!errorCode && THROTTLING_ERROR_CODES.includes(errorCode));\nconst isConnectionError = (error) => [\n AmplifyErrorCode.NetworkError,\n // TODO(vNext): unify the error code `ERR_NETWORK` used by the Storage XHR handler\n 'ERR_NETWORK',\n].includes(error?.name);\nconst isServerSideError = (statusCode, errorCode) => (!!statusCode && [500, 502, 503, 504].includes(statusCode)) ||\n (!!errorCode && TIMEOUT_ERROR_CODES.includes(errorCode));\n"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CAAC;AAChE,MAAM,iBAAiB,GAAG,CAAC,KAAK,KAAK;AACrC,IAAI,gBAAgB,CAAC,YAAY;AACjC;AACA,IAAI,aAAa;AACjB,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACxB,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,SAAS,KAAK,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC;AAC/G,KAAK,CAAC,CAAC,SAAS,IAAI,mBAAmB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;;;;"}
@@ -1,3 +1,4 @@
1
1
  export { RetryOptions, retryMiddlewareFactory } from './middleware';
2
2
  export { jitteredBackoff } from './jitteredBackoff';
3
3
  export { getRetryDecider } from './defaultRetryDecider';
4
+ export { RetryDeciderOutput } from './types';
@@ -1,4 +1,5 @@
1
1
  import { MiddlewareContext, MiddlewareHandler, Request, Response } from '../../types/core';
2
+ import { RetryDeciderOutput } from './types';
2
3
  /**
3
4
  * Configuration of the retry middleware
4
5
  */
@@ -8,9 +9,10 @@ export interface RetryOptions<TResponse = Response> {
8
9
  *
9
10
  * @param response Optional response of the request.
10
11
  * @param error Optional error thrown from previous attempts.
12
+ * @param middlewareContext Optional context object to store data between retries.
11
13
  * @returns True if the request should be retried.
12
14
  */
13
- retryDecider(response?: TResponse, error?: unknown): Promise<boolean>;
15
+ retryDecider(response?: TResponse, error?: unknown, middlewareContext?: MiddlewareContext): Promise<RetryDeciderOutput>;
14
16
  /**
15
17
  * Function to compute the delay in milliseconds before the next retry based
16
18
  * on the number of attempts.
@@ -38,7 +38,10 @@ const retryMiddlewareFactory = ({ maxAttempts = DEFAULT_RETRY_ATTEMPTS, retryDec
38
38
  ? (context.attemptsCount ?? 0)
39
39
  : attemptsCount + 1;
40
40
  context.attemptsCount = attemptsCount;
41
- if (await retryDecider(response, error)) {
41
+ const { isCredentialsExpiredError, retryable } = await retryDecider(response, error, context);
42
+ if (retryable) {
43
+ // Setting isCredentialsInvalid flag to notify signing middleware to forceRefresh credentials provider.
44
+ context.isCredentialsExpired = !!isCredentialsExpiredError;
42
45
  if (!abortSignal?.aborted && attemptsCount < maxAttempts) {
43
46
  // prevent sleep for last attempt or cancelled request;
44
47
  const delay = computeDelay(attemptsCount);
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.mjs","sources":["../../../../../src/clients/middleware/retry/middleware.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst DEFAULT_RETRY_ATTEMPTS = 3;\n/**\n * Retry middleware\n */\nexport const retryMiddlewareFactory = ({ maxAttempts = DEFAULT_RETRY_ATTEMPTS, retryDecider, computeDelay, abortSignal, }) => {\n if (maxAttempts < 1) {\n throw new Error('maxAttempts must be greater than 0');\n }\n return (next, context) => async function retryMiddleware(request) {\n let error;\n let attemptsCount = context.attemptsCount ?? 0;\n let response;\n // When retry is not needed or max attempts is reached, either error or response will be set. This function handles either cases.\n const handleTerminalErrorOrResponse = () => {\n if (response) {\n addOrIncrementMetadataAttempts(response, attemptsCount);\n return response;\n }\n else {\n addOrIncrementMetadataAttempts(error, attemptsCount);\n throw error;\n }\n };\n while (!abortSignal?.aborted && attemptsCount < maxAttempts) {\n try {\n response = await next(request);\n error = undefined;\n }\n catch (e) {\n error = e;\n response = undefined;\n }\n // context.attemptsCount may be updated after calling next handler which may retry the request by itself.\n attemptsCount =\n (context.attemptsCount ?? 0) > attemptsCount\n ? (context.attemptsCount ?? 0)\n : attemptsCount + 1;\n context.attemptsCount = attemptsCount;\n if (await retryDecider(response, error)) {\n if (!abortSignal?.aborted && attemptsCount < maxAttempts) {\n // prevent sleep for last attempt or cancelled request;\n const delay = computeDelay(attemptsCount);\n await cancellableSleep(delay, abortSignal);\n }\n continue;\n }\n else {\n return handleTerminalErrorOrResponse();\n }\n }\n if (abortSignal?.aborted) {\n throw new Error('Request aborted.');\n }\n else {\n return handleTerminalErrorOrResponse();\n }\n };\n};\nconst cancellableSleep = (timeoutMs, abortSignal) => {\n if (abortSignal?.aborted) {\n return Promise.resolve();\n }\n let timeoutId;\n let sleepPromiseResolveFn;\n const sleepPromise = new Promise(resolve => {\n sleepPromiseResolveFn = resolve;\n timeoutId = setTimeout(resolve, timeoutMs);\n });\n abortSignal?.addEventListener('abort', function cancelSleep(_) {\n clearTimeout(timeoutId);\n abortSignal?.removeEventListener('abort', cancelSleep);\n sleepPromiseResolveFn();\n });\n return sleepPromise;\n};\nconst addOrIncrementMetadataAttempts = (nextHandlerOutput, attempts) => {\n if (Object.prototype.toString.call(nextHandlerOutput) !== '[object Object]') {\n return;\n }\n nextHandlerOutput.$metadata = {\n ...(nextHandlerOutput.$metadata ?? {}),\n attempts,\n };\n};\n"],"names":[],"mappings":"AAAA;AACA;AACA,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC;AACA;AACA;AACY,MAAC,sBAAsB,GAAG,CAAC,EAAE,WAAW,GAAG,sBAAsB,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,GAAG,KAAK;AAC9H,IAAI,IAAI,WAAW,GAAG,CAAC,EAAE;AACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AAC9D,KAAK;AACL,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,KAAK,eAAe,eAAe,CAAC,OAAO,EAAE;AACtE,QAAQ,IAAI,KAAK,CAAC;AAClB,QAAQ,IAAI,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC;AACvD,QAAQ,IAAI,QAAQ,CAAC;AACrB;AACA,QAAQ,MAAM,6BAA6B,GAAG,MAAM;AACpD,YAAY,IAAI,QAAQ,EAAE;AAC1B,gBAAgB,8BAA8B,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AACxE,gBAAgB,OAAO,QAAQ,CAAC;AAChC,aAAa;A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AAC;AACnD,SAAS;AACT,KAAK,CAAC;AACN,EAAE;AACF,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,WAAW,KAAK;AACrD,IAAI,IAAI,WAAW,EAAE,OAAO,EAAE;AAC9B,QAAQ,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AACjC,KAAK;AACL,IAAI,IAAI,SAAS,CAAC;AAClB,IAAI,IAAI,qBAAqB,CAAC;AAC9B,IAAI,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,IAAI;AAChD,QAAQ,qBAAqB,GAAG,OAAO,CAAC;AACxC,QAAQ,SAAS,GAAG,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACnD,KAAK,CAAC,CAAC;AACP,IAAI,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,SAAS,WAAW,CAAC,CAAC,EAAE;AACnE,QAAQ,YAAY,CAAC,SAAS,CAAC,CAAC;AAChC,QAAQ,WAAW,EAAE,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAC/D,QAAQ,qBAAqB,EAAE,CAAC;AAChC,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,YAAY,CAAC;AACxB,CAAC,CAAC;AACF,MAAM,8BAA8B,GAAG,CAAC,iBAAiB,EAAE,QAAQ,KAAK;AACxE,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,iBAAiB,EAAE;AACjF,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,iBAAiB,CAAC,SAAS,GAAG;AAClC,QAAQ,IAAI,iBAAiB,CAAC,SAAS,IAAI,EAAE,CAAC;AAC9C,QAAQ,QAAQ;AAChB,KAAK,CAAC;AACN,CAAC;;;;"}
1
+ {"version":3,"file":"middleware.mjs","sources":["../../../../../src/clients/middleware/retry/middleware.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst DEFAULT_RETRY_ATTEMPTS = 3;\n/**\n * Retry middleware\n */\nexport const retryMiddlewareFactory = ({ maxAttempts = DEFAULT_RETRY_ATTEMPTS, retryDecider, computeDelay, abortSignal, }) => {\n if (maxAttempts < 1) {\n throw new Error('maxAttempts must be greater than 0');\n }\n return (next, context) => async function retryMiddleware(request) {\n let error;\n let attemptsCount = context.attemptsCount ?? 0;\n let response;\n // When retry is not needed or max attempts is reached, either error or response will be set. This function handles either cases.\n const handleTerminalErrorOrResponse = () => {\n if (response) {\n addOrIncrementMetadataAttempts(response, attemptsCount);\n return response;\n }\n else {\n addOrIncrementMetadataAttempts(error, attemptsCount);\n throw error;\n }\n };\n while (!abortSignal?.aborted && attemptsCount < maxAttempts) {\n try {\n response = await next(request);\n error = undefined;\n }\n catch (e) {\n error = e;\n response = undefined;\n }\n // context.attemptsCount may be updated after calling next handler which may retry the request by itself.\n attemptsCount =\n (context.attemptsCount ?? 0) > attemptsCount\n ? (context.attemptsCount ?? 0)\n : attemptsCount + 1;\n context.attemptsCount = attemptsCount;\n const { isCredentialsExpiredError, retryable } = await retryDecider(response, error, context);\n if (retryable) {\n // Setting isCredentialsInvalid flag to notify signing middleware to forceRefresh credentials provider.\n context.isCredentialsExpired = !!isCredentialsExpiredError;\n if (!abortSignal?.aborted && attemptsCount < maxAttempts) {\n // prevent sleep for last attempt or cancelled request;\n const delay = computeDelay(attemptsCount);\n await cancellableSleep(delay, abortSignal);\n }\n continue;\n }\n else {\n return handleTerminalErrorOrResponse();\n }\n }\n if (abortSignal?.aborted) {\n throw new Error('Request aborted.');\n }\n else {\n return handleTerminalErrorOrResponse();\n }\n };\n};\nconst cancellableSleep = (timeoutMs, abortSignal) => {\n if (abortSignal?.aborted) {\n return Promise.resolve();\n }\n let timeoutId;\n let sleepPromiseResolveFn;\n const sleepPromise = new Promise(resolve => {\n sleepPromiseResolveFn = resolve;\n timeoutId = setTimeout(resolve, timeoutMs);\n });\n abortSignal?.addEventListener('abort', function cancelSleep(_) {\n clearTimeout(timeoutId);\n abortSignal?.removeEventListener('abort', cancelSleep);\n sleepPromiseResolveFn();\n });\n return sleepPromise;\n};\nconst addOrIncrementMetadataAttempts = (nextHandlerOutput, attempts) => {\n if (Object.prototype.toString.call(nextHandlerOutput) !== '[object Object]') {\n return;\n }\n nextHandlerOutput.$metadata = {\n ...(nextHandlerOutput.$metadata ?? {}),\n attempts,\n };\n};\n"],"names":[],"mappings":"AAAA;AACA;AACA,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC;AACA;AACA;AACY,MAAC,sBAAsB,GAAG,CAAC,EAAE,WAAW,GAAG,sBAAsB,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,GAAG,KAAK;AAC9H,IAAI,IAAI,WAAW,GAAG,CAAC,EAAE;AACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AAC9D,KAAK;AACL,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,KAAK,eAAe,eAAe,CAAC,OAAO,EAAE;AACtE,QAAQ,IAAI,KAAK,CAAC;AAClB,QAAQ,IAAI,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC;AACvD,QAAQ,IAAI,QAAQ,CAAC;AACrB;AACA,QAAQ,MAAM,6BAA6B,GAAG,MAAM;AACpD,YAAY,IAAI,QAAQ,EAAE;AAC1B,gBAAgB,8BAA8B,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AACxE,gBAAgB,OAAO,QAAQ,CAAC;AAChC,aAAa;AACb,iBAAiB;AACjB,gBAAgB,8BAA8B,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;AACrE,gBAAgB,MAAM,KAAK,CAAC;AAC5B,aAAa;AACb,SAAS,CAAC;AACV,QAAQ,OAAO,CAAC,WAAW,EAAE,OAAO,IAAI,aAAa,GAAG,WAAW,EAAE;AACrE,YAAY,IAAI;AAChB,gBAAgB,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,C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AW,EAAE,OAAO,EAAE;AAC9B,QAAQ,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AACjC,KAAK;AACL,IAAI,IAAI,SAAS,CAAC;AAClB,IAAI,IAAI,qBAAqB,CAAC;AAC9B,IAAI,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,IAAI;AAChD,QAAQ,qBAAqB,GAAG,OAAO,CAAC;AACxC,QAAQ,SAAS,GAAG,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACnD,KAAK,CAAC,CAAC;AACP,IAAI,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,SAAS,WAAW,CAAC,CAAC,EAAE;AACnE,QAAQ,YAAY,CAAC,SAAS,CAAC,CAAC;AAChC,QAAQ,WAAW,EAAE,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAC/D,QAAQ,qBAAqB,EAAE,CAAC;AAChC,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,YAAY,CAAC;AACxB,CAAC,CAAC;AACF,MAAM,8BAA8B,GAAG,CAAC,iBAAiB,EAAE,QAAQ,KAAK;AACxE,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,iBAAiB,EAAE;AACjF,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,iBAAiB,CAAC,SAAS,GAAG;AAClC,QAAQ,IAAI,iBAAiB,CAAC,SAAS,IAAI,EAAE,CAAC;AAC9C,QAAQ,QAAQ;AAChB,KAAK,CAAC;AACN,CAAC;;;;"}
@@ -0,0 +1,4 @@
1
+ export interface RetryDeciderOutput {
2
+ retryable: boolean;
3
+ isCredentialsExpiredError?: boolean;
4
+ }
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +1 @@
1
- export { signingMiddlewareFactory, SigningOptions } from './middleware';
1
+ export { signingMiddlewareFactory, SigningOptions, CredentialsProviderOptions, } from './middleware';
@@ -1,9 +1,17 @@
1
1
  import { Credentials, HttpRequest, HttpResponse, MiddlewareHandler } from '../../types';
2
+ import { MiddlewareContext } from '../../types/core';
3
+ /**
4
+ * Options type for the async callback function returning aws credentials. This
5
+ * function is used by SigV4 signer to resolve the aws credentials
6
+ */
7
+ export interface CredentialsProviderOptions {
8
+ forceRefresh?: boolean;
9
+ }
2
10
  /**
3
11
  * Configuration of the signing middleware
4
12
  */
5
13
  export interface SigningOptions {
6
- credentials: Credentials | (() => Promise<Credentials>);
14
+ credentials: Credentials | ((options?: CredentialsProviderOptions) => Promise<Credentials>);
7
15
  region: string;
8
16
  service: string;
9
17
  /**
@@ -18,4 +26,4 @@ export interface SigningOptions {
18
26
  * Middleware that SigV4 signs request with AWS credentials, and correct system clock offset.
19
27
  * This middleware is expected to be placed after retry middleware.
20
28
  */
21
- export declare const signingMiddlewareFactory: ({ credentials, region, service, uriEscapePath, }: SigningOptions) => (next: MiddlewareHandler<HttpRequest, HttpResponse>) => (request: HttpRequest) => Promise<HttpResponse>;
29
+ export declare const signingMiddlewareFactory: ({ credentials, region, service, uriEscapePath, }: SigningOptions) => (next: MiddlewareHandler<HttpRequest, HttpResponse>, context: MiddlewareContext) => (request: HttpRequest) => Promise<HttpResponse>;
@@ -12,10 +12,14 @@ import { getUpdatedSystemClockOffset } from './utils/getUpdatedSystemClockOffset
12
12
  */
13
13
  const signingMiddlewareFactory = ({ credentials, region, service, uriEscapePath = true, }) => {
14
14
  let currentSystemClockOffset;
15
- return (next) => async function signingMiddleware(request) {
15
+ return (next, context) => async function signingMiddleware(request) {
16
16
  currentSystemClockOffset = currentSystemClockOffset ?? 0;
17
17
  const signRequestOptions = {
18
- credentials: typeof credentials === 'function' ? await credentials() : credentials,
18
+ credentials: typeof credentials === 'function'
19
+ ? await credentials({
20
+ forceRefresh: !!context?.isCredentialsExpired,
21
+ })
22
+ : credentials,
19
23
  signingDate: getSkewCorrectedDate(currentSystemClockOffset),
20
24
  signingRegion: region,
21
25
  signingService: service,
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.mjs","sources":["../../../../../src/clients/middleware/signing/middleware.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { signRequest } from './signer/signatureV4';\nimport { getSkewCorrectedDate } from './utils/getSkewCorrectedDate';\nimport { getUpdatedSystemClockOffset } from './utils/getUpdatedSystemClockOffset';\n/**\n * Middleware that SigV4 signs request with AWS credentials, and correct system clock offset.\n * This middleware is expected to be placed after retry middleware.\n */\nexport const signingMiddlewareFactory = ({ credentials, region, service, uriEscapePath = true, }) => {\n let currentSystemClockOffset;\n return (next) => async function signingMiddleware(request) {\n currentSystemClockOffset = currentSystemClockOffset ?? 0;\n const signRequestOptions = {\n credentials: typeof credentials === 'function' ? await credentials() : credentials,\n signingDate: getSkewCorrectedDate(currentSystemClockOffset),\n signingRegion: region,\n signingService: service,\n uriEscapePath,\n };\n const signedRequest = await signRequest(request, signRequestOptions);\n const response = await next(signedRequest);\n // Update system clock offset if response contains date header, regardless of the status code.\n // non-2xx response will still be returned from next handler instead of thrown, because it's\n // only thrown by the retry middleware.\n const dateString = getDateHeader(response);\n if (dateString) {\n currentSystemClockOffset = getUpdatedSystemClockOffset(Date.parse(dateString), currentSystemClockOffset);\n }\n return response;\n };\n};\nconst getDateHeader = ({ headers } = {}) => headers?.date ?? headers?.Date ?? headers?.['x-amz-date'];\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AACY,MAAC,wBAAwB,GAAG,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,KAAK;AACrG,IAAI,IAAI,wBAAwB,CAAC;AACjC,IAAI,OAAO,CAAC,IAAI,KAAK,eAAe,iBAAiB,CAAC,OAAO,EAAE;AAC/D,QAAQ,wBAAwB,GAAG,wBAAwB,IAAI,CAAC,CAAC;AACjE,QAAQ,MAAM,kBAAkB,GAAG;AACnC,YAAY,WAAW,EAAE,OAAO,WAAW,KAAK,UAAU,GAAG,MAAM,WAAW,EAAE,GAAG,WAAW;AAC9F,YAAY,WAAW,EAAE,oBAAoB,CAAC,wBAAwB,CAAC;AACvE,YAAY,aAAa,EAAE,MAAM;AACjC,YAAY,cAAc,EAAE,OAAO;AACnC,YAAY,aAAa;AACzB,SAAS,CAAC;AACV,QAAQ,MAAM,aAAa,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAC7E,QAAQ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC;AACnD;AACA;AACA;AACA,QAAQ,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;AACnD,QAAQ,IAAI,UAAU,EAAE;AACxB,YAAY,wBAAwB,GAAG,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,wBAAwB,CAAC,CAAC;AACrH,SAAS;AACT,QAAQ,OAAO,QAAQ,CAAC;AACxB,KAAK,CAAC;AACN,EAAE;AACF,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,IAAI,IAAI,OAAO,GAAG,YAAY,CAAC;;;;"}
1
+ {"version":3,"file":"middleware.mjs","sources":["../../../../../src/clients/middleware/signing/middleware.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { signRequest } from './signer/signatureV4';\nimport { getSkewCorrectedDate } from './utils/getSkewCorrectedDate';\nimport { getUpdatedSystemClockOffset } from './utils/getUpdatedSystemClockOffset';\n/**\n * Middleware that SigV4 signs request with AWS credentials, and correct system clock offset.\n * This middleware is expected to be placed after retry middleware.\n */\nexport const signingMiddlewareFactory = ({ credentials, region, service, uriEscapePath = true, }) => {\n let currentSystemClockOffset;\n return (next, context) => async function signingMiddleware(request) {\n currentSystemClockOffset = currentSystemClockOffset ?? 0;\n const signRequestOptions = {\n credentials: typeof credentials === 'function'\n ? await credentials({\n forceRefresh: !!context?.isCredentialsExpired,\n })\n : credentials,\n signingDate: getSkewCorrectedDate(currentSystemClockOffset),\n signingRegion: region,\n signingService: service,\n uriEscapePath,\n };\n const signedRequest = await signRequest(request, signRequestOptions);\n const response = await next(signedRequest);\n // Update system clock offset if response contains date header, regardless of the status code.\n // non-2xx response will still be returned from next handler instead of thrown, because it's\n // only thrown by the retry middleware.\n const dateString = getDateHeader(response);\n if (dateString) {\n currentSystemClockOffset = getUpdatedSystemClockOffset(Date.parse(dateString), currentSystemClockOffset);\n }\n return response;\n };\n};\nconst getDateHeader = ({ headers } = {}) => headers?.date ?? headers?.Date ?? headers?.['x-amz-date'];\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AACY,MAAC,wBAAwB,GAAG,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,KAAK;AACrG,IAAI,IAAI,wBAAwB,CAAC;AACjC,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,KAAK,eAAe,iBAAiB,CAAC,OAAO,EAAE;AACxE,QAAQ,wBAAwB,GAAG,wBAAwB,IAAI,CAAC,CAAC;AACjE,QAAQ,MAAM,kBAAkB,GAAG;AACnC,YAAY,WAAW,EAAE,OAAO,WAAW,KAAK,UAAU;AAC1D,kBAAkB,MAAM,WAAW,CAAC;AACpC,oBAAoB,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,oBAAoB;AACjE,iBAAiB,CAAC;AAClB,kBAAkB,WAAW;AAC7B,YAAY,WAAW,EAAE,oBAAoB,CAAC,wBAAwB,CAAC;AACvE,YAAY,aAAa,EAAE,MAAM;AACjC,YAAY,cAAc,EAAE,OAAO;AACnC,YAAY,aAAa;AACzB,SAAS,CAAC;AACV,QAAQ,MAAM,aAAa,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAC7E,QAAQ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC;AACnD;AACA;AACA;AACA,QAAQ,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;AACnD,QAAQ,IAAI,UAAU,EAAE;AACxB,YAAY,wBAAwB,GAAG,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,wBAAwB,CAAC,CAAC;AACrH,SAAS;AACT,QAAQ,OAAO,QAAQ,CAAC;AACxB,KAAK,CAAC;AACN,EAAE;AACF,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,IAAI,IAAI,OAAO,GAAG,YAAY,CAAC;;;;"}
@@ -17,6 +17,11 @@ export type MiddlewareHandler<Input, Output> = (request: Input) => Promise<Outpu
17
17
  * The context object to store states across the middleware chain.
18
18
  */
19
19
  export interface MiddlewareContext {
20
+ /**
21
+ * Whether an error indicating expired credentials has been returned from server-side.
22
+ * This is set by the retry middleware.
23
+ */
24
+ isCredentialsExpired?: boolean;
20
25
  /**
21
26
  * The number of times the request has been attempted. This is set by retry middleware
22
27
  */
@@ -1,3 +1,3 @@
1
- export { Middleware, MiddlewareHandler, Request, Response, TransferHandler, Endpoint, } from './core';
1
+ export { Middleware, MiddlewareHandler, MiddlewareContext, Request, Response, TransferHandler, Endpoint, } from './core';
2
2
  export { Headers, HttpRequest, HttpResponse, HttpTransferHandler, HttpTransferOptions, ResponseBodyMixin, } from './http';
3
3
  export { Credentials, EndpointResolverOptions, ErrorParser, ServiceClientOptions, } from './aws';
@@ -25,11 +25,12 @@ function parseAuth(amplifyOutputsAuthProperties) {
25
25
  if (!amplifyOutputsAuthProperties) {
26
26
  return undefined;
27
27
  }
28
- const { user_pool_id, user_pool_client_id, identity_pool_id, password_policy, mfa_configuration, mfa_methods, unauthenticated_identities_enabled, oauth, username_attributes, standard_required_attributes, } = amplifyOutputsAuthProperties;
28
+ const { user_pool_id, user_pool_client_id, identity_pool_id, password_policy, mfa_configuration, mfa_methods, unauthenticated_identities_enabled, oauth, username_attributes, standard_required_attributes, groups, } = amplifyOutputsAuthProperties;
29
29
  const authConfig = {
30
30
  Cognito: {
31
31
  userPoolId: user_pool_id,
32
32
  userPoolClientId: user_pool_client_id,
33
+ groups,
33
34
  },
34
35
  };
35
36
  if (identity_pool_id) {
@@ -231,13 +232,14 @@ function getMfaStatus(mfaConfiguration) {
231
232
  }
232
233
  function createBucketInfoMap(buckets) {
233
234
  const mappedBuckets = {};
234
- buckets.forEach(({ name, bucket_name: bucketName, aws_region: region }) => {
235
+ buckets.forEach(({ name, bucket_name: bucketName, aws_region: region, paths }) => {
235
236
  if (name in mappedBuckets) {
236
237
  throw new Error(`Duplicate friendly name found: ${name}. Name must be unique.`);
237
238
  }
238
239
  mappedBuckets[name] = {
239
240
  bucketName,
240
241
  region,
242
+ paths,
241
243
  };
242
244
  });
243
245
  return mappedBuckets;
@@ -1 +1 @@
1
- {"version":3,"file":"parseAmplifyOutputs.mjs","sources":["../../src/parseAmplifyOutputs.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function isAmplifyOutputs(config) {\n // version format initially will be '1' but is expected to be something like x.y where x is major and y minor version\n const { version } = config;\n if (!version) {\n return false;\n }\n return version.startsWith('1');\n}\nfunction parseStorage(amplifyOutputsStorageProperties) {\n if (!amplifyOutputsStorageProperties) {\n return undefined;\n }\n const { bucket_name, aws_region, buckets } = amplifyOutputsStorageProperties;\n return {\n S3: {\n bucket: bucket_name,\n region: aws_region,\n buckets: buckets && createBucketInfoMap(buckets),\n },\n };\n}\nfunction parseAuth(amplifyOutputsAuthProperties) {\n if (!amplifyOutputsAuthProperties) {\n return undefined;\n }\n const { user_pool_id, user_pool_client_id, identity_pool_id, password_policy, mfa_configuration, mfa_methods, unauthenticated_identities_enabled, oauth, username_attributes, standard_required_attributes, } = amplifyOutputsAuthProperties;\n const authConfig = {\n Cognito: {\n userPoolId: user_pool_id,\n userPoolClientId: user_pool_client_id,\n },\n };\n if (identity_pool_id) {\n authConfig.Cognito = {\n ...authConfig.Cognito,\n identityPoolId: identity_pool_id,\n };\n }\n if (password_policy) {\n authConfig.Cognito.passwordFormat = {\n requireLowercase: password_policy.require_lowercase,\n requireNumbers: password_policy.require_numbers,\n requireUppercase: password_policy.require_uppercase,\n requireSpecialCharacters: password_policy.require_symbols,\n minLength: password_policy.min_length ?? 6,\n };\n }\n if (mfa_configuration) {\n authConfig.Cognito.mfa = {\n status: getMfaStatus(mfa_configuration),\n smsEnabled: mfa_methods?.includes('SMS'),\n totpEnabled: mfa_methods?.includes('TOTP'),\n };\n }\n if (unauthenticated_identities_enabled) {\n authConfig.Cognito.allowGuestAccess = unauthenticated_identities_enabled;\n }\n if (oauth) {\n authConfig.Cognito.loginWith = {\n oauth: {\n domain: oauth.domain,\n redirectSignIn: oauth.redirect_sign_in_uri,\n redirectSignOut: oauth.redirect_sign_out_uri,\n responseType: oauth.response_type === 'token' ? 'token' : 'code',\n scopes: oauth.scopes,\n providers: getOAuthProviders(oauth.identity_providers),\n },\n };\n }\n if (username_attributes) {\n authConfig.Cognito.loginWith = {\n ...authConfig.Cognito.loginWith,\n email: username_attributes.includes('email'),\n phone: username_attributes.includes('phone_number'),\n // Signing in with a username is not currently supported in Gen2, this should always evaluate to false\n username: username_attributes.includes('username'),\n };\n }\n if (standard_required_attributes) {\n authConfig.Cognito.userAttributes = standard_required_attributes.reduce((acc, curr) => ({ ...acc, [curr]: { required: true } }), {});\n }\n return authConfig;\n}\nexport function parseAnalytics(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties?.amazon_pinpoint) {\n return undefined;\n }\n const { amazon_pinpoint } = amplifyOutputsAnalyticsProperties;\n return {\n Pinpoint: {\n appId: amazon_pinpoint.app_id,\n region: amazon_pinpoint.aws_region,\n },\n };\n}\nfunction parseGeo(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties) {\n return undefined;\n }\n const { aws_region, geofence_collections, maps, search_indices } = amplifyOutputsAnalyticsProperties;\n return {\n LocationService: {\n region: aws_region,\n searchIndices: search_indices,\n geofenceCollections: geofence_collections,\n maps,\n },\n };\n}\nfunction parseData(amplifyOutputsDataProperties) {\n if (!amplifyOutputsDataProperties) {\n return undefined;\n }\n const { aws_region, default_authorization_type, url, api_key, model_introspection, } = amplifyOutputsDataProperties;\n const GraphQL = {\n endpoint: url,\n defaultAuthMode: getGraphQLAuthMode(default_authorization_type),\n region: aws_region,\n apiKey: api_key,\n modelIntrospection: model_introspection,\n };\n return {\n GraphQL,\n };\n}\nfunction parseCustom(amplifyOutputsCustomProperties) {\n if (!amplifyOutputsCustomProperties?.events) {\n return undefined;\n }\n const { url, aws_region, api_key, default_authorization_type } = amplifyOutputsCustomProperties.events;\n const Events = {\n endpoint: url,\n defaultAuthMode: getGraphQLAuthMode(default_authorization_type),\n region: aws_region,\n apiKey: api_key,\n };\n return {\n Events,\n };\n}\nfunction parseNotifications(amplifyOutputsNotificationsProperties) {\n if (!amplifyOutputsNotificationsProperties) {\n return undefined;\n }\n const { aws_region, channels, amazon_pinpoint_app_id } = amplifyOutputsNotificationsProperties;\n const hasInAppMessaging = channels.includes('IN_APP_MESSAGING');\n const hasPushNotification = channels.includes('APNS') || channels.includes('FCM');\n if (!(hasInAppMessaging || hasPushNotification)) {\n return undefined;\n }\n // At this point, we know the Amplify outputs contains at least one supported channel\n const notificationsConfig = {};\n if (hasInAppMessaging) {\n notificationsConfig.InAppMessaging = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n if (hasPushNotification) {\n notificationsConfig.PushNotification = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n return notificationsConfig;\n}\nexport function parseAmplifyOutputs(amplifyOutputs) {\n const resourcesConfig = {};\n if (amplifyOutputs.storage) {\n resourcesConfig.Storage = parseStorage(amplifyOutputs.storage);\n }\n if (amplifyOutputs.auth) {\n resourcesConfig.Auth = parseAuth(amplifyOutputs.auth);\n }\n if (amplifyOutputs.analytics) {\n resourcesConfig.Analytics = parseAnalytics(amplifyOutputs.analytics);\n }\n if (amplifyOutputs.geo) {\n resourcesConfig.Geo = parseGeo(amplifyOutputs.geo);\n }\n if (amplifyOutputs.data) {\n resourcesConfig.API = parseData(amplifyOutputs.data);\n }\n if (amplifyOutputs.custom) {\n const customConfig = parseCustom(amplifyOutputs.custom);\n if (customConfig && 'Events' in customConfig) {\n resourcesConfig.API = { ...resourcesConfig.API, ...customConfig };\n }\n }\n if (amplifyOutputs.notifications) {\n resourcesConfig.Notifications = parseNotifications(amplifyOutputs.notifications);\n }\n return resourcesConfig;\n}\nconst authModeNames = {\n AMAZON_COGNITO_USER_POOLS: 'userPool',\n API_KEY: 'apiKey',\n AWS_IAM: 'iam',\n AWS_LAMBDA: 'lambda',\n OPENID_CONNECT: 'oidc',\n};\nfunction getGraphQLAuthMode(authType) {\n return authModeNames[authType];\n}\nconst providerNames = {\n GOOGLE: 'Google',\n LOGIN_WITH_AMAZON: 'Amazon',\n FACEBOOK: 'Facebook',\n SIGN_IN_WITH_APPLE: 'Apple',\n};\nfunction getOAuthProviders(providers = []) {\n return providers.reduce((oAuthProviders, provider) => {\n if (providerNames[provider] !== undefined) {\n oAuthProviders.push(providerNames[provider]);\n }\n return oAuthProviders;\n }, []);\n}\nfunction getMfaStatus(mfaConfiguration) {\n if (mfaConfiguration === 'OPTIONAL')\n return 'optional';\n if (mfaConfiguration === 'REQUIRED')\n return 'on';\n return 'off';\n}\nfunction createBucketInfoMap(buckets) {\n const mappedBuckets = {};\n buckets.forEach(({ name, bucket_name: bucketName, aws_region: region }) => {\n if (name in mappedBuckets) {\n throw new Error(`Duplicate friendly name found: ${name}. Name must be unique.`);\n }\n mappedBuckets[name] = {\n bucketName,\n region,\n };\n });\n return mappedBuckets;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,gBAAgB,CAAC,MAAM,EAAE;AACzC;AACA,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;AAC/B,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AACD,SAAS,YAAY,CAAC,+BAA+B,EAAE;AACvD,IAAI,IAAI,CAAC,+BAA+B,EAAE;AAC1C,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,IAAI,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,+BAA+B,CAAC;AACjF,IAAI,OAAO;AACX,QAAQ,EAAE,EAAE;AACZ,YAAY,MAAM,EAAE,WAAW;AAC/B,YAAY,MAAM,EAAE,UAAU;AAC9B,YAAY,OAAO,EAAE,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC;AAC5D,SAAS;AACT,KAAK,CAAC;AACN,CAAC;AACD,SAAS,SAAS,CAAC,4BAA4B,EAAE;AACjD,IAAI,IAAI,CAAC,4BAA4B,EAAE;AACvC,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,IAAI,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,kCAAkC,EAAE,KAAK,EAAE,mBAAmB,EAAE,4BAA4B,GAAG,GAAG,4BAA4B,CAAC;AACjP,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,OAAO,EAAE;AACjB,YAAY,UAAU,EAAE,YAAY;AACpC,YAAY,gBAAgB,EAAE,mBAAmB;A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YAAY,MAAM,IAAI,KAAK,CAAC,CAAC,+BAA+B,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAC5F,SAAS;AACT,QAAQ,aAAa,CAAC,IAAI,CAAC,GAAG;AAC9B,YAAY,UAAU;AACtB,YAAY,MAAM;AAClB,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,aAAa,CAAC;AACzB;;;;"}
1
+ {"version":3,"file":"parseAmplifyOutputs.mjs","sources":["../../src/parseAmplifyOutputs.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function isAmplifyOutputs(config) {\n // version format initially will be '1' but is expected to be something like x.y where x is major and y minor version\n const { version } = config;\n if (!version) {\n return false;\n }\n return version.startsWith('1');\n}\nfunction parseStorage(amplifyOutputsStorageProperties) {\n if (!amplifyOutputsStorageProperties) {\n return undefined;\n }\n const { bucket_name, aws_region, buckets } = amplifyOutputsStorageProperties;\n return {\n S3: {\n bucket: bucket_name,\n region: aws_region,\n buckets: buckets && createBucketInfoMap(buckets),\n },\n };\n}\nfunction parseAuth(amplifyOutputsAuthProperties) {\n if (!amplifyOutputsAuthProperties) {\n return undefined;\n }\n const { user_pool_id, user_pool_client_id, identity_pool_id, password_policy, mfa_configuration, mfa_methods, unauthenticated_identities_enabled, oauth, username_attributes, standard_required_attributes, groups, } = amplifyOutputsAuthProperties;\n const authConfig = {\n Cognito: {\n userPoolId: user_pool_id,\n userPoolClientId: user_pool_client_id,\n groups,\n },\n };\n if (identity_pool_id) {\n authConfig.Cognito = {\n ...authConfig.Cognito,\n identityPoolId: identity_pool_id,\n };\n }\n if (password_policy) {\n authConfig.Cognito.passwordFormat = {\n requireLowercase: password_policy.require_lowercase,\n requireNumbers: password_policy.require_numbers,\n requireUppercase: password_policy.require_uppercase,\n requireSpecialCharacters: password_policy.require_symbols,\n minLength: password_policy.min_length ?? 6,\n };\n }\n if (mfa_configuration) {\n authConfig.Cognito.mfa = {\n status: getMfaStatus(mfa_configuration),\n smsEnabled: mfa_methods?.includes('SMS'),\n totpEnabled: mfa_methods?.includes('TOTP'),\n };\n }\n if (unauthenticated_identities_enabled) {\n authConfig.Cognito.allowGuestAccess = unauthenticated_identities_enabled;\n }\n if (oauth) {\n authConfig.Cognito.loginWith = {\n oauth: {\n domain: oauth.domain,\n redirectSignIn: oauth.redirect_sign_in_uri,\n redirectSignOut: oauth.redirect_sign_out_uri,\n responseType: oauth.response_type === 'token' ? 'token' : 'code',\n scopes: oauth.scopes,\n providers: getOAuthProviders(oauth.identity_providers),\n },\n };\n }\n if (username_attributes) {\n authConfig.Cognito.loginWith = {\n ...authConfig.Cognito.loginWith,\n email: username_attributes.includes('email'),\n phone: username_attributes.includes('phone_number'),\n // Signing in with a username is not currently supported in Gen2, this should always evaluate to false\n username: username_attributes.includes('username'),\n };\n }\n if (standard_required_attributes) {\n authConfig.Cognito.userAttributes = standard_required_attributes.reduce((acc, curr) => ({ ...acc, [curr]: { required: true } }), {});\n }\n return authConfig;\n}\nexport function parseAnalytics(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties?.amazon_pinpoint) {\n return undefined;\n }\n const { amazon_pinpoint } = amplifyOutputsAnalyticsProperties;\n return {\n Pinpoint: {\n appId: amazon_pinpoint.app_id,\n region: amazon_pinpoint.aws_region,\n },\n };\n}\nfunction parseGeo(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties) {\n return undefined;\n }\n const { aws_region, geofence_collections, maps, search_indices } = amplifyOutputsAnalyticsProperties;\n return {\n LocationService: {\n region: aws_region,\n searchIndices: search_indices,\n geofenceCollections: geofence_collections,\n maps,\n },\n };\n}\nfunction parseData(amplifyOutputsDataProperties) {\n if (!amplifyOutputsDataProperties) {\n return undefined;\n }\n const { aws_region, default_authorization_type, url, api_key, model_introspection, } = amplifyOutputsDataProperties;\n const GraphQL = {\n endpoint: url,\n defaultAuthMode: getGraphQLAuthMode(default_authorization_type),\n region: aws_region,\n apiKey: api_key,\n modelIntrospection: model_introspection,\n };\n return {\n GraphQL,\n };\n}\nfunction parseCustom(amplifyOutputsCustomProperties) {\n if (!amplifyOutputsCustomProperties?.events) {\n return undefined;\n }\n const { url, aws_region, api_key, default_authorization_type } = amplifyOutputsCustomProperties.events;\n const Events = {\n endpoint: url,\n defaultAuthMode: getGraphQLAuthMode(default_authorization_type),\n region: aws_region,\n apiKey: api_key,\n };\n return {\n Events,\n };\n}\nfunction parseNotifications(amplifyOutputsNotificationsProperties) {\n if (!amplifyOutputsNotificationsProperties) {\n return undefined;\n }\n const { aws_region, channels, amazon_pinpoint_app_id } = amplifyOutputsNotificationsProperties;\n const hasInAppMessaging = channels.includes('IN_APP_MESSAGING');\n const hasPushNotification = channels.includes('APNS') || channels.includes('FCM');\n if (!(hasInAppMessaging || hasPushNotification)) {\n return undefined;\n }\n // At this point, we know the Amplify outputs contains at least one supported channel\n const notificationsConfig = {};\n if (hasInAppMessaging) {\n notificationsConfig.InAppMessaging = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n if (hasPushNotification) {\n notificationsConfig.PushNotification = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n return notificationsConfig;\n}\nexport function parseAmplifyOutputs(amplifyOutputs) {\n const resourcesConfig = {};\n if (amplifyOutputs.storage) {\n resourcesConfig.Storage = parseStorage(amplifyOutputs.storage);\n }\n if (amplifyOutputs.auth) {\n resourcesConfig.Auth = parseAuth(amplifyOutputs.auth);\n }\n if (amplifyOutputs.analytics) {\n resourcesConfig.Analytics = parseAnalytics(amplifyOutputs.analytics);\n }\n if (amplifyOutputs.geo) {\n resourcesConfig.Geo = parseGeo(amplifyOutputs.geo);\n }\n if (amplifyOutputs.data) {\n resourcesConfig.API = parseData(amplifyOutputs.data);\n }\n if (amplifyOutputs.custom) {\n const customConfig = parseCustom(amplifyOutputs.custom);\n if (customConfig && 'Events' in customConfig) {\n resourcesConfig.API = { ...resourcesConfig.API, ...customConfig };\n }\n }\n if (amplifyOutputs.notifications) {\n resourcesConfig.Notifications = parseNotifications(amplifyOutputs.notifications);\n }\n return resourcesConfig;\n}\nconst authModeNames = {\n AMAZON_COGNITO_USER_POOLS: 'userPool',\n API_KEY: 'apiKey',\n AWS_IAM: 'iam',\n AWS_LAMBDA: 'lambda',\n OPENID_CONNECT: 'oidc',\n};\nfunction getGraphQLAuthMode(authType) {\n return authModeNames[authType];\n}\nconst providerNames = {\n GOOGLE: 'Google',\n LOGIN_WITH_AMAZON: 'Amazon',\n FACEBOOK: 'Facebook',\n SIGN_IN_WITH_APPLE: 'Apple',\n};\nfunction getOAuthProviders(providers = []) {\n return providers.reduce((oAuthProviders, provider) => {\n if (providerNames[provider] !== undefined) {\n oAuthProviders.push(providerNames[provider]);\n }\n return oAuthProviders;\n }, []);\n}\nfunction getMfaStatus(mfaConfiguration) {\n if (mfaConfiguration === 'OPTIONAL')\n return 'optional';\n if (mfaConfiguration === 'REQUIRED')\n return 'on';\n return 'off';\n}\nfunction createBucketInfoMap(buckets) {\n const mappedBuckets = {};\n buckets.forEach(({ name, bucket_name: bucketName, aws_region: region, paths }) => {\n if (name in mappedBuckets) {\n throw new Error(`Duplicate friendly name found: ${name}. Name must be unique.`);\n }\n mappedBuckets[name] = {\n bucketName,\n region,\n paths,\n };\n });\n return mappedBuckets;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,gBAAgB,CAAC,MAAM,EAAE;AACzC;AACA,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;AAC/B,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AACD,SAAS,YAAY,CAAC,+BAA+B,EAAE;AACvD,IAAI,IAAI,CAAC,+BAA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MFAConfiguration = 'OPTIONAL' | 'REQUIRED' | 'NONE';
3
3
  export type AmplifyOutputsAuthMFAMethod = 'SMS' | 'TOTP';
4
+ type UserGroupName = string;
5
+ type UserGroupPrecedence = Record<string, number>;
4
6
  export interface AmplifyOutputsAuthProperties {
5
7
  aws_region: string;
6
8
  authentication_flow_type?: 'USER_SRP_AUTH' | 'CUSTOM_AUTH';
@@ -28,6 +30,7 @@ export interface AmplifyOutputsAuthProperties {
28
30
  unauthenticated_identities_enabled?: boolean;
29
31
  mfa_configuration?: string;
30
32
  mfa_methods?: string[];
33
+ groups?: Record<UserGroupName, UserGroupPrecedence>[];
31
34
  }
32
35
  export interface AmplifyOutputsStorageBucketProperties {
33
36
  /** Friendly bucket name provided in Amplify Outputs */
@@ -36,6 +39,8 @@ export interface AmplifyOutputsStorageBucketProperties {
36
39
  bucket_name: string;
37
40
  /** Region for the bucket */
38
41
  aws_region: string;
42
+ /** Paths to object with access permissions */
43
+ paths?: Record<string, Record<string, string[] | undefined>>;
39
44
  }
40
45
  export interface AmplifyOutputsStorageProperties {
41
46
  /** Default region for Storage */
@@ -100,3 +105,4 @@ export interface AmplifyOutputs {
100
105
  custom?: AmplifyOutputsCustomProperties;
101
106
  notifications?: AmplifyOutputsNotificationsProperties;
102
107
  }
108
+ export {};
@@ -61,6 +61,8 @@ export interface AuthTokens {
61
61
  export type AuthStandardAttributeKey = 'address' | 'birthdate' | 'email_verified' | 'family_name' | 'gender' | 'given_name' | 'locale' | 'middle_name' | 'name' | 'nickname' | 'phone_number_verified' | 'picture' | 'preferred_username' | 'profile' | 'sub' | 'updated_at' | 'website' | 'zoneinfo' | AuthVerifiableAttributeKey;
62
62
  export type LegacyUserAttributeKey = Uppercase<AuthStandardAttributeKey>;
63
63
  export type AuthVerifiableAttributeKey = 'email' | 'phone_number';
64
+ type UserGroupName = string;
65
+ type UserGroupPrecedence = Record<string, number>;
64
66
  export type AuthConfigUserAttributes = Partial<Record<AuthStandardAttributeKey, {
65
67
  required: boolean;
66
68
  }>>;
@@ -76,6 +78,7 @@ export interface AuthIdentityPoolConfig {
76
78
  userAttributes?: never;
77
79
  mfa?: never;
78
80
  passwordFormat?: never;
81
+ groups?: never;
79
82
  };
80
83
  }
81
84
  export interface CognitoIdentityPoolConfig {
@@ -113,6 +116,7 @@ export interface CognitoUserPoolConfig {
113
116
  requireNumbers?: boolean;
114
117
  requireSpecialCharacters?: boolean;
115
118
  };
119
+ groups?: Record<UserGroupName, UserGroupPrecedence>[];
116
120
  }
117
121
  export interface OAuthConfig {
118
122
  domain: string;