@aws-amplify/core 6.0.1-preview-testing.be90020.0 → 6.0.1-ssr-api.df60e41.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/internals/aws-clients/pinpoint/package.json +4 -4
- package/lib/BackgroundProcessManager/BackgroundManagerNotOpenError.d.ts +3 -0
- package/lib/BackgroundProcessManager/BackgroundManagerNotOpenError.js +11 -0
- package/lib/{Util → BackgroundProcessManager}/BackgroundProcessManager.d.ts +1 -23
- package/lib/BackgroundProcessManager/BackgroundProcessManager.js +287 -0
- package/lib/BackgroundProcessManager/index.d.ts +1 -0
- package/lib/BackgroundProcessManager/index.js +7 -0
- package/lib/BackgroundProcessManager/types.d.ts +41 -0
- package/lib/BackgroundProcessManager/types.js +23 -0
- package/lib/Cache/StorageCache.d.ts +14 -31
- package/lib/Cache/StorageCache.js +41 -106
- package/lib/Cache/StorageCache.native.d.ts +19 -0
- package/lib/Cache/StorageCache.native.js +62 -0
- package/lib/Cache/{AsyncStorageCache.d.ts → StorageCacheCommon.d.ts} +124 -99
- package/lib/Cache/StorageCacheCommon.js +468 -0
- 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/CacheList.js +160 -0
- package/lib/Cache/utils/cacheHelpers.d.ts +14 -0
- package/lib/Cache/utils/cacheHelpers.js +49 -0
- package/lib/Cache/utils/errorHelpers.d.ts +7 -0
- package/lib/Cache/utils/errorHelpers.js +24 -0
- package/lib/Cache/utils/index.d.ts +2 -0
- package/lib/Cache/utils/index.js +12 -0
- package/lib/Hub/index.d.ts +7 -0
- package/lib/Hub/index.js +44 -77
- package/lib/Hub/types/AuthTypes.d.ts +19 -0
- package/lib/I18n/I18n.d.ts +3 -19
- package/lib/I18n/I18n.js +25 -60
- package/lib/I18n/errorHelpers.d.ts +5 -0
- package/lib/I18n/errorHelpers.js +16 -0
- package/lib/I18n/index.d.ts +3 -15
- package/lib/I18n/index.js +28 -56
- package/lib/I18n/types.d.ts +1 -4
- package/lib/I18n/types.js +5 -9
- package/lib/Logger/ConsoleLogger.js +54 -130
- package/{lib-esm/Util → lib/Mutex}/Mutex.d.ts +2 -15
- package/lib/{Util → Mutex}/Mutex.js +17 -20
- package/lib/Mutex/index.d.ts +1 -0
- package/lib/Mutex/index.js +7 -0
- package/lib/Mutex/types.d.ts +13 -0
- package/lib/Platform/customUserAgent.d.ts +16 -0
- package/lib/Platform/customUserAgent.js +57 -0
- package/lib/Platform/detectFramework.js +12 -13
- package/lib/Platform/detection/Angular.js +4 -5
- package/lib/Platform/detection/Expo.js +1 -1
- package/lib/Platform/detection/Next.js +1 -1
- package/lib/Platform/detection/Nuxt.js +1 -1
- package/lib/Platform/detection/React.js +5 -5
- package/lib/Platform/detection/Svelte.js +2 -2
- package/lib/Platform/detection/Vue.js +1 -1
- package/lib/Platform/detection/Web.js +1 -1
- package/lib/Platform/detection/helpers.js +7 -7
- package/lib/Platform/detection/index.js +13 -13
- package/lib/Platform/index.js +32 -52
- package/lib/Platform/types.d.ts +75 -8
- package/lib/Platform/types.js +40 -39
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Reachability/Reachability.d.ts +7 -0
- package/lib/Reachability/Reachability.js +42 -0
- package/lib/Reachability/Reachability.native.d.ts +6 -0
- package/lib/{Util → Reachability}/Reachability.native.js +14 -20
- package/lib/Reachability/index.d.ts +1 -0
- package/lib/Reachability/index.js +7 -0
- package/lib/Reachability/types.d.ts +3 -0
- package/lib/Reachability/types.js +4 -0
- package/lib/ServiceWorker/ServiceWorker.js +86 -112
- package/lib/ServiceWorker/errorHelpers.d.ts +7 -0
- package/lib/ServiceWorker/errorHelpers.js +24 -0
- package/lib/ServiceWorker/index.d.ts +0 -12
- package/lib/ServiceWorker/index.js +0 -12
- package/lib/{Util → Signer}/DateUtils.js +10 -27
- package/lib/{Signer.js → Signer/Signer.js} +50 -52
- package/lib/Signer/index.d.ts +1 -0
- package/lib/Signer/index.js +7 -0
- package/lib/adapterCore/error/AmplifyServerContextError.d.ts +1 -1
- package/lib/adapterCore/error/AmplifyServerContextError.js +9 -27
- package/lib/adapterCore/serverContext/serverContext.js +8 -8
- package/lib/adapterCore/serverContext/serverContextRegistry.js +6 -6
- package/lib/awsClients/cognitoIdentity/base.js +67 -0
- package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getCredentialsForIdentity.d.ts +2 -1
- package/lib/awsClients/cognitoIdentity/getCredentialsForIdentity.js +39 -0
- package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getId.d.ts +2 -1
- package/lib/awsClients/cognitoIdentity/getId.js +30 -0
- package/lib/awsClients/cognitoIdentity/types.js +4 -0
- package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/base.js +12 -14
- package/lib/awsClients/pinpoint/errorHelpers.d.ts +5 -0
- package/lib/awsClients/pinpoint/errorHelpers.js +16 -0
- package/{lib-esm/AwsClients/Pinpoint → lib/awsClients/pinpoint}/getInAppMessages.d.ts +4 -3
- package/lib/awsClients/pinpoint/getInAppMessages.js +34 -0
- package/{lib-esm/AwsClients/Pinpoint → lib/awsClients/pinpoint}/putEvents.d.ts +4 -3
- package/lib/awsClients/pinpoint/putEvents.js +37 -0
- package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/updateEndpoint.d.ts +4 -3
- package/lib/awsClients/pinpoint/updateEndpoint.js +38 -0
- package/lib/clients/endpoints/getDnsSuffix.js +7 -29
- package/lib/clients/handlers/authenticated.js +5 -5
- package/lib/clients/handlers/fetch.js +41 -97
- package/lib/clients/handlers/unauthenticated.js +4 -4
- package/lib/clients/internal/composeServiceApi.js +17 -67
- package/lib/clients/internal/composeTransferHandler.js +9 -11
- package/lib/clients/middleware/retry/defaultRetryDecider.js +18 -75
- package/lib/clients/middleware/retry/isClockSkewError.js +2 -4
- package/lib/clients/middleware/retry/jitteredBackoff.js +5 -5
- package/lib/clients/middleware/retry/middleware.js +61 -125
- package/lib/clients/middleware/signing/middleware.js +24 -86
- package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.js +21 -55
- package/lib/clients/middleware/signing/signer/signatureV4/signRequest.js +14 -25
- package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +7 -7
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js +8 -30
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js +11 -38
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +13 -17
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +5 -8
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js +2 -2
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js +3 -3
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js +7 -11
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +9 -10
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js +4 -6
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js +8 -8
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +15 -16
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js +2 -4
- package/lib/clients/middleware/signing/utils/extendedEncodeURIComponent.js +3 -5
- package/lib/clients/middleware/signing/utils/getSkewCorrectedDate.js +1 -3
- package/lib/clients/middleware/signing/utils/getUpdatedSystemClockOffset.js +2 -2
- package/lib/clients/middleware/signing/utils/isClockSkewed.js +4 -6
- package/lib/clients/middleware/userAgent/middleware.js +14 -63
- package/lib/clients/serde/json.js +30 -96
- package/lib/clients/serde/responseInfo.js +12 -18
- package/lib/clients/types/http.d.ts +17 -1
- package/lib/clients/utils/memoization.js +3 -3
- package/lib/constants.d.ts +4 -0
- package/lib/constants.js +18 -0
- package/lib/{Util/Errors.d.ts → errors/AmplifyError.d.ts} +2 -9
- package/lib/errors/AmplifyError.js +26 -0
- package/lib/errors/PlatformNotSupportedError.d.ts +4 -0
- package/lib/errors/PlatformNotSupportedError.js +16 -0
- package/lib/errors/createAssertionFunction.d.ts +3 -0
- package/lib/errors/createAssertionFunction.js +19 -0
- package/lib/errors/errorHelpers.d.ts +2 -0
- package/lib/errors/errorHelpers.js +19 -0
- package/lib/errors/index.d.ts +4 -0
- package/lib/errors/index.js +13 -0
- package/lib/index.d.ts +7 -7
- package/lib/index.js +17 -16
- package/lib/libraryUtils.d.ts +20 -16
- package/lib/libraryUtils.js +60 -69
- package/lib/parseAWSExports.js +172 -35
- package/lib/providers/kinesis/types/index.d.ts +1 -0
- package/lib/providers/kinesis/types/index.js +19 -0
- package/lib/providers/kinesis/types/kinesis.d.ts +9 -0
- package/lib/providers/kinesis/types/kinesis.js +4 -0
- package/lib/providers/kinesis-firehose/types/index.d.ts +1 -0
- package/lib/providers/kinesis-firehose/types/index.js +4 -0
- package/lib/providers/kinesis-firehose/types/kinesis-firehose.d.ts +9 -0
- package/lib/providers/kinesis-firehose/types/kinesis-firehose.js +4 -0
- package/lib/providers/personalize/types/index.d.ts +1 -0
- package/lib/providers/personalize/types/index.js +4 -0
- package/lib/providers/personalize/types/personalize.d.ts +8 -0
- package/lib/providers/personalize/types/personalize.js +4 -0
- package/lib/providers/pinpoint/apis/flushEvents.d.ts +2 -0
- package/lib/providers/pinpoint/apis/flushEvents.js +21 -0
- package/lib/providers/pinpoint/apis/index.d.ts +1 -0
- package/lib/providers/pinpoint/apis/index.js +3 -1
- package/lib/providers/pinpoint/apis/record.d.ts +1 -1
- package/lib/providers/pinpoint/apis/record.js +58 -109
- package/lib/providers/pinpoint/apis/updateEndpoint.d.ts +1 -1
- package/lib/providers/pinpoint/apis/updateEndpoint.js +65 -110
- package/lib/providers/pinpoint/index.d.ts +2 -1
- package/lib/providers/pinpoint/index.js +5 -0
- 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 +7 -4
- package/lib/providers/pinpoint/utils/PinpointEventBuffer.d.ts +1 -0
- package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +111 -197
- package/lib/providers/pinpoint/utils/cacheEndpointId.js +12 -49
- package/lib/providers/pinpoint/utils/getCacheKey.js +2 -2
- package/lib/providers/pinpoint/utils/getEndpointId.js +7 -51
- package/lib/providers/pinpoint/utils/getEventBuffer.js +19 -21
- package/lib/providers/pinpoint/utils/index.d.ts +1 -0
- package/lib/providers/pinpoint/utils/index.js +3 -1
- package/lib/providers/pinpoint/utils/isAppInForeground.d.ts +1 -0
- package/lib/{RNComponents → providers/pinpoint/utils}/isAppInForeground.js +1 -4
- package/lib/providers/pinpoint/utils/isAppInForeground.native.d.ts +1 -0
- package/lib/providers/pinpoint/utils/isAppInForeground.native.js +9 -0
- package/lib/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
- package/lib/providers/pinpoint/utils/resolveEndpointId.js +34 -0
- package/lib/singleton/API/types.d.ts +73 -0
- package/lib/singleton/API/types.js +2 -0
- package/lib/singleton/Amplify.d.ts +2 -2
- package/lib/singleton/Amplify.js +34 -93
- package/lib/singleton/Analytics/types.d.ts +4 -1
- package/lib/singleton/Auth/index.js +48 -115
- package/lib/singleton/Auth/types.d.ts +31 -4
- package/lib/singleton/Auth/utils/errorHelpers.d.ts +8 -0
- package/lib/singleton/Auth/utils/errorHelpers.js +32 -0
- package/lib/singleton/Auth/utils/index.d.ts +1 -1
- package/lib/singleton/Auth/utils/index.js +30 -46
- package/lib/singleton/Cache/types.d.ts +18 -0
- package/lib/singleton/Cache/types.js +4 -0
- package/lib/singleton/Geo/types.d.ts +17 -0
- package/lib/singleton/Geo/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/InAppMessaging/types.d.ts +2 -0
- package/lib/singleton/Notifications/InAppMessaging/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 +6 -0
- package/lib/singleton/Notifications/types.js +4 -0
- package/lib/singleton/Predictions/types.d.ts +49 -0
- package/lib/singleton/Predictions/types.js +4 -0
- package/lib/singleton/apis/clearCredentials.js +1 -1
- package/lib/singleton/apis/fetchAuthSession.js +3 -3
- package/lib/singleton/apis/internal/fetchAuthSession.js +1 -1
- package/lib/singleton/apis/server/fetchAuthSession.js +3 -3
- package/lib/singleton/types.d.ts +12 -1
- package/{lib-esm/StorageHelper/cookieStorage.d.ts → lib/storage/CookieStorage.d.ts} +4 -3
- package/lib/storage/CookieStorage.js +52 -0
- package/lib/storage/CookieStorage.native.d.ts +7 -0
- package/lib/storage/CookieStorage.native.js +15 -0
- package/lib/storage/DefaultStorage.d.ts +7 -0
- package/lib/storage/DefaultStorage.js +16 -0
- package/{lib-esm/StorageHelper/localStorage.d.ts → lib/storage/DefaultStorage.native.d.ts} +6 -5
- package/lib/storage/DefaultStorage.native.js +50 -0
- package/lib/storage/InMemoryStorage.d.ts +12 -0
- package/lib/storage/InMemoryStorage.js +35 -0
- package/lib/{StorageHelper/sessionStorage.d.ts → storage/KeyValueStorage.d.ts} +5 -4
- package/lib/storage/KeyValueStorage.js +56 -0
- package/lib/storage/SessionStorage.d.ts +7 -0
- package/lib/storage/SessionStorage.js +16 -0
- package/lib/storage/index.d.ts +7 -0
- package/lib/storage/index.js +14 -0
- package/lib/storage/utils.d.ts +10 -0
- package/lib/storage/utils.js +22 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/core.d.ts +4 -1
- package/lib/types/errors.d.ts +9 -3
- package/lib/types/errors.js +7 -0
- package/lib/types/storage.d.ts +3 -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/amplifyUrl/polyfill.native.js +6 -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/convert/base64/base64Decoder.d.ts +2 -0
- package/lib/utils/convert/base64/base64Decoder.js +11 -0
- package/lib/utils/convert/base64/base64Encoder.d.ts +2 -0
- package/lib/utils/convert/base64/base64Encoder.js +17 -0
- package/lib/utils/convert/base64/bytesToString.d.ts +1 -0
- package/lib/utils/convert/base64/bytesToString.js +9 -0
- package/lib/utils/convert/index.d.ts +2 -0
- package/lib/utils/convert/index.js +9 -0
- package/lib/utils/convert/types.d.ts +9 -0
- package/lib/utils/convert/types.js +4 -0
- package/lib/utils/deepFreeze.d.ts +1 -0
- package/lib/utils/deepFreeze.js +16 -0
- package/lib/utils/generateRandomString.d.ts +1 -0
- package/lib/utils/generateRandomString.js +14 -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} +9 -9
- package/{lib-esm/ClientDevice/browser.d.ts → lib/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} +14 -14
- package/lib/utils/getClientInfo/getClientInfo.js +68 -0
- package/lib/utils/getClientInfo/index.d.ts +1 -0
- package/lib/utils/getClientInfo/index.js +7 -0
- package/lib/utils/globalHelpers/index.d.ts +3 -0
- package/lib/utils/globalHelpers/index.js +50 -0
- package/lib/utils/globalHelpers/index.native.d.ts +3 -0
- package/lib/utils/globalHelpers/index.native.js +28 -0
- package/lib/utils/index.d.ts +8 -0
- package/lib/utils/index.js +25 -0
- package/lib/utils/isBrowser.d.ts +1 -0
- package/lib/utils/isBrowser.js +7 -0
- package/lib/utils/isWebWorker.d.ts +1 -0
- package/lib/utils/isWebWorker.js +14 -0
- package/lib/utils/retry/NonRetryableError.d.ts +4 -0
- package/lib/utils/retry/NonRetryableError.js +12 -0
- package/lib/utils/retry/constants.d.ts +1 -0
- package/lib/utils/retry/constants.js +6 -0
- package/lib/utils/retry/index.d.ts +5 -0
- package/lib/utils/retry/index.js +15 -0
- package/lib/utils/retry/isNonRetryableError.d.ts +2 -0
- package/lib/utils/retry/isNonRetryableError.js +10 -0
- package/lib/utils/retry/jitteredBackoff.d.ts +6 -0
- package/lib/utils/retry/jitteredBackoff.js +19 -0
- package/lib/utils/retry/jitteredExponentialRetry.d.ts +5 -0
- package/lib/utils/retry/jitteredExponentialRetry.js +14 -0
- package/lib/utils/retry/retry.d.ts +6 -0
- package/lib/utils/retry/retry.js +64 -0
- package/lib/utils/sessionListener/SessionListener.d.ts +10 -0
- package/lib/utils/sessionListener/SessionListener.js +53 -0
- package/lib/utils/sessionListener/SessionListener.native.d.ts +10 -0
- package/lib/utils/sessionListener/SessionListener.native.js +50 -0
- package/lib/utils/sessionListener/constants.d.ts +2 -0
- package/lib/utils/sessionListener/constants.js +8 -0
- package/lib/utils/sessionListener/index.d.ts +3 -0
- package/lib/utils/sessionListener/index.js +10 -0
- package/lib/utils/sessionListener/types.d.ts +6 -0
- package/lib/utils/sessionListener/types.js +4 -0
- package/lib/utils/urlSafeDecode.d.ts +1 -0
- package/lib/utils/urlSafeDecode.js +10 -0
- package/lib/utils/urlSafeEncode.d.ts +1 -0
- package/lib/utils/urlSafeEncode.js +12 -0
- package/lib-esm/BackgroundProcessManager/BackgroundManagerNotOpenError.d.ts +3 -0
- package/lib-esm/BackgroundProcessManager/BackgroundManagerNotOpenError.js +7 -0
- package/lib-esm/{Util → BackgroundProcessManager}/BackgroundProcessManager.d.ts +1 -23
- package/lib-esm/BackgroundProcessManager/BackgroundProcessManager.js +283 -0
- package/lib-esm/BackgroundProcessManager/index.d.ts +1 -0
- package/lib-esm/BackgroundProcessManager/index.js +3 -0
- package/lib-esm/BackgroundProcessManager/types.d.ts +41 -0
- package/lib-esm/BackgroundProcessManager/types.js +20 -0
- package/lib-esm/Cache/StorageCache.d.ts +14 -31
- package/lib-esm/Cache/StorageCache.js +40 -106
- package/lib-esm/Cache/StorageCache.native.d.ts +19 -0
- package/lib-esm/Cache/StorageCache.native.js +58 -0
- package/lib-esm/Cache/{AsyncStorageCache.d.ts → StorageCacheCommon.d.ts} +124 -99
- package/lib-esm/Cache/StorageCacheCommon.js +464 -0
- 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 +46 -84
- package/lib-esm/Cache/utils/cacheHelpers.d.ts +14 -0
- package/lib-esm/Cache/utils/cacheHelpers.js +42 -0
- package/lib-esm/Cache/utils/errorHelpers.d.ts +7 -0
- package/lib-esm/Cache/utils/errorHelpers.js +21 -0
- package/lib-esm/Cache/utils/index.d.ts +2 -0
- package/lib-esm/Cache/utils/index.js +4 -0
- package/lib-esm/Hub/index.d.ts +7 -0
- package/lib-esm/Hub/index.js +42 -76
- package/lib-esm/Hub/types/AuthTypes.d.ts +19 -0
- package/lib-esm/I18n/I18n.d.ts +3 -19
- package/lib-esm/I18n/I18n.js +24 -60
- package/lib-esm/I18n/errorHelpers.d.ts +5 -0
- package/lib-esm/I18n/errorHelpers.js +13 -0
- package/lib-esm/I18n/index.d.ts +3 -15
- package/lib-esm/I18n/index.js +26 -55
- package/lib-esm/I18n/types.d.ts +1 -4
- package/lib-esm/I18n/types.js +3 -8
- package/lib-esm/Logger/ConsoleLogger.js +53 -129
- package/{lib/Util → lib-esm/Mutex}/Mutex.d.ts +2 -15
- package/lib-esm/{Util → Mutex}/Mutex.js +15 -20
- package/lib-esm/Mutex/index.d.ts +1 -0
- package/lib-esm/Mutex/index.js +3 -0
- package/lib-esm/Mutex/types.d.ts +13 -0
- package/lib-esm/Platform/customUserAgent.d.ts +16 -0
- package/lib-esm/Platform/customUserAgent.js +52 -0
- package/lib-esm/Platform/detectFramework.js +11 -12
- package/lib-esm/Platform/detection/Angular.js +3 -4
- package/lib-esm/Platform/detection/React.js +4 -4
- package/lib-esm/Platform/detection/Svelte.js +1 -1
- package/lib-esm/Platform/detection/helpers.js +7 -7
- package/lib-esm/Platform/detection/index.js +3 -3
- package/lib-esm/Platform/index.js +30 -50
- package/lib-esm/Platform/types.d.ts +75 -8
- package/lib-esm/Platform/types.js +40 -39
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Reachability/Reachability.d.ts +7 -0
- package/lib-esm/Reachability/Reachability.js +39 -0
- package/lib-esm/Reachability/Reachability.native.d.ts +6 -0
- package/lib-esm/{Util → Reachability}/Reachability.native.js +11 -16
- package/lib-esm/Reachability/index.d.ts +1 -0
- package/lib-esm/Reachability/index.js +3 -0
- package/lib-esm/Reachability/types.d.ts +3 -0
- package/lib-esm/Reachability/types.js +3 -0
- package/lib-esm/ServiceWorker/ServiceWorker.js +78 -105
- package/lib-esm/ServiceWorker/errorHelpers.d.ts +7 -0
- package/lib-esm/ServiceWorker/errorHelpers.js +21 -0
- package/lib-esm/ServiceWorker/index.d.ts +0 -12
- package/lib-esm/ServiceWorker/index.js +0 -12
- package/lib-esm/{Util → Signer}/DateUtils.js +11 -28
- package/lib-esm/Signer/Signer.js +124 -0
- package/lib-esm/Signer/index.d.ts +1 -0
- package/lib-esm/Signer/index.js +3 -0
- package/lib-esm/adapterCore/error/AmplifyServerContextError.d.ts +1 -1
- package/lib-esm/adapterCore/error/AmplifyServerContextError.js +9 -28
- package/lib-esm/adapterCore/serverContext/serverContext.js +6 -6
- package/lib-esm/adapterCore/serverContext/serverContextRegistry.js +7 -7
- package/lib-esm/awsClients/cognitoIdentity/base.js +62 -0
- package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getCredentialsForIdentity.d.ts +2 -1
- package/lib-esm/awsClients/cognitoIdentity/getCredentialsForIdentity.js +36 -0
- package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getId.d.ts +2 -1
- package/lib-esm/awsClients/cognitoIdentity/getId.js +27 -0
- package/lib-esm/awsClients/cognitoIdentity/types.js +3 -0
- package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/base.js +9 -11
- package/lib-esm/awsClients/pinpoint/errorHelpers.d.ts +5 -0
- package/lib-esm/awsClients/pinpoint/errorHelpers.js +13 -0
- package/{lib/AwsClients/Pinpoint → lib-esm/awsClients/pinpoint}/getInAppMessages.d.ts +4 -3
- package/lib-esm/awsClients/pinpoint/getInAppMessages.js +31 -0
- package/{lib/AwsClients/Pinpoint → lib-esm/awsClients/pinpoint}/putEvents.d.ts +4 -3
- package/lib-esm/awsClients/pinpoint/putEvents.js +34 -0
- package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/updateEndpoint.d.ts +4 -3
- package/lib-esm/awsClients/pinpoint/updateEndpoint.js +35 -0
- package/lib-esm/clients/endpoints/getDnsSuffix.js +6 -28
- package/lib-esm/clients/endpoints/partitions.js +2 -2
- package/lib-esm/clients/handlers/authenticated.js +1 -1
- package/lib-esm/clients/handlers/fetch.js +40 -96
- package/lib-esm/clients/handlers/unauthenticated.js +1 -1
- package/lib-esm/clients/internal/composeServiceApi.js +17 -67
- package/lib-esm/clients/internal/composeTransferHandler.js +9 -11
- package/lib-esm/clients/middleware/retry/defaultRetryDecider.js +17 -74
- package/lib-esm/clients/middleware/retry/isClockSkewError.js +2 -4
- package/lib-esm/clients/middleware/retry/jitteredBackoff.js +5 -5
- package/lib-esm/clients/middleware/retry/middleware.js +61 -125
- package/lib-esm/clients/middleware/signing/middleware.js +21 -83
- package/lib-esm/clients/middleware/signing/signer/signatureV4/constants.js +17 -17
- package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.js +18 -52
- package/lib-esm/clients/middleware/signing/signer/signatureV4/signRequest.js +10 -21
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +5 -5
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js +8 -30
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js +11 -38
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +8 -12
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +5 -8
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js +1 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js +3 -3
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js +5 -9
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +5 -6
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js +4 -6
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js +6 -6
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +13 -14
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js +1 -3
- package/lib-esm/clients/middleware/signing/utils/extendedEncodeURIComponent.js +3 -5
- package/lib-esm/clients/middleware/signing/utils/getSkewCorrectedDate.js +1 -3
- package/lib-esm/clients/middleware/signing/utils/getUpdatedSystemClockOffset.js +1 -1
- package/lib-esm/clients/middleware/signing/utils/isClockSkewed.js +3 -5
- package/lib-esm/clients/middleware/userAgent/middleware.js +14 -63
- package/lib-esm/clients/serde/json.js +29 -95
- package/lib-esm/clients/serde/responseInfo.js +11 -17
- package/lib-esm/clients/types/http.d.ts +17 -1
- package/lib-esm/clients/utils/memoization.js +3 -3
- package/lib-esm/constants.d.ts +4 -0
- package/lib-esm/constants.js +15 -0
- package/lib-esm/{Util/Errors.d.ts → errors/AmplifyError.d.ts} +2 -9
- package/lib-esm/errors/AmplifyError.js +22 -0
- package/lib-esm/errors/PlatformNotSupportedError.d.ts +4 -0
- package/lib-esm/errors/PlatformNotSupportedError.js +12 -0
- package/lib-esm/errors/createAssertionFunction.d.ts +3 -0
- package/lib-esm/errors/createAssertionFunction.js +15 -0
- package/lib-esm/errors/errorHelpers.d.ts +2 -0
- package/lib-esm/errors/errorHelpers.js +16 -0
- package/lib-esm/errors/index.d.ts +4 -0
- package/lib-esm/errors/index.js +6 -0
- package/lib-esm/index.d.ts +7 -7
- package/lib-esm/index.js +7 -6
- package/lib-esm/libraryUtils.d.ts +20 -16
- package/lib-esm/libraryUtils.js +21 -18
- package/lib-esm/parseAWSExports.js +171 -34
- package/lib-esm/providers/kinesis/types/index.d.ts +1 -0
- package/lib-esm/providers/kinesis/types/index.js +3 -0
- package/lib-esm/providers/kinesis/types/kinesis.d.ts +9 -0
- package/lib-esm/providers/kinesis/types/kinesis.js +3 -0
- package/lib-esm/providers/kinesis-firehose/types/index.d.ts +1 -0
- package/lib-esm/providers/kinesis-firehose/types/index.js +3 -0
- package/lib-esm/providers/kinesis-firehose/types/kinesis-firehose.d.ts +9 -0
- package/lib-esm/providers/kinesis-firehose/types/kinesis-firehose.js +3 -0
- package/lib-esm/providers/personalize/types/index.d.ts +1 -0
- package/lib-esm/providers/personalize/types/index.js +3 -0
- package/lib-esm/providers/personalize/types/personalize.d.ts +8 -0
- package/lib-esm/providers/personalize/types/personalize.js +3 -0
- package/lib-esm/providers/pinpoint/apis/flushEvents.d.ts +2 -0
- package/lib-esm/providers/pinpoint/apis/flushEvents.js +17 -0
- package/lib-esm/providers/pinpoint/apis/index.d.ts +1 -0
- package/lib-esm/providers/pinpoint/apis/index.js +1 -0
- package/lib-esm/providers/pinpoint/apis/record.d.ts +1 -1
- package/lib-esm/providers/pinpoint/apis/record.js +56 -107
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.d.ts +1 -1
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +64 -109
- package/lib-esm/providers/pinpoint/index.d.ts +2 -1
- package/lib-esm/providers/pinpoint/index.js +2 -0
- 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 +7 -4
- package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.d.ts +1 -0
- package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +110 -197
- package/lib-esm/providers/pinpoint/utils/cacheEndpointId.js +10 -47
- package/lib-esm/providers/pinpoint/utils/constants.js +4 -4
- package/lib-esm/providers/pinpoint/utils/getCacheKey.js +2 -2
- package/lib-esm/providers/pinpoint/utils/getEndpointId.js +5 -49
- package/lib-esm/providers/pinpoint/utils/getEventBuffer.js +17 -19
- 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/isAppInForeground.js +3 -0
- package/lib-esm/providers/pinpoint/utils/isAppInForeground.native.js +5 -0
- package/lib-esm/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
- package/lib-esm/providers/pinpoint/utils/resolveEndpointId.js +30 -0
- package/lib-esm/singleton/API/types.d.ts +73 -0
- package/lib-esm/singleton/API/types.js +1 -0
- package/lib-esm/singleton/Amplify.d.ts +2 -2
- package/lib-esm/singleton/Amplify.js +32 -92
- package/lib-esm/singleton/Analytics/types.d.ts +4 -1
- package/lib-esm/singleton/Auth/index.js +48 -116
- package/lib-esm/singleton/Auth/types.d.ts +31 -4
- package/lib-esm/singleton/Auth/utils/errorHelpers.d.ts +8 -0
- package/lib-esm/singleton/Auth/utils/errorHelpers.js +29 -0
- package/lib-esm/singleton/Auth/utils/index.d.ts +1 -1
- package/lib-esm/singleton/Auth/utils/index.js +28 -44
- package/lib-esm/singleton/Cache/types.d.ts +18 -0
- package/lib-esm/singleton/Cache/types.js +3 -0
- package/lib-esm/singleton/Geo/types.d.ts +17 -0
- package/lib-esm/singleton/Geo/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/InAppMessaging/types.d.ts +2 -0
- package/lib-esm/singleton/Notifications/InAppMessaging/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 +6 -0
- package/lib-esm/singleton/Notifications/types.js +3 -0
- package/lib-esm/singleton/Predictions/types.d.ts +49 -0
- package/lib-esm/singleton/Predictions/types.js +3 -0
- package/lib-esm/singleton/apis/fetchAuthSession.js +1 -1
- package/lib-esm/singleton/apis/internal/fetchAuthSession.js +1 -1
- package/lib-esm/singleton/apis/server/fetchAuthSession.js +1 -1
- package/lib-esm/singleton/types.d.ts +12 -1
- package/{lib/StorageHelper/cookieStorage.d.ts → lib-esm/storage/CookieStorage.d.ts} +4 -3
- package/lib-esm/storage/CookieStorage.js +45 -0
- package/lib-esm/storage/CookieStorage.native.d.ts +7 -0
- package/lib-esm/storage/CookieStorage.native.js +11 -0
- package/lib-esm/storage/DefaultStorage.d.ts +7 -0
- package/lib-esm/storage/DefaultStorage.js +12 -0
- package/{lib/StorageHelper/localStorage.d.ts → lib-esm/storage/DefaultStorage.native.d.ts} +6 -5
- package/lib-esm/storage/DefaultStorage.native.js +46 -0
- package/lib-esm/storage/InMemoryStorage.d.ts +12 -0
- package/lib-esm/storage/InMemoryStorage.js +31 -0
- package/lib-esm/{StorageHelper/sessionStorage.d.ts → storage/KeyValueStorage.d.ts} +5 -4
- package/lib-esm/storage/KeyValueStorage.js +52 -0
- package/lib-esm/storage/SessionStorage.d.ts +7 -0
- package/lib-esm/storage/SessionStorage.js +12 -0
- package/lib-esm/storage/index.d.ts +7 -0
- package/lib-esm/storage/index.js +10 -0
- package/lib-esm/storage/utils.d.ts +10 -0
- package/lib-esm/storage/utils.js +17 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/core.d.ts +4 -1
- package/lib-esm/types/errors.d.ts +9 -3
- package/lib-esm/types/errors.js +6 -1
- package/lib-esm/types/storage.d.ts +3 -0
- package/lib-esm/utils/amplifyUrl/index.d.ts +13 -0
- package/lib-esm/utils/amplifyUrl/index.js +6 -0
- package/lib-esm/utils/amplifyUrl/polyfill.d.ts +0 -0
- package/lib-esm/utils/amplifyUrl/polyfill.js +4 -0
- package/lib-esm/utils/amplifyUrl/polyfill.native.d.ts +1 -0
- package/lib-esm/utils/amplifyUrl/polyfill.native.js +4 -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.d.ts +0 -0
- package/lib-esm/utils/amplifyUuid/polyfill.js +4 -0
- package/lib-esm/utils/amplifyUuid/polyfill.native.d.ts +1 -0
- package/lib-esm/utils/amplifyUuid/polyfill.native.js +4 -0
- package/lib-esm/utils/convert/base64/base64Decoder.d.ts +2 -0
- package/lib-esm/utils/convert/base64/base64Decoder.js +8 -0
- package/lib-esm/utils/convert/base64/base64Encoder.d.ts +2 -0
- package/lib-esm/utils/convert/base64/base64Encoder.js +14 -0
- package/lib-esm/utils/convert/base64/bytesToString.d.ts +1 -0
- package/lib-esm/utils/convert/base64/bytesToString.js +5 -0
- package/lib-esm/utils/convert/index.d.ts +2 -0
- package/lib-esm/utils/convert/index.js +4 -0
- package/lib-esm/utils/convert/types.d.ts +9 -0
- package/lib-esm/utils/convert/types.js +3 -0
- package/lib-esm/utils/deepFreeze.d.ts +1 -0
- package/lib-esm/utils/deepFreeze.js +12 -0
- package/lib-esm/utils/generateRandomString.d.ts +1 -0
- package/lib-esm/utils/generateRandomString.js +10 -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} +6 -6
- package/{lib/ClientDevice/browser.d.ts → lib-esm/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} +11 -11
- package/lib-esm/{ClientDevice/browser.js → utils/getClientInfo/getClientInfo.js} +18 -28
- package/lib-esm/utils/getClientInfo/index.d.ts +1 -0
- package/lib-esm/utils/getClientInfo/index.js +3 -0
- package/lib-esm/utils/globalHelpers/index.d.ts +3 -0
- package/lib-esm/utils/globalHelpers/index.js +44 -0
- package/lib-esm/utils/globalHelpers/index.native.d.ts +3 -0
- package/lib-esm/utils/globalHelpers/index.native.js +22 -0
- package/lib-esm/utils/index.d.ts +8 -0
- package/lib-esm/utils/index.js +10 -0
- package/lib-esm/utils/isBrowser.d.ts +1 -0
- package/lib-esm/utils/isBrowser.js +3 -0
- package/lib-esm/utils/isWebWorker.d.ts +1 -0
- package/lib-esm/utils/isWebWorker.js +10 -0
- package/lib-esm/utils/retry/NonRetryableError.d.ts +4 -0
- package/lib-esm/utils/retry/NonRetryableError.js +8 -0
- package/lib-esm/utils/retry/constants.d.ts +1 -0
- package/lib-esm/utils/retry/constants.js +3 -0
- package/lib-esm/utils/retry/index.d.ts +5 -0
- package/lib-esm/utils/retry/index.js +7 -0
- package/lib-esm/utils/retry/isNonRetryableError.d.ts +2 -0
- package/lib-esm/utils/retry/isNonRetryableError.js +6 -0
- package/lib-esm/utils/retry/jitteredBackoff.d.ts +6 -0
- package/lib-esm/utils/retry/jitteredBackoff.js +15 -0
- package/lib-esm/utils/retry/jitteredExponentialRetry.d.ts +5 -0
- package/lib-esm/utils/retry/jitteredExponentialRetry.js +10 -0
- package/lib-esm/utils/retry/retry.d.ts +6 -0
- package/lib-esm/utils/retry/retry.js +60 -0
- package/lib-esm/utils/sessionListener/SessionListener.d.ts +10 -0
- package/lib-esm/utils/sessionListener/SessionListener.js +49 -0
- package/lib-esm/utils/sessionListener/SessionListener.native.d.ts +10 -0
- package/lib-esm/utils/sessionListener/SessionListener.native.js +46 -0
- package/lib-esm/utils/sessionListener/constants.d.ts +2 -0
- package/lib-esm/utils/sessionListener/constants.js +5 -0
- package/lib-esm/utils/sessionListener/index.d.ts +3 -0
- package/lib-esm/utils/sessionListener/index.js +5 -0
- package/lib-esm/utils/sessionListener/types.d.ts +6 -0
- package/lib-esm/utils/sessionListener/types.js +3 -0
- package/lib-esm/{Util/StringUtils.d.ts → utils/urlSafeDecode.d.ts} +0 -1
- package/lib-esm/utils/urlSafeDecode.js +6 -0
- package/{lib/Util/StringUtils.d.ts → lib-esm/utils/urlSafeEncode.d.ts} +0 -1
- package/lib-esm/utils/urlSafeEncode.js +8 -0
- package/package.json +18 -45
- package/src/BackgroundProcessManager/BackgroundManagerNotOpenError.ts +8 -0
- package/src/{Util → BackgroundProcessManager}/BackgroundProcessManager.ts +4 -58
- package/src/BackgroundProcessManager/index.ts +4 -0
- package/src/BackgroundProcessManager/types.ts +49 -0
- 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 +1 -1
- package/src/Cache/{Utils → utils}/CacheList.ts +185 -198
- package/src/Cache/utils/cacheHelpers.ts +52 -0
- package/src/Cache/utils/errorHelpers.ts +26 -0
- package/src/Cache/{Utils → utils}/index.ts +4 -5
- package/src/Hub/index.ts +11 -2
- package/src/Hub/types/AuthTypes.ts +12 -1
- package/src/I18n/I18n.ts +4 -25
- package/src/I18n/errorHelpers.ts +18 -0
- package/src/I18n/index.ts +9 -33
- package/src/I18n/types.ts +1 -4
- package/src/Logger/ConsoleLogger.ts +1 -1
- package/src/{Util → Mutex}/Mutex.ts +2 -20
- package/src/Mutex/index.ts +4 -0
- package/src/Mutex/types.ts +20 -0
- package/src/Platform/customUserAgent.ts +75 -0
- package/src/Platform/index.ts +14 -1
- package/src/Platform/types.ts +84 -39
- package/src/Platform/version.ts +1 -1
- package/src/{Util → Reachability}/Reachability.native.ts +7 -12
- package/src/Reachability/Reachability.ts +55 -0
- package/src/Reachability/index.ts +4 -0
- package/src/Reachability/types.ts +6 -0
- package/src/ServiceWorker/ServiceWorker.ts +39 -48
- package/src/ServiceWorker/errorHelpers.ts +26 -0
- package/src/ServiceWorker/index.ts +0 -12
- package/src/{Util → Signer}/DateUtils.ts +1 -1
- package/src/{Signer.ts → Signer/Signer.ts} +5 -4
- package/src/Signer/index.ts +4 -0
- package/src/adapterCore/error/AmplifyServerContextError.ts +1 -1
- package/src/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/base.ts +4 -1
- package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/base.ts +2 -1
- package/src/awsClients/pinpoint/errorHelpers.ts +19 -0
- package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/getInAppMessages.ts +2 -1
- package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/putEvents.ts +4 -7
- package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/updateEndpoint.ts +2 -1
- package/src/clients/handlers/fetch.ts +5 -1
- package/src/clients/middleware/retry/jitteredBackoff.ts +1 -1
- package/src/clients/middleware/signing/signer/signatureV4/presignUrl.ts +2 -1
- package/src/clients/types/http.ts +19 -1
- package/src/{Util/Constants.ts → constants.ts} +0 -11
- package/src/{Util/Errors.ts → errors/AmplifyError.ts} +2 -18
- package/src/errors/PlatformNotSupportedError.ts +14 -0
- package/src/errors/createAssertionFunction.ts +23 -0
- package/src/errors/errorHelpers.ts +20 -0
- package/src/errors/index.ts +7 -0
- package/src/index.ts +16 -11
- package/src/libraryUtils.ts +61 -57
- package/src/parseAWSExports.ts +214 -14
- package/src/providers/kinesis/types/index.ts +4 -0
- package/src/providers/kinesis/types/kinesis.ts +12 -0
- package/src/providers/kinesis-firehose/types/index.ts +4 -0
- package/src/providers/kinesis-firehose/types/kinesis-firehose.ts +12 -0
- package/src/providers/personalize/types/index.ts +4 -0
- package/src/providers/personalize/types/personalize.ts +11 -0
- package/src/providers/pinpoint/apis/flushEvents.ts +31 -0
- package/src/providers/pinpoint/apis/index.ts +1 -0
- package/src/providers/pinpoint/apis/record.ts +36 -33
- package/src/providers/pinpoint/apis/updateEndpoint.ts +26 -10
- package/src/providers/pinpoint/index.ts +6 -1
- 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 +7 -3
- package/src/providers/pinpoint/utils/PinpointEventBuffer.ts +21 -13
- package/src/providers/pinpoint/utils/index.ts +1 -0
- package/src/providers/pinpoint/utils/isAppInForeground.native.ts +7 -0
- package/src/providers/pinpoint/utils/isAppInForeground.ts +4 -0
- package/src/providers/pinpoint/utils/resolveEndpointId.ts +46 -0
- package/src/singleton/API/types.ts +90 -0
- package/src/singleton/Amplify.ts +10 -8
- package/src/singleton/Analytics/types.ts +7 -1
- package/src/singleton/Auth/types.ts +53 -4
- package/src/singleton/Auth/utils/errorHelpers.ts +37 -0
- package/src/singleton/Auth/utils/index.ts +35 -38
- package/src/singleton/Cache/types.ts +27 -0
- package/src/singleton/Geo/types.ts +20 -0
- package/src/singleton/Interactions/types.ts +29 -0
- package/src/singleton/Notifications/InAppMessaging/types.ts +6 -0
- package/src/singleton/Notifications/PushNotification/types.ts +6 -0
- package/src/singleton/Notifications/types.ts +10 -0
- package/src/singleton/Predictions/types.ts +61 -0
- package/src/singleton/types.ts +15 -7
- package/src/storage/CookieStorage.native.ts +13 -0
- package/src/storage/CookieStorage.ts +68 -0
- package/src/storage/DefaultStorage.native.ts +58 -0
- package/src/storage/DefaultStorage.ts +14 -0
- package/src/storage/InMemoryStorage.ts +36 -0
- package/src/{StorageHelper/sessionStorage.ts → storage/KeyValueStorage.ts} +15 -18
- package/src/storage/SessionStorage.ts +14 -0
- package/src/storage/index.ts +13 -0
- package/src/storage/utils.ts +22 -0
- package/src/types/core.ts +4 -1
- package/src/types/errors.ts +15 -3
- package/src/types/storage.ts +4 -0
- package/src/utils/amplifyUrl/index.ts +9 -0
- package/src/utils/amplifyUrl/polyfill.native.ts +6 -0
- package/src/utils/amplifyUrl/polyfill.ts +4 -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/convert/base64/base64Decoder.ts +11 -0
- package/src/utils/convert/base64/base64Encoder.ts +18 -0
- package/src/utils/convert/base64/bytesToString.ts +6 -0
- package/src/utils/convert/index.ts +5 -0
- package/src/utils/convert/types.ts +17 -0
- package/src/utils/deepFreeze.ts +16 -0
- package/src/utils/generateRandomString.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/globalHelpers/index.native.ts +30 -0
- package/src/utils/globalHelpers/index.ts +54 -0
- package/src/utils/index.ts +17 -0
- package/src/utils/isBrowser.ts +5 -0
- package/src/utils/isWebWorker.ts +13 -0
- package/src/utils/retry/NonRetryableError.ts +9 -0
- package/src/utils/retry/constants.ts +4 -0
- package/src/utils/retry/index.ts +8 -0
- package/src/utils/retry/isNonRetryableError.ts +9 -0
- package/src/utils/retry/jitteredBackoff.ts +21 -0
- package/src/utils/retry/jitteredExponentialRetry.ts +18 -0
- package/src/{Util/Retry.ts → utils/retry/retry.ts} +4 -44
- package/src/utils/sessionListener/SessionListener.native.ts +70 -0
- package/src/utils/sessionListener/SessionListener.ts +74 -0
- package/src/utils/sessionListener/constants.ts +6 -0
- package/src/utils/sessionListener/index.ts +7 -0
- package/src/utils/sessionListener/types.ts +11 -0
- package/src/{Util/StringUtils.ts → utils/urlSafeDecode.ts} +0 -6
- package/src/utils/urlSafeEncode.ts +9 -0
- package/lib/Amplify.d.ts +0 -29
- package/lib/Amplify.js +0 -118
- package/lib/AwsClients/CognitoIdentity/base.js +0 -114
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +0 -83
- package/lib/AwsClients/CognitoIdentity/getId.js +0 -73
- package/lib/AwsClients/Pinpoint/getInAppMessages.js +0 -77
- package/lib/AwsClients/Pinpoint/putEvents.js +0 -84
- package/lib/AwsClients/Pinpoint/updateEndpoint.js +0 -81
- package/lib/Cache/AsyncStorageCache.js +0 -744
- package/lib/Cache/BrowserStorageCache.d.ts +0 -166
- package/lib/Cache/BrowserStorageCache.js +0 -469
- package/lib/Cache/InMemoryCache.d.ts +0 -129
- package/lib/Cache/InMemoryCache.js +0 -349
- package/lib/Cache/Utils/CacheList.js +0 -196
- package/lib/Cache/Utils/CacheUtils.d.ts +0 -25
- package/lib/Cache/Utils/CacheUtils.js +0 -88
- 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/browser.js +0 -80
- 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/RNComponents/index.d.ts +0 -6
- package/lib/RNComponents/index.js +0 -16
- package/lib/RNComponents/reactnative.d.ts +0 -3
- package/lib/RNComponents/reactnative.js +0 -14
- package/lib/StorageHelper/cookieStorage.js +0 -167
- package/lib/StorageHelper/inMemoryStorage.d.ts +0 -10
- package/lib/StorageHelper/inMemoryStorage.js +0 -82
- package/lib/StorageHelper/index.d.ts +0 -45
- package/lib/StorageHelper/index.js +0 -83
- package/lib/StorageHelper/localStorage.js +0 -114
- package/lib/StorageHelper/reactnative.d.ts +0 -83
- package/lib/StorageHelper/reactnative.js +0 -250
- package/lib/StorageHelper/sessionStorage.js +0 -114
- package/lib/Util/BackgroundProcessManager.js +0 -449
- package/lib/Util/Constants.d.ts +0 -12
- package/lib/Util/Constants.js +0 -29
- package/lib/Util/Errors.js +0 -62
- package/lib/Util/JS.d.ts +0 -29
- package/lib/Util/JS.js +0 -214
- package/lib/Util/Reachability.d.ts +0 -13
- package/lib/Util/Reachability.js +0 -69
- package/lib/Util/Reachability.native.d.ts +0 -12
- package/lib/Util/Retry.d.ts +0 -21
- package/lib/Util/Retry.js +0 -205
- package/lib/Util/StringUtils.js +0 -17
- package/lib/Util/errors/AssertError.d.ts +0 -2
- package/lib/Util/errors/AssertError.js +0 -11
- package/lib/Util/index.d.ts +0 -7
- package/lib/Util/index.js +0 -31
- package/lib/clients/middleware/signing/signer/signatureV4/index.native.d.ts +0 -5
- package/lib/clients/middleware/signing/signer/signatureV4/index.native.js +0 -15
- package/lib-esm/Amplify.d.ts +0 -29
- package/lib-esm/Amplify.js +0 -115
- package/lib-esm/AwsClients/CognitoIdentity/base.js +0 -109
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +0 -80
- package/lib-esm/AwsClients/CognitoIdentity/getId.js +0 -70
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.js +0 -74
- package/lib-esm/AwsClients/Pinpoint/putEvents.js +0 -81
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.js +0 -78
- package/lib-esm/Cache/AsyncStorageCache.js +0 -737
- package/lib-esm/Cache/BrowserStorageCache.d.ts +0 -166
- package/lib-esm/Cache/BrowserStorageCache.js +0 -466
- package/lib-esm/Cache/InMemoryCache.d.ts +0 -129
- package/lib-esm/Cache/InMemoryCache.js +0 -346
- package/lib-esm/Cache/Utils/CacheUtils.d.ts +0 -25
- package/lib-esm/Cache/Utils/CacheUtils.js +0 -81
- 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/lib-esm/RNComponents/index.d.ts +0 -6
- package/lib-esm/RNComponents/index.js +0 -13
- package/lib-esm/RNComponents/isAppInForeground.js +0 -6
- package/lib-esm/RNComponents/reactnative.d.ts +0 -3
- package/lib-esm/RNComponents/reactnative.js +0 -6
- package/lib-esm/Signer.js +0 -127
- package/lib-esm/StorageHelper/cookieStorage.js +0 -141
- package/lib-esm/StorageHelper/inMemoryStorage.d.ts +0 -10
- package/lib-esm/StorageHelper/inMemoryStorage.js +0 -79
- package/lib-esm/StorageHelper/index.d.ts +0 -45
- package/lib-esm/StorageHelper/index.js +0 -76
- package/lib-esm/StorageHelper/localStorage.js +0 -111
- package/lib-esm/StorageHelper/reactnative.d.ts +0 -83
- package/lib-esm/StorageHelper/reactnative.js +0 -244
- package/lib-esm/StorageHelper/sessionStorage.js +0 -111
- package/lib-esm/Util/BackgroundProcessManager.js +0 -446
- package/lib-esm/Util/Constants.d.ts +0 -12
- package/lib-esm/Util/Constants.js +0 -26
- package/lib-esm/Util/Errors.js +0 -57
- package/lib-esm/Util/JS.d.ts +0 -29
- package/lib-esm/Util/JS.js +0 -199
- package/lib-esm/Util/Reachability.d.ts +0 -13
- package/lib-esm/Util/Reachability.js +0 -64
- package/lib-esm/Util/Reachability.native.d.ts +0 -12
- package/lib-esm/Util/Retry.d.ts +0 -21
- package/lib-esm/Util/Retry.js +0 -198
- package/lib-esm/Util/StringUtils.js +0 -12
- package/lib-esm/Util/errors/AssertError.d.ts +0 -2
- package/lib-esm/Util/errors/AssertError.js +0 -7
- package/lib-esm/Util/index.d.ts +0 -7
- package/lib-esm/Util/index.js +0 -9
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.d.ts +0 -5
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.js +0 -8
- package/polyfills/URL/index.ts +0 -14
- package/polyfills/URL/tsconfig.json +0 -10
- package/polyfills/URL/webpack.config.js +0 -43
- package/src/Amplify.ts +0 -106
- package/src/Cache/AsyncStorageCache.ts +0 -500
- package/src/Cache/BrowserStorageCache.ts +0 -517
- package/src/Cache/CHANGELOG.md +0 -1239
- package/src/Cache/InMemoryCache.ts +0 -354
- package/src/Cache/Utils/CacheUtils.ts +0 -92
- 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/src/RNComponents/index.ts +0 -16
- package/src/RNComponents/isAppInForeground.ts +0 -8
- package/src/RNComponents/reactnative.ts +0 -6
- package/src/StorageHelper/cookieStorage.ts +0 -99
- package/src/StorageHelper/inMemoryStorage.ts +0 -32
- package/src/StorageHelper/index.ts +0 -78
- package/src/StorageHelper/localStorage.ts +0 -60
- package/src/StorageHelper/reactnative.ts +0 -182
- package/src/Util/JS.ts +0 -255
- package/src/Util/Reachability.ts +0 -58
- package/src/Util/errors/AssertError.ts +0 -11
- package/src/Util/index.ts +0 -23
- package/src/clients/middleware/signing/signer/signatureV4/index.native.ts +0 -10
- /package/lib/{AwsClients/CognitoIdentity/types.js → Cache/types/cache.js} +0 -0
- /package/lib/{Cache/types/Cache.js → Mutex/types.js} +0 -0
- /package/lib/{Util → Signer}/DateUtils.d.ts +0 -0
- /package/lib/{Signer.d.ts → Signer/Signer.d.ts} +0 -0
- /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/base.d.ts +0 -0
- /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/index.d.ts +0 -0
- /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/index.js +0 -0
- /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/types.d.ts +0 -0
- /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/base.d.ts +0 -0
- /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/index.d.ts +0 -0
- /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/index.js +0 -0
- /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/types.d.ts +0 -0
- /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/types.js +0 -0
- /package/lib-esm/{AwsClients/CognitoIdentity/types.js → Cache/types/cache.js} +0 -0
- /package/lib-esm/{Cache/types/Cache.js → Mutex/types.js} +0 -0
- /package/lib-esm/{Util → Signer}/DateUtils.d.ts +0 -0
- /package/lib-esm/{Signer.d.ts → Signer/Signer.d.ts} +0 -0
- /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/base.d.ts +0 -0
- /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/index.d.ts +0 -0
- /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/index.js +0 -0
- /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/types.d.ts +0 -0
- /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/base.d.ts +0 -0
- /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/index.d.ts +0 -0
- /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/index.js +0 -0
- /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/types.d.ts +0 -0
- /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/types.js +0 -0
- /package/lib-esm/{RNComponents → providers/pinpoint/utils}/isAppInForeground.d.ts +0 -0
- /package/{lib/RNComponents/isAppInForeground.d.ts → lib-esm/providers/pinpoint/utils/isAppInForeground.native.d.ts} +0 -0
- /package/src/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getCredentialsForIdentity.ts +0 -0
- /package/src/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getId.ts +0 -0
- /package/src/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/index.ts +0 -0
- /package/src/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/types.ts +0 -0
- /package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/index.ts +0 -0
- /package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/types.ts +0 -0
|
@@ -1,23 +1,11 @@
|
|
|
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
|
import { ConsoleLogger as Logger } from '../Logger';
|
|
16
|
-
import { isBrowser } from '../
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
4
|
+
import { isBrowser } from '../utils';
|
|
5
|
+
import { AmplifyError } from '../errors';
|
|
6
|
+
import { assert, ServiceWorkerErrorCode } from './errorHelpers';
|
|
7
|
+
import { record } from '../providers/pinpoint';
|
|
8
|
+
import { Amplify, fetchAuthSession } from '../singleton';
|
|
21
9
|
/**
|
|
22
10
|
* Provides a means to registering a service worker in the browser
|
|
23
11
|
* and communicating with it via postMessage events.
|
|
@@ -30,25 +18,18 @@ import { SERVICE_WORKER_EXCEPTION } from '../Util/Constants';
|
|
|
30
18
|
* and attempt to dispatch messages on state change and record analytics
|
|
31
19
|
* events based on the service worker lifecycle.
|
|
32
20
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
export class ServiceWorkerClass {
|
|
22
|
+
constructor() {
|
|
35
23
|
// The AWS Amplify logger
|
|
36
24
|
this._logger = new Logger('ServiceWorker');
|
|
37
25
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
message: 'Service Worker instance is undefined',
|
|
46
|
-
});
|
|
47
|
-
return this._serviceWorker;
|
|
48
|
-
},
|
|
49
|
-
enumerable: false,
|
|
50
|
-
configurable: true
|
|
51
|
-
});
|
|
26
|
+
/**
|
|
27
|
+
* Get the currently active service worker
|
|
28
|
+
*/
|
|
29
|
+
get serviceWorker() {
|
|
30
|
+
assert(this._serviceWorker !== undefined, ServiceWorkerErrorCode.UndefinedInstance);
|
|
31
|
+
return this._serviceWorker;
|
|
32
|
+
}
|
|
52
33
|
/**
|
|
53
34
|
* Register the service-worker.js file in the browser
|
|
54
35
|
* Make sure the service-worker.js is part of the build
|
|
@@ -61,37 +42,34 @@ var ServiceWorkerClass = /** @class */ (function () {
|
|
|
61
42
|
* - resolve(ServiceWorkerRegistration)
|
|
62
43
|
* - reject(Error)
|
|
63
44
|
**/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this._logger.debug("registering ".concat(filePath));
|
|
69
|
-
this._logger.debug("registering service worker with scope ".concat(scope));
|
|
70
|
-
return new Promise(function (resolve, reject) {
|
|
45
|
+
register(filePath = '/service-worker.js', scope = '/') {
|
|
46
|
+
this._logger.debug(`registering ${filePath}`);
|
|
47
|
+
this._logger.debug(`registering service worker with scope ${scope}`);
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
71
49
|
if (navigator && 'serviceWorker' in navigator) {
|
|
72
50
|
navigator.serviceWorker
|
|
73
51
|
.register(filePath, {
|
|
74
|
-
scope
|
|
52
|
+
scope,
|
|
75
53
|
})
|
|
76
|
-
.then(
|
|
54
|
+
.then(registration => {
|
|
77
55
|
if (registration.installing) {
|
|
78
|
-
|
|
56
|
+
this._serviceWorker = registration.installing;
|
|
79
57
|
}
|
|
80
58
|
else if (registration.waiting) {
|
|
81
|
-
|
|
59
|
+
this._serviceWorker = registration.waiting;
|
|
82
60
|
}
|
|
83
61
|
else if (registration.active) {
|
|
84
|
-
|
|
62
|
+
this._serviceWorker = registration.active;
|
|
85
63
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
64
|
+
this._registration = registration;
|
|
65
|
+
this._setupListeners();
|
|
66
|
+
this._logger.debug(`Service Worker Registration Success: ${registration}`);
|
|
89
67
|
return resolve(registration);
|
|
90
68
|
})
|
|
91
|
-
.catch(
|
|
92
|
-
|
|
69
|
+
.catch(error => {
|
|
70
|
+
this._logger.debug(`Service Worker Registration Failed ${error}`);
|
|
93
71
|
return reject(new AmplifyError({
|
|
94
|
-
name:
|
|
72
|
+
name: ServiceWorkerErrorCode.Unavailable,
|
|
95
73
|
message: 'Service Worker not available',
|
|
96
74
|
underlyingError: error,
|
|
97
75
|
}));
|
|
@@ -99,12 +77,12 @@ var ServiceWorkerClass = /** @class */ (function () {
|
|
|
99
77
|
}
|
|
100
78
|
else {
|
|
101
79
|
return reject(new AmplifyError({
|
|
102
|
-
name:
|
|
80
|
+
name: ServiceWorkerErrorCode.Unavailable,
|
|
103
81
|
message: 'Service Worker not available',
|
|
104
82
|
}));
|
|
105
83
|
}
|
|
106
84
|
});
|
|
107
|
-
}
|
|
85
|
+
}
|
|
108
86
|
/**
|
|
109
87
|
* Enable web push notifications. If not subscribed, a new subscription will
|
|
110
88
|
* be created and registered.
|
|
@@ -116,66 +94,59 @@ var ServiceWorkerClass = /** @class */ (function () {
|
|
|
116
94
|
* - resolve(PushSubscription)
|
|
117
95
|
* - reject(Error)
|
|
118
96
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
asserts(this._registration !== undefined, {
|
|
122
|
-
name: SERVICE_WORKER_EXCEPTION,
|
|
123
|
-
message: 'Service Worker registration is undefined',
|
|
124
|
-
});
|
|
97
|
+
enablePush(publicKey) {
|
|
98
|
+
assert(this._registration !== undefined, ServiceWorkerErrorCode.UndefinedRegistration);
|
|
125
99
|
this._publicKey = publicKey;
|
|
126
|
-
return new Promise(
|
|
100
|
+
return new Promise((resolve, reject) => {
|
|
127
101
|
if (isBrowser()) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
message: 'Service Worker registration is undefined',
|
|
131
|
-
});
|
|
132
|
-
_this._registration.pushManager.getSubscription().then(function (subscription) {
|
|
102
|
+
assert(this._registration !== undefined, ServiceWorkerErrorCode.UndefinedRegistration);
|
|
103
|
+
this._registration.pushManager.getSubscription().then(subscription => {
|
|
133
104
|
if (subscription) {
|
|
134
|
-
|
|
135
|
-
|
|
105
|
+
this._subscription = subscription;
|
|
106
|
+
this._logger.debug(`User is subscribed to push: ${JSON.stringify(subscription)}`);
|
|
136
107
|
resolve(subscription);
|
|
137
108
|
}
|
|
138
109
|
else {
|
|
139
|
-
|
|
140
|
-
return
|
|
110
|
+
this._logger.debug(`User is NOT subscribed to push`);
|
|
111
|
+
return this._registration.pushManager.subscribe({
|
|
141
112
|
userVisibleOnly: true,
|
|
142
|
-
applicationServerKey:
|
|
113
|
+
applicationServerKey: this._urlB64ToUint8Array(publicKey),
|
|
143
114
|
})
|
|
144
|
-
.then(
|
|
145
|
-
|
|
146
|
-
|
|
115
|
+
.then(subscription => {
|
|
116
|
+
this._subscription = subscription;
|
|
117
|
+
this._logger.debug(`User subscribed: ${JSON.stringify(subscription)}`);
|
|
147
118
|
resolve(subscription);
|
|
148
119
|
})
|
|
149
|
-
.catch(
|
|
150
|
-
|
|
120
|
+
.catch(error => {
|
|
121
|
+
this._logger.error(error);
|
|
151
122
|
});
|
|
152
123
|
}
|
|
153
124
|
});
|
|
154
125
|
}
|
|
155
126
|
else {
|
|
156
127
|
return reject(new AmplifyError({
|
|
157
|
-
name:
|
|
128
|
+
name: ServiceWorkerErrorCode.Unavailable,
|
|
158
129
|
message: 'Service Worker not available',
|
|
159
130
|
}));
|
|
160
131
|
}
|
|
161
132
|
});
|
|
162
|
-
}
|
|
133
|
+
}
|
|
163
134
|
/**
|
|
164
135
|
* Convert a base64 encoded string to a Uint8 array for the push server key
|
|
165
136
|
* @param base64String
|
|
166
137
|
*/
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
138
|
+
_urlB64ToUint8Array(base64String) {
|
|
139
|
+
const padding = '='.repeat((4 - (base64String.length % 4)) % 4);
|
|
140
|
+
const base64 = (base64String + padding)
|
|
170
141
|
.replace(/\-/g, '+')
|
|
171
142
|
.replace(/_/g, '/');
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
for (
|
|
143
|
+
const rawData = window.atob(base64);
|
|
144
|
+
const outputArray = new Uint8Array(rawData.length);
|
|
145
|
+
for (let i = 0; i < rawData.length; ++i) {
|
|
175
146
|
outputArray[i] = rawData.charCodeAt(i);
|
|
176
147
|
}
|
|
177
148
|
return outputArray;
|
|
178
|
-
}
|
|
149
|
+
}
|
|
179
150
|
/**
|
|
180
151
|
* Send a message to the service worker. The service worker needs
|
|
181
152
|
* to implement `self.addEventListener('message') to handle the
|
|
@@ -184,37 +155,39 @@ var ServiceWorkerClass = /** @class */ (function () {
|
|
|
184
155
|
* - see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable
|
|
185
156
|
* @returns {Promise}
|
|
186
157
|
**/
|
|
187
|
-
|
|
158
|
+
send(message) {
|
|
188
159
|
if (this._serviceWorker) {
|
|
189
160
|
this._serviceWorker.postMessage(typeof message === 'object' ? JSON.stringify(message) : message);
|
|
190
161
|
}
|
|
191
|
-
}
|
|
162
|
+
}
|
|
192
163
|
/**
|
|
193
164
|
* Listen for service worker state change and message events
|
|
194
165
|
* https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/state
|
|
195
166
|
**/
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
167
|
+
_setupListeners() {
|
|
168
|
+
this.serviceWorker.addEventListener('statechange', async (event) => {
|
|
169
|
+
const currentState = this.serviceWorker.state;
|
|
170
|
+
this._logger.debug(`ServiceWorker statechange: ${currentState}`);
|
|
171
|
+
const { appId, region } = Amplify.getConfig().Analytics?.Pinpoint ?? {};
|
|
172
|
+
const { credentials } = await fetchAuthSession();
|
|
173
|
+
if (appId && region && credentials) {
|
|
174
|
+
// Pinpoint is configured, record an event
|
|
175
|
+
record({
|
|
176
|
+
appId,
|
|
177
|
+
region,
|
|
178
|
+
category: 'Core',
|
|
179
|
+
credentials,
|
|
180
|
+
event: {
|
|
181
|
+
name: 'ServiceWorker',
|
|
182
|
+
attributes: {
|
|
183
|
+
state: currentState,
|
|
184
|
+
},
|
|
207
185
|
},
|
|
208
186
|
});
|
|
209
187
|
}
|
|
210
188
|
});
|
|
211
|
-
this.serviceWorker.addEventListener('message',
|
|
212
|
-
|
|
189
|
+
this.serviceWorker.addEventListener('message', event => {
|
|
190
|
+
this._logger.debug(`ServiceWorker message event: ${event}`);
|
|
213
191
|
});
|
|
214
|
-
}
|
|
215
|
-
return ServiceWorkerClass;
|
|
216
|
-
}());
|
|
217
|
-
export { ServiceWorkerClass };
|
|
218
|
-
function isAmplifyWithAnalytics(amplify) {
|
|
219
|
-
return amplify.Analytics && typeof amplify.Analytics.record === 'function';
|
|
192
|
+
}
|
|
220
193
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AssertionFunction } from '../types';
|
|
2
|
+
export declare enum ServiceWorkerErrorCode {
|
|
3
|
+
UndefinedInstance = "UndefinedInstance",
|
|
4
|
+
UndefinedRegistration = "UndefinedRegistration",
|
|
5
|
+
Unavailable = "Unavailable"
|
|
6
|
+
}
|
|
7
|
+
export declare const assert: AssertionFunction<ServiceWorkerErrorCode>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { createAssertionFunction } from '../errors';
|
|
4
|
+
export var ServiceWorkerErrorCode;
|
|
5
|
+
(function (ServiceWorkerErrorCode) {
|
|
6
|
+
ServiceWorkerErrorCode["UndefinedInstance"] = "UndefinedInstance";
|
|
7
|
+
ServiceWorkerErrorCode["UndefinedRegistration"] = "UndefinedRegistration";
|
|
8
|
+
ServiceWorkerErrorCode["Unavailable"] = "Unavailable";
|
|
9
|
+
})(ServiceWorkerErrorCode || (ServiceWorkerErrorCode = {}));
|
|
10
|
+
const serviceWorkerErrorMap = {
|
|
11
|
+
[ServiceWorkerErrorCode.UndefinedInstance]: {
|
|
12
|
+
message: 'Service Worker instance is undefined.',
|
|
13
|
+
},
|
|
14
|
+
[ServiceWorkerErrorCode.UndefinedRegistration]: {
|
|
15
|
+
message: 'Service Worker registration is undefined.',
|
|
16
|
+
},
|
|
17
|
+
[ServiceWorkerErrorCode.Unavailable]: {
|
|
18
|
+
message: 'Service Worker not available.',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export const assert = createAssertionFunction(serviceWorkerErrorMap);
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
|
-
* the License. A copy of the License is located at
|
|
6
|
-
*
|
|
7
|
-
* http://aws.amazon.com/apache2.0/
|
|
8
|
-
*
|
|
9
|
-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
10
|
-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
|
-
* and limitations under the License.
|
|
12
|
-
*/
|
|
13
1
|
export { ServiceWorkerClass as ServiceWorker } from './ServiceWorker';
|
|
@@ -1,15 +1,3 @@
|
|
|
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
|
export { ServiceWorkerClass as ServiceWorker } from './ServiceWorker';
|
|
@@ -6,30 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @see https://github.com/aws/aws-sdk-js/blob/6edf586dcc1de7fe8fbfbbd9a0d2b1847921e6e1/lib/util.js#L262
|
|
8
8
|
*/
|
|
9
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
10
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
11
|
-
if (!m) return o;
|
|
12
|
-
var i = m.call(o), r, ar = [], e;
|
|
13
|
-
try {
|
|
14
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
15
|
-
}
|
|
16
|
-
catch (error) { e = { error: error }; }
|
|
17
|
-
finally {
|
|
18
|
-
try {
|
|
19
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
20
|
-
}
|
|
21
|
-
finally { if (e) throw e.error; }
|
|
22
|
-
}
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
9
|
// Comment - TODO: remove
|
|
26
|
-
|
|
27
|
-
export
|
|
10
|
+
const FIVE_MINUTES_IN_MS = 1000 * 60 * 5;
|
|
11
|
+
export const DateUtils = {
|
|
28
12
|
/**
|
|
29
13
|
* Milliseconds to offset the date to compensate for clock skew between device & services
|
|
30
14
|
*/
|
|
31
15
|
clockOffset: 0,
|
|
32
|
-
getDateWithClockOffset
|
|
16
|
+
getDateWithClockOffset() {
|
|
33
17
|
if (DateUtils.clockOffset) {
|
|
34
18
|
return new Date(new Date().getTime() + DateUtils.clockOffset);
|
|
35
19
|
}
|
|
@@ -40,33 +24,32 @@ export var DateUtils = {
|
|
|
40
24
|
/**
|
|
41
25
|
* @returns {number} Clock offset in milliseconds
|
|
42
26
|
*/
|
|
43
|
-
getClockOffset
|
|
27
|
+
getClockOffset() {
|
|
44
28
|
return DateUtils.clockOffset;
|
|
45
29
|
},
|
|
46
|
-
getHeaderStringFromDate
|
|
47
|
-
if (date === void 0) { date = DateUtils.getDateWithClockOffset(); }
|
|
30
|
+
getHeaderStringFromDate(date = DateUtils.getDateWithClockOffset()) {
|
|
48
31
|
return date.toISOString().replace(/[:\-]|\.\d{3}/g, '');
|
|
49
32
|
},
|
|
50
|
-
getDateFromHeaderString
|
|
51
|
-
|
|
33
|
+
getDateFromHeaderString(header) {
|
|
34
|
+
const [, year, month, day, hour, minute, second] = header.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2}).+/);
|
|
52
35
|
return new Date(Date.UTC(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), Number(second)));
|
|
53
36
|
},
|
|
54
|
-
isClockSkewed
|
|
37
|
+
isClockSkewed(serverDate) {
|
|
55
38
|
// API gateway permits client calls that are off by no more than ±5 minutes
|
|
56
39
|
return (Math.abs(serverDate.getTime() - DateUtils.getDateWithClockOffset().getTime()) >= FIVE_MINUTES_IN_MS);
|
|
57
40
|
},
|
|
58
|
-
isClockSkewError
|
|
41
|
+
isClockSkewError(error) {
|
|
59
42
|
if (!error.response || !error.response.headers) {
|
|
60
43
|
return false;
|
|
61
44
|
}
|
|
62
|
-
|
|
45
|
+
const { headers } = error.response;
|
|
63
46
|
return Boolean(['BadRequestException', 'InvalidSignatureException'].includes(headers['x-amzn-errortype']) &&
|
|
64
47
|
(headers.date || headers.Date));
|
|
65
48
|
},
|
|
66
49
|
/**
|
|
67
50
|
* @param {number} offset Clock offset in milliseconds
|
|
68
51
|
*/
|
|
69
|
-
setClockOffset
|
|
52
|
+
setClockOffset(offset) {
|
|
70
53
|
DateUtils.clockOffset = offset;
|
|
71
54
|
},
|
|
72
55
|
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { DateUtils } from './DateUtils';
|
|
4
|
+
import { presignUrl, signRequest, TOKEN_QUERY_PARAM, } from '../clients/middleware/signing/signer/signatureV4';
|
|
5
|
+
import { AmplifyUrl } from '../utils/amplifyUrl';
|
|
6
|
+
const IOT_SERVICE_NAME = 'iotdevicegateway';
|
|
7
|
+
// Best practice regex to parse the service and region from an AWS endpoint
|
|
8
|
+
const AWS_ENDPOINT_REGEX = /([^\.]+)\.(?:([^\.]*)\.)?amazonaws\.com(.cn)?$/;
|
|
9
|
+
export class Signer {
|
|
10
|
+
/**
|
|
11
|
+
* Sign a HTTP request, add 'Authorization' header to request param
|
|
12
|
+
* @method sign
|
|
13
|
+
* @memberof Signer
|
|
14
|
+
* @static
|
|
15
|
+
*
|
|
16
|
+
* @param {object} request - HTTP request object
|
|
17
|
+
<pre>
|
|
18
|
+
request: {
|
|
19
|
+
method: GET | POST | PUT ...
|
|
20
|
+
url: ...,
|
|
21
|
+
headers: {
|
|
22
|
+
header1: ...
|
|
23
|
+
},
|
|
24
|
+
data: data
|
|
25
|
+
}
|
|
26
|
+
</pre>
|
|
27
|
+
* @param {object} access_info - AWS access credential info
|
|
28
|
+
<pre>
|
|
29
|
+
access_info: {
|
|
30
|
+
access_key: ...,
|
|
31
|
+
secret_key: ...,
|
|
32
|
+
session_token: ...
|
|
33
|
+
}
|
|
34
|
+
</pre>
|
|
35
|
+
* @param {object} [service_info] - AWS service type and region, optional,
|
|
36
|
+
* if not provided then parse out from url
|
|
37
|
+
<pre>
|
|
38
|
+
service_info: {
|
|
39
|
+
service: ...,
|
|
40
|
+
region: ...
|
|
41
|
+
}
|
|
42
|
+
</pre>
|
|
43
|
+
*
|
|
44
|
+
* @returns {object} Signed HTTP request
|
|
45
|
+
*/
|
|
46
|
+
static sign(request, accessInfo, serviceInfo) {
|
|
47
|
+
request.headers = request.headers || {};
|
|
48
|
+
if (request.body && !request.data) {
|
|
49
|
+
throw new Error('The attribute "body" was found on the request object. Please use the attribute "data" instead.');
|
|
50
|
+
}
|
|
51
|
+
const requestToSign = {
|
|
52
|
+
...request,
|
|
53
|
+
body: request.data,
|
|
54
|
+
url: new AmplifyUrl(request.url),
|
|
55
|
+
};
|
|
56
|
+
const options = getOptions(requestToSign, accessInfo, serviceInfo);
|
|
57
|
+
const signedRequest = signRequest(requestToSign, options);
|
|
58
|
+
// Prior to using `signRequest`, Signer accepted urls as strings and outputted urls as string. Coerce the property
|
|
59
|
+
// back to a string so as not to disrupt consumers of Signer.
|
|
60
|
+
signedRequest.url = signedRequest.url.toString();
|
|
61
|
+
// HTTP headers should be case insensitive but, to maintain parity with the previous Signer implementation and
|
|
62
|
+
// limit the impact of this implementation swap, replace lowercased headers with title cased ones.
|
|
63
|
+
signedRequest.headers.Authorization = signedRequest.headers.authorization;
|
|
64
|
+
signedRequest.headers['X-Amz-Security-Token'] =
|
|
65
|
+
signedRequest.headers['x-amz-security-token'];
|
|
66
|
+
delete signedRequest.headers.authorization;
|
|
67
|
+
delete signedRequest.headers['x-amz-security-token'];
|
|
68
|
+
return signedRequest;
|
|
69
|
+
}
|
|
70
|
+
static signUrl(urlOrRequest, accessInfo, serviceInfo, expiration) {
|
|
71
|
+
const urlToSign = typeof urlOrRequest === 'object' ? urlOrRequest.url : urlOrRequest;
|
|
72
|
+
const method = typeof urlOrRequest === 'object' ? urlOrRequest.method : 'GET';
|
|
73
|
+
const body = typeof urlOrRequest === 'object' ? urlOrRequest.body : undefined;
|
|
74
|
+
const presignable = {
|
|
75
|
+
body,
|
|
76
|
+
method,
|
|
77
|
+
url: new AmplifyUrl(urlToSign),
|
|
78
|
+
};
|
|
79
|
+
const options = getOptions(presignable, accessInfo, serviceInfo, expiration);
|
|
80
|
+
const signedUrl = presignUrl(presignable, options);
|
|
81
|
+
if (accessInfo.session_token &&
|
|
82
|
+
!sessionTokenRequiredInSigning(options.signingService)) {
|
|
83
|
+
signedUrl.searchParams.append(TOKEN_QUERY_PARAM, accessInfo.session_token);
|
|
84
|
+
}
|
|
85
|
+
return signedUrl.toString();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const getOptions = (request, accessInfo, serviceInfo, expiration) => {
|
|
89
|
+
const { access_key, secret_key, session_token } = accessInfo ?? {};
|
|
90
|
+
const { region: urlRegion, service: urlService } = parseServiceInfo(request.url);
|
|
91
|
+
const { region = urlRegion, service = urlService } = serviceInfo ?? {};
|
|
92
|
+
const credentials = {
|
|
93
|
+
accessKeyId: access_key,
|
|
94
|
+
secretAccessKey: secret_key,
|
|
95
|
+
...(sessionTokenRequiredInSigning(service)
|
|
96
|
+
? { sessionToken: session_token }
|
|
97
|
+
: {}),
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
credentials,
|
|
101
|
+
signingDate: DateUtils.getDateWithClockOffset(),
|
|
102
|
+
signingRegion: region,
|
|
103
|
+
signingService: service,
|
|
104
|
+
...(expiration && { expiration }),
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
// TODO: V6 investigate whether add to custom clients' general signer implementation.
|
|
108
|
+
const parseServiceInfo = (url) => {
|
|
109
|
+
const host = url.host;
|
|
110
|
+
const matched = host.match(AWS_ENDPOINT_REGEX) ?? [];
|
|
111
|
+
let parsed = matched.slice(1, 3);
|
|
112
|
+
if (parsed[1] === 'es') {
|
|
113
|
+
// Elastic Search
|
|
114
|
+
parsed = parsed.reverse();
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
service: parsed[0],
|
|
118
|
+
region: parsed[1],
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
// IoT service does not allow the session token in the canonical request
|
|
122
|
+
// https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html
|
|
123
|
+
// TODO: V6 investigate whether add to custom clients' general signer implementation.
|
|
124
|
+
const sessionTokenRequiredInSigning = (service) => service !== IOT_SERVICE_NAME;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Signer } from './Signer';
|
|
@@ -1,32 +1,13 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
-
return extendStatics(d, b);
|
|
9
|
-
};
|
|
10
|
-
return function (d, b) {
|
|
11
|
-
if (typeof b !== "function" && b !== null)
|
|
12
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
-
extendStatics(d, b);
|
|
14
|
-
function __() { this.constructor = d; }
|
|
15
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
-
};
|
|
17
|
-
})();
|
|
18
|
-
import { AmplifyError } from '../../libraryUtils';
|
|
19
|
-
var AmplifyServerContextError = /** @class */ (function (_super) {
|
|
20
|
-
__extends(AmplifyServerContextError, _super);
|
|
21
|
-
function AmplifyServerContextError(_a) {
|
|
22
|
-
var message = _a.message, recoverySuggestion = _a.recoverySuggestion, underlyingError = _a.underlyingError;
|
|
23
|
-
return _super.call(this, {
|
|
3
|
+
import { AmplifyError } from '../../errors';
|
|
4
|
+
export class AmplifyServerContextError extends AmplifyError {
|
|
5
|
+
constructor({ message, recoverySuggestion, underlyingError, }) {
|
|
6
|
+
super({
|
|
24
7
|
name: 'AmplifyServerContextError',
|
|
25
|
-
message
|
|
26
|
-
recoverySuggestion
|
|
27
|
-
underlyingError
|
|
28
|
-
})
|
|
8
|
+
message,
|
|
9
|
+
recoverySuggestion,
|
|
10
|
+
underlyingError,
|
|
11
|
+
});
|
|
29
12
|
}
|
|
30
|
-
|
|
31
|
-
}(AmplifyError));
|
|
32
|
-
export { AmplifyServerContextError };
|
|
13
|
+
}
|
|
@@ -8,11 +8,11 @@ import { AmplifyClass } from '../../singleton';
|
|
|
8
8
|
* @param libraryOptions The Amplify library options.
|
|
9
9
|
* @returns The Amplify server context spec.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
12
|
-
|
|
11
|
+
export const createAmplifyServerContext = (amplifyConfig, libraryOptions) => {
|
|
12
|
+
const amplify = new AmplifyClass();
|
|
13
13
|
amplify.configure(amplifyConfig, libraryOptions);
|
|
14
14
|
return serverContextRegistry.register({
|
|
15
|
-
amplify
|
|
15
|
+
amplify,
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
@@ -20,8 +20,8 @@ export var createAmplifyServerContext = function (amplifyConfig, libraryOptions)
|
|
|
20
20
|
* @param contextSpec The context spec used to get the Amplify server context.
|
|
21
21
|
* @returns The Amplify server context.
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
24
|
-
|
|
23
|
+
export const getAmplifyServerContext = (contextSpec) => {
|
|
24
|
+
const context = serverContextRegistry.get(contextSpec);
|
|
25
25
|
if (context) {
|
|
26
26
|
return context;
|
|
27
27
|
}
|
|
@@ -31,6 +31,6 @@ export var getAmplifyServerContext = function (contextSpec) {
|
|
|
31
31
|
* Destroys an Amplify server context.
|
|
32
32
|
* @param contextSpec The context spec used to destroy the Amplify server context.
|
|
33
33
|
*/
|
|
34
|
-
export
|
|
34
|
+
export const destroyAmplifyServerContext = (contextSpec) => {
|
|
35
35
|
serverContextRegistry.deregister(contextSpec);
|
|
36
36
|
};
|