@aws-amplify/core 6.0.1-console-preview.f63250a.0 → 6.0.1-console-preview.e8aa063.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/adapter-core/package.json +8 -0
- package/internals/providers/pinpoint/package.json +8 -0
- package/internals/utils/package.json +7 -0
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +1 -1
- package/lib/AwsClients/CognitoIdentity/getId.d.ts +1 -1
- package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +1 -1
- package/lib/AwsClients/Pinpoint/index.d.ts +1 -1
- package/lib/AwsClients/Pinpoint/putEvents.d.ts +1 -1
- package/lib/AwsClients/Pinpoint/putEvents.js +2 -2
- package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +1 -1
- package/lib/Cache/AsyncStorageCache.js +3 -3
- package/lib/Cache/BrowserStorageCache.js +5 -5
- package/lib/Cache/InMemoryCache.js +3 -3
- package/lib/Cache/StorageCache.js +1 -1
- package/lib/Cache/Utils/CacheList.js +5 -5
- package/lib/Credentials.js +2 -5
- package/lib/{Hub.d.ts → Hub/index.d.ts} +5 -21
- package/lib/Hub/index.js +151 -0
- package/lib/Hub/types/AuthTypes.d.ts +11 -0
- package/lib/Hub/types/HubTypes.d.ts +28 -0
- package/lib/Hub/types/HubTypes.js +4 -0
- package/lib/Hub/types/index.d.ts +2 -0
- package/lib/Hub/types/index.js +20 -0
- package/lib/I18n/I18n.js +1 -1
- package/lib/I18n/index.js +5 -5
- package/lib/OAuthHelper/FacebookOAuth.js +1 -1
- package/lib/OAuthHelper/GoogleOAuth.js +1 -1
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/RNComponents/index.d.ts +1 -0
- package/lib/RNComponents/index.js +2 -1
- package/lib/RNComponents/isAppInForeground.d.ts +1 -0
- package/lib/RNComponents/isAppInForeground.js +10 -0
- package/lib/ServiceWorker/ServiceWorker.js +9 -9
- package/lib/StorageHelper/localStorage.js +1 -1
- package/lib/StorageHelper/sessionStorage.js +1 -1
- package/lib/UniversalStorage/index.js +1 -1
- package/lib/Util/Constants.d.ts +12 -8
- package/lib/Util/Constants.js +21 -15
- package/lib/{Errors.d.ts → Util/Errors.d.ts} +1 -1
- package/lib/Util/Reachability.js +1 -1
- package/lib/Util/errors/AssertError.js +1 -1
- package/lib/Util/index.d.ts +1 -1
- package/lib/Util/index.js +1 -5
- package/lib/adapterCore/error/AmplifyServerContextError.d.ts +8 -0
- package/lib/adapterCore/error/AmplifyServerContextError.js +35 -0
- package/lib/adapterCore/error/index.d.ts +1 -0
- package/lib/adapterCore/error/index.js +7 -0
- package/lib/adapterCore/index.d.ts +2 -0
- package/lib/adapterCore/index.js +11 -0
- package/lib/adapterCore/serverContext/index.d.ts +2 -0
- package/lib/adapterCore/serverContext/index.js +9 -0
- package/lib/adapterCore/serverContext/serverContext.d.ts +20 -0
- package/lib/adapterCore/serverContext/serverContext.js +42 -0
- package/lib/adapterCore/serverContext/serverContextRegistry.d.ts +6 -0
- package/lib/adapterCore/serverContext/serverContextRegistry.js +24 -0
- package/lib/adapterCore/serverContext/types/amplifyServer.d.ts +16 -0
- package/lib/adapterCore/serverContext/types/amplifyServer.js +4 -0
- package/lib/adapterCore/serverContext/types/cookieStorage.d.ts +31 -0
- package/lib/adapterCore/serverContext/types/cookieStorage.js +4 -0
- package/lib/adapterCore/serverContext/types/index.d.ts +4 -0
- package/lib/adapterCore/serverContext/types/index.js +4 -0
- package/lib/clients/handlers/fetch.js +1 -0
- package/lib/clients/internal/composeServiceApi.d.ts +5 -2
- package/lib/index.d.ts +11 -32
- package/lib/index.js +19 -100
- package/lib/libraryUtils.d.ts +21 -0
- package/lib/libraryUtils.js +105 -0
- package/lib/providers/pinpoint/apis/index.d.ts +2 -0
- package/lib/providers/pinpoint/apis/index.js +9 -0
- package/lib/providers/pinpoint/apis/record.d.ts +5 -0
- package/lib/providers/pinpoint/apis/record.js +120 -0
- package/lib/providers/pinpoint/apis/updateEndpoint.d.ts +5 -0
- package/lib/providers/pinpoint/apis/updateEndpoint.js +120 -0
- package/lib/providers/pinpoint/index.d.ts +2 -0
- package/lib/providers/pinpoint/index.js +19 -0
- package/lib/providers/pinpoint/types/buffer.d.ts +25 -0
- package/lib/providers/pinpoint/types/buffer.js +4 -0
- package/lib/providers/pinpoint/types/index.d.ts +1 -0
- package/lib/providers/pinpoint/types/index.js +19 -0
- package/lib/providers/pinpoint/types/pinpoint.d.ts +40 -0
- package/lib/providers/pinpoint/types/pinpoint.js +4 -0
- package/lib/providers/pinpoint/utils/PinpointEventBuffer.d.ts +23 -0
- package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +278 -0
- package/lib/providers/pinpoint/utils/cacheEndpointId.d.ts +7 -0
- package/lib/providers/pinpoint/utils/cacheEndpointId.js +61 -0
- package/lib/providers/pinpoint/utils/constants.d.ts +4 -0
- package/lib/providers/pinpoint/utils/constants.js +10 -0
- package/lib/providers/pinpoint/utils/getCacheKey.d.ts +7 -0
- package/lib/providers/pinpoint/utils/getCacheKey.js +13 -0
- package/lib/providers/pinpoint/utils/getEndpointId.d.ts +7 -0
- package/lib/providers/pinpoint/utils/getEndpointId.js +62 -0
- package/lib/providers/pinpoint/utils/getEventBuffer.d.ts +8 -0
- package/lib/providers/pinpoint/utils/getEventBuffer.js +48 -0
- package/lib/providers/pinpoint/utils/index.d.ts +3 -0
- package/lib/providers/pinpoint/utils/index.js +11 -0
- package/lib/server.d.ts +1 -0
- package/lib/server.js +7 -0
- package/lib/singleton/Amplify.d.ts +36 -0
- package/lib/singleton/Amplify.js +138 -0
- package/lib/singleton/Analytics/types.d.ts +2 -0
- package/lib/singleton/Analytics/types.js +4 -0
- package/lib/singleton/Auth/index.js +15 -12
- package/lib/singleton/Auth/types.d.ts +28 -3
- package/lib/singleton/Auth/utils/index.d.ts +3 -2
- package/lib/singleton/Auth/utils/index.js +15 -1
- package/lib/singleton/Storage/types.d.ts +6 -2
- package/lib/singleton/apis/fetchAuthSession.d.ts +2 -0
- package/lib/singleton/apis/fetchAuthSession.js +11 -0
- package/lib/singleton/apis/internal/fetchAuthSession.d.ts +3 -0
- package/lib/singleton/apis/internal/fetchAuthSession.js +9 -0
- package/lib/singleton/apis/server/fetchAuthSession.d.ts +3 -0
- package/lib/singleton/apis/server/fetchAuthSession.js +11 -0
- package/lib/singleton/index.d.ts +2 -46
- package/lib/singleton/index.js +7 -144
- package/lib/singleton/types.d.ts +3 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/core.d.ts +47 -0
- package/lib/types/core.js +4 -0
- package/lib/types/errors.d.ts +16 -0
- package/lib/types/errors.js +4 -0
- package/lib/types/index.d.ts +4 -1
- package/lib/types/index.js +6 -3
- package/lib/types/logging.d.ts +13 -0
- package/lib/types/logging.js +4 -0
- package/lib/types/storage.d.ts +14 -0
- package/lib/types/storage.js +4 -0
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +1 -1
- package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +1 -1
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +1 -1
- package/lib-esm/AwsClients/Pinpoint/index.d.ts +1 -1
- package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +1 -1
- package/lib-esm/AwsClients/Pinpoint/putEvents.js +1 -1
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +1 -1
- package/lib-esm/Cache/AsyncStorageCache.js +1 -1
- package/lib-esm/Cache/BrowserStorageCache.js +1 -1
- package/lib-esm/Cache/InMemoryCache.js +1 -1
- package/lib-esm/Cache/StorageCache.js +2 -2
- package/lib-esm/Cache/Utils/CacheList.js +1 -1
- package/lib-esm/Credentials.js +2 -5
- package/lib-esm/{Hub.d.ts → Hub/index.d.ts} +5 -21
- package/lib-esm/Hub/index.js +148 -0
- package/lib-esm/Hub/types/AuthTypes.d.ts +11 -0
- package/lib-esm/Hub/types/HubTypes.d.ts +28 -0
- package/lib-esm/Hub/types/HubTypes.js +3 -0
- package/lib-esm/Hub/types/index.d.ts +2 -0
- package/lib-esm/Hub/types/index.js +4 -0
- package/lib-esm/I18n/I18n.js +2 -2
- package/lib-esm/I18n/index.js +1 -1
- package/lib-esm/OAuthHelper/FacebookOAuth.js +1 -1
- package/lib-esm/OAuthHelper/GoogleOAuth.js +1 -1
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/RNComponents/index.d.ts +1 -0
- package/lib-esm/RNComponents/index.js +2 -1
- package/lib-esm/RNComponents/isAppInForeground.d.ts +1 -0
- package/lib-esm/RNComponents/isAppInForeground.js +6 -0
- package/lib-esm/ServiceWorker/ServiceWorker.js +3 -3
- package/lib-esm/StorageHelper/localStorage.js +1 -1
- package/lib-esm/StorageHelper/sessionStorage.js +1 -1
- package/lib-esm/UniversalStorage/index.js +1 -1
- package/lib-esm/Util/Constants.d.ts +12 -8
- package/lib-esm/Util/Constants.js +20 -8
- package/lib-esm/{Errors.d.ts → Util/Errors.d.ts} +1 -1
- package/lib-esm/Util/Reachability.js +1 -1
- package/lib-esm/Util/errors/AssertError.js +1 -1
- package/lib-esm/Util/index.d.ts +1 -1
- package/lib-esm/Util/index.js +1 -1
- package/lib-esm/adapterCore/error/AmplifyServerContextError.d.ts +8 -0
- package/lib-esm/adapterCore/error/AmplifyServerContextError.js +32 -0
- package/lib-esm/adapterCore/error/index.d.ts +1 -0
- package/lib-esm/adapterCore/error/index.js +3 -0
- package/lib-esm/adapterCore/index.d.ts +2 -0
- package/lib-esm/adapterCore/index.js +4 -0
- package/lib-esm/adapterCore/serverContext/index.d.ts +2 -0
- package/lib-esm/adapterCore/serverContext/index.js +3 -0
- package/lib-esm/adapterCore/serverContext/serverContext.d.ts +20 -0
- package/lib-esm/adapterCore/serverContext/serverContext.js +36 -0
- package/lib-esm/adapterCore/serverContext/serverContextRegistry.d.ts +6 -0
- package/lib-esm/adapterCore/serverContext/serverContextRegistry.js +21 -0
- package/lib-esm/adapterCore/serverContext/types/amplifyServer.d.ts +16 -0
- package/lib-esm/adapterCore/serverContext/types/amplifyServer.js +3 -0
- package/lib-esm/adapterCore/serverContext/types/cookieStorage.d.ts +31 -0
- package/lib-esm/adapterCore/serverContext/types/cookieStorage.js +3 -0
- package/lib-esm/adapterCore/serverContext/types/index.d.ts +4 -0
- package/lib-esm/adapterCore/serverContext/types/index.js +3 -0
- package/lib-esm/clients/handlers/fetch.js +1 -0
- package/lib-esm/clients/internal/composeServiceApi.d.ts +5 -2
- package/lib-esm/index.d.ts +11 -32
- package/lib-esm/index.js +11 -29
- package/lib-esm/libraryUtils.d.ts +21 -0
- package/lib-esm/libraryUtils.js +33 -0
- package/lib-esm/providers/pinpoint/apis/index.d.ts +2 -0
- package/lib-esm/providers/pinpoint/apis/index.js +4 -0
- package/lib-esm/providers/pinpoint/apis/record.d.ts +5 -0
- package/lib-esm/providers/pinpoint/apis/record.js +116 -0
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.d.ts +5 -0
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +116 -0
- package/lib-esm/providers/pinpoint/index.d.ts +2 -0
- package/lib-esm/providers/pinpoint/index.js +3 -0
- package/lib-esm/providers/pinpoint/types/buffer.d.ts +25 -0
- package/lib-esm/providers/pinpoint/types/buffer.js +3 -0
- package/lib-esm/providers/pinpoint/types/index.d.ts +1 -0
- package/lib-esm/providers/pinpoint/types/index.js +3 -0
- package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +40 -0
- package/lib-esm/providers/pinpoint/types/pinpoint.js +3 -0
- package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.d.ts +23 -0
- package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +275 -0
- package/lib-esm/providers/pinpoint/utils/cacheEndpointId.d.ts +7 -0
- package/lib-esm/providers/pinpoint/utils/cacheEndpointId.js +57 -0
- package/lib-esm/providers/pinpoint/utils/constants.d.ts +4 -0
- package/lib-esm/providers/pinpoint/utils/constants.js +7 -0
- package/lib-esm/providers/pinpoint/utils/getCacheKey.d.ts +7 -0
- package/lib-esm/providers/pinpoint/utils/getCacheKey.js +9 -0
- package/lib-esm/providers/pinpoint/utils/getEndpointId.d.ts +7 -0
- package/lib-esm/providers/pinpoint/utils/getEndpointId.js +58 -0
- package/lib-esm/providers/pinpoint/utils/getEventBuffer.d.ts +8 -0
- package/lib-esm/providers/pinpoint/utils/getEventBuffer.js +44 -0
- package/lib-esm/providers/pinpoint/utils/index.d.ts +3 -0
- package/lib-esm/providers/pinpoint/utils/index.js +5 -0
- package/lib-esm/server.d.ts +1 -0
- package/lib-esm/server.js +3 -0
- package/lib-esm/singleton/Amplify.d.ts +36 -0
- package/lib-esm/singleton/Amplify.js +135 -0
- package/lib-esm/singleton/Analytics/types.d.ts +2 -0
- package/lib-esm/singleton/Analytics/types.js +3 -0
- package/lib-esm/singleton/Auth/index.js +14 -11
- package/lib-esm/singleton/Auth/types.d.ts +28 -3
- package/lib-esm/singleton/Auth/utils/index.d.ts +3 -2
- package/lib-esm/singleton/Auth/utils/index.js +13 -0
- package/lib-esm/singleton/Storage/types.d.ts +6 -2
- package/lib-esm/singleton/apis/fetchAuthSession.d.ts +2 -0
- package/lib-esm/singleton/apis/fetchAuthSession.js +7 -0
- package/lib-esm/singleton/apis/internal/fetchAuthSession.d.ts +3 -0
- package/lib-esm/singleton/apis/internal/fetchAuthSession.js +5 -0
- package/lib-esm/singleton/apis/server/fetchAuthSession.d.ts +3 -0
- package/lib-esm/singleton/apis/server/fetchAuthSession.js +7 -0
- package/lib-esm/singleton/index.d.ts +2 -46
- package/lib-esm/singleton/index.js +2 -141
- package/lib-esm/singleton/types.d.ts +3 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/core.d.ts +47 -0
- package/lib-esm/types/core.js +3 -0
- package/lib-esm/types/errors.d.ts +16 -0
- package/lib-esm/types/errors.js +3 -0
- package/lib-esm/types/index.d.ts +4 -1
- package/lib-esm/types/index.js +4 -1
- package/lib-esm/types/logging.d.ts +13 -0
- package/lib-esm/types/logging.js +3 -0
- package/lib-esm/types/storage.d.ts +14 -0
- package/lib-esm/types/storage.js +3 -0
- package/package.json +15 -12
- package/server/package.json +8 -0
- package/src/AwsClients/Pinpoint/index.ts +1 -1
- package/src/AwsClients/Pinpoint/putEvents.ts +1 -1
- package/src/Cache/AsyncStorageCache.ts +1 -1
- package/src/Cache/BrowserStorageCache.ts +1 -1
- package/src/Cache/InMemoryCache.ts +1 -1
- package/src/Cache/StorageCache.ts +2 -2
- package/src/Cache/Utils/CacheList.ts +1 -1
- package/src/Credentials.ts +2 -8
- package/src/Hub/index.ts +204 -0
- package/src/Hub/types/AuthTypes.ts +10 -0
- package/src/Hub/types/HubTypes.ts +46 -0
- package/src/{Providers → Hub/types}/index.ts +3 -1
- package/src/I18n/I18n.ts +2 -2
- package/src/I18n/index.ts +1 -1
- package/src/Logger/ConsoleLogger.ts +1 -2
- package/src/OAuthHelper/FacebookOAuth.ts +1 -1
- package/src/OAuthHelper/GoogleOAuth.ts +1 -1
- package/src/Platform/version.ts +1 -1
- package/src/RNComponents/index.ts +2 -1
- package/src/RNComponents/isAppInForeground.ts +8 -0
- package/src/ServiceWorker/ServiceWorker.ts +3 -3
- package/src/StorageHelper/localStorage.ts +1 -1
- package/src/StorageHelper/sessionStorage.ts +1 -1
- package/src/UniversalStorage/index.ts +1 -1
- package/src/Util/Constants.ts +25 -16
- package/src/{Errors.ts → Util/Errors.ts} +1 -1
- package/src/Util/Reachability.ts +1 -1
- package/src/Util/errors/AssertError.ts +1 -1
- package/src/Util/index.ts +0 -4
- package/src/adapterCore/error/AmplifyServerContextError.ts +23 -0
- package/src/adapterCore/error/index.ts +4 -0
- package/src/adapterCore/index.ts +11 -0
- package/src/adapterCore/serverContext/index.ts +10 -0
- package/src/adapterCore/serverContext/serverContext.ts +54 -0
- package/src/adapterCore/serverContext/serverContextRegistry.ts +31 -0
- package/src/adapterCore/serverContext/types/amplifyServer.ts +29 -0
- package/src/adapterCore/serverContext/types/cookieStorage.ts +43 -0
- package/src/adapterCore/serverContext/types/index.ts +9 -0
- package/src/clients/handlers/fetch.ts +1 -0
- package/src/clients/internal/composeServiceApi.ts +13 -4
- package/src/index.ts +40 -120
- package/src/libraryUtils.ts +102 -0
- package/src/providers/pinpoint/apis/index.ts +5 -0
- package/src/providers/pinpoint/apis/record.ts +90 -0
- package/src/providers/pinpoint/apis/updateEndpoint.ts +82 -0
- package/src/providers/pinpoint/index.ts +5 -0
- package/src/providers/pinpoint/types/buffer.ts +32 -0
- package/{lib-esm/Providers/index.js → src/providers/pinpoint/types/index.ts} +2 -1
- package/src/providers/pinpoint/types/pinpoint.ts +55 -0
- package/src/providers/pinpoint/utils/PinpointEventBuffer.ts +248 -0
- package/src/providers/pinpoint/utils/cacheEndpointId.ts +27 -0
- package/src/providers/pinpoint/utils/constants.ts +8 -0
- package/src/providers/pinpoint/utils/getCacheKey.ts +16 -0
- package/src/providers/pinpoint/utils/getEndpointId.ts +20 -0
- package/src/providers/pinpoint/utils/getEventBuffer.ts +60 -0
- package/src/providers/pinpoint/utils/index.ts +6 -0
- package/src/server.ts +4 -0
- package/src/singleton/Amplify.ts +121 -0
- package/src/singleton/Analytics/types.ts +6 -0
- package/src/singleton/Auth/index.ts +7 -5
- package/src/singleton/Auth/types.ts +38 -6
- package/src/singleton/Auth/utils/index.ts +27 -1
- package/src/singleton/Storage/types.ts +6 -3
- package/src/singleton/apis/fetchAuthSession.ts +12 -0
- package/src/singleton/apis/internal/fetchAuthSession.ts +12 -0
- package/src/singleton/apis/server/fetchAuthSession.ts +16 -0
- package/src/singleton/index.ts +2 -128
- package/src/singleton/types.ts +4 -4
- package/src/types/core.ts +58 -0
- package/src/types/errors.ts +21 -0
- package/src/types/index.ts +5 -1
- package/src/types/logging.ts +24 -0
- package/src/types/storage.ts +19 -0
- package/lib/Hub.js +0 -220
- package/lib/Providers/AWSCloudWatchProvider.d.ts +0 -34
- package/lib/Providers/AWSCloudWatchProvider.js +0 -619
- package/lib/Providers/index.d.ts +0 -1
- package/lib/Providers/index.js +0 -7
- package/lib/constants.d.ts +0 -9
- package/lib/constants.js +0 -22
- package/lib/types/types.d.ts +0 -76
- package/lib-esm/Hub.js +0 -217
- package/lib-esm/Providers/AWSCloudWatchProvider.d.ts +0 -34
- package/lib-esm/Providers/AWSCloudWatchProvider.js +0 -616
- package/lib-esm/Providers/index.d.ts +0 -1
- package/lib-esm/constants.d.ts +0 -9
- package/lib-esm/constants.js +0 -19
- package/lib-esm/types/types.d.ts +0 -76
- package/src/Hub.ts +0 -236
- package/src/Providers/AWSCloudWatchProvider.ts +0 -540
- package/src/constants.ts +0 -31
- package/src/types/types.ts +0 -104
- /package/lib/{types/types.js → Hub/types/AuthTypes.js} +0 -0
- /package/lib/{Errors.js → Util/Errors.js} +0 -0
- /package/lib/{JS.d.ts → Util/JS.d.ts} +0 -0
- /package/lib/{JS.js → Util/JS.js} +0 -0
- /package/lib-esm/{types/types.js → Hub/types/AuthTypes.js} +0 -0
- /package/lib-esm/{Errors.js → Util/Errors.js} +0 -0
- /package/lib-esm/{JS.d.ts → Util/JS.d.ts} +0 -0
- /package/lib-esm/{JS.js → Util/JS.js} +0 -0
- /package/src/{JS.ts → Util/JS.ts} +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
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
|
+
import { Cache } from '../../..';
|
|
40
|
+
import { getCacheKey } from './getCacheKey';
|
|
41
|
+
/**
|
|
42
|
+
* Writes an endpoint id to a long-lived cache.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export var cacheEndpointId = function (appId, category, endpointId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
+
var cacheKey, ttl, expiration;
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
cacheKey = getCacheKey(appId, category);
|
|
50
|
+
ttl = 1000 * 60 * 60 * 24 * 365 * 100;
|
|
51
|
+
expiration = new Date().getTime() + ttl;
|
|
52
|
+
return [2 /*return*/, Cache.setItem(cacheKey, endpointId, {
|
|
53
|
+
expires: expiration,
|
|
54
|
+
priority: 1,
|
|
55
|
+
})];
|
|
56
|
+
});
|
|
57
|
+
}); };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Default buffer constants
|
|
4
|
+
export var BUFFER_SIZE = 1000;
|
|
5
|
+
export var FLUSH_SIZE = 100;
|
|
6
|
+
export var FLUSH_INTERVAL = 5 * 1000; // 5s
|
|
7
|
+
export var RESEND_LIMIT = 5;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
var PROVIDER_NAME = 'pinpoint';
|
|
4
|
+
/**
|
|
5
|
+
* Returns a unique cache key for a particular category/appId combination.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export var getCacheKey = function (appId, category) { return "".concat(category, ":").concat(PROVIDER_NAME, ":").concat(appId); };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
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
|
+
import { Cache } from '../../..';
|
|
40
|
+
import { getCacheKey } from './getCacheKey';
|
|
41
|
+
/**
|
|
42
|
+
* Returns an endpoint id from cache or `undefined` if not found.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export var getEndpointId = function (appId, category) { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
+
var cacheKey, cachedEndpointId;
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
switch (_a.label) {
|
|
50
|
+
case 0:
|
|
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
|
+
}); };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EventBufferConfig } from '../types/buffer';
|
|
2
|
+
import { PinpointEventBuffer } from './PinpointEventBuffer';
|
|
3
|
+
/**
|
|
4
|
+
* Returns a PinpointEventBuffer instance for the specified region & app ID, creating one if it does not yet exist.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const getEventBuffer: ({ appId, bufferSize, credentials, flushInterval, flushSize, identityId, region, resendLimit, userAgentValue }: EventBufferConfig) => PinpointEventBuffer;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { PinpointEventBuffer } from './PinpointEventBuffer';
|
|
4
|
+
import { BUFFER_SIZE, FLUSH_INTERVAL, FLUSH_SIZE, RESEND_LIMIT } from './constants';
|
|
5
|
+
// Map of buffers by region -> appId
|
|
6
|
+
var eventBufferMap = {};
|
|
7
|
+
/**
|
|
8
|
+
* Returns a PinpointEventBuffer instance for the specified region & app ID, creating one if it does not yet exist.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export var getEventBuffer = function (_a) {
|
|
13
|
+
var _b;
|
|
14
|
+
var appId = _a.appId, _c = _a.bufferSize, bufferSize = _c === void 0 ? BUFFER_SIZE : _c, credentials = _a.credentials, _d = _a.flushInterval, flushInterval = _d === void 0 ? FLUSH_INTERVAL : _d, _e = _a.flushSize, flushSize = _e === void 0 ? FLUSH_SIZE : _e, identityId = _a.identityId, region = _a.region, _f = _a.resendLimit, resendLimit = _f === void 0 ? RESEND_LIMIT : _f, userAgentValue = _a.userAgentValue;
|
|
15
|
+
if ((_b = eventBufferMap[region]) === null || _b === void 0 ? void 0 : _b[appId]) {
|
|
16
|
+
var buffer_1 = eventBufferMap[region][appId];
|
|
17
|
+
/*
|
|
18
|
+
If the identity has changed flush out the buffer and create a new instance. The old instance will be garbage
|
|
19
|
+
collected.
|
|
20
|
+
*/
|
|
21
|
+
if (buffer_1.identityHasChanged(identityId)) {
|
|
22
|
+
buffer_1.flush();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return buffer_1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
var buffer = new PinpointEventBuffer({
|
|
29
|
+
appId: appId,
|
|
30
|
+
bufferSize: bufferSize,
|
|
31
|
+
credentials: credentials,
|
|
32
|
+
flushInterval: flushInterval,
|
|
33
|
+
flushSize: flushSize,
|
|
34
|
+
identityId: identityId,
|
|
35
|
+
region: region,
|
|
36
|
+
resendLimit: resendLimit,
|
|
37
|
+
userAgentValue: userAgentValue
|
|
38
|
+
});
|
|
39
|
+
if (!eventBufferMap[region]) {
|
|
40
|
+
eventBufferMap[region] = {};
|
|
41
|
+
}
|
|
42
|
+
eventBufferMap[region][appId] = buffer;
|
|
43
|
+
return buffer;
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { fetchAuthSession } from './singleton/apis/server/fetchAuthSession';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AuthClass } from './Auth';
|
|
2
|
+
import { LibraryOptions, ResourcesConfig } from './types';
|
|
3
|
+
export declare class AmplifyClass {
|
|
4
|
+
resourcesConfig: ResourcesConfig;
|
|
5
|
+
libraryOptions: LibraryOptions;
|
|
6
|
+
/**
|
|
7
|
+
* Cross-category Auth utilities.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
readonly Auth: AuthClass;
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Configures Amplify for use with your back-end resources.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* `configure` can be used to specify additional library options where available for supported categories.
|
|
18
|
+
*
|
|
19
|
+
* @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
|
|
20
|
+
* @param libraryOptions - Additional options for customizing the behavior of the library.
|
|
21
|
+
*/
|
|
22
|
+
configure(resourcesConfig: ResourcesConfig, libraryOptions?: LibraryOptions): void;
|
|
23
|
+
/**
|
|
24
|
+
* Provides access to the current back-end resource configuration for the Library.
|
|
25
|
+
*
|
|
26
|
+
* @returns Returns the current back-end resource configuration.
|
|
27
|
+
*/
|
|
28
|
+
getConfig(): ResourcesConfig;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The `Amplify` utility is used to configure the library.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* `Amplify` is responsible for orchestrating cross-category communication within the library.
|
|
35
|
+
*/
|
|
36
|
+
export declare const Amplify: AmplifyClass;
|
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
24
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
25
|
+
import { AuthClass } from './Auth';
|
|
26
|
+
import { Hub, AMPLIFY_SYMBOL } from '../Hub';
|
|
27
|
+
// TODO(v6): add default AuthTokenStore for each platform
|
|
28
|
+
var AmplifyClass = /** @class */ (function () {
|
|
29
|
+
function AmplifyClass() {
|
|
30
|
+
this.resourcesConfig = {};
|
|
31
|
+
this.Auth = new AuthClass();
|
|
32
|
+
// TODO(v6): add default providers for getting started
|
|
33
|
+
this.libraryOptions = {};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Configures Amplify for use with your back-end resources.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* `configure` can be used to specify additional library options where available for supported categories.
|
|
40
|
+
*
|
|
41
|
+
* @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
|
|
42
|
+
* @param libraryOptions - Additional options for customizing the behavior of the library.
|
|
43
|
+
*/
|
|
44
|
+
AmplifyClass.prototype.configure = function (resourcesConfig, libraryOptions) {
|
|
45
|
+
if (libraryOptions === void 0) { libraryOptions = {}; }
|
|
46
|
+
this.resourcesConfig = mergeResourceConfig(this.resourcesConfig, resourcesConfig);
|
|
47
|
+
this.libraryOptions = mergeLibraryOptions(this.libraryOptions, libraryOptions);
|
|
48
|
+
this.Auth.configure(this.resourcesConfig.Auth, this.libraryOptions.Auth);
|
|
49
|
+
Hub.dispatch('core', {
|
|
50
|
+
event: 'configure',
|
|
51
|
+
data: resourcesConfig,
|
|
52
|
+
}, 'Configure', AMPLIFY_SYMBOL);
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Provides access to the current back-end resource configuration for the Library.
|
|
56
|
+
*
|
|
57
|
+
* @returns Returns the current back-end resource configuration.
|
|
58
|
+
*/
|
|
59
|
+
AmplifyClass.prototype.getConfig = function () {
|
|
60
|
+
return JSON.parse(JSON.stringify(this.resourcesConfig));
|
|
61
|
+
};
|
|
62
|
+
return AmplifyClass;
|
|
63
|
+
}());
|
|
64
|
+
export { AmplifyClass };
|
|
65
|
+
/**
|
|
66
|
+
* The `Amplify` utility is used to configure the library.
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* `Amplify` is responsible for orchestrating cross-category communication within the library.
|
|
70
|
+
*/
|
|
71
|
+
export var Amplify = new AmplifyClass();
|
|
72
|
+
// TODO(v6): validate until which level this will nested, during Amplify.configure API review.
|
|
73
|
+
function mergeResourceConfig(existingConfig, newConfig) {
|
|
74
|
+
var e_1, _a, e_2, _b;
|
|
75
|
+
var resultConfig = {};
|
|
76
|
+
try {
|
|
77
|
+
for (var _c = __values(Object.keys(existingConfig)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
78
|
+
var category = _d.value;
|
|
79
|
+
resultConfig[category] = existingConfig[category];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
83
|
+
finally {
|
|
84
|
+
try {
|
|
85
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
86
|
+
}
|
|
87
|
+
finally { if (e_1) throw e_1.error; }
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
for (var _e = __values(Object.keys(newConfig).filter(function (key) { return key !== 'ssr'; })), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
91
|
+
var key = _f.value;
|
|
92
|
+
resultConfig[key] = __assign(__assign({}, resultConfig[key]), newConfig[key]);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
96
|
+
finally {
|
|
97
|
+
try {
|
|
98
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
99
|
+
}
|
|
100
|
+
finally { if (e_2) throw e_2.error; }
|
|
101
|
+
}
|
|
102
|
+
resultConfig.ssr = newConfig.ssr;
|
|
103
|
+
return resultConfig;
|
|
104
|
+
}
|
|
105
|
+
function mergeLibraryOptions(existingConfig, newConfig) {
|
|
106
|
+
var e_3, _a, e_4, _b;
|
|
107
|
+
var resultConfig = {};
|
|
108
|
+
try {
|
|
109
|
+
for (var _c = __values(Object.keys(existingConfig)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
110
|
+
var category = _d.value;
|
|
111
|
+
resultConfig[category] = existingConfig[category];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
115
|
+
finally {
|
|
116
|
+
try {
|
|
117
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
118
|
+
}
|
|
119
|
+
finally { if (e_3) throw e_3.error; }
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
for (var _e = __values(Object.keys(newConfig)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
123
|
+
var category = _f.value;
|
|
124
|
+
resultConfig[category] = __assign(__assign({}, resultConfig[category]), newConfig[category]);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
128
|
+
finally {
|
|
129
|
+
try {
|
|
130
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
131
|
+
}
|
|
132
|
+
finally { if (e_4) throw e_4.error; }
|
|
133
|
+
}
|
|
134
|
+
return resultConfig;
|
|
135
|
+
}
|
|
@@ -38,7 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
// SPDX-License-Identifier: Apache-2.0
|
|
39
39
|
import { Observable } from 'rxjs';
|
|
40
40
|
import { asserts } from '../../Util/errors/AssertError';
|
|
41
|
-
import { AUTH_CONFING_EXCEPTION } from '../../
|
|
41
|
+
import { AUTH_CONFING_EXCEPTION } from '../../Util/Constants';
|
|
42
42
|
export function isTokenExpired(_a) {
|
|
43
43
|
var expiresAt = _a.expiresAt, clockDrift = _a.clockDrift;
|
|
44
44
|
var currentTime = Date.now();
|
|
@@ -69,16 +69,17 @@ var AuthClass = /** @class */ (function () {
|
|
|
69
69
|
var tokens, credentialsAndIdentityId;
|
|
70
70
|
return __generator(this, function (_h) {
|
|
71
71
|
switch (_h.label) {
|
|
72
|
-
case 0:
|
|
73
|
-
case 1:
|
|
74
|
-
// Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available
|
|
75
|
-
tokens =
|
|
76
|
-
(_c = (_h.sent())) !== null && _c !== void 0 ? _c : undefined;
|
|
72
|
+
case 0:
|
|
77
73
|
asserts(!!this.authConfig, {
|
|
78
74
|
name: AUTH_CONFING_EXCEPTION,
|
|
79
75
|
message: 'AuthConfig is required',
|
|
80
76
|
recoverySuggestion: 'call Amplify.configure in your app with a valid AuthConfig',
|
|
81
77
|
});
|
|
78
|
+
return [4 /*yield*/, ((_b = (_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.tokenProvider) === null || _b === void 0 ? void 0 : _b.getTokens(options))];
|
|
79
|
+
case 1:
|
|
80
|
+
// Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available
|
|
81
|
+
tokens =
|
|
82
|
+
(_c = (_h.sent())) !== null && _c !== void 0 ? _c : undefined;
|
|
82
83
|
if (!tokens) return [3 /*break*/, 3];
|
|
83
84
|
return [4 /*yield*/, ((_e = (_d = this.authOptions) === null || _d === void 0 ? void 0 : _d.credentialsProvider) === null || _e === void 0 ? void 0 : _e.getCredentialsAndIdentityId({
|
|
84
85
|
authConfig: this.authConfig,
|
|
@@ -91,11 +92,13 @@ var AuthClass = /** @class */ (function () {
|
|
|
91
92
|
credentialsAndIdentityId =
|
|
92
93
|
_h.sent();
|
|
93
94
|
return [3 /*break*/, 5];
|
|
94
|
-
case 3:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
case 3:
|
|
96
|
+
if (!!this.authConfig.isMandatorySignInEnabled) return [3 /*break*/, 5];
|
|
97
|
+
return [4 /*yield*/, ((_g = (_f = this.authOptions) === null || _f === void 0 ? void 0 : _f.credentialsProvider) === null || _g === void 0 ? void 0 : _g.getCredentialsAndIdentityId({
|
|
98
|
+
authConfig: this.authConfig,
|
|
99
|
+
authenticated: false,
|
|
100
|
+
forceRefresh: options.forceRefresh,
|
|
101
|
+
}))];
|
|
99
102
|
case 4:
|
|
100
103
|
// getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)
|
|
101
104
|
credentialsAndIdentityId =
|
|
@@ -37,7 +37,7 @@ export interface AWSCredentialsAndIdentityIdProvider {
|
|
|
37
37
|
clearCredentials: () => void;
|
|
38
38
|
}
|
|
39
39
|
export type TokenProvider = {
|
|
40
|
-
getTokens: ({ forceRefresh, }
|
|
40
|
+
getTokens: ({ forceRefresh, }?: {
|
|
41
41
|
forceRefresh?: boolean;
|
|
42
42
|
}) => Promise<AuthTokens | null>;
|
|
43
43
|
};
|
|
@@ -48,7 +48,10 @@ export type AuthTokens = {
|
|
|
48
48
|
idToken?: JWT;
|
|
49
49
|
accessToken: JWT;
|
|
50
50
|
};
|
|
51
|
-
export type AuthConfig = IdentityPoolConfig | UserPoolConfig | UserPoolConfigAndIdentityPoolConfig
|
|
51
|
+
export type AuthConfig = StrictUnion<IdentityPoolConfig | UserPoolConfig | UserPoolConfigWithOAuth | UserPoolConfigAndIdentityPoolConfig | UserPoolConfigAndIdentityPoolConfigWithOAuth>;
|
|
52
|
+
type UnionKeys<T> = T extends T ? keyof T : never;
|
|
53
|
+
type StrictUnionHelper<T, TAll> = T extends any ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>> : never;
|
|
54
|
+
type StrictUnion<T> = StrictUnionHelper<T, T>;
|
|
52
55
|
export type IdentityPoolConfig = {
|
|
53
56
|
identityPoolId: string;
|
|
54
57
|
userPoolWebClientId?: never;
|
|
@@ -62,6 +65,20 @@ export type UserPoolConfig = {
|
|
|
62
65
|
identityPoolId?: never;
|
|
63
66
|
clientMetadata?: Record<string, string>;
|
|
64
67
|
};
|
|
68
|
+
export type UserPoolConfigWithOAuth = {
|
|
69
|
+
userPoolWebClientId: string;
|
|
70
|
+
userPoolId: string;
|
|
71
|
+
identityPoolId?: never;
|
|
72
|
+
clientMetadata?: Record<string, string>;
|
|
73
|
+
oauth: OAuthConfig;
|
|
74
|
+
};
|
|
75
|
+
export type OAuthConfig = {
|
|
76
|
+
domain: string;
|
|
77
|
+
scopes: Array<string>;
|
|
78
|
+
redirectSignIn: string;
|
|
79
|
+
redirectSignOut: string;
|
|
80
|
+
responseType: string;
|
|
81
|
+
};
|
|
65
82
|
export type UserPoolConfigAndIdentityPoolConfig = {
|
|
66
83
|
userPoolWebClientId: string;
|
|
67
84
|
userPoolId: string;
|
|
@@ -69,12 +86,20 @@ export type UserPoolConfigAndIdentityPoolConfig = {
|
|
|
69
86
|
clientMetadata?: Record<string, string>;
|
|
70
87
|
isMandatorySignInEnabled?: boolean;
|
|
71
88
|
};
|
|
89
|
+
export type UserPoolConfigAndIdentityPoolConfigWithOAuth = {
|
|
90
|
+
userPoolWebClientId: string;
|
|
91
|
+
userPoolId: string;
|
|
92
|
+
identityPoolId: string;
|
|
93
|
+
clientMetadata?: Record<string, string>;
|
|
94
|
+
isMandatorySignInEnabled?: boolean;
|
|
95
|
+
oauth: OAuthConfig;
|
|
96
|
+
};
|
|
72
97
|
export type GetCredentialsOptions = GetCredentialsAuthenticatedUser | GetCredentialsUnauthenticatedUser;
|
|
73
98
|
type GetCredentialsAuthenticatedUser = {
|
|
74
99
|
authenticated: true;
|
|
75
100
|
forceRefresh?: boolean;
|
|
76
101
|
authConfig: AuthConfig;
|
|
77
|
-
tokens
|
|
102
|
+
tokens: AuthTokens;
|
|
78
103
|
};
|
|
79
104
|
type GetCredentialsUnauthenticatedUser = {
|
|
80
105
|
authenticated: false;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AuthConfig, IdentityPoolConfig, JWT, UserPoolConfig, UserPoolConfigAndIdentityPoolConfig } from '../types';
|
|
2
|
-
export declare function assertTokenProviderConfig(authConfig?: AuthConfig): asserts authConfig is UserPoolConfig;
|
|
1
|
+
import { AuthConfig, IdentityPoolConfig, JWT, UserPoolConfig, UserPoolConfigAndIdentityPoolConfig, UserPoolConfigAndIdentityPoolConfigWithOAuth, UserPoolConfigWithOAuth } from '../types';
|
|
2
|
+
export declare function assertTokenProviderConfig(authConfig?: AuthConfig): asserts authConfig is UserPoolConfigAndIdentityPoolConfigWithOAuth | UserPoolConfigWithOAuth | UserPoolConfigAndIdentityPoolConfig | UserPoolConfig;
|
|
3
|
+
export declare function assertOAuthConfig(authConfig?: AuthConfig): asserts authConfig is UserPoolConfigAndIdentityPoolConfigWithOAuth | UserPoolConfigWithOAuth;
|
|
3
4
|
export declare function assertIdentityPooIdConfig(authConfig: AuthConfig): asserts authConfig is IdentityPoolConfig;
|
|
4
5
|
export declare function assertUserPoolAndIdentityPooConfig(authConfig: AuthConfig): asserts authConfig is UserPoolConfigAndIdentityPoolConfig;
|
|
5
6
|
export declare function decodeJWT(token: string): JWT;
|
|
@@ -10,6 +10,19 @@ export function assertTokenProviderConfig(authConfig) {
|
|
|
10
10
|
recoverySuggestion: 'Make sure to call Amplify.configure in your app',
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
+
export function assertOAuthConfig(authConfig) {
|
|
14
|
+
var _a, _b, _c, _d;
|
|
15
|
+
assertTokenProviderConfig(authConfig);
|
|
16
|
+
var validOAuthConfig = !!((_a = authConfig.oauth) === null || _a === void 0 ? void 0 : _a.domain) &&
|
|
17
|
+
!!((_b = authConfig.oauth) === null || _b === void 0 ? void 0 : _b.redirectSignOut) &&
|
|
18
|
+
!!((_c = authConfig.oauth) === null || _c === void 0 ? void 0 : _c.redirectSignIn) &&
|
|
19
|
+
!!((_d = authConfig.oauth) === null || _d === void 0 ? void 0 : _d.responseType);
|
|
20
|
+
return asserts(validOAuthConfig, {
|
|
21
|
+
name: 'OAuthNotConfigureException',
|
|
22
|
+
message: 'oauth param not configured',
|
|
23
|
+
recoverySuggestion: 'Make sure to call Amplify.configure with oauth parameter in your app',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
13
26
|
export function assertIdentityPooIdConfig(authConfig) {
|
|
14
27
|
var validConfig = !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.identityPoolId);
|
|
15
28
|
return asserts(validConfig, {
|
|
@@ -2,13 +2,17 @@ export type StorageAccessLevel = 'guest' | 'protected' | 'private';
|
|
|
2
2
|
export interface StorageConfig {
|
|
3
3
|
bucket?: string;
|
|
4
4
|
region?: string;
|
|
5
|
+
dangerouslyConnectToHttpEndpointForTesting?: string;
|
|
5
6
|
}
|
|
6
7
|
type StoragePrefixResolver = (params: {
|
|
7
8
|
accessLevel: StorageAccessLevel;
|
|
8
9
|
targetIdentityId?: string;
|
|
9
10
|
}) => Promise<string>;
|
|
10
11
|
export interface LibraryStorageOptions {
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
AWSS3: {
|
|
13
|
+
prefixResolver?: StoragePrefixResolver;
|
|
14
|
+
defaultAccessLevel?: StorageAccessLevel;
|
|
15
|
+
isObjectLockEnabled?: boolean;
|
|
16
|
+
};
|
|
13
17
|
}
|
|
14
18
|
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { fetchAuthSession as fetchAuthSessionInternal } from './internal/fetchAuthSession';
|
|
4
|
+
import { Amplify } from '../Amplify';
|
|
5
|
+
export var fetchAuthSession = function (options) {
|
|
6
|
+
return fetchAuthSessionInternal(Amplify, options);
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { getAmplifyServerContext } from '../../../adapterCore';
|
|
4
|
+
import { fetchAuthSession as fetchAuthSessionInternal } from '../internal/fetchAuthSession';
|
|
5
|
+
export var fetchAuthSession = function (contextSpec, options) {
|
|
6
|
+
return fetchAuthSessionInternal(getAmplifyServerContext(contextSpec).amplify, options);
|
|
7
|
+
};
|