@aws-amplify/core 6.0.17 → 6.0.18-experimental-lerna-test.d2b0b08.55
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.
- package/dist/cjs/I18n/index.js +1 -1
- package/dist/cjs/I18n/index.js.map +1 -1
- package/dist/cjs/Logger/ConsoleLogger.js +9 -0
- package/dist/cjs/Logger/ConsoleLogger.js.map +1 -1
- package/dist/cjs/Platform/version.js +1 -1
- package/dist/cjs/Platform/version.js.map +1 -1
- package/dist/cjs/ServiceWorker/ServiceWorker.js +3 -3
- package/dist/cjs/ServiceWorker/ServiceWorker.js.map +1 -1
- package/dist/cjs/clients/middleware/retry/defaultRetryDecider.js +1 -1
- package/dist/cjs/clients/middleware/retry/defaultRetryDecider.js.map +1 -1
- package/dist/cjs/libraryUtils.js +4 -5
- package/dist/cjs/libraryUtils.js.map +1 -1
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/utils.js +6 -0
- package/dist/cjs/types/utils.js.map +1 -0
- package/dist/cjs/utils/WordArray.js +2 -1
- package/dist/cjs/utils/WordArray.js.map +1 -1
- package/dist/esm/I18n/index.d.ts +1 -1
- package/dist/esm/I18n/index.mjs +1 -1
- package/dist/esm/I18n/index.mjs.map +1 -1
- package/dist/esm/Logger/ConsoleLogger.d.ts +1 -0
- package/dist/esm/Logger/ConsoleLogger.mjs +9 -0
- package/dist/esm/Logger/ConsoleLogger.mjs.map +1 -1
- package/dist/esm/Platform/version.d.ts +1 -1
- package/dist/esm/Platform/version.mjs +1 -1
- package/dist/esm/Platform/version.mjs.map +1 -1
- package/dist/esm/ServiceWorker/ServiceWorker.d.ts +3 -3
- package/dist/esm/ServiceWorker/ServiceWorker.mjs +3 -3
- package/dist/esm/ServiceWorker/ServiceWorker.mjs.map +1 -1
- package/dist/esm/clients/middleware/retry/defaultRetryDecider.mjs +1 -1
- package/dist/esm/clients/middleware/retry/defaultRetryDecider.mjs.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/libraryUtils.d.ts +4 -4
- package/dist/esm/libraryUtils.mjs +1 -1
- package/dist/esm/singleton/API/types.d.ts +23 -3
- package/dist/esm/singleton/Auth/types.d.ts +17 -3
- package/dist/esm/singleton/Auth/utils/index.d.ts +2 -1
- package/dist/esm/singleton/apis/fetchAuthSession.d.ts +2 -2
- package/dist/esm/singleton/types.d.ts +9 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/utils.d.ts +8 -0
- package/dist/esm/types/utils.mjs +2 -0
- package/dist/esm/types/utils.mjs.map +1 -0
- package/dist/esm/utils/WordArray.d.ts +1 -1
- package/dist/esm/utils/WordArray.mjs +1 -1
- package/dist/esm/utils/WordArray.mjs.map +1 -1
- package/package.json +3 -3
- package/src/I18n/index.ts +1 -1
- package/src/Logger/ConsoleLogger.ts +9 -0
- package/src/Platform/version.ts +1 -1
- package/src/ServiceWorker/ServiceWorker.ts +3 -3
- package/src/clients/middleware/retry/defaultRetryDecider.ts +1 -1
- package/src/index.ts +1 -0
- package/src/libraryUtils.ts +11 -3
- package/src/singleton/API/types.ts +26 -1
- package/src/singleton/Auth/types.ts +25 -6
- package/src/singleton/Auth/utils/index.ts +1 -1
- package/src/singleton/apis/fetchAuthSession.ts +4 -2
- package/src/singleton/types.ts +9 -0
- package/src/types/index.ts +1 -0
- package/src/types/utils.ts +14 -0
- package/src/utils/WordArray.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.0.
|
|
1
|
+
export declare const version = "6.0.18-experimental-lerna-test.d2b0b08.55+d2b0b087b";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.0.
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.0.18-experimental-lerna-test.d2b0b08.55+d2b0b087b';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
|
|
@@ -25,8 +25,8 @@ export declare class ServiceWorkerClass {
|
|
|
25
25
|
* Make sure the service-worker.js is part of the build
|
|
26
26
|
* for example with Angular, modify the angular-cli.json file
|
|
27
27
|
* and add to "assets" array "service-worker.js"
|
|
28
|
-
* @param {string}
|
|
29
|
-
* @param {string}
|
|
28
|
+
* @param {string} filePath Service worker file. Defaults to "/service-worker.js"
|
|
29
|
+
* @param {string} scope The service worker scope. Defaults to "/"
|
|
30
30
|
* - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
|
|
31
31
|
* @returns {Promise}
|
|
32
32
|
* - resolve(ServiceWorkerRegistration)
|
|
@@ -54,7 +54,7 @@ export declare class ServiceWorkerClass {
|
|
|
54
54
|
* Send a message to the service worker. The service worker needs
|
|
55
55
|
* to implement `self.addEventListener('message') to handle the
|
|
56
56
|
* message. This ***currently*** does not work in Safari or IE.
|
|
57
|
-
* @param {object | string}
|
|
57
|
+
* @param {object | string} message An arbitrary JSON object or string message to send to the service worker
|
|
58
58
|
* - see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable
|
|
59
59
|
* @returns {Promise}
|
|
60
60
|
**/
|
|
@@ -49,8 +49,8 @@ class ServiceWorkerClass {
|
|
|
49
49
|
* Make sure the service-worker.js is part of the build
|
|
50
50
|
* for example with Angular, modify the angular-cli.json file
|
|
51
51
|
* and add to "assets" array "service-worker.js"
|
|
52
|
-
* @param {string}
|
|
53
|
-
* @param {string}
|
|
52
|
+
* @param {string} filePath Service worker file. Defaults to "/service-worker.js"
|
|
53
|
+
* @param {string} scope The service worker scope. Defaults to "/"
|
|
54
54
|
* - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
|
|
55
55
|
* @returns {Promise}
|
|
56
56
|
* - resolve(ServiceWorkerRegistration)
|
|
@@ -165,7 +165,7 @@ class ServiceWorkerClass {
|
|
|
165
165
|
* Send a message to the service worker. The service worker needs
|
|
166
166
|
* to implement `self.addEventListener('message') to handle the
|
|
167
167
|
* message. This ***currently*** does not work in Safari or IE.
|
|
168
|
-
* @param {object | string}
|
|
168
|
+
* @param {object | string} message An arbitrary JSON object or string message to send to the service worker
|
|
169
169
|
* - see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable
|
|
170
170
|
* @returns {Promise}
|
|
171
171
|
**/
|
|
@@ -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} - (optional) Service worker file. Defaults to \"/service-worker.js\"\n * @param {string} - (optional) 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} - 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,CAAC;AAC1D,KAAK;AACL;AACA;AACA;AACA,IAAI,IAAI,aAAa,GAAG;AACxB,QAAQ,MAAM,CAAC,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;AAC5F,QAAQ,OAAO,IAAI,CAAC,cAAc,CAAC;AACnC,KAAK;AACL;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,CAAC;AACtD,QAAQ,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAC7E,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAChD,YAAY,IAAI,SAAS,IAAI,eAAe,IAAI,SAAS,EAAE;AAC3D,gBAAgB,SAAS,CAAC,aAAa;AACvC,qBAAqB,QAAQ,CAAC,QAAQ,EAAE;AACxC,oBAAoB,KAAK;AACzB,iBAAiB,CAAC;AAClB,qBAAqB,IAAI,CAAC,YAAY,IAAI;AAC1C,oBAAoB,IAAI,YAAY,CAAC,UAAU,EAAE;AACjD,wBAAwB,IAAI,CAAC,cAAc,GAAG,YAAY,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C;AACnB,aAAa;AACb,SAAS,CAAC,CAAC;AACX,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,CAAC;AACxE,SAAS,CAAC,CAAC;AACX,KAAK;AACL;;;;"}
|
|
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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AQ,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,CAAC;AACxE,SAAS,CAAC,CAAC;AACX,KAAK;AACL;;;;"}
|
|
@@ -10,7 +10,7 @@ const getRetryDecider = (errorParser) => async (response, error) => {
|
|
|
10
10
|
const parsedError = error ??
|
|
11
11
|
(await errorParser(response)) ??
|
|
12
12
|
undefined;
|
|
13
|
-
const errorCode = parsedError?.code;
|
|
13
|
+
const errorCode = parsedError?.code || parsedError?.name;
|
|
14
14
|
const statusCode = response?.statusCode;
|
|
15
15
|
return (isConnectionError(error) ||
|
|
16
16
|
isThrottlingError(statusCode, errorCode) ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultRetryDecider.mjs","sources":["../../../../../src/clients/middleware/retry/defaultRetryDecider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { isClockSkewError } from './isClockSkewError';\n/**\n * Get retry decider function\n * @param errorParser Function to load JavaScript error from HTTP response\n */\nexport const getRetryDecider = (errorParser) => async (response, error) => {\n const parsedError = error ??\n (await errorParser(response)) ??\n undefined;\n const errorCode = parsedError?.code;\n const statusCode = response?.statusCode;\n return (isConnectionError(error) ||\n isThrottlingError(statusCode, errorCode) ||\n isClockSkewError(errorCode) ||\n isServerSideError(statusCode, errorCode));\n};\n// reference: https://github.com/aws/aws-sdk-js-v3/blob/ab0e7be36e7e7f8a0c04834357aaad643c7912c3/packages/service-error-classification/src/constants.ts#L22-L37\nconst THROTTLING_ERROR_CODES = [\n 'BandwidthLimitExceeded',\n 'EC2ThrottledException',\n 'LimitExceededException',\n 'PriorRequestNotComplete',\n 'ProvisionedThroughputExceededException',\n 'RequestLimitExceeded',\n 'RequestThrottled',\n 'RequestThrottledException',\n 'SlowDown',\n 'ThrottledException',\n 'Throttling',\n 'ThrottlingException',\n 'TooManyRequestsException',\n];\nconst TIMEOUT_ERROR_CODES = [\n 'TimeoutError',\n 'RequestTimeout',\n 'RequestTimeoutException',\n];\nconst isThrottlingError = (statusCode, errorCode) => statusCode === 429 ||\n (!!errorCode && THROTTLING_ERROR_CODES.includes(errorCode));\nconst isConnectionError = (error) => error?.name === 'Network error';\nconst isServerSideError = (statusCode, errorCode) => (!!statusCode && [500, 502, 503, 504].includes(statusCode)) ||\n (!!errorCode && TIMEOUT_ERROR_CODES.includes(errorCode));\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACY,MAAC,eAAe,GAAG,CAAC,WAAW,KAAK,OAAO,QAAQ,EAAE,KAAK,KAAK;AAC3E,IAAI,MAAM,WAAW,GAAG,KAAK;AAC7B,SAAS,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAC;AACrC,QAAQ,SAAS,CAAC;AAClB,IAAI,MAAM,SAAS,GAAG,WAAW,EAAE,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"defaultRetryDecider.mjs","sources":["../../../../../src/clients/middleware/retry/defaultRetryDecider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { isClockSkewError } from './isClockSkewError';\n/**\n * Get retry decider function\n * @param errorParser Function to load JavaScript error from HTTP response\n */\nexport const getRetryDecider = (errorParser) => async (response, error) => {\n const parsedError = error ??\n (await errorParser(response)) ??\n undefined;\n const errorCode = parsedError?.code || parsedError?.name;\n const statusCode = response?.statusCode;\n return (isConnectionError(error) ||\n isThrottlingError(statusCode, errorCode) ||\n isClockSkewError(errorCode) ||\n isServerSideError(statusCode, errorCode));\n};\n// reference: https://github.com/aws/aws-sdk-js-v3/blob/ab0e7be36e7e7f8a0c04834357aaad643c7912c3/packages/service-error-classification/src/constants.ts#L22-L37\nconst THROTTLING_ERROR_CODES = [\n 'BandwidthLimitExceeded',\n 'EC2ThrottledException',\n 'LimitExceededException',\n 'PriorRequestNotComplete',\n 'ProvisionedThroughputExceededException',\n 'RequestLimitExceeded',\n 'RequestThrottled',\n 'RequestThrottledException',\n 'SlowDown',\n 'ThrottledException',\n 'Throttling',\n 'ThrottlingException',\n 'TooManyRequestsException',\n];\nconst TIMEOUT_ERROR_CODES = [\n 'TimeoutError',\n 'RequestTimeout',\n 'RequestTimeoutException',\n];\nconst isThrottlingError = (statusCode, errorCode) => statusCode === 429 ||\n (!!errorCode && THROTTLING_ERROR_CODES.includes(errorCode));\nconst isConnectionError = (error) => error?.name === 'Network error';\nconst isServerSideError = (statusCode, errorCode) => (!!statusCode && [500, 502, 503, 504].includes(statusCode)) ||\n (!!errorCode && TIMEOUT_ERROR_CODES.includes(errorCode));\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACY,MAAC,eAAe,GAAG,CAAC,WAAW,KAAK,OAAO,QAAQ,EAAE,KAAK,KAAK;AAC3E,IAAI,MAAM,WAAW,GAAG,KAAK;AAC7B,SAAS,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAC;AACrC,QAAQ,SAAS,CAAC;AAClB,IAAI,MAAM,SAAS,GAAG,WAAW,EAAE,IAAI,IAAI,WAAW,EAAE,IAAI,CAAC;AAC7D,IAAI,MAAM,UAAU,GAAG,QAAQ,EAAE,UAAU,CAAC;AAC5C,IAAI,QAAQ,iBAAiB,CAAC,KAAK,CAAC;AACpC,QAAQ,iBAAiB,CAAC,UAAU,EAAE,SAAS,CAAC;AAChD,QAAQ,gBAAgB,CAAC,SAAS,CAAC;AACnC,QAAQ,iBAAiB,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE;AAClD,EAAE;AACF;AACA,MAAM,sBAAsB,GAAG;AAC/B,IAAI,wBAAwB;AAC5B,IAAI,uBAAuB;AAC3B,IAAI,wBAAwB;AAC5B,IAAI,yBAAyB;AAC7B,IAAI,wCAAwC;AAC5C,IAAI,sBAAsB;AAC1B,IAAI,kBAAkB;AACtB,IAAI,2BAA2B;AAC/B,IAAI,UAAU;AACd,IAAI,oBAAoB;AACxB,IAAI,YAAY;AAChB,IAAI,qBAAqB;AACzB,IAAI,0BAA0B;AAC9B,CAAC,CAAC;AACF,MAAM,mBAAmB,GAAG;AAC5B,IAAI,cAAc;AAClB,IAAI,gBAAgB;AACpB,IAAI,yBAAyB;AAC7B,CAAC,CAAC;AACF,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,SAAS,KAAK,UAAU,KAAK,GAAG;AACvE,KAAK,CAAC,CAAC,SAAS,IAAI,sBAAsB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AAChE,MAAM,iBAAiB,GAAG,CAAC,KAAK,KAAK,KAAK,EAAE,IAAI,KAAK,eAAe,CAAC;AACrE,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,SAAS,KAAK,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC;AAC/G,KAAK,CAAC,CAAC,SAAS,IAAI,mBAAmB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;;;;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Hub } from './Hub';
|
|
2
2
|
export { HubCapsule, HubCallback, HubPayload } from './Hub/types';
|
|
3
|
-
export { TokenProvider, AuthTokens, FetchAuthSessionOptions, CredentialsAndIdentityIdProvider, CredentialsAndIdentityId, Identity, OAuthConfig, CognitoUserPoolConfig, JWT, } from './singleton/Auth/types';
|
|
3
|
+
export { TokenProvider, AuthTokens, FetchAuthSessionOptions, AuthSession, CredentialsAndIdentityIdProvider, CredentialsAndIdentityId, Identity, OAuthConfig, CognitoUserPoolConfig, JWT, } from './singleton/Auth/types';
|
|
4
4
|
export { decodeJWT } from './singleton/Auth/utils';
|
|
5
5
|
export { AuthConfig, AuthUserPoolConfig, AuthUserPoolAndIdentityPoolConfig, APIConfig, PredictionsConfig, StorageAccessLevel, StorageConfig, GetCredentialsOptions, ResourcesConfig, LibraryOptions, AnalyticsConfig, GeoConfig, } from './singleton/types';
|
|
6
6
|
export { Amplify, fetchAuthSession, AmplifyClass as AmplifyClassV6, clearCredentials, } from './singleton';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import WordArray from './utils/WordArray';
|
|
2
1
|
export { generateRandomString, isBrowser, isNonRetryableError, isWebWorker, jitteredBackoff, jitteredExponentialRetry, NonRetryableError, retry, urlSafeDecode, urlSafeEncode, deDupeAsyncFunction, } from './utils';
|
|
3
2
|
export { parseAWSExports } from './parseAWSExports';
|
|
4
3
|
export { LegacyConfig } from './singleton/types';
|
|
@@ -7,9 +6,9 @@ export { amplifyUuid } from './utils/amplifyUuid';
|
|
|
7
6
|
export { AmplifyUrl, AmplifyUrlSearchParams } from './utils/amplifyUrl';
|
|
8
7
|
export { decodeJWT, assertTokenProviderConfig, assertIdentityPoolIdConfig, assertOAuthConfig, } from './singleton/Auth/utils';
|
|
9
8
|
export { isTokenExpired } from './singleton/Auth';
|
|
10
|
-
export { AssociationBelongsTo, AssociationHasMany, AssociationHasOne, DocumentType, GraphQLAuthMode, ModelFieldType, ModelIntrospectionSchema, SchemaModel, SchemaModels, ModelAttribute, SecondaryIndexAttribute, GraphQLProviderConfig, } from './singleton/API/types';
|
|
9
|
+
export { AssociationBelongsTo, AssociationHasMany, AssociationHasOne, DocumentType, GraphQLAuthMode, ModelFieldType, NonModelFieldType, ModelIntrospectionSchema, SchemaModel, SchemaModels, SchemaNonModel, SchemaNonModels, CustomOperations, CustomOperation, CustomOperationArguments, CustomOperationArgument, ModelAttribute, SecondaryIndexAttribute, GraphQLProviderConfig, } from './singleton/API/types';
|
|
11
10
|
export { Signer } from './Signer';
|
|
12
|
-
export { JWT,
|
|
11
|
+
export { JWT, CognitoIdentityPoolConfig, JwtPayload, AuthStandardAttributeKey, AuthVerifiableAttributeKey, AWSCredentials, } from './singleton/Auth/types';
|
|
13
12
|
export { haveCredentialsChanged } from './utils/haveCredentialsChanged';
|
|
14
13
|
export { Platform, getAmplifyUserAgentObject, getAmplifyUserAgent, } from './Platform';
|
|
15
14
|
export { ApiAction, AuthAction, AnalyticsAction, Category, CustomUserAgentDetails, DataStoreAction, Framework, GeoAction, InteractionsAction, InAppMessagingAction, PredictionsAction, PubSubAction, PushNotificationAction, StorageAction, SetCustomUserAgentInput, StorageUserAgentInput, AuthUserAgentInput, InAppMessagingUserAgentInput, GeoUserAgentInput, } from './Platform/types';
|
|
@@ -22,10 +21,11 @@ export { Reachability } from './Reachability';
|
|
|
22
21
|
export { USER_AGENT_HEADER } from './constants';
|
|
23
22
|
export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
|
|
24
23
|
export { AMPLIFY_SYMBOL } from './Hub';
|
|
24
|
+
export { StrictUnion } from './types';
|
|
25
25
|
export { base64Decoder, base64Encoder } from './utils/convert';
|
|
26
26
|
export { getCrypto } from './utils/globalHelpers';
|
|
27
27
|
export { cryptoSecureRandomInt } from './utils/cryptoSecureRandomInt';
|
|
28
|
-
export { WordArray };
|
|
28
|
+
export { WordArray } from './utils/WordArray';
|
|
29
29
|
export { HubInternal } from './Hub';
|
|
30
30
|
export { sessionListener } from './utils/sessionListener';
|
|
31
31
|
export { SessionState } from './utils/sessionListener/types';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { default as WordArray } from './utils/WordArray.mjs';
|
|
2
1
|
export { generateRandomString } from './utils/generateRandomString.mjs';
|
|
3
2
|
import './utils/getClientInfo/getClientInfo.mjs';
|
|
4
3
|
export { isBrowser } from './utils/isBrowser.mjs';
|
|
@@ -38,6 +37,7 @@ export { base64Decoder } from './utils/convert/base64/base64Decoder.mjs';
|
|
|
38
37
|
export { base64Encoder } from './utils/convert/base64/base64Encoder.mjs';
|
|
39
38
|
export { getCrypto } from './utils/globalHelpers/index.mjs';
|
|
40
39
|
export { cryptoSecureRandomInt } from './utils/cryptoSecureRandomInt.mjs';
|
|
40
|
+
export { WordArray } from './utils/WordArray.mjs';
|
|
41
41
|
export { sessionListener } from './utils/sessionListener/index.mjs';
|
|
42
42
|
export { SESSION_START_EVENT, SESSION_STOP_EVENT } from './utils/sessionListener/constants.mjs';
|
|
43
43
|
//# sourceMappingURL=libraryUtils.mjs.map
|
|
@@ -85,6 +85,9 @@ export interface ModelIntrospectionSchema {
|
|
|
85
85
|
models: SchemaModels;
|
|
86
86
|
nonModels: SchemaNonModels;
|
|
87
87
|
enums: SchemaEnums;
|
|
88
|
+
queries?: CustomOperations;
|
|
89
|
+
mutations?: CustomOperations;
|
|
90
|
+
subscriptions?: CustomOperations;
|
|
88
91
|
}
|
|
89
92
|
/**
|
|
90
93
|
* Top-level Entities on a Schema
|
|
@@ -92,6 +95,7 @@ export interface ModelIntrospectionSchema {
|
|
|
92
95
|
export type SchemaModels = Record<string, SchemaModel>;
|
|
93
96
|
export type SchemaNonModels = Record<string, SchemaNonModel>;
|
|
94
97
|
export type SchemaEnums = Record<string, SchemaEnum>;
|
|
98
|
+
export type CustomOperations = Record<string, CustomOperation>;
|
|
95
99
|
export interface SchemaModel {
|
|
96
100
|
name: string;
|
|
97
101
|
attributes?: ModelAttribute[];
|
|
@@ -120,6 +124,21 @@ export interface SecondaryIndexAttribute {
|
|
|
120
124
|
fields: string[];
|
|
121
125
|
};
|
|
122
126
|
}
|
|
127
|
+
export interface CustomOperation {
|
|
128
|
+
name: string;
|
|
129
|
+
type: FieldType;
|
|
130
|
+
isArray: boolean;
|
|
131
|
+
isRequired: boolean;
|
|
132
|
+
arguments?: CustomOperationArguments;
|
|
133
|
+
}
|
|
134
|
+
export type CustomOperationArguments = Record<string, CustomOperationArgument>;
|
|
135
|
+
export interface CustomOperationArgument {
|
|
136
|
+
name: string;
|
|
137
|
+
type: FieldType;
|
|
138
|
+
isArray: boolean;
|
|
139
|
+
isRequired: boolean;
|
|
140
|
+
isArrayNullable?: boolean;
|
|
141
|
+
}
|
|
123
142
|
/**
|
|
124
143
|
* Field Definition
|
|
125
144
|
*/
|
|
@@ -137,11 +156,12 @@ export interface Field {
|
|
|
137
156
|
export interface ModelFieldType {
|
|
138
157
|
model: string;
|
|
139
158
|
}
|
|
159
|
+
export interface NonModelFieldType {
|
|
160
|
+
nonModel: string;
|
|
161
|
+
}
|
|
140
162
|
export type FieldType = 'ID' | 'String' | 'Int' | 'Float' | 'AWSDate' | 'AWSTime' | 'AWSDateTime' | 'AWSTimestamp' | 'AWSEmail' | 'AWSURL' | 'AWSIPAddress' | 'Boolean' | 'AWSJSON' | 'AWSPhone' | {
|
|
141
163
|
enum: string;
|
|
142
|
-
} | ModelFieldType |
|
|
143
|
-
nonModel: string;
|
|
144
|
-
};
|
|
164
|
+
} | ModelFieldType | NonModelFieldType;
|
|
145
165
|
export type FieldAttribute = ModelAttribute;
|
|
146
166
|
/**
|
|
147
167
|
* Field-level Relationship Definitions
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StrictUnion } from '../../types';
|
|
1
2
|
import { AtLeastOne } from '../types';
|
|
2
3
|
interface JwtPayloadStandardFields {
|
|
3
4
|
exp?: number;
|
|
@@ -51,6 +52,11 @@ export interface FetchAuthSessionOptions {
|
|
|
51
52
|
export interface AuthTokens {
|
|
52
53
|
idToken?: JWT;
|
|
53
54
|
accessToken: JWT;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated
|
|
57
|
+
* Use getCurrentUser to access signInDetails
|
|
58
|
+
*/
|
|
59
|
+
signInDetails?: AWSAuthSignInDetails;
|
|
54
60
|
}
|
|
55
61
|
export type AuthStandardAttributeKey = 'address' | 'birthdate' | 'email_verified' | 'family_name' | 'gender' | 'given_name' | 'locale' | 'middle_name' | 'name' | 'nickname' | 'phone_number_verified' | 'picture' | 'preferred_username' | 'profile' | 'sub' | 'updated_at' | 'website' | 'zoneinfo' | AuthVerifiableAttributeKey;
|
|
56
62
|
export type LegacyUserAttributeKey = Uppercase<AuthStandardAttributeKey>;
|
|
@@ -60,9 +66,6 @@ export type AuthConfigUserAttributes = Partial<Record<AuthStandardAttributeKey,
|
|
|
60
66
|
}>>;
|
|
61
67
|
export type AuthConfig = AtLeastOne<CognitoProviderConfig>;
|
|
62
68
|
export type CognitoProviderConfig = StrictUnion<AuthIdentityPoolConfig | AuthUserPoolConfig | AuthUserPoolAndIdentityPoolConfig>;
|
|
63
|
-
type UnionKeys<T> = T extends T ? keyof T : never;
|
|
64
|
-
type StrictUnionHelper<T, TAll> = T extends any ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>> : never;
|
|
65
|
-
export type StrictUnion<T> = StrictUnionHelper<T, T>;
|
|
66
69
|
export interface AuthIdentityPoolConfig {
|
|
67
70
|
Cognito: CognitoIdentityPoolConfig & {
|
|
68
71
|
userPoolClientId?: never;
|
|
@@ -156,4 +159,15 @@ export interface AWSCredentials {
|
|
|
156
159
|
sessionToken?: string;
|
|
157
160
|
expiration?: Date;
|
|
158
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* @deprecated
|
|
164
|
+
*/
|
|
165
|
+
interface AWSAuthSignInDetails {
|
|
166
|
+
loginId?: string;
|
|
167
|
+
authFlowType?: AuthFlowType;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* @deprecated
|
|
171
|
+
*/
|
|
172
|
+
type AuthFlowType = 'USER_SRP_AUTH' | 'CUSTOM_WITH_SRP' | 'CUSTOM_WITHOUT_SRP' | 'USER_PASSWORD_AUTH';
|
|
159
173
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StrictUnion } from '../../../types';
|
|
2
|
+
import { AuthConfig, CognitoIdentityPoolConfig, CognitoUserPoolAndIdentityPoolConfig, CognitoUserPoolConfig, JWT, OAuthConfig } from '../types';
|
|
2
3
|
export declare function assertTokenProviderConfig(cognitoConfig?: StrictUnion<CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig | CognitoIdentityPoolConfig>): asserts cognitoConfig is CognitoUserPoolAndIdentityPoolConfig | CognitoUserPoolConfig;
|
|
3
4
|
export declare function assertOAuthConfig(cognitoConfig?: AuthConfig['Cognito']): asserts cognitoConfig is AuthConfig['Cognito'] & {
|
|
4
5
|
loginWith: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FetchAuthSessionOptions } from '../Auth/types';
|
|
2
|
-
export declare const fetchAuthSession: (options?: FetchAuthSessionOptions) => Promise<
|
|
1
|
+
import { AuthSession, FetchAuthSessionOptions } from '../Auth/types';
|
|
2
|
+
export declare const fetchAuthSession: (options?: FetchAuthSessionOptions) => Promise<AuthSession>;
|
|
@@ -6,6 +6,9 @@ import { PredictionsConfig } from './Predictions/types';
|
|
|
6
6
|
import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
|
|
7
7
|
import { NotificationsConfig } from './Notifications/types';
|
|
8
8
|
import { InteractionsConfig } from './Interactions/types';
|
|
9
|
+
/**
|
|
10
|
+
* Compatibility type representing the Amplify Gen 1 configuration file schema. This type should not be used directly.
|
|
11
|
+
*/
|
|
9
12
|
export interface LegacyConfig {
|
|
10
13
|
/**
|
|
11
14
|
* @deprecated The field should not be used.
|
|
@@ -15,6 +18,9 @@ export interface LegacyConfig {
|
|
|
15
18
|
export type AtLeastOne<T, U = {
|
|
16
19
|
[K in keyof T]: Pick<T, K>;
|
|
17
20
|
}> = Partial<T> & U[keyof U];
|
|
21
|
+
/**
|
|
22
|
+
* Amplify library configuration type. Used to specify back-end resource configuration across the library.
|
|
23
|
+
*/
|
|
18
24
|
export interface ResourcesConfig {
|
|
19
25
|
API?: APIConfig;
|
|
20
26
|
Analytics?: AnalyticsConfig;
|
|
@@ -25,6 +31,9 @@ export interface ResourcesConfig {
|
|
|
25
31
|
Storage?: StorageConfig;
|
|
26
32
|
Geo?: GeoConfig;
|
|
27
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Amplify library options type. Used to customize library behavior.
|
|
36
|
+
*/
|
|
28
37
|
export interface LibraryOptions {
|
|
29
38
|
API?: LibraryAPIOptions;
|
|
30
39
|
Auth?: LibraryAuthOptions;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type UnionKeys<T> = T extends T ? keyof T : never;
|
|
2
|
+
type StrictUnionHelper<T, TAll> = T extends any ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>> : never;
|
|
3
|
+
/**
|
|
4
|
+
* Makes a union 'strict', such that members are disallowed from including the keys of other members. E.g.,
|
|
5
|
+
* `{x: 1, y: 1}` is a valid member of `{x: number} | {y: number}` but not of StrictUnion<{x: number} | {y: number}>.
|
|
6
|
+
*/
|
|
7
|
+
export type StrictUnion<T> = StrictUnionHelper<T, T>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WordArray.mjs","sources":["../../../src/utils/WordArray.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { cryptoSecureRandomInt } from './cryptoSecureRandomInt';\n/**\n * Hex encoding strategy.\n * Converts a word array to a hex string.\n * @param {WordArray} wordArray The word array.\n * @return {string} The hex string.\n * @static\n */\nfunction hexStringify(wordArray) {\n // Shortcuts\n const { words } = wordArray;\n const { sigBytes } = wordArray;\n // Convert\n const hexChars = [];\n for (let i = 0; i < sigBytes; i++) {\n const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n hexChars.push((bite >>> 4).toString(16));\n hexChars.push((bite & 0x0f).toString(16));\n }\n return hexChars.join('');\n}\nexport
|
|
1
|
+
{"version":3,"file":"WordArray.mjs","sources":["../../../src/utils/WordArray.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { cryptoSecureRandomInt } from './cryptoSecureRandomInt';\n/**\n * Hex encoding strategy.\n * Converts a word array to a hex string.\n * @param {WordArray} wordArray The word array.\n * @return {string} The hex string.\n * @static\n */\nfunction hexStringify(wordArray) {\n // Shortcuts\n const { words } = wordArray;\n const { sigBytes } = wordArray;\n // Convert\n const hexChars = [];\n for (let i = 0; i < sigBytes; i++) {\n const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n hexChars.push((bite >>> 4).toString(16));\n hexChars.push((bite & 0x0f).toString(16));\n }\n return hexChars.join('');\n}\nexport class WordArray {\n constructor(words, sigBytes) {\n this.words = [];\n let Words = words;\n Words = this.words = Words || [];\n if (sigBytes !== undefined) {\n this.sigBytes = sigBytes;\n }\n else {\n this.sigBytes = Words.length * 4;\n }\n }\n random(nBytes) {\n const words = [];\n for (let i = 0; i < nBytes; i += 4) {\n words.push(cryptoSecureRandomInt());\n }\n return new WordArray(words, nBytes);\n }\n toString() {\n return hexStringify(this);\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,YAAY,CAAC,SAAS,EAAE;AACjC;AACA,IAAI,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;AAChC,IAAI,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;AACnC;AACA,IAAI,MAAM,QAAQ,GAAG,EAAE,CAAC;AACxB,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE;AACvC,QAAQ,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC;AACpE,QAAQ,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,EAAE,QAAQ,CAAC,E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lerna-test.d2b0b08.55+d2b0b087b",
|
|
4
4
|
"description": "Core category of aws-amplify",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"uuid": "^9.0.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@aws-amplify/react-native": "1.0.
|
|
63
|
+
"@aws-amplify/react-native": "1.0.18-experimental-lerna-test.d2b0b08.55+d2b0b087b",
|
|
64
64
|
"@types/js-cookie": "3.0.2",
|
|
65
65
|
"genversion": "^2.2.0",
|
|
66
66
|
"typescript": "5.0.2"
|
|
@@ -192,5 +192,5 @@
|
|
|
192
192
|
]
|
|
193
193
|
}
|
|
194
194
|
},
|
|
195
|
-
"gitHead": "
|
|
195
|
+
"gitHead": "d2b0b087bdaa4db452916b53afff3d664c29cca0"
|
|
196
196
|
}
|
package/src/I18n/index.ts
CHANGED
|
@@ -83,7 +83,7 @@ export class I18n {
|
|
|
83
83
|
* @static
|
|
84
84
|
* @method
|
|
85
85
|
* Add vocabularies for one language
|
|
86
|
-
* @param {String}
|
|
86
|
+
* @param {String} language - Language of the dictionary
|
|
87
87
|
* @param {Object} vocabularies - Object that has key-value as dictionary entry
|
|
88
88
|
*/
|
|
89
89
|
static putVocabulariesForLanguage(
|
|
@@ -35,6 +35,7 @@ export class ConsoleLogger implements Logger {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
static LOG_LEVEL: string | null = null;
|
|
38
|
+
static BIND_ALL_LOG_LEVELS = false;
|
|
38
39
|
|
|
39
40
|
_padding(n: number) {
|
|
40
41
|
return n < 10 ? '0' + n : '' + n;
|
|
@@ -89,6 +90,14 @@ export class ConsoleLogger implements Logger {
|
|
|
89
90
|
if (type === LogType.WARN && console.warn) {
|
|
90
91
|
log = console.warn.bind(console);
|
|
91
92
|
}
|
|
93
|
+
if (ConsoleLogger.BIND_ALL_LOG_LEVELS) {
|
|
94
|
+
if (type === LogType.INFO && console.info) {
|
|
95
|
+
log = console.info.bind(console);
|
|
96
|
+
}
|
|
97
|
+
if (type === LogType.DEBUG && console.debug) {
|
|
98
|
+
log = console.debug.bind(console);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
92
101
|
|
|
93
102
|
const prefix = `[${type}] ${this._ts()} ${this.name}`;
|
|
94
103
|
let message = '';
|
package/src/Platform/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '6.0.
|
|
2
|
+
export const version = '6.0.18-experimental-lerna-test.d2b0b08.55+d2b0b087b';
|
|
@@ -55,8 +55,8 @@ export class ServiceWorkerClass {
|
|
|
55
55
|
* Make sure the service-worker.js is part of the build
|
|
56
56
|
* for example with Angular, modify the angular-cli.json file
|
|
57
57
|
* and add to "assets" array "service-worker.js"
|
|
58
|
-
* @param {string}
|
|
59
|
-
* @param {string}
|
|
58
|
+
* @param {string} filePath Service worker file. Defaults to "/service-worker.js"
|
|
59
|
+
* @param {string} scope The service worker scope. Defaults to "/"
|
|
60
60
|
* - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
|
|
61
61
|
* @returns {Promise}
|
|
62
62
|
* - resolve(ServiceWorkerRegistration)
|
|
@@ -195,7 +195,7 @@ export class ServiceWorkerClass {
|
|
|
195
195
|
* Send a message to the service worker. The service worker needs
|
|
196
196
|
* to implement `self.addEventListener('message') to handle the
|
|
197
197
|
* message. This ***currently*** does not work in Safari or IE.
|
|
198
|
-
* @param {object | string}
|
|
198
|
+
* @param {object | string} message An arbitrary JSON object or string message to send to the service worker
|
|
199
199
|
* - see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable
|
|
200
200
|
* @returns {Promise}
|
|
201
201
|
**/
|
|
@@ -16,7 +16,7 @@ export const getRetryDecider =
|
|
|
16
16
|
(error as Error & { code: string }) ??
|
|
17
17
|
(await errorParser(response)) ??
|
|
18
18
|
undefined;
|
|
19
|
-
const errorCode = parsedError?.code;
|
|
19
|
+
const errorCode = parsedError?.code || parsedError?.name;
|
|
20
20
|
const statusCode = response?.statusCode;
|
|
21
21
|
|
|
22
22
|
return (
|
package/src/index.ts
CHANGED
package/src/libraryUtils.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
/*
|
|
5
5
|
This file maps top-level exports from `@aws-amplify/core/internals/utils`. These are intended to be internal
|
|
6
6
|
utils for use throughout the library.
|
|
7
7
|
*/
|
|
8
|
+
|
|
8
9
|
// Core utilities
|
|
9
10
|
export {
|
|
10
11
|
generateRandomString,
|
|
@@ -40,9 +41,16 @@ export {
|
|
|
40
41
|
DocumentType,
|
|
41
42
|
GraphQLAuthMode,
|
|
42
43
|
ModelFieldType,
|
|
44
|
+
NonModelFieldType,
|
|
43
45
|
ModelIntrospectionSchema,
|
|
44
46
|
SchemaModel,
|
|
45
47
|
SchemaModels,
|
|
48
|
+
SchemaNonModel,
|
|
49
|
+
SchemaNonModels,
|
|
50
|
+
CustomOperations,
|
|
51
|
+
CustomOperation,
|
|
52
|
+
CustomOperationArguments,
|
|
53
|
+
CustomOperationArgument,
|
|
46
54
|
ModelAttribute,
|
|
47
55
|
SecondaryIndexAttribute,
|
|
48
56
|
GraphQLProviderConfig,
|
|
@@ -50,7 +58,6 @@ export {
|
|
|
50
58
|
export { Signer } from './Signer';
|
|
51
59
|
export {
|
|
52
60
|
JWT,
|
|
53
|
-
StrictUnion,
|
|
54
61
|
CognitoIdentityPoolConfig,
|
|
55
62
|
JwtPayload,
|
|
56
63
|
AuthStandardAttributeKey,
|
|
@@ -112,10 +119,11 @@ export { Reachability } from './Reachability';
|
|
|
112
119
|
export { USER_AGENT_HEADER } from './constants';
|
|
113
120
|
export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
|
|
114
121
|
export { AMPLIFY_SYMBOL } from './Hub';
|
|
122
|
+
export { StrictUnion } from './types';
|
|
115
123
|
export { base64Decoder, base64Encoder } from './utils/convert';
|
|
116
124
|
export { getCrypto } from './utils/globalHelpers';
|
|
117
125
|
export { cryptoSecureRandomInt } from './utils/cryptoSecureRandomInt';
|
|
118
|
-
export { WordArray };
|
|
126
|
+
export { WordArray } from './utils/WordArray';
|
|
119
127
|
|
|
120
128
|
// Hub
|
|
121
129
|
export { HubInternal } from './Hub';
|
|
@@ -106,6 +106,9 @@ export interface ModelIntrospectionSchema {
|
|
|
106
106
|
models: SchemaModels;
|
|
107
107
|
nonModels: SchemaNonModels;
|
|
108
108
|
enums: SchemaEnums;
|
|
109
|
+
queries?: CustomOperations;
|
|
110
|
+
mutations?: CustomOperations;
|
|
111
|
+
subscriptions?: CustomOperations;
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
/**
|
|
@@ -114,6 +117,7 @@ export interface ModelIntrospectionSchema {
|
|
|
114
117
|
export type SchemaModels = Record<string, SchemaModel>;
|
|
115
118
|
export type SchemaNonModels = Record<string, SchemaNonModel>;
|
|
116
119
|
export type SchemaEnums = Record<string, SchemaEnum>;
|
|
120
|
+
export type CustomOperations = Record<string, CustomOperation>;
|
|
117
121
|
|
|
118
122
|
export interface SchemaModel {
|
|
119
123
|
name: string;
|
|
@@ -146,6 +150,24 @@ export interface SecondaryIndexAttribute {
|
|
|
146
150
|
};
|
|
147
151
|
}
|
|
148
152
|
|
|
153
|
+
export interface CustomOperation {
|
|
154
|
+
name: string;
|
|
155
|
+
type: FieldType;
|
|
156
|
+
isArray: boolean;
|
|
157
|
+
isRequired: boolean;
|
|
158
|
+
arguments?: CustomOperationArguments;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export type CustomOperationArguments = Record<string, CustomOperationArgument>;
|
|
162
|
+
|
|
163
|
+
export interface CustomOperationArgument {
|
|
164
|
+
name: string;
|
|
165
|
+
type: FieldType;
|
|
166
|
+
isArray: boolean;
|
|
167
|
+
isRequired: boolean;
|
|
168
|
+
isArrayNullable?: boolean;
|
|
169
|
+
}
|
|
170
|
+
|
|
149
171
|
/**
|
|
150
172
|
* Field Definition
|
|
151
173
|
*/
|
|
@@ -164,6 +186,9 @@ export interface Field {
|
|
|
164
186
|
export interface ModelFieldType {
|
|
165
187
|
model: string;
|
|
166
188
|
}
|
|
189
|
+
export interface NonModelFieldType {
|
|
190
|
+
nonModel: string;
|
|
191
|
+
}
|
|
167
192
|
|
|
168
193
|
export type FieldType =
|
|
169
194
|
| 'ID'
|
|
@@ -182,7 +207,7 @@ export type FieldType =
|
|
|
182
207
|
| 'AWSPhone'
|
|
183
208
|
| { enum: string }
|
|
184
209
|
| ModelFieldType
|
|
185
|
-
|
|
|
210
|
+
| NonModelFieldType;
|
|
186
211
|
export type FieldAttribute = ModelAttribute;
|
|
187
212
|
|
|
188
213
|
/**
|