@aws-amplify/core 6.10.6-unstable.cde36a7.0 → 6.10.7-unstable.b188564.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/cjs/BackgroundProcessManager/BackgroundProcessManager.js +1 -0
  2. package/dist/cjs/BackgroundProcessManager/BackgroundProcessManager.js.map +1 -1
  3. package/dist/cjs/Logger/ConsoleLogger.js +1 -0
  4. package/dist/cjs/Logger/ConsoleLogger.js.map +1 -1
  5. package/dist/cjs/Platform/version.js +1 -1
  6. package/dist/cjs/Platform/version.js.map +1 -1
  7. package/dist/cjs/awsClients/pinpoint/getInAppMessages.js +1 -1
  8. package/dist/cjs/awsClients/pinpoint/getInAppMessages.js.map +1 -1
  9. package/dist/cjs/awsClients/pinpoint/putEvents.js +1 -1
  10. package/dist/cjs/awsClients/pinpoint/putEvents.js.map +1 -1
  11. package/dist/cjs/awsClients/pinpoint/updateEndpoint.js +1 -1
  12. package/dist/cjs/awsClients/pinpoint/updateEndpoint.js.map +1 -1
  13. package/dist/cjs/clients/handlers/{authenticated.js → aws/authenticated.js} +9 -7
  14. package/dist/cjs/clients/handlers/aws/authenticated.js.map +1 -0
  15. package/dist/cjs/clients/handlers/aws/unauthenticated.js +17 -0
  16. package/dist/cjs/clients/handlers/aws/unauthenticated.js.map +1 -0
  17. package/dist/cjs/clients/index.js +5 -3
  18. package/dist/cjs/clients/index.js.map +1 -1
  19. package/dist/cjs/clients/middleware/retry/amzSdkInvocationIdHeaderMiddleware.js +28 -0
  20. package/dist/cjs/clients/middleware/retry/amzSdkInvocationIdHeaderMiddleware.js.map +1 -0
  21. package/dist/cjs/clients/middleware/retry/amzSdkRequestHeaderMiddleware.js +27 -0
  22. package/dist/cjs/clients/middleware/retry/amzSdkRequestHeaderMiddleware.js.map +1 -0
  23. package/dist/cjs/clients/middleware/retry/constants.js +11 -0
  24. package/dist/cjs/clients/middleware/retry/constants.js.map +1 -0
  25. package/dist/cjs/clients/middleware/retry/index.js +7 -3
  26. package/dist/cjs/clients/middleware/retry/index.js.map +1 -1
  27. package/dist/cjs/clients/middleware/retry/jitteredBackoff.js +3 -3
  28. package/dist/cjs/clients/middleware/retry/jitteredBackoff.js.map +1 -1
  29. package/dist/cjs/clients/middleware/retry/{middleware.js → retryMiddleware.js} +4 -6
  30. package/dist/cjs/clients/middleware/retry/retryMiddleware.js.map +1 -0
  31. package/dist/cjs/clients/types/aws.js +0 -2
  32. package/dist/cjs/clients/types/aws.js.map +1 -1
  33. package/dist/cjs/errors/AmplifyError.js +6 -3
  34. package/dist/cjs/errors/AmplifyError.js.map +1 -1
  35. package/dist/cjs/types/errors.js +0 -2
  36. package/dist/cjs/types/errors.js.map +1 -1
  37. package/dist/esm/BackgroundProcessManager/BackgroundProcessManager.mjs +1 -0
  38. package/dist/esm/BackgroundProcessManager/BackgroundProcessManager.mjs.map +1 -1
  39. package/dist/esm/Logger/ConsoleLogger.mjs +1 -0
  40. package/dist/esm/Logger/ConsoleLogger.mjs.map +1 -1
  41. package/dist/esm/Platform/version.d.ts +1 -1
  42. package/dist/esm/Platform/version.mjs +1 -1
  43. package/dist/esm/Platform/version.mjs.map +1 -1
  44. package/dist/esm/ServiceWorker/ServiceWorker.mjs +9 -1
  45. package/dist/esm/ServiceWorker/ServiceWorker.mjs.map +1 -1
  46. package/dist/esm/awsClients/cognitoIdentity/base.d.ts +1 -1
  47. package/dist/esm/awsClients/cognitoIdentity/base.mjs +13 -3
  48. package/dist/esm/awsClients/cognitoIdentity/base.mjs.map +1 -1
  49. package/dist/esm/awsClients/cognitoIdentity/getCredentialsForIdentity.mjs +9 -0
  50. package/dist/esm/awsClients/cognitoIdentity/getCredentialsForIdentity.mjs.map +1 -1
  51. package/dist/esm/awsClients/cognitoIdentity/getId.mjs +9 -0
  52. package/dist/esm/awsClients/cognitoIdentity/getId.mjs.map +1 -1
  53. package/dist/esm/awsClients/pinpoint/base.mjs +16 -2
  54. package/dist/esm/awsClients/pinpoint/base.mjs.map +1 -1
  55. package/dist/esm/awsClients/pinpoint/getInAppMessages.d.ts +3 -3
  56. package/dist/esm/awsClients/pinpoint/getInAppMessages.mjs +1 -1
  57. package/dist/esm/awsClients/pinpoint/getInAppMessages.mjs.map +1 -1
  58. package/dist/esm/awsClients/pinpoint/putEvents.d.ts +3 -3
  59. package/dist/esm/awsClients/pinpoint/putEvents.mjs +1 -1
  60. package/dist/esm/awsClients/pinpoint/putEvents.mjs.map +1 -1
  61. package/dist/esm/awsClients/pinpoint/updateEndpoint.d.ts +3 -3
  62. package/dist/esm/awsClients/pinpoint/updateEndpoint.mjs +1 -1
  63. package/dist/esm/awsClients/pinpoint/updateEndpoint.mjs.map +1 -1
  64. package/dist/esm/clients/handlers/aws/authenticated.d.ts +5 -0
  65. package/dist/esm/clients/handlers/aws/authenticated.mjs +24 -0
  66. package/dist/esm/clients/handlers/aws/authenticated.mjs.map +1 -0
  67. package/dist/esm/clients/handlers/aws/unauthenticated.d.ts +4 -0
  68. package/dist/esm/clients/handlers/aws/unauthenticated.mjs +22 -0
  69. package/dist/esm/clients/handlers/aws/unauthenticated.mjs.map +1 -0
  70. package/dist/esm/clients/index.d.ts +4 -4
  71. package/dist/esm/clients/index.mjs +5 -3
  72. package/dist/esm/clients/index.mjs.map +1 -1
  73. package/dist/esm/clients/middleware/retry/amzSdkInvocationIdHeaderMiddleware.d.ts +12 -0
  74. package/dist/esm/clients/middleware/retry/amzSdkInvocationIdHeaderMiddleware.mjs +40 -0
  75. package/dist/esm/clients/middleware/retry/amzSdkInvocationIdHeaderMiddleware.mjs.map +1 -0
  76. package/dist/esm/clients/middleware/retry/amzSdkRequestHeaderMiddleware.d.ts +14 -0
  77. package/dist/esm/clients/middleware/retry/amzSdkRequestHeaderMiddleware.mjs +25 -0
  78. package/dist/esm/clients/middleware/retry/amzSdkRequestHeaderMiddleware.mjs.map +1 -0
  79. package/dist/esm/clients/middleware/retry/constants.d.ts +4 -0
  80. package/dist/esm/clients/middleware/retry/constants.mjs +9 -0
  81. package/dist/esm/clients/middleware/retry/constants.mjs.map +1 -0
  82. package/dist/esm/clients/middleware/retry/index.d.ts +3 -1
  83. package/dist/esm/clients/middleware/retry/index.mjs +3 -1
  84. package/dist/esm/clients/middleware/retry/index.mjs.map +1 -1
  85. package/dist/esm/clients/middleware/retry/jitteredBackoff.d.ts +1 -1
  86. package/dist/esm/clients/middleware/retry/jitteredBackoff.mjs +1 -1
  87. package/dist/esm/clients/middleware/retry/jitteredBackoff.mjs.map +1 -1
  88. package/dist/esm/clients/middleware/retry/{middleware.d.ts → retryMiddleware.d.ts} +4 -4
  89. package/dist/esm/clients/middleware/retry/{middleware.mjs → retryMiddleware.mjs} +4 -5
  90. package/dist/esm/clients/middleware/retry/retryMiddleware.mjs.map +1 -0
  91. package/dist/esm/clients/types/aws.d.ts +1 -1
  92. package/dist/esm/errors/AmplifyError.d.ts +8 -4
  93. package/dist/esm/errors/AmplifyError.mjs +6 -3
  94. package/dist/esm/errors/AmplifyError.mjs.map +1 -1
  95. package/dist/esm/providers/pinpoint/apis/updateEndpoint.mjs +9 -1
  96. package/dist/esm/providers/pinpoint/apis/updateEndpoint.mjs.map +1 -1
  97. package/dist/esm/providers/pinpoint/utils/PinpointEventBuffer.mjs +9 -0
  98. package/dist/esm/providers/pinpoint/utils/PinpointEventBuffer.mjs.map +1 -1
  99. package/dist/esm/singleton/Auth/types.d.ts +1 -1
  100. package/dist/esm/types/errors.d.ts +7 -6
  101. package/dist/esm/types/errors.mjs +0 -2
  102. package/dist/esm/types/errors.mjs.map +1 -1
  103. package/package.json +8 -8
  104. package/src/BackgroundProcessManager/BackgroundProcessManager.ts +1 -0
  105. package/src/Logger/ConsoleLogger.ts +1 -0
  106. package/src/Platform/version.ts +1 -1
  107. package/src/awsClients/pinpoint/getInAppMessages.ts +1 -1
  108. package/src/awsClients/pinpoint/putEvents.ts +1 -1
  109. package/src/awsClients/pinpoint/updateEndpoint.ts +1 -1
  110. package/src/clients/handlers/aws/authenticated.ts +39 -0
  111. package/src/clients/handlers/aws/unauthenticated.ts +34 -0
  112. package/src/clients/index.ts +7 -4
  113. package/src/clients/middleware/retry/amzSdkInvocationIdHeaderMiddleware.ts +31 -0
  114. package/src/clients/middleware/retry/amzSdkRequestHeaderMiddleware.ts +38 -0
  115. package/src/clients/middleware/retry/constants.ts +10 -0
  116. package/src/clients/middleware/retry/index.ts +6 -1
  117. package/src/clients/middleware/retry/jitteredBackoff.ts +2 -3
  118. package/src/clients/middleware/retry/{middleware.ts → retryMiddleware.ts} +10 -9
  119. package/src/clients/types/aws.ts +1 -5
  120. package/src/errors/AmplifyError.ts +13 -4
  121. package/src/singleton/Auth/types.ts +1 -5
  122. package/src/types/errors.ts +12 -4
  123. package/dist/cjs/clients/handlers/authenticated.js.map +0 -1
  124. package/dist/cjs/clients/handlers/unauthenticated.js +0 -12
  125. package/dist/cjs/clients/handlers/unauthenticated.js.map +0 -1
  126. package/dist/cjs/clients/middleware/retry/middleware.js.map +0 -1
  127. package/dist/esm/clients/handlers/authenticated.d.ts +0 -5
  128. package/dist/esm/clients/handlers/authenticated.mjs +0 -20
  129. package/dist/esm/clients/handlers/authenticated.mjs.map +0 -1
  130. package/dist/esm/clients/handlers/unauthenticated.d.ts +0 -4
  131. package/dist/esm/clients/handlers/unauthenticated.mjs +0 -15
  132. package/dist/esm/clients/handlers/unauthenticated.mjs.map +0 -1
  133. package/dist/esm/clients/middleware/retry/middleware.mjs.map +0 -1
  134. package/src/clients/handlers/authenticated.ts +0 -27
  135. package/src/clients/handlers/unauthenticated.ts +0 -19
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retryMiddleware.js","sources":["../../../../../src/clients/middleware/retry/retryMiddleware.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.retryMiddlewareFactory = void 0;\nconst constants_1 = require(\"./constants\");\n/**\n * Middleware that executes the retry logic.\n */\nconst retryMiddlewareFactory = ({ maxAttempts = constants_1.DEFAULT_RETRY_ATTEMPTS, retryDecider, computeDelay, abortSignal, }) => {\n if (maxAttempts < 1) {\n throw new Error('maxAttempts must be greater than 0');\n }\n return (next, context) => async function retryMiddleware(request) {\n let error;\n let attemptsCount = context.attemptsCount ?? 0;\n let response;\n // When retry is not needed or max attempts is reached, either error or response will be set. This function handles either cases.\n const handleTerminalErrorOrResponse = () => {\n if (response) {\n addOrIncrementMetadataAttempts(response, attemptsCount);\n return response;\n }\n else {\n addOrIncrementMetadataAttempts(error, attemptsCount);\n throw error;\n }\n };\n while (!abortSignal?.aborted && attemptsCount < maxAttempts) {\n try {\n response = await next(request);\n error = undefined;\n }\n catch (e) {\n error = e;\n response = undefined;\n }\n // context.attemptsCount may be updated after calling next handler which may retry the request by itself.\n attemptsCount =\n (context.attemptsCount ?? 0) > attemptsCount\n ? (context.attemptsCount ?? 0)\n : attemptsCount + 1;\n context.attemptsCount = attemptsCount;\n const { isCredentialsExpiredError, retryable } = await retryDecider(response, error, context);\n if (retryable) {\n // Setting isCredentialsInvalid flag to notify signing middleware to forceRefresh credentials provider.\n context.isCredentialsExpired = !!isCredentialsExpiredError;\n if (!abortSignal?.aborted && attemptsCount < maxAttempts) {\n // prevent sleep for last attempt or cancelled request;\n const delay = computeDelay(attemptsCount);\n await cancellableSleep(delay, abortSignal);\n }\n continue;\n }\n else {\n return handleTerminalErrorOrResponse();\n }\n }\n if (abortSignal?.aborted) {\n throw new Error('Request aborted.');\n }\n else {\n return handleTerminalErrorOrResponse();\n }\n };\n};\nexports.retryMiddlewareFactory = retryMiddlewareFactory;\nconst cancellableSleep = (timeoutMs, abortSignal) => {\n if (abortSignal?.aborted) {\n return Promise.resolve();\n }\n let timeoutId;\n let sleepPromiseResolveFn;\n const sleepPromise = new Promise(resolve => {\n sleepPromiseResolveFn = resolve;\n timeoutId = setTimeout(resolve, timeoutMs);\n });\n abortSignal?.addEventListener('abort', function cancelSleep(_) {\n clearTimeout(timeoutId);\n abortSignal?.removeEventListener('abort', cancelSleep);\n sleepPromiseResolveFn();\n });\n return sleepPromise;\n};\nconst addOrIncrementMetadataAttempts = (nextHandlerOutput, attempts) => {\n if (Object.prototype.toString.call(nextHandlerOutput) !== '[object Object]') {\n return;\n }\n nextHandlerOutput.$metadata = {\n ...(nextHandlerOutput.$metadata ?? {}),\n attempts,\n };\n};\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,sBAAsB,GAAG,MAAM;AACvC,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;AAC1C;AACA;AACA;AACA,MAAM,sBAAsB,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC,sBAAsB,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,GAAG,KAAK;AACnI,IAAI,IAAI,WAAW,GAAG,CAAC,EAAE;AACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC;AAC7D;AACA,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,KAAK,eAAe,eAAe,CAAC,OAAO,EAAE;AACtE,QAAQ,IAAI,KAAK;AACjB,QAAQ,IAAI,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,CAAC;AACtD,QAAQ,IAAI,QAAQ;AACpB;AACA,QAAQ,MAAM,6BAA6B,GAAG,MAAM;AACpD,YAAY,IAAI,QAAQ,EAAE;AAC1B,gBAAgB,8BAA8B,CAAC,QAAQ,EAAE,aAAa,CAAC;AACvE,gBAAgB,OAAO,QAAQ;AAC/B;AACA,iBAAiB;AACjB,gBAAgB,8BAA8B,CAAC,KAAK,EAAE,aAAa,CAAC;AACpE,gBAAgB,MAAM,KAAK;AAC3B;AACA,SAAS;AACT,QAAQ,OAAO,CAAC,WAAW,EAAE,OAAO,IAAI,aAAa,GAAG,WAAW,EAAE;AACrE,YAAY,IAAI;AAChB,gBAAgB,QAAQ,GAAG,MAAM,IAA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S;AACjB,IAAI,IAAI,qBAAqB;AAC7B,IAAI,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,IAAI;AAChD,QAAQ,qBAAqB,GAAG,OAAO;AACvC,QAAQ,SAAS,GAAG,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC;AAClD,KAAK,CAAC;AACN,IAAI,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,SAAS,WAAW,CAAC,CAAC,EAAE;AACnE,QAAQ,YAAY,CAAC,SAAS,CAAC;AAC/B,QAAQ,WAAW,EAAE,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC;AAC9D,QAAQ,qBAAqB,EAAE;AAC/B,KAAK,CAAC;AACN,IAAI,OAAO,YAAY;AACvB,CAAC;AACD,MAAM,8BAA8B,GAAG,CAAC,iBAAiB,EAAE,QAAQ,KAAK;AACxE,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,iBAAiB,EAAE;AACjF,QAAQ;AACR;AACA,IAAI,iBAAiB,CAAC,SAAS,GAAG;AAClC,QAAQ,IAAI,iBAAiB,CAAC,SAAS,IAAI,EAAE,CAAC;AAC9C,QAAQ,QAAQ;AAChB,KAAK;AACL,CAAC;;"}
@@ -1,6 +1,4 @@
1
1
  'use strict';
