@aws-amplify/core 6.3.11 → 6.3.12

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 (45) hide show
  1. package/dist/cjs/Platform/version.js +1 -1
  2. package/dist/cjs/Platform/version.js.map +1 -1
  3. package/dist/cjs/clients/handlers/fetch.js +7 -4
  4. package/dist/cjs/clients/handlers/fetch.js.map +1 -1
  5. package/dist/cjs/errors/errorHelpers.js +3 -0
  6. package/dist/cjs/errors/errorHelpers.js.map +1 -1
  7. package/dist/cjs/singleton/Auth/utils/index.js +6 -0
  8. package/dist/cjs/singleton/Auth/utils/index.js.map +1 -1
  9. package/dist/cjs/singleton/apis/fetchAuthSession.js +9 -0
  10. package/dist/cjs/singleton/apis/fetchAuthSession.js.map +1 -1
  11. package/dist/cjs/types/errors.js +1 -0
  12. package/dist/cjs/types/errors.js.map +1 -1
  13. package/dist/esm/Platform/version.d.ts +1 -1
  14. package/dist/esm/Platform/version.mjs +1 -1
  15. package/dist/esm/Platform/version.mjs.map +1 -1
  16. package/dist/esm/awsClients/cognitoIdentity/base.mjs +2 -0
  17. package/dist/esm/awsClients/cognitoIdentity/base.mjs.map +1 -1
  18. package/dist/esm/awsClients/cognitoIdentity/getCredentialsForIdentity.mjs +2 -0
  19. package/dist/esm/awsClients/cognitoIdentity/getCredentialsForIdentity.mjs.map +1 -1
  20. package/dist/esm/awsClients/cognitoIdentity/getId.mjs +2 -0
  21. package/dist/esm/awsClients/cognitoIdentity/getId.mjs.map +1 -1
  22. package/dist/esm/clients/handlers/fetch.mjs +8 -4
  23. package/dist/esm/clients/handlers/fetch.mjs.map +1 -1
  24. package/dist/esm/errors/errorHelpers.mjs +3 -0
  25. package/dist/esm/errors/errorHelpers.mjs.map +1 -1
  26. package/dist/esm/providers/pinpoint/apis/updateEndpoint.mjs +2 -0
  27. package/dist/esm/providers/pinpoint/apis/updateEndpoint.mjs.map +1 -1
  28. package/dist/esm/providers/pinpoint/utils/PinpointEventBuffer.mjs +2 -0
  29. package/dist/esm/providers/pinpoint/utils/PinpointEventBuffer.mjs.map +1 -1
  30. package/dist/esm/singleton/Auth/utils/index.d.ts +6 -0
  31. package/dist/esm/singleton/Auth/utils/index.mjs +6 -0
  32. package/dist/esm/singleton/Auth/utils/index.mjs.map +1 -1
  33. package/dist/esm/singleton/apis/fetchAuthSession.d.ts +9 -0
  34. package/dist/esm/singleton/apis/fetchAuthSession.mjs +9 -0
  35. package/dist/esm/singleton/apis/fetchAuthSession.mjs.map +1 -1
  36. package/dist/esm/types/errors.d.ts +2 -1
  37. package/dist/esm/types/errors.mjs +1 -0
  38. package/dist/esm/types/errors.mjs.map +1 -1
  39. package/package.json +4 -4
  40. package/src/Platform/version.ts +1 -1
  41. package/src/clients/handlers/fetch.ts +7 -4
  42. package/src/errors/errorHelpers.ts +3 -0
  43. package/src/singleton/Auth/utils/index.ts +6 -0
  44. package/src/singleton/apis/fetchAuthSession.ts +9 -0
  45. package/src/types/errors.ts +1 -0
@@ -3,5 +3,5 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.version = void 0;
5
5
  // generated by genversion
6
- exports.version = '6.5.2';
6
+ exports.version = '6.5.3';
7
7
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.5.2';\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AACzB;AACA,OAAO,CAAC,OAAO,GAAG,OAAO;;"}
1
+ {"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.5.3';\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AACzB;AACA,OAAO,CAAC,OAAO,GAAG,OAAO;;"}
@@ -4,7 +4,9 @@
4
4
  // SPDX-License-Identifier: Apache-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchTransferHandler = void 0;
7
+ const errors_1 = require("../../errors");
7
8
  const memoization_1 = require("../utils/memoization");
9
+ const types_1 = require("../../types");
8
10
  const shouldSendBody = (method) => !['HEAD', 'GET', 'DELETE'].includes(method.toUpperCase());
9
11
  // TODO[AllanZhengYP]: we need to provide isCanceledError utility
10
12
  const fetchTransferHandler = async ({ url, method, headers, body }, { abortSignal, cache, withCrossDomainCredentials }) => {
@@ -20,11 +22,12 @@ const fetchTransferHandler = async ({ url, method, headers, body }, { abortSigna
20
22
  });
21
23
  }
