@aws-amplify/core 6.0.1-api-v6-models.9351bcf.0 → 6.0.1-api-v6-models.58f2536.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,7 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
// Default buffer constants
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
4
|
+
export const BUFFER_SIZE = 1000;
|
|
5
|
+
export const FLUSH_SIZE = 100;
|
|
6
|
+
export const FLUSH_INTERVAL = 5 * 1000; // 5s
|
|
7
|
+
export const RESEND_LIMIT = 5;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
3
|
+
const PROVIDER_NAME = 'pinpoint';
|
|
4
4
|
/**
|
|
5
5
|
* Returns a unique cache key for a particular category/appId combination.
|
|
6
6
|
*
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export const getCacheKey = (appId, category) => `${category}:${PROVIDER_NAME}:${appId}`;
|
|
@@ -1,41 +1,5 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
-
function step(op) {
|
|
17
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
-
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;
|
|
20
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
-
switch (op[0]) {
|
|
22
|
-
case 0: case 1: t = op; break;
|
|
23
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
-
default:
|
|
27
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
-
if (t[2]) _.ops.pop();
|
|
32
|
-
_.trys.pop(); continue;
|
|
33
|
-
}
|
|
34
|
-
op = body.call(thisArg, _);
|
|
35
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
3
|
import { Cache } from '../../..';
|
|
40
4
|
import { getCacheKey } from './getCacheKey';
|
|
41
5
|
/**
|
|
@@ -43,16 +7,8 @@ import { getCacheKey } from './getCacheKey';
|
|
|
43
7
|
*
|
|
44
8
|
* @internal
|
|
45
9
|
*/
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
cacheKey = getCacheKey(appId, category);
|
|
52
|
-
return [4 /*yield*/, Cache.getItem(cacheKey)];
|
|
53
|
-
case 1:
|
|
54
|
-
cachedEndpointId = _a.sent();
|
|
55
|
-
return [2 /*return*/, cachedEndpointId !== null && cachedEndpointId !== void 0 ? cachedEndpointId : undefined];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}); };
|
|
10
|
+
export const getEndpointId = async (appId, category) => {
|
|
11
|
+
const cacheKey = getCacheKey(appId, category);
|
|
12
|
+
const cachedEndpointId = await Cache.getItem(cacheKey);
|
|
13
|
+
return cachedEndpointId ?? undefined;
|
|
14
|
+
};
|
|
@@ -3,38 +3,36 @@
|
|
|
3
3
|
import { PinpointEventBuffer } from './PinpointEventBuffer';
|
|
4
4
|
import { BUFFER_SIZE, FLUSH_INTERVAL, FLUSH_SIZE, RESEND_LIMIT } from './constants';
|
|
5
5
|
// Map of buffers by region -> appId
|
|
6
|
-
|
|
6
|
+
const eventBufferMap = {};
|
|
7
7
|
/**
|
|
8
8
|
* Returns a PinpointEventBuffer instance for the specified region & app ID, creating one if it does not yet exist.
|
|
9
9
|
*
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if ((_b = eventBufferMap[region]) === null || _b === void 0 ? void 0 : _b[appId]) {
|
|
16
|
-
var buffer_1 = eventBufferMap[region][appId];
|
|
12
|
+
export const getEventBuffer = ({ appId, bufferSize = BUFFER_SIZE, credentials, flushInterval = FLUSH_INTERVAL, flushSize = FLUSH_SIZE, identityId, region, resendLimit = RESEND_LIMIT, userAgentValue }) => {
|
|
13
|
+
if (eventBufferMap[region]?.[appId]) {
|
|
14
|
+
const buffer = eventBufferMap[region][appId];
|
|
17
15
|
/*
|
|
18
16
|
If the identity has changed flush out the buffer and create a new instance. The old instance will be garbage
|
|
19
17
|
collected.
|
|
20
18
|
*/
|
|
21
|
-
if (
|
|
22
|
-
|
|
19
|
+
if (buffer.identityHasChanged(identityId)) {
|
|
20
|
+
buffer.flush();
|
|
23
21
|
}
|
|
24
22
|
else {
|
|
25
|
-
return
|
|
23
|
+
return buffer;
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
appId
|
|
30
|
-
bufferSize
|
|
31
|
-
credentials
|
|
32
|
-
flushInterval
|
|
33
|
-
flushSize
|
|
34
|
-
identityId
|
|
35
|
-
region
|
|
36
|
-
resendLimit
|
|
37
|
-
userAgentValue
|
|
26
|
+
const buffer = new PinpointEventBuffer({
|
|
27
|
+
appId,
|
|
28
|
+
bufferSize,
|
|
29
|
+
credentials,
|
|
30
|
+
flushInterval,
|
|
31
|
+
flushSize,
|
|
32
|
+
identityId,
|
|
33
|
+
region,
|
|
34
|
+
resendLimit,
|
|
35
|
+
userAgentValue
|
|
38
36
|
});
|
|
39
37
|
if (!eventBufferMap[region]) {
|
|
40
38
|
eventBufferMap[region] = {};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
// @ts-ignore: missing type definition
|
|
4
4
|
import { AppState } from 'react-native';
|
|
5
|
-
export
|
|
5
|
+
export const isAppInForeground = () => AppState.currentState === 'active';
|
|
@@ -1,41 +1,5 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
-
function step(op) {
|
|
17
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
-
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;
|
|
20
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
-
switch (op[0]) {
|
|
22
|
-
case 0: case 1: t = op; break;
|
|
23
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
-
default:
|
|
27
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
-
if (t[2]) _.ops.pop();
|
|
32
|
-
_.trys.pop(); continue;
|
|
33
|
-
}
|
|
34
|
-
op = body.call(thisArg, _);
|
|
35
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
3
|
import { assert } from '../../../errors';
|
|
40
4
|
import { AmplifyErrorCode } from '../../../types';
|
|
41
5
|
import { updateEndpoint } from '../apis';
|
|
@@ -46,36 +10,21 @@ import { getEndpointId } from './getEndpointId';
|
|
|
46
10
|
*
|
|
47
11
|
* @internal
|
|
48
12
|
*/
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
appId: appId,
|
|
62
|
-
category: category,
|
|
63
|
-
channelType: channelType,
|
|
64
|
-
credentials: credentials,
|
|
65
|
-
identityId: identityId,
|
|
66
|
-
region: region,
|
|
67
|
-
userAgentValue: userAgentValue,
|
|
68
|
-
})];
|
|
69
|
-
case 2:
|
|
70
|
-
_b.sent();
|
|
71
|
-
return [4 /*yield*/, getEndpointId(appId, category)];
|
|
72
|
-
case 3:
|
|
73
|
-
endpointId = _b.sent();
|
|
74
|
-
_b.label = 4;
|
|
75
|
-
case 4:
|
|
76
|
-
assert(!!endpointId, AmplifyErrorCode.NoEndpointId);
|
|
77
|
-
return [2 /*return*/, endpointId];
|
|
78
|
-
}
|
|
13
|
+
export const resolveEndpointId = async ({ address, appId, category, channelType, credentials, identityId, region, userAgentValue, }) => {
|
|
14
|
+
let endpointId = await getEndpointId(appId, category);
|
|
15
|
+
if (!endpointId) {
|
|
16
|
+
await updateEndpoint({
|
|
17
|
+
address,
|
|
18
|
+
appId,
|
|
19
|
+
category,
|
|
20
|
+
channelType,
|
|
21
|
+
credentials,
|
|
22
|
+
identityId,
|
|
23
|
+
region,
|
|
24
|
+
userAgentValue,
|
|
79
25
|
});
|
|
80
|
-
|
|
26
|
+
endpointId = await getEndpointId(appId, category);
|
|
27
|
+
}
|
|
28
|
+
assert(!!endpointId, AmplifyErrorCode.NoEndpointId);
|
|
29
|
+
return endpointId;
|
|
81
30
|
};
|
|
@@ -14,6 +14,10 @@ export declare class AmplifyClass {
|
|
|
14
14
|
* Configures Amplify for use with your back-end resources.
|
|
15
15
|
*
|
|
16
16
|
* @remarks
|
|
17
|
+
* This API does not perform any merging of either `resourcesConfig` or `libraryOptions`. The most recently
|
|
18
|
+
* provided values will be used after configuration.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
17
21
|
* `configure` can be used to specify additional library options where available for supported categories.
|
|
18
22
|
*
|
|
19
23
|
* @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
|
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __values = (this && this.__values) || function(o) {
|
|
13
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
14
|
-
if (m) return m.call(o);
|
|
15
|
-
if (o && typeof o.length === "number") return {
|
|
16
|
-
next: function () {
|
|
17
|
-
if (o && i >= o.length) o = void 0;
|
|
18
|
-
return { value: o && o[i++], done: !o };
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
22
|
-
};
|
|
23
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
24
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
25
3
|
import { AuthClass } from './Auth';
|
|
26
4
|
import { Hub, AMPLIFY_SYMBOL } from '../Hub';
|
|
27
5
|
import { parseAWSExports } from '../parseAWSExports';
|
|
28
6
|
import { deepFreeze } from '../utils';
|
|
29
|
-
|
|
30
|
-
|
|
7
|
+
export class AmplifyClass {
|
|
8
|
+
constructor() {
|
|
31
9
|
this.resourcesConfig = {};
|
|
32
10
|
this.libraryOptions = {};
|
|
33
11
|
this.Auth = new AuthClass();
|
|
@@ -36,22 +14,27 @@ var AmplifyClass = /** @class */ (function () {
|
|
|
36
14
|
* Configures Amplify for use with your back-end resources.
|
|
37
15
|
*
|
|
38
16
|
* @remarks
|
|
17
|
+
* This API does not perform any merging of either `resourcesConfig` or `libraryOptions`. The most recently
|
|
18
|
+
* provided values will be used after configuration.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
39
21
|
* `configure` can be used to specify additional library options where available for supported categories.
|
|
40
22
|
*
|
|
41
23
|
* @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
|
|
42
24
|
* @param libraryOptions - Additional options for customizing the behavior of the library.
|
|
43
25
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (Object.keys(resourcesConfig).some(function (key) { return key.startsWith('aws_'); })) {
|
|
26
|
+
configure(resourcesConfig, libraryOptions) {
|
|
27
|
+
let resolvedResourceConfig;
|
|
28
|
+
if (Object.keys(resourcesConfig).some(key => key.startsWith('aws_'))) {
|
|
48
29
|
resolvedResourceConfig = parseAWSExports(resourcesConfig);
|
|
49
30
|
}
|
|
50
31
|
else {
|
|
51
32
|
resolvedResourceConfig = resourcesConfig;
|
|
52
33
|
}
|
|
53
|
-
this.resourcesConfig =
|
|
54
|
-
|
|
34
|
+
this.resourcesConfig = resolvedResourceConfig;
|
|
35
|
+
if (libraryOptions) {
|
|
36
|
+
this.libraryOptions = libraryOptions;
|
|
37
|
+
}
|
|
55
38
|
// Make resource config immutable
|
|
56
39
|
this.resourcesConfig = deepFreeze(this.resourcesConfig);
|
|
57
40
|
this.Auth.configure(this.resourcesConfig.Auth, this.libraryOptions.Auth);
|
|
@@ -59,86 +42,20 @@ var AmplifyClass = /** @class */ (function () {
|
|
|
59
42
|
event: 'configure',
|
|
60
43
|
data: resourcesConfig,
|
|
61
44
|
}, 'Configure', AMPLIFY_SYMBOL);
|
|
62
|
-
}
|
|
45
|
+
}
|
|
63
46
|
/**
|
|
64
47
|
* Provides access to the current back-end resource configuration for the Library.
|
|
65
48
|
*
|
|
66
49
|
* @returns Returns the immutable back-end resource configuration.
|
|
67
50
|
*/
|
|
68
|
-
|
|
51
|
+
getConfig() {
|
|
69
52
|
return this.resourcesConfig;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}());
|
|
73
|
-
export { AmplifyClass };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
74
55
|
/**
|
|
75
56
|
* The `Amplify` utility is used to configure the library.
|
|
76
57
|
*
|
|
77
58
|
* @remarks
|
|
78
59
|
* `Amplify` is responsible for orchestrating cross-category communication within the library.
|
|
79
60
|
*/
|
|
80
|
-
export
|
|
81
|
-
// TODO(v6): validate until which level this will nested, during Amplify.configure API review.
|
|
82
|
-
function mergeResourceConfig(existingConfig, newConfig) {
|
|
83
|
-
var e_1, _a, e_2, _b;
|
|
84
|
-
var resultConfig = {};
|
|
85
|
-
try {
|
|
86
|
-
for (var _c = __values(Object.keys(existingConfig)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
87
|
-
var category = _d.value;
|
|
88
|
-
resultConfig[category] = existingConfig[category];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
92
|
-
finally {
|
|
93
|
-
try {
|
|
94
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
95
|
-
}
|
|
96
|
-
finally { if (e_1) throw e_1.error; }
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
for (var _e = __values(Object.keys(newConfig)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
100
|
-
var key = _f.value;
|
|
101
|
-
resultConfig[key] = __assign(__assign({}, resultConfig[key]), newConfig[key]);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
105
|
-
finally {
|
|
106
|
-
try {
|
|
107
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
108
|
-
}
|
|
109
|
-
finally { if (e_2) throw e_2.error; }
|
|
110
|
-
}
|
|
111
|
-
return resultConfig;
|
|
112
|
-
}
|
|
113
|
-
function mergeLibraryOptions(existingConfig, newConfig) {
|
|
114
|
-
var e_3, _a, e_4, _b;
|
|
115
|
-
var resultConfig = {};
|
|
116
|
-
try {
|
|
117
|
-
for (var _c = __values(Object.keys(existingConfig)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
118
|
-
var category = _d.value;
|
|
119
|
-
resultConfig[category] = existingConfig[category];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
123
|
-
finally {
|
|
124
|
-
try {
|
|
125
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
126
|
-
}
|
|
127
|
-
finally { if (e_3) throw e_3.error; }
|
|
128
|
-
}
|
|
129
|
-
try {
|
|
130
|
-
for (var _e = __values(Object.keys(newConfig).filter(function (key) { return key !== 'ssr'; })), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
131
|
-
var key = _f.value;
|
|
132
|
-
resultConfig[key] = __assign(__assign({}, resultConfig[key]), newConfig[key]);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
136
|
-
finally {
|
|
137
|
-
try {
|
|
138
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
139
|
-
}
|
|
140
|
-
finally { if (e_4) throw e_4.error; }
|
|
141
|
-
}
|
|
142
|
-
resultConfig.ssr = newConfig.ssr;
|
|
143
|
-
return resultConfig;
|
|
144
|
-
}
|
|
61
|
+
export const Amplify = new AmplifyClass();
|
|
@@ -2,4 +2,8 @@ import { PinpointProviderConfig } from '../../providers/pinpoint/types';
|
|
|
2
2
|
import { KinesisProviderConfig } from '../../providers/kinesis/types';
|
|
3
3
|
import { KinesisFirehoseProviderConfig } from '../../providers/kinesis-firehose/types';
|
|
4
4
|
import { PersonalizeProviderConfig } from '../../providers/personalize/types';
|
|
5
|
-
|
|
5
|
+
type AtLeastOne<T, U = {
|
|
6
|
+
[K in keyof T]: Pick<T, K>;
|
|
7
|
+
}> = Partial<T> & U[keyof U];
|
|
8
|
+
export type AnalyticsConfig = AtLeastOne<PinpointProviderConfig & KinesisProviderConfig & KinesisFirehoseProviderConfig & PersonalizeProviderConfig>;
|
|
9
|
+
export {};
|
|
@@ -1,47 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
export function isTokenExpired(_a) {
|
|
38
|
-
var expiresAt = _a.expiresAt, clockDrift = _a.clockDrift;
|
|
39
|
-
var currentTime = Date.now();
|
|
1
|
+
export function isTokenExpired({ expiresAt, clockDrift, }) {
|
|
2
|
+
const currentTime = Date.now();
|
|
40
3
|
return currentTime + clockDrift > expiresAt;
|
|
41
4
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
5
|
+
export class AuthClass {
|
|
6
|
+
constructor() { }
|
|
45
7
|
/**
|
|
46
8
|
* Configure Auth category
|
|
47
9
|
*
|
|
@@ -52,79 +14,49 @@ var AuthClass = /** @class */ (function () {
|
|
|
52
14
|
*
|
|
53
15
|
* @returns void
|
|
54
16
|
*/
|
|
55
|
-
|
|
17
|
+
configure(authResourcesConfig, authOptions) {
|
|
56
18
|
this.authConfig = authResourcesConfig;
|
|
57
19
|
this.authOptions = authOptions;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
AuthClass.prototype.clearCredentials = function () {
|
|
104
|
-
var _a;
|
|
105
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
-
return __generator(this, function (_b) {
|
|
107
|
-
switch (_b.label) {
|
|
108
|
-
case 0:
|
|
109
|
-
if (!((_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.credentialsProvider)) return [3 /*break*/, 2];
|
|
110
|
-
return [4 /*yield*/, this.authOptions.credentialsProvider.clearCredentialsAndIdentityId()];
|
|
111
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
112
|
-
case 2: return [2 /*return*/];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
AuthClass.prototype.getTokens = function (options) {
|
|
118
|
-
var _a, _b, _c;
|
|
119
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
-
return __generator(this, function (_d) {
|
|
121
|
-
switch (_d.label) {
|
|
122
|
-
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))];
|
|
123
|
-
case 1: return [2 /*return*/, ((_c = (_d.sent())) !== null && _c !== void 0 ? _c : undefined)];
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
return AuthClass;
|
|
129
|
-
}());
|
|
130
|
-
export { AuthClass };
|
|
20
|
+
}
|
|
21
|
+
async fetchAuthSession(options = {}) {
|
|
22
|
+
let tokens;
|
|
23
|
+
let credentialsAndIdentityId;
|
|
24
|
+
let userSub;
|
|
25
|
+
// Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available
|
|
26
|
+
tokens = await this.getTokens(options);
|
|
27
|
+
if (tokens) {
|
|
28
|
+
userSub = tokens.accessToken?.payload?.sub;
|
|
29
|
+
// getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)
|
|
30
|
+
credentialsAndIdentityId =
|
|
31
|
+
await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({
|
|
32
|
+
authConfig: this.authConfig,
|
|
33
|
+
tokens,
|
|
34
|
+
authenticated: true,
|
|
35
|
+
forceRefresh: options.forceRefresh,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)
|
|
40
|
+
credentialsAndIdentityId =
|
|
41
|
+
await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({
|
|
42
|
+
authConfig: this.authConfig,
|
|
43
|
+
authenticated: false,
|
|
44
|
+
forceRefresh: options.forceRefresh,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
tokens,
|
|
49
|
+
credentials: credentialsAndIdentityId?.credentials,
|
|
50
|
+
identityId: credentialsAndIdentityId?.identityId,
|
|
51
|
+
userSub,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async clearCredentials() {
|
|
55
|
+
if (this.authOptions?.credentialsProvider) {
|
|
56
|
+
return await this.authOptions.credentialsProvider.clearCredentialsAndIdentityId();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async getTokens(options) {
|
|
60
|
+
return ((await this.authOptions?.tokenProvider?.getTokens(options)) ?? undefined);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -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
|
};
|