@aws-amplify/core 5.3.2-unstable.ffe65ea.1 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/internals/aws-client-utils/package.json +8 -0
- package/internals/aws-clients/pinpoint/package.json +8 -0
- package/lib/Amplify.js +18 -3
- package/lib/AwsClients/CognitoIdentity/base.d.ts +28 -0
- package/lib/AwsClients/CognitoIdentity/base.js +109 -0
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +12 -0
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +82 -0
- package/lib/AwsClients/CognitoIdentity/getId.d.ts +12 -0
- package/lib/AwsClients/CognitoIdentity/getId.js +72 -0
- package/lib/AwsClients/CognitoIdentity/index.d.ts +2 -0
- package/lib/AwsClients/CognitoIdentity/index.js +9 -0
- package/lib/AwsClients/CognitoIdentity/types.d.ts +153 -0
- package/lib/AwsClients/CognitoIdentity/types.js +4 -0
- package/lib/AwsClients/Pinpoint/base.d.ts +17 -0
- package/lib/AwsClients/Pinpoint/base.js +39 -0
- package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +13 -0
- package/lib/AwsClients/Pinpoint/getInAppMessages.js +77 -0
- package/lib/AwsClients/Pinpoint/index.d.ts +4 -0
- package/lib/AwsClients/Pinpoint/index.js +11 -0
- package/lib/AwsClients/Pinpoint/putEvents.d.ts +13 -0
- package/lib/AwsClients/Pinpoint/putEvents.js +78 -0
- package/lib/AwsClients/Pinpoint/types.d.ts +836 -0
- package/lib/AwsClients/Pinpoint/types.js +5 -0
- package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +13 -0
- package/lib/AwsClients/Pinpoint/updateEndpoint.js +81 -0
- package/lib/ClientDevice/android.js +3 -2
- package/lib/ClientDevice/browser.js +1 -1
- package/lib/ClientDevice/index.js +3 -3
- package/lib/ClientDevice/ios.js +3 -2
- package/lib/ClientDevice/reactnative.js +3 -3
- package/lib/Credentials.js +176 -113
- package/lib/Errors.js +1 -1
- package/lib/Hub.d.ts +4 -4
- package/lib/Hub.js +47 -12
- package/lib/I18n/I18n.js +13 -3
- package/lib/I18n/index.js +1 -1
- package/lib/I18n/types.js +1 -1
- package/lib/JS.js +29 -17
- package/lib/Logger/ConsoleLogger.js +51 -17
- package/lib/Logger/index.js +3 -3
- package/lib/Logger/logger-interface.js +0 -1
- package/lib/OAuthHelper/FacebookOAuth.js +41 -6
- package/lib/OAuthHelper/GoogleOAuth.js +41 -6
- package/lib/OAuthHelper/index.js +1 -1
- package/lib/Platform/index.js +8 -7
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +2 -2
- package/lib/Providers/AWSCloudWatchProvider.js +104 -44
- package/lib/Providers/index.js +2 -2
- package/lib/RNComponents/index.js +2 -2
- package/lib/RNComponents/reactnative.js +7 -5
- package/lib/ServiceWorker/ServiceWorker.js +11 -11
- package/lib/ServiceWorker/index.js +2 -2
- package/lib/Signer.js +17 -7
- package/lib/StorageHelper/index.js +1 -1
- package/lib/StorageHelper/reactnative.js +5 -3
- package/lib/UniversalStorage/index.d.ts +2 -2
- package/lib/UniversalStorage/index.js +24 -6
- package/lib/Util/BackgroundProcessManager.js +84 -23
- package/lib/Util/Constants.js +1 -1
- package/lib/Util/DateUtils.js +18 -3
- package/lib/Util/Mutex.js +0 -1
- package/lib/Util/Reachability.d.ts +1 -1
- package/lib/Util/Reachability.js +18 -6
- package/lib/Util/Reachability.native.d.ts +1 -1
- package/lib/Util/Reachability.native.js +4 -3
- package/lib/Util/Retry.js +103 -26
- package/lib/Util/StringUtils.js +1 -1
- package/lib/Util/index.js +24 -21
- package/lib/clients/endpoints/getDnsSuffix.d.ts +11 -0
- package/lib/clients/endpoints/getDnsSuffix.js +49 -0
- package/lib/clients/endpoints/index.d.ts +1 -0
- package/lib/clients/endpoints/index.js +7 -0
- package/lib/clients/endpoints/partitions.d.ts +33 -0
- package/lib/clients/endpoints/partitions.js +41 -0
- package/lib/clients/handlers/authenticated.d.ts +5 -0
- package/lib/clients/handlers/authenticated.js +15 -0
- package/lib/clients/handlers/fetch.d.ts +4 -0
- package/lib/clients/handlers/fetch.js +123 -0
- package/lib/clients/handlers/unauthenticated.d.ts +4 -0
- package/lib/clients/handlers/unauthenticated.js +10 -0
- package/lib/clients/index.d.ts +8 -0
- package/lib/clients/index.js +37 -0
- package/lib/clients/internal/composeServiceApi.d.ts +8 -0
- package/lib/clients/internal/composeServiceApi.js +75 -0
- package/lib/clients/internal/composeTransferHandler.d.ts +29 -0
- package/lib/clients/internal/composeTransferHandler.js +26 -0
- package/lib/clients/middleware/retry/defaultRetryDecider.d.ts +6 -0
- package/lib/clients/middleware/retry/defaultRetryDecider.js +101 -0
- package/lib/clients/middleware/retry/index.d.ts +3 -0
- package/lib/clients/middleware/retry/index.js +11 -0
- package/lib/clients/middleware/retry/jitteredBackoff.d.ts +2 -0
- package/lib/clients/middleware/retry/jitteredBackoff.js +16 -0
- package/lib/clients/middleware/retry/middleware.d.ts +40 -0
- package/lib/clients/middleware/retry/middleware.js +143 -0
- package/lib/clients/middleware/signing/index.d.ts +1 -0
- package/lib/clients/middleware/signing/index.js +7 -0
- package/lib/clients/middleware/signing/middleware.d.ts +13 -0
- package/lib/clients/middleware/signing/middleware.js +101 -0
- package/lib/clients/middleware/signing/signer/signatureV4/constants.js +1 -1
- package/lib/clients/middleware/signing/signer/signatureV4/index.js +4 -4
- package/lib/clients/middleware/signing/signer/signatureV4/index.native.js +4 -4
- package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.js +46 -8
- package/lib/clients/middleware/signing/signer/signatureV4/signRequest.js +22 -11
- package/lib/clients/middleware/signing/signer/signatureV4/types/index.js +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/types/signer.js +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.d.ts +3 -2
- package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +7 -5
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.d.ts +2 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js +23 -7
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js +24 -8
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +8 -7
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +3 -2
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js +3 -2
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js +3 -2
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.d.ts +2 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js +4 -3
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +7 -6
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.d.ts +2 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js +3 -2
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js +8 -7
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +5 -4
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js +3 -2
- package/lib/clients/middleware/signing/utils/extendedEncodeURIComponent.d.ts +10 -0
- package/lib/clients/middleware/signing/utils/extendedEncodeURIComponent.js +23 -0
- package/lib/clients/middleware/signing/utils/getSkewCorrectedDate.d.ts +10 -0
- package/lib/clients/middleware/signing/utils/getSkewCorrectedDate.js +18 -0
- package/lib/clients/middleware/signing/utils/getUpdatedSystemClockOffset.d.ts +9 -0
- package/lib/clients/middleware/signing/utils/getUpdatedSystemClockOffset.js +21 -0
- package/lib/clients/middleware/signing/utils/isClockSkewed.d.ts +11 -0
- package/lib/clients/middleware/signing/utils/isClockSkewed.js +23 -0
- package/lib/clients/middleware/userAgent/index.d.ts +1 -0
- package/lib/clients/middleware/userAgent/index.js +7 -0
- package/lib/clients/middleware/userAgent/middleware.d.ts +13 -0
- package/lib/clients/middleware/userAgent/middleware.js +77 -0
- package/lib/clients/serde/index.d.ts +2 -0
- package/lib/clients/serde/index.js +10 -0
- package/lib/clients/serde/json.d.ts +12 -0
- package/lib/clients/serde/json.js +115 -0
- package/lib/clients/serde/responseInfo.d.ts +3 -0
- package/lib/clients/serde/responseInfo.js +23 -0
- package/lib/clients/types/aws.d.ts +18 -1
- package/lib/clients/types/aws.js +0 -1
- package/lib/clients/types/core.d.ts +22 -0
- package/lib/clients/types/core.js +0 -1
- package/lib/clients/types/http.d.ts +8 -4
- package/lib/clients/types/http.js +0 -1
- package/lib/clients/types/index.d.ts +3 -2
- package/lib/clients/types/index.js +0 -1
- package/lib/clients/utils/isClockSkewError.d.ts +9 -0
- package/lib/clients/utils/isClockSkewError.js +27 -0
- package/lib/constants.js +1 -1
- package/lib/index.js +61 -60
- package/lib/parseAWSExports.js +15 -4
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/index.js +15 -1
- package/lib/types/types.d.ts +1 -1
- package/lib/types/types.js +0 -1
- package/lib-esm/Amplify.js +16 -2
- package/lib-esm/AwsClients/CognitoIdentity/base.d.ts +28 -0
- package/lib-esm/AwsClients/CognitoIdentity/base.js +104 -0
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +12 -0
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +79 -0
- package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +12 -0
- package/lib-esm/AwsClients/CognitoIdentity/getId.js +69 -0
- package/lib-esm/AwsClients/CognitoIdentity/index.d.ts +2 -0
- package/lib-esm/AwsClients/CognitoIdentity/index.js +4 -0
- package/lib-esm/AwsClients/CognitoIdentity/types.d.ts +153 -0
- package/lib-esm/AwsClients/CognitoIdentity/types.js +3 -0
- package/lib-esm/AwsClients/Pinpoint/base.d.ts +17 -0
- package/lib-esm/AwsClients/Pinpoint/base.js +35 -0
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +13 -0
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.js +74 -0
- package/lib-esm/AwsClients/Pinpoint/index.d.ts +4 -0
- package/lib-esm/AwsClients/Pinpoint/index.js +5 -0
- package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +13 -0
- package/lib-esm/AwsClients/Pinpoint/putEvents.js +75 -0
- package/lib-esm/AwsClients/Pinpoint/types.d.ts +836 -0
- package/lib-esm/AwsClients/Pinpoint/types.js +4 -0
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +13 -0
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.js +78 -0
- package/lib-esm/ClientDevice/android.js +0 -1
- package/lib-esm/ClientDevice/browser.js +0 -1
- package/lib-esm/ClientDevice/index.js +0 -1
- package/lib-esm/ClientDevice/ios.js +0 -1
- package/lib-esm/ClientDevice/reactnative.js +0 -1
- package/lib-esm/Credentials.js +149 -87
- package/lib-esm/Errors.js +0 -1
- package/lib-esm/Hub.d.ts +4 -4
- package/lib-esm/Hub.js +43 -9
- package/lib-esm/I18n/I18n.js +11 -2
- package/lib-esm/I18n/index.js +0 -1
- package/lib-esm/I18n/types.js +0 -1
- package/lib-esm/JS.js +0 -1
- package/lib-esm/Logger/ConsoleLogger.js +49 -16
- package/lib-esm/Logger/index.js +0 -1
- package/lib-esm/Logger/logger-interface.js +1 -1
- package/lib-esm/OAuthHelper/FacebookOAuth.js +36 -2
- package/lib-esm/OAuthHelper/GoogleOAuth.js +36 -2
- package/lib-esm/OAuthHelper/index.js +0 -1
- package/lib-esm/Platform/index.js +5 -6
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -2
- package/lib-esm/Providers/AWSCloudWatchProvider.js +75 -16
- package/lib-esm/Providers/index.js +0 -1
- package/lib-esm/RNComponents/index.js +0 -1
- package/lib-esm/RNComponents/reactnative.js +0 -1
- package/lib-esm/ServiceWorker/ServiceWorker.js +9 -10
- package/lib-esm/ServiceWorker/index.js +0 -1
- package/lib-esm/Signer.js +11 -2
- package/lib-esm/StorageHelper/index.js +0 -1
- package/lib-esm/StorageHelper/reactnative.js +0 -1
- package/lib-esm/UniversalStorage/index.d.ts +2 -2
- package/lib-esm/UniversalStorage/index.js +17 -3
- package/lib-esm/Util/BackgroundProcessManager.js +74 -14
- package/lib-esm/Util/Constants.js +0 -1
- package/lib-esm/Util/DateUtils.js +16 -2
- package/lib-esm/Util/Mutex.js +0 -1
- package/lib-esm/Util/Reachability.d.ts +1 -1
- package/lib-esm/Util/Reachability.js +11 -2
- package/lib-esm/Util/Reachability.native.d.ts +1 -1
- package/lib-esm/Util/Reachability.native.js +0 -1
- package/lib-esm/Util/Retry.js +92 -18
- package/lib-esm/Util/StringUtils.js +0 -1
- package/lib-esm/Util/index.js +0 -1
- package/lib-esm/clients/endpoints/getDnsSuffix.d.ts +11 -0
- package/lib-esm/clients/endpoints/getDnsSuffix.js +45 -0
- package/lib-esm/clients/endpoints/index.d.ts +1 -0
- package/lib-esm/clients/endpoints/index.js +3 -0
- package/lib-esm/clients/endpoints/partitions.d.ts +33 -0
- package/lib-esm/clients/endpoints/partitions.js +38 -0
- package/lib-esm/clients/handlers/authenticated.d.ts +5 -0
- package/lib-esm/clients/handlers/authenticated.js +12 -0
- package/lib-esm/clients/handlers/fetch.d.ts +4 -0
- package/lib-esm/clients/handlers/fetch.js +119 -0
- package/lib-esm/clients/handlers/unauthenticated.d.ts +4 -0
- package/lib-esm/clients/handlers/unauthenticated.js +7 -0
- package/lib-esm/clients/index.d.ts +8 -0
- package/lib-esm/clients/index.js +10 -0
- package/lib-esm/clients/internal/composeServiceApi.d.ts +8 -0
- package/lib-esm/clients/internal/composeServiceApi.js +71 -0
- package/lib-esm/clients/internal/composeTransferHandler.d.ts +29 -0
- package/lib-esm/clients/internal/composeTransferHandler.js +22 -0
- package/lib-esm/clients/middleware/retry/defaultRetryDecider.d.ts +6 -0
- package/lib-esm/clients/middleware/retry/defaultRetryDecider.js +97 -0
- package/lib-esm/clients/middleware/retry/index.d.ts +3 -0
- package/lib-esm/clients/middleware/retry/index.js +5 -0
- package/lib-esm/clients/middleware/retry/jitteredBackoff.d.ts +2 -0
- package/lib-esm/clients/middleware/retry/jitteredBackoff.js +12 -0
- package/lib-esm/clients/middleware/retry/middleware.d.ts +40 -0
- package/lib-esm/clients/middleware/retry/middleware.js +138 -0
- package/lib-esm/clients/middleware/signing/index.d.ts +1 -0
- package/lib-esm/clients/middleware/signing/index.js +3 -0
- package/lib-esm/clients/middleware/signing/middleware.d.ts +13 -0
- package/lib-esm/clients/middleware/signing/middleware.js +97 -0
- package/lib-esm/clients/middleware/signing/signer/signatureV4/constants.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.js +39 -3
- package/lib-esm/clients/middleware/signing/signer/signatureV4/signRequest.js +15 -6
- package/lib-esm/clients/middleware/signing/signer/signatureV4/types/index.js +1 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/types/signer.js +1 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.d.ts +3 -2
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.d.ts +2 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js +20 -6
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js +18 -4
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js +1 -2
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.d.ts +2 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.d.ts +2 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js +1 -2
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js +0 -1
- package/lib-esm/clients/middleware/signing/utils/extendedEncodeURIComponent.d.ts +10 -0
- package/lib-esm/clients/middleware/signing/utils/extendedEncodeURIComponent.js +19 -0
- package/lib-esm/clients/middleware/signing/utils/getSkewCorrectedDate.d.ts +10 -0
- package/lib-esm/clients/middleware/signing/utils/getSkewCorrectedDate.js +14 -0
- package/lib-esm/clients/middleware/signing/utils/getUpdatedSystemClockOffset.d.ts +9 -0
- package/lib-esm/clients/middleware/signing/utils/getUpdatedSystemClockOffset.js +17 -0
- package/lib-esm/clients/middleware/signing/utils/isClockSkewed.d.ts +11 -0
- package/lib-esm/clients/middleware/signing/utils/isClockSkewed.js +19 -0
- package/lib-esm/clients/middleware/userAgent/index.d.ts +1 -0
- package/lib-esm/clients/middleware/userAgent/index.js +3 -0
- package/lib-esm/clients/middleware/userAgent/middleware.d.ts +13 -0
- package/lib-esm/clients/middleware/userAgent/middleware.js +73 -0
- package/lib-esm/clients/serde/index.d.ts +2 -0
- package/lib-esm/clients/serde/index.js +4 -0
- package/lib-esm/clients/serde/json.d.ts +12 -0
- package/lib-esm/clients/serde/json.js +110 -0
- package/lib-esm/clients/serde/responseInfo.d.ts +3 -0
- package/lib-esm/clients/serde/responseInfo.js +19 -0
- package/lib-esm/clients/types/aws.d.ts +18 -1
- package/lib-esm/clients/types/aws.js +1 -1
- package/lib-esm/clients/types/core.d.ts +22 -0
- package/lib-esm/clients/types/core.js +1 -1
- package/lib-esm/clients/types/http.d.ts +8 -4
- package/lib-esm/clients/types/http.js +1 -1
- package/lib-esm/clients/types/index.d.ts +3 -2
- package/lib-esm/clients/types/index.js +1 -1
- package/lib-esm/clients/utils/isClockSkewError.d.ts +9 -0
- package/lib-esm/clients/utils/isClockSkewError.js +23 -0
- package/lib-esm/constants.js +0 -1
- package/lib-esm/index.js +0 -1
- package/lib-esm/parseAWSExports.js +11 -2
- package/lib-esm/tsconfig.tsbuildinfo +1 -0
- package/lib-esm/types/index.js +1 -1
- package/lib-esm/types/types.d.ts +1 -1
- package/lib-esm/types/types.js +1 -1
- package/package.json +56 -22
- package/src/AwsClients/CognitoIdentity/base.ts +88 -0
- package/src/AwsClients/CognitoIdentity/getCredentialsForIdentity.ts +67 -0
- package/src/AwsClients/CognitoIdentity/getId.ts +58 -0
- package/src/AwsClients/CognitoIdentity/index.ts +9 -0
- package/src/AwsClients/CognitoIdentity/types.ts +159 -0
- package/src/AwsClients/Pinpoint/base.ts +41 -0
- package/src/AwsClients/Pinpoint/getInAppMessages.ts +56 -0
- package/src/AwsClients/Pinpoint/index.ts +15 -0
- package/src/AwsClients/Pinpoint/putEvents.ts +55 -0
- package/src/AwsClients/Pinpoint/types.ts +844 -0
- package/src/AwsClients/Pinpoint/updateEndpoint.ts +60 -0
- package/src/Credentials.ts +75 -100
- package/src/OAuthHelper/FacebookOAuth.ts +1 -1
- package/src/OAuthHelper/GoogleOAuth.ts +1 -1
- package/src/Platform/version.ts +1 -1
- package/src/StorageHelper/reactnative.ts +1 -1
- package/src/clients/endpoints/getDnsSuffix.ts +25 -0
- package/src/clients/endpoints/index.ts +4 -0
- package/src/clients/endpoints/partitions.ts +40 -0
- package/src/clients/handlers/authenticated.ts +19 -0
- package/src/clients/handlers/fetch.ts +75 -0
- package/src/clients/handlers/unauthenticated.ts +14 -0
- package/src/clients/index.ts +15 -0
- package/src/clients/internal/composeServiceApi.ts +50 -0
- package/src/clients/internal/composeTransferHandler.ts +89 -0
- package/src/clients/middleware/retry/defaultRetryDecider.ts +54 -0
- package/src/clients/middleware/retry/index.ts +6 -0
- package/src/clients/middleware/retry/jitteredBackoff.ts +16 -0
- package/src/clients/middleware/retry/middleware.ts +133 -0
- package/src/clients/middleware/signing/index.ts +4 -0
- package/src/clients/middleware/signing/middleware.ts +65 -0
- package/src/clients/middleware/signing/utils/extendedEncodeURIComponent.ts +21 -0
- package/src/clients/middleware/signing/utils/getSkewCorrectedDate.ts +14 -0
- package/src/clients/middleware/signing/utils/getUpdatedSystemClockOffset.ts +22 -0
- package/src/clients/middleware/signing/utils/isClockSkewed.ts +26 -0
- package/src/clients/middleware/userAgent/index.ts +4 -0
- package/src/clients/middleware/userAgent/middleware.ts +41 -0
- package/src/clients/serde/index.ts +5 -0
- package/src/clients/serde/json.ts +51 -0
- package/src/clients/serde/responseInfo.ts +20 -0
- package/src/clients/types/aws.ts +21 -0
- package/src/clients/types/core.ts +40 -0
- package/src/clients/types/http.ts +12 -2
- package/src/clients/types/index.ts +22 -2
- package/src/clients/utils/isClockSkewError.ts +24 -0
- package/lib/.tsbuildinfo +0 -3
- package/lib/Amplify.js.map +0 -1
- package/lib/ClientDevice/android.js.map +0 -1
- package/lib/ClientDevice/browser.js.map +0 -1
- package/lib/ClientDevice/index.js.map +0 -1
- package/lib/ClientDevice/ios.js.map +0 -1
- package/lib/ClientDevice/reactnative.js.map +0 -1
- package/lib/Credentials.js.map +0 -1
- package/lib/Errors.js.map +0 -1
- package/lib/Hub.js.map +0 -1
- package/lib/I18n/I18n.js.map +0 -1
- package/lib/I18n/index.js.map +0 -1
- package/lib/I18n/types.js.map +0 -1
- package/lib/JS.js.map +0 -1
- package/lib/Logger/ConsoleLogger.js.map +0 -1
- package/lib/Logger/index.js.map +0 -1
- package/lib/Logger/logger-interface.js.map +0 -1
- package/lib/OAuthHelper/FacebookOAuth.js.map +0 -1
- package/lib/OAuthHelper/GoogleOAuth.js.map +0 -1
- package/lib/OAuthHelper/index.js.map +0 -1
- package/lib/Platform/index.js.map +0 -1
- package/lib/Platform/version.js.map +0 -1
- package/lib/Providers/AWSCloudWatchProvider.js.map +0 -1
- package/lib/Providers/index.js.map +0 -1
- package/lib/RNComponents/index.js.map +0 -1
- package/lib/RNComponents/reactnative.js.map +0 -1
- package/lib/ServiceWorker/ServiceWorker.js.map +0 -1
- package/lib/ServiceWorker/index.js.map +0 -1
- package/lib/Signer.js.map +0 -1
- package/lib/StorageHelper/index.js.map +0 -1
- package/lib/StorageHelper/reactnative.js.map +0 -1
- package/lib/UniversalStorage/index.js.map +0 -1
- package/lib/Util/BackgroundProcessManager.js.map +0 -1
- package/lib/Util/CognitoIdentityClient.d.ts +0 -14
- package/lib/Util/CognitoIdentityClient.js +0 -31
- package/lib/Util/CognitoIdentityClient.js.map +0 -1
- package/lib/Util/Constants.js.map +0 -1
- package/lib/Util/DateUtils.js.map +0 -1
- package/lib/Util/Mutex.js.map +0 -1
- package/lib/Util/Reachability.js.map +0 -1
- package/lib/Util/Reachability.native.js.map +0 -1
- package/lib/Util/Retry.js.map +0 -1
- package/lib/Util/StringUtils.js.map +0 -1
- package/lib/Util/index.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/constants.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/index.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/index.native.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/signRequest.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/types/index.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/types/signer.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignature.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js.map +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js.map +0 -1
- package/lib/clients/types/aws.js.map +0 -1
- package/lib/clients/types/core.js.map +0 -1
- package/lib/clients/types/http.js.map +0 -1
- package/lib/clients/types/index.js.map +0 -1
- package/lib/constants.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/parseAWSExports.js.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib/types/types.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/Amplify.js.map +0 -1
- package/lib-esm/ClientDevice/android.js.map +0 -1
- package/lib-esm/ClientDevice/browser.js.map +0 -1
- package/lib-esm/ClientDevice/index.js.map +0 -1
- package/lib-esm/ClientDevice/ios.js.map +0 -1
- package/lib-esm/ClientDevice/reactnative.js.map +0 -1
- package/lib-esm/Credentials.js.map +0 -1
- package/lib-esm/Errors.js.map +0 -1
- package/lib-esm/Hub.js.map +0 -1
- package/lib-esm/I18n/I18n.js.map +0 -1
- package/lib-esm/I18n/index.js.map +0 -1
- package/lib-esm/I18n/types.js.map +0 -1
- package/lib-esm/JS.js.map +0 -1
- package/lib-esm/Logger/ConsoleLogger.js.map +0 -1
- package/lib-esm/Logger/index.js.map +0 -1
- package/lib-esm/Logger/logger-interface.js.map +0 -1
- package/lib-esm/OAuthHelper/FacebookOAuth.js.map +0 -1
- package/lib-esm/OAuthHelper/GoogleOAuth.js.map +0 -1
- package/lib-esm/OAuthHelper/index.js.map +0 -1
- package/lib-esm/Platform/index.js.map +0 -1
- package/lib-esm/Platform/version.js.map +0 -1
- package/lib-esm/Providers/AWSCloudWatchProvider.js.map +0 -1
- package/lib-esm/Providers/index.js.map +0 -1
- package/lib-esm/RNComponents/index.js.map +0 -1
- package/lib-esm/RNComponents/reactnative.js.map +0 -1
- package/lib-esm/ServiceWorker/ServiceWorker.js.map +0 -1
- package/lib-esm/ServiceWorker/index.js.map +0 -1
- package/lib-esm/Signer.js.map +0 -1
- package/lib-esm/StorageHelper/index.js.map +0 -1
- package/lib-esm/StorageHelper/reactnative.js.map +0 -1
- package/lib-esm/UniversalStorage/index.js.map +0 -1
- package/lib-esm/Util/BackgroundProcessManager.js.map +0 -1
- package/lib-esm/Util/CognitoIdentityClient.d.ts +0 -14
- package/lib-esm/Util/CognitoIdentityClient.js +0 -27
- package/lib-esm/Util/CognitoIdentityClient.js.map +0 -1
- package/lib-esm/Util/Constants.js.map +0 -1
- package/lib-esm/Util/DateUtils.js.map +0 -1
- package/lib-esm/Util/Mutex.js.map +0 -1
- package/lib-esm/Util/Reachability.js.map +0 -1
- package/lib-esm/Util/Reachability.native.js.map +0 -1
- package/lib-esm/Util/Retry.js.map +0 -1
- package/lib-esm/Util/StringUtils.js.map +0 -1
- package/lib-esm/Util/index.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/constants.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/signRequest.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/types/index.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/types/signer.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignature.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js.map +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js.map +0 -1
- package/lib-esm/clients/types/aws.js.map +0 -1
- package/lib-esm/clients/types/core.js.map +0 -1
- package/lib-esm/clients/types/http.js.map +0 -1
- package/lib-esm/clients/types/index.js.map +0 -1
- package/lib-esm/constants.js.map +0 -1
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/parseAWSExports.js.map +0 -1
- package/lib-esm/types/index.js.map +0 -1
- package/lib-esm/types/types.js.map +0 -1
- package/src/Util/CognitoIdentityClient.ts +0 -48
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { authenticatedHandler } from '../../clients/handlers/authenticated';
|
|
5
|
+
import { composeServiceApi } from '../../clients/internal/composeServiceApi';
|
|
6
|
+
import { extendedEncodeURIComponent } from '../../clients/middleware/signing/utils/extendedEncodeURIComponent';
|
|
7
|
+
import {
|
|
8
|
+
parseJsonBody,
|
|
9
|
+
parseJsonError,
|
|
10
|
+
parseMetadata,
|
|
11
|
+
} from '../../clients/serde';
|
|
12
|
+
import { Endpoint, HttpRequest, HttpResponse } from '../../clients/types';
|
|
13
|
+
import { defaultConfig, getSharedHeaders } from './base';
|
|
14
|
+
import type {
|
|
15
|
+
UpdateEndpointCommandInput as UpdateEndpointInput,
|
|
16
|
+
UpdateEndpointCommandOutput as UpdateEndpointOutput,
|
|
17
|
+
} from './types';
|
|
18
|
+
|
|
19
|
+
export type { UpdateEndpointInput, UpdateEndpointOutput };
|
|
20
|
+
|
|
21
|
+
const updateEndpointSerializer = (
|
|
22
|
+
{ ApplicationId, EndpointId, EndpointRequest }: UpdateEndpointInput,
|
|
23
|
+
endpoint: Endpoint
|
|
24
|
+
): HttpRequest => {
|
|
25
|
+
const headers = getSharedHeaders();
|
|
26
|
+
const url = new URL(endpoint.url);
|
|
27
|
+
url.pathname = `v1/apps/${extendedEncodeURIComponent(
|
|
28
|
+
ApplicationId
|
|
29
|
+
)}/endpoints/${extendedEncodeURIComponent(EndpointId)}`;
|
|
30
|
+
const body = JSON.stringify(EndpointRequest ?? {});
|
|
31
|
+
return { method: 'PUT', headers, url, body };
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const updateEndpointDeserializer = async (
|
|
35
|
+
response: HttpResponse
|
|
36
|
+
): Promise<UpdateEndpointOutput> => {
|
|
37
|
+
if (response.statusCode >= 300) {
|
|
38
|
+
const error = await parseJsonError(response);
|
|
39
|
+
throw error;
|
|
40
|
+
} else {
|
|
41
|
+
const { Message, RequestID } = await parseJsonBody(response);
|
|
42
|
+
return {
|
|
43
|
+
MessageBody: {
|
|
44
|
+
Message,
|
|
45
|
+
RequestID,
|
|
46
|
+
},
|
|
47
|
+
$metadata: parseMetadata(response),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
export const updateEndpoint = composeServiceApi(
|
|
56
|
+
authenticatedHandler,
|
|
57
|
+
updateEndpointSerializer,
|
|
58
|
+
updateEndpointDeserializer,
|
|
59
|
+
defaultConfig
|
|
60
|
+
);
|
package/src/Credentials.ts
CHANGED
|
@@ -5,20 +5,9 @@ import { FacebookOAuth, GoogleOAuth } from './OAuthHelper';
|
|
|
5
5
|
import { jitteredExponentialRetry } from './Util';
|
|
6
6
|
import { ICredentials } from './types';
|
|
7
7
|
import { Amplify } from './Amplify';
|
|
8
|
-
import {
|
|
9
|
-
fromCognitoIdentity,
|
|
10
|
-
FromCognitoIdentityParameters,
|
|
11
|
-
fromCognitoIdentityPool,
|
|
12
|
-
FromCognitoIdentityPoolParameters,
|
|
13
|
-
} from '@aws-sdk/credential-provider-cognito-identity';
|
|
14
|
-
import {
|
|
15
|
-
GetIdCommand,
|
|
16
|
-
GetCredentialsForIdentityCommand,
|
|
17
|
-
} from '@aws-sdk/client-cognito-identity';
|
|
18
|
-
import { CredentialProvider } from '@aws-sdk/types';
|
|
8
|
+
import { getId, getCredentialsForIdentity } from './AwsClients/CognitoIdentity';
|
|
19
9
|
import { parseAWSExports } from './parseAWSExports';
|
|
20
10
|
import { Hub } from './Hub';
|
|
21
|
-
import { createCognitoIdentityClient } from './Util/CognitoIdentityClient';
|
|
22
11
|
|
|
23
12
|
const logger = new Logger('Credentials');
|
|
24
13
|
|
|
@@ -49,7 +38,7 @@ export class CredentialsClass {
|
|
|
49
38
|
private _storage;
|
|
50
39
|
private _storageSync;
|
|
51
40
|
private _identityId;
|
|
52
|
-
private _nextCredentialsRefresh:
|
|
41
|
+
private _nextCredentialsRefresh: number;
|
|
53
42
|
|
|
54
43
|
// Allow `Auth` to be injected for SSR, but Auth isn't a required dependency for Credentials
|
|
55
44
|
Auth = undefined;
|
|
@@ -291,47 +280,29 @@ export class CredentialsClass {
|
|
|
291
280
|
|
|
292
281
|
const identityId = (this._identityId = await this._getGuestIdentityId());
|
|
293
282
|
|
|
294
|
-
const
|
|
295
|
-
region: identityPoolRegion || region,
|
|
296
|
-
});
|
|
283
|
+
const cognitoConfig = { region: identityPoolRegion ?? region };
|
|
297
284
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
};
|
|
304
|
-
credentials = fromCognitoIdentity(cognitoIdentityParams)();
|
|
305
|
-
} else {
|
|
306
|
-
/*
|
|
307
|
-
Retreiving identityId with GetIdCommand to mimic the behavior in the following code in aws-sdk-v3:
|
|
308
|
-
https://git.io/JeDxU
|
|
309
|
-
|
|
310
|
-
Note: Retreive identityId from CredentialsProvider once aws-sdk-js v3 supports this.
|
|
311
|
-
*/
|
|
312
|
-
const credentialsProvider: CredentialProvider = async () => {
|
|
313
|
-
const { IdentityId } = await cognitoClient.send(
|
|
314
|
-
new GetIdCommand({
|
|
315
|
-
IdentityPoolId: identityPoolId,
|
|
316
|
-
})
|
|
317
|
-
);
|
|
285
|
+
const guestCredentialsProvider = async () => {
|
|
286
|
+
if (!identityId) {
|
|
287
|
+
const { IdentityId } = await getId(cognitoConfig, {
|
|
288
|
+
IdentityPoolId: identityPoolId,
|
|
289
|
+
});
|
|
318
290
|
this._identityId = IdentityId;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
const credentialsFromCognitoIdentity = fromCognitoIdentity(
|
|
325
|
-
cognitoIdentityParams
|
|
326
|
-
);
|
|
327
|
-
|
|
328
|
-
return credentialsFromCognitoIdentity();
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
credentials = credentialsProvider().catch(async err => {
|
|
332
|
-
throw err;
|
|
291
|
+
}
|
|
292
|
+
const { Credentials } = await getCredentialsForIdentity(cognitoConfig, {
|
|
293
|
+
IdentityId: this._identityId,
|
|
333
294
|
});
|
|
334
|
-
|
|
295
|
+
return {
|
|
296
|
+
identityId: this._identityId,
|
|
297
|
+
accessKeyId: Credentials.AccessKeyId,
|
|
298
|
+
secretAccessKey: Credentials.SecretKey,
|
|
299
|
+
sessionToken: Credentials.SessionToken,
|
|
300
|
+
expiration: Credentials.Expiration,
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
let credentials = guestCredentialsProvider().catch(async err => {
|
|
304
|
+
throw err;
|
|
305
|
+
});
|
|
335
306
|
|
|
336
307
|
return this._loadCredentials(credentials, 'guest', false, null)
|
|
337
308
|
.then(res => {
|
|
@@ -347,26 +318,28 @@ export class CredentialsClass {
|
|
|
347
318
|
logger.debug('Failed to load guest credentials');
|
|
348
319
|
await this._removeGuestIdentityId();
|
|
349
320
|
|
|
350
|
-
const
|
|
351
|
-
const { IdentityId } = await
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
})
|
|
355
|
-
);
|
|
321
|
+
const guestCredentialsProvider = async () => {
|
|
322
|
+
const { IdentityId } = await getId(cognitoConfig, {
|
|
323
|
+
IdentityPoolId: identityPoolId,
|
|
324
|
+
});
|
|
356
325
|
this._identityId = IdentityId;
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
const credentialsFromCognitoIdentity = fromCognitoIdentity(
|
|
363
|
-
cognitoIdentityParams
|
|
326
|
+
const { Credentials } = await getCredentialsForIdentity(
|
|
327
|
+
cognitoConfig,
|
|
328
|
+
{
|
|
329
|
+
IdentityId,
|
|
330
|
+
}
|
|
364
331
|
);
|
|
365
332
|
|
|
366
|
-
return
|
|
333
|
+
return {
|
|
334
|
+
identityId: IdentityId,
|
|
335
|
+
accessKeyId: Credentials.AccessKeyId,
|
|
336
|
+
secretAccessKey: Credentials.SecretKey,
|
|
337
|
+
sessionToken: Credentials.SessionToken,
|
|
338
|
+
expiration: Credentials.Expiration,
|
|
339
|
+
};
|
|
367
340
|
};
|
|
368
341
|
|
|
369
|
-
credentials =
|
|
342
|
+
credentials = guestCredentialsProvider().catch(async err => {
|
|
370
343
|
throw err;
|
|
371
344
|
});
|
|
372
345
|
|
|
@@ -378,7 +351,8 @@ export class CredentialsClass {
|
|
|
378
351
|
}
|
|
379
352
|
|
|
380
353
|
private _setCredentialsFromFederation(params) {
|
|
381
|
-
const { provider, token
|
|
354
|
+
const { provider, token } = params;
|
|
355
|
+
let { identity_id } = params;
|
|
382
356
|
const domains = {
|
|
383
357
|
google: 'accounts.google.com',
|
|
384
358
|
facebook: 'graph.facebook.com',
|
|
@@ -407,26 +381,33 @@ export class CredentialsClass {
|
|
|
407
381
|
);
|
|
408
382
|
}
|
|
409
383
|
|
|
410
|
-
const
|
|
411
|
-
region: identityPoolRegion || region,
|
|
412
|
-
});
|
|
384
|
+
const cognitoConfig = { region: identityPoolRegion ?? region };
|
|
413
385
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
386
|
+
const authenticatedCredentialsProvider = async () => {
|
|
387
|
+
if (!identity_id) {
|
|
388
|
+
const { IdentityId } = await getId(cognitoConfig, {
|
|
389
|
+
IdentityPoolId: identityPoolId,
|
|
390
|
+
Logins: logins,
|
|
391
|
+
});
|
|
392
|
+
identity_id = IdentityId;
|
|
393
|
+
}
|
|
394
|
+
const { Credentials } = await getCredentialsForIdentity(cognitoConfig, {
|
|
395
|
+
IdentityId: identity_id,
|
|
396
|
+
Logins: logins,
|
|
397
|
+
});
|
|
398
|
+
return {
|
|
417
399
|
identityId: identity_id,
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
} else {
|
|
423
|
-
const cognitoIdentityParams: FromCognitoIdentityPoolParameters = {
|
|
424
|
-
logins,
|
|
425
|
-
identityPoolId,
|
|
426
|
-
client: cognitoClient,
|
|
400
|
+
accessKeyId: Credentials.AccessKeyId,
|
|
401
|
+
secretAccessKey: Credentials.SecretKey,
|
|
402
|
+
sessionToken: Credentials.SessionToken,
|
|
403
|
+
expiration: Credentials.Expiration,
|
|
427
404
|
};
|
|
428
|
-
|
|
429
|
-
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
const credentials = authenticatedCredentialsProvider().catch(async err => {
|
|
408
|
+
throw err;
|
|
409
|
+
});
|
|
410
|
+
|
|
430
411
|
return this._loadCredentials(credentials, 'federated', true, params);
|
|
431
412
|
}
|
|
432
413
|
|
|
@@ -449,9 +430,7 @@ export class CredentialsClass {
|
|
|
449
430
|
const logins = {};
|
|
450
431
|
logins[key] = idToken;
|
|
451
432
|
|
|
452
|
-
const
|
|
453
|
-
region: identityPoolRegion || region,
|
|
454
|
-
});
|
|
433
|
+
const cognitoConfig = { region: identityPoolRegion ?? region };
|
|
455
434
|
|
|
456
435
|
/*
|
|
457
436
|
Retreiving identityId with GetIdCommand to mimic the behavior in the following code in aws-sdk-v3:
|
|
@@ -459,7 +438,7 @@ export class CredentialsClass {
|
|
|
459
438
|
|
|
460
439
|
Note: Retreive identityId from CredentialsProvider once aws-sdk-js v3 supports this.
|
|
461
440
|
*/
|
|
462
|
-
const credentialsProvider
|
|
441
|
+
const credentialsProvider = async () => {
|
|
463
442
|
// try to fetch the local stored guest identity, if found, we will associate it with the logins
|
|
464
443
|
const guestIdentityId = await this._getGuestIdentityId();
|
|
465
444
|
|
|
@@ -467,12 +446,10 @@ export class CredentialsClass {
|
|
|
467
446
|
if (!guestIdentityId) {
|
|
468
447
|
// for a first-time user, this will return a brand new identity
|
|
469
448
|
// for a returning user, this will retrieve the previous identity assocaited with the logins
|
|
470
|
-
const { IdentityId } = await
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
})
|
|
475
|
-
);
|
|
449
|
+
const { IdentityId } = await getId(cognitoConfig, {
|
|
450
|
+
IdentityPoolId: identityPoolId,
|
|
451
|
+
Logins: logins,
|
|
452
|
+
});
|
|
476
453
|
generatedOrRetrievedIdentityId = IdentityId;
|
|
477
454
|
}
|
|
478
455
|
|
|
@@ -481,12 +458,10 @@ export class CredentialsClass {
|
|
|
481
458
|
// single source of truth for the primary identity associated with the logins
|
|
482
459
|
// only if a guest identity is used for a first-time user, that guest identity will become its primary identity
|
|
483
460
|
IdentityId: primaryIdentityId,
|
|
484
|
-
} = await
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
})
|
|
489
|
-
);
|
|
461
|
+
} = await getCredentialsForIdentity(cognitoConfig, {
|
|
462
|
+
IdentityId: guestIdentityId || generatedOrRetrievedIdentityId,
|
|
463
|
+
Logins: logins,
|
|
464
|
+
});
|
|
490
465
|
|
|
491
466
|
this._identityId = primaryIdentityId;
|
|
492
467
|
if (guestIdentityId) {
|
|
@@ -6,7 +6,7 @@ import { NonRetryableError } from '../Util';
|
|
|
6
6
|
|
|
7
7
|
const logger = new Logger('CognitoCredentials');
|
|
8
8
|
|
|
9
|
-
const waitForInit = new Promise((res, rej) => {
|
|
9
|
+
const waitForInit = new Promise<void>((res, rej) => {
|
|
10
10
|
if (!browserOrNode().isBrowser) {
|
|
11
11
|
logger.debug('not in the browser, directly resolved');
|
|
12
12
|
return res();
|
|
@@ -6,7 +6,7 @@ import { NonRetryableError } from '../Util';
|
|
|
6
6
|
|
|
7
7
|
const logger = new Logger('CognitoCredentials');
|
|
8
8
|
|
|
9
|
-
const waitForInit = new Promise((res, rej) => {
|
|
9
|
+
const waitForInit = new Promise<void>((res, rej) => {
|
|
10
10
|
if (!browserOrNode().isBrowser) {
|
|
11
11
|
logger.debug('not in the browser, directly resolved');
|
|
12
12
|
return res();
|
package/src/Platform/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '5.2.5
|
|
2
|
+
export const version = '5.2.5';
|
|
@@ -59,7 +59,7 @@ class MemoryStorage {
|
|
|
59
59
|
*/
|
|
60
60
|
static sync() {
|
|
61
61
|
if (!MemoryStorage.syncPromise) {
|
|
62
|
-
MemoryStorage.syncPromise = new Promise((res, rej) => {
|
|
62
|
+
MemoryStorage.syncPromise = new Promise<void>((res, rej) => {
|
|
63
63
|
AsyncStorage.getAllKeys((errKeys, keys) => {
|
|
64
64
|
if (errKeys) rej(errKeys);
|
|
65
65
|
const memoryKeys = keys.filter(key =>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { defaultPartition, partitionsInfo } from './partitions';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get the AWS Services endpoint URL's DNS suffix for a given region. A typical AWS regional service endpoint URL will
|
|
8
|
+
* follow this pattern: {endpointPrefix}.{region}.{dnsSuffix}. For example, the endpoint URL for Cognito Identity in
|
|
9
|
+
* us-east-1 will be cognito-identity.us-east-1.amazonaws.com. Here the DnsSuffix is `amazonaws.com`.
|
|
10
|
+
*
|
|
11
|
+
* @param region
|
|
12
|
+
* @returns The DNS suffix
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export const getDnsSuffix = (region: string): string => {
|
|
17
|
+
const { partitions } = partitionsInfo;
|
|
18
|
+
for (const { regions, outputs, regionRegex } of partitions) {
|
|
19
|
+
const regex = new RegExp(regionRegex);
|
|
20
|
+
if (regions.includes(region) || regex.test(region)) {
|
|
21
|
+
return outputs.dnsSuffix;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return defaultPartition.outputs.dnsSuffix;
|
|
25
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Default partition for AWS services. This is used when the region is not provided or the region is not recognized.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export const defaultPartition = {
|
|
10
|
+
id: 'aws',
|
|
11
|
+
outputs: {
|
|
12
|
+
dnsSuffix: 'amazonaws.com',
|
|
13
|
+
},
|
|
14
|
+
regionRegex: '^(us|eu|ap|sa|ca|me|af)\\-\\w+\\-\\d+$',
|
|
15
|
+
regions: ['aws-global'],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This data is adapted from the partition file from AWS SDK shared utilities but remove some contents for bundle size
|
|
20
|
+
* concern. Information removed are `dualStackDnsSuffix`, `supportDualStack`, `supportFIPS`, restricted partitions, and
|
|
21
|
+
* list of regions for each partition other than global regions.
|
|
22
|
+
*
|
|
23
|
+
* * Ref: https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints
|
|
24
|
+
* * Ref: https://github.com/aws/aws-sdk-js-v3/blob/0201baef03c2379f1f6f7150b9d401d4b230d488/packages/util-endpoints/src/lib/aws/partitions.json#L1
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export const partitionsInfo = {
|
|
29
|
+
partitions: [
|
|
30
|
+
defaultPartition,
|
|
31
|
+
{
|
|
32
|
+
id: 'aws-cn',
|
|
33
|
+
outputs: {
|
|
34
|
+
dnsSuffix: 'amazonaws.com.cn',
|
|
35
|
+
},
|
|
36
|
+
regionRegex: '^cn\\-\\w+\\-\\d+$',
|
|
37
|
+
regions: ['aws-cn-global'],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { retryMiddleware, RetryOptions } from '../middleware/retry';
|
|
5
|
+
import { signingMiddleware, SigningOptions } from '../middleware/signing';
|
|
6
|
+
import { userAgentMiddleware, UserAgentOptions } from '../middleware/userAgent';
|
|
7
|
+
import { composeTransferHandler } from '../internal/composeTransferHandler';
|
|
8
|
+
import { fetchTransferHandler } from './fetch';
|
|
9
|
+
import { HttpRequest, HttpResponse } from '../types';
|
|
10
|
+
|
|
11
|
+
export const authenticatedHandler = composeTransferHandler<
|
|
12
|
+
[UserAgentOptions, RetryOptions<HttpResponse>, SigningOptions],
|
|
13
|
+
HttpRequest,
|
|
14
|
+
HttpResponse
|
|
15
|
+
>(fetchTransferHandler, [
|
|
16
|
+
userAgentMiddleware,
|
|
17
|
+
retryMiddleware,
|
|
18
|
+
signingMiddleware,
|
|
19
|
+
]);
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import 'isomorphic-unfetch'; // TODO: remove this dependency in v6
|
|
5
|
+
import { HttpRequest, HttpResponse, HttpTransferOptions } from '../types/http';
|
|
6
|
+
import { TransferHandler } from '../types/core';
|
|
7
|
+
|
|
8
|
+
const shouldSendBody = (method: string) =>
|
|
9
|
+
!['HEAD', 'GET', 'DELETE'].includes(method.toUpperCase());
|
|
10
|
+
|
|
11
|
+
export const fetchTransferHandler: TransferHandler<
|
|
12
|
+
HttpRequest,
|
|
13
|
+
HttpResponse,
|
|
14
|
+
HttpTransferOptions
|
|
15
|
+
> = async ({ url, method, headers, body }, { abortSignal }) => {
|
|
16
|
+
let resp: Response;
|
|
17
|
+
try {
|
|
18
|
+
resp = await fetch(url, {
|
|
19
|
+
method,
|
|
20
|
+
headers,
|
|
21
|
+
body: shouldSendBody(method) ? body : undefined,
|
|
22
|
+
signal: abortSignal,
|
|
23
|
+
});
|
|
24
|
+
} catch (e) {
|
|
25
|
+
// TODO: needs to revise error handling in v6
|
|
26
|
+
// For now this is a thin wrapper over original fetch error similar to cognito-identity-js package.
|
|
27
|
+
// Ref: https://github.com/aws-amplify/amplify-js/blob/4fbc8c0a2be7526aab723579b4c95b552195a80b/packages/amazon-cognito-identity-js/src/Client.js#L103-L108
|
|
28
|
+
if (e instanceof TypeError) {
|
|
29
|
+
throw new Error('Network error');
|
|
30
|
+
}
|
|
31
|
+
throw e;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const responseHeaders = {};
|
|
35
|
+
resp.headers?.forEach((value, key) => {
|
|
36
|
+
responseHeaders[key.toLowerCase()] = value;
|
|
37
|
+
});
|
|
38
|
+
const httpResponse = {
|
|
39
|
+
statusCode: resp.status,
|
|
40
|
+
headers: responseHeaders,
|
|
41
|
+
body: null,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// resp.body is a ReadableStream according to Fetch API spec, but React Native
|
|
45
|
+
// does not implement it.
|
|
46
|
+
const bodyWithMixin = Object.assign(resp.body ?? {}, {
|
|
47
|
+
text: withMemoization(() => resp.text()),
|
|
48
|
+
blob: withMemoization(() => resp.blob()),
|
|
49
|
+
json: withMemoization(() => resp.json()),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
...httpResponse,
|
|
54
|
+
body: bodyWithMixin,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Cache the payload of a response body. It allows multiple calls to the body,
|
|
60
|
+
* for example, when reading the body in both retry decider and error deserializer.
|
|
61
|
+
* Caching body is allowed here because we call the body accessor(blob(), json(),
|
|
62
|
+
* etc.) when body is small or streaming implementation is not available(RN).
|
|
63
|
+
*/
|
|
64
|
+
const withMemoization = <T>(payloadAccessor: () => Promise<T>) => {
|
|
65
|
+
let cached: Promise<T>;
|
|
66
|
+
return () => {
|
|
67
|
+
if (!cached) {
|
|
68
|
+
// Explicitly not awaiting. Intermediate await would add overhead and
|
|
69
|
+
// introduce a possible race in the event that this wrapper is called
|
|
70
|
+
// again before the first `payloadAccessor` call resolves.
|
|
71
|
+
cached = payloadAccessor();
|
|
72
|
+
}
|
|
73
|
+
return cached;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { retryMiddleware, RetryOptions } from '../middleware/retry';
|
|
5
|
+
import { userAgentMiddleware, UserAgentOptions } from '../middleware/userAgent';
|
|
6
|
+
import { composeTransferHandler } from '../internal/composeTransferHandler';
|
|
7
|
+
import { fetchTransferHandler } from './fetch';
|
|
8
|
+
import { HttpRequest, HttpResponse } from '../types';
|
|
9
|
+
|
|
10
|
+
export const unauthenticatedHandler = composeTransferHandler<
|
|
11
|
+
[UserAgentOptions, RetryOptions<HttpResponse>],
|
|
12
|
+
HttpRequest,
|
|
13
|
+
HttpResponse
|
|
14
|
+
>(fetchTransferHandler, [userAgentMiddleware, retryMiddleware]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export { getDnsSuffix } from './endpoints';
|
|
5
|
+
|
|
6
|
+
export { fetchTransferHandler } from './handlers/fetch';
|
|
7
|
+
export { unauthenticatedHandler } from './handlers/unauthenticated';
|
|
8
|
+
export { authenticatedHandler } from './handlers/authenticated';
|
|
9
|
+
export { composeServiceApi } from './internal/composeServiceApi';
|
|
10
|
+
export {
|
|
11
|
+
signRequest,
|
|
12
|
+
presignUrl,
|
|
13
|
+
} from './middleware/signing/signer/signatureV4';
|
|
14
|
+
export { parseJsonBody, parseJsonError, parseMetadata } from './serde';
|
|
15
|
+
export * from './types';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ServiceClientOptions } from '../types/aws';
|
|
5
|
+
import { TransferHandler, Endpoint } from '../types/core';
|
|
6
|
+
import { HttpRequest, HttpResponse } from '../types/http';
|
|
7
|
+
|
|
8
|
+
export const composeServiceApi = <
|
|
9
|
+
TransferHandlerOptions,
|
|
10
|
+
Input,
|
|
11
|
+
Output,
|
|
12
|
+
DefaultConfig extends Partial<TransferHandlerOptions & ServiceClientOptions>
|
|
13
|
+
>(
|
|
14
|
+
transferHandler: TransferHandler<
|
|
15
|
+
HttpRequest,
|
|
16
|
+
HttpResponse,
|
|
17
|
+
TransferHandlerOptions
|
|
18
|
+
>,
|
|
19
|
+
serializer: (input: Input, endpoint: Endpoint) => HttpRequest,
|
|
20
|
+
deserializer: (output: HttpResponse) => Promise<Output>,
|
|
21
|
+
defaultConfig: DefaultConfig
|
|
22
|
+
) => {
|
|
23
|
+
return async (
|
|
24
|
+
config: OptionalizeKey<
|
|
25
|
+
TransferHandlerOptions & ServiceClientOptions,
|
|
26
|
+
keyof DefaultConfig
|
|
27
|
+
>,
|
|
28
|
+
input: Input
|
|
29
|
+
) => {
|
|
30
|
+
const resolvedConfig = {
|
|
31
|
+
...defaultConfig,
|
|
32
|
+
...config,
|
|
33
|
+
} as unknown as TransferHandlerOptions & ServiceClientOptions;
|
|
34
|
+
const endpoint = await resolvedConfig.endpointResolver({
|
|
35
|
+
region: resolvedConfig.region,
|
|
36
|
+
});
|
|
37
|
+
// Unlike AWS SDK clients, a serializer should NOT populate the `host` or `content-length` headers.
|
|
38
|
+
// Both of these headers are prohibited per Spec(https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name).
|
|
39
|
+
// They will be populated automatically by browser, or node-fetch polyfill.
|
|
40
|
+
const request = serializer(input, endpoint);
|
|
41
|
+
const response = await transferHandler(request, {
|
|
42
|
+
...resolvedConfig,
|
|
43
|
+
});
|
|
44
|
+
return await deserializer(response);
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type OptionalizeKey<T, K> = Omit<T, K & keyof T> & {
|
|
49
|
+
[P in K & keyof T]?: T[P];
|
|
50
|
+
};
|