@aws-amplify/core 6.0.1-console-preview.5f040a2.0 → 6.0.1-console-preview.a1c533e.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Hub/index.d.ts +7 -0
- package/lib/Hub/index.js +8 -1
- package/lib/Platform/customUserAgent.d.ts +16 -0
- package/lib/Platform/customUserAgent.js +70 -0
- package/lib/Platform/index.js +10 -1
- package/lib/Platform/types.d.ts +31 -0
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/libraryUtils.d.ts +4 -3
- package/lib/libraryUtils.js +6 -4
- package/lib/parseAWSExports.js +70 -14
- package/lib/singleton/Auth/types.d.ts +27 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/Hub/index.d.ts +7 -0
- package/lib-esm/Hub/index.js +7 -0
- package/lib-esm/Platform/customUserAgent.d.ts +16 -0
- package/lib-esm/Platform/customUserAgent.js +65 -0
- package/lib-esm/Platform/index.js +10 -1
- package/lib-esm/Platform/types.d.ts +31 -0
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/libraryUtils.d.ts +4 -3
- package/lib-esm/libraryUtils.js +3 -2
- package/lib-esm/parseAWSExports.js +70 -14
- package/lib-esm/singleton/Auth/types.d.ts +27 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/Hub/index.ts +8 -0
- package/src/Platform/customUserAgent.ts +75 -0
- package/src/Platform/index.ts +14 -1
- package/src/Platform/types.ts +44 -1
- package/src/Platform/version.ts +1 -1
- package/src/libraryUtils.ts +13 -8
- package/src/parseAWSExports.ts +54 -13
- package/src/singleton/Auth/types.ts +49 -0
package/lib/Hub/index.d.ts
CHANGED
|
@@ -37,3 +37,10 @@ export declare class HubClass {
|
|
|
37
37
|
private _toListeners;
|
|
38
38
|
}
|
|
39
39
|
export declare const Hub: HubClass;
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*
|
|
43
|
+
* Internal hub used for core Amplify functionality. Not intended for use outside of Amplify.
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
export declare const HubInternal: HubClass;
|
package/lib/Hub/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
38
38
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
39
39
|
};
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.Hub = exports.HubClass = exports.AMPLIFY_SYMBOL = void 0;
|
|
41
|
+
exports.HubInternal = exports.Hub = exports.HubClass = exports.AMPLIFY_SYMBOL = void 0;
|
|
42
42
|
var Logger_1 = require("../Logger");
|
|
43
43
|
var constants_1 = require("../constants");
|
|
44
44
|
var errors_1 = require("../errors");
|
|
@@ -149,3 +149,10 @@ exports.HubClass = HubClass;
|
|
|
149
149
|
pseudo Singleton for the main messaging bus, however you can still create
|
|
150
150
|
your own instance of HubClass() for a separate "private bus" of events.*/
|
|
151
151
|
exports.Hub = new HubClass('__default__');
|
|
152
|
+
/**
|
|
153
|
+
* @internal
|
|
154
|
+
*
|
|
155
|
+
* Internal hub used for core Amplify functionality. Not intended for use outside of Amplify.
|
|
156
|
+
*
|
|
157
|
+
*/
|
|
158
|
+
exports.HubInternal = new HubClass('internal-hub');
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AdditionalDetails, SetCustomUserAgentInput } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Sets custom user agent state which will be appended to applicable requests. Returns a function that can be used to
|
|
4
|
+
* clean up any custom state set with this API.
|
|
5
|
+
*
|
|
6
|
+
* @note
|
|
7
|
+
* This API operates globally. Calling this API multiple times will result in the most recently set values for a
|
|
8
|
+
* particular API being used.
|
|
9
|
+
*
|
|
10
|
+
* @note
|
|
11
|
+
* This utility IS NOT compatible with SSR.
|
|
12
|
+
*
|
|
13
|
+
* @param input - SetCustomUserAgentInput that defines custom state to apply to the specified APIs.
|
|
14
|
+
*/
|
|
15
|
+
export declare const setCustomUserAgent: (input: SetCustomUserAgentInput) => (() => void);
|
|
16
|
+
export declare const getCustomUserAgent: (category: string, api: string) => AdditionalDetails | undefined;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
var __assign = (this && this.__assign) || function () {
|
|
5
|
+
__assign = Object.assign || function(t) {
|
|
6
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
7
|
+
s = arguments[i];
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
9
|
+
t[p] = s[p];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
return __assign.apply(this, arguments);
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.getCustomUserAgent = exports.setCustomUserAgent = void 0;
|
|
17
|
+
// Maintains custom user-agent state set by external consumers.
|
|
18
|
+
var customUserAgentState = {};
|
|
19
|
+
/**
|
|
20
|
+
* Sets custom user agent state which will be appended to applicable requests. Returns a function that can be used to
|
|
21
|
+
* clean up any custom state set with this API.
|
|
22
|
+
*
|
|
23
|
+
* @note
|
|
24
|
+
* This API operates globally. Calling this API multiple times will result in the most recently set values for a
|
|
25
|
+
* particular API being used.
|
|
26
|
+
*
|
|
27
|
+
* @note
|
|
28
|
+
* This utility IS NOT compatible with SSR.
|
|
29
|
+
*
|
|
30
|
+
* @param input - SetCustomUserAgentInput that defines custom state to apply to the specified APIs.
|
|
31
|
+
*/
|
|
32
|
+
var setCustomUserAgent = function (input) {
|
|
33
|
+
var _a;
|
|
34
|
+
// Save custom user-agent state & increment reference counter
|
|
35
|
+
// TODO Remove `any` when we upgrade to TypeScript 5.2, see: https://github.com/microsoft/TypeScript/issues/44373
|
|
36
|
+
customUserAgentState[input.category] = input.apis.reduce(function (acc, api) {
|
|
37
|
+
var _a;
|
|
38
|
+
var _b;
|
|
39
|
+
return (__assign(__assign({}, acc), (_a = {}, _a[api] = {
|
|
40
|
+
refCount: ((_b = acc[api]) === null || _b === void 0 ? void 0 : _b.refCount) ? acc[api].refCount + 1 : 1,
|
|
41
|
+
additionalDetails: input.additionalDetails,
|
|
42
|
+
}, _a)));
|
|
43
|
+
}, (_a = customUserAgentState[input.category]) !== null && _a !== void 0 ? _a : {});
|
|
44
|
+
// Callback that cleans up state for APIs recorded by this call
|
|
45
|
+
var cleanUpCallbackCalled = false;
|
|
46
|
+
var cleanUpCallback = function () {
|
|
47
|
+
// Only allow the cleanup callback to be called once
|
|
48
|
+
if (cleanUpCallbackCalled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
cleanUpCallbackCalled = true;
|
|
52
|
+
input.apis.forEach(function (api) {
|
|
53
|
+
var apiRefCount = customUserAgentState[input.category][api].refCount;
|
|
54
|
+
if (apiRefCount > 1) {
|
|
55
|
+
customUserAgentState[input.category][api].refCount = apiRefCount - 1;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
delete customUserAgentState[input.category][api];
|
|
59
|
+
// Clean up category if no more APIs set
|
|
60
|
+
if (!Object.keys(customUserAgentState[input.category]).length) {
|
|
61
|
+
delete customUserAgentState[input.category];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
return cleanUpCallback;
|
|
67
|
+
};
|
|
68
|
+
exports.setCustomUserAgent = setCustomUserAgent;
|
|
69
|
+
var getCustomUserAgent = function (category, api) { var _a, _b; return (_b = (_a = customUserAgentState[category]) === null || _a === void 0 ? void 0 : _a[api]) === null || _b === void 0 ? void 0 : _b.additionalDetails; };
|
|
70
|
+
exports.getCustomUserAgent = getCustomUserAgent;
|
package/lib/Platform/index.js
CHANGED
|
@@ -22,6 +22,7 @@ exports.getAmplifyUserAgent = exports.getAmplifyUserAgentObject = exports.Platfo
|
|
|
22
22
|
var types_1 = require("./types");
|
|
23
23
|
var version_1 = require("./version");
|
|
24
24
|
var detectFramework_1 = require("./detectFramework");
|
|
25
|
+
var customUserAgent_1 = require("./customUserAgent");
|
|
25
26
|
var BASE_USER_AGENT = "aws-amplify";
|
|
26
27
|
var PlatformBuilder = /** @class */ (function () {
|
|
27
28
|
function PlatformBuilder() {
|
|
@@ -55,6 +56,14 @@ var getAmplifyUserAgentObject = function (_a) {
|
|
|
55
56
|
userAgent.push([category, action]);
|
|
56
57
|
}
|
|
57
58
|
userAgent.push(['framework', (0, detectFramework_1.detectFramework)()]);
|
|
59
|
+
if (category && action) {
|
|
60
|
+
var customState = (0, customUserAgent_1.getCustomUserAgent)(category, action);
|
|
61
|
+
if (customState) {
|
|
62
|
+
customState.forEach(function (state) {
|
|
63
|
+
userAgent.push(state);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
58
67
|
return userAgent;
|
|
59
68
|
};
|
|
60
69
|
exports.getAmplifyUserAgentObject = getAmplifyUserAgentObject;
|
|
@@ -63,7 +72,7 @@ var getAmplifyUserAgent = function (customUserAgentDetails) {
|
|
|
63
72
|
var userAgentString = userAgent
|
|
64
73
|
.map(function (_a) {
|
|
65
74
|
var _b = __read(_a, 2), agentKey = _b[0], agentValue = _b[1];
|
|
66
|
-
return "".concat(agentKey, "/").concat(agentValue);
|
|
75
|
+
return agentKey && agentValue ? "".concat(agentKey, "/").concat(agentValue) : agentKey;
|
|
67
76
|
})
|
|
68
77
|
.join(' ');
|
|
69
78
|
return userAgentString;
|
package/lib/Platform/types.d.ts
CHANGED
|
@@ -126,4 +126,35 @@ export type CustomUserAgentDetails = (CustomUserAgentDetailsBase & {
|
|
|
126
126
|
category?: never;
|
|
127
127
|
action?: never;
|
|
128
128
|
}) | UserAgentDetailsWithCategory<Category.API> | UserAgentDetailsWithCategory<Category.Auth> | UserAgentDetailsWithCategory<Category.Analytics> | UserAgentDetailsWithCategory<Category.DataStore> | UserAgentDetailsWithCategory<Category.Geo> | UserAgentDetailsWithCategory<Category.Interactions> | UserAgentDetailsWithCategory<Category.InAppMessaging> | UserAgentDetailsWithCategory<Category.Predictions> | UserAgentDetailsWithCategory<Category.PubSub> | UserAgentDetailsWithCategory<Category.PushNotification> | UserAgentDetailsWithCategory<Category.Storage>;
|
|
129
|
+
/**
|
|
130
|
+
* `refCount` tracks how many consumers have set state for a particular API to avoid it being cleared before all
|
|
131
|
+
* consumers are done using it.
|
|
132
|
+
*
|
|
133
|
+
* Category -> Action -> Custom State
|
|
134
|
+
*/
|
|
135
|
+
export type CategoryUserAgentStateMap = Record<string, {
|
|
136
|
+
refCount: number;
|
|
137
|
+
additionalDetails: AdditionalDetails;
|
|
138
|
+
}>;
|
|
139
|
+
export type CustomUserAgentStateMap = Record<string, CategoryUserAgentStateMap>;
|
|
140
|
+
export type AdditionalDetails = [string, string?][];
|
|
141
|
+
type StorageUserAgentInput = {
|
|
142
|
+
category: Category.Storage;
|
|
143
|
+
apis: StorageAction[];
|
|
144
|
+
};
|
|
145
|
+
type AuthUserAgentInput = {
|
|
146
|
+
category: Category.Auth;
|
|
147
|
+
apis: AuthAction[];
|
|
148
|
+
};
|
|
149
|
+
type InAppMessagingUserAgentInput = {
|
|
150
|
+
category: Category.InAppMessaging;
|
|
151
|
+
apis: InAppMessagingAction[];
|
|
152
|
+
};
|
|
153
|
+
type GeoUserAgentInput = {
|
|
154
|
+
category: Category.Geo;
|
|
155
|
+
apis: GeoAction[];
|
|
156
|
+
};
|
|
157
|
+
export type SetCustomUserAgentInput = (StorageUserAgentInput | AuthUserAgentInput | InAppMessagingUserAgentInput | GeoUserAgentInput) & {
|
|
158
|
+
additionalDetails: AdditionalDetails;
|
|
159
|
+
};
|
|
129
160
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.0.1-console-preview.
|
|
1
|
+
export declare const version = "6.0.1-console-preview.a1c533e.0+a1c533e";
|
package/lib/Platform/version.js
CHANGED
package/lib/libraryUtils.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export { generateRandomString, isBrowser, isNonRetryableError, isWebWorker, jitteredBackoff, jitteredExponentialRetry, NonRetryableError, retry, urlSafeDecode, urlSafeEncode, } from './utils';
|
|
2
2
|
export { parseAWSExports } from './parseAWSExports';
|
|
3
3
|
export { LegacyConfig } from './singleton/types';
|
|
4
|
-
export { JWT, StrictUnion, CognitoIdentityPoolConfig, JwtPayload, } from './singleton/Auth/types';
|
|
5
4
|
export { decodeJWT, assertTokenProviderConfig, assertIdentityPoolIdConfig, assertOAuthConfig, } from './singleton/Auth/utils';
|
|
6
5
|
export { isTokenExpired } from './singleton/Auth';
|
|
7
6
|
export { APIAuthMode, DocumentType } from './singleton/API/types';
|
|
8
7
|
export { Signer } from './Signer';
|
|
8
|
+
export { JWT, StrictUnion, CognitoIdentityPoolConfig, JwtPayload, AuthStandardAttributeKey, AuthVerifiableAttributeKey, } from './singleton/Auth/types';
|
|
9
9
|
export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
|
|
10
10
|
export { ClientDevice } from './ClientDevice';
|
|
11
11
|
export { Platform, getAmplifyUserAgentObject, getAmplifyUserAgent, } from './Platform';
|
|
12
|
-
export { ApiAction, AuthAction, AnalyticsAction, Category, CustomUserAgentDetails, DataStoreAction, Framework, GeoAction, InteractionsAction, InAppMessagingAction, PredictionsAction, PubSubAction, PushNotificationAction, StorageAction, } from './Platform/types';
|
|
12
|
+
export { ApiAction, AuthAction, AnalyticsAction, Category, CustomUserAgentDetails, DataStoreAction, Framework, GeoAction, InteractionsAction, InAppMessagingAction, PredictionsAction, PubSubAction, PushNotificationAction, StorageAction, SetCustomUserAgentInput, } from './Platform/types';
|
|
13
|
+
export { setCustomUserAgent } from './Platform/customUserAgent';
|
|
13
14
|
export { ServiceWorker } from './ServiceWorker';
|
|
14
15
|
export { BackgroundProcessManager } from './BackgroundProcessManager';
|
|
15
16
|
export { Mutex } from './Mutex';
|
|
@@ -21,4 +22,4 @@ export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
|
|
|
21
22
|
export { AMPLIFY_SYMBOL } from './Hub';
|
|
22
23
|
export { base64Decoder, base64Encoder } from './utils/convert';
|
|
23
24
|
export { getCrypto } from './utils/globalHelpers';
|
|
24
|
-
export {
|
|
25
|
+
export { HubInternal } from './Hub';
|
package/lib/libraryUtils.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
5
|
+
exports.base64Decoder = exports.AMPLIFY_SYMBOL = exports.fetchAuthSession = exports.USER_AGENT_HEADER = exports.INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER = exports.AmplifyErrorCode = exports.createAssertionFunction = exports.PlatformNotSupportedError = exports.AmplifyError = exports.Reachability = exports.Mutex = exports.BackgroundProcessManager = exports.ServiceWorker = exports.setCustomUserAgent = exports.StorageAction = exports.PushNotificationAction = exports.PubSubAction = exports.PredictionsAction = exports.InAppMessagingAction = exports.InteractionsAction = exports.GeoAction = exports.Framework = exports.DataStoreAction = exports.Category = exports.AnalyticsAction = exports.AuthAction = exports.ApiAction = exports.getAmplifyUserAgent = exports.getAmplifyUserAgentObject = exports.Platform = exports.ClientDevice = exports.Logger = exports.ConsoleLogger = exports.Signer = exports.isTokenExpired = exports.assertOAuthConfig = exports.assertIdentityPoolIdConfig = exports.assertTokenProviderConfig = exports.decodeJWT = exports.parseAWSExports = exports.urlSafeEncode = exports.urlSafeDecode = exports.retry = exports.NonRetryableError = exports.jitteredExponentialRetry = exports.jitteredBackoff = exports.isWebWorker = exports.isNonRetryableError = exports.isBrowser = exports.generateRandomString = void 0;
|
|
6
|
+
exports.HubInternal = exports.getCrypto = exports.base64Encoder = void 0;
|
|
7
7
|
/*
|
|
8
8
|
This file maps top-level exports from `@aws-amplify/core/internals/utils`. These are intended to be internal
|
|
9
9
|
utils for use throughout the library.
|
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "Signer", { enumerable: true, get: function () {
|
|
|
36
36
|
var Logger_1 = require("./Logger");
|
|
37
37
|
Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return Logger_1.ConsoleLogger; } });
|
|
38
38
|
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return Logger_1.ConsoleLogger; } });
|
|
39
|
-
// Platform &
|
|
39
|
+
// Platform & user-agent utilities
|
|
40
40
|
var ClientDevice_1 = require("./ClientDevice");
|
|
41
41
|
Object.defineProperty(exports, "ClientDevice", { enumerable: true, get: function () { return ClientDevice_1.ClientDevice; } });
|
|
42
42
|
var Platform_1 = require("./Platform");
|
|
@@ -57,6 +57,8 @@ Object.defineProperty(exports, "PredictionsAction", { enumerable: true, get: fun
|
|
|
57
57
|
Object.defineProperty(exports, "PubSubAction", { enumerable: true, get: function () { return types_1.PubSubAction; } });
|
|
58
58
|
Object.defineProperty(exports, "PushNotificationAction", { enumerable: true, get: function () { return types_1.PushNotificationAction; } });
|
|
59
59
|
Object.defineProperty(exports, "StorageAction", { enumerable: true, get: function () { return types_1.StorageAction; } });
|
|
60
|
+
var customUserAgent_1 = require("./Platform/customUserAgent");
|
|
61
|
+
Object.defineProperty(exports, "setCustomUserAgent", { enumerable: true, get: function () { return customUserAgent_1.setCustomUserAgent; } });
|
|
60
62
|
// Service worker
|
|
61
63
|
var ServiceWorker_1 = require("./ServiceWorker");
|
|
62
64
|
Object.defineProperty(exports, "ServiceWorker", { enumerable: true, get: function () { return ServiceWorker_1.ServiceWorker; } });
|
|
@@ -87,4 +89,4 @@ var globalHelpers_1 = require("./utils/globalHelpers");
|
|
|
87
89
|
Object.defineProperty(exports, "getCrypto", { enumerable: true, get: function () { return globalHelpers_1.getCrypto; } });
|
|
88
90
|
// Hub
|
|
89
91
|
var Hub_2 = require("./Hub");
|
|
90
|
-
Object.defineProperty(exports, "
|
|
92
|
+
Object.defineProperty(exports, "HubInternal", { enumerable: true, get: function () { return Hub_2.HubInternal; } });
|
package/lib/parseAWSExports.js
CHANGED
|
@@ -10,6 +10,31 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
|
17
|
+
try {
|
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
+
}
|
|
20
|
+
catch (error) { e = { error: error }; }
|
|
21
|
+
finally {
|
|
22
|
+
try {
|
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
+
}
|
|
25
|
+
finally { if (e) throw e.error; }
|
|
26
|
+
}
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
30
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
31
|
+
if (ar || !(i in from)) {
|
|
32
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
33
|
+
ar[i] = from[i];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
37
|
+
};
|
|
13
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
39
|
exports.parseAWSExports = void 0;
|
|
15
40
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
@@ -33,9 +58,9 @@ var authTypeMapping = {
|
|
|
33
58
|
* @returns A {@link ResourcesConfig} object.
|
|
34
59
|
*/
|
|
35
60
|
var parseAWSExports = function (config) {
|
|
36
|
-
var _a;
|
|
61
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
37
62
|
if (config === void 0) { config = {}; }
|
|
38
|
-
var aws_appsync_apiKey = config.aws_appsync_apiKey, aws_appsync_authenticationType = config.aws_appsync_authenticationType, aws_appsync_graphqlEndpoint = config.aws_appsync_graphqlEndpoint, aws_appsync_region = config.aws_appsync_region, aws_cognito_identity_pool_id = config.aws_cognito_identity_pool_id, aws_cognito_sign_up_verification_method = config.aws_cognito_sign_up_verification_method, aws_mandatory_sign_in = config.aws_mandatory_sign_in, aws_mobile_analytics_app_id = config.aws_mobile_analytics_app_id, aws_mobile_analytics_app_region = config.aws_mobile_analytics_app_region, aws_user_files_s3_bucket = config.aws_user_files_s3_bucket, aws_user_files_s3_bucket_region = config.aws_user_files_s3_bucket_region, aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing = config.aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing, aws_user_pools_id = config.aws_user_pools_id, aws_user_pools_web_client_id = config.aws_user_pools_web_client_id, geo = config.geo, oauth = config.oauth, aws_cloud_logic_custom = config.aws_cloud_logic_custom, Notifications = config.Notifications;
|
|
63
|
+
var aws_appsync_apiKey = config.aws_appsync_apiKey, aws_appsync_authenticationType = config.aws_appsync_authenticationType, aws_appsync_graphqlEndpoint = config.aws_appsync_graphqlEndpoint, aws_appsync_region = config.aws_appsync_region, aws_cognito_identity_pool_id = config.aws_cognito_identity_pool_id, aws_cognito_sign_up_verification_method = config.aws_cognito_sign_up_verification_method, aws_cognito_mfa_configuration = config.aws_cognito_mfa_configuration, aws_cognito_mfa_types = config.aws_cognito_mfa_types, aws_cognito_password_protection_settings = config.aws_cognito_password_protection_settings, aws_cognito_verification_mechanisms = config.aws_cognito_verification_mechanisms, aws_cognito_signup_attributes = config.aws_cognito_signup_attributes, aws_cognito_username_attributes = config.aws_cognito_username_attributes, aws_mandatory_sign_in = config.aws_mandatory_sign_in, aws_mobile_analytics_app_id = config.aws_mobile_analytics_app_id, aws_mobile_analytics_app_region = config.aws_mobile_analytics_app_region, aws_user_files_s3_bucket = config.aws_user_files_s3_bucket, aws_user_files_s3_bucket_region = config.aws_user_files_s3_bucket_region, aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing = config.aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing, aws_user_pools_id = config.aws_user_pools_id, aws_user_pools_web_client_id = config.aws_user_pools_web_client_id, geo = config.geo, oauth = config.oauth, aws_cloud_logic_custom = config.aws_cloud_logic_custom, Notifications = config.Notifications;
|
|
39
64
|
var amplifyConfig = {};
|
|
40
65
|
// Analytics
|
|
41
66
|
if (aws_mobile_analytics_app_id) {
|
|
@@ -49,7 +74,7 @@ var parseAWSExports = function (config) {
|
|
|
49
74
|
// Notifications
|
|
50
75
|
if (Notifications) {
|
|
51
76
|
if ((_a = Notifications.InAppMessaging) === null || _a === void 0 ? void 0 : _a.AWSPinpoint) {
|
|
52
|
-
var
|
|
77
|
+
var _p = Notifications.InAppMessaging.AWSPinpoint, appId = _p.appId, region = _p.region;
|
|
53
78
|
amplifyConfig.Notifications = {
|
|
54
79
|
InAppMessaging: {
|
|
55
80
|
Pinpoint: {
|
|
@@ -76,12 +101,45 @@ var parseAWSExports = function (config) {
|
|
|
76
101
|
};
|
|
77
102
|
}
|
|
78
103
|
// Auth
|
|
104
|
+
var mfaConfig = aws_cognito_mfa_configuration ? {
|
|
105
|
+
status: aws_cognito_mfa_configuration && aws_cognito_mfa_configuration.toLowerCase(),
|
|
106
|
+
totpEnabled: (_b = aws_cognito_mfa_types === null || aws_cognito_mfa_types === void 0 ? void 0 : aws_cognito_mfa_types.includes('TOTP')) !== null && _b !== void 0 ? _b : false,
|
|
107
|
+
smsEnabled: (_c = aws_cognito_mfa_types === null || aws_cognito_mfa_types === void 0 ? void 0 : aws_cognito_mfa_types.includes('SMS')) !== null && _c !== void 0 ? _c : false
|
|
108
|
+
} : undefined;
|
|
109
|
+
var passwordFormatConfig = aws_cognito_password_protection_settings ? {
|
|
110
|
+
minLength: aws_cognito_password_protection_settings.passwordPolicyMinLength,
|
|
111
|
+
requireLowercase: (_e = (_d = aws_cognito_password_protection_settings.passwordPolicyCharacters) === null || _d === void 0 ? void 0 : _d.includes('REQUIRES_LOWERCASE')) !== null && _e !== void 0 ? _e : false,
|
|
112
|
+
requireUppercase: (_g = (_f = aws_cognito_password_protection_settings.passwordPolicyCharacters) === null || _f === void 0 ? void 0 : _f.includes('REQUIRES_UPPERCASE')) !== null && _g !== void 0 ? _g : false,
|
|
113
|
+
requireNumbers: (_j = (_h = aws_cognito_password_protection_settings.passwordPolicyCharacters) === null || _h === void 0 ? void 0 : _h.includes('REQUIRES_NUMBERS')) !== null && _j !== void 0 ? _j : false,
|
|
114
|
+
requireSpecialCharacters: (_l = (_k = aws_cognito_password_protection_settings.passwordPolicyCharacters) === null || _k === void 0 ? void 0 : _k.includes('REQUIRES_SYMBOLS')) !== null && _l !== void 0 ? _l : false,
|
|
115
|
+
} : undefined;
|
|
116
|
+
var mergedUserAttributes = Array.from(new Set(__spreadArray(__spreadArray([], __read((aws_cognito_verification_mechanisms !== null && aws_cognito_verification_mechanisms !== void 0 ? aws_cognito_verification_mechanisms : [])), false), __read((aws_cognito_signup_attributes !== null && aws_cognito_signup_attributes !== void 0 ? aws_cognito_signup_attributes : [])), false)));
|
|
117
|
+
var userAttributesConfig = mergedUserAttributes.map(function (s) {
|
|
118
|
+
var _a;
|
|
119
|
+
return (_a = {},
|
|
120
|
+
_a[s.toLowerCase()] = {
|
|
121
|
+
required: true // All user attributes generated by the CLI will be required
|
|
122
|
+
},
|
|
123
|
+
_a);
|
|
124
|
+
});
|
|
125
|
+
var loginWithEmailEnabled = (_m = aws_cognito_username_attributes === null || aws_cognito_username_attributes === void 0 ? void 0 : aws_cognito_username_attributes.includes('EMAIL')) !== null && _m !== void 0 ? _m : false;
|
|
126
|
+
var loginWithPhoneEnabled = (_o = aws_cognito_username_attributes === null || aws_cognito_username_attributes === void 0 ? void 0 : aws_cognito_username_attributes.includes('PHONE_NUMBER')) !== null && _o !== void 0 ? _o : false;
|
|
79
127
|
if (aws_cognito_identity_pool_id || aws_user_pools_id) {
|
|
80
128
|
amplifyConfig.Auth = {
|
|
81
|
-
Cognito:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
129
|
+
Cognito: {
|
|
130
|
+
identityPoolId: aws_cognito_identity_pool_id,
|
|
131
|
+
allowGuestAccess: aws_mandatory_sign_in !== 'enable',
|
|
132
|
+
signUpVerificationMethod: aws_cognito_sign_up_verification_method,
|
|
133
|
+
userAttributes: userAttributesConfig,
|
|
134
|
+
userPoolClientId: aws_user_pools_web_client_id,
|
|
135
|
+
userPoolId: aws_user_pools_id,
|
|
136
|
+
mfa: mfaConfig,
|
|
137
|
+
passwordFormat: passwordFormatConfig,
|
|
138
|
+
loginWith: __assign({ username: (loginWithEmailEnabled || loginWithPhoneEnabled) ? false : true, email: loginWithEmailEnabled, phone: loginWithPhoneEnabled }, (oauth &&
|
|
139
|
+
Object.keys(oauth).length > 0 && {
|
|
140
|
+
oauth: getOAuthConfig(oauth),
|
|
141
|
+
})),
|
|
142
|
+
},
|
|
85
143
|
};
|
|
86
144
|
}
|
|
87
145
|
// Storage
|
|
@@ -120,12 +178,10 @@ var getRedirectUrl = function (redirectStr) {
|
|
|
120
178
|
var getOAuthConfig = function (_a) {
|
|
121
179
|
var domain = _a.domain, scope = _a.scope, redirectSignIn = _a.redirectSignIn, redirectSignOut = _a.redirectSignOut, responseType = _a.responseType;
|
|
122
180
|
return ({
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
responseType: responseType,
|
|
129
|
-
},
|
|
181
|
+
domain: domain,
|
|
182
|
+
scopes: scope,
|
|
183
|
+
redirectSignIn: getRedirectUrl(redirectSignIn),
|
|
184
|
+
redirectSignOut: getRedirectUrl(redirectSignOut),
|
|
185
|
+
responseType: responseType,
|
|
130
186
|
});
|
|
131
187
|
};
|
|
@@ -50,6 +50,11 @@ export type AuthTokens = {
|
|
|
50
50
|
idToken?: JWT;
|
|
51
51
|
accessToken: JWT;
|
|
52
52
|
};
|
|
53
|
+
export type AuthStandardAttributeKey = 'address' | 'birthdate' | 'email_verified' | 'family_name' | 'gender' | 'given_name' | 'locale' | 'middle_name' | 'name' | 'nickname' | 'phone_number_verified' | 'picture' | 'preferred_username' | 'profile' | 'sub' | 'updated_at' | 'website' | 'zoneinfo' | AuthVerifiableAttributeKey;
|
|
54
|
+
export type AuthVerifiableAttributeKey = 'email' | 'phone_number';
|
|
55
|
+
export type AuthConfigUserAttributes = Partial<Record<AuthStandardAttributeKey, {
|
|
56
|
+
required: boolean;
|
|
57
|
+
}>>;
|
|
53
58
|
export type AuthConfig = StrictUnion<AuthIdentityPoolConfig | AuthUserPoolConfig | AuthUserPoolAndIdentityPoolConfig>;
|
|
54
59
|
type UnionKeys<T> = T extends T ? keyof T : never;
|
|
55
60
|
type StrictUnionHelper<T, TAll> = T extends any ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>> : never;
|
|
@@ -59,6 +64,11 @@ export type AuthIdentityPoolConfig = {
|
|
|
59
64
|
userPoolClientId?: never;
|
|
60
65
|
userPoolId?: never;
|
|
61
66
|
loginWith?: never;
|
|
67
|
+
signUpVerificationMethod?: never;
|
|
68
|
+
userAttributes?: never;
|
|
69
|
+
mfa?: never;
|
|
70
|
+
passwordFormat?: never;
|
|
71
|
+
endpoint?: never;
|
|
62
72
|
};
|
|
63
73
|
};
|
|
64
74
|
export type CognitoIdentityPoolConfig = {
|
|
@@ -77,7 +87,24 @@ export type CognitoUserPoolConfig = {
|
|
|
77
87
|
signUpVerificationMethod?: 'code' | 'link';
|
|
78
88
|
loginWith?: {
|
|
79
89
|
oauth?: OAuthConfig;
|
|
90
|
+
username?: boolean;
|
|
91
|
+
email?: boolean;
|
|
92
|
+
phone?: boolean;
|
|
80
93
|
};
|
|
94
|
+
userAttributes?: AuthConfigUserAttributes;
|
|
95
|
+
mfa?: {
|
|
96
|
+
status?: 'on' | 'off' | 'optional';
|
|
97
|
+
totpEnabled?: boolean;
|
|
98
|
+
smsEnabled?: boolean;
|
|
99
|
+
};
|
|
100
|
+
passwordFormat?: {
|
|
101
|
+
minLength?: number;
|
|
102
|
+
requireLowercase?: boolean;
|
|
103
|
+
requireUppercase?: boolean;
|
|
104
|
+
requireNumbers?: boolean;
|
|
105
|
+
requireSpecialCharacters?: boolean;
|
|
106
|
+
};
|
|
107
|
+
endpoint?: string;
|
|
81
108
|
};
|
|
82
109
|
export type OAuthConfig = {
|
|
83
110
|
domain: string;
|