@aws-amplify/core 6.0.1-api-v6-models.9351bcf.0 → 6.0.1-api-v6-models.891fe0d.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/BackgroundProcessManager/BackgroundManagerNotOpenError.js +4 -21
- package/lib/BackgroundProcessManager/BackgroundProcessManager.js +126 -245
- package/lib/Cache/StorageCache.js +32 -92
- package/lib/Cache/StorageCache.native.js +38 -140
- package/lib/Cache/StorageCacheCommon.js +271 -600
- package/lib/Cache/index.js +1 -1
- package/lib/Cache/utils/CacheList.js +42 -66
- package/lib/Cache/utils/cacheHelpers.js +6 -8
- package/lib/Cache/utils/errorHelpers.js +6 -7
- package/lib/Hub/index.js +34 -74
- package/lib/I18n/I18n.js +24 -39
- package/lib/I18n/errorHelpers.js +4 -5
- package/lib/I18n/index.js +24 -27
- package/lib/I18n/types.js +3 -4
- package/lib/Logger/ConsoleLogger.js +53 -129
- package/lib/Mutex/Mutex.js +15 -19
- package/lib/Platform/customUserAgent.js +13 -26
- 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 +26 -55
- package/lib/Platform/types.d.ts +1 -1
- package/lib/Platform/types.js +1 -1
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Reachability/Reachability.js +20 -48
- package/lib/Reachability/Reachability.native.js +12 -16
- package/lib/ServiceWorker/ServiceWorker.js +80 -136
- package/lib/ServiceWorker/errorHelpers.js +6 -7
- package/lib/Signer/DateUtils.d.ts +9 -0
- package/lib/Signer/DateUtils.js +19 -28
- package/lib/Signer/Signer.d.ts +9 -0
- package/lib/Signer/Signer.js +58 -54
- 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 +25 -73
- package/lib/awsClients/cognitoIdentity/getCredentialsForIdentity.js +24 -68
- package/lib/awsClients/cognitoIdentity/getId.js +19 -62
- package/lib/awsClients/pinpoint/base.js +12 -15
- package/lib/awsClients/pinpoint/errorHelpers.js +4 -5
- package/lib/awsClients/pinpoint/getInAppMessages.js +24 -68
- package/lib/awsClients/pinpoint/putEvents.js +26 -70
- package/lib/awsClients/pinpoint/updateEndpoint.js +28 -72
- package/lib/clients/endpoints/getDnsSuffix.js +7 -29
- package/lib/clients/handlers/authenticated.js +5 -5
- package/lib/clients/handlers/fetch.js +41 -98
- 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/index.js +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.js +21 -56
- 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/utils/memoization.js +3 -3
- package/lib/constants.js +1 -1
- package/lib/errors/AmplifyError.js +9 -28
- package/lib/errors/PlatformNotSupportedError.js +7 -24
- package/lib/errors/createAssertionFunction.js +12 -15
- package/lib/errors/errorHelpers.js +7 -8
- package/lib/index.d.ts +1 -1
- package/lib/libraryUtils.d.ts +4 -0
- package/lib/libraryUtils.js +13 -3
- package/lib/parseAWSExports.js +109 -100
- package/lib/providers/kinesis/types/kinesis.d.ts +1 -1
- package/lib/providers/kinesis-firehose/types/kinesis-firehose.d.ts +1 -1
- package/lib/providers/personalize/types/personalize.d.ts +1 -1
- package/lib/providers/pinpoint/apis/flushEvents.js +8 -8
- package/lib/providers/pinpoint/apis/record.js +58 -93
- package/lib/providers/pinpoint/apis/updateEndpoint.js +65 -112
- package/lib/providers/pinpoint/types/pinpoint.d.ts +3 -1
- package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +105 -196
- 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/isAppInForeground.js +1 -1
- package/lib/providers/pinpoint/utils/isAppInForeground.native.js +2 -2
- package/lib/providers/pinpoint/utils/resolveEndpointId.js +20 -71
- package/lib/singleton/Amplify.d.ts +4 -0
- package/lib/singleton/Amplify.js +21 -103
- package/lib/singleton/Analytics/types.d.ts +5 -1
- package/lib/singleton/Auth/index.js +48 -115
- package/lib/singleton/Auth/types.d.ts +2 -2
- package/lib/singleton/Auth/utils/errorHelpers.js +7 -8
- package/lib/singleton/Auth/utils/index.js +18 -19
- 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 +3 -1
- package/lib/storage/CookieStorage.js +29 -99
- package/lib/storage/CookieStorage.native.js +5 -22
- package/lib/storage/DefaultStorage.js +6 -23
- package/lib/storage/DefaultStorage.native.js +18 -64
- package/lib/storage/InMemoryStorage.js +17 -23
- package/lib/storage/KeyValueStorage.js +24 -80
- package/lib/storage/SessionStorage.js +6 -23
- package/lib/storage/index.js +4 -4
- package/lib/storage/utils.js +7 -11
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/WordArray.d.ts +7 -0
- package/lib/utils/WordArray.js +49 -0
- package/lib/utils/amplifyUrl/index.js +2 -2
- package/lib/utils/amplifyUrl/polyfill.native.js +1 -1
- package/lib/utils/amplifyUuid/index.d.ts +1 -1
- package/lib/utils/amplifyUuid/index.js +2 -2
- package/lib/utils/amplifyUuid/polyfill.native.js +1 -1
- package/lib/utils/convert/base64/base64Decoder.js +2 -2
- package/lib/utils/convert/base64/base64Encoder.js +5 -6
- package/lib/utils/convert/base64/bytesToString.js +1 -1
- package/lib/utils/cryptoSecureRandomInt.d.ts +1 -0
- package/lib/utils/cryptoSecureRandomInt.js +16 -0
- package/lib/utils/deepFreeze.js +6 -28
- package/lib/utils/generateRandomString.js +4 -4
- package/lib/utils/getClientInfo/getClientInfo.android.js +7 -7
- package/lib/utils/getClientInfo/getClientInfo.ios.js +12 -12
- package/lib/utils/getClientInfo/getClientInfo.js +16 -16
- package/lib/utils/globalHelpers/index.js +4 -4
- package/lib/utils/globalHelpers/index.native.js +6 -6
- package/lib/utils/isBrowser.js +1 -3
- package/lib/utils/isWebWorker.js +2 -2
- package/lib/utils/retry/NonRetryableError.js +5 -23
- package/lib/utils/retry/isNonRetryableError.js +2 -2
- package/lib/utils/retry/jitteredBackoff.js +6 -7
- package/lib/utils/retry/jitteredExponentialRetry.js +4 -7
- package/lib/utils/retry/retry.js +50 -140
- package/lib/utils/sessionListener/SessionListener.js +17 -19
- package/lib/utils/sessionListener/SessionListener.native.js +18 -22
- package/lib/utils/sessionListener/constants.d.ts +2 -0
- package/lib/utils/sessionListener/constants.js +8 -0
- package/lib/utils/sessionListener/index.d.ts +1 -0
- package/lib/utils/sessionListener/index.js +5 -2
- package/lib/utils/urlSafeDecode.js +2 -2
- package/lib/utils/urlSafeEncode.js +1 -1
- package/lib-esm/BackgroundProcessManager/BackgroundManagerNotOpenError.js +4 -22
- package/lib-esm/BackgroundProcessManager/BackgroundProcessManager.js +124 -244
- package/lib-esm/Cache/StorageCache.js +26 -87
- package/lib-esm/Cache/StorageCache.native.js +33 -136
- package/lib-esm/Cache/StorageCacheCommon.js +267 -597
- package/lib-esm/Cache/constants.js +2 -2
- package/lib-esm/Cache/index.js +1 -1
- package/lib-esm/Cache/utils/CacheList.js +41 -66
- package/lib-esm/Cache/utils/cacheHelpers.js +5 -7
- package/lib-esm/Cache/utils/errorHelpers.js +6 -7
- package/lib-esm/Hub/index.js +34 -75
- package/lib-esm/I18n/I18n.js +23 -39
- package/lib-esm/I18n/errorHelpers.js +4 -5
- package/lib-esm/I18n/index.js +21 -25
- package/lib-esm/I18n/types.js +3 -5
- package/lib-esm/Logger/ConsoleLogger.js +52 -128
- package/lib-esm/Mutex/Mutex.js +15 -20
- package/lib-esm/Platform/customUserAgent.js +13 -26
- 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 +23 -52
- package/lib-esm/Platform/types.d.ts +1 -1
- package/lib-esm/Platform/types.js +1 -1
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Reachability/Reachability.js +18 -46
- package/lib-esm/Reachability/Reachability.native.js +10 -15
- package/lib-esm/ServiceWorker/ServiceWorker.js +74 -131
- package/lib-esm/ServiceWorker/errorHelpers.js +6 -7
- package/lib-esm/Signer/DateUtils.d.ts +9 -0
- package/lib-esm/Signer/DateUtils.js +20 -29
- package/lib-esm/Signer/Signer.d.ts +9 -0
- package/lib-esm/Signer/Signer.js +54 -51
- package/lib-esm/adapterCore/error/AmplifyServerContextError.js +8 -27
- 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 +21 -69
- package/lib-esm/awsClients/cognitoIdentity/getCredentialsForIdentity.js +22 -66
- package/lib-esm/awsClients/cognitoIdentity/getId.js +17 -60
- package/lib-esm/awsClients/pinpoint/base.js +8 -11
- package/lib-esm/awsClients/pinpoint/errorHelpers.js +4 -5
- package/lib-esm/awsClients/pinpoint/getInAppMessages.js +19 -63
- package/lib-esm/awsClients/pinpoint/putEvents.js +20 -64
- package/lib-esm/awsClients/pinpoint/updateEndpoint.js +23 -67
- 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 -97
- 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 +4 -4
- 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/index.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.js +17 -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/utils/memoization.js +3 -3
- package/lib-esm/constants.js +5 -5
- package/lib-esm/errors/AmplifyError.js +9 -29
- package/lib-esm/errors/PlatformNotSupportedError.js +5 -23
- package/lib-esm/errors/createAssertionFunction.js +11 -14
- package/lib-esm/errors/errorHelpers.js +6 -7
- package/lib-esm/index.d.ts +1 -1
- package/lib-esm/libraryUtils.d.ts +4 -0
- package/lib-esm/libraryUtils.js +4 -0
- package/lib-esm/parseAWSExports.js +108 -99
- package/lib-esm/providers/kinesis/types/kinesis.d.ts +1 -1
- package/lib-esm/providers/kinesis-firehose/types/kinesis-firehose.d.ts +1 -1
- package/lib-esm/providers/personalize/types/personalize.d.ts +1 -1
- package/lib-esm/providers/pinpoint/apis/flushEvents.js +6 -6
- package/lib-esm/providers/pinpoint/apis/record.js +54 -89
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +61 -108
- package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +3 -1
- package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +102 -194
- 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/isAppInForeground.js +1 -1
- package/lib-esm/providers/pinpoint/utils/isAppInForeground.native.js +1 -1
- package/lib-esm/providers/pinpoint/utils/resolveEndpointId.js +16 -67
- package/lib-esm/singleton/Amplify.d.ts +4 -0
- package/lib-esm/singleton/Amplify.js +18 -101
- package/lib-esm/singleton/Analytics/types.d.ts +5 -1
- package/lib-esm/singleton/Auth/index.js +48 -116
- package/lib-esm/singleton/Auth/types.d.ts +2 -2
- package/lib-esm/singleton/Auth/utils/errorHelpers.js +7 -8
- package/lib-esm/singleton/Auth/utils/index.js +16 -17
- 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 +3 -1
- package/lib-esm/storage/CookieStorage.js +28 -99
- package/lib-esm/storage/CookieStorage.native.js +4 -22
- package/lib-esm/storage/DefaultStorage.js +4 -22
- package/lib-esm/storage/DefaultStorage.native.js +17 -64
- package/lib-esm/storage/InMemoryStorage.js +17 -24
- package/lib-esm/storage/KeyValueStorage.js +23 -80
- package/lib-esm/storage/SessionStorage.js +4 -22
- package/lib-esm/storage/index.js +3 -3
- package/lib-esm/storage/utils.js +6 -10
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/utils/WordArray.d.ts +7 -0
- package/lib-esm/utils/WordArray.js +46 -0
- package/lib-esm/utils/amplifyUrl/index.js +2 -2
- package/lib-esm/utils/amplifyUuid/index.d.ts +1 -1
- package/lib-esm/utils/amplifyUuid/index.js +1 -1
- package/lib-esm/utils/convert/base64/base64Decoder.js +2 -2
- package/lib-esm/utils/convert/base64/base64Encoder.js +4 -5
- package/lib-esm/utils/convert/base64/bytesToString.js +1 -1
- package/lib-esm/utils/cryptoSecureRandomInt.d.ts +1 -0
- package/lib-esm/utils/cryptoSecureRandomInt.js +12 -0
- package/lib-esm/utils/deepFreeze.js +6 -28
- package/lib-esm/utils/generateRandomString.js +4 -4
- package/lib-esm/utils/getClientInfo/getClientInfo.android.js +5 -5
- package/lib-esm/utils/getClientInfo/getClientInfo.ios.js +10 -10
- package/lib-esm/utils/getClientInfo/getClientInfo.js +15 -15
- package/lib-esm/utils/globalHelpers/index.js +3 -3
- package/lib-esm/utils/globalHelpers/index.native.js +4 -4
- package/lib-esm/utils/isBrowser.js +1 -3
- package/lib-esm/utils/isWebWorker.js +2 -2
- package/lib-esm/utils/retry/NonRetryableError.js +5 -24
- package/lib-esm/utils/retry/constants.js +1 -1
- package/lib-esm/utils/retry/isNonRetryableError.js +2 -2
- package/lib-esm/utils/retry/jitteredBackoff.js +5 -6
- package/lib-esm/utils/retry/jitteredExponentialRetry.js +1 -4
- package/lib-esm/utils/retry/retry.js +48 -138
- package/lib-esm/utils/sessionListener/SessionListener.js +16 -19
- package/lib-esm/utils/sessionListener/SessionListener.native.js +17 -22
- 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 +1 -0
- package/lib-esm/utils/sessionListener/index.js +2 -1
- package/lib-esm/utils/urlSafeDecode.js +2 -2
- package/lib-esm/utils/urlSafeEncode.js +1 -1
- package/package.json +11 -24
- package/src/Cache/types/index.ts +4 -4
- package/src/Platform/types.ts +1 -1
- package/src/Platform/version.ts +1 -1
- package/src/Signer/DateUtils.ts +10 -2
- package/src/Signer/Signer.ts +9 -2
- package/src/clients/middleware/signing/signer/signatureV4/index.ts +0 -1
- package/src/index.ts +1 -0
- package/src/libraryUtils.ts +7 -1
- package/src/parseAWSExports.ts +45 -6
- package/src/providers/kinesis/types/kinesis.ts +1 -1
- package/src/providers/kinesis-firehose/types/kinesis-firehose.ts +1 -1
- package/src/providers/personalize/types/personalize.ts +1 -1
- package/src/providers/pinpoint/apis/record.ts +22 -5
- package/src/providers/pinpoint/types/pinpoint.ts +3 -1
- package/src/singleton/Amplify.ts +9 -52
- package/src/singleton/Analytics/types.ts +9 -4
- package/src/singleton/Auth/types.ts +2 -2
- package/src/singleton/Predictions/types.ts +61 -0
- package/src/singleton/types.ts +3 -1
- package/src/utils/WordArray.ts +57 -0
- package/src/utils/amplifyUuid/index.ts +1 -1
- package/src/utils/cryptoSecureRandomInt.ts +14 -0
- package/src/utils/sessionListener/constants.ts +6 -0
- package/src/utils/sessionListener/index.ts +1 -0
|
@@ -1,51 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.AuthClass = exports.isTokenExpired = void 0;
|
|
40
|
-
function isTokenExpired(
|
|
41
|
-
|
|
42
|
-
var currentTime = Date.now();
|
|
4
|
+
function isTokenExpired({ expiresAt, clockDrift, }) {
|
|
5
|
+
const currentTime = Date.now();
|
|
43
6
|
return currentTime + clockDrift > expiresAt;
|
|
44
7
|
}
|
|
45
8
|
exports.isTokenExpired = isTokenExpired;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
9
|
+
class AuthClass {
|
|
10
|
+
constructor() { }
|
|
49
11
|
/**
|
|
50
12
|
* Configure Auth category
|
|
51
13
|
*
|
|
@@ -56,79 +18,50 @@ var AuthClass = /** @class */ (function () {
|
|
|
56
18
|
*
|
|
57
19
|
* @returns void
|
|
58
20
|
*/
|
|
59
|
-
|
|
21
|
+
configure(authResourcesConfig, authOptions) {
|
|
60
22
|
this.authConfig = authResourcesConfig;
|
|
61
23
|
this.authOptions = authOptions;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
AuthClass.prototype.clearCredentials = function () {
|
|
108
|
-
var _a;
|
|
109
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
110
|
-
return __generator(this, function (_b) {
|
|
111
|
-
switch (_b.label) {
|
|
112
|
-
case 0:
|
|
113
|
-
if (!((_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.credentialsProvider)) return [3 /*break*/, 2];
|
|
114
|
-
return [4 /*yield*/, this.authOptions.credentialsProvider.clearCredentialsAndIdentityId()];
|
|
115
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
116
|
-
case 2: return [2 /*return*/];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
AuthClass.prototype.getTokens = function (options) {
|
|
122
|
-
var _a, _b, _c;
|
|
123
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
124
|
-
return __generator(this, function (_d) {
|
|
125
|
-
switch (_d.label) {
|
|
126
|
-
case 0: return [4 /*yield*/, ((_b = (_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.tokenProvider) === null || _b === void 0 ? void 0 : _b.getTokens(options))];
|
|
127
|
-
case 1: return [2 /*return*/, ((_c = (_d.sent())) !== null && _c !== void 0 ? _c : undefined)];
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
return AuthClass;
|
|
133
|
-
}());
|
|
24
|
+
}
|
|
25
|
+
async fetchAuthSession(options = {}) {
|
|
26
|
+
let tokens;
|
|
27
|
+
let credentialsAndIdentityId;
|
|
28
|
+
let userSub;
|
|
29
|
+
// Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available
|
|
30
|
+
tokens = await this.getTokens(options);
|
|
31
|
+
if (tokens) {
|
|
32
|
+
userSub = tokens.accessToken?.payload?.sub;
|
|
33
|
+
// getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)
|
|
34
|
+
credentialsAndIdentityId =
|
|
35
|
+
await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({
|
|
36
|
+
authConfig: this.authConfig,
|
|
37
|
+
tokens,
|
|
38
|
+
authenticated: true,
|
|
39
|
+
forceRefresh: options.forceRefresh,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)
|
|
44
|
+
credentialsAndIdentityId =
|
|
45
|
+
await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({
|
|
46
|
+
authConfig: this.authConfig,
|
|
47
|
+
authenticated: false,
|
|
48
|
+
forceRefresh: options.forceRefresh,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
tokens,
|
|
53
|
+
credentials: credentialsAndIdentityId?.credentials,
|
|
54
|
+
identityId: credentialsAndIdentityId?.identityId,
|
|
55
|
+
userSub,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async clearCredentials() {
|
|
59
|
+
if (this.authOptions?.credentialsProvider) {
|
|
60
|
+
return await this.authOptions.credentialsProvider.clearCredentialsAndIdentityId();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async getTokens(options) {
|
|
64
|
+
return ((await this.authOptions?.tokenProvider?.getTokens(options)) ?? undefined);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
134
67
|
exports.AuthClass = AuthClass;
|
|
@@ -112,9 +112,9 @@ export type OAuthConfig = {
|
|
|
112
112
|
redirectSignIn: Array<string>;
|
|
113
113
|
redirectSignOut: Array<string>;
|
|
114
114
|
responseType: 'code' | 'token';
|
|
115
|
-
providers?: Array<
|
|
115
|
+
providers?: Array<OAuthProvider | CustomProvider>;
|
|
116
116
|
};
|
|
117
|
-
type
|
|
117
|
+
export type OAuthProvider = 'Google' | 'Facebook' | 'Amazon' | 'Apple';
|
|
118
118
|
type CustomProvider = {
|
|
119
119
|
custom: string;
|
|
120
120
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
var _a;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
5
|
exports.assert = exports.AuthConfigurationErrorCode = void 0;
|
|
7
|
-
|
|
6
|
+
const errors_1 = require("../../../errors");
|
|
8
7
|
var AuthConfigurationErrorCode;
|
|
9
8
|
(function (AuthConfigurationErrorCode) {
|
|
10
9
|
AuthConfigurationErrorCode["AuthTokenConfigException"] = "AuthTokenConfigException";
|
|
@@ -12,22 +11,22 @@ var AuthConfigurationErrorCode;
|
|
|
12
11
|
AuthConfigurationErrorCode["InvalidIdentityPoolIdException"] = "InvalidIdentityPoolIdException";
|
|
13
12
|
AuthConfigurationErrorCode["OAuthNotConfigureException"] = "OAuthNotConfigureException";
|
|
14
13
|
})(AuthConfigurationErrorCode = exports.AuthConfigurationErrorCode || (exports.AuthConfigurationErrorCode = {}));
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const authConfigurationErrorMap = {
|
|
15
|
+
[AuthConfigurationErrorCode.AuthTokenConfigException]: {
|
|
17
16
|
message: 'Auth Token Provider not configured.',
|
|
18
17
|
recoverySuggestion: 'Make sure to call Amplify.configure in your app.',
|
|
19
18
|
},
|
|
20
|
-
|
|
19
|
+
[AuthConfigurationErrorCode.AuthUserPoolAndIdentityPoolException]: {
|
|
21
20
|
message: 'Auth UserPool or IdentityPool not configured.',
|
|
22
21
|
recoverySuggestion: 'Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId.',
|
|
23
22
|
},
|
|
24
|
-
|
|
23
|
+
[AuthConfigurationErrorCode.InvalidIdentityPoolIdException]: {
|
|
25
24
|
message: 'Invalid identity pool id provided.',
|
|
26
25
|
recoverySuggestion: 'Make sure a valid identityPoolId is given in the config.',
|
|
27
26
|
},
|
|
28
|
-
|
|
27
|
+
[AuthConfigurationErrorCode.OAuthNotConfigureException]: {
|
|
29
28
|
message: 'oauth param not configured.',
|
|
30
29
|
recoverySuggestion: 'Make sure to call Amplify.configure with oauth parameter in your app.',
|
|
31
30
|
},
|
|
32
|
-
|
|
31
|
+
};
|
|
33
32
|
exports.assert = (0, errors_1.createAssertionFunction)(authConfigurationErrorMap);
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.decodeJWT = exports.assertIdentityPoolIdConfig = exports.assertOAuthConfig = exports.assertTokenProviderConfig = void 0;
|
|
4
4
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
5
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const errorHelpers_1 = require("./errorHelpers");
|
|
7
|
+
const convert_1 = require("../../../utils/convert");
|
|
8
8
|
function assertTokenProviderConfig(cognitoConfig) {
|
|
9
|
-
|
|
9
|
+
let assertionValid = true; // assume valid until otherwise proveed
|
|
10
10
|
if (!cognitoConfig) {
|
|
11
11
|
assertionValid = false;
|
|
12
12
|
}
|
|
@@ -18,40 +18,39 @@ function assertTokenProviderConfig(cognitoConfig) {
|
|
|
18
18
|
}
|
|
19
19
|
exports.assertTokenProviderConfig = assertTokenProviderConfig;
|
|
20
20
|
function assertOAuthConfig(cognitoConfig) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
!!
|
|
24
|
-
!!
|
|
25
|
-
!!((_h = (_g = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _g === void 0 ? void 0 : _g.oauth) === null || _h === void 0 ? void 0 : _h.responseType);
|
|
21
|
+
const validOAuthConfig = !!cognitoConfig?.loginWith?.oauth?.domain &&
|
|
22
|
+
!!cognitoConfig?.loginWith?.oauth?.redirectSignOut &&
|
|
23
|
+
!!cognitoConfig?.loginWith?.oauth?.redirectSignIn &&
|
|
24
|
+
!!cognitoConfig?.loginWith?.oauth?.responseType;
|
|
26
25
|
return (0, errorHelpers_1.assert)(validOAuthConfig, errorHelpers_1.AuthConfigurationErrorCode.OAuthNotConfigureException);
|
|
27
26
|
}
|
|
28
27
|
exports.assertOAuthConfig = assertOAuthConfig;
|
|
29
28
|
function assertIdentityPoolIdConfig(cognitoConfig) {
|
|
30
|
-
|
|
29
|
+
const validConfig = !!cognitoConfig?.identityPoolId;
|
|
31
30
|
return (0, errorHelpers_1.assert)(validConfig, errorHelpers_1.AuthConfigurationErrorCode.InvalidIdentityPoolIdException);
|
|
32
31
|
}
|
|
33
32
|
exports.assertIdentityPoolIdConfig = assertIdentityPoolIdConfig;
|
|
34
33
|
function assertUserPoolAndIdentityPoolConfig(authConfig) {
|
|
35
|
-
|
|
34
|
+
const validConfig = !!authConfig?.Cognito.identityPoolId && !!authConfig?.Cognito.userPoolId;
|
|
36
35
|
return (0, errorHelpers_1.assert)(validConfig, errorHelpers_1.AuthConfigurationErrorCode.AuthUserPoolAndIdentityPoolException);
|
|
37
36
|
}
|
|
38
37
|
function decodeJWT(token) {
|
|
39
|
-
|
|
38
|
+
const tokenParts = token.split('.');
|
|
40
39
|
if (tokenParts.length !== 3) {
|
|
41
40
|
throw new Error('Invalid token');
|
|
42
41
|
}
|
|
43
42
|
try {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.convert(
|
|
43
|
+
const base64WithUrlSafe = tokenParts[1];
|
|
44
|
+
const base64 = base64WithUrlSafe.replace(/-/g, '+').replace(/_/g, '/');
|
|
45
|
+
const jsonStr = decodeURIComponent(convert_1.base64Decoder
|
|
46
|
+
.convert(base64)
|
|
48
47
|
.split('')
|
|
49
|
-
.map(
|
|
48
|
+
.map(char => `%${`00${char.charCodeAt(0).toString(16)}`.slice(-2)}`)
|
|
50
49
|
.join(''));
|
|
51
|
-
|
|
50
|
+
const payload = JSON.parse(jsonStr);
|
|
52
51
|
return {
|
|
53
|
-
toString:
|
|
54
|
-
payload
|
|
52
|
+
toString: () => token,
|
|
53
|
+
payload,
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
56
|
catch (err) {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
type SpeechGeneratorDefaults = {
|
|
2
|
+
voiceId?: string;
|
|
3
|
+
};
|
|
4
|
+
type TranscriptionDefaults = {
|
|
5
|
+
language?: string;
|
|
6
|
+
};
|
|
7
|
+
type TranslateTextDefaults = {
|
|
8
|
+
sourceLanguage?: string;
|
|
9
|
+
targetLanguage?: string;
|
|
10
|
+
};
|
|
11
|
+
type IdentifyEntitiesDefaults = {
|
|
12
|
+
collectionId?: string;
|
|
13
|
+
maxEntities?: number;
|
|
14
|
+
};
|
|
15
|
+
type IdentityLabelsDefaults = {
|
|
16
|
+
type?: string;
|
|
17
|
+
};
|
|
18
|
+
type IdentifyTextDefaults = {
|
|
19
|
+
format?: string;
|
|
20
|
+
};
|
|
21
|
+
type InterpretTextDefaults = {
|
|
22
|
+
type?: string;
|
|
23
|
+
};
|
|
24
|
+
type ConvertConfig = {
|
|
25
|
+
speechGenerator?: PredictionsProviderConfig<SpeechGeneratorDefaults>;
|
|
26
|
+
transcription?: PredictionsProviderConfig<TranscriptionDefaults>;
|
|
27
|
+
translateText?: PredictionsProviderConfig<TranslateTextDefaults>;
|
|
28
|
+
};
|
|
29
|
+
type IdentifyConfig = {
|
|
30
|
+
identifyEntities?: PredictionsProviderConfig<IdentifyEntitiesDefaults> & {
|
|
31
|
+
celebrityDetectionEnabled?: boolean;
|
|
32
|
+
};
|
|
33
|
+
identifyLabels?: PredictionsProviderConfig<IdentityLabelsDefaults>;
|
|
34
|
+
identifyText?: PredictionsProviderConfig<IdentifyTextDefaults>;
|
|
35
|
+
};
|
|
36
|
+
type InterpretConfig = {
|
|
37
|
+
interpretText?: PredictionsProviderConfig<InterpretTextDefaults>;
|
|
38
|
+
};
|
|
39
|
+
export type PredictionsProviderConfig<T> = {
|
|
40
|
+
region?: string;
|
|
41
|
+
proxy?: boolean;
|
|
42
|
+
defaults?: T;
|
|
43
|
+
};
|
|
44
|
+
export type PredictionsConfig = {
|
|
45
|
+
convert?: ConvertConfig;
|
|
46
|
+
identify?: IdentifyConfig;
|
|
47
|
+
interpret?: InterpretConfig;
|
|
48
|
+
};
|
|
49
|
+
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.clearCredentials = void 0;
|
|
6
|
-
|
|
6
|
+
const Amplify_1 = require("../Amplify");
|
|
7
7
|
function clearCredentials() {
|
|
8
8
|
return Amplify_1.Amplify.Auth.clearCredentials();
|
|
9
9
|
}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.fetchAuthSession = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const fetchAuthSession_1 = require("./internal/fetchAuthSession");
|
|
7
|
+
const Amplify_1 = require("../Amplify");
|
|
8
|
+
const fetchAuthSession = (options) => {
|
|
9
9
|
return (0, fetchAuthSession_1.fetchAuthSession)(Amplify_1.Amplify, options);
|
|
10
10
|
};
|
|
11
11
|
exports.fetchAuthSession = fetchAuthSession;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.fetchAuthSession = void 0;
|
|
6
|
-
|
|
6
|
+
const fetchAuthSession = (amplify, options) => {
|
|
7
7
|
return amplify.Auth.fetchAuthSession(options);
|
|
8
8
|
};
|
|
9
9
|
exports.fetchAuthSession = fetchAuthSession;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.fetchAuthSession = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const adapterCore_1 = require("../../../adapterCore");
|
|
7
|
+
const fetchAuthSession_1 = require("../internal/fetchAuthSession");
|
|
8
|
+
const fetchAuthSession = (contextSpec, options) => {
|
|
9
9
|
return (0, fetchAuthSession_1.fetchAuthSession)((0, adapterCore_1.getAmplifyServerContext)(contextSpec).amplify, options);
|
|
10
10
|
};
|
|
11
11
|
exports.fetchAuthSession = fetchAuthSession;
|
package/lib/singleton/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { APIConfig, LibraryAPIOptions } from './API/types';
|
|
|
2
2
|
import { AnalyticsConfig } from './Analytics/types';
|
|
3
3
|
import { AuthConfig, LibraryAuthOptions, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, CognitoIdentityPoolConfig } from './Auth/types';
|
|
4
4
|
import { GeoConfig } from './Geo/types';
|
|
5
|
+
import { PredictionsConfig } from './Predictions/types';
|
|
5
6
|
import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
|
|
6
7
|
import { NotificationsConfig } from './Notifications/types';
|
|
7
8
|
import { InteractionsConfig } from './Interactions/types';
|
|
@@ -17,6 +18,7 @@ export type ResourcesConfig = {
|
|
|
17
18
|
Auth?: AuthConfig;
|
|
18
19
|
Interactions?: InteractionsConfig;
|
|
19
20
|
Notifications?: NotificationsConfig;
|
|
21
|
+
Predictions?: PredictionsConfig;
|
|
20
22
|
Storage?: StorageConfig;
|
|
21
23
|
Geo?: GeoConfig;
|
|
22
24
|
};
|
|
@@ -26,4 +28,4 @@ export type LibraryOptions = {
|
|
|
26
28
|
Storage?: LibraryStorageOptions;
|
|
27
29
|
ssr?: boolean;
|
|
28
30
|
};
|
|
29
|
-
export { APIConfig, AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, InteractionsConfig, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, GeoConfig, };
|
|
31
|
+
export { APIConfig, AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, InteractionsConfig, PredictionsConfig, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, GeoConfig, };
|
|
@@ -1,63 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
var __assign = (this && this.__assign) || function () {
|
|
5
|
-
__assign = Object.assign || function(t) {
|
|
6
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
7
|
-
s = arguments[i];
|
|
8
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
9
|
-
t[p] = s[p];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
return __assign.apply(this, arguments);
|
|
14
|
-
};
|
|
15
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
25
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
26
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
27
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
|
-
function step(op) {
|
|
29
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
31
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
32
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
|
-
switch (op[0]) {
|
|
34
|
-
case 0: case 1: t = op; break;
|
|
35
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
36
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
37
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
38
|
-
default:
|
|
39
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
40
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
41
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
42
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
43
|
-
if (t[2]) _.ops.pop();
|
|
44
|
-
_.trys.pop(); continue;
|
|
45
|
-
}
|
|
46
|
-
op = body.call(thisArg, _);
|
|
47
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
48
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
4
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
52
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
53
6
|
};
|
|
54
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
8
|
exports.CookieStorage = void 0;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var path = data.path, domain = data.domain, expires = data.expires, sameSite = data.sameSite, secure = data.secure;
|
|
9
|
+
const js_cookie_1 = __importDefault(require("js-cookie"));
|
|
10
|
+
class CookieStorage {
|
|
11
|
+
constructor(data = {}) {
|
|
12
|
+
const { path, domain, expires, sameSite, secure } = data;
|
|
61
13
|
this.domain = domain;
|
|
62
14
|
this.path = path ? path : '/';
|
|
63
15
|
this.expires = data.hasOwnProperty('expires') ? expires : 365;
|
|
@@ -72,51 +24,29 @@ var CookieStorage = /** @class */ (function () {
|
|
|
72
24
|
this.sameSite = sameSite;
|
|
73
25
|
}
|
|
74
26
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
CookieStorage.prototype.clear = function () {
|
|
101
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
var cookie, promises;
|
|
103
|
-
var _this = this;
|
|
104
|
-
return __generator(this, function (_a) {
|
|
105
|
-
switch (_a.label) {
|
|
106
|
-
case 0:
|
|
107
|
-
cookie = js_cookie_1.default.get();
|
|
108
|
-
promises = Object.keys(cookie).map(function (key) { return _this.removeItem(key); });
|
|
109
|
-
return [4 /*yield*/, Promise.all(promises)];
|
|
110
|
-
case 1:
|
|
111
|
-
_a.sent();
|
|
112
|
-
return [2 /*return*/];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
CookieStorage.prototype.getData = function () {
|
|
118
|
-
return __assign({ path: this.path, expires: this.expires, domain: this.domain, secure: this.secure }, (this.sameSite && { sameSite: this.sameSite }));
|
|
119
|
-
};
|
|
120
|
-
return CookieStorage;
|
|
121
|
-
}());
|
|
27
|
+
async setItem(key, value) {
|
|
28
|
+
js_cookie_1.default.set(key, value, this.getData());
|
|
29
|
+
}
|
|
30
|
+
async getItem(key) {
|
|
31
|
+
const item = js_cookie_1.default.get(key);
|
|
32
|
+
return item ?? null;
|
|
33
|
+
}
|
|
34
|
+
async removeItem(key) {
|
|
35
|
+
js_cookie_1.default.remove(key, this.getData());
|
|
36
|
+
}
|
|
37
|
+
async clear() {
|
|
38
|
+
const cookie = js_cookie_1.default.get();
|
|
39
|
+
const promises = Object.keys(cookie).map(key => this.removeItem(key));
|
|
40
|
+
await Promise.all(promises);
|
|
41
|
+
}
|
|
42
|
+
getData() {
|
|
43
|
+
return {
|
|
44
|
+
path: this.path,
|
|
45
|
+
expires: this.expires,
|
|
46
|
+
domain: this.domain,
|
|
47
|
+
secure: this.secure,
|
|
48
|
+
...(this.sameSite && { sameSite: this.sameSite }),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
122
52
|
exports.CookieStorage = CookieStorage;
|
|
@@ -1,32 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
var __extends = (this && this.__extends) || (function () {
|
|
5
|
-
var extendStatics = function (d, b) {
|
|
6
|
-
extendStatics = Object.setPrototypeOf ||
|
|
7
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
9
|
-
return extendStatics(d, b);
|
|
10
|
-
};
|
|
11
|
-
return function (d, b) {
|
|
12
|
-
if (typeof b !== "function" && b !== null)
|
|
13
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
14
|
-
extendStatics(d, b);
|
|
15
|
-
function __() { this.constructor = d; }
|
|
16
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
17
|
-
};
|
|
18
|
-
})();
|
|
19
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
5
|
exports.CookieStorage = void 0;
|
|
21
|
-
|
|
6
|
+
const KeyValueStorage_1 = require("./KeyValueStorage");
|
|
22
7
|
/**
|
|
23
8
|
* @internal
|
|
24
9
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return _super.call(this) || this;
|
|
10
|
+
class CookieStorage extends KeyValueStorage_1.KeyValueStorage {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
29
13
|
}
|
|
30
|
-
|
|
31
|
-
}(KeyValueStorage_1.KeyValueStorage));
|
|
14
|
+
}
|
|
32
15
|
exports.CookieStorage = CookieStorage;
|