2
2
 
3
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
- // SPDX-License-Identifier: Apache-2.0
5
3
  Object.defineProperty(exports, "__esModule", { value: true });
6
4
  //# sourceMappingURL=aws.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aws.js","sources":["../../../../src/clients/types/aws.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 });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
1
+ {"version":3,"file":"aws.js","sources":["../../../../src/clients/types/aws.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
- // SPDX-License-Identifier: Apache-2.0
5
3
  Object.defineProperty(exports, "__esModule", { value: true });
6
4
  exports.AmplifyError = void 0;
7
5
  class AmplifyError extends Error {
@@ -13,11 +11,16 @@ class AmplifyError extends Error {
13
11
  * @param recoverySuggestion suggestion to recover from the error.
14
12
  *
15
13
  */
16
- constructor({ message, name, recoverySuggestion, underlyingError, }) {
14
+ constructor({ message, name, recoverySuggestion, underlyingError, metadata, }) {
17
15
  super(message);
18
16
  this.name = name;
19
17
  this.underlyingError = underlyingError;
20
18
  this.recoverySuggestion = recoverySuggestion;
19
+ if (metadata) {
20
+ // If metadata exists, explicitly only record the following properties.
21
+ const { extendedRequestId, httpStatusCode, requestId } = metadata;
22
+ this.metadata = { extendedRequestId, httpStatusCode, requestId };
23
+ }
21
24
  // Hack for making the custom error class work when transpiled to es5
22
25
  // TODO: Delete the following 2 lines after we change the build target to >= es2015
23
26
  this.constructor = AmplifyError;
@@ -1 +1 @@
1
- {"version":3,"file":"AmplifyError.js","sources":["../../../src/errors/AmplifyError.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.AmplifyError = void 0;\nclass AmplifyError extends Error {\n /**\n * Constructs an AmplifyError.\n *\n * @param message text that describes the main problem.\n * @param underlyingError the underlying cause of the error.\n * @param recoverySuggestion suggestion to recover from the error.\n *\n */\n constructor({ message, name, recoverySuggestion, underlyingError, }) {\n super(message);\n this.name = name;\n this.underlyingError = underlyingError;\n this.recoverySuggestion = recoverySuggestion;\n // Hack for making the custom error class work when transpiled to es5\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = AmplifyError;\n Object.setPrototypeOf(this, AmplifyError.prototype);\n }\n}\nexports.AmplifyError = AmplifyError;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,YAAY,GAAG,MAAM;AAC7B,MAAM,YAAY,SAAS,KAAK,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,eAAe,GAAG,EAAE;AACzE,QAAQ,KAAK,CAAC,OAAO,CAAC;AACtB,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI;AACxB,QAAQ,IAAI,CAAC,eAAe,GAAG,eAAe;AAC9C,QAAQ,IAAI,CAAC,kBAAkB,GAAG,kBAAkB;AACpD;AACA;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,YAAY;AACvC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC;AAC3D;AACA;AACA,OAAO,CAAC,YAAY,GAAG,YAAY;;"}
1
+ {"version":3,"file":"AmplifyError.js","sources":["../../../src/errors/AmplifyError.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AmplifyError = void 0;\nclass AmplifyError extends Error {\n /**\n * Constructs an AmplifyError.\n *\n * @param message text that describes the main problem.\n * @param underlyingError the underlying cause of the error.\n * @param recoverySuggestion suggestion to recover from the error.\n *\n */\n constructor({ message, name, recoverySuggestion, underlyingError, metadata, }) {\n super(message);\n this.name = name;\n this.underlyingError = underlyingError;\n this.recoverySuggestion = recoverySuggestion;\n if (metadata) {\n // If metadata exists, explicitly only record the following properties.\n const { extendedRequestId, httpStatusCode, requestId } = metadata;\n this.metadata = { extendedRequestId, httpStatusCode, requestId };\n }\n // Hack for making the custom error class work when transpiled to es5\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = AmplifyError;\n Object.setPrototypeOf(this, AmplifyError.prototype);\n }\n}\nexports.AmplifyError = AmplifyError;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,YAAY,GAAG,MAAM;AAC7B,MAAM,YAAY,SAAS,KAAK,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,eAAe,EAAE,QAAQ,GAAG,EAAE;AACnF,QAAQ,KAAK,CAAC,OAAO,CAAC;AACtB,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI;AACxB,QAAQ,IAAI,CAAC,eAAe,GAAG,eAAe;AAC9C,QAAQ,IAAI,CAAC,kBAAkB,GAAG,kBAAkB;AACpD,QAAQ,IAAI,QAAQ,EAAE;AACtB;AACA,YAAY,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,QAAQ;AAC7E,YAAY,IAAI,CAAC,QAAQ,GAAG,EAAE,iBAAiB,EAAE,cAAc,EAAE,SAAS,EAAE;AAC5E;AACA;AACA;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,YAAY;AACvC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC;AAC3D;AACA;AACA,OAAO,CAAC,YAAY,GAAG,YAAY;;"}
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
- // SPDX-License-Identifier: Apache-2.0
5
3
  Object.defineProperty(exports, "__esModule", { value: true });
6
4
  exports.AmplifyErrorCode = void 0;
7
5
  (function (AmplifyErrorCode) {
@@ -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[\"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;AAC7D,OAAO,CAAC,gBAAgB,GAAG,MAAM;AAEjC,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,cAAc;AACrD,IAAI,gBAAgB,CAAC,sBAAsB,CAAC,GAAG,sBAAsB;AACrE,IAAI,gBAAgB,CAAC,SAAS,CAAC,GAAG,SAAS;AAC3C,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,cAAc;AACrD,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\";\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,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,gBAAgB,GAAG,MAAM;AAEjC,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,cAAc;AACrD,IAAI,gBAAgB,CAAC,sBAAsB,CAAC,GAAG,sBAAsB;AACrE,IAAI,gBAAgB,CAAC,SAAS,CAAC,GAAG,SAAS;AAC3C,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,cAAc;AACrD,CAAC,EAAqB,OAAO,CAAC,gBAAgB,KAAK,OAAO,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC;;"}
@@ -248,6 +248,7 @@ class BackgroundProcessManager {
248
248
  // Due to potential races with a job's natural completion, it's
249
249
  // reasonable to expect the termination call to fail. Hence,
250
250
  // not logging as an error.
251
+ // eslint-disable-next-line no-console
251
252
  console.warn(`Failed to send termination signal to job. Error: ${error.message}`, job);
252
253
  }
253
254
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BackgroundProcessManager.mjs","sources":["../../../src/BackgroundProcessManager/BackgroundProcessManager.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BackgroundManagerNotOpenError } from './BackgroundManagerNotOpenError';\nimport { BackgroundProcessManagerState } from './types';\n/**\n * @private For internal Amplify use.\n *\n * Creates a new scope for promises, observables, and other types of work or\n * processes that may be running in the background. This manager provides\n * an singular entrypoint to request termination and await completion.\n *\n * As work completes on its own prior to close, the manager removes them\n * from the registry to avoid holding references to completed jobs.\n */\nexport class BackgroundProcessManager {\n constructor() {\n /**\n * A string indicating whether the manager is accepting new work (\"Open\"),\n * waiting for work to complete (\"Closing\"), or fully done with all\n * submitted work and *not* accepting new jobs (\"Closed\").\n */\n this._state = BackgroundProcessManagerState.Open;\n /**\n * The list of outstanding jobs we'll need to wait for upon `close()`\n */\n this.jobs = new Set();\n }\n add(jobOrDescription, optionalDescription) {\n let job;\n let description;\n if (typeof jobOrDescription === 'string') {\n job = undefined;\n description = jobOrDescription;\n }\n else {\n job = jobOrDescription;\n description = optionalDescription;\n }\n const error = this.closedFailure(description);\n if (error)\n return error;\n if (job === undefined) {\n return this.addHook(description);\n }\n else if (typeof job === 'function') {\n return this.addFunction(job, description);\n }\n else if (job instanceof BackgroundProcessManager) {\n this.addManager(job, description);\n }\n else {\n throw new Error('If `job` is provided, it must be an Observable, Function, or BackgroundProcessManager.');\n }\n }\n /**\n * Adds a **cleaner** function that doesn't immediately get executed.\n * Instead, the caller gets a **terminate** function back. The *cleaner* is\n * invoked only once the mananger *closes* or the returned **terminate**\n * function is called.\n *\n * @param clean The cleanup function.\n * @param description Optional description to help identify pending jobs.\n * @returns A terminate function.\n */\n addCleaner(clean, description) {\n const { resolve, onTerminate } = this.addHook(description);\n const proxy = async () => {\n await clean();\n resolve();\n };\n onTerminate.then(proxy);\n return proxy;\n }\n addFunction(job, description) {\n // the function we call when we want to try to terminate this job.\n let terminate;\n // the promise the job can opt into listening to for termination.\n const onTerminate = new Promise(resolve => {\n terminate = resolve;\n });\n // finally! start the job.\n const jobResult = job(onTerminate);\n // depending on what the job gives back, register the result\n // so we can monitor for completion.\n if (typeof jobResult?.then === 'function') {\n this.registerPromise(jobResult, terminate, description);\n }\n // At the end of the day, or you know, method call, it doesn't matter\n // what the return value is at all; we just pass it through to the\n // caller.\n return jobResult;\n }\n addManager(manager, description) {\n this.addCleaner(async () => manager.close(), description);\n }\n /**\n * Creates and registers a fabricated job for processes that need to operate\n * with callbacks/hooks. The returned `resolve` and `reject`\n * functions can be used to signal the job is done successfully or not.\n * The returned `onTerminate` is a promise that will resolve when the\n * manager is requesting the termination of the job.\n *\n * @param description Optional description to help identify pending jobs.\n * @returns `{ resolve, reject, onTerminate }`\n */\n addHook(description) {\n // the resolve/reject functions we'll provide to the caller to signal\n // the state of the job.\n let promiseResolve;\n let promiseReject;\n // the underlying promise we'll use to manage it, pretty much like\n // any other promise.\n const promise = new Promise((resolve, reject) => {\n promiseResolve = resolve;\n promiseReject = reject;\n });\n // the function we call when we want to try to terminate this job.\n let terminate;\n // the promise the job can opt into listening to for termination.\n const onTerminate = new Promise(resolve => {\n terminate = resolve;\n });\n this.registerPromise(promise, terminate, description);\n return {\n resolve: promiseResolve,\n reject: promiseReject,\n onTerminate,\n };\n }\n /**\n * Adds a Promise based job to the list of jobs for monitoring and listens\n * for either a success or failure, upon which the job is considered \"done\"\n * and removed from the registry.\n *\n * @param promise A promise that is on its way to being returned to a\n * caller, which needs to be tracked as a background job.\n * @param terminate The termination function to register, which can be\n * invoked to request the job stop.\n * @param description Optional description to help identify pending jobs.\n */\n registerPromise(promise, terminate, description) {\n const jobEntry = { promise, terminate, description };\n this.jobs.add(jobEntry);\n // in all of my testing, it is safe to multi-subscribe to a promise.\n // so, rather than create another layer of promising, we're just going\n // to hook into the promise we already have, and when it's done\n // (successfully or not), we no longer need to wait for it upon close.\n //\n // sorry this is a bit hand-wavy:\n //\n // i believe we use `.then` and `.catch` instead of `.finally` because\n // `.finally` is invoked in a different order in the sequence, and this\n // breaks assumptions throughout and causes failures.\n promise\n .then(() => {\n this.jobs.delete(jobEntry);\n })\n .catch(() => {\n this.jobs.delete(jobEntry);\n });\n }\n /**\n * The number of jobs being waited on.\n *\n * We don't use this for anything. It's just informational for the caller,\n * and can be used in logging and testing.\n *\n * @returns the number of jobs.\n */\n get length() {\n return this.jobs.size;\n }\n /**\n * The execution state of the manager. One of:\n *\n * 1. \"Open\" -> Accepting new jobs\n * 1. \"Closing\" -> Not accepting new work. Waiting for jobs to complete.\n * 1. \"Closed\" -> Not accepting new work. All submitted jobs are complete.\n */\n get state() {\n return this._state;\n }\n /**\n * The registered `description` of all still-pending jobs.\n *\n * @returns descriptions as an array.\n */\n get pending() {\n return Array.from(this.jobs).map(job => job.description);\n }\n /**\n * Whether the manager is accepting new jobs.\n */\n get isOpen() {\n return this._state === BackgroundProcessManagerState.Open;\n }\n /**\n * Whether the manager is rejecting new work, but still waiting for\n * submitted work to complete.\n */\n get isClosing() {\n return this._state === BackgroundProcessManagerState.Closing;\n }\n /**\n * Whether the manager is rejecting work and done waiting for submitted\n * work to complete.\n */\n get isClosed() {\n return this._state === BackgroundProcessManagerState.Closed;\n }\n closedFailure(description) {\n if (!this.isOpen) {\n return Promise.reject(new BackgroundManagerNotOpenError([\n `The manager is ${this.state}.`,\n `You tried to add \"${description}\".`,\n `Pending jobs: [\\n${this.pending\n .map(t => ' ' + t)\n .join(',\\n')}\\n]`,\n ].join('\\n')));\n }\n }\n /**\n * Signals jobs to stop (for those that accept interruptions) and waits\n * for confirmation that jobs have stopped.\n *\n * This immediately puts the manager into a closing state and just begins\n * to reject new work. After all work in the manager is complete, the\n * manager goes into a `Completed` state and `close()` returns.\n *\n * This call is idempotent.\n *\n * If the manager is already closing or closed, `finalCleaup` is not executed.\n *\n * @param onClosed\n * @returns The settled results of each still-running job's promise. If the\n * manager is already closed, this will contain the results as of when the\n * manager's `close()` was called in an `Open` state.\n */\n async close() {\n if (this.isOpen) {\n this._state = BackgroundProcessManagerState.Closing;\n for (const job of Array.from(this.jobs)) {\n try {\n job.terminate();\n }\n catch (error) {\n // Due to potential races with a job's natural completion, it's\n // reasonable to expect the termination call to fail. Hence,\n // not logging as an error.\n console.warn(`Failed to send termination signal to job. Error: ${error.message}`, job);\n }\n }\n // Use `allSettled()` because we want to wait for all to finish. We do\n // not want to stop waiting if there is a failure.\n this._closingPromise = Promise.allSettled(Array.from(this.jobs).map(j => j.promise));\n await this._closingPromise;\n this._state = BackgroundProcessManagerState.Closed;\n }\n return this._closingPromise;\n }\n /**\n * Signals the manager to start accepting work (again) and returns once\n * the manager is ready to do so.\n *\n * If the state is already `Open`, this call is a no-op.\n *\n * If the state is `Closed`, this call simply updates state and returns.\n *\n * If the state is `Closing`, this call waits for completion before it\n * updates the state and returns.\n */\n async open() {\n if (this.isClosing) {\n await this.close();\n }\n this._state = BackgroundProcessManagerState.Open;\n }\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,wBAAwB,CAAC;AACtC,IAAI,WAAW,GAAG;AAClB;AACA;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,MAAM,GAAG,6BAA6B,CAAC,IAAI;AACxD;AACA;AACA;AACA,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,EAAE;AAC7B;AACA,IAAI,GAAG,CAAC,gBAAgB,EAAE,mBAAmB,EAAE;AAC/C,QAAQ,IAAI,GAAG;AACf,QAAQ,IAAI,WAAW;AACvB,QAAQ,IAAI,OAAO,gBAAgB,KAAK,QAAQ,EAAE;AAClD,YAAY,GAAG,GAAG,SAAS;AAC3B,YAAY,WAAW,GAAG,gBAAgB;AAC1C;AACA,aAAa;AACb,YAAY,GAAG,GAAG,gBAAgB;AAClC,YAAY,WAAW,GAAG,mBAAmB;AAC7C;AACA,QAAQ,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;AACrD,QAAQ,IAAI,KAAK;AACjB,YAAY,OAAO,KAAK;AACxB,QAAQ,IAAI,GAAG,KAAK,SAAS,EAAE;AAC/B,YAAY,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;AAC5C;AACA,aAAa,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;AAC5C,YAAY,OAAO,IAAI,CAAC,WAAW,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,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE;AACzB,YAAY,IAAI,CAAC,MAAM,GAAG,6BAA6B,CAAC,OAAO;AAC/D,YAAY,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AACrD,gBAAgB,IAAI;AACpB,oBAAoB,GAAG,CAAC,SAAS,EAAE;AACnC;AACA,gBAAgB,OAAO,KAAK,EAAE;AAC9B;AACA;AACA;AACA,oBAAoB,OAAO,CAAC,IAAI,CAAC,CAAC,iDAAiD,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC;AAC1G;AACA;AACA;AACA;AACA,YAAY,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC;AAChG,YAAY,MAAM,IAAI,CAAC,eAAe;AACtC,YAAY,IAAI,CAAC,MAAM,GAAG,6BAA6B,CAAC,MAAM;AAC9D;AACA,QAAQ,OAAO,IAAI,CAAC,eAAe;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;AAC5B,YAAY,MAAM,IAAI,CAAC,KAAK,EAAE;AAC9B;AACA,QAAQ,IAAI,CAAC,MAAM,GAAG,6BAA6B,CAAC,IAAI;AACxD;AACA;;;;"}
1
+ {"version":3,"file":"BackgroundProcessManager.mjs","sources":["../../../src/BackgroundProcessManager/BackgroundProcessManager.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BackgroundManagerNotOpenError } from './BackgroundManagerNotOpenError';\nimport { BackgroundProcessManagerState } from './types';\n/**\n * @private For internal Amplify use.\n *\n * Creates a new scope for promises, observables, and other types of work or\n * processes that may be running in the background. This manager provides\n * an singular entrypoint to request termination and await completion.\n *\n * As work completes on its own prior to close, the manager removes them\n * from the registry to avoid holding references to completed jobs.\n */\nexport class BackgroundProcessManager {\n constructor() {\n /**\n * A string indicating whether the manager is accepting new work (\"Open\"),\n * waiting for work to complete (\"Closing\"), or fully done with all\n * submitted work and *not* accepting new jobs (\"Closed\").\n */\n this._state = BackgroundProcessManagerState.Open;\n /**\n * The list of outstanding jobs we'll need to wait for upon `close()`\n */\n this.jobs = new Set();\n }\n add(jobOrDescription, optionalDescription) {\n let job;\n let description;\n if (typeof jobOrDescription === 'string') {\n job = undefined;\n description = jobOrDescription;\n }\n else {\n job = jobOrDescription;\n description = optionalDescription;\n }\n const error = this.closedFailure(description);\n if (error)\n return error;\n if (job === undefined) {\n return this.addHook(description);\n }\n else if (typeof job === 'function') {\n return this.addFunction(job, description);\n }\n else if (job instanceof BackgroundProcessManager) {\n this.addManager(job, description);\n }\n else {\n throw new Error('If `job` is provided, it must be an Observable, Function, or BackgroundProcessManager.');\n }\n }\n /**\n * Adds a **cleaner** function that doesn't immediately get executed.\n * Instead, the caller gets a **terminate** function back. The *cleaner* is\n * invoked only once the mananger *closes* or the returned **terminate**\n * function is called.\n *\n * @param clean The cleanup function.\n * @param description Optional description to help identify pending jobs.\n * @returns A terminate function.\n */\n addCleaner(clean, description) {\n const { resolve, onTerminate } = this.addHook(description);\n const proxy = async () => {\n await clean();\n resolve();\n };\n onTerminate.then(proxy);\n return proxy;\n }\n addFunction(job, description) {\n // the function we call when we want to try to terminate this job.\n let terminate;\n // the promise the job can opt into listening to for termination.\n const onTerminate = new Promise(resolve => {\n terminate = resolve;\n });\n // finally! start the job.\n const jobResult = job(onTerminate);\n // depending on what the job gives back, register the result\n // so we can monitor for completion.\n if (typeof jobResult?.then === 'function') {\n this.registerPromise(jobResult, terminate, description);\n }\n // At the end of the day, or you know, method call, it doesn't matter\n // what the return value is at all; we just pass it through to the\n // caller.\n return jobResult;\n }\n addManager(manager, description) {\n this.addCleaner(async () => manager.close(), description);\n }\n /**\n * Creates and registers a fabricated job for processes that need to operate\n * with callbacks/hooks. The returned `resolve` and `reject`\n * functions can be used to signal the job is done successfully or not.\n * The returned `onTerminate` is a promise that will resolve when the\n * manager is requesting the termination of the job.\n *\n * @param description Optional description to help identify pending jobs.\n * @returns `{ resolve, reject, onTerminate }`\n */\n addHook(description) {\n // the resolve/reject functions we'll provide to the caller to signal\n // the state of the job.\n let promiseResolve;\n let promiseReject;\n // the underlying promise we'll use to manage it, pretty much like\n // any other promise.\n const promise = new Promise((resolve, reject) => {\n promiseResolve = resolve;\n promiseReject = reject;\n });\n // the function we call when we want to try to terminate this job.\n let terminate;\n // the promise the job can opt into listening to for termination.\n const onTerminate = new Promise(resolve => {\n terminate = resolve;\n });\n this.registerPromise(promise, terminate, description);\n return {\n resolve: promiseResolve,\n reject: promiseReject,\n onTerminate,\n };\n }\n /**\n * Adds a Promise based job to the list of jobs for monitoring and listens\n * for either a success or failure, upon which the job is considered \"done\"\n * and removed from the registry.\n *\n * @param promise A promise that is on its way to being returned to a\n * caller, which needs to be tracked as a background job.\n * @param terminate The termination function to register, which can be\n * invoked to request the job stop.\n * @param description Optional description to help identify pending jobs.\n */\n registerPromise(promise, terminate, description) {\n const jobEntry = { promise, terminate, description };\n this.jobs.add(jobEntry);\n // in all of my testing, it is safe to multi-subscribe to a promise.\n // so, rather than create another layer of promising, we're just going\n // to hook into the promise we already have, and when it's done\n // (successfully or not), we no longer need to wait for it upon close.\n //\n // sorry this is a bit hand-wavy:\n //\n // i believe we use `.then` and `.catch` instead of `.finally` because\n // `.finally` is invoked in a different order in the sequence, and this\n // breaks assumptions throughout and causes failures.\n promise\n .then(() => {\n this.jobs.delete(jobEntry);\n })\n .catch(() => {\n this.jobs.delete(jobEntry);\n });\n }\n /**\n * The number of jobs being waited on.\n *\n * We don't use this for anything. It's just informational for the caller,\n * and can be used in logging and testing.\n *\n * @returns the number of jobs.\n */\n get length() {\n return this.jobs.size;\n }\n /**\n * The execution state of the manager. One of:\n *\n * 1. \"Open\" -> Accepting new jobs\n * 1. \"Closing\" -> Not accepting new work. Waiting for jobs to complete.\n * 1. \"Closed\" -> Not accepting new work. All submitted jobs are complete.\n */\n get state() {\n return this._state;\n }\n /**\n * The registered `description` of all still-pending jobs.\n *\n * @returns descriptions as an array.\n */\n get pending() {\n return Array.from(this.jobs).map(job => job.description);\n }\n /**\n * Whether the manager is accepting new jobs.\n */\n get isOpen() {\n return this._state === BackgroundProcessManagerState.Open;\n }\n /**\n * Whether the manager is rejecting new work, but still waiting for\n * submitted work to complete.\n */\n get isClosing() {\n return this._state === BackgroundProcessManagerState.Closing;\n }\n /**\n * Whether the manager is rejecting work and done waiting for submitted\n * work to complete.\n */\n get isClosed() {\n return this._state === BackgroundProcessManagerState.Closed;\n }\n closedFailure(description) {\n if (!this.isOpen) {\n return Promise.reject(new BackgroundManagerNotOpenError([\n `The manager is ${this.state}.`,\n `You tried to add \"${description}\".`,\n `Pending jobs: [\\n${this.pending\n .map(t => ' ' + t)\n .join(',\\n')}\\n]`,\n ].join('\\n')));\n }\n }\n /**\n * Signals jobs to stop (for those that accept interruptions) and waits\n * for confirmation that jobs have stopped.\n *\n * This immediately puts the manager into a closing state and just begins\n * to reject new work. After all work in the manager is complete, the\n * manager goes into a `Completed` state and `close()` returns.\n *\n * This call is idempotent.\n *\n * If the manager is already closing or closed, `finalCleaup` is not executed.\n *\n * @param onClosed\n * @returns The settled results of each still-running job's promise. If the\n * manager is already closed, this will contain the results as of when the\n * manager's `close()` was called in an `Open` state.\n */\n async close() {\n if (this.isOpen) {\n this._state = BackgroundProcessManagerState.Closing;\n for (const job of Array.from(this.jobs)) {\n try {\n job.terminate();\n }\n catch (error) {\n // Due to potential races with a job's natural completion, it's\n // reasonable to expect the termination call to fail. Hence,\n // not logging as an error.\n // eslint-disable-next-line no-console\n console.warn(`Failed to send termination signal to job. Error: ${error.message}`, job);\n }\n }\n // Use `allSettled()` because we want to wait for all to finish. We do\n // not want to stop waiting if there is a failure.\n this._closingPromise = Promise.allSettled(Array.from(this.jobs).map(j => j.promise));\n await this._closingPromise;\n this._state = BackgroundProcessManagerState.Closed;\n }\n return this._closingPromise;\n }\n /**\n * Signals the manager to start accepting work (again) and returns once\n * the manager is ready to do so.\n *\n * If the state is already `Open`, this call is a no-op.\n *\n * If the state is `Closed`, this call simply updates state and returns.\n *\n * If the state is `Closing`, this call waits for completion before it\n * updates the state and returns.\n */\n async open() {\n if (this.isClosing) {\n await this.close();\n }\n this._state = BackgroundProcessManagerState.Open;\n }\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,wBAAwB,CAAC;AACtC,IAAI,WAAW,GAAG;AAClB;AACA;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,MAAM,GAAG,6BAA6B,CAAC,IAAI;AACxD;AACA;AACA;AACA,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,EAAE;AAC7B;AACA,IAAI,GAAG,CAAC,gBAAgB,EAAE,mBAAmB,EAAE;AAC/C,QAAQ,IAAI,GAAG;AACf,QAAQ,IAAI,WAAW;AACvB,QAAQ,IAAI,OAAO,gBAAgB,KAAK,QAAQ,EAAE;AAClD,YAAY,GAAG,GAAG,SAAS;AAC3B,YAAY,WAAW,GAAG,gBAAgB;AAC1C;AACA,aAAa;AACb,YAAY,GAAG,GAAG,gBAAgB;AAClC,YAAY,WAAW,GAAG,mBAAmB;AAC7C;AACA,QAAQ,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;AACrD,QAAQ,IAAI,KAAK;AACjB,YAAY,OAAO,KAAK;AACxB,QAAQ,IAAI,GAAG,KAAK,SAAS,EAAE;AAC/B,YAAY,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;AA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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE;AACzB,YAAY,IAAI,CAAC,MAAM,GAAG,6BAA6B,CAAC,OAAO;AAC/D,YAAY,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AACrD,gBAAgB,IAAI;AACpB,oBAAoB,GAAG,CAAC,SAAS,EAAE;AACnC;AACA,gBAAgB,OAAO,KAAK,EAAE;AAC9B;AACA;AACA;AACA;AACA,oBAAoB,OAAO,CAAC,IAAI,CAAC,CAAC,iDAAiD,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC;AAC1G;AACA;AACA;AACA;AACA,YAAY,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC;AAChG,YAAY,MAAM,IAAI,CAAC,eAAe;AACtC,YAAY,IAAI,CAAC,MAAM,GAAG,6BAA6B,CAAC,MAAM;AAC9D;AACA,QAAQ,OAAO,IAAI,CAAC,eAAe;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;AAC5B,YAAY,MAAM,IAAI,CAAC,KAAK,EAAE;AAC9B;AACA,QAAQ,IAAI,CAAC,MAAM,GAAG,6BAA6B,CAAC,IAAI;AACxD;AACA;;;;"}
@@ -1,6 +1,7 @@
1
1
  import { AWS_CLOUDWATCH_CATEGORY } from '../constants.mjs';
2
2
  import { LogType } from './types.mjs';
3
3
 
4
+ /* eslint-disable no-console */
4
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
6
  // SPDX-License-Identifier: Apache-2.0
6
7
  const LOG_LEVELS = {
@@ -1 +1 @@
1
- {"version":3,"file":"ConsoleLogger.mjs","sources":["../../../src/Logger/ConsoleLogger.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AWS_CLOUDWATCH_CATEGORY } from '../constants';\nimport { LogType } from './types';\nconst LOG_LEVELS = {\n VERBOSE: 1,\n DEBUG: 2,\n INFO: 3,\n WARN: 4,\n ERROR: 5,\n NONE: 6,\n};\n/**\n * Write logs\n * @class Logger\n */\nexport class ConsoleLogger {\n /**\n * @constructor\n * @param {string} name - Name of the logger\n */\n constructor(name, level = LogType.WARN) {\n this.name = name;\n this.level = level;\n this._pluggables = [];\n }\n _padding(n) {\n return n < 10 ? '0' + n : '' + n;\n }\n _ts() {\n const dt = new Date();\n return ([this._padding(dt.getMinutes()), this._padding(dt.getSeconds())].join(':') +\n '.' +\n dt.getMilliseconds());\n }\n configure(config) {\n if (!config)\n return this._config;\n this._config = config;\n return this._config;\n }\n /**\n * Write log\n * @method\n * @memeberof Logger\n * @param {LogType|string} type - log type, default INFO\n * @param {string|object} msg - Logging message or object\n */\n _log(type, ...msg) {\n let loggerLevelName = this.level;\n if (ConsoleLogger.LOG_LEVEL) {\n loggerLevelName = ConsoleLogger.LOG_LEVEL;\n }\n if (typeof window !== 'undefined' && window.LOG_LEVEL) {\n loggerLevelName = window.LOG_LEVEL;\n }\n const loggerLevel = LOG_LEVELS[loggerLevelName];\n const typeLevel = LOG_LEVELS[type];\n if (!(typeLevel >= loggerLevel)) {\n // Do nothing if type is not greater than or equal to logger level (handle undefined)\n return;\n }\n let log = console.log.bind(console);\n if (type === LogType.ERROR && console.error) {\n log = console.error.bind(console);\n }\n if (type === LogType.WARN && console.warn) {\n log = console.warn.bind(console);\n }\n if (ConsoleLogger.BIND_ALL_LOG_LEVELS) {\n if (type === LogType.INFO && console.info) {\n log = console.info.bind(console);\n }\n if (type === LogType.DEBUG && console.debug) {\n log = console.debug.bind(console);\n }\n }\n const prefix = `[${type}] ${this._ts()} ${this.name}`;\n let message = '';\n if (msg.length === 1 && typeof msg[0] === 'string') {\n message = `${prefix} - ${msg[0]}`;\n log(message);\n }\n else if (msg.length === 1) {\n message = `${prefix} ${msg[0]}`;\n log(prefix, msg[0]);\n }\n else if (typeof msg[0] === 'string') {\n let obj = msg.slice(1);\n if (obj.length === 1) {\n obj = obj[0];\n }\n message = `${prefix} - ${msg[0]} ${obj}`;\n log(`${prefix} - ${msg[0]}`, obj);\n }\n else {\n message = `${prefix} ${msg}`;\n log(prefix, msg);\n }\n for (const plugin of this._pluggables) {\n const logEvent = { message, timestamp: Date.now() };\n plugin.pushLogs([logEvent]);\n }\n }\n /**\n * Write General log. Default to INFO\n * @method\n * @memeberof Logger\n * @param {string|object} msg - Logging message or object\n */\n log(...msg) {\n this._log(LogType.INFO, ...msg);\n }\n /**\n * Write INFO log\n * @method\n * @memeberof Logger\n * @param {string|object} msg - Logging message or object\n */\n info(...msg) {\n this._log(LogType.INFO, ...msg);\n }\n /**\n * Write WARN log\n * @method\n * @memeberof Logger\n * @param {string|object} msg - Logging message or object\n */\n warn(...msg) {\n this._log(LogType.WARN, ...msg);\n }\n /**\n * Write ERROR log\n * @method\n * @memeberof Logger\n * @param {string|object} msg - Logging message or object\n */\n error(...msg) {\n this._log(LogType.ERROR, ...msg);\n }\n /**\n * Write DEBUG log\n * @method\n * @memeberof Logger\n * @param {string|object} msg - Logging message or object\n */\n debug(...msg) {\n this._log(LogType.DEBUG, ...msg);\n }\n /**\n * Write VERBOSE log\n * @method\n * @memeberof Logger\n * @param {string|object} msg - Logging message or object\n */\n verbose(...msg) {\n this._log(LogType.VERBOSE, ...msg);\n }\n addPluggable(pluggable) {\n if (pluggable && pluggable.getCategoryName() === AWS_CLOUDWATCH_CATEGORY) {\n this._pluggables.push(pluggable);\n pluggable.configure(this._config);\n }\n }\n listPluggables() {\n return this._pluggables;\n }\n}\nConsoleLogger.LOG_LEVEL = null;\nConsoleLogger.BIND_ALL_LOG_LEVELS = false;\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA,MAAM,UAAU,GAAG;AACnB,IAAI,OAAO,EAAE,CAAC;AACd,IAAI,KAAK,EAAE,CAAC;AACZ,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,KAAK,EAAE,CAAC;AACZ,IAAI,IAAI,EAAE,CAAC;AACX,CAAC;AACD;AACA;AACA;AACA;AACO,MAAM,aAAa,CAAC;AAC3B;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE;AAC5C,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI;AACxB,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK;AAC1B,QAAQ,IAAI,CAAC,WAAW,GAAG,EAAE;AAC7B;AACA,IAAI,QAAQ,CAAC,CAAC,EAAE;AAChB,QAAQ,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;AACxC;AACA,IAAI,GAAG,GAAG;AACV,QAAQ,MAAM,EAAE,GAAG,IAAI,IAAI,EAAE;AAC7B,QAAQ,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;AAC1F,YAAY,GAAG;AACf,YAAY,EAAE,CAAC,eAAe,EAAE;AAChC;AACA,IAAI,SAAS,CAAC,MAAM,EAAE;AACtB,QAAQ,IAAI,CAAC,MAAM;AACnB,YAAY,OAAO,IAAI,CAAC,OAAO;AAC/B,QAAQ,IAAI,CAAC,OAAO,GAAG,MAAM;AAC7B,QAAQ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QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC;AAC1C;AACA,IAAI,YAAY,CAAC,SAAS,EAAE;AAC5B,QAAQ,IAAI,SAAS,IAAI,SAAS,CAAC,eAAe,EAAE,KAAK,uBAAuB,EAAE;AAClF,YAAY,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC;AAC5C,YAAY,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC;AAC7C;AACA;AACA,IAAI,cAAc,GAAG;AACrB,QAAQ,OAAO,IAAI,CAAC,WAAW;AAC/B;AACA;AACA,aAAa,CAAC,SAAS,GAAG,IAAI;AAC9B,aAAa,CAAC,mBAAmB,GAAG,KAAK;;;;"}
1
+ {"version":3,"file":"ConsoleLogger.mjs","sources":["../../../src/Logger/ConsoleLogger.ts"],"sourcesContent":["/* eslint-disable no-console */\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AWS_CLOUDWATCH_CATEGORY } from '../constants';\nimport { LogType } from './types';\nconst LOG_LEVELS = {\n VERBOSE: 1,\n DEBUG: 2,\n INFO: 3,\n WARN: 4,\n ERROR: 5,\n NONE: 6,\n};\n/**\n * Write logs\n * @class Logger\n */\nexport class ConsoleLogger {\n /**\n * @constructor\n * @param {string} name - Name of the logger\n */\n constructor(name, level = LogType.WARN) {\n this.name = name;\n this.level = level;\n this._pluggables = [];\n }\n _padding(n) {\n return n < 10 ? '0' + n : '' + n;\n }\n _ts() {\n const dt = new Date();\n return ([this._padding(dt.getMinutes()), this._padding(dt.getSeconds())].join(':') +\n '.' +\n dt.getMilliseconds());\n }\n configure(config) {\n if (!config)\n return this._config;\n this._config = config;\n return this._config;\n }\n /**\n * Write log\n * @method\n * @memeberof Logger\n * @param {LogType|string} type - log type, default INFO\n * @param {string|object} msg - Logging message or object\n */\n _log(type, ...msg) {\n let loggerLevelName = this.level;\n if (ConsoleLogger.LOG_LEVEL) {\n loggerLevelName = ConsoleLogger.LOG_LEVEL;\n }\n if (typeof window !== 'undefined' && window.LOG_LEVEL) {\n loggerLevelName = window.LOG_LEVEL;\n }\n const loggerLevel = LOG_LEVELS[loggerLevelName];\n const typeLevel = LOG_LEVELS[type];\n if (!(typeLevel >= loggerLevel)) {\n // Do nothing if type is not greater than or equal to logger level (handle undefined)\n return;\n }\n let log = console.log.bind(console);\n if (type === LogType.ERROR && console.error) {\n log = console.error.bind(console);\n }\n if (type === LogType.WARN && console.warn) {\n log = console.warn.bind(console);\n }\n if (ConsoleLogger.BIND_ALL_LOG_LEVELS) {\n if (type === LogType.INFO && console.info) {\n log = console.info.bind(console);\n }\n if (type === LogType.DEBUG && console.debug) {\n log = console.debug.bind(console);\n }\n }\n const prefix = `[${type}] ${this._ts()} ${this.name}`;\n let message = '';\n if (msg.length === 1 && typeof msg[0] === 'string') {\n message = `${prefix} - ${msg[0]}`;\n log(message);\n }\n else if (msg.length === 1) {\n message = `${prefix} ${msg[0]}`;\n log(prefix, msg[0]);\n }\n else if (typeof msg[0] === 'string') {\n let obj = msg.slice(1);\n if (obj.length === 1) {\n obj = obj[0];\n }\n message = `${prefix} - ${msg[0]} ${obj}`;\n log(`${prefix} - ${msg[0]}`, obj);\n }\n else {\n message = `${prefix} ${msg}`;\n log(prefix, msg);\n }\n for (const plugin of this._pluggables) {\n const logEvent = { message, timestamp: Date.now() };\n plugin.pushLogs([logEvent]);\n }\n }\n /**\n * Write General log. Default to INFO\n * @method\n * @memeberof Logger\n * @param {string|object} msg - Logging message or object\n */\n log(...msg) {\n this._log(LogType.INFO, ...msg);\n }\n /**\n * Write INFO log\n * @method\n * @memeberof Logger\n * @param {string|object} msg - Logging message or object\n */\n info(...msg) {\n this._log(LogType.INFO, ...msg);\n }\n /**\n * Write WARN log\n * @method\n * @memeberof Logger\n * @param {string|object} msg - Logging message or object\n */\n warn(...msg) {\n this._log(LogType.WARN, ...msg);\n }\n /**\n * Write ERROR log\n * @method\n * @memeberof Logger\n * @param {string|object} msg - Logging message or object\n */\n error(...msg) {\n this._log(LogType.ERROR, ...msg);\n }\n /**\n * Write DEBUG log\n * @method\n * @memeberof Logger\n * @param {string|object} msg - Logging message or object\n */\n debug(...msg) {\n this._log(LogType.DEBUG, ...msg);\n }\n /**\n * Write VERBOSE log\n * @method\n * @memeberof Logger\n * @param {string|object} msg - Logging message or object\n */\n verbose(...msg) {\n this._log(LogType.VERBOSE, ...msg);\n }\n addPluggable(pluggable) {\n if (pluggable && pluggable.getCategoryName() === AWS_CLOUDWATCH_CATEGORY) {\n this._pluggables.push(pluggable);\n pluggable.configure(this._config);\n }\n }\n listPluggables() {\n return this._pluggables;\n }\n}\nConsoleLogger.LOG_LEVEL = null;\nConsoleLogger.BIND_ALL_LOG_LEVELS = false;\n"],"names":[],"mappings":";;;AAAA;AACA;AACA;AAGA,MAAM,UAAU,GAAG;AACnB,IAAI,OAAO,EAAE,CAAC;AACd,IAAI,KAAK,EAAE,CAAC;AACZ,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,KAAK,EAAE,CAAC;AACZ,IAAI,IAAI,EAAE,CAAC;AACX,CAAC;AACD;AACA;AACA;AACA;AACO,MAAM,aAAa,CAAC;AAC3B;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE;AAC5C,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI;AACxB,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK;AAC1B,QAAQ,IAAI,CAAC,WAAW,GAAG,EAAE;AAC7B;AACA,IAAI,QAAQ,CAAC,CAAC,EAAE;AAChB,QAAQ,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;AACxC;AACA,IAAI,GAAG,GAAG;AACV,QAAQ,MAAM,EAAE,GAAG,IAAI,IAAI,EAAE;AAC7B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;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,KAAK,CAAC,GAAG,GAAG,EAAE;AAClB,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,KAAK,CAAC,GAAG,GAAG,EAAE;AAClB,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,CAAC,GAAG,GAAG,EAAE;AACpB,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC;AAC1C;AACA,IAAI,YAAY,CAAC,SAAS,EAAE;AAC5B,QAAQ,IAAI,SAAS,IAAI,SAAS,CAAC,eAAe,EAAE,KAAK,uBAAuB,EAAE;AAClF,YAAY,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC;AAC5C,YAAY,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC;AAC7C;AACA;AACA,IAAI,cAAc,GAAG;AACrB,QAAQ,OAAO,IAAI,CAAC,WAAW;AAC/B;AACA;AACA,aAAa,CAAC,SAAS,GAAG,IAAI;AAC9B,aAAa,CAAC,mBAAmB,GAAG,KAAK;;;;"}
@@ -1 +1 @@
1
- export declare const version = "6.13.6-unstable.cde36a7.0+cde36a7";
1
+ export declare const version = "6.13.7-unstable.b188564.0+b188564";
@@ -1,5 +1,5 @@
1
1
  // generated by genversion
2
- const version = '6.13.6-unstable.cde36a7.0+cde36a7';
2
+ const version = '6.13.7-unstable.b188564.0+b188564';
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.13.6-unstable.cde36a7.0+cde36a7';\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.13.7-unstable.b188564.0+b188564';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
@@ -5,11 +5,19 @@ import '../errors/errorHelpers.mjs';
5
5
  import '../utils/getClientInfo/getClientInfo.mjs';
6
6
  import { isBrowser } from '../utils/isBrowser.mjs';
7
7
  import '../utils/retry/retry.mjs';
8
+ import '../parseAWSExports.mjs';
9
+ import 'uuid';
10
+ import '../singleton/Auth/utils/errorHelpers.mjs';
8
11
  import '@aws-crypto/sha256-js';
9
12
  import '@smithy/util-hex-encoding';
13
+ import '../Platform/index.mjs';
14
+ import '../Platform/types.mjs';
15
+ import '../BackgroundProcessManager/types.mjs';
16
+ import '../Reachability/Reachability.mjs';
17
+ import '../Hub/index.mjs';
18
+ import '../utils/sessionListener/index.mjs';
10
19
  import '../awsClients/pinpoint/base.mjs';
11
20
  import '../awsClients/pinpoint/errorHelpers.mjs';
12
- import 'uuid';
13
21
  import '../Cache/index.mjs';
14
22
  import { record } from '../providers/pinpoint/apis/record.mjs';
15
23
  import '../providers/pinpoint/utils/PinpointEventBuffer.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceWorker.mjs","sources":["../../../src/ServiceWorker/ServiceWorker.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '../Logger';\nimport { isBrowser } from '../utils';\nimport { AmplifyError } from '../errors';\nimport { record } from '../providers/pinpoint';\nimport { Amplify, fetchAuthSession } from '../singleton';\nimport { ServiceWorkerErrorCode, assert } from './errorHelpers';\n/**\n * Provides a means to registering a service worker in the browser\n * and communicating with it via postMessage events.\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/\n *\n * postMessage events are currently not supported in all browsers. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API\n *\n * At the minmum this class will register the service worker and listen\n * and attempt to dispatch messages on state change and record analytics\n * events based on the service worker lifecycle.\n */\nexport class ServiceWorkerClass {\n constructor() {\n // The AWS Amplify logger\n this._logger = new ConsoleLogger('ServiceWorker');\n }\n /**\n * Get the currently active service worker\n */\n get serviceWorker() {\n assert(this._serviceWorker !== undefined, ServiceWorkerErrorCode.UndefinedInstance);\n return this._serviceWorker;\n }\n /**\n * Register the service-worker.js file in the browser\n * Make sure the service-worker.js is part of the build\n * for example with Angular, modify the angular-cli.json file\n * and add to \"assets\" array \"service-worker.js\"\n * @param {string} filePath Service worker file. Defaults to \"/service-worker.js\"\n * @param {string} scope The service worker scope. Defaults to \"/\"\n * - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n * @returns {Promise}\n *\t- resolve(ServiceWorkerRegistration)\n *\t- reject(Error)\n **/\n register(filePath = '/service-worker.js', scope = '/') {\n this._logger.debug(`registering ${filePath}`);\n this._logger.debug(`registering service worker with scope ${scope}`);\n return new Promise((resolve, reject) => {\n if (navigator && 'serviceWorker' in navigator) {\n navigator.serviceWorker\n .register(filePath, {\n scope,\n })\n .then(registration => {\n if (registration.installing) {\n this._serviceWorker = registration.installing;\n }\n else if (registration.waiting) {\n this._serviceWorker = registration.waiting;\n }\n else if (registration.active) {\n this._serviceWorker = registration.active;\n }\n this._registration = registration;\n this._setupListeners();\n this._logger.debug(`Service Worker Registration Success: ${registration}`);\n resolve(registration);\n })\n .catch(error => {\n this._logger.debug(`Service Worker Registration Failed ${error}`);\n reject(new AmplifyError({\n name: ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n underlyingError: error,\n }));\n });\n }\n else {\n reject(new AmplifyError({\n name: ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n }));\n }\n });\n }\n /**\n * Enable web push notifications. If not subscribed, a new subscription will\n * be created and registered.\n * \tTest Push Server: https://web-push-codelab.glitch.me/\n * \tPush Server Libraries: https://github.com/web-push-libs/\n * \tAPI Doc: https://developers.google.com/web/fundamentals/codelabs/push-notifications/\n * @param publicKey\n * @returns {Promise}\n * \t- resolve(PushSubscription)\n * - reject(Error)\n */\n enablePush(publicKey) {\n assert(this._registration !== undefined, ServiceWorkerErrorCode.UndefinedRegistration);\n this._publicKey = publicKey;\n return new Promise((resolve, reject) => {\n if (isBrowser()) {\n assert(this._registration !== undefined, ServiceWorkerErrorCode.UndefinedRegistration);\n this._registration.pushManager.getSubscription().then(subscription => {\n if (subscription) {\n this._subscription = subscription;\n this._logger.debug(`User is subscribed to push: ${JSON.stringify(subscription)}`);\n resolve(subscription);\n }\n else {\n this._logger.debug(`User is NOT subscribed to push`);\n return this._registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: this._urlB64ToUint8Array(publicKey),\n })\n .then(pushManagerSubscription => {\n this._subscription = pushManagerSubscription;\n this._logger.debug(`User subscribed: ${JSON.stringify(pushManagerSubscription)}`);\n resolve(pushManagerSubscription);\n })\n .catch(error => {\n this._logger.error(error);\n });\n }\n });\n }\n else {\n reject(new AmplifyError({\n name: ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n }));\n }\n });\n }\n /**\n * Convert a base64 encoded string to a Uint8 array for the push server key\n * @param base64String\n */\n _urlB64ToUint8Array(base64String) {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding)\n .replace(/-/g, '+')\n .replace(/_/g, '/');\n const rawData = window.atob(base64);\n const outputArray = new Uint8Array(rawData.length);\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n }\n /**\n * Send a message to the service worker. The service worker needs\n * to implement `self.addEventListener('message') to handle the\n * message. This ***currently*** does not work in Safari or IE.\n * @param {object | string} message An arbitrary JSON object or string message to send to the service worker\n *\t- see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable\n * @returns {Promise}\n **/\n send(message) {\n if (this._serviceWorker) {\n this._serviceWorker.postMessage(typeof message === 'object' ? JSON.stringify(message) : message);\n }\n }\n /**\n * Listen for service worker state change and message events\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/state\n **/\n _setupListeners() {\n this.serviceWorker.addEventListener('statechange', async () => {\n const currentState = this.serviceWorker.state;\n this._logger.debug(`ServiceWorker statechange: ${currentState}`);\n const { appId, region, bufferSize, flushInterval, flushSize, resendLimit, } = Amplify.getConfig().Analytics?.Pinpoint ?? {};\n const { credentials } = await fetchAuthSession();\n if (appId && region && credentials) {\n // Pinpoint is configured, record an event\n record({\n appId,\n region,\n category: 'Core',\n credentials,\n bufferSize,\n flushInterval,\n flushSize,\n resendLimit,\n event: {\n name: 'ServiceWorker',\n attributes: {\n state: currentState,\n },\n },\n });\n }\n });\n this.serviceWorker.addEventListener('message', event => {\n this._logger.debug(`ServiceWorker message event: ${event}`);\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,kBAAkB,CAAC;AAChC,IAAI,WAAW,GAAG;AAClB;AACA,QAAQ,IAAI,CAAC,OAAO,GAAG,IAAI,aAAa,CAAC,eAAe,CAAC;AACzD;AACA;AACA;AACA;AACA,IAAI,IAAI,aAAa,GAAG;AACxB,QAAQ,MAAM,CAAC,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,sBAAsB,CAAC,iBAAiB,CAAC;AAC3F,QAAQ,OAAO,IAAI,CAAC,cAAc;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,QAAQ,CAAC,QAAQ,GAAG,oBAAoB,EAAE,KAAK,GAAG,GAAG,EAAE;AAC3D,QAAQ,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,QAAQ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AwB,UAAU,EAAE;AACpC,4BAA4B,KAAK,EAAE,YAAY;AAC/C,yBAAyB;AACzB,qBAAqB;AACrB,iBAAiB,CAAC;AAClB;AACA,SAAS,CAAC;AACV,QAAQ,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,IAAI;AAChE,YAAY,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC,CAAC;AACvE,SAAS,CAAC;AACV;AACA;;;;"}
1
+ {"version":3,"file":"ServiceWorker.mjs","sources":["../../../src/ServiceWorker/ServiceWorker.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '../Logger';\nimport { isBrowser } from '../utils';\nimport { AmplifyError } from '../errors';\nimport { record } from '../providers/pinpoint';\nimport { Amplify, fetchAuthSession } from '../singleton';\nimport { ServiceWorkerErrorCode, assert } from './errorHelpers';\n/**\n * Provides a means to registering a service worker in the browser\n * and communicating with it via postMessage events.\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/\n *\n * postMessage events are currently not supported in all browsers. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API\n *\n * At the minmum this class will register the service worker and listen\n * and attempt to dispatch messages on state change and record analytics\n * events based on the service worker lifecycle.\n */\nexport class ServiceWorkerClass {\n constructor() {\n // The AWS Amplify logger\n this._logger = new ConsoleLogger('ServiceWorker');\n }\n /**\n * Get the currently active service worker\n */\n get serviceWorker() {\n assert(this._serviceWorker !== undefined, ServiceWorkerErrorCode.UndefinedInstance);\n return this._serviceWorker;\n }\n /**\n * Register the service-worker.js file in the browser\n * Make sure the service-worker.js is part of the build\n * for example with Angular, modify the angular-cli.json file\n * and add to \"assets\" array \"service-worker.js\"\n * @param {string} filePath Service worker file. Defaults to \"/service-worker.js\"\n * @param {string} scope The service worker scope. Defaults to \"/\"\n * - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n * @returns {Promise}\n *\t- resolve(ServiceWorkerRegistration)\n *\t- reject(Error)\n **/\n register(filePath = '/service-worker.js', scope = '/') {\n this._logger.debug(`registering ${filePath}`);\n this._logger.debug(`registering service worker with scope ${scope}`);\n return new Promise((resolve, reject) => {\n if (navigator && 'serviceWorker' in navigator) {\n navigator.serviceWorker\n .register(filePath, {\n scope,\n })\n .then(registration => {\n if (registration.installing) {\n this._serviceWorker = registration.installing;\n }\n else if (registration.waiting) {\n this._serviceWorker = registration.waiting;\n }\n else if (registration.active) {\n this._serviceWorker = registration.active;\n }\n this._registration = registration;\n this._setupListeners();\n this._logger.debug(`Service Worker Registration Success: ${registration}`);\n resolve(registration);\n })\n .catch(error => {\n this._logger.debug(`Service Worker Registration Failed ${error}`);\n reject(new AmplifyError({\n name: ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n underlyingError: error,\n }));\n });\n }\n else {\n reject(new AmplifyError({\n name: ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n }));\n }\n });\n }\n /**\n * Enable web push notifications. If not subscribed, a new subscription will\n * be created and registered.\n * \tTest Push Server: https://web-push-codelab.glitch.me/\n * \tPush Server Libraries: https://github.com/web-push-libs/\n * \tAPI Doc: https://developers.google.com/web/fundamentals/codelabs/push-notifications/\n * @param publicKey\n * @returns {Promise}\n * \t- resolve(PushSubscription)\n * - reject(Error)\n */\n enablePush(publicKey) {\n assert(this._registration !== undefined, ServiceWorkerErrorCode.UndefinedRegistration);\n this._publicKey = publicKey;\n return new Promise((resolve, reject) => {\n if (isBrowser()) {\n assert(this._registration !== undefined, ServiceWorkerErrorCode.UndefinedRegistration);\n this._registration.pushManager.getSubscription().then(subscription => {\n if (subscription) {\n this._subscription = subscription;\n this._logger.debug(`User is subscribed to push: ${JSON.stringify(subscription)}`);\n resolve(subscription);\n }\n else {\n this._logger.debug(`User is NOT subscribed to push`);\n return this._registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: this._urlB64ToUint8Array(publicKey),\n })\n .then(pushManagerSubscription => {\n this._subscription = pushManagerSubscription;\n this._logger.debug(`User subscribed: ${JSON.stringify(pushManagerSubscription)}`);\n resolve(pushManagerSubscription);\n })\n .catch(error => {\n this._logger.error(error);\n });\n }\n });\n }\n else {\n reject(new AmplifyError({\n name: ServiceWorkerErrorCode.Unavailable,\n message: 'Service Worker not available',\n }));\n }\n });\n }\n /**\n * Convert a base64 encoded string to a Uint8 array for the push server key\n * @param base64String\n */\n _urlB64ToUint8Array(base64String) {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding)\n .replace(/-/g, '+')\n .replace(/_/g, '/');\n const rawData = window.atob(base64);\n const outputArray = new Uint8Array(rawData.length);\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n }\n /**\n * Send a message to the service worker. The service worker needs\n * to implement `self.addEventListener('message') to handle the\n * message. This ***currently*** does not work in Safari or IE.\n * @param {object | string} message An arbitrary JSON object or string message to send to the service worker\n *\t- see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable\n * @returns {Promise}\n **/\n send(message) {\n if (this._serviceWorker) {\n this._serviceWorker.postMessage(typeof message === 'object' ? JSON.stringify(message) : message);\n }\n }\n /**\n * Listen for service worker state change and message events\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/state\n **/\n _setupListeners() {\n this.serviceWorker.addEventListener('statechange', async () => {\n const currentState = this.serviceWorker.state;\n this._logger.debug(`ServiceWorker statechange: ${currentState}`);\n const { appId, region, bufferSize, flushInterval, flushSize, resendLimit, } = Amplify.getConfig().Analytics?.Pinpoint ?? {};\n const { credentials } = await fetchAuthSession();\n if (appId && region && credentials) {\n // Pinpoint is configured, record an event\n record({\n appId,\n region,\n category: 'Core',\n credentials,\n bufferSize,\n flushInterval,\n flushSize,\n resendLimit,\n event: {\n name: 'ServiceWorker',\n attributes: {\n state: currentState,\n },\n },\n });\n }\n });\n this.serviceWorker.addEventListener('message', event => {\n this._logger.debug(`ServiceWorker message event: ${event}`);\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,kBAAkB,CAAC;AAChC,IAAI,WAAW,GAAG;AAClB;AACA,QAAQ,IAAI,CAAC,OAAO,GAAG,IAAI,aAAa,CAAC,eAAe,CAAC;AACzD;AACA;AACA;AACA;AACA,IAAI,IAAI,aAAa,GAAG;AACxB,QAAQ,MAAM,CAAC,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,sBAAsB,CAAC,iBAAiB,CAAC;AAC3F,QAAQ,OAAO,IAAI,CAAC,cAAc;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,QAAQ,CAAC,QAAQ,GAAG,oBAAoB,EAAE,KAAK,GAAG,GAAG,EAAE;AAC3D,QAAQ,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;AACrD,QAAQ,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC,CAAC;AAC5E,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAChD,YAAY,IAAI,SAAS,IAAI,eAAe,IAAI,SAAS,EAAE;AAC3D,gBAAgB,SAAS,CAAC;AAC1B,qBAAqB,QAAQ,CAAC,QAAQ,EAAE;AACxC,oBAAoB,KAAK;AACzB,iBAAiB;AACjB,qBAAqB,IAAI,CAAC,YAAY,IAAI;AAC1C,oBAAoB,IAAI,YAAY,CAAC,UAAU,EAAE;AACjD,wBAAwB,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,UAAU;AACrE;AACA,yBAAy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EAAE,YAAY;AACvE,YAAY,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK;AACzD,YAAY,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,2BAA2B,EAAE,YAAY,CAAC,CAAC,CAAC;AAC5E,YAAY,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,GAAG,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,SAAS,EAAE,QAAQ,IAAI,EAAE;AACvI,YAAY,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,gBAAgB,EAAE;AAC5D,YAAY,IAAI,KAAK,IAAI,MAAM,IAAI,WAAW,EAAE;AAChD;AACA,gBAAgB,MAAM,CAAC;AACvB,oBAAoB,KAAK;AACzB,oBAAoB,MAAM;AAC1B,oBAAoB,QAAQ,EAAE,MAAM;AACpC,oBAAoB,WAAW;AAC/B,oBAAoB,UAAU;AAC9B,oBAAoB,aAAa;AACjC,oBAAoB,SAAS;AAC7B,oBAAoB,WAAW;AAC/B,oBAAoB,KAAK,EAAE;AAC3B,wBAAwB,IAAI,EAAE,eAAe;AAC7C,wBAAwB,UAAU,EAAE;AACpC,4BAA4B,KAAK,EAAE,YAAY;AAC/C,yBAAyB;AACzB,qBAAqB;AACrB,iBAAiB,CAAC;AAClB;AACA,SAAS,CAAC;AACV,QAAQ,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,IAAI;AAChE,YAAY,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC,CAAC;AACvE,SAAS,CAAC;AACV;AACA;;;;"}
@@ -5,7 +5,7 @@ import { Endpoint, EndpointResolverOptions, Headers, HttpRequest, HttpResponse }
5
5
  *
6
6
  * @internal
7
7
  */
8
- export declare const cognitoIdentityTransferHandler: (request: HttpRequest, options: Record<string, unknown> & import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").HttpTransferOptions) => Promise<HttpResponse>;
8
+ export declare const cognitoIdentityTransferHandler: (request: HttpRequest, options: Record<string, unknown> & import("../../clients").UserAgentOptions & object & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").AmzSdkRequestHeaderMiddlewareOptions & import("../../clients").HttpTransferOptions) => Promise<HttpResponse>;
9
9
  /**
10
10
  * @internal
11
11
  */
@@ -1,15 +1,25 @@
1
1
  import { getDnsSuffix } from '../../clients/endpoints/getDnsSuffix.mjs';
2
2
  import '../../types/errors.mjs';
3
3
  import '../../errors/errorHelpers.mjs';
4
- import { unauthenticatedHandler } from '../../clients/handlers/unauthenticated.mjs';
4
+ import { unauthenticatedHandler } from '../../clients/handlers/aws/unauthenticated.mjs';
5
5
  import { jitteredBackoff } from '../../clients/middleware/retry/jitteredBackoff.mjs';
6
6
  import { getRetryDecider } from '../../clients/middleware/retry/defaultRetryDecider.mjs';
7
+ import '../../utils/getClientInfo/getClientInfo.mjs';
8
+ import '../../utils/retry/retry.mjs';
9
+ import '../../parseAWSExports.mjs';
10
+ import 'uuid';
11
+ import { AmplifyUrl } from '../../utils/amplifyUrl/index.mjs';
12
+ import '../../singleton/Auth/utils/errorHelpers.mjs';
7
13
  import '@aws-crypto/sha256-js';
8
14
  import '@smithy/util-hex-encoding';
9
- import { AmplifyUrl } from '../../utils/amplifyUrl/index.mjs';
15
+ import { getAmplifyUserAgent } from '../../Platform/index.mjs';
16
+ import '../../Platform/types.mjs';
17
+ import '../../BackgroundProcessManager/types.mjs';
18
+ import '../../Reachability/Reachability.mjs';
19
+ import '../../Hub/index.mjs';
20
+ import '../../utils/sessionListener/index.mjs';
10
21
  import { composeTransferHandler } from '../../clients/internal/composeTransferHandler.mjs';
11
22
  import { parseJsonError } from '../../clients/serde/json.mjs';
12
- import { getAmplifyUserAgent } from '../../Platform/index.mjs';
13
23
  import { observeFrameworkChanges } from '../../Platform/detectFramework.mjs';
14
24
 
15
25
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -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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MAAM;AAChE,IAAI,OAAO;AACX,IAAI,GAAG;AACP,IAAI,IAAI;AACR,IAAI,MAAM,EAAE,MAAM;AAClB,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"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACA,MAAM,YAAY,GAAG,kBAAkB;AACvC;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM;AAC1C,IAAI,GAAG,EAAE,IAAI,UAAU,CAAC,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACrF,CAAC,CAAC;AACF;AACA;AACA;AACA,MAAM,6BAA6B,GAAG,MAAM,IAAI,IAAI,eAAe,sBAAsB,CAAC,OAAO,EAAE;AACnG,IAAI,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU;AACjD,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC;AACxB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,8BAA8B,GAAG,sBAAsB,CAAC,sBAAsB,EAAE,CAAC,6BAA6B,CAAC;AAC5H;AACA;AACA;AACY,MAAC,aAAa,GAAG;AAC7B,IAAI,OAAO,EAAE,YAAY;AACzB,IAAI,gBAAgB;AACpB,IAAI,YAAY,EAAE,eAAe,CAAC,cAAc,CAAC;AACjD,IAAI,YAAY,EAAE,eAAe;AACjC,IAAI,cAAc,EAAE,mBAAmB,EAAE;AACzC,IAAI,KAAK,EAAE,UAAU;AACrB;AACA,uBAAuB,CAAC,MAAM;AAC9B,IAAI,aAAa,CAAC,cAAc,GAAG,mBAAmB,EAAE;AACxD,CAAC,CAAC;AACF;AACA;AACA;AACY,MAAC,gBAAgB,GAAG,CAAC,SAAS,MAAM;AAChD,IAAI,cAAc,EAAE,4BAA4B;AAChD,IAAI,cAAc,EAAE,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAC;AAC5D,CAAC;AACD;AACA;AACA;AACY,MAAC,mBAAmB,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,MAAM;AAChE,IAAI,OAAO;AACX,IAAI,GAAG;AACP,IAAI,IAAI;AACR,IAAI,MAAM,EAAE,MAAM;AAClB,CAAC;;;;"}
@@ -2,8 +2,17 @@ import '../../types/errors.mjs';
2
2
  import '../../errors/errorHelpers.mjs';
3
3
  import '../../utils/getClientInfo/getClientInfo.mjs';
4
4
  import '../../utils/retry/retry.mjs';
5
+ import '../../parseAWSExports.mjs';
6
+ import 'uuid';
7
+ import '../../singleton/Auth/utils/errorHelpers.mjs';
5
8
  import '@aws-crypto/sha256-js';
6
9
  import '@smithy/util-hex-encoding';
10
+ import '../../Platform/index.mjs';
11
+ import '../../Platform/types.mjs';
12
+ import '../../BackgroundProcessManager/types.mjs';
13
+ import '../../Reachability/Reachability.mjs';
14
+ import '../../Hub/index.mjs';
15
+ import '../../utils/sessionListener/index.mjs';
7
16
  import { parseMetadata } from '../../clients/serde/responseInfo.mjs';
8
17
  import { parseJsonError, parseJsonBody } from '../../clients/serde/json.mjs';
9
18
  import { composeServiceApi } from '../../clients/internal/composeServiceApi.mjs';
@@ -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,KAAK,EAAE,QAAQ,KAAK;AACjE,IAAI,MAAM,OAAO,GAAG,gBAAgB,CAAC,2BAA2B,CAAC;AACjE,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;AACtC,IAAI,OAAO,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;AACvD,CAAC;AACD,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;AACpD,QAAQ,MAAM,KAAK;AACnB;AACA,SAAS;AACT,QAAQ,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC;AAClD,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;AACT;AACA,CAAC;AACD,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;AACL,CAAC;AACD;AACA;AACA;AACY,MAAC,yBAAyB,GAAG,iBAAiB,CAAC,8BAA8B,EAAE,mCAAmC,EAAE,qCAAqC,EAAE,aAAa;;;;"}
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,KAAK,EAAE,QAAQ,KAAK;AACjE,IAAI,MAAM,OAAO,GAAG,gBAAgB,CAAC,2BAA2B,CAAC;AACjE,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;AACtC,IAAI,OAAO,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;AACvD,CAAC;AACD,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;AACpD,QAAQ,MAAM,KAAK;AACnB;AACA,SAAS;AACT,QAAQ,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC;AAClD,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;AACT;AACA,CAAC;AACD,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;AACL,CAAC;AACD;AACA;AACA;AACY,MAAC,yBAAyB,GAAG,iBAAiB,CAAC,8BAA8B,EAAE,mCAAmC,EAAE,qCAAqC,EAAE,aAAa;;;;"}
@@ -2,8 +2,17 @@ import '../../types/errors.mjs';
2
2
  import '../../errors/errorHelpers.mjs';
3
3
  import '../../utils/getClientInfo/getClientInfo.mjs';
4
4
  import '../../utils/retry/retry.mjs';
5
+ import '../../parseAWSExports.mjs';
6
+ import 'uuid';
7
+ import '../../singleton/Auth/utils/errorHelpers.mjs';
5
8
  import '@aws-crypto/sha256-js';
6
9
  import '@smithy/util-hex-encoding';
10
+ import '../../Platform/index.mjs';
11
+ import '../../Platform/types.mjs';
12
+ import '../../BackgroundProcessManager/types.mjs';
13
+ import '../../Reachability/Reachability.mjs';
14
+ import '../../Hub/index.mjs';
15
+ import '../../utils/sessionListener/index.mjs';
7
16
  import { parseMetadata } from '../../clients/serde/responseInfo.mjs';
8
17
  import { parseJsonError, parseJsonBody } from '../../clients/serde/json.mjs';
9
18
  import { composeServiceApi } from '../../clients/internal/composeServiceApi.mjs';
@@ -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;AAC7C,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;AACtC,IAAI,OAAO,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;AACvD,CAAC;AACD,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;AACpD,QAAQ,MAAM,KAAK;AACnB;AACA,SAAS;AACT,QAAQ,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC;AAClD,QAAQ,OAAO;AACf,YAAY,UAAU,EAAE,IAAI,CAAC,UAAU;AACvC,YAAY,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC;AAC9C,SAAS;AACT;AACA,CAAC;AACD;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;AAC7C,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;AACtC,IAAI,OAAO,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;AACvD,CAAC;AACD,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;AACpD,QAAQ,MAAM,KAAK;AACnB;AACA,SAAS;AACT,QAAQ,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC;AAClD,QAAQ,OAAO;AACf,YAAY,UAAU,EAAE,IAAI,CAAC,UAAU;AACvC,YAAY,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC;AAC9C,SAAS;AACT;AACA,CAAC;AACD;AACA;AACA;AACY,MAAC,KAAK,GAAG,iBAAiB,CAAC,8BAA8B,EAAE,eAAe,EAAE,iBAAiB,EAAE,aAAa;;;;"}
@@ -1,9 +1,23 @@
1
1
  import { getDnsSuffix } from '../../clients/endpoints/getDnsSuffix.mjs';
2
2
  import { jitteredBackoff } from '../../clients/middleware/retry/jitteredBackoff.mjs';
3
3
  import { getRetryDecider } from '../../clients/middleware/retry/defaultRetryDecider.mjs';
4
- import { parseJsonError } from '../../clients/serde/json.mjs';
5
- import { getAmplifyUserAgent } from '../../Platform/index.mjs';
4
+ import '../../types/errors.mjs';
5
+ import '../../errors/errorHelpers.mjs';
6
+ import '../../utils/getClientInfo/getClientInfo.mjs';
7
+ import '../../utils/retry/retry.mjs';
8
+ import '../../parseAWSExports.mjs';
9
+ import 'uuid';
6
10
  import { AmplifyUrl } from '../../utils/amplifyUrl/index.mjs';
11
+ import '../../singleton/Auth/utils/errorHelpers.mjs';
12
+ import '@aws-crypto/sha256-js';
13
+ import '@smithy/util-hex-encoding';
14
+ import { getAmplifyUserAgent } from '../../Platform/index.mjs';
15
+ import '../../Platform/types.mjs';
16
+ import '../../BackgroundProcessManager/types.mjs';
17
+ import '../../Reachability/Reachability.mjs';
18
+ import '../../Hub/index.mjs';
19
+ import '../../utils/sessionListener/index.mjs';
20
+ import { parseJsonError } from '../../clients/serde/json.mjs';
7
21
 
8
22
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
9
23
  // SPDX-License-Identifier: Apache-2.0
@@ -1 +1 @@
1
- {"version":3,"file":"base.mjs","sources":["../../../../src/awsClients/pinpoint/base.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getDnsSuffix } from '../../clients/endpoints';\nimport { getRetryDecider, jitteredBackoff, } from '../../clients/middleware/retry';\nimport { parseJsonError } from '../../clients/serde/json';\nimport { getAmplifyUserAgent } from '../../Platform';\nimport { AmplifyUrl } from '../../utils/amplifyUrl';\n/**\n * The service name used to sign requests if the API requires authentication.\n */\nconst SERVICE_NAME = 'mobiletargeting';\n/**\n * The endpoint resolver function that returns the endpoint URL for a given region.\n */\nconst endpointResolver = ({ region }) => ({\n url: new AmplifyUrl(`https://pinpoint.${region}.${getDnsSuffix(region)}`),\n});\n/**\n * @internal\n */\nexport const defaultConfig = {\n service: SERVICE_NAME,\n endpointResolver,\n retryDecider: getRetryDecider(parseJsonError),\n computeDelay: jitteredBackoff,\n userAgentValue: getAmplifyUserAgent(),\n};\n/**\n * @internal\n */\nexport const getSharedHeaders = () => ({\n 'content-type': 'application/json',\n});\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA,MAAM,YAAY,GAAG,iBAAiB;AACtC;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM;AAC1C,IAAI,GAAG,EAAE,IAAI,UAAU,CAAC,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC,CAAC;AACF;AACA;AACA;AACY,MAAC,aAAa,GAAG;AAC7B,IAAI,OAAO,EAAE,YAAY;AACzB,IAAI,gBAAgB;AACpB,IAAI,YAAY,EAAE,eAAe,CAAC,cAAc,CAAC;AACjD,IAAI,YAAY,EAAE,eAAe;AACjC,IAAI,cAAc,EAAE,mBAAmB,EAAE;AACzC;AACA;AACA;AACA;AACY,MAAC,gBAAgB,GAAG,OAAO;AACvC,IAAI,cAAc,EAAE,kBAAkB;AACtC,CAAC;;;;"}
1
+ {"version":3,"file":"base.mjs","sources":["../../../../src/awsClients/pinpoint/base.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getDnsSuffix } from '../../clients/endpoints';\nimport { getRetryDecider, jitteredBackoff, } from '../../clients/middleware/retry';\nimport { parseJsonError } from '../../clients/serde/json';\nimport { getAmplifyUserAgent } from '../../Platform';\nimport { AmplifyUrl } from '../../utils/amplifyUrl';\n/**\n * The service name used to sign requests if the API requires authentication.\n */\nconst SERVICE_NAME = 'mobiletargeting';\n/**\n * The endpoint resolver function that returns the endpoint URL for a given region.\n */\nconst endpointResolver = ({ region }) => ({\n url: new AmplifyUrl(`https://pinpoint.${region}.${getDnsSuffix(region)}`),\n});\n/**\n * @internal\n */\nexport const defaultConfig = {\n service: SERVICE_NAME,\n endpointResolver,\n retryDecider: getRetryDecider(parseJsonError),\n computeDelay: jitteredBackoff,\n userAgentValue: getAmplifyUserAgent(),\n};\n/**\n * @internal\n */\nexport const getSharedHeaders = () => ({\n 'content-type': 'application/json',\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA,MAAM,YAAY,GAAG,iBAAiB;AACtC;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM;AAC1C,IAAI,GAAG,EAAE,IAAI,UAAU,CAAC,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC,CAAC;AACF;AACA;AACA;AACY,MAAC,aAAa,GAAG;AAC7B,IAAI,OAAO,EAAE,YAAY;AACzB,IAAI,gBAAgB;AACpB,IAAI,YAAY,EAAE,eAAe,CAAC,cAAc,CAAC;AACjD,IAAI,YAAY,EAAE,eAAe;AACjC,IAAI,cAAc,EAAE,mBAAmB,EAAE;AACzC;AACA;AACA;AACA;AACY,MAAC,gBAAgB,GAAG,OAAO;AACvC,IAAI,cAAc,EAAE,kBAAkB;AACtC,CAAC;;;;"}
@@ -17,8 +17,8 @@ export declare const getInAppMessages: (config: {
17
17
  cache?: RequestCache | undefined;
18
18
  withCrossDomainCredentials?: boolean | undefined;
19
19
  maxAttempts?: number | undefined;
20
- userAgentHeader?: string | undefined;
21
- uriEscapePath?: boolean | undefined;
22
- credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | ((options?: import("../../clients").CredentialsProviderOptions | undefined) => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
23
20
  region: string;
21
+ credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | ((options?: import("../../clients").CredentialsProviderOptions | undefined) => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
22
+ uriEscapePath?: boolean | undefined;
23
+ userAgentHeader?: string | undefined;
24
24
  }, input: import("./types").GetInAppMessagesRequest) => Promise<GetInAppMessagesOutput>;
@@ -1,4 +1,4 @@
1
- import { authenticatedHandler } from '../../clients/handlers/authenticated.mjs';
1
+ import { authenticatedHandler } from '../../clients/handlers/aws/authenticated.mjs';
2
2
  import { composeServiceApi } from '../../clients/internal/composeServiceApi.mjs';
3
3
  import { extendedEncodeURIComponent } from '../../clients/middleware/signing/utils/extendedEncodeURIComponent.mjs';
4
4
  import { parseMetadata } from '../../clients/serde/responseInfo.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"getInAppMessages.mjs","sources":["../../../../src/awsClients/pinpoint/getInAppMessages.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { authenticatedHandler } from '../../clients/handlers/authenticated';\nimport { composeServiceApi } from '../../clients/internal/composeServiceApi';\nimport { extendedEncodeURIComponent } from '../../clients/middleware/signing/utils/extendedEncodeURIComponent';\nimport { parseJsonBody, parseJsonError, parseMetadata, } from '../../clients/serde';\nimport { AmplifyUrl } from '../../utils/amplifyUrl';\nimport { defaultConfig, getSharedHeaders } from './base';\nconst getInAppMessagesSerializer = ({ ApplicationId = '', EndpointId = '' }, endpoint) => {\n const headers = getSharedHeaders();\n const url = new AmplifyUrl(endpoint.url);\n url.pathname = `v1/apps/${extendedEncodeURIComponent(ApplicationId)}/endpoints/${extendedEncodeURIComponent(EndpointId)}/inappmessages`;\n return { method: 'GET', headers, url };\n};\nconst getInAppMessagesDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseJsonError(response);\n throw error;\n }\n else {\n const { InAppMessageCampaigns } = await parseJsonBody(response);\n return {\n InAppMessagesResponse: { InAppMessageCampaigns },\n $metadata: parseMetadata(response),\n };\n }\n};\n/**\n * @internal\n */\nexport const getInAppMessages = composeServiceApi(authenticatedHandler, getInAppMessagesSerializer, getInAppMessagesDeserializer, defaultConfig);\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AAOA,MAAM,0BAA0B,GAAG,CAAC,EAAE,aAAa,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,EAAE,QAAQ,KAAK;AAC1F,IAAI,MAAM,OAAO,GAAG,gBAAgB,EAAE;AACtC,IAAI,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC;AAC5C,IAAI,GAAG,CAAC,QAAQ,GAAG,CAAC,QAAQ,EAAE,0BAA0B,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,0BAA0B,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC;AAC3I,IAAI,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE;AAC1C,CAAC;AACD,MAAM,4BAA4B,GAAG,OAAO,QAAQ,KAAK;AACzD,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC;AACpD,QAAQ,MAAM,KAAK;AACnB;AACA,SAAS;AACT,QAAQ,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC;AACvE,QAAQ,OAAO;AACf,YAAY,qBAAqB,EAAE,EAAE,qBAAqB,EAAE;AAC5D,YAAY,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC;AAC9C,SAAS;AACT;AACA,CAAC;AACD;AACA;AACA;AACY,MAAC,gBAAgB,GAAG,iBAAiB,CAAC,oBAAoB,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,aAAa;;;;"}
1
+ {"version":3,"file":"getInAppMessages.mjs","sources":["../../../../src/awsClients/pinpoint/getInAppMessages.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { authenticatedHandler } from '../../clients/handlers/aws/authenticated';\nimport { composeServiceApi } from '../../clients/internal/composeServiceApi';\nimport { extendedEncodeURIComponent } from '../../clients/middleware/signing/utils/extendedEncodeURIComponent';\nimport { parseJsonBody, parseJsonError, parseMetadata, } from '../../clients/serde';\nimport { AmplifyUrl } from '../../utils/amplifyUrl';\nimport { defaultConfig, getSharedHeaders } from './base';\nconst getInAppMessagesSerializer = ({ ApplicationId = '', EndpointId = '' }, endpoint) => {\n const headers = getSharedHeaders();\n const url = new AmplifyUrl(endpoint.url);\n url.pathname = `v1/apps/${extendedEncodeURIComponent(ApplicationId)}/endpoints/${extendedEncodeURIComponent(EndpointId)}/inappmessages`;\n return { method: 'GET', headers, url };\n};\nconst getInAppMessagesDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseJsonError(response);\n throw error;\n }\n else {\n const { InAppMessageCampaigns } = await parseJsonBody(response);\n return {\n InAppMessagesResponse: { InAppMessageCampaigns },\n $metadata: parseMetadata(response),\n };\n }\n};\n/**\n * @internal\n */\nexport const getInAppMessages = composeServiceApi(authenticatedHandler, getInAppMessagesSerializer, getInAppMessagesDeserializer, defaultConfig);\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AAOA,MAAM,0BAA0B,GAAG,CAAC,EAAE,aAAa,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,EAAE,QAAQ,KAAK;AAC1F,IAAI,MAAM,OAAO,GAAG,gBAAgB,EAAE;AACtC,IAAI,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC;AAC5C,IAAI,GAAG,CAAC,QAAQ,GAAG,CAAC,QAAQ,EAAE,0BAA0B,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,0BAA0B,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC;AAC3I,IAAI,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE;AAC1C,CAAC;AACD,MAAM,4BAA4B,GAAG,OAAO,QAAQ,KAAK;AACzD,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC;AACpD,QAAQ,MAAM,KAAK;AACnB;AACA,SAAS;AACT,QAAQ,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC;AACvE,QAAQ,OAAO;AACf,YAAY,qBAAqB,EAAE,EAAE,qBAAqB,EAAE;AAC5D,YAAY,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC;AAC9C,SAAS;AACT;AACA,CAAC;AACD;AACA;AACA;AACY,MAAC,gBAAgB,GAAG,iBAAiB,CAAC,oBAAoB,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,aAAa;;;;"}
@@ -17,8 +17,8 @@ export declare const putEvents: (config: {
17
17
  cache?: RequestCache | undefined;
18
18
  withCrossDomainCredentials?: boolean | undefined;
19
19
  maxAttempts?: number | undefined;
20
- userAgentHeader?: string | undefined;
21
- uriEscapePath?: boolean | undefined;
22
- credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | ((options?: import("../../clients").CredentialsProviderOptions | undefined) => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
23
20
  region: string;
21
+ credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | ((options?: import("../../clients").CredentialsProviderOptions | undefined) => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
22
+ uriEscapePath?: boolean | undefined;
23
+ userAgentHeader?: string | undefined;
24
24
  }, input: import("./types").PutEventsRequest) => Promise<PutEventsOutput>;
@@ -1,4 +1,4 @@
1
- import { authenticatedHandler } from '../../clients/handlers/authenticated.mjs';
1
+ import { authenticatedHandler } from '../../clients/handlers/aws/authenticated.mjs';
2
2
  import { composeServiceApi } from '../../clients/internal/composeServiceApi.mjs';
3
3
  import { extendedEncodeURIComponent } from '../../clients/middleware/signing/utils/extendedEncodeURIComponent.mjs';
4
4
  import { parseMetadata } from '../../clients/serde/responseInfo.mjs';