@aws-amplify/core 6.0.1-api-v6-models.8035dfc.0 → 6.0.1-api-v6-models.572a7b5.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.
- package/lib/Cache/StorageCache.d.ts +14 -31
- package/lib/Cache/StorageCache.js +97 -102
- package/lib/Cache/StorageCache.native.d.ts +19 -0
- package/lib/Cache/StorageCache.native.js +164 -0
- package/{lib-esm/Cache/AsyncStorageCache.d.ts → lib/Cache/StorageCacheCommon.d.ts} +124 -99
- package/lib/Cache/{AsyncStorageCache.js → StorageCacheCommon.js} +494 -432
- package/lib/Cache/constants.d.ts +6 -0
- package/lib/Cache/constants.js +17 -0
- package/lib/Cache/index.d.ts +2 -0
- package/lib/Cache/index.js +7 -0
- package/lib/Cache/types/cache.d.ts +38 -0
- package/lib/Cache/types/index.d.ts +1 -1
- package/lib/Cache/types/index.js +1 -1
- package/lib/Cache/{Utils → utils}/CacheList.d.ts +1 -1
- package/lib/Cache/{Utils → utils}/CacheList.js +2 -1
- package/lib/Cache/utils/cacheHelpers.d.ts +14 -0
- package/lib/Cache/utils/cacheHelpers.js +51 -0
- package/lib/Cache/{Utils → utils}/errorHelpers.d.ts +0 -1
- package/lib/Cache/{Utils → utils}/errorHelpers.js +0 -4
- package/lib/Cache/utils/index.d.ts +2 -0
- package/lib/Cache/utils/index.js +12 -0
- package/lib/I18n/I18n.js +1 -6
- package/lib/Platform/types.d.ts +18 -8
- package/lib/Platform/types.js +10 -2
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Reachability/Reachability.d.ts +1 -0
- package/lib/Reachability/Reachability.js +42 -1
- package/lib/ServiceWorker/ServiceWorker.js +69 -17
- package/lib/ServiceWorker/index.d.ts +0 -12
- package/lib/ServiceWorker/index.js +0 -12
- package/lib/Signer/Signer.js +3 -2
- package/lib/awsClients/cognitoIdentity/base.js +2 -1
- package/lib/awsClients/pinpoint/base.js +2 -1
- package/lib/awsClients/pinpoint/getInAppMessages.js +2 -1
- package/lib/awsClients/pinpoint/putEvents.js +2 -1
- package/lib/awsClients/pinpoint/updateEndpoint.js +2 -1
- package/lib/clients/middleware/signing/signer/signatureV4/index.d.ts +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/index.js +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.js +2 -1
- package/lib/errors/errorHelpers.d.ts +2 -0
- package/lib/errors/errorHelpers.js +20 -0
- package/lib/errors/index.d.ts +1 -0
- package/lib/errors/index.js +3 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.js +9 -6
- package/lib/libraryUtils.d.ts +8 -7
- package/lib/libraryUtils.js +17 -17
- package/lib/parseAWSExports.js +34 -19
- package/lib/providers/pinpoint/apis/flushEvents.d.ts +2 -2
- package/lib/providers/pinpoint/apis/record.d.ts +1 -1
- package/lib/providers/pinpoint/apis/record.js +8 -24
- package/lib/providers/pinpoint/apis/updateEndpoint.js +6 -6
- package/lib/providers/pinpoint/index.d.ts +2 -2
- package/lib/providers/pinpoint/index.js +4 -2
- package/lib/providers/pinpoint/types/errors.d.ts +9 -0
- package/lib/providers/pinpoint/types/errors.js +15 -0
- package/lib/providers/pinpoint/types/index.d.ts +1 -0
- package/lib/providers/pinpoint/types/index.js +3 -0
- package/lib/providers/pinpoint/types/pinpoint.d.ts +3 -3
- package/lib/providers/pinpoint/utils/index.d.ts +1 -0
- package/lib/providers/pinpoint/utils/index.js +3 -1
- package/lib/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
- package/lib/providers/pinpoint/utils/resolveEndpointId.js +85 -0
- package/lib/singleton/Amplify.d.ts +2 -2
- package/lib/singleton/Amplify.js +6 -5
- package/lib/singleton/Auth/types.d.ts +3 -3
- package/lib/singleton/Cache/types.d.ts +18 -0
- package/lib/singleton/Cache/types.js +4 -0
- package/lib/singleton/Interactions/types.d.ts +21 -0
- package/lib/singleton/Interactions/types.js +4 -0
- package/lib/singleton/Notifications/PushNotification/types.d.ts +2 -0
- package/lib/singleton/Notifications/PushNotification/types.js +4 -0
- package/lib/singleton/Notifications/types.d.ts +3 -1
- package/lib/singleton/types.d.ts +3 -3
- package/lib/storage/CookieStorage.js +8 -5
- package/lib/storage/DefaultStorage.js +1 -1
- package/lib/storage/utils.d.ts +1 -1
- package/lib/storage/utils.js +3 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/errors.d.ts +1 -0
- package/lib/types/errors.js +1 -0
- package/lib/utils/amplifyUrl/index.d.ts +13 -0
- package/lib/utils/amplifyUrl/index.js +10 -0
- package/lib/utils/amplifyUrl/polyfill.d.ts +0 -0
- package/lib/utils/amplifyUrl/polyfill.js +4 -0
- package/lib/utils/amplifyUrl/polyfill.native.d.ts +1 -0
- package/lib/utils/amplifyUuid/index.d.ts +3 -0
- package/lib/utils/amplifyUuid/index.js +9 -0
- package/lib/utils/amplifyUuid/polyfill.d.ts +0 -0
- package/lib/utils/amplifyUuid/polyfill.js +4 -0
- package/lib/utils/amplifyUuid/polyfill.native.d.ts +1 -0
- package/lib/utils/amplifyUuid/polyfill.native.js +6 -0
- package/lib/utils/deepFreeze.d.ts +1 -0
- package/lib/utils/deepFreeze.js +38 -0
- package/lib/{ClientDevice/android.d.ts → utils/getClientInfo/getClientInfo.android.d.ts} +1 -1
- package/lib/{ClientDevice/android.js → utils/getClientInfo/getClientInfo.android.js} +4 -4
- package/lib/{ClientDevice/browser.d.ts → utils/getClientInfo/getClientInfo.d.ts} +1 -9
- package/lib/{ClientDevice/ios.d.ts → utils/getClientInfo/getClientInfo.ios.d.ts} +1 -1
- package/lib/{ClientDevice/ios.js → utils/getClientInfo/getClientInfo.ios.js} +4 -4
- package/lib/{ClientDevice/browser.js → utils/getClientInfo/getClientInfo.js} +6 -18
- package/lib/utils/getClientInfo/index.d.ts +1 -0
- package/lib/utils/getClientInfo/index.js +7 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +5 -1
- package/lib/utils/sessionListener/SessionListener.d.ts +10 -0
- package/lib/utils/sessionListener/SessionListener.js +55 -0
- package/lib/utils/sessionListener/SessionListener.native.d.ts +10 -0
- package/lib/utils/sessionListener/SessionListener.native.js +54 -0
- package/lib/utils/sessionListener/index.d.ts +2 -0
- package/lib/utils/sessionListener/index.js +7 -0
- package/lib/utils/sessionListener/types.d.ts +6 -0
- package/lib/utils/sessionListener/types.js +4 -0
- package/lib-esm/Cache/StorageCache.d.ts +14 -31
- package/lib-esm/Cache/StorageCache.js +97 -102
- package/lib-esm/Cache/StorageCache.native.d.ts +19 -0
- package/lib-esm/Cache/StorageCache.native.js +161 -0
- package/{lib/Cache/AsyncStorageCache.d.ts → lib-esm/Cache/StorageCacheCommon.d.ts} +124 -99
- package/lib-esm/Cache/{AsyncStorageCache.js → StorageCacheCommon.js} +493 -430
- package/lib-esm/Cache/constants.d.ts +6 -0
- package/lib-esm/Cache/constants.js +14 -0
- package/lib-esm/Cache/index.d.ts +2 -0
- package/lib-esm/Cache/index.js +4 -0
- package/lib-esm/Cache/types/cache.d.ts +38 -0
- package/lib-esm/Cache/types/index.d.ts +1 -1
- package/lib-esm/Cache/types/index.js +1 -1
- package/lib-esm/Cache/{Utils → utils}/CacheList.d.ts +1 -1
- package/lib-esm/Cache/{Utils → utils}/CacheList.js +1 -1
- package/lib-esm/Cache/utils/cacheHelpers.d.ts +14 -0
- package/lib-esm/Cache/utils/cacheHelpers.js +44 -0
- package/lib-esm/Cache/{Utils → utils}/errorHelpers.d.ts +0 -1
- package/lib-esm/Cache/{Utils → utils}/errorHelpers.js +0 -4
- package/lib-esm/Cache/utils/index.d.ts +2 -0
- package/lib-esm/Cache/utils/index.js +4 -0
- package/lib-esm/I18n/I18n.js +1 -6
- package/lib-esm/Platform/types.d.ts +18 -8
- package/lib-esm/Platform/types.js +10 -2
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Reachability/Reachability.d.ts +1 -0
- package/lib-esm/Reachability/Reachability.js +43 -2
- package/lib-esm/ServiceWorker/ServiceWorker.js +69 -17
- package/lib-esm/ServiceWorker/index.d.ts +0 -12
- package/lib-esm/ServiceWorker/index.js +0 -12
- package/lib-esm/Signer/Signer.js +3 -2
- package/lib-esm/awsClients/cognitoIdentity/base.js +2 -1
- package/lib-esm/awsClients/pinpoint/base.js +2 -1
- package/lib-esm/awsClients/pinpoint/getInAppMessages.js +2 -1
- package/lib-esm/awsClients/pinpoint/putEvents.js +2 -1
- package/lib-esm/awsClients/pinpoint/updateEndpoint.js +2 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.d.ts +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.js +2 -1
- package/lib-esm/errors/errorHelpers.d.ts +2 -0
- package/lib-esm/errors/errorHelpers.js +17 -0
- package/lib-esm/errors/index.d.ts +1 -0
- package/lib-esm/errors/index.js +1 -0
- package/lib-esm/index.d.ts +4 -4
- package/lib-esm/index.js +5 -4
- package/lib-esm/libraryUtils.d.ts +8 -7
- package/lib-esm/libraryUtils.js +7 -7
- package/lib-esm/parseAWSExports.js +34 -19
- package/lib-esm/providers/pinpoint/apis/flushEvents.d.ts +2 -2
- package/lib-esm/providers/pinpoint/apis/record.d.ts +1 -1
- package/lib-esm/providers/pinpoint/apis/record.js +9 -25
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +6 -6
- package/lib-esm/providers/pinpoint/index.d.ts +2 -2
- package/lib-esm/providers/pinpoint/index.js +2 -1
- package/lib-esm/providers/pinpoint/types/errors.d.ts +9 -0
- package/lib-esm/providers/pinpoint/types/errors.js +12 -0
- package/lib-esm/providers/pinpoint/types/index.d.ts +1 -0
- package/lib-esm/providers/pinpoint/types/index.js +1 -0
- package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +3 -3
- package/lib-esm/providers/pinpoint/utils/index.d.ts +1 -0
- package/lib-esm/providers/pinpoint/utils/index.js +1 -0
- package/lib-esm/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
- package/lib-esm/providers/pinpoint/utils/resolveEndpointId.js +81 -0
- package/lib-esm/singleton/Amplify.d.ts +2 -2
- package/lib-esm/singleton/Amplify.js +6 -5
- package/lib-esm/singleton/Auth/types.d.ts +3 -3
- package/lib-esm/singleton/Cache/types.d.ts +18 -0
- package/lib-esm/singleton/Cache/types.js +3 -0
- package/lib-esm/singleton/Interactions/types.d.ts +21 -0
- package/lib-esm/singleton/Interactions/types.js +3 -0
- package/lib-esm/singleton/Notifications/PushNotification/types.d.ts +2 -0
- package/lib-esm/singleton/Notifications/PushNotification/types.js +3 -0
- package/lib-esm/singleton/Notifications/types.d.ts +3 -1
- package/lib-esm/singleton/types.d.ts +3 -3
- package/lib-esm/storage/CookieStorage.js +5 -5
- package/lib-esm/storage/DefaultStorage.js +2 -2
- package/lib-esm/storage/utils.d.ts +1 -1
- package/lib-esm/storage/utils.js +1 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/errors.d.ts +1 -0
- package/lib-esm/types/errors.js +1 -0
- package/lib-esm/utils/amplifyUrl/index.d.ts +13 -0
- package/lib-esm/utils/amplifyUrl/index.js +6 -0
- package/lib-esm/utils/amplifyUuid/index.d.ts +3 -0
- package/lib-esm/utils/amplifyUuid/index.js +6 -0
- package/lib-esm/utils/amplifyUuid/polyfill.native.js +4 -0
- package/lib-esm/utils/deepFreeze.d.ts +1 -0
- package/lib-esm/utils/deepFreeze.js +34 -0
- package/lib-esm/{ClientDevice/android.d.ts → utils/getClientInfo/getClientInfo.android.d.ts} +1 -1
- package/lib-esm/{ClientDevice/android.js → utils/getClientInfo/getClientInfo.android.js} +2 -2
- package/lib-esm/{ClientDevice/browser.d.ts → utils/getClientInfo/getClientInfo.d.ts} +1 -9
- package/lib-esm/{ClientDevice/ios.d.ts → utils/getClientInfo/getClientInfo.ios.d.ts} +1 -1
- package/lib-esm/{ClientDevice/ios.js → utils/getClientInfo/getClientInfo.ios.js} +2 -2
- package/lib-esm/{ClientDevice/browser.js → utils/getClientInfo/getClientInfo.js} +4 -14
- package/lib-esm/utils/getClientInfo/index.d.ts +1 -0
- package/lib-esm/utils/getClientInfo/index.js +3 -0
- package/lib-esm/utils/index.d.ts +2 -0
- package/lib-esm/utils/index.js +2 -0
- package/lib-esm/utils/sessionListener/SessionListener.d.ts +10 -0
- package/lib-esm/utils/sessionListener/SessionListener.js +52 -0
- package/lib-esm/utils/sessionListener/SessionListener.native.d.ts +10 -0
- package/lib-esm/utils/sessionListener/SessionListener.native.js +51 -0
- package/lib-esm/utils/sessionListener/index.d.ts +2 -0
- package/lib-esm/utils/sessionListener/index.js +4 -0
- package/lib-esm/utils/sessionListener/types.d.ts +6 -0
- package/lib-esm/utils/sessionListener/types.js +3 -0
- package/package.json +9 -19
- package/src/Cache/StorageCache.native.ts +65 -0
- package/src/Cache/StorageCache.ts +61 -158
- package/src/Cache/StorageCacheCommon.ts +577 -0
- package/src/Cache/constants.ts +18 -0
- package/src/Cache/index.ts +6 -0
- package/src/Cache/types/cache.ts +51 -0
- package/src/Cache/types/index.ts +4 -4
- package/src/Cache/{Utils → utils}/CacheList.ts +185 -185
- package/src/Cache/utils/cacheHelpers.ts +52 -0
- package/src/Cache/{Utils → utils}/errorHelpers.ts +0 -4
- package/src/Cache/{Utils → utils}/index.ts +4 -5
- package/src/I18n/I18n.ts +1 -6
- package/src/Platform/types.ts +20 -11
- package/src/Platform/version.ts +1 -1
- package/src/Reachability/Reachability.ts +22 -2
- package/src/ServiceWorker/ServiceWorker.ts +20 -17
- package/src/ServiceWorker/index.ts +0 -12
- package/src/Signer/Signer.ts +3 -2
- package/src/awsClients/cognitoIdentity/base.ts +4 -1
- package/src/awsClients/pinpoint/base.ts +2 -1
- package/src/awsClients/pinpoint/getInAppMessages.ts +2 -1
- package/src/awsClients/pinpoint/putEvents.ts +2 -1
- package/src/awsClients/pinpoint/updateEndpoint.ts +2 -1
- package/src/clients/middleware/signing/signer/signatureV4/index.ts +0 -2
- package/src/clients/middleware/signing/signer/signatureV4/presignUrl.ts +2 -1
- package/src/errors/errorHelpers.ts +20 -0
- package/src/errors/index.ts +1 -0
- package/src/index.ts +8 -4
- package/src/libraryUtils.ts +17 -11
- package/src/parseAWSExports.ts +28 -9
- package/src/providers/pinpoint/apis/flushEvents.ts +2 -2
- package/src/providers/pinpoint/apis/record.ts +14 -28
- package/src/providers/pinpoint/apis/updateEndpoint.ts +6 -6
- package/src/providers/pinpoint/index.ts +6 -2
- package/src/providers/pinpoint/types/errors.ts +12 -0
- package/src/providers/pinpoint/types/index.ts +1 -0
- package/src/providers/pinpoint/types/pinpoint.ts +3 -2
- package/src/providers/pinpoint/utils/index.ts +1 -0
- package/src/providers/pinpoint/utils/resolveEndpointId.ts +46 -0
- package/src/singleton/Amplify.ts +10 -8
- package/src/singleton/Auth/types.ts +3 -3
- package/src/singleton/Cache/types.ts +27 -0
- package/src/singleton/Interactions/types.ts +29 -0
- package/src/singleton/Notifications/PushNotification/types.ts +6 -0
- package/src/singleton/Notifications/types.ts +3 -1
- package/src/singleton/types.ts +3 -5
- package/src/storage/CookieStorage.ts +5 -9
- package/src/storage/DefaultStorage.ts +2 -2
- package/src/storage/utils.ts +1 -1
- package/src/types/errors.ts +1 -0
- package/src/utils/amplifyUrl/index.ts +9 -0
- package/src/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.ts → utils/amplifyUrl/polyfill.native.ts} +1 -0
- package/src/utils/amplifyUuid/index.ts +9 -0
- package/src/utils/amplifyUuid/polyfill.native.ts +6 -0
- package/src/utils/amplifyUuid/polyfill.ts +4 -0
- package/src/utils/deepFreeze.ts +16 -0
- package/src/{ClientDevice/android.ts → utils/getClientInfo/getClientInfo.android.ts} +2 -2
- package/src/{ClientDevice/ios.ts → utils/getClientInfo/getClientInfo.ios.ts} +3 -3
- package/src/{ClientDevice/browser.ts → utils/getClientInfo/getClientInfo.ts} +4 -16
- package/src/utils/getClientInfo/index.ts +4 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/sessionListener/SessionListener.native.ts +70 -0
- package/src/utils/sessionListener/SessionListener.ts +74 -0
- package/src/utils/sessionListener/index.ts +6 -0
- package/src/utils/sessionListener/types.ts +11 -0
- package/lib/Amplify.d.ts +0 -29
- package/lib/Amplify.js +0 -118
- package/lib/Cache/BrowserStorageCache.d.ts +0 -166
- package/lib/Cache/BrowserStorageCache.js +0 -456
- package/lib/Cache/InMemoryCache.d.ts +0 -129
- package/lib/Cache/InMemoryCache.js +0 -342
- package/lib/Cache/Utils/CacheUtils.d.ts +0 -25
- package/lib/Cache/Utils/CacheUtils.js +0 -86
- package/lib/Cache/Utils/index.d.ts +0 -2
- package/lib/Cache/Utils/index.js +0 -16
- package/lib/Cache/reactnative.d.ts +0 -3
- package/lib/Cache/reactnative.js +0 -8
- package/lib/Cache/types/Cache.d.ts +0 -55
- package/lib/ClientDevice/index.d.ts +0 -23
- package/lib/ClientDevice/index.js +0 -18
- package/lib/ClientDevice/reactnative.d.ts +0 -7
- package/lib/ClientDevice/reactnative.js +0 -24
- package/lib-esm/Amplify.d.ts +0 -29
- package/lib-esm/Amplify.js +0 -115
- package/lib-esm/Cache/BrowserStorageCache.d.ts +0 -166
- package/lib-esm/Cache/BrowserStorageCache.js +0 -453
- package/lib-esm/Cache/InMemoryCache.d.ts +0 -129
- package/lib-esm/Cache/InMemoryCache.js +0 -339
- package/lib-esm/Cache/Utils/CacheUtils.d.ts +0 -25
- package/lib-esm/Cache/Utils/CacheUtils.js +0 -79
- package/lib-esm/Cache/Utils/index.d.ts +0 -2
- package/lib-esm/Cache/Utils/index.js +0 -4
- package/lib-esm/Cache/reactnative.d.ts +0 -3
- package/lib-esm/Cache/reactnative.js +0 -6
- package/lib-esm/Cache/types/Cache.d.ts +0 -55
- package/lib-esm/ClientDevice/index.d.ts +0 -23
- package/lib-esm/ClientDevice/index.js +0 -15
- package/lib-esm/ClientDevice/reactnative.d.ts +0 -7
- package/lib-esm/ClientDevice/reactnative.js +0 -21
- package/src/Amplify.ts +0 -106
- package/src/Cache/AsyncStorageCache.ts +0 -495
- package/src/Cache/BrowserStorageCache.ts +0 -504
- package/src/Cache/CHANGELOG.md +0 -1239
- package/src/Cache/InMemoryCache.ts +0 -347
- package/src/Cache/Utils/CacheUtils.ts +0 -90
- package/src/Cache/reactnative.ts +0 -9
- package/src/Cache/types/Cache.ts +0 -75
- package/src/ClientDevice/index.ts +0 -14
- package/src/ClientDevice/reactnative.ts +0 -18
- package/lib/Cache/types/{Cache.js → cache.js} +0 -0
- package/lib/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.js → utils/amplifyUrl/polyfill.native.js} +1 -1
- /package/lib-esm/Cache/types/{Cache.js → cache.js} +0 -0
- /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.d.ts → utils/amplifyUrl/polyfill.d.ts} +0 -0
- /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.js → utils/amplifyUrl/polyfill.js} +0 -0
- /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.d.ts → utils/amplifyUrl/polyfill.native.d.ts} +0 -0
- /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.js → utils/amplifyUrl/polyfill.native.js} +0 -0
- /package/{lib/clients/middleware/signing/signer/signatureV4/polyfills/index.d.ts → lib-esm/utils/amplifyUuid/polyfill.d.ts} +0 -0
- /package/{lib/clients/middleware/signing/signer/signatureV4/polyfills/index.js → lib-esm/utils/amplifyUuid/polyfill.js} +0 -0
- /package/{lib/clients/middleware/signing/signer/signatureV4/polyfills/index.native.d.ts → lib-esm/utils/amplifyUuid/polyfill.native.d.ts} +0 -0
- /package/src/{clients/middleware/signing/signer/signatureV4/polyfills/index.ts → utils/amplifyUrl/polyfill.ts} +0 -0
|
@@ -1,185 +1,185 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { assert, CacheErrorCode } from './errorHelpers';
|
|
5
|
-
|
|
6
|
-
class DoubleLinkedNode {
|
|
7
|
-
key: string;
|
|
8
|
-
prevNode: DoubleLinkedNode | null;
|
|
9
|
-
nextNode: DoubleLinkedNode | null;
|
|
10
|
-
|
|
11
|
-
constructor(keyVal?: string) {
|
|
12
|
-
this.key = keyVal ? keyVal : '';
|
|
13
|
-
this.prevNode = null;
|
|
14
|
-
this.nextNode = null;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* double linked list plus a hash table inside
|
|
20
|
-
* each key in the cache stored as a node in the list
|
|
21
|
-
* recently visited node will be rotated to the head
|
|
22
|
-
* so the Last Recently Visited node will be at the tail
|
|
23
|
-
*
|
|
24
|
-
* @member head - dummy head of the linked list
|
|
25
|
-
* @member tail - dummy tail of the linked list
|
|
26
|
-
* @member hashtable - the hashtable which maps cache key to list node
|
|
27
|
-
* @member length - length of the list
|
|
28
|
-
*/
|
|
29
|
-
export
|
|
30
|
-
private head: DoubleLinkedNode;
|
|
31
|
-
private tail: DoubleLinkedNode;
|
|
32
|
-
private hashtable: Record<string, any>;
|
|
33
|
-
private length: number;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* initialization
|
|
37
|
-
*/
|
|
38
|
-
constructor() {
|
|
39
|
-
this.head = new DoubleLinkedNode();
|
|
40
|
-
this.tail = new DoubleLinkedNode();
|
|
41
|
-
this.hashtable = {};
|
|
42
|
-
this.length = 0;
|
|
43
|
-
|
|
44
|
-
this.head.nextNode = this.tail;
|
|
45
|
-
this.tail.prevNode = this.head;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* insert node to the head of the list
|
|
50
|
-
*
|
|
51
|
-
* @param node
|
|
52
|
-
*/
|
|
53
|
-
private insertNodeToHead(node: DoubleLinkedNode) {
|
|
54
|
-
const tmp: DoubleLinkedNode | null = this.head.nextNode;
|
|
55
|
-
this.head.nextNode = node;
|
|
56
|
-
node.nextNode = tmp;
|
|
57
|
-
node.prevNode = this.head;
|
|
58
|
-
assert(tmp !== null, CacheErrorCode.NullPreviousNode);
|
|
59
|
-
tmp.prevNode = node;
|
|
60
|
-
|
|
61
|
-
this.length = this.length + 1;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* remove node
|
|
66
|
-
*
|
|
67
|
-
* @param node
|
|
68
|
-
*/
|
|
69
|
-
private removeNode(node: DoubleLinkedNode): void {
|
|
70
|
-
assert(node.prevNode !== null, CacheErrorCode.NullPreviousNode);
|
|
71
|
-
assert(node.nextNode !== null, CacheErrorCode.NullNextNode);
|
|
72
|
-
node.prevNode.nextNode = node.nextNode;
|
|
73
|
-
node.nextNode.prevNode = node.prevNode;
|
|
74
|
-
|
|
75
|
-
node.prevNode = null;
|
|
76
|
-
node.nextNode = null;
|
|
77
|
-
|
|
78
|
-
this.length = this.length - 1;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @return true if list is empty
|
|
83
|
-
*/
|
|
84
|
-
public isEmpty(): boolean {
|
|
85
|
-
return this.length === 0;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* refresh node so it is rotated to the head
|
|
90
|
-
*
|
|
91
|
-
* @param key - key of the node
|
|
92
|
-
*/
|
|
93
|
-
public refresh(key: string): void {
|
|
94
|
-
const node: DoubleLinkedNode = this.hashtable[key];
|
|
95
|
-
this.removeNode(node);
|
|
96
|
-
this.insertNodeToHead(node);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* insert new node to the head and add it in the hashtable
|
|
101
|
-
*
|
|
102
|
-
* @param key - the key of the node
|
|
103
|
-
*/
|
|
104
|
-
public insertItem(key: string): void {
|
|
105
|
-
const node: DoubleLinkedNode = new DoubleLinkedNode(key);
|
|
106
|
-
this.hashtable[key] = node;
|
|
107
|
-
this.insertNodeToHead(node);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* @return the LAST Recently Visited key
|
|
112
|
-
*/
|
|
113
|
-
public getLastItem(): string {
|
|
114
|
-
assert(this.tail.prevNode !== null, CacheErrorCode.NullPreviousNode);
|
|
115
|
-
return this.tail.prevNode.key;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* remove the cache key from the list and hashtable
|
|
120
|
-
* @param key - the key of the node
|
|
121
|
-
*/
|
|
122
|
-
public removeItem(key: string): void {
|
|
123
|
-
const removedItem: DoubleLinkedNode = this.hashtable[key];
|
|
124
|
-
this.removeNode(removedItem);
|
|
125
|
-
delete this.hashtable[key];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @return length of the list
|
|
130
|
-
*/
|
|
131
|
-
public getSize(): number {
|
|
132
|
-
return this.length;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @return true if the key is in the hashtable
|
|
137
|
-
* @param key
|
|
138
|
-
*/
|
|
139
|
-
public containsKey(key: string): boolean {
|
|
140
|
-
return key in this.hashtable;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* clean up the list and hashtable
|
|
145
|
-
*/
|
|
146
|
-
public clearList(): void {
|
|
147
|
-
for (const key of Object.keys(this.hashtable)) {
|
|
148
|
-
if (this.hashtable.hasOwnProperty(key)) {
|
|
149
|
-
delete this.hashtable[key];
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
this.head.nextNode = this.tail;
|
|
153
|
-
this.tail.prevNode = this.head;
|
|
154
|
-
this.length = 0;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* @return all keys in the hashtable
|
|
159
|
-
*/
|
|
160
|
-
public getKeys(): string[] {
|
|
161
|
-
return Object.keys(this.hashtable);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* mainly for test
|
|
166
|
-
*
|
|
167
|
-
* @param key
|
|
168
|
-
* @return true if key is the head node
|
|
169
|
-
*/
|
|
170
|
-
public isHeadNode(key: string): boolean {
|
|
171
|
-
const node = this.hashtable[key];
|
|
172
|
-
return node.prevNode === this.head;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* mainly for test
|
|
177
|
-
*
|
|
178
|
-
* @param key
|
|
179
|
-
* @return true if key is the tail node
|
|
180
|
-
*/
|
|
181
|
-
public isTailNode(key: string): boolean {
|
|
182
|
-
const node = this.hashtable[key];
|
|
183
|
-
return node.nextNode === this.tail;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { assert, CacheErrorCode } from './errorHelpers';
|
|
5
|
+
|
|
6
|
+
class DoubleLinkedNode {
|
|
7
|
+
key: string;
|
|
8
|
+
prevNode: DoubleLinkedNode | null;
|
|
9
|
+
nextNode: DoubleLinkedNode | null;
|
|
10
|
+
|
|
11
|
+
constructor(keyVal?: string) {
|
|
12
|
+
this.key = keyVal ? keyVal : '';
|
|
13
|
+
this.prevNode = null;
|
|
14
|
+
this.nextNode = null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* double linked list plus a hash table inside
|
|
20
|
+
* each key in the cache stored as a node in the list
|
|
21
|
+
* recently visited node will be rotated to the head
|
|
22
|
+
* so the Last Recently Visited node will be at the tail
|
|
23
|
+
*
|
|
24
|
+
* @member head - dummy head of the linked list
|
|
25
|
+
* @member tail - dummy tail of the linked list
|
|
26
|
+
* @member hashtable - the hashtable which maps cache key to list node
|
|
27
|
+
* @member length - length of the list
|
|
28
|
+
*/
|
|
29
|
+
export class CacheList {
|
|
30
|
+
private head: DoubleLinkedNode;
|
|
31
|
+
private tail: DoubleLinkedNode;
|
|
32
|
+
private hashtable: Record<string, any>;
|
|
33
|
+
private length: number;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* initialization
|
|
37
|
+
*/
|
|
38
|
+
constructor() {
|
|
39
|
+
this.head = new DoubleLinkedNode();
|
|
40
|
+
this.tail = new DoubleLinkedNode();
|
|
41
|
+
this.hashtable = {};
|
|
42
|
+
this.length = 0;
|
|
43
|
+
|
|
44
|
+
this.head.nextNode = this.tail;
|
|
45
|
+
this.tail.prevNode = this.head;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* insert node to the head of the list
|
|
50
|
+
*
|
|
51
|
+
* @param node
|
|
52
|
+
*/
|
|
53
|
+
private insertNodeToHead(node: DoubleLinkedNode) {
|
|
54
|
+
const tmp: DoubleLinkedNode | null = this.head.nextNode;
|
|
55
|
+
this.head.nextNode = node;
|
|
56
|
+
node.nextNode = tmp;
|
|
57
|
+
node.prevNode = this.head;
|
|
58
|
+
assert(tmp !== null, CacheErrorCode.NullPreviousNode);
|
|
59
|
+
tmp.prevNode = node;
|
|
60
|
+
|
|
61
|
+
this.length = this.length + 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* remove node
|
|
66
|
+
*
|
|
67
|
+
* @param node
|
|
68
|
+
*/
|
|
69
|
+
private removeNode(node: DoubleLinkedNode): void {
|
|
70
|
+
assert(node.prevNode !== null, CacheErrorCode.NullPreviousNode);
|
|
71
|
+
assert(node.nextNode !== null, CacheErrorCode.NullNextNode);
|
|
72
|
+
node.prevNode.nextNode = node.nextNode;
|
|
73
|
+
node.nextNode.prevNode = node.prevNode;
|
|
74
|
+
|
|
75
|
+
node.prevNode = null;
|
|
76
|
+
node.nextNode = null;
|
|
77
|
+
|
|
78
|
+
this.length = this.length - 1;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @return true if list is empty
|
|
83
|
+
*/
|
|
84
|
+
public isEmpty(): boolean {
|
|
85
|
+
return this.length === 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* refresh node so it is rotated to the head
|
|
90
|
+
*
|
|
91
|
+
* @param key - key of the node
|
|
92
|
+
*/
|
|
93
|
+
public refresh(key: string): void {
|
|
94
|
+
const node: DoubleLinkedNode = this.hashtable[key];
|
|
95
|
+
this.removeNode(node);
|
|
96
|
+
this.insertNodeToHead(node);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* insert new node to the head and add it in the hashtable
|
|
101
|
+
*
|
|
102
|
+
* @param key - the key of the node
|
|
103
|
+
*/
|
|
104
|
+
public insertItem(key: string): void {
|
|
105
|
+
const node: DoubleLinkedNode = new DoubleLinkedNode(key);
|
|
106
|
+
this.hashtable[key] = node;
|
|
107
|
+
this.insertNodeToHead(node);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @return the LAST Recently Visited key
|
|
112
|
+
*/
|
|
113
|
+
public getLastItem(): string {
|
|
114
|
+
assert(this.tail.prevNode !== null, CacheErrorCode.NullPreviousNode);
|
|
115
|
+
return this.tail.prevNode.key;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* remove the cache key from the list and hashtable
|
|
120
|
+
* @param key - the key of the node
|
|
121
|
+
*/
|
|
122
|
+
public removeItem(key: string): void {
|
|
123
|
+
const removedItem: DoubleLinkedNode = this.hashtable[key];
|
|
124
|
+
this.removeNode(removedItem);
|
|
125
|
+
delete this.hashtable[key];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @return length of the list
|
|
130
|
+
*/
|
|
131
|
+
public getSize(): number {
|
|
132
|
+
return this.length;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @return true if the key is in the hashtable
|
|
137
|
+
* @param key
|
|
138
|
+
*/
|
|
139
|
+
public containsKey(key: string): boolean {
|
|
140
|
+
return key in this.hashtable;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* clean up the list and hashtable
|
|
145
|
+
*/
|
|
146
|
+
public clearList(): void {
|
|
147
|
+
for (const key of Object.keys(this.hashtable)) {
|
|
148
|
+
if (this.hashtable.hasOwnProperty(key)) {
|
|
149
|
+
delete this.hashtable[key];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
this.head.nextNode = this.tail;
|
|
153
|
+
this.tail.prevNode = this.head;
|
|
154
|
+
this.length = 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @return all keys in the hashtable
|
|
159
|
+
*/
|
|
160
|
+
public getKeys(): string[] {
|
|
161
|
+
return Object.keys(this.hashtable);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* mainly for test
|
|
166
|
+
*
|
|
167
|
+
* @param key
|
|
168
|
+
* @return true if key is the head node
|
|
169
|
+
*/
|
|
170
|
+
public isHeadNode(key: string): boolean {
|
|
171
|
+
const node = this.hashtable[key];
|
|
172
|
+
return node.prevNode === this.head;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* mainly for test
|
|
177
|
+
*
|
|
178
|
+
* @param key
|
|
179
|
+
* @return true if key is the tail node
|
|
180
|
+
*/
|
|
181
|
+
public isTailNode(key: string): boolean {
|
|
182
|
+
const node = this.hashtable[key];
|
|
183
|
+
return node.nextNode === this.tail;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { currentSizeKey } from '../constants';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* return the byte size of the string
|
|
8
|
+
* @param str
|
|
9
|
+
*/
|
|
10
|
+
export function getByteLength(str: string): number {
|
|
11
|
+
let ret: number = 0;
|
|
12
|
+
ret = str.length;
|
|
13
|
+
|
|
14
|
+
for (let i = str.length; i >= 0; i -= 1) {
|
|
15
|
+
const charCode: number = str.charCodeAt(i);
|
|
16
|
+
if (charCode > 0x7f && charCode <= 0x7ff) {
|
|
17
|
+
ret += 1;
|
|
18
|
+
} else if (charCode > 0x7ff && charCode <= 0xffff) {
|
|
19
|
+
ret += 2;
|
|
20
|
+
}
|
|
21
|
+
// trail surrogate
|
|
22
|
+
if (charCode >= 0xdc00 && charCode <= 0xdfff) {
|
|
23
|
+
i -= 1;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return ret;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* get current time
|
|
32
|
+
*/
|
|
33
|
+
export function getCurrentTime(): number {
|
|
34
|
+
const currentTime = new Date();
|
|
35
|
+
return currentTime.getTime();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* check if passed value is an integer
|
|
40
|
+
*/
|
|
41
|
+
export function isInteger(value?: number): boolean {
|
|
42
|
+
if (Number.isInteger) {
|
|
43
|
+
return Number.isInteger(value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
typeof value === 'number' && isFinite(value) && Math.floor(value) === value
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const getCurrentSizeKey = (keyPrefix: string) =>
|
|
52
|
+
`${keyPrefix}${currentSizeKey}`;
|
|
@@ -6,7 +6,6 @@ import { AmplifyErrorMap, AssertionFunction } from '../../types';
|
|
|
6
6
|
|
|
7
7
|
export enum CacheErrorCode {
|
|
8
8
|
NoCacheItem = 'NoCacheItem',
|
|
9
|
-
NoCacheStorage = 'NoCacheStorage',
|
|
10
9
|
NullNextNode = 'NullNextNode',
|
|
11
10
|
NullPreviousNode = 'NullPreviousNode',
|
|
12
11
|
}
|
|
@@ -15,9 +14,6 @@ const cacheErrorMap: AmplifyErrorMap<CacheErrorCode> = {
|
|
|
15
14
|
[CacheErrorCode.NoCacheItem]: {
|
|
16
15
|
message: 'Item not found in the cache storage.',
|
|
17
16
|
},
|
|
18
|
-
[CacheErrorCode.NoCacheStorage]: {
|
|
19
|
-
message: 'Storage is not defined in the cache config.',
|
|
20
|
-
},
|
|
21
17
|
[CacheErrorCode.NullNextNode]: {
|
|
22
18
|
message: 'Next node is null.',
|
|
23
19
|
},
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export {
|
|
5
|
-
CacheObject,
|
|
6
|
-
defaultConfig,
|
|
7
5
|
getByteLength,
|
|
8
|
-
|
|
6
|
+
getCurrentSizeKey,
|
|
7
|
+
getCurrentTime,
|
|
9
8
|
isInteger,
|
|
10
|
-
} from './
|
|
11
|
-
export {
|
|
9
|
+
} from './cacheHelpers';
|
|
10
|
+
export { CacheList } from './CacheList';
|
package/src/I18n/I18n.ts
CHANGED
|
@@ -37,12 +37,7 @@ export class I18n {
|
|
|
37
37
|
* Sets the default language from the configuration when required.
|
|
38
38
|
*/
|
|
39
39
|
setDefaultLanguage() {
|
|
40
|
-
if
|
|
41
|
-
const i18nConfig = Amplify.getConfig().I18n;
|
|
42
|
-
this._lang = i18nConfig?.language;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Default to window language if not set in config
|
|
40
|
+
// Default to window language if not set in instance
|
|
46
41
|
if (
|
|
47
42
|
!this._lang &&
|
|
48
43
|
typeof window !== 'undefined' &&
|
package/src/Platform/types.ts
CHANGED
|
@@ -83,7 +83,14 @@ export enum DataStoreAction {
|
|
|
83
83
|
GraphQl = '2',
|
|
84
84
|
}
|
|
85
85
|
export enum GeoAction {
|
|
86
|
-
|
|
86
|
+
SearchByText = '0',
|
|
87
|
+
SearchByCoordinates = '1',
|
|
88
|
+
SearchForSuggestions = '2',
|
|
89
|
+
SearchByPlaceId = '3',
|
|
90
|
+
SaveGeofences = '4',
|
|
91
|
+
GetGeofence = '5',
|
|
92
|
+
ListGeofences = '6',
|
|
93
|
+
DeleteGeofences = '7',
|
|
87
94
|
}
|
|
88
95
|
export enum InAppMessagingAction {
|
|
89
96
|
SyncMessages = '1',
|
|
@@ -102,7 +109,8 @@ export enum PubSubAction {
|
|
|
102
109
|
Subscribe = '1',
|
|
103
110
|
}
|
|
104
111
|
export enum PushNotificationAction {
|
|
105
|
-
|
|
112
|
+
InitializePushNotifications = '1',
|
|
113
|
+
IdentifyUser = '2',
|
|
106
114
|
}
|
|
107
115
|
export enum StorageAction {
|
|
108
116
|
UploadData = '1',
|
|
@@ -166,31 +174,32 @@ export type CustomUserAgentStateMap = Record<string, CategoryUserAgentStateMap>;
|
|
|
166
174
|
|
|
167
175
|
export type AdditionalDetails = [string, string?][];
|
|
168
176
|
|
|
169
|
-
type StorageUserAgentInput = {
|
|
177
|
+
export type StorageUserAgentInput = {
|
|
170
178
|
category: Category.Storage;
|
|
171
179
|
apis: StorageAction[];
|
|
180
|
+
additionalDetails: AdditionalDetails;
|
|
172
181
|
};
|
|
173
182
|
|
|
174
|
-
type AuthUserAgentInput = {
|
|
183
|
+
export type AuthUserAgentInput = {
|
|
175
184
|
category: Category.Auth;
|
|
176
185
|
apis: AuthAction[];
|
|
186
|
+
additionalDetails: AdditionalDetails;
|
|
177
187
|
};
|
|
178
188
|
|
|
179
|
-
type InAppMessagingUserAgentInput = {
|
|
189
|
+
export type InAppMessagingUserAgentInput = {
|
|
180
190
|
category: Category.InAppMessaging;
|
|
181
191
|
apis: InAppMessagingAction[];
|
|
192
|
+
additionalDetails: AdditionalDetails;
|
|
182
193
|
};
|
|
183
194
|
|
|
184
|
-
type GeoUserAgentInput = {
|
|
195
|
+
export type GeoUserAgentInput = {
|
|
185
196
|
category: Category.Geo;
|
|
186
197
|
apis: GeoAction[];
|
|
198
|
+
additionalDetails: AdditionalDetails;
|
|
187
199
|
};
|
|
188
200
|
|
|
189
|
-
export type SetCustomUserAgentInput =
|
|
201
|
+
export type SetCustomUserAgentInput =
|
|
190
202
|
| StorageUserAgentInput
|
|
191
203
|
| AuthUserAgentInput
|
|
192
204
|
| InAppMessagingUserAgentInput
|
|
193
|
-
| GeoUserAgentInput
|
|
194
|
-
) & {
|
|
195
|
-
additionalDetails: AdditionalDetails;
|
|
196
|
-
};
|
|
205
|
+
| GeoUserAgentInput;
|
package/src/Platform/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '6.0.1-api-v6-models.
|
|
2
|
+
export const version = '6.0.1-api-v6-models.572a7b5.0+572a7b5';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { CompletionObserver, Observable } from 'rxjs';
|
|
4
|
+
import { CompletionObserver, Observable, from } from 'rxjs';
|
|
5
5
|
import { isWebWorker } from '../libraryUtils';
|
|
6
6
|
import { NetworkStatus } from './types';
|
|
7
7
|
|
|
@@ -9,7 +9,13 @@ export class Reachability {
|
|
|
9
9
|
private static _observers: Array<CompletionObserver<NetworkStatus>> = [];
|
|
10
10
|
|
|
11
11
|
networkMonitor(_?: unknown): Observable<NetworkStatus> {
|
|
12
|
-
const globalObj = isWebWorker()
|
|
12
|
+
const globalObj = isWebWorker()
|
|
13
|
+
? self
|
|
14
|
+
: typeof window !== 'undefined' && window;
|
|
15
|
+
|
|
16
|
+
if (!globalObj) {
|
|
17
|
+
return from([{ online: true }]);
|
|
18
|
+
}
|
|
13
19
|
|
|
14
20
|
return new Observable(observer => {
|
|
15
21
|
observer.next({ online: globalObj.navigator.onLine });
|
|
@@ -32,4 +38,18 @@ export class Reachability {
|
|
|
32
38
|
};
|
|
33
39
|
});
|
|
34
40
|
}
|
|
41
|
+
|
|
42
|
+
// expose observers to simulate offline mode for integration testing
|
|
43
|
+
private static _observerOverride(status: NetworkStatus): void {
|
|
44
|
+
for (const observer of this._observers) {
|
|
45
|
+
if (observer.closed) {
|
|
46
|
+
this._observers = this._observers.filter(
|
|
47
|
+
_observer => _observer !== observer
|
|
48
|
+
);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
observer?.next && observer.next(status);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
35
55
|
}
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
import { ConsoleLogger as Logger } from '../Logger';
|
|
5
5
|
import { isBrowser } from '../utils';
|
|
6
|
-
import { Amplify } from '../Amplify';
|
|
7
6
|
import { AmplifyError } from '../errors';
|
|
8
7
|
import { assert, ServiceWorkerErrorCode } from './errorHelpers';
|
|
8
|
+
import { record } from '../providers/pinpoint';
|
|
9
|
+
import { Amplify, fetchAuthSession } from '../singleton';
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
12
|
* Provides a means to registering a service worker in the browser
|
|
11
13
|
* and communicating with it via postMessage events.
|
|
@@ -205,15 +207,25 @@ export class ServiceWorkerClass {
|
|
|
205
207
|
* https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/state
|
|
206
208
|
**/
|
|
207
209
|
_setupListeners() {
|
|
208
|
-
this.serviceWorker.addEventListener('statechange', event => {
|
|
210
|
+
this.serviceWorker.addEventListener('statechange', async event => {
|
|
209
211
|
const currentState = this.serviceWorker.state;
|
|
210
212
|
this._logger.debug(`ServiceWorker statechange: ${currentState}`);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
|
|
214
|
+
const { appId, region } = Amplify.getConfig().Analytics?.Pinpoint ?? {};
|
|
215
|
+
const { credentials } = await fetchAuthSession();
|
|
216
|
+
|
|
217
|
+
if (appId && region && credentials) {
|
|
218
|
+
// Pinpoint is configured, record an event
|
|
219
|
+
record({
|
|
220
|
+
appId,
|
|
221
|
+
region,
|
|
222
|
+
category: 'Core',
|
|
223
|
+
credentials,
|
|
224
|
+
event: {
|
|
225
|
+
name: 'ServiceWorker',
|
|
226
|
+
attributes: {
|
|
227
|
+
state: currentState,
|
|
228
|
+
},
|
|
217
229
|
},
|
|
218
230
|
});
|
|
219
231
|
}
|
|
@@ -223,12 +235,3 @@ export class ServiceWorkerClass {
|
|
|
223
235
|
});
|
|
224
236
|
}
|
|
225
237
|
}
|
|
226
|
-
|
|
227
|
-
type AmplifyWithAnalytics = {
|
|
228
|
-
Analytics: {
|
|
229
|
-
record: Function;
|
|
230
|
-
};
|
|
231
|
-
};
|
|
232
|
-
function isAmplifyWithAnalytics(amplify: any): amplify is AmplifyWithAnalytics {
|
|
233
|
-
return amplify.Analytics && typeof amplify.Analytics.record === 'function';
|
|
234
|
-
}
|
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
/**
|
|
4
|
-
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
7
|
-
* the License. A copy of the License is located at
|
|
8
|
-
*
|
|
9
|
-
* http://aws.amazon.com/apache2.0/
|
|
10
|
-
*
|
|
11
|
-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
12
|
-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
13
|
-
* and limitations under the License.
|
|
14
|
-
*/
|
|
15
3
|
|
|
16
4
|
export { ServiceWorkerClass as ServiceWorker } from './ServiceWorker';
|
package/src/Signer/Signer.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
signRequest,
|
|
8
8
|
TOKEN_QUERY_PARAM,
|
|
9
9
|
} from '../clients/middleware/signing/signer/signatureV4';
|
|
10
|
+
import { AmplifyUrl } from '../utils/amplifyUrl';
|
|
10
11
|
|
|
11
12
|
const IOT_SERVICE_NAME = 'iotdevicegateway';
|
|
12
13
|
// Best practice regex to parse the service and region from an AWS endpoint
|
|
@@ -75,7 +76,7 @@ export class Signer {
|
|
|
75
76
|
const requestToSign = {
|
|
76
77
|
...request,
|
|
77
78
|
body: request.data,
|
|
78
|
-
url: new
|
|
79
|
+
url: new AmplifyUrl(request.url),
|
|
79
80
|
};
|
|
80
81
|
|
|
81
82
|
const options = getOptions(requestToSign, accessInfo, serviceInfo);
|
|
@@ -121,7 +122,7 @@ export class Signer {
|
|
|
121
122
|
const presignable = {
|
|
122
123
|
body,
|
|
123
124
|
method,
|
|
124
|
-
url: new
|
|
125
|
+
url: new AmplifyUrl(urlToSign),
|
|
125
126
|
};
|
|
126
127
|
|
|
127
128
|
const options = getOptions(
|