22
24
  catch (e) {
23
- // TODO: needs to revise error handling in v6
24
- // For now this is a thin wrapper over original fetch error similar to cognito-identity-js package.
25
- // Ref: https://github.com/aws-amplify/amplify-js/blob/4fbc8c0a2be7526aab723579b4c95b552195a80b/packages/amazon-cognito-identity-js/src/Client.js#L103-L108
26
25
  if (e instanceof TypeError) {
27
- throw new Error('Network error');
26
+ throw new errors_1.AmplifyError({
27
+ name: types_1.AmplifyErrorCode.NetworkError,
28
+ message: 'A network error has occurred.',
29
+ underlyingError: e,
30
+ });
28
31
  }
29
32
  throw e;
30
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sources":["../../../../src/clients/handlers/fetch.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.fetchTransferHandler = void 0;\nconst memoization_1 = require(\"../utils/memoization\");\nconst shouldSendBody = (method) => !['HEAD', 'GET', 'DELETE'].includes(method.toUpperCase());\n// TODO[AllanZhengYP]: we need to provide isCanceledError utility\nconst fetchTransferHandler = async ({ url, method, headers, body }, { abortSignal, cache, withCrossDomainCredentials }) => {\n let resp;\n try {\n resp = await fetch(url, {\n method,\n headers,\n body: shouldSendBody(method) ? body : undefined,\n signal: abortSignal,\n cache,\n credentials: withCrossDomainCredentials ? 'include' : 'same-origin',\n });\n }\n catch (e) {\n // TODO: needs to revise error handling in v6\n // For now this is a thin wrapper over original fetch error similar to cognito-identity-js package.\n // Ref: https://github.com/aws-amplify/amplify-js/blob/4fbc8c0a2be7526aab723579b4c95b552195a80b/packages/amazon-cognito-identity-js/src/Client.js#L103-L108\n if (e instanceof TypeError) {\n throw new Error('Network error');\n }\n throw e;\n }\n const responseHeaders = {};\n resp.headers?.forEach((value, key) => {\n responseHeaders[key.toLowerCase()] = value;\n });\n const httpResponse = {\n statusCode: resp.status,\n headers: responseHeaders,\n body: null,\n };\n // resp.body is a ReadableStream according to Fetch API spec, but React Native\n // does not implement it.\n const bodyWithMixin = Object.assign(resp.body ?? {}, {\n text: (0, memoization_1.withMemoization)(() => resp.text()),\n blob: (0, memoization_1.withMemoization)(() => resp.blob()),\n json: (0, memoization_1.withMemoization)(() => resp.json()),\n });\n return {\n ...httpResponse,\n body: bodyWithMixin,\n };\n};\nexports.fetchTransferHandler = fetchTransferHandler;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC,CAAC;AACtC,MAAM,aAAa,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACtD,MAAM,cAAc,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,EA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AE,EAAE;AACzD,QAAQ,IAAI,EAAE,IAAI,aAAa,CAAC,eAAe,EAAE,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;AACnE,QAAQ,IAAI,EAAE,IAAI,aAAa,CAAC,eAAe,EAAE,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;AACnE,QAAQ,IAAI,EAAE,IAAI,aAAa,CAAC,eAAe,EAAE,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;AACnE,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,GAAG,YAAY;AACvB,QAAQ,IAAI,EAAE,aAAa;AAC3B,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,oBAAoB,GAAG,oBAAoB;;"}
1
+ {"version":3,"file":"fetch.js","sources":["../../../../src/clients/handlers/fetch.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.fetchTransferHandler = void 0;\nconst errors_1 = require(\"../../errors\");\nconst memoization_1 = require(\"../utils/memoization\");\nconst types_1 = require(\"../../types\");\nconst shouldSendBody = (method) => !['HEAD', 'GET', 'DELETE'].includes(method.toUpperCase());\n// TODO[AllanZhengYP]: we need to provide isCanceledError utility\nconst fetchTransferHandler = async ({ url, method, headers, body }, { abortSignal, cache, withCrossDomainCredentials }) => {\n let resp;\n try {\n resp = await fetch(url, {\n method,\n headers,\n body: shouldSendBody(method) ? body : undefined,\n signal: abortSignal,\n cache,\n credentials: withCrossDomainCredentials ? 'include' : 'same-origin',\n });\n }\n catch (e) {\n if (e instanceof TypeError) {\n throw new errors_1.AmplifyError({\n name: types_1.AmplifyErrorCode.NetworkError,\n message: 'A network error has occurred.',\n underlyingError: e,\n });\n }\n throw e;\n }\n const responseHeaders = {};\n resp.headers?.forEach((value, key) => {\n responseHeaders[key.toLowerCase()] = value;\n });\n const httpResponse = {\n statusCode: resp.status,\n headers: responseHeaders,\n body: null,\n };\n // resp.body is a ReadableStream according to Fetch API spec, but React Native\n // does not implement it.\n const bodyWithMixin = Object.assign(resp.body ?? {}, {\n text: (0, memoization_1.withMemoization)(() => resp.text()),\n blob: (0, memoization_1.withMemoization)(() => resp.blob()),\n json: (0, memoization_1.withMemoization)(() => resp.json()),\n });\n return {\n ...httpResponse,\n body: bodyWithMixin,\n };\n};\nexports.fetchTransferHandler = fetchTransferHandler;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC,CAAC;AACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AACzC,MAAM,aAAa,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACtD,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,cAAc,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AAC7F;AACA,MAAM,oBAAoB,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,0BAA0B,EAAE,KAAK;AAC3H,IAAI,IAAI,IAAI,CAAC;AACb,IAAI,IAAI;AACR,QAAQ,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;AAChC,YAAY,MAAM;AAClB,YAAY,OAAO;AACnB,YAAY,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS;AAC3D,YAAY,MAAM,EAAE,WAAW;AAC/B,YAAY,KAAK;AACjB,YAAY,WAAW,EAAE,0BAA0B,GAAG,SAAS,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AC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,oBAAoB,GAAG,oBAAoB;;"}
@@ -16,6 +16,9 @@ const amplifyErrorMap = {
16
16
  [types_1.AmplifyErrorCode.Unknown]: {
17
17
  message: 'An unknown error occurred.',
18
18
  },
19
+ [types_1.AmplifyErrorCode.NetworkError]: {
20
+ message: 'A network error has occurred.',
21
+ },
19
22
  };
20
23
  exports.assert = (0, createAssertionFunction_1.createAssertionFunction)(amplifyErrorMap);
21
24
  //# sourceMappingURL=errorHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorHelpers.js","sources":["../../../src/errors/errorHelpers.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.assert = void 0;\nconst types_1 = require(\"../types\");\nconst createAssertionFunction_1 = require(\"./createAssertionFunction\");\nconst amplifyErrorMap = {\n [types_1.AmplifyErrorCode.NoEndpointId]: {\n message: 'Endpoint ID was not found and was unable to be created.',\n },\n [types_1.AmplifyErrorCode.PlatformNotSupported]: {\n message: 'Function not supported on current platform.',\n },\n [types_1.AmplifyErrorCode.Unknown]: {\n message: 'An unknown error occurred.',\n },\n};\nexports.assert = (0, createAssertionFunction_1.createAssertionFunction)(amplifyErrorMap);\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;AACxB,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,yBAAyB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AACvE,MAAM,eAAe,GAAG;AACxB,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,GAAG;AAC7C,QAAQ,OAAO,EAAE,yDAAyD;AAC1E,KAAK;AACL,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,oBAAoB,GAAG;AACrD,QAAQ,OAAO,EAAE,6CAA6C;AAC9D,KAAK;AACL,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,GAAG;AACxC,QAAQ,OAAO,EAAE,4BAA4B;AAC7C,KAAK;AACL,CAAC,CAAC;AACF,OAAO,CAAC,MAAM,GAAG,IAAI,yBAAyB,CAAC,uBAAuB,EAAE,eAAe,CAAC;;"}
1
+ {"version":3,"file":"errorHelpers.js","sources":["../../../src/errors/errorHelpers.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.assert = void 0;\nconst types_1 = require(\"../types\");\nconst createAssertionFunction_1 = require(\"./createAssertionFunction\");\nconst amplifyErrorMap = {\n [types_1.AmplifyErrorCode.NoEndpointId]: {\n message: 'Endpoint ID was not found and was unable to be created.',\n },\n [types_1.AmplifyErrorCode.PlatformNotSupported]: {\n message: 'Function not supported on current platform.',\n },\n [types_1.AmplifyErrorCode.Unknown]: {\n message: 'An unknown error occurred.',\n },\n [types_1.AmplifyErrorCode.NetworkError]: {\n message: 'A network error has occurred.',\n },\n};\nexports.assert = (0, createAssertionFunction_1.createAssertionFunction)(amplifyErrorMap);\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;AACxB,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,yBAAyB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AACvE,MAAM,eAAe,GAAG;AACxB,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,GAAG;AAC7C,QAAQ,OAAO,EAAE,yDAAyD;AAC1E,KAAK;AACL,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,oBAAoB,GAAG;AACrD,QAAQ,OAAO,EAAE,6CAA6C;AAC9D,KAAK;AACL,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,GAAG;AACxC,QAAQ,OAAO,EAAE,4BAA4B;AAC7C,KAAK;AACL,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,GAAG;AAC7C,QAAQ,OAAO,EAAE,+BAA+B;AAChD,KAAK;AACL,CAAC,CAAC;AACF,OAAO,CAAC,MAAM,GAAG,IAAI,yBAAyB,CAAC,uBAAuB,EAAE,eAAe,CAAC;;"}
@@ -31,6 +31,12 @@ function assertIdentityPoolIdConfig(cognitoConfig) {
31
31
  (0, errorHelpers_1.assert)(validConfig, errorHelpers_1.AuthConfigurationErrorCode.InvalidIdentityPoolIdException);
32
32
  }
33
33
  exports.assertIdentityPoolIdConfig = assertIdentityPoolIdConfig;
34
+ /**
35
+ * Decodes payload of JWT token
36
+ *
37
+ * @param {String} token A string representing a token to be decoded
38
+ * @throws {@link Error} - Throws error when token is invalid or payload malformed.
39
+ */
34
40
  function decodeJWT(token) {
35
41
  const tokenParts = token.split('.');
36
42
  if (tokenParts.length !== 3) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/singleton/Auth/utils/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.decodeJWT = exports.assertIdentityPoolIdConfig = exports.assertOAuthConfig = exports.assertTokenProviderConfig = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst convert_1 = require(\"../../../utils/convert\");\nconst errorHelpers_1 = require(\"./errorHelpers\");\nfunction assertTokenProviderConfig(cognitoConfig) {\n let assertionValid = true; // assume valid until otherwise proveed\n if (!cognitoConfig) {\n assertionValid = false;\n }\n else {\n assertionValid =\n !!cognitoConfig.userPoolId && !!cognitoConfig.userPoolClientId;\n }\n (0, errorHelpers_1.assert)(assertionValid, errorHelpers_1.AuthConfigurationErrorCode.AuthUserPoolException);\n}\nexports.assertTokenProviderConfig = assertTokenProviderConfig;\nfunction assertOAuthConfig(cognitoConfig) {\n const validOAuthConfig = !!cognitoConfig?.loginWith?.oauth?.domain &&\n !!cognitoConfig?.loginWith?.oauth?.redirectSignOut &&\n !!cognitoConfig?.loginWith?.oauth?.redirectSignIn &&\n !!cognitoConfig?.loginWith?.oauth?.responseType;\n (0, errorHelpers_1.assert)(validOAuthConfig, errorHelpers_1.AuthConfigurationErrorCode.OAuthNotConfigureException);\n}\nexports.assertOAuthConfig = assertOAuthConfig;\nfunction assertIdentityPoolIdConfig(cognitoConfig) {\n const validConfig = !!cognitoConfig?.identityPoolId;\n (0, errorHelpers_1.assert)(validConfig, errorHelpers_1.AuthConfigurationErrorCode.InvalidIdentityPoolIdException);\n}\nexports.assertIdentityPoolIdConfig = assertIdentityPoolIdConfig;\nfunction decodeJWT(token) {\n const tokenParts = token.split('.');\n if (tokenParts.length !== 3) {\n throw new Error('Invalid token');\n }\n try {\n const base64WithUrlSafe = tokenParts[1];\n const base64 = base64WithUrlSafe.replace(/-/g, '+').replace(/_/g, '/');\n const jsonStr = decodeURIComponent(convert_1.base64Decoder\n .convert(base64)\n .split('')\n .map(char => `%${`00${char.charCodeAt(0).toString(16)}`.slice(-2)}`)\n .join(''));\n const payload = JSON.parse(jsonStr);\n return {\n toString: () => token,\n payload,\n };\n }\n catch (err) {\n throw new Error('Invalid token payload');\n }\n}\nexports.decodeJWT = decodeJWT;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,0BAA0B,GAAG,OAAO,CAAC,iBA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,CAAC,uBAAuB,CAAC,CAAC;AACjD,KAAK;AACL,CAAC;AACD,OAAO,CAAC,SAAS,GAAG,SAAS;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/singleton/Auth/utils/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.decodeJWT = exports.assertIdentityPoolIdConfig = exports.assertOAuthConfig = exports.assertTokenProviderConfig = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst convert_1 = require(\"../../../utils/convert\");\nconst errorHelpers_1 = require(\"./errorHelpers\");\nfunction assertTokenProviderConfig(cognitoConfig) {\n let assertionValid = true; // assume valid until otherwise proveed\n if (!cognitoConfig) {\n assertionValid = false;\n }\n else {\n assertionValid =\n !!cognitoConfig.userPoolId && !!cognitoConfig.userPoolClientId;\n }\n (0, errorHelpers_1.assert)(assertionValid, errorHelpers_1.AuthConfigurationErrorCode.AuthUserPoolException);\n}\nexports.assertTokenProviderConfig = assertTokenProviderConfig;\nfunction assertOAuthConfig(cognitoConfig) {\n const validOAuthConfig = !!cognitoConfig?.loginWith?.oauth?.domain &&\n !!cognitoConfig?.loginWith?.oauth?.redirectSignOut &&\n !!cognitoConfig?.loginWith?.oauth?.redirectSignIn &&\n !!cognitoConfig?.loginWith?.oauth?.responseType;\n (0, errorHelpers_1.assert)(validOAuthConfig, errorHelpers_1.AuthConfigurationErrorCode.OAuthNotConfigureException);\n}\nexports.assertOAuthConfig = assertOAuthConfig;\nfunction assertIdentityPoolIdConfig(cognitoConfig) {\n const validConfig = !!cognitoConfig?.identityPoolId;\n (0, errorHelpers_1.assert)(validConfig, errorHelpers_1.AuthConfigurationErrorCode.InvalidIdentityPoolIdException);\n}\nexports.assertIdentityPoolIdConfig = assertIdentityPoolIdConfig;\n/**\n * Decodes payload of JWT token\n *\n * @param {String} token A string representing a token to be decoded\n * @throws {@link Error} - Throws error when token is invalid or payload malformed.\n */\nfunction decodeJWT(token) {\n const tokenParts = token.split('.');\n if (tokenParts.length !== 3) {\n throw new Error('Invalid token');\n }\n try {\n const base64WithUrlSafe = tokenParts[1];\n const base64 = base64WithUrlSafe.replace(/-/g, '+').replace(/_/g, '/');\n const jsonStr = decodeURIComponent(convert_1.base64Decoder\n .convert(base64)\n .split('')\n .map(char => `%${`00${char.charCodeAt(0).toString(16)}`.slice(-2)}`)\n .join(''));\n const payload = JSON.parse(jsonStr);\n return {\n toString: () => token,\n payload,\n };\n }\n catch (err) {\n throw new Error('Invalid token payload');\n }\n}\nexports.decodeJWT = decodeJWT;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,yBAAyB,GAAG,KAAK,CAAC,CAAC;AAChI;AACA;AACA,MAAM,SAAS,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACpD,MAAM,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACjD,SAAS,yBAAyB,CAAC,aAAa,EAAE;AAClD,IAAI,IAAI,cAAc,GAAG,IAAI,CAAC;AAC9B,IAAI,IAAI,CAAC,aAAa,EAAE;AACxB,QAAQ,cAAc,GAAG,KAAK,CAAC;AAC/B,KAAK;AACL,SAAS;AACT,QAAQ,cAAc;AACtB,YAAY,CAAC,CAAC,aAAa,CAAC,UAAU,IAAI,CAAC,CAAC,aAAa,CAAC,gBAAgB,CAAC;AAC3E,KAAK;AACL,IAAI,IAAI,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,cAAc,CAAC,0BAA0B,CAAC,qBAAqB,CAAC,CAAC;AAChH,CAAC;AACD,OAAO,CAAC,yBAAyB,GAAG,yBAAyB,CAAC;AAC9D,SAAS,iBAAiB,CAAC,aAAa,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BAAkB,CAAC,SAAS,CAAC,aAAa;AAClE,aAAa,OAAO,CAAC,MAAM,CAAC;AAC5B,aAAa,KAAK,CAAC,EAAE,CAAC;AACtB,aAAa,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChF,aAAa,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACvB,QAAQ,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC5C,QAAQ,OAAO;AACf,YAAY,QAAQ,EAAE,MAAM,KAAK;AACjC,YAAY,OAAO;AACnB,SAAS,CAAC;AACV,KAAK;AACL,IAAI,OAAO,GAAG,EAAE;AAChB,QAAQ,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;AACjD,KAAK;AACL,CAAC;AACD,OAAO,CAAC,SAAS,GAAG,SAAS;;"}
@@ -6,6 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchAuthSession = void 0;
7
7
  const Amplify_1 = require("../Amplify");
8
8
  const fetchAuthSession_1 = require("./internal/fetchAuthSession");
9
+ /**
10
+ * Fetch the auth session including the tokens and credentials if they are available. By default it
11
+ * does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh
12
+ * with `{ forceRefresh: true }` input.
13
+ *
14
+ * @param options - Options configuring the fetch behavior.
15
+ * @throws {@link AuthError} - Throws error when session information cannot be refreshed.
16
+ * @returns Promise<AuthSession>
17
+ */
9
18
  const fetchAuthSession = (options) => {
10
19
  return (0, fetchAuthSession_1.fetchAuthSession)(Amplify_1.Amplify, options);
11
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"fetchAuthSession.js","sources":["../../../../src/singleton/apis/fetchAuthSession.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.fetchAuthSession = void 0;\nconst Amplify_1 = require(\"../Amplify\");\nconst fetchAuthSession_1 = require(\"./internal/fetchAuthSession\");\nconst fetchAuthSession = (options) => {\n return (0, fetchAuthSession_1.fetchAuthSession)(Amplify_1.Amplify, options);\n};\nexports.fetchAuthSession = fetchAuthSession;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAClC,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACxC,MAAM,kBAAkB,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAClE,MAAM,gBAAgB,GAAG,CAAC,OAAO,KAAK;AACtC,IAAI,OAAO,IAAI,kBAAkB,CAAC,gBAAgB,EAAE,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAChF,CAAC,CAAC;AACF,OAAO,CAAC,gBAAgB,GAAG,gBAAgB;;"}
1
+ {"version":3,"file":"fetchAuthSession.js","sources":["../../../../src/singleton/apis/fetchAuthSession.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.fetchAuthSession = void 0;\nconst Amplify_1 = require(\"../Amplify\");\nconst fetchAuthSession_1 = require(\"./internal/fetchAuthSession\");\n/**\n * Fetch the auth session including the tokens and credentials if they are available. By default it\n * does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh\n * with `{ forceRefresh: true }` input.\n *\n * @param options - Options configuring the fetch behavior.\n * @throws {@link AuthError} - Throws error when session information cannot be refreshed.\n * @returns Promise<AuthSession>\n */\nconst fetchAuthSession = (options) => {\n return (0, fetchAuthSession_1.fetchAuthSession)(Amplify_1.Amplify, options);\n};\nexports.fetchAuthSession = fetchAuthSession;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAClC,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACxC,MAAM,kBAAkB,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,OAAO,KAAK;AACtC,IAAI,OAAO,IAAI,kBAAkB,CAAC,gBAAgB,EAAE,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAChF,CAAC,CAAC;AACF,OAAO,CAAC,gBAAgB,GAAG,gBAAgB;;"}
@@ -8,5 +8,6 @@ exports.AmplifyErrorCode = void 0;
8
8
  AmplifyErrorCode["NoEndpointId"] = "NoEndpointId";
9
9
  AmplifyErrorCode["PlatformNotSupported"] = "PlatformNotSupported";
10
10
  AmplifyErrorCode["Unknown"] = "Unknown";
11
+ AmplifyErrorCode["NetworkError"] = "NetworkError";
11
12
  })(exports.AmplifyErrorCode || (exports.AmplifyErrorCode = {}));
12
13
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sources":["../../../src/types/errors.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AmplifyErrorCode = void 0;\nvar AmplifyErrorCode;\n(function (AmplifyErrorCode) {\n AmplifyErrorCode[\"NoEndpointId\"] = \"NoEndpointId\";\n AmplifyErrorCode[\"PlatformNotSupported\"] = \"PlatformNotSupported\";\n AmplifyErrorCode[\"Unknown\"] = \"Unknown\";\n})(AmplifyErrorCode = exports.AmplifyErrorCode || (exports.AmplifyErrorCode = {}));\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAElC,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACtD,IAAI,gBAAgB,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;AACtE,IAAI,gBAAgB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AAC5C,CAAC,EAAqB,OAAO,CAAC,gBAAgB,KAAK,OAAO,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC;;"}
1
+ {"version":3,"file":"errors.js","sources":["../../../src/types/errors.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AmplifyErrorCode = void 0;\nvar AmplifyErrorCode;\n(function (AmplifyErrorCode) {\n AmplifyErrorCode[\"NoEndpointId\"] = \"NoEndpointId\";\n AmplifyErrorCode[\"PlatformNotSupported\"] = \"PlatformNotSupported\";\n AmplifyErrorCode[\"Unknown\"] = \"Unknown\";\n AmplifyErrorCode[\"NetworkError\"] = \"NetworkError\";\n})(AmplifyErrorCode = exports.AmplifyErrorCode || (exports.AmplifyErrorCode = {}));\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAElC,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACtD,IAAI,gBAAgB,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;AACtE,IAAI,gBAAgB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AAC5C,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACtD,CAAC,EAAqB,OAAO,CAAC,gBAAgB,KAAK,OAAO,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC;;"}
@@ -1 +1 @@
1
- export declare const version = "6.5.2";
1
+ export declare const version = "6.5.3";
@@ -1,5 +1,5 @@
1
1
  // generated by genversion
2
- const version = '6.5.2';
2
+ const version = '6.5.3';
3
3
 
4
4
  export { version };
5
5
  //# sourceMappingURL=version.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.5.2';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
1
+ {"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.5.3';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
@@ -1,4 +1,6 @@
1
1
  import { getDnsSuffix } from '../../clients/endpoints/getDnsSuffix.mjs';
2
+ import '../../types/errors.mjs';
3
+ import '../../errors/errorHelpers.mjs';
2
4
  import { unauthenticatedHandler } from '../../clients/handlers/unauthenticated.mjs';
3
5
  import { jitteredBackoff } from '../../clients/middleware/retry/jitteredBackoff.mjs';
4
6
  import { getRetryDecider } from '../../clients/middleware/retry/defaultRetryDecider.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"base.mjs","sources":["../../../../src/awsClients/cognitoIdentity/base.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getDnsSuffix, parseJsonError, unauthenticatedHandler, } from '../../clients';\nimport { composeTransferHandler } from '../../clients/internal/composeTransferHandler';\nimport { getRetryDecider, jitteredBackoff, } from '../../clients/middleware/retry';\nimport { getAmplifyUserAgent } from '../../Platform';\nimport { observeFrameworkChanges } from '../../Platform/detectFramework';\nimport { AmplifyUrl } from '../../utils/amplifyUrl';\n/**\n * The service name used to sign requests if the API requires authentication.\n */\nconst SERVICE_NAME = 'cognito-identity';\n/**\n * The endpoint resolver function that returns the endpoint URL for a given region.\n */\nconst endpointResolver = ({ region }) => ({\n url: new AmplifyUrl(`https://cognito-identity.${region}.${getDnsSuffix(region)}`),\n});\n/**\n * A Cognito Identity-specific middleware that disables caching for all requests.\n */\nconst disableCacheMiddlewareFactory = () => next => async function disableCacheMiddleware(request) {\n request.headers['cache-control'] = 'no-store';\n return next(request);\n};\n/**\n * A Cognito Identity-specific transfer handler that does NOT sign requests, and\n * disables caching.\n *\n * @internal\n */\nexport const cognitoIdentityTransferHandler = composeTransferHandler(unauthenticatedHandler, [disableCacheMiddlewareFactory]);\n/**\n * @internal\n */\nexport const defaultConfig = {\n service: SERVICE_NAME,\n endpointResolver,\n retryDecider: getRetryDecider(parseJsonError),\n computeDelay: jitteredBackoff,\n userAgentValue: getAmplifyUserAgent(),\n cache: 'no-store',\n};\nobserveFrameworkChanges(() => {\n defaultConfig.userAgentValue = getAmplifyUserAgent();\n});\n/**\n * @internal\n */\nexport const getSharedHeaders = (operation) => ({\n 'content-type': 'application/x-amz-json-1.1',\n 'x-amz-target': `AWSCognitoIdentityService.${operation}`,\n});\n/**\n * @internal\n */\nexport const buildHttpRpcRequest = ({ url }, headers, body) => ({\n headers,\n url,\n body,\n method: 'POST',\n});\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACA,MAAM,YAAY,GAAG,kBAAkB,CAAC;AACxC;AACA;AACA;AACA,MAAM,gBAA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ClB,CAAC;;;;"}
1
+ {"version":3,"file":"base.mjs","sources":["../../../../src/awsClients/cognitoIdentity/base.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getDnsSuffix, parseJsonError, unauthenticatedHandler, } from '../../clients';\nimport { composeTransferHandler } from '../../clients/internal/composeTransferHandler';\nimport { getRetryDecider, jitteredBackoff, } from '../../clients/middleware/retry';\nimport { getAmplifyUserAgent } from '../../Platform';\nimport { observeFrameworkChanges } from '../../Platform/detectFramework';\nimport { AmplifyUrl } from '../../utils/amplifyUrl';\n/**\n * The service name used to sign requests if the API requires authentication.\n */\nconst SERVICE_NAME = 'cognito-identity';\n/**\n * The endpoint resolver function that returns the endpoint URL for a given region.\n */\nconst endpointResolver = ({ region }) => ({\n url: new AmplifyUrl(`https://cognito-identity.${region}.${getDnsSuffix(region)}`),\n});\n/**\n * A Cognito Identity-specific middleware that disables caching for all requests.\n */\nconst disableCacheMiddlewareFactory = () => next => async function disableCacheMiddleware(request) {\n request.headers['cache-control'] = 'no-store';\n return next(request);\n};\n/**\n * A Cognito Identity-specific transfer handler that does NOT sign requests, and\n * disables caching.\n *\n * @internal\n */\nexport const cognitoIdentityTransferHandler = composeTransferHandler(unauthenticatedHandler, [disableCacheMiddlewareFactory]);\n/**\n * @internal\n */\nexport const defaultConfig = {\n service: SERVICE_NAME,\n endpointResolver,\n retryDecider: getRetryDecider(parseJsonError),\n computeDelay: jitteredBackoff,\n userAgentValue: getAmplifyUserAgent(),\n cache: 'no-store',\n};\nobserveFrameworkChanges(() => {\n defaultConfig.userAgentValue = getAmplifyUserAgent();\n});\n/**\n * @internal\n */\nexport const getSharedHeaders = (operation) => ({\n 'content-type': 'application/x-amz-json-1.1',\n 'x-amz-target': `AWSCognitoIdentityService.${operation}`,\n});\n/**\n * @internal\n */\nexport const buildHttpRpcRequest = ({ url }, headers, body) => ({\n headers,\n url,\n body,\n method: 'POST',\n});\n"],"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AG,EAAE,EAAE,OAAO,EAAE,IAAI,MAAM;AAChE,IAAI,OAAO;AACX,IAAI,GAAG;AACP,IAAI,IAAI;AACR,IAAI,MAAM,EAAE,MAAM;AAClB,CAAC;;;;"}
@@ -1,3 +1,5 @@
1
+ import '../../types/errors.mjs';
2
+ import '../../errors/errorHelpers.mjs';
1
3
  import '../../utils/getClientInfo/getClientInfo.mjs';
2
4
  import '../../utils/retry/retry.mjs';
3
5
  import '@aws-crypto/sha256-js';
@@ -1 +1 @@
1
- {"version":3,"file":"getCredentialsForIdentity.mjs","sources":["../../../../src/awsClients/cognitoIdentity/getCredentialsForIdentity.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseJsonBody, parseJsonError, parseMetadata, } from '../../clients';\nimport { composeServiceApi } from '../../clients/internal';\nimport { buildHttpRpcRequest, cognitoIdentityTransferHandler, defaultConfig, getSharedHeaders, } from './base';\nconst getCredentialsForIdentitySerializer = (input, endpoint) => {\n const headers = getSharedHeaders('GetCredentialsForIdentity');\n const body = JSON.stringify(input);\n return buildHttpRpcRequest(endpoint, headers, body);\n};\nconst getCredentialsForIdentityDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseJsonError(response);\n throw error;\n }\n else {\n const body = await parseJsonBody(response);\n return {\n IdentityId: body.IdentityId,\n Credentials: deserializeCredentials(body.Credentials),\n $metadata: parseMetadata(response),\n };\n }\n};\nconst deserializeCredentials = ({ AccessKeyId, SecretKey, SessionToken, Expiration, } = {}) => {\n return {\n AccessKeyId,\n SecretKey,\n SessionToken,\n Expiration: Expiration && new Date(Expiration * 1000),\n };\n};\n/**\n * @internal\n */\nexport const getCredentialsForIdentity = composeServiceApi(cognitoIdentityTransferHandler, getCredentialsForIdentitySerializer, getCredentialsForIdentityDeserializer, defaultConfig);\n"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AAIA,MAAM,mCAAmC,GAAG,CAAC,KAA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getCredentialsForIdentity.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseJsonBody, parseJsonError, parseMetadata, } from '../../clients';\nimport { composeServiceApi } from '../../clients/internal';\nimport { buildHttpRpcRequest, cognitoIdentityTransferHandler, defaultConfig, getSharedHeaders, } from './base';\nconst getCredentialsForIdentitySerializer = (input, endpoint) => {\n const headers = getSharedHeaders('GetCredentialsForIdentity');\n const body = JSON.stringify(input);\n return buildHttpRpcRequest(endpoint, headers, body);\n};\nconst getCredentialsForIdentityDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseJsonError(response);\n throw error;\n }\n else {\n const body = await parseJsonBody(response);\n return {\n IdentityId: body.IdentityId,\n Credentials: deserializeCredentials(body.Credentials),\n $metadata: parseMetadata(response),\n };\n }\n};\nconst deserializeCredentials = ({ AccessKeyId, SecretKey, SessionToken, Expiration, } = {}) => {\n return {\n AccessKeyId,\n SecretKey,\n SessionToken,\n Expiration: Expiration && new Date(Expiration * 1000),\n };\n};\n/**\n * @internal\n */\nexport const getCredentialsForIdentity = composeServiceApi(cognitoIdentityTransferHandler, getCredentialsForIdentitySerializer, getCredentialsForIdentityDeserializer, defaultConfig);\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAIA,MAAM,mCAAmC,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK;AACjE,IAAI,MAAM,OAAO,GAAG,gBAAgB,CAAC,2BAA2B,CAAC,CAAC;AAClE,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACvC,IAAI,OAAO,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC,CAAC;AACF,MAAM,qCAAqC,GAAG,OAAO,QAAQ,KAAK;AAClE,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;AACrD,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK;AACL,SAAS;AACT,QAAQ,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC;AACnD,QAAQ,OAAO;AACf,YAAY,UAAU,EAAE,IAAI,CAAC,UAAU;AACvC,YAAY,WAAW,EAAE,sBAAsB,CAAC,IAAI,CAAC,WAAW,CAAC;AACjE,YAAY,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC;AAC9C,SAAS,CAAC;AACV,KAAK;AACL,CAAC,CAAC;AACF,MAAM,sBAAsB,GAAG,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,GAAG,GAAG,EAAE,KAAK;AAC/F,IAAI,OAAO;AACX,QAAQ,WAAW;AACnB,QAAQ,SAAS;AACjB,QAAQ,YAAY;AACpB,QAAQ,UAAU,EAAE,UAAU,IAAI,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;AAC7D,KAAK,CAAC;AACN,CAAC,CAAC;AACF;AACA;AACA;AACY,MAAC,yBAAyB,GAAG,iBAAiB,CAAC,8BAA8B,EAAE,mCAAmC,EAAE,qCAAqC,EAAE,aAAa;;;;"}
@@ -1,3 +1,5 @@
1
+ import '../../types/errors.mjs';
2
+ import '../../errors/errorHelpers.mjs';
1
3
  import '../../utils/getClientInfo/getClientInfo.mjs';
2
4
  import '../../utils/retry/retry.mjs';
3
5
  import '@aws-crypto/sha256-js';
@@ -1 +1 @@
1
- {"version":3,"file":"getId.mjs","sources":["../../../../src/awsClients/cognitoIdentity/getId.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseJsonBody, parseJsonError, parseMetadata, } from '../../clients';\nimport { composeServiceApi } from '../../clients/internal';\nimport { buildHttpRpcRequest, cognitoIdentityTransferHandler, defaultConfig, getSharedHeaders, } from './base';\nconst getIdSerializer = (input, endpoint) => {\n const headers = getSharedHeaders('GetId');\n const body = JSON.stringify(input);\n return buildHttpRpcRequest(endpoint, headers, body);\n};\nconst getIdDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseJsonError(response);\n throw error;\n }\n else {\n const body = await parseJsonBody(response);\n return {\n IdentityId: body.IdentityId,\n $metadata: parseMetadata(response),\n };\n }\n};\n/**\n * @internal\n */\nexport const getId = composeServiceApi(cognitoIdentityTransferHandler, getIdSerializer, getIdDeserializer, defaultConfig);\n"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AAIA,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK;AAC7C,IAAI,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC9C,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACvC,IAAI,OAAO,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC,CAAC;AACF,MAAM,iBAAiB,GAAG,OAAO,QAAQ,KAAK;AAC9C,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;AACrD,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK;AACL,SAAS;AACT,QAAQ,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC;AACnD,QAAQ,OAAO;AACf,YAAY,UAAU,EAAE,IAAI,CAAC,UAAU;AACvC,YAAY,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC;AAC9C,SAAS,CAAC;AACV,KAAK;AACL,CAAC,CAAC;AACF;AACA;AACA;AACY,MAAC,KAAK,GAAG,iBAAiB,CAAC,8BAA8B,EAAE,eAAe,EAAE,iBAAiB,EAAE,aAAa;;;;"}
1
+ {"version":3,"file":"getId.mjs","sources":["../../../../src/awsClients/cognitoIdentity/getId.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseJsonBody, parseJsonError, parseMetadata, } from '../../clients';\nimport { composeServiceApi } from '../../clients/internal';\nimport { buildHttpRpcRequest, cognitoIdentityTransferHandler, defaultConfig, getSharedHeaders, } from './base';\nconst getIdSerializer = (input, endpoint) => {\n const headers = getSharedHeaders('GetId');\n const body = JSON.stringify(input);\n return buildHttpRpcRequest(endpoint, headers, body);\n};\nconst getIdDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseJsonError(response);\n throw error;\n }\n else {\n const body = await parseJsonBody(response);\n return {\n IdentityId: body.IdentityId,\n $metadata: parseMetadata(response),\n };\n }\n};\n/**\n * @internal\n */\nexport const getId = composeServiceApi(cognitoIdentityTransferHandler, getIdSerializer, getIdDeserializer, defaultConfig);\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAIA,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK;AAC7C,IAAI,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC9C,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACvC,IAAI,OAAO,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC,CAAC;AACF,MAAM,iBAAiB,GAAG,OAAO,QAAQ,KAAK;AAC9C,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;AACrD,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK;AACL,SAAS;AACT,QAAQ,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC;AACnD,QAAQ,OAAO;AACf,YAAY,UAAU,EAAE,IAAI,CAAC,UAAU;AACvC,YAAY,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC;AAC9C,SAAS,CAAC;AACV,KAAK;AACL,CAAC,CAAC;AACF;AACA;AACA;AACY,MAAC,KAAK,GAAG,iBAAiB,CAAC,8BAA8B,EAAE,eAAe,EAAE,iBAAiB,EAAE,aAAa;;;;"}
@@ -1,3 +1,6 @@
1
+ import { AmplifyError } from '../../errors/AmplifyError.mjs';
2
+ import { AmplifyErrorCode } from '../../types/errors.mjs';
3
+ import '../../errors/errorHelpers.mjs';
1
4
  import { withMemoization } from '../utils/memoization.mjs';
2
5
 
3
6
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -17,11 +20,12 @@ const fetchTransferHandler = async ({ url, method, headers, body }, { abortSigna
17
20
  });
18
21
  }
19
22
  catch (e) {
20
- // TODO: needs to revise error handling in v6
21
- // For now this is a thin wrapper over original fetch error similar to cognito-identity-js package.
22
- // Ref: https://github.com/aws-amplify/amplify-js/blob/4fbc8c0a2be7526aab723579b4c95b552195a80b/packages/amazon-cognito-identity-js/src/Client.js#L103-L108
23
23
  if (e instanceof TypeError) {
24
- throw new Error('Network error');
24
+ throw new AmplifyError({
25
+ name: AmplifyErrorCode.NetworkError,
26
+ message: 'A network error has occurred.',
27
+ underlyingError: e,
28
+ });
25
29
  }
26
30
  throw e;
27
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.mjs","sources":["../../../../src/clients/handlers/fetch.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { withMemoization } from '../utils/memoization';\nconst shouldSendBody = (method) => !['HEAD', 'GET', 'DELETE'].includes(method.toUpperCase());\n// TODO[AllanZhengYP]: we need to provide isCanceledError utility\nexport const fetchTransferHandler = async ({ url, method, headers, body }, { abortSignal, cache, withCrossDomainCredentials }) => {\n let resp;\n try {\n resp = await fetch(url, {\n method,\n headers,\n body: shouldSendBody(method) ? body : undefined,\n signal: abortSignal,\n cache,\n credentials: withCrossDomainCredentials ? 'include' : 'same-origin',\n });\n }\n catch (e) {\n // TODO: needs to revise error handling in v6\n // For now this is a thin wrapper over original fetch error similar to cognito-identity-js package.\n // Ref: https://github.com/aws-amplify/amplify-js/blob/4fbc8c0a2be7526aab723579b4c95b552195a80b/packages/amazon-cognito-identity-js/src/Client.js#L103-L108\n if (e instanceof TypeError) {\n throw new Error('Network error');\n }\n throw e;\n }\n const responseHeaders = {};\n resp.headers?.forEach((value, key) => {\n responseHeaders[key.toLowerCase()] = value;\n });\n const httpResponse = {\n statusCode: resp.status,\n headers: responseHeaders,\n body: null,\n };\n // resp.body is a ReadableStream according to Fetch API spec, but React Native\n // does not implement it.\n const bodyWithMixin = Object.assign(resp.body ?? {}, {\n text: withMemoization(() => resp.text()),\n blob: withMemoization(() => resp.blob()),\n json: withMemoization(() => resp.json()),\n });\n return {\n ...httpResponse,\n body: bodyWithMixin,\n };\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEA,MAAM,cAAc,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AAC7F;AACY,MAAC,oBAAoB,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,0BAA0B,EAAE,KAAK;AAClI,IAAI,IAAI,IAAI,CAAC;AACb,IAAI,IAAI;AACR,QAAQ,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;AAChC,YAAY,MAAM;AAClB,YAAY,OAAO;AACnB,YAAY,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS;AAC3D,YAAY,MAAM,EAAE,WAAW;AAC/B,YAAY,KAAK;AACjB,YAAY,WAAW,EAAE,0BAA0B,GAAG,SAAS,GAAG,aAAa;AAC/E,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,CAAC,EAAE;AACd;AACA;AACA;AACA,QAAQ,IAAI,CAAC,YAAY,SAAS,EAAE;AACpC,YAAY,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;AAC7C,SAAS;AACT,QAAQ,MAAM,CAAC,CAAC;AAChB,KAAK;AACL,IAAI,MAAM,eAAe,GAAG,EAAE,CAAC;AAC/B,IAAI,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AAC1C,QAAQ,eAAe,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;AACnD,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,YAAY,GAAG;AACzB,QAAQ,UAAU,EAAE,IAAI,CAAC,MAAM;AAC/B,QAAQ,OAAO,EAAE,eAAe;AAChC,QAAQ,IAAI,EAAE,IAAI;AAClB,KAAK,CAAC;AACN;AACA;AACA,IAAI,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE;AACzD,QAAQ,IAAI,EAAE,eAAe,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;AAChD,QAAQ,IAAI,EAAE,eAAe,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;AAChD,QAAQ,IAAI,EAAE,eAAe,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;AAChD,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,GAAG,YAAY;AACvB,QAAQ,IAAI,EAAE,aAAa;AAC3B,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"fetch.mjs","sources":["../../../../src/clients/handlers/fetch.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyError } from '../../errors';\nimport { withMemoization } from '../utils/memoization';\nimport { AmplifyErrorCode } from '../../types';\nconst shouldSendBody = (method) => !['HEAD', 'GET', 'DELETE'].includes(method.toUpperCase());\n// TODO[AllanZhengYP]: we need to provide isCanceledError utility\nexport const fetchTransferHandler = async ({ url, method, headers, body }, { abortSignal, cache, withCrossDomainCredentials }) => {\n let resp;\n try {\n resp = await fetch(url, {\n method,\n headers,\n body: shouldSendBody(method) ? body : undefined,\n signal: abortSignal,\n cache,\n credentials: withCrossDomainCredentials ? 'include' : 'same-origin',\n });\n }\n catch (e) {\n if (e instanceof TypeError) {\n throw new AmplifyError({\n name: AmplifyErrorCode.NetworkError,\n message: 'A network error has occurred.',\n underlyingError: e,\n });\n }\n throw e;\n }\n const responseHeaders = {};\n resp.headers?.forEach((value, key) => {\n responseHeaders[key.toLowerCase()] = value;\n });\n const httpResponse = {\n statusCode: resp.status,\n headers: responseHeaders,\n body: null,\n };\n // resp.body is a ReadableStream according to Fetch API spec, but React Native\n // does not implement it.\n const bodyWithMixin = Object.assign(resp.body ?? {}, {\n text: withMemoization(() => resp.text()),\n blob: withMemoization(() => resp.blob()),\n json: withMemoization(() => resp.json()),\n });\n return {\n ...httpResponse,\n body: bodyWithMixin,\n };\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAIA,MAAM,cAAc,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AAC7F;AACY,MAAC,oBAAoB,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,0BAA0B,EAAE,KAAK;AAClI,IAAI,IAAI,IAAI,CAAC;AACb,IAAI,IAAI;AACR,QAAQ,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;AAChC,YAAY,MAAM;AAClB,YAAY,OA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;AACP,IAAI,OAAO;AACX,QAAQ,GAAG,YAAY;AACvB,QAAQ,IAAI,EAAE,aAAa;AAC3B,KAAK,CAAC;AACN;;;;"}
@@ -13,6 +13,9 @@ const amplifyErrorMap = {
13
13
  [AmplifyErrorCode.Unknown]: {
14
14
  message: 'An unknown error occurred.',
15
15
  },
16
+ [AmplifyErrorCode.NetworkError]: {
17
+ message: 'A network error has occurred.',
18
+ },
16
19
  };
17
20
  const assert = createAssertionFunction(amplifyErrorMap);
18
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"errorHelpers.mjs","sources":["../../../src/errors/errorHelpers.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyErrorCode } from '../types';\nimport { createAssertionFunction } from './createAssertionFunction';\nconst amplifyErrorMap = {\n [AmplifyErrorCode.NoEndpointId]: {\n message: 'Endpoint ID was not found and was unable to be created.',\n },\n [AmplifyErrorCode.PlatformNotSupported]: {\n message: 'Function not supported on current platform.',\n },\n [AmplifyErrorCode.Unknown]: {\n message: 'An unknown error occurred.',\n },\n};\nexport const assert = createAssertionFunction(amplifyErrorMap);\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA,MAAM,eAAe,GAAG;AACxB,IAAI,CAAC,gBAAgB,CAAC,YAAY,GAAG;AACrC,QAAQ,OAAO,EAAE,yDAAyD;AAC1E,KAAK;AACL,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,GAAG;AAC7C,QAAQ,OAAO,EAAE,6CAA6C;AAC9D,KAAK;AACL,IAAI,CAAC,gBAAgB,CAAC,OAAO,GAAG;AAChC,QAAQ,OAAO,EAAE,4BAA4B;AAC7C,KAAK;AACL,CAAC,CAAC;AACU,MAAC,MAAM,GAAG,uBAAuB,CAAC,eAAe;;;;"}
1
+ {"version":3,"file":"errorHelpers.mjs","sources":["../../../src/errors/errorHelpers.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyErrorCode } from '../types';\nimport { createAssertionFunction } from './createAssertionFunction';\nconst amplifyErrorMap = {\n [AmplifyErrorCode.NoEndpointId]: {\n message: 'Endpoint ID was not found and was unable to be created.',\n },\n [AmplifyErrorCode.PlatformNotSupported]: {\n message: 'Function not supported on current platform.',\n },\n [AmplifyErrorCode.Unknown]: {\n message: 'An unknown error occurred.',\n },\n [AmplifyErrorCode.NetworkError]: {\n message: 'A network error has occurred.',\n },\n};\nexport const assert = createAssertionFunction(amplifyErrorMap);\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA,MAAM,eAAe,GAAG;AACxB,IAAI,CAAC,gBAAgB,CAAC,YAAY,GAAG;AACrC,QAAQ,OAAO,EAAE,yDAAyD;AAC1E,KAAK;AACL,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,GAAG;AAC7C,QAAQ,OAAO,EAAE,6CAA6C;AAC9D,KAAK;AACL,IAAI,CAAC,gBAAgB,CAAC,OAAO,GAAG;AAChC,QAAQ,OAAO,EAAE,4BAA4B;AAC7C,KAAK;AACL,IAAI,CAAC,gBAAgB,CAAC,YAAY,GAAG;AACrC,QAAQ,OAAO,EAAE,+BAA+B;AAChD,KAAK;AACL,CAAC,CAAC;AACU,MAAC,MAAM,GAAG,uBAAuB,CAAC,eAAe;;;;"}
@@ -2,6 +2,8 @@ import { getClientInfo } from '../../../utils/getClientInfo/getClientInfo.mjs';
2
2
  import '../../../utils/retry/retry.mjs';
3
3
  import '@aws-crypto/sha256-js';
4
4
  import '@smithy/util-hex-encoding';
5
+ import '../../../types/errors.mjs';
6
+ import '../../../errors/errorHelpers.mjs';
5
7
  import '../../../awsClients/pinpoint/base.mjs';
6
8
  import '../../../awsClients/pinpoint/errorHelpers.mjs';
7
9
  import { updateEndpoint as updateEndpoint$1 } from '../../../awsClients/pinpoint/updateEndpoint.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"updateEndpoint.mjs","sources":["../../../../../src/providers/pinpoint/apis/updateEndpoint.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { updateEndpoint as clientUpdateEndpoint, } from '../../../awsClients/pinpoint';\nimport { amplifyUuid } from '../../../utils/amplifyUuid';\nimport { getClientInfo } from '../../../utils/getClientInfo';\nimport { cacheEndpointId } from '../utils/cacheEndpointId';\nimport { clearCreatedEndpointId, createEndpointId, } from '../utils/createEndpointId';\nimport { getEndpointId } from '../utils/getEndpointId';\n/**\n * @internal\n */\nexport const updateEndpoint = async ({ address, appId, category, channelType, credentials, identityId, optOut, region, userAttributes, userId, userProfile, userAgentValue, }) => {\n const endpointId = await getEndpointId(appId, category);\n // only generate a new endpoint id if one was not found in cache\n const createdEndpointId = !endpointId\n ? createEndpointId(appId, category)\n : undefined;\n const { customProperties, demographic, email, location, metrics, name, plan, } = userProfile ?? {};\n // only automatically populate the endpoint with client info and identity id upon endpoint creation to\n // avoid overwriting the endpoint with these values every time the endpoint is updated\n const demographicsFromClientInfo = {};\n const resolvedUserId = createdEndpointId ? (userId ?? identityId) : userId;\n if (createdEndpointId) {\n const clientInfo = getClientInfo();\n demographicsFromClientInfo.appVersion = clientInfo.appVersion;\n demographicsFromClientInfo.make = clientInfo.make;\n demographicsFromClientInfo.model = clientInfo.model;\n demographicsFromClientInfo.modelVersion = clientInfo.version;\n demographicsFromClientInfo.platform = clientInfo.platform;\n }\n const mergedDemographic = {\n ...demographicsFromClientInfo,\n ...demographic,\n };\n const attributes = {\n ...(email && { email: [email] }),\n ...(name && { name: [name] }),\n ...(plan && { plan: [plan] }),\n ...customProperties,\n };\n const shouldAddDemographics = createdEndpointId || demographic;\n const shouldAddAttributes = email || customProperties || name || plan;\n const shouldAddUser = resolvedUserId || userAttributes;\n const input = {\n ApplicationId: appId,\n EndpointId: endpointId ?? createdEndpointId,\n EndpointRequest: {\n RequestId: amplifyUuid(),\n EffectiveDate: new Date().toISOString(),\n ChannelType: channelType,\n Address: address,\n ...(shouldAddAttributes && { Attributes: attributes }),\n ...(shouldAddDemographics && {\n Demographic: {\n AppVersion: mergedDemographic.appVersion,\n Locale: mergedDemographic.locale,\n Make: mergedDemographic.make,\n Model: mergedDemographic.model,\n ModelVersion: mergedDemographic.modelVersion,\n Platform: mergedDemographic.platform,\n PlatformVersion: mergedDemographic.platformVersion,\n Timezone: mergedDemographic.timezone,\n },\n }),\n ...(location && {\n Location: {\n City: location.city,\n Country: location.country,\n Latitude: location.latitude,\n Longitude: location.longitude,\n PostalCode: location.postalCode,\n Region: location.region,\n },\n }),\n Metrics: metrics,\n OptOut: optOut,\n ...(shouldAddUser && {\n User: {\n UserId: resolvedUserId,\n UserAttributes: userAttributes,\n },\n }),\n },\n };\n try {\n await clientUpdateEndpoint({ credentials, region, userAgentValue }, input);\n // if we had to create an endpoint id, we need to now cache it\n if (createdEndpointId) {\n await cacheEndpointId(appId, category, createdEndpointId);\n }\n }\n finally {\n // at this point, we completely reset the behavior so even if the update was unsuccessful\n // we can just start over with a newly created endpoint id\n if (createdEndpointId) {\n clearCreatedEndpointId(appId, category);\n }\n }\n};\n"],"names":["clientUpdateEndpoint"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACY,MAAC,cAAc,GAAG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,GAAG,KAAK;AAClL,IAAI,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC5D;AACA,IAAI,MAAM,iBAAiB,GAAG,CAAC,UAAU;AACzC,UAAU,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC;AAC3C,UAAU,SAAS,CAAC;AACpB,IAAI,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,KAAK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;AACd,YAAY,OAAO,EAAE,OAAO;AAC5B,YAAY,MAAM,EAAE,MAAM;AAC1B,YAAY,IAAI,aAAa,IAAI;AACjC,gBAAgB,IAAI,EAAE;AACtB,oBAAoB,MAAM,EAAE,cAAc;AAC1C,oBAAoB,cAAc,EAAE,cAAc;AAClD,iBAAiB;AACjB,aAAa,CAAC;AACd,SAAS;AACT,KAAK,CAAC;AACN,IAAI,IAAI;AACR,QAAQ,MAAMA,gBAAoB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,KAAK,CAAC,CAAC;AACnF;AACA,QAAQ,IAAI,iBAAiB,EAAE;AAC/B,YAAY,MAAM,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AACtE,SAAS;AACT,KAAK;AACL,YAAY;AACZ;AACA;AACA,QAAQ,IAAI,iBAAiB,EAAE;AAC/B,YAAY,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACpD,SAAS;AACT,KAAK;AACL;;;;"}
1
+ {"version":3,"file":"updateEndpoint.mjs","sources":["../../../../../src/providers/pinpoint/apis/updateEndpoint.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { updateEndpoint as clientUpdateEndpoint, } from '../../../awsClients/pinpoint';\nimport { amplifyUuid } from '../../../utils/amplifyUuid';\nimport { getClientInfo } from '../../../utils/getClientInfo';\nimport { cacheEndpointId } from '../utils/cacheEndpointId';\nimport { clearCreatedEndpointId, createEndpointId, } from '../utils/createEndpointId';\nimport { getEndpointId } from '../utils/getEndpointId';\n/**\n * @internal\n */\nexport const updateEndpoint = async ({ address, appId, category, channelType, credentials, identityId, optOut, region, userAttributes, userId, userProfile, userAgentValue, }) => {\n const endpointId = await getEndpointId(appId, category);\n // only generate a new endpoint id if one was not found in cache\n const createdEndpointId = !endpointId\n ? createEndpointId(appId, category)\n : undefined;\n const { customProperties, demographic, email, location, metrics, name, plan, } = userProfile ?? {};\n // only automatically populate the endpoint with client info and identity id upon endpoint creation to\n // avoid overwriting the endpoint with these values every time the endpoint is updated\n const demographicsFromClientInfo = {};\n const resolvedUserId = createdEndpointId ? (userId ?? identityId) : userId;\n if (createdEndpointId) {\n const clientInfo = getClientInfo();\n demographicsFromClientInfo.appVersion = clientInfo.appVersion;\n demographicsFromClientInfo.make = clientInfo.make;\n demographicsFromClientInfo.model = clientInfo.model;\n demographicsFromClientInfo.modelVersion = clientInfo.version;\n demographicsFromClientInfo.platform = clientInfo.platform;\n }\n const mergedDemographic = {\n ...demographicsFromClientInfo,\n ...demographic,\n };\n const attributes = {\n ...(email && { email: [email] }),\n ...(name && { name: [name] }),\n ...(plan && { plan: [plan] }),\n ...customProperties,\n };\n const shouldAddDemographics = createdEndpointId || demographic;\n const shouldAddAttributes = email || customProperties || name || plan;\n const shouldAddUser = resolvedUserId || userAttributes;\n const input = {\n ApplicationId: appId,\n EndpointId: endpointId ?? createdEndpointId,\n EndpointRequest: {\n RequestId: amplifyUuid(),\n EffectiveDate: new Date().toISOString(),\n ChannelType: channelType,\n Address: address,\n ...(shouldAddAttributes && { Attributes: attributes }),\n ...(shouldAddDemographics && {\n Demographic: {\n AppVersion: mergedDemographic.appVersion,\n Locale: mergedDemographic.locale,\n Make: mergedDemographic.make,\n Model: mergedDemographic.model,\n ModelVersion: mergedDemographic.modelVersion,\n Platform: mergedDemographic.platform,\n PlatformVersion: mergedDemographic.platformVersion,\n Timezone: mergedDemographic.timezone,\n },\n }),\n ...(location && {\n Location: {\n City: location.city,\n Country: location.country,\n Latitude: location.latitude,\n Longitude: location.longitude,\n PostalCode: location.postalCode,\n Region: location.region,\n },\n }),\n Metrics: metrics,\n OptOut: optOut,\n ...(shouldAddUser && {\n User: {\n UserId: resolvedUserId,\n UserAttributes: userAttributes,\n },\n }),\n },\n };\n try {\n await clientUpdateEndpoint({ credentials, region, userAgentValue }, input);\n // if we had to create an endpoint id, we need to now cache it\n if (createdEndpointId) {\n await cacheEndpointId(appId, category, createdEndpointId);\n }\n }\n finally {\n // at this point, we completely reset the behavior so even if the update was unsuccessful\n // we can just start over with a newly created endpoint id\n if (createdEndpointId) {\n clearCreatedEndpointId(appId, category);\n }\n }\n};\n"],"names":["clientUpdateEndpoint"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACY,MAAC,cAAc,GAAG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,GAAG,KAAK;AAClL,IAAI,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC5D;AACA,IAAI,MAAM,iBAAiB,GAAG,CAAC,UAAU;AACzC,UAAU,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC;AAC3C,UAAU,SAAS,CAAC;AACpB,IAAI,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,GAAG,WAAW,IAAI,EAAE,CAAC;AACvG;AACA;AACA,IAAI,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAC1C,IAAI,MAAM,cAAc,GAAG,iBAAiB,IAAI,MAAM,IAAI,UAAU,IAAI,MAAM,CAAC;AAC/E,IAAI,IAAI,iBAAiB,EAAE;AAC3B,QAAQ,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;AAC3C,QAAQ,0BAA0B,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;AACtE,QAAQ,0BAA0B,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;AAC1D,QAAQ,0BAA0B,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;AAC5D,QAAQ,0BAA0B,CAAC,YAAY,GAAG,U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AAiB,EAAE;AAC/B,YAAY,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACpD,SAAS;AACT,KAAK;AACL;;;;"}
@@ -3,6 +3,8 @@ import '../../../utils/getClientInfo/getClientInfo.mjs';
3
3
  import '../../../utils/retry/retry.mjs';
4
4
  import '@aws-crypto/sha256-js';
5
5
  import '@smithy/util-hex-encoding';
6
+ import '../../../types/errors.mjs';
7
+ import '../../../errors/errorHelpers.mjs';
6
8
  import '../../../awsClients/pinpoint/base.mjs';
7
9
  import { putEvents } from '../../../awsClients/pinpoint/putEvents.mjs';
8
10
  import { isAppInForeground } from './isAppInForeground.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"PinpointEventBuffer.mjs","sources":["../../../../../src/providers/pinpoint/utils/PinpointEventBuffer.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '../../../Logger';\nimport { putEvents, } from '../../../awsClients/pinpoint';\nimport { isAppInForeground } from './isAppInForeground';\nconst logger = new ConsoleLogger('PinpointEventBuffer');\nconst RETRYABLE_CODES = [429, 500];\nconst ACCEPTED_CODES = [202];\nexport class PinpointEventBuffer {\n constructor(config) {\n this._interval = undefined;\n this._pause = false;\n this._flush = false;\n this._buffer = [];\n this._config = config;\n this._sendBatch = this._sendBatch.bind(this);\n this._startLoop();\n }\n push(event) {\n if (this._buffer.length >= this._config.bufferSize) {\n logger.debug('Exceeded Pinpoint event buffer limits, event dropped.', {\n eventId: event.eventId,\n });\n return;\n }\n this._buffer.push({ [event.eventId]: event });\n }\n pause() {\n this._pause = true;\n }\n resume() {\n this._pause = false;\n }\n flush() {\n this._flush = true;\n }\n identityHasChanged(identityId) {\n return this._config.identityId !== identityId;\n }\n flushAll() {\n this._putEvents(this._buffer.splice(0, this._buffer.length));\n }\n _startLoop() {\n if (this._interval) {\n clearInterval(this._interval);\n }\n const { flushInterval } = this._config;\n this._interval = setInterval(this._sendBatch, flushInterval);\n }\n _sendBatch() {\n const bufferLength = this._buffer.length;\n if (this._flush && !bufferLength && this._interval) {\n clearInterval(this._interval);\n }\n if (this._pause || !bufferLength || !isAppInForeground()) {\n return;\n }\n const { flushSize } = this._config;\n const batchSize = Math.min(flushSize, bufferLength);\n const bufferSubset = this._buffer.splice(0, batchSize);\n this._putEvents(bufferSubset);\n }\n async _putEvents(buffer) {\n const eventMap = this._bufferToMap(buffer);\n const batchEventParams = this._generateBatchEventParams(eventMap);\n try {\n const { credentials, region, userAgentValue } = this._config;\n const data = await putEvents({\n credentials,\n region,\n userAgentValue,\n }, batchEventParams);\n this._processPutEventsSuccessResponse(data, eventMap);\n }\n catch (err) {\n this._handlePutEventsFailure(err, eventMap);\n }\n }\n _generateBatchEventParams(eventMap) {\n const batchItem = {};\n Object.values(eventMap).forEach(item => {\n const { event, timestamp, endpointId, eventId, session } = item;\n const { name, attributes, metrics } = event;\n batchItem[endpointId] = {\n Endpoint: {\n ...batchItem[endpointId]?.Endpoint,\n },\n Events: {\n ...batchItem[endpointId]?.Events,\n [eventId]: {\n EventType: name,\n Timestamp: new Date(timestamp).toISOString(),\n Attributes: attributes,\n Metrics: metrics,\n Session: session,\n },\n },\n };\n });\n return {\n ApplicationId: this._config.appId,\n EventsRequest: {\n BatchItem: batchItem,\n },\n };\n }\n _handlePutEventsFailure(err, eventMap) {\n logger.debug('putEvents call to Pinpoint failed.', err);\n const statusCode = err.$metadata && err.$metadata.httpStatusCode;\n if (RETRYABLE_CODES.includes(statusCode)) {\n const retryableEvents = Object.values(eventMap);\n this._retry(retryableEvents);\n }\n }\n _processPutEventsSuccessResponse(data, eventMap) {\n const { Results = {} } = data.EventsResponse ?? {};\n const retryableEvents = [];\n Object.entries(Results).forEach(([_, endpointValues]) => {\n const responses = endpointValues.EventsItemResponse ?? {};\n Object.entries(responses).forEach(([eventId, eventValues]) => {\n const eventObject = eventMap[eventId];\n if (!eventObject) {\n return;\n }\n const { StatusCode, Message } = eventValues ?? {};\n if (StatusCode && ACCEPTED_CODES.includes(StatusCode)) {\n return;\n }\n if (StatusCode && RETRYABLE_CODES.includes(StatusCode)) {\n retryableEvents.push(eventObject);\n return;\n }\n const { name } = eventObject.event;\n logger.warn('Pinpoint event failed to send.', {\n eventId,\n name,\n message: Message,\n });\n });\n });\n if (retryableEvents.length) {\n this._retry(retryableEvents);\n }\n }\n _retry(retryableEvents) {\n // retryable events that haven't reached the resendLimit\n const eligibleEvents = [];\n retryableEvents.forEach((bufferedEvent) => {\n const { eventId } = bufferedEvent;\n const { name } = bufferedEvent.event;\n if (bufferedEvent.resendLimit-- > 0) {\n logger.debug('Resending event.', {\n eventId,\n name,\n remainingAttempts: bufferedEvent.resendLimit,\n });\n eligibleEvents.push({ [eventId]: bufferedEvent });\n return;\n }\n logger.debug('No retry attempts remaining for event.', {\n eventId,\n name,\n });\n });\n // add the events to the front of the buffer\n this._buffer.unshift(...eligibleEvents);\n }\n _bufferToMap(buffer) {\n return buffer.reduce((acc, curVal) => {\n const [[key, value]] = Object.entries(curVal);\n acc[key] = value;\n return acc;\n }, {});\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AAIA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,qBAAqB,CAAC,CAAC;AACxD,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACnC,MAAM,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;AACtB,MAAM,mBAAmB,CAAC;AACjC,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;AACnC,QAAQ,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;AAC5B,QAAQ,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;AAC5B,QAAQ,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAC1B,QAAQ,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;AAC9B,QAAQ,IAA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AAa;AACb,YAAY,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE;AACnE,gBAAgB,OAAO;AACvB,gBAAgB,IAAI;AACpB,aAAa,CAAC,CAAC;AACf,SAAS,CAAC,CAAC;AACX;AACA,QAAQ,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,CAAC;AAChD,KAAK;AACL,IAAI,YAAY,CAAC,MAAM,EAAE;AACzB,QAAQ,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK;AAC9C,YAAY,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC1D,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC7B,YAAY,OAAO,GAAG,CAAC;AACvB,SAAS,EAAE,EAAE,CAAC,CAAC;AACf,KAAK;AACL;;;;"}
1
+ {"version":3,"file":"PinpointEventBuffer.mjs","sources":["../../../../../src/providers/pinpoint/utils/PinpointEventBuffer.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '../../../Logger';\nimport { putEvents, } from '../../../awsClients/pinpoint';\nimport { isAppInForeground } from './isAppInForeground';\nconst logger = new ConsoleLogger('PinpointEventBuffer');\nconst RETRYABLE_CODES = [429, 500];\nconst ACCEPTED_CODES = [202];\nexport class PinpointEventBuffer {\n constructor(config) {\n this._interval = undefined;\n this._pause = false;\n this._flush = false;\n this._buffer = [];\n this._config = config;\n this._sendBatch = this._sendBatch.bind(this);\n this._startLoop();\n }\n push(event) {\n if (this._buffer.length >= this._config.bufferSize) {\n logger.debug('Exceeded Pinpoint event buffer limits, event dropped.', {\n eventId: event.eventId,\n });\n return;\n }\n this._buffer.push({ [event.eventId]: event });\n }\n pause() {\n this._pause = true;\n }\n resume() {\n this._pause = false;\n }\n flush() {\n this._flush = true;\n }\n identityHasChanged(identityId) {\n return this._config.identityId !== identityId;\n }\n flushAll() {\n this._putEvents(this._buffer.splice(0, this._buffer.length));\n }\n _startLoop() {\n if (this._interval) {\n clearInterval(this._interval);\n }\n const { flushInterval } = this._config;\n this._interval = setInterval(this._sendBatch, flushInterval);\n }\n _sendBatch() {\n const bufferLength = this._buffer.length;\n if (this._flush && !bufferLength && this._interval) {\n clearInterval(this._interval);\n }\n if (this._pause || !bufferLength || !isAppInForeground()) {\n return;\n }\n const { flushSize } = this._config;\n const batchSize = Math.min(flushSize, bufferLength);\n const bufferSubset = this._buffer.splice(0, batchSize);\n this._putEvents(bufferSubset);\n }\n async _putEvents(buffer) {\n const eventMap = this._bufferToMap(buffer);\n const batchEventParams = this._generateBatchEventParams(eventMap);\n try {\n const { credentials, region, userAgentValue } = this._config;\n const data = await putEvents({\n credentials,\n region,\n userAgentValue,\n }, batchEventParams);\n this._processPutEventsSuccessResponse(data, eventMap);\n }\n catch (err) {\n this._handlePutEventsFailure(err, eventMap);\n }\n }\n _generateBatchEventParams(eventMap) {\n const batchItem = {};\n Object.values(eventMap).forEach(item => {\n const { event, timestamp, endpointId, eventId, session } = item;\n const { name, attributes, metrics } = event;\n batchItem[endpointId] = {\n Endpoint: {\n ...batchItem[endpointId]?.Endpoint,\n },\n Events: {\n ...batchItem[endpointId]?.Events,\n [eventId]: {\n EventType: name,\n Timestamp: new Date(timestamp).toISOString(),\n Attributes: attributes,\n Metrics: metrics,\n Session: session,\n },\n },\n };\n });\n return {\n ApplicationId: this._config.appId,\n EventsRequest: {\n BatchItem: batchItem,\n },\n };\n }\n _handlePutEventsFailure(err, eventMap) {\n logger.debug('putEvents call to Pinpoint failed.', err);\n const statusCode = err.$metadata && err.$metadata.httpStatusCode;\n if (RETRYABLE_CODES.includes(statusCode)) {\n const retryableEvents = Object.values(eventMap);\n this._retry(retryableEvents);\n }\n }\n _processPutEventsSuccessResponse(data, eventMap) {\n const { Results = {} } = data.EventsResponse ?? {};\n const retryableEvents = [];\n Object.entries(Results).forEach(([_, endpointValues]) => {\n const responses = endpointValues.EventsItemResponse ?? {};\n Object.entries(responses).forEach(([eventId, eventValues]) => {\n const eventObject = eventMap[eventId];\n if (!eventObject) {\n return;\n }\n const { StatusCode, Message } = eventValues ?? {};\n if (StatusCode && ACCEPTED_CODES.includes(StatusCode)) {\n return;\n }\n if (StatusCode && RETRYABLE_CODES.includes(StatusCode)) {\n retryableEvents.push(eventObject);\n return;\n }\n const { name } = eventObject.event;\n logger.warn('Pinpoint event failed to send.', {\n eventId,\n name,\n message: Message,\n });\n });\n });\n if (retryableEvents.length) {\n this._retry(retryableEvents);\n }\n }\n _retry(retryableEvents) {\n // retryable events that haven't reached the resendLimit\n const eligibleEvents = [];\n retryableEvents.forEach((bufferedEvent) => {\n const { eventId } = bufferedEvent;\n const { name } = bufferedEvent.event;\n if (bufferedEvent.resendLimit-- > 0) {\n logger.debug('Resending event.', {\n eventId,\n name,\n remainingAttempts: bufferedEvent.resendLimit,\n });\n eligibleEvents.push({ [eventId]: bufferedEvent });\n return;\n }\n logger.debug('No retry attempts remaining for event.', {\n eventId,\n name,\n });\n });\n // add the events to the front of the buffer\n this._buffer.unshift(...eligibleEvents);\n }\n _bufferToMap(buffer) {\n return buffer.reduce((acc, curVal) => {\n const [[key, value]] = Object.entries(curVal);\n acc[key] = value;\n return acc;\n }, {});\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAIA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,qBAAqB,CAAC,CAAC;AACxD,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACnC,MAAM,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;AACtB,MAAM,mBAAmB,CAAC;AACjC,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;AACnC,QAAQ,IAAI,CAAC,MAAM,GAAG,KAAK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oB,iBAAiB,EAAE,aAAa,CAAC,WAAW;AAChE,iBAAiB,CAAC,CAAC;AACnB,gBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,GAAG,aAAa,EAAE,CAAC,CAAC;AAClE,gBAAgB,OAAO;AACvB,aAAa;AACb,YAAY,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE;AACnE,gBAAgB,OAAO;AACvB,gBAAgB,IAAI;AACpB,aAAa,CAAC,CAAC;AACf,SAAS,CAAC,CAAC;AACX;AACA,QAAQ,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,CAAC;AAChD,KAAK;AACL,IAAI,YAAY,CAAC,MAAM,EAAE;AACzB,QAAQ,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK;AAC9C,YAAY,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC1D,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC7B,YAAY,OAAO,GAAG,CAAC;AACvB,SAAS,EAAE,EAAE,CAAC,CAAC;AACf,KAAK;AACL;;;;"}
@@ -7,4 +7,10 @@ export declare function assertOAuthConfig(cognitoConfig?: AuthConfig['Cognito'])
7
7
  };
8
8
  };
9
9
  export declare function assertIdentityPoolIdConfig(cognitoConfig?: StrictUnion<CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig | CognitoIdentityPoolConfig>): asserts cognitoConfig is CognitoIdentityPoolConfig;
10
+ /**
11
+ * Decodes payload of JWT token
12
+ *
13
+ * @param {String} token A string representing a token to be decoded
14
+ * @throws {@link Error} - Throws error when token is invalid or payload malformed.
15
+ */
10
16
  export declare function decodeJWT(token: string): JWT;
@@ -27,6 +27,12 @@ function assertIdentityPoolIdConfig(cognitoConfig) {
27
27
  const validConfig = !!cognitoConfig?.identityPoolId;
28
28
  assert(validConfig, AuthConfigurationErrorCode.InvalidIdentityPoolIdException);
29
29
  }
30
+ /**
31
+ * Decodes payload of JWT token
32
+ *
33
+ * @param {String} token A string representing a token to be decoded
34
+ * @throws {@link Error} - Throws error when token is invalid or payload malformed.
35
+ */
30
36
  function decodeJWT(token) {
31
37
  const tokenParts = token.split('.');
32
38
  if (tokenParts.length !== 3) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../../../src/singleton/Auth/utils/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { base64Decoder } from '../../../utils/convert';\nimport { AuthConfigurationErrorCode, assert } from './errorHelpers';\nexport function assertTokenProviderConfig(cognitoConfig) {\n let assertionValid = true; // assume valid until otherwise proveed\n if (!cognitoConfig) {\n assertionValid = false;\n }\n else {\n assertionValid =\n !!cognitoConfig.userPoolId && !!cognitoConfig.userPoolClientId;\n }\n assert(assertionValid, AuthConfigurationErrorCode.AuthUserPoolException);\n}\nexport function assertOAuthConfig(cognitoConfig) {\n const validOAuthConfig = !!cognitoConfig?.loginWith?.oauth?.domain &&\n !!cognitoConfig?.loginWith?.oauth?.redirectSignOut &&\n !!cognitoConfig?.loginWith?.oauth?.redirectSignIn &&\n !!cognitoConfig?.loginWith?.oauth?.responseType;\n assert(validOAuthConfig, AuthConfigurationErrorCode.OAuthNotConfigureException);\n}\nexport function assertIdentityPoolIdConfig(cognitoConfig) {\n const validConfig = !!cognitoConfig?.identityPoolId;\n assert(validConfig, AuthConfigurationErrorCode.InvalidIdentityPoolIdException);\n}\nexport function decodeJWT(token) {\n const tokenParts = token.split('.');\n if (tokenParts.length !== 3) {\n throw new Error('Invalid token');\n }\n try {\n const base64WithUrlSafe = tokenParts[1];\n const base64 = base64WithUrlSafe.replace(/-/g, '+').replace(/_/g, '/');\n const jsonStr = decodeURIComponent(base64Decoder\n .convert(base64)\n .split('')\n .map(char => `%${`00${char.charCodeAt(0).toString(16)}`.slice(-2)}`)\n .join(''));\n const payload = JSON.parse(jsonStr);\n return {\n toString: () => token,\n payload,\n };\n }\n catch (err) {\n throw new Error('Invalid token payload');\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAGO,SAAS,yBAAyB,CAAC,aAAa,EAAE;AACzD,IAAI,IAAI,cAAc,GAAG,IAAI,CAAC;AAC9B,IAAI,IAAI,CAAC,aAAa,EAAE;AACxB,QAAQ,cAAc,GAAG,KAAK,CAAC;AAC/B,KAAK;AACL,SAAS;AACT,QAAQ,cAAc;AACtB,YAAY,CAAC,CAAC,aAAa,CAAC,UAAU,IAAI,CAAC,CAAC,aAAa,CAAC,gBAAgB,CAAC;AAC3E,KAAK;AACL,IAAI,MAAM,CAAC,cAAc,EAAE,0BAA0B,CAAC,qBAAqB,CAAC,CAAC;AAC7E,CAAC;AACM,SAAS,iBAAiB,CAAC,aAAa,EAAE;AACjD,IAAI,MAAM,gBAAgB,GAAG,CAAC,CAAC,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM;AACtE,QAAQ,CAAC,CAAC,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe;AAC1D,QAAQ,CAAC,CAAC,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc;AACzD,QAAQ,CAAC,CAAC,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,CAAC;AACxD,IAAI,MAAM,CAAC,gBAAgB,EAAE,0BAA0B,CAAC,0BAA0B,CAAC,CAAC;AACpF,CAAC;AACM,SAAS,0BAA0B,CAAC,aAAa,EAAE;AAC1D,IAAI,MAAM,WAAW,GAAG,CAAC,CAAC,aAAa,EAAE,cAAc,CAAC;AACxD,IAAI,MAAM,CAAC,WAAW,EAAE,0BAA0B,CAAC,8BAA8B,CAAC,CAAC;AACnF,CAAC;AACM,SAAS,SAAS,CAAC,KAAK,EAAE;AACjC,IAAI,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACxC,IAAI,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;AACjC,QAAQ,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;AACzC,KAAK;AACL,IAAI,IAAI;AACR,QAAQ,MAAM,iBAAiB,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AAChD,QAAQ,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC/E,QAAQ,MAAM,OAAO,GAAG,kBAAkB,CAAC,aAAa;AACxD,aAAa,OAAO,CAAC,MAAM,CAAC;AAC5B,aAAa,KAAK,CAAC,EAAE,CAAC;AACtB,aAAa,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChF,aAAa,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACvB,QAAQ,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC5C,QAAQ,OAAO;AACf,YAAY,QAAQ,EAAE,MAAM,KAAK;AACjC,YAAY,OAAO;AACnB,SAAS,CAAC;AACV,KAAK;AACL,IAAI,OAAO,GAAG,EAAE;AAChB,QAAQ,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;AACjD,KAAK;AACL;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../../../src/singleton/Auth/utils/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { base64Decoder } from '../../../utils/convert';\nimport { AuthConfigurationErrorCode, assert } from './errorHelpers';\nexport function assertTokenProviderConfig(cognitoConfig) {\n let assertionValid = true; // assume valid until otherwise proveed\n if (!cognitoConfig) {\n assertionValid = false;\n }\n else {\n assertionValid =\n !!cognitoConfig.userPoolId && !!cognitoConfig.userPoolClientId;\n }\n assert(assertionValid, AuthConfigurationErrorCode.AuthUserPoolException);\n}\nexport function assertOAuthConfig(cognitoConfig) {\n const validOAuthConfig = !!cognitoConfig?.loginWith?.oauth?.domain &&\n !!cognitoConfig?.loginWith?.oauth?.redirectSignOut &&\n !!cognitoConfig?.loginWith?.oauth?.redirectSignIn &&\n !!cognitoConfig?.loginWith?.oauth?.responseType;\n assert(validOAuthConfig, AuthConfigurationErrorCode.OAuthNotConfigureException);\n}\nexport function assertIdentityPoolIdConfig(cognitoConfig) {\n const validConfig = !!cognitoConfig?.identityPoolId;\n assert(validConfig, AuthConfigurationErrorCode.InvalidIdentityPoolIdException);\n}\n/**\n * Decodes payload of JWT token\n *\n * @param {String} token A string representing a token to be decoded\n * @throws {@link Error} - Throws error when token is invalid or payload malformed.\n */\nexport function decodeJWT(token) {\n const tokenParts = token.split('.');\n if (tokenParts.length !== 3) {\n throw new Error('Invalid token');\n }\n try {\n const base64WithUrlSafe = tokenParts[1];\n const base64 = base64WithUrlSafe.replace(/-/g, '+').replace(/_/g, '/');\n const jsonStr = decodeURIComponent(base64Decoder\n .convert(base64)\n .split('')\n .map(char => `%${`00${char.charCodeAt(0).toString(16)}`.slice(-2)}`)\n .join(''));\n const payload = JSON.parse(jsonStr);\n return {\n toString: () => token,\n payload,\n };\n }\n catch (err) {\n throw new Error('Invalid token payload');\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAGO,SAAS,yBAAyB,CAAC,aAAa,EAAE;AACzD,IAAI,IAAI,cAAc,GAAG,IAAI,CAAC;AAC9B,IAAI,IAAI,CAAC,aAAa,EAAE;AACxB,QAAQ,cAAc,GAAG,KAAK,CAAC;AAC/B,KAAK;AACL,SAAS;AACT,QAAQ,cAAc;AACtB,YAAY,CAAC,CAAC,aAAa,CAA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AQ,MAAM,OAAO,GAAG,kBAAkB,CAAC,aAAa;AACxD,aAAa,OAAO,CAAC,MAAM,CAAC;AAC5B,aAAa,KAAK,CAAC,EAAE,CAAC;AACtB,aAAa,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChF,aAAa,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACvB,QAAQ,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC5C,QAAQ,OAAO;AACf,YAAY,QAAQ,EAAE,MAAM,KAAK;AACjC,YAAY,OAAO;AACnB,SAAS,CAAC;AACV,KAAK;AACL,IAAI,OAAO,GAAG,EAAE;AAChB,QAAQ,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;AACjD,KAAK;AACL;;;;"}
@@ -1,2 +1,11 @@
1
1
  import { AuthSession, FetchAuthSessionOptions } from '../Auth/types';
2
+ /**
3
+ * Fetch the auth session including the tokens and credentials if they are available. By default it
4
+ * does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh
5
+ * with `{ forceRefresh: true }` input.
6
+ *
7
+ * @param options - Options configuring the fetch behavior.
8
+ * @throws {@link AuthError} - Throws error when session information cannot be refreshed.
9
+ * @returns Promise<AuthSession>
10
+ */
2
11
  export declare const fetchAuthSession: (options?: FetchAuthSessionOptions) => Promise<AuthSession>;
@@ -3,6 +3,15 @@ import { fetchAuthSession as fetchAuthSession$1 } from './internal/fetchAuthSess
3
3
 
4
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
5
  // SPDX-License-Identifier: Apache-2.0
6
+ /**
7
+ * Fetch the auth session including the tokens and credentials if they are available. By default it
8
+ * does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh
9
+ * with `{ forceRefresh: true }` input.
10
+ *
11
+ * @param options - Options configuring the fetch behavior.
12
+ * @throws {@link AuthError} - Throws error when session information cannot be refreshed.
13
+ * @returns Promise<AuthSession>
14
+ */
6
15
  const fetchAuthSession = (options) => {
7
16
  return fetchAuthSession$1(Amplify, options);
8
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"fetchAuthSession.mjs","sources":["../../../../src/singleton/apis/fetchAuthSession.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '../Amplify';\nimport { fetchAuthSession as fetchAuthSessionInternal } from './internal/fetchAuthSession';\nexport const fetchAuthSession = (options) => {\n return fetchAuthSessionInternal(Amplify, options);\n};\n"],"names":["fetchAuthSessionInternal"],"mappings":";;;AAAA;AACA;AAGY,MAAC,gBAAgB,GAAG,CAAC,OAAO,KAAK;AAC7C,IAAI,OAAOA,kBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACtD;;;;"}
1
+ {"version":3,"file":"fetchAuthSession.mjs","sources":["../../../../src/singleton/apis/fetchAuthSession.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '../Amplify';\nimport { fetchAuthSession as fetchAuthSessionInternal } from './internal/fetchAuthSession';\n/**\n * Fetch the auth session including the tokens and credentials if they are available. By default it\n * does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh\n * with `{ forceRefresh: true }` input.\n *\n * @param options - Options configuring the fetch behavior.\n * @throws {@link AuthError} - Throws error when session information cannot be refreshed.\n * @returns Promise<AuthSession>\n */\nexport const fetchAuthSession = (options) => {\n return fetchAuthSessionInternal(Amplify, options);\n};\n"],"names":["fetchAuthSessionInternal"],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,gBAAgB,GAAG,CAAC,OAAO,KAAK;AAC7C,IAAI,OAAOA,kBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACtD;;;;"}
@@ -1,7 +1,8 @@
1
1
  export declare enum AmplifyErrorCode {
2
2
  NoEndpointId = "NoEndpointId",
3
3
  PlatformNotSupported = "PlatformNotSupported",
4
- Unknown = "Unknown"
4
+ Unknown = "Unknown",
5
+ NetworkError = "NetworkError"
5
6
  }
6
7
  export interface AmplifyErrorParams<ErrorCode extends string = string> {
7
8
  message: string;
@@ -5,6 +5,7 @@ var AmplifyErrorCode;
5
5
  AmplifyErrorCode["NoEndpointId"] = "NoEndpointId";
6
6
  AmplifyErrorCode["PlatformNotSupported"] = "PlatformNotSupported";
7
7
  AmplifyErrorCode["Unknown"] = "Unknown";
8
+ AmplifyErrorCode["NetworkError"] = "NetworkError";
8
9
  })(AmplifyErrorCode || (AmplifyErrorCode = {}));
9
10
 
10
11
  export { AmplifyErrorCode };
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","sources":["../../../src/types/errors.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport var AmplifyErrorCode;\n(function (AmplifyErrorCode) {\n AmplifyErrorCode[\"NoEndpointId\"] = \"NoEndpointId\";\n AmplifyErrorCode[\"PlatformNotSupported\"] = \"PlatformNotSupported\";\n AmplifyErrorCode[\"Unknown\"] = \"Unknown\";\n})(AmplifyErrorCode || (AmplifyErrorCode = {}));\n"],"names":[],"mappings":"AAAA;AACA;AACU,IAAC,iBAAiB;AAC5B,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACtD,IAAI,gBAAgB,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;AACtE,IAAI,gBAAgB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AAC5C,CAAC,EAAE,gBAAgB,KAAK,gBAAgB,GAAG,EAAE,CAAC,CAAC;;;;"}
1
+ {"version":3,"file":"errors.mjs","sources":["../../../src/types/errors.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport var AmplifyErrorCode;\n(function (AmplifyErrorCode) {\n AmplifyErrorCode[\"NoEndpointId\"] = \"NoEndpointId\";\n AmplifyErrorCode[\"PlatformNotSupported\"] = \"PlatformNotSupported\";\n AmplifyErrorCode[\"Unknown\"] = \"Unknown\";\n AmplifyErrorCode[\"NetworkError\"] = \"NetworkError\";\n})(AmplifyErrorCode || (AmplifyErrorCode = {}));\n"],"names":[],"mappings":"AAAA;AACA;AACU,IAAC,iBAAiB;AAC5B,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACtD,IAAI,gBAAgB,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;AACtE,IAAI,gBAAgB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AAC5C,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACtD,CAAC,EAAE,gBAAgB,KAAK,gBAAgB,GAAG,EAAE,CAAC,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/core",
3
- "version": "6.3.11",
3
+ "version": "6.3.12",
4
4
  "description": "Core category of aws-amplify",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -82,13 +82,13 @@
82
82
  "name": "Custom clients (fetch handler)",
83
83
  "path": "./dist/esm/clients/handlers/fetch.mjs",
84
84
  "import": "{ fetchTransferHandler }",
85
- "limit": "500 B"
85
+ "limit": "575 B"
86
86
  },
87
87
  {
88
88
  "name": "Custom clients (unauthenticated handler)",
89
89
  "path": "./dist/esm/clients/handlers/unauthenticated.mjs",
90
90
  "import": "{ unauthenticatedHandler }",
91
- "limit": "1 kB"
91
+ "limit": "1.15 kB"
92
92
  },
93
93
  {
94
94
  "name": "Custom clients (request signer)",
@@ -192,5 +192,5 @@
192
192
  ]
193
193
  }
194
194
  },
195
- "gitHead": "733c3bd722f06b87f674736cc3f997d6ba5addda"
195
+ "gitHead": "e2e9c5af8ce2c0a6f89e87e224c16d8551c491bd"
196
196
  }
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '6.5.2';
2
+ export const version = '6.5.3';
@@ -3,7 +3,9 @@
3
3
 
4
4
  import { HttpRequest, HttpResponse, HttpTransferOptions } from '../types/http';
5
5
  import { TransferHandler } from '../types/core';
6
+ import { AmplifyError } from '../../errors';
6
7
  import { withMemoization } from '../utils/memoization';
8
+ import { AmplifyErrorCode } from '../../types';
7
9
 
8
10
  const shouldSendBody = (method: string) =>
9
11
  !['HEAD', 'GET', 'DELETE'].includes(method.toUpperCase());
@@ -28,11 +30,12 @@ export const fetchTransferHandler: TransferHandler<
28
30
  credentials: withCrossDomainCredentials ? 'include' : 'same-origin',
29
31
  });
30
32
  } catch (e) {
31
- // TODO: needs to revise error handling in v6
32
- // For now this is a thin wrapper over original fetch error similar to cognito-identity-js package.
33
- // Ref: https://github.com/aws-amplify/amplify-js/blob/4fbc8c0a2be7526aab723579b4c95b552195a80b/packages/amazon-cognito-identity-js/src/Client.js#L103-L108
34
33
  if (e instanceof TypeError) {
35
- throw new Error('Network error');
34
+ throw new AmplifyError({
35
+ name: AmplifyErrorCode.NetworkError,
36
+ message: 'A network error has occurred.',
37
+ underlyingError: e,
38
+ });
36
39
  }
37
40
  throw e;
38
41
  }
@@ -15,6 +15,9 @@ const amplifyErrorMap: AmplifyErrorMap<AmplifyErrorCode> = {
15
15
  [AmplifyErrorCode.Unknown]: {
16
16
  message: 'An unknown error occurred.',
17
17
  },
18
+ [AmplifyErrorCode.NetworkError]: {
19
+ message: 'A network error has occurred.',
20
+ },
18
21
  };
19
22
 
20
23
  export const assert: AssertionFunction<AmplifyErrorCode> =
@@ -66,6 +66,12 @@ export function assertIdentityPoolIdConfig(
66
66
  );
67
67
  }
68
68
 
69
+ /**
70
+ * Decodes payload of JWT token
71
+ *
72
+ * @param {String} token A string representing a token to be decoded
73
+ * @throws {@link Error} - Throws error when token is invalid or payload malformed.
74
+ */
69
75
  export function decodeJWT(token: string): JWT {
70
76
  const tokenParts = token.split('.');
71
77
 
@@ -6,6 +6,15 @@ import { AuthSession, FetchAuthSessionOptions } from '../Auth/types';
6
6
 
7
7
  import { fetchAuthSession as fetchAuthSessionInternal } from './internal/fetchAuthSession';
8
8
 
9
+ /**
10
+ * Fetch the auth session including the tokens and credentials if they are available. By default it
11
+ * does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh
12
+ * with `{ forceRefresh: true }` input.
13
+ *
14
+ * @param options - Options configuring the fetch behavior.
15
+ * @throws {@link AuthError} - Throws error when session information cannot be refreshed.
16
+ * @returns Promise<AuthSession>
17
+ */
9
18
  export const fetchAuthSession = (
10
19
  options?: FetchAuthSessionOptions,
11
20
  ): Promise<AuthSession> => {
@@ -5,6 +5,7 @@ export enum AmplifyErrorCode {
5
5
  NoEndpointId = 'NoEndpointId',
6
6
  PlatformNotSupported = 'PlatformNotSupported',
7
7
  Unknown = 'Unknown',
8
+ NetworkError = 'NetworkError',
8
9
  }
9
10
 
10
11
  export interface AmplifyErrorParams<ErrorCode extends string = string> {