@aws-amplify/core 6.0.29-unstable.d0fdfa6.0 → 6.1.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/dist/cjs/Platform/version.js +1 -1
- package/dist/cjs/Platform/version.js.map +1 -1
- package/dist/cjs/libraryUtils.js +7 -2
- package/dist/cjs/libraryUtils.js.map +1 -1
- package/dist/cjs/parseAWSExports.js +8 -9
- package/dist/cjs/parseAWSExports.js.map +1 -1
- package/dist/cjs/parseAmplifyOutputs.js +215 -0
- package/dist/cjs/parseAmplifyOutputs.js.map +1 -0
- package/dist/cjs/singleton/Amplify.js +2 -8
- package/dist/cjs/singleton/Amplify.js.map +1 -1
- package/dist/cjs/singleton/AmplifyOutputs/types.js +6 -0
- package/dist/cjs/singleton/AmplifyOutputs/types.js.map +1 -0
- package/dist/cjs/utils/parseAmplifyConfig.js +27 -0
- package/dist/cjs/utils/parseAmplifyConfig.js.map +1 -0
- package/dist/esm/Platform/version.d.ts +1 -1
- package/dist/esm/Platform/version.mjs +1 -1
- package/dist/esm/Platform/version.mjs.map +1 -1
- package/dist/esm/libraryUtils.d.ts +3 -0
- package/dist/esm/libraryUtils.mjs +2 -0
- package/dist/esm/libraryUtils.mjs.map +1 -1
- package/dist/esm/parseAWSExports.mjs +8 -9
- package/dist/esm/parseAWSExports.mjs.map +1 -1
- package/dist/esm/parseAmplifyOutputs.d.ts +5 -0
- package/dist/esm/parseAmplifyOutputs.mjs +210 -0
- package/dist/esm/parseAmplifyOutputs.mjs.map +1 -0
- package/dist/esm/singleton/API/types.d.ts +3 -4
- package/dist/esm/singleton/Amplify.d.ts +2 -2
- package/dist/esm/singleton/Amplify.mjs +15 -9
- package/dist/esm/singleton/Amplify.mjs.map +1 -1
- package/dist/esm/singleton/AmplifyOutputs/types.d.ts +80 -0
- package/dist/esm/singleton/AmplifyOutputs/types.mjs +2 -0
- package/dist/esm/singleton/AmplifyOutputs/types.mjs.map +1 -0
- package/dist/esm/singleton/Auth/types.d.ts +2 -1
- package/dist/esm/singleton/Storage/types.d.ts +10 -0
- package/dist/esm/singleton/types.d.ts +1 -0
- package/dist/esm/utils/parseAmplifyConfig.d.ts +10 -0
- package/dist/esm/utils/parseAmplifyConfig.mjs +25 -0
- package/dist/esm/utils/parseAmplifyConfig.mjs.map +1 -0
- package/package.json +3 -3
- package/src/Platform/version.ts +1 -1
- package/src/libraryUtils.ts +4 -0
- package/src/parseAWSExports.ts +8 -9
- package/src/parseAmplifyOutputs.ts +333 -0
- package/src/singleton/API/types.ts +4 -2
- package/src/singleton/Amplify.ts +4 -9
- package/src/singleton/AmplifyOutputs/types.ts +99 -0
- package/src/singleton/Auth/types.ts +3 -1
- package/src/singleton/Storage/types.ts +10 -0
- package/src/singleton/types.ts +2 -0
- package/src/utils/parseAmplifyConfig.ts +26 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseAmplifyConfig.js","sources":["../../../src/utils/parseAmplifyConfig.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.parseAmplifyConfig = void 0;\nconst parseAWSExports_1 = require(\"../parseAWSExports\");\nconst parseAmplifyOutputs_1 = require(\"../parseAmplifyOutputs\");\n/**\n * Parses the variety of configuration shapes that Amplify can accept into a ResourcesConfig.\n *\n * @param amplifyConfig An Amplify configuration object conforming to one of the supported schemas.\n * @return A ResourcesConfig for the provided configuration object.\n */\nconst parseAmplifyConfig = (amplifyConfig) => {\n if (Object.keys(amplifyConfig).some(key => key.startsWith('aws_'))) {\n return (0, parseAWSExports_1.parseAWSExports)(amplifyConfig);\n }\n else if ((0, parseAmplifyOutputs_1.isAmplifyOutputs)(amplifyConfig)) {\n return (0, parseAmplifyOutputs_1.parseAmplifyOutputs)(amplifyConfig);\n }\n else {\n return amplifyConfig;\n }\n};\nexports.parseAmplifyConfig = parseAmplifyConfig;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,MAAM,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACxD,MAAM,qBAAqB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAChE;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,kBAAkB,GAAG,CAAC,aAAa,KAAK;AAC9C,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE;AACxE,QAAQ,OAAO,IAAI,iBAAiB,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;AACrE,KAAK;AACL,SAAS,IAAI,IAAI,qBAAqB,CAAC,gBAAgB,EAAE,aAAa,CAAC,EAAE;AACzE,QAAQ,OAAO,IAAI,qBAAqB,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;AAC7E,KAAK;AACL,SAAS;AACT,QAAQ,OAAO,aAAa,CAAC;AAC7B,KAAK;AACL,CAAC,CAAC;AACF,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.
|
|
1
|
+
export declare const version = "6.2.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.2.0';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export { generateRandomString, isBrowser, isNonRetryableError, isWebWorker, jitteredBackoff, jitteredExponentialRetry, NonRetryableError, retry, urlSafeDecode, urlSafeEncode, deDupeAsyncFunction, } from './utils';
|
|
2
2
|
export { parseAWSExports } from './parseAWSExports';
|
|
3
|
+
export { isAmplifyOutputs, parseAmplifyOutputs } from './parseAmplifyOutputs';
|
|
3
4
|
export { LegacyConfig } from './singleton/types';
|
|
5
|
+
export { AmplifyOutputs } from './singleton/AmplifyOutputs/types';
|
|
4
6
|
export { ADD_OAUTH_LISTENER } from './singleton/constants';
|
|
5
7
|
export { amplifyUuid } from './utils/amplifyUuid';
|
|
6
8
|
export { AmplifyUrl, AmplifyUrlSearchParams } from './utils/amplifyUrl';
|
|
9
|
+
export { parseAmplifyConfig } from './utils/parseAmplifyConfig';
|
|
7
10
|
export { getClientInfo } from './utils';
|
|
8
11
|
export { decodeJWT, assertTokenProviderConfig, assertIdentityPoolIdConfig, assertOAuthConfig, } from './singleton/Auth/utils';
|
|
9
12
|
export { isTokenExpired } from './singleton/Auth';
|
|
@@ -11,9 +11,11 @@ export { urlSafeDecode } from './utils/urlSafeDecode.mjs';
|
|
|
11
11
|
export { urlSafeEncode } from './utils/urlSafeEncode.mjs';
|
|
12
12
|
export { deDupeAsyncFunction } from './utils/deDupeAsyncFunction.mjs';
|
|
13
13
|
export { parseAWSExports } from './parseAWSExports.mjs';
|
|
14
|
+
export { isAmplifyOutputs, parseAmplifyOutputs } from './parseAmplifyOutputs.mjs';
|
|
14
15
|
export { ADD_OAUTH_LISTENER } from './singleton/constants.mjs';
|
|
15
16
|
export { amplifyUuid } from './utils/amplifyUuid/index.mjs';
|
|
16
17
|
export { AmplifyUrl, AmplifyUrlSearchParams } from './utils/amplifyUrl/index.mjs';
|
|
18
|
+
export { parseAmplifyConfig } from './utils/parseAmplifyConfig.mjs';
|
|
17
19
|
export { assertIdentityPoolIdConfig, assertOAuthConfig, assertTokenProviderConfig, decodeJWT } from './singleton/Auth/utils/index.mjs';
|
|
18
20
|
export { isTokenExpired } from './singleton/Auth/index.mjs';
|
|
19
21
|
export { Signer } from './Signer/Signer.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libraryUtils.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"libraryUtils.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -174,15 +174,14 @@ const parseAWSExports = (config = {}) => {
|
|
|
174
174
|
// Geo
|
|
175
175
|
if (geo) {
|
|
176
176
|
const { amazon_location_service } = geo;
|
|
177
|
-
amplifyConfig.Geo =
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
: { ...geo };
|
|
177
|
+
amplifyConfig.Geo = {
|
|
178
|
+
LocationService: {
|
|
179
|
+
maps: amazon_location_service.maps,
|
|
180
|
+
geofenceCollections: amazon_location_service.geofenceCollections,
|
|
181
|
+
searchIndices: amazon_location_service.search_indices,
|
|
182
|
+
region: amazon_location_service.region,
|
|
183
|
+
},
|
|
184
|
+
};
|
|
186
185
|
}
|
|
187
186
|
// REST API
|
|
188
187
|
if (aws_cloud_logic_custom) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseAWSExports.mjs","sources":["../../src/parseAWSExports.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from './Logger';\nimport { AmplifyError } from './errors';\nconst logger = new ConsoleLogger('parseAWSExports');\nconst authTypeMapping = {\n API_KEY: 'apiKey',\n AWS_IAM: 'iam',\n AMAZON_COGNITO_USER_POOLS: 'userPool',\n OPENID_CONNECT: 'oidc',\n NONE: 'none',\n AWS_LAMBDA: 'lambda',\n // `LAMBDA` is an incorrect value that was added during the v6 rewrite.\n // Keeping it as a valid value until v7 to prevent breaking customers who might\n // be relying on it as a workaround.\n // ref: https://github.com/aws-amplify/amplify-js/pull/12922\n // TODO: @v7 remove next line\n LAMBDA: 'lambda',\n};\n/**\n * Converts the object imported from `aws-exports.js` or `amplifyconfiguration.json` files generated by\n * the Amplify CLI into an object that conforms to the {@link ResourcesConfig}.\n *\n * @param config A configuration object imported from `aws-exports.js` or `amplifyconfiguration.json`.\n *\n * @returns An object that conforms to the {@link ResourcesConfig} .\n */\nexport const parseAWSExports = (config = {}) => {\n if (!Object.prototype.hasOwnProperty.call(config, 'aws_project_region')) {\n throw new AmplifyError({\n name: 'InvalidParameterException',\n message: 'Invalid config parameter.',\n recoverySuggestion: 'Ensure passing the config object imported from `amplifyconfiguration.json`.',\n });\n }\n const { aws_appsync_apiKey, aws_appsync_authenticationType, aws_appsync_graphqlEndpoint, aws_appsync_region, aws_bots_config, aws_cognito_identity_pool_id, aws_cognito_sign_up_verification_method, aws_cognito_mfa_configuration, aws_cognito_mfa_types, aws_cognito_password_protection_settings, aws_cognito_verification_mechanisms, aws_cognito_signup_attributes, aws_cognito_social_providers, aws_cognito_username_attributes, aws_mandatory_sign_in, aws_mobile_analytics_app_id, aws_mobile_analytics_app_region, aws_user_files_s3_bucket, aws_user_files_s3_bucket_region, aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing, aws_user_pools_id, aws_user_pools_web_client_id, geo, oauth, predictions, aws_cloud_logic_custom, Notifications, modelIntrospection, } = config;\n const amplifyConfig = {};\n // Analytics\n if (aws_mobile_analytics_app_id) {\n amplifyConfig.Analytics = {\n Pinpoint: {\n appId: aws_mobile_analytics_app_id,\n region: aws_mobile_analytics_app_region,\n },\n };\n }\n // Notifications\n const { InAppMessaging, Push } = Notifications ?? {};\n if (InAppMessaging?.AWSPinpoint || Push?.AWSPinpoint) {\n if (InAppMessaging?.AWSPinpoint) {\n const { appId, region } = InAppMessaging.AWSPinpoint;\n amplifyConfig.Notifications = {\n InAppMessaging: {\n Pinpoint: {\n appId,\n region,\n },\n },\n };\n }\n if (Push?.AWSPinpoint) {\n const { appId, region } = Push.AWSPinpoint;\n amplifyConfig.Notifications = {\n ...amplifyConfig.Notifications,\n PushNotification: {\n Pinpoint: {\n appId,\n region,\n },\n },\n };\n }\n }\n // Interactions\n if (Array.isArray(aws_bots_config)) {\n amplifyConfig.Interactions = {\n LexV1: Object.fromEntries(aws_bots_config.map(bot => [bot.name, bot])),\n };\n }\n // API\n if (aws_appsync_graphqlEndpoint) {\n const defaultAuthMode = authTypeMapping[aws_appsync_authenticationType];\n if (!defaultAuthMode) {\n logger.debug(`Invalid authentication type ${aws_appsync_authenticationType}. Falling back to IAM.`);\n }\n amplifyConfig.API = {\n GraphQL: {\n endpoint: aws_appsync_graphqlEndpoint,\n apiKey: aws_appsync_apiKey,\n region: aws_appsync_region,\n defaultAuthMode: defaultAuthMode ?? 'iam',\n },\n };\n if (modelIntrospection) {\n amplifyConfig.API.GraphQL.modelIntrospection = modelIntrospection;\n }\n }\n // Auth\n const mfaConfig = aws_cognito_mfa_configuration\n ? {\n status: aws_cognito_mfa_configuration &&\n aws_cognito_mfa_configuration.toLowerCase(),\n totpEnabled: aws_cognito_mfa_types?.includes('TOTP') ?? false,\n smsEnabled: aws_cognito_mfa_types?.includes('SMS') ?? false,\n }\n : undefined;\n const passwordFormatConfig = aws_cognito_password_protection_settings\n ? {\n minLength: aws_cognito_password_protection_settings.passwordPolicyMinLength,\n requireLowercase: aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes('REQUIRES_LOWERCASE') ?? false,\n requireUppercase: aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes('REQUIRES_UPPERCASE') ?? false,\n requireNumbers: aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes('REQUIRES_NUMBERS') ?? false,\n requireSpecialCharacters: aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes('REQUIRES_SYMBOLS') ?? false,\n }\n : undefined;\n const mergedUserAttributes = Array.from(new Set([\n ...(aws_cognito_verification_mechanisms ?? []),\n ...(aws_cognito_signup_attributes ?? []),\n ]));\n const userAttributes = mergedUserAttributes.reduce((attributes, key) => ({\n ...attributes,\n // All user attributes generated by the CLI are required\n [key.toLowerCase()]: { required: true },\n }), {});\n const loginWithEmailEnabled = aws_cognito_username_attributes?.includes('EMAIL') ?? false;\n const loginWithPhoneEnabled = aws_cognito_username_attributes?.includes('PHONE_NUMBER') ?? false;\n if (aws_cognito_identity_pool_id || aws_user_pools_id) {\n amplifyConfig.Auth = {\n Cognito: {\n identityPoolId: aws_cognito_identity_pool_id,\n allowGuestAccess: aws_mandatory_sign_in !== 'enable',\n signUpVerificationMethod: aws_cognito_sign_up_verification_method,\n userAttributes,\n userPoolClientId: aws_user_pools_web_client_id,\n userPoolId: aws_user_pools_id,\n mfa: mfaConfig,\n passwordFormat: passwordFormatConfig,\n loginWith: {\n username: !(loginWithEmailEnabled || loginWithPhoneEnabled),\n email: loginWithEmailEnabled,\n phone: loginWithPhoneEnabled,\n },\n },\n };\n }\n const hasOAuthConfig = oauth ? Object.keys(oauth).length > 0 : false;\n const hasSocialProviderConfig = aws_cognito_social_providers\n ? aws_cognito_social_providers.length > 0\n : false;\n if (amplifyConfig.Auth && hasOAuthConfig) {\n amplifyConfig.Auth.Cognito.loginWith = {\n ...amplifyConfig.Auth.Cognito.loginWith,\n oauth: {\n ...getOAuthConfig(oauth),\n ...(hasSocialProviderConfig && {\n providers: parseSocialProviders(aws_cognito_social_providers),\n }),\n },\n };\n }\n // Storage\n if (aws_user_files_s3_bucket) {\n amplifyConfig.Storage = {\n S3: {\n bucket: aws_user_files_s3_bucket,\n region: aws_user_files_s3_bucket_region,\n dangerouslyConnectToHttpEndpointForTesting: aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing,\n },\n };\n }\n // Geo\n if (geo) {\n const { amazon_location_service } = geo;\n amplifyConfig.Geo = amazon_location_service\n ? {\n LocationService: {\n ...amazon_location_service,\n searchIndices: amazon_location_service.search_indices,\n region: amazon_location_service.region,\n },\n }\n : { ...geo };\n }\n // REST API\n if (aws_cloud_logic_custom) {\n amplifyConfig.API = {\n ...amplifyConfig.API,\n REST: aws_cloud_logic_custom.reduce((acc, api) => {\n const { name, endpoint, region, service } = api;\n return {\n ...acc,\n [name]: {\n endpoint,\n ...(service ? { service } : undefined),\n ...(region ? { region } : undefined),\n },\n };\n }, {}),\n };\n }\n // Predictions\n if (predictions) {\n // map VoiceId from speechGenerator defaults to voiceId\n const { VoiceId: voiceId } = predictions?.convert?.speechGenerator?.defaults ?? {};\n amplifyConfig.Predictions = voiceId\n ? {\n ...predictions,\n convert: {\n ...predictions.convert,\n speechGenerator: {\n ...predictions.convert.speechGenerator,\n defaults: { voiceId },\n },\n },\n }\n : predictions;\n }\n return amplifyConfig;\n};\nconst getRedirectUrl = (redirectStr) => redirectStr?.split(',') ?? [];\nconst getOAuthConfig = ({ domain, scope, redirectSignIn, redirectSignOut, responseType, }) => ({\n domain,\n scopes: scope,\n redirectSignIn: getRedirectUrl(redirectSignIn),\n redirectSignOut: getRedirectUrl(redirectSignOut),\n responseType,\n});\nconst parseSocialProviders = (aws_cognito_social_providers) => {\n return aws_cognito_social_providers.map((provider) => {\n const updatedProvider = provider.toLowerCase();\n return updatedProvider.charAt(0).toUpperCase() + updatedProvider.slice(1);\n });\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAGA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAAC;AACpD,MAAM,eAAe,GAAG;AACxB,IAAI,OAAO,EAAE,QAAQ;AACrB,IAAI,OAAO,EAAE,KAAK;AAClB,IAAI,yBAAyB,EAAE,UAAU;AACzC,IAAI,cAAc,EAAE,MAAM;AAC1B,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,UAAU,EAAE,QAAQ;AACxB;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,EAAE,QAAQ;AACpB,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;A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YAAY,GAAG,MAAM;AAC/F,IAAI,MAAM;AACV,IAAI,MAAM,EAAE,KAAK;AACjB,IAAI,cAAc,EAAE,cAAc,CAAC,cAAc,CAAC;AAClD,IAAI,eAAe,EAAE,cAAc,CAAC,eAAe,CAAC;AACpD,IAAI,YAAY;AAChB,CAAC,CAAC,CAAC;AACH,MAAM,oBAAoB,GAAG,CAAC,4BAA4B,KAAK;AAC/D,IAAI,OAAO,4BAA4B,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK;AAC1D,QAAQ,MAAM,eAAe,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AACvD,QAAQ,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAClF,KAAK,CAAC,CAAC;AACP,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"parseAWSExports.mjs","sources":["../../src/parseAWSExports.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from './Logger';\nimport { AmplifyError } from './errors';\nconst logger = new ConsoleLogger('parseAWSExports');\nconst authTypeMapping = {\n API_KEY: 'apiKey',\n AWS_IAM: 'iam',\n AMAZON_COGNITO_USER_POOLS: 'userPool',\n OPENID_CONNECT: 'oidc',\n NONE: 'none',\n AWS_LAMBDA: 'lambda',\n // `LAMBDA` is an incorrect value that was added during the v6 rewrite.\n // Keeping it as a valid value until v7 to prevent breaking customers who might\n // be relying on it as a workaround.\n // ref: https://github.com/aws-amplify/amplify-js/pull/12922\n // TODO: @v7 remove next line\n LAMBDA: 'lambda',\n};\n/**\n * Converts the object imported from `aws-exports.js` or `amplifyconfiguration.json` files generated by\n * the Amplify CLI into an object that conforms to the {@link ResourcesConfig}.\n *\n * @param config A configuration object imported from `aws-exports.js` or `amplifyconfiguration.json`.\n *\n * @returns An object that conforms to the {@link ResourcesConfig} .\n */\nexport const parseAWSExports = (config = {}) => {\n if (!Object.prototype.hasOwnProperty.call(config, 'aws_project_region')) {\n throw new AmplifyError({\n name: 'InvalidParameterException',\n message: 'Invalid config parameter.',\n recoverySuggestion: 'Ensure passing the config object imported from `amplifyconfiguration.json`.',\n });\n }\n const { aws_appsync_apiKey, aws_appsync_authenticationType, aws_appsync_graphqlEndpoint, aws_appsync_region, aws_bots_config, aws_cognito_identity_pool_id, aws_cognito_sign_up_verification_method, aws_cognito_mfa_configuration, aws_cognito_mfa_types, aws_cognito_password_protection_settings, aws_cognito_verification_mechanisms, aws_cognito_signup_attributes, aws_cognito_social_providers, aws_cognito_username_attributes, aws_mandatory_sign_in, aws_mobile_analytics_app_id, aws_mobile_analytics_app_region, aws_user_files_s3_bucket, aws_user_files_s3_bucket_region, aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing, aws_user_pools_id, aws_user_pools_web_client_id, geo, oauth, predictions, aws_cloud_logic_custom, Notifications, modelIntrospection, } = config;\n const amplifyConfig = {};\n // Analytics\n if (aws_mobile_analytics_app_id) {\n amplifyConfig.Analytics = {\n Pinpoint: {\n appId: aws_mobile_analytics_app_id,\n region: aws_mobile_analytics_app_region,\n },\n };\n }\n // Notifications\n const { InAppMessaging, Push } = Notifications ?? {};\n if (InAppMessaging?.AWSPinpoint || Push?.AWSPinpoint) {\n if (InAppMessaging?.AWSPinpoint) {\n const { appId, region } = InAppMessaging.AWSPinpoint;\n amplifyConfig.Notifications = {\n InAppMessaging: {\n Pinpoint: {\n appId,\n region,\n },\n },\n };\n }\n if (Push?.AWSPinpoint) {\n const { appId, region } = Push.AWSPinpoint;\n amplifyConfig.Notifications = {\n ...amplifyConfig.Notifications,\n PushNotification: {\n Pinpoint: {\n appId,\n region,\n },\n },\n };\n }\n }\n // Interactions\n if (Array.isArray(aws_bots_config)) {\n amplifyConfig.Interactions = {\n LexV1: Object.fromEntries(aws_bots_config.map(bot => [bot.name, bot])),\n };\n }\n // API\n if (aws_appsync_graphqlEndpoint) {\n const defaultAuthMode = authTypeMapping[aws_appsync_authenticationType];\n if (!defaultAuthMode) {\n logger.debug(`Invalid authentication type ${aws_appsync_authenticationType}. Falling back to IAM.`);\n }\n amplifyConfig.API = {\n GraphQL: {\n endpoint: aws_appsync_graphqlEndpoint,\n apiKey: aws_appsync_apiKey,\n region: aws_appsync_region,\n defaultAuthMode: defaultAuthMode ?? 'iam',\n },\n };\n if (modelIntrospection) {\n amplifyConfig.API.GraphQL.modelIntrospection = modelIntrospection;\n }\n }\n // Auth\n const mfaConfig = aws_cognito_mfa_configuration\n ? {\n status: aws_cognito_mfa_configuration &&\n aws_cognito_mfa_configuration.toLowerCase(),\n totpEnabled: aws_cognito_mfa_types?.includes('TOTP') ?? false,\n smsEnabled: aws_cognito_mfa_types?.includes('SMS') ?? false,\n }\n : undefined;\n const passwordFormatConfig = aws_cognito_password_protection_settings\n ? {\n minLength: aws_cognito_password_protection_settings.passwordPolicyMinLength,\n requireLowercase: aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes('REQUIRES_LOWERCASE') ?? false,\n requireUppercase: aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes('REQUIRES_UPPERCASE') ?? false,\n requireNumbers: aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes('REQUIRES_NUMBERS') ?? false,\n requireSpecialCharacters: aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes('REQUIRES_SYMBOLS') ?? false,\n }\n : undefined;\n const mergedUserAttributes = Array.from(new Set([\n ...(aws_cognito_verification_mechanisms ?? []),\n ...(aws_cognito_signup_attributes ?? []),\n ]));\n const userAttributes = mergedUserAttributes.reduce((attributes, key) => ({\n ...attributes,\n // All user attributes generated by the CLI are required\n [key.toLowerCase()]: { required: true },\n }), {});\n const loginWithEmailEnabled = aws_cognito_username_attributes?.includes('EMAIL') ?? false;\n const loginWithPhoneEnabled = aws_cognito_username_attributes?.includes('PHONE_NUMBER') ?? false;\n if (aws_cognito_identity_pool_id || aws_user_pools_id) {\n amplifyConfig.Auth = {\n Cognito: {\n identityPoolId: aws_cognito_identity_pool_id,\n allowGuestAccess: aws_mandatory_sign_in !== 'enable',\n signUpVerificationMethod: aws_cognito_sign_up_verification_method,\n userAttributes,\n userPoolClientId: aws_user_pools_web_client_id,\n userPoolId: aws_user_pools_id,\n mfa: mfaConfig,\n passwordFormat: passwordFormatConfig,\n loginWith: {\n username: !(loginWithEmailEnabled || loginWithPhoneEnabled),\n email: loginWithEmailEnabled,\n phone: loginWithPhoneEnabled,\n },\n },\n };\n }\n const hasOAuthConfig = oauth ? Object.keys(oauth).length > 0 : false;\n const hasSocialProviderConfig = aws_cognito_social_providers\n ? aws_cognito_social_providers.length > 0\n : false;\n if (amplifyConfig.Auth && hasOAuthConfig) {\n amplifyConfig.Auth.Cognito.loginWith = {\n ...amplifyConfig.Auth.Cognito.loginWith,\n oauth: {\n ...getOAuthConfig(oauth),\n ...(hasSocialProviderConfig && {\n providers: parseSocialProviders(aws_cognito_social_providers),\n }),\n },\n };\n }\n // Storage\n if (aws_user_files_s3_bucket) {\n amplifyConfig.Storage = {\n S3: {\n bucket: aws_user_files_s3_bucket,\n region: aws_user_files_s3_bucket_region,\n dangerouslyConnectToHttpEndpointForTesting: aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing,\n },\n };\n }\n // Geo\n if (geo) {\n const { amazon_location_service } = geo;\n amplifyConfig.Geo = {\n LocationService: {\n maps: amazon_location_service.maps,\n geofenceCollections: amazon_location_service.geofenceCollections,\n searchIndices: amazon_location_service.search_indices,\n region: amazon_location_service.region,\n },\n };\n }\n // REST API\n if (aws_cloud_logic_custom) {\n amplifyConfig.API = {\n ...amplifyConfig.API,\n REST: aws_cloud_logic_custom.reduce((acc, api) => {\n const { name, endpoint, region, service } = api;\n return {\n ...acc,\n [name]: {\n endpoint,\n ...(service ? { service } : undefined),\n ...(region ? { region } : undefined),\n },\n };\n }, {}),\n };\n }\n // Predictions\n if (predictions) {\n // map VoiceId from speechGenerator defaults to voiceId\n const { VoiceId: voiceId } = predictions?.convert?.speechGenerator?.defaults ?? {};\n amplifyConfig.Predictions = voiceId\n ? {\n ...predictions,\n convert: {\n ...predictions.convert,\n speechGenerator: {\n ...predictions.convert.speechGenerator,\n defaults: { voiceId },\n },\n },\n }\n : predictions;\n }\n return amplifyConfig;\n};\nconst getRedirectUrl = (redirectStr) => redirectStr?.split(',') ?? [];\nconst getOAuthConfig = ({ domain, scope, redirectSignIn, redirectSignOut, responseType, }) => ({\n domain,\n scopes: scope,\n redirectSignIn: getRedirectUrl(redirectSignIn),\n redirectSignOut: getRedirectUrl(redirectSignOut),\n responseType,\n});\nconst parseSocialProviders = (aws_cognito_social_providers) => {\n return aws_cognito_social_providers.map((provider) => {\n const updatedProvider = provider.toLowerCase();\n return updatedProvider.charAt(0).toUpperCase() + updatedProvider.slice(1);\n });\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAGA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAAC;AACpD,MAAM,eAAe,GAAG;AACxB,IAAI,OAAO,EAAE,QAAQ;AACrB,IAAI,OAAO,EAAE,KAAK;AAClB,IAAI,yBAAyB,EAAE,UAAU;AACzC,IAAI,cAAc,EAAE,MAAM;AAC1B,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,UAAU,EAAE,QAAQ;AACxB;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,EAAE,QAAQ;AACpB,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,eAAe,GAAG,CAAC,MAAM,GAAG,EAAE,KAAK;AAChD,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAAE;AAC7E,QAAQ,MAAM,IAAI,YAAY,CAAC;AAC/B,YAAY,IAAI,EAAE,2BAA2B;AAC7C,YAAY,OAAO,EAAE,2BAA2B;AAChD,YAAY,kBAA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AAG,CAAC,CAAC,QAAQ,KAAK;AAC1D,QAAQ,MAAM,eAAe,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AACvD,QAAQ,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAClF,KAAK,CAAC,CAAC;AACP,CAAC;;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AmplifyOutputs, AmplifyOutputsAnalyticsProperties } from './singleton/AmplifyOutputs/types';
|
|
2
|
+
import { AnalyticsConfig, LegacyConfig, ResourcesConfig } from './singleton/types';
|
|
3
|
+
export declare function isAmplifyOutputs(config: ResourcesConfig | LegacyConfig | AmplifyOutputs): config is AmplifyOutputs;
|
|
4
|
+
export declare function parseAnalytics(amplifyOutputsAnalyticsProperties?: AmplifyOutputsAnalyticsProperties): AnalyticsConfig | undefined;
|
|
5
|
+
export declare function parseAmplifyOutputs(amplifyOutputs: AmplifyOutputs): ResourcesConfig;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
function isAmplifyOutputs(config) {
|
|
4
|
+
// version format initially will be '1' but is expected to be something like x.y where x is major and y minor version
|
|
5
|
+
const { version } = config;
|
|
6
|
+
if (!version) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return version.startsWith('1');
|
|
10
|
+
}
|
|
11
|
+
function parseStorage(amplifyOutputsStorageProperties) {
|
|
12
|
+
if (!amplifyOutputsStorageProperties) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const { bucket_name, aws_region } = amplifyOutputsStorageProperties;
|
|
16
|
+
return {
|
|
17
|
+
S3: {
|
|
18
|
+
bucket: bucket_name,
|
|
19
|
+
region: aws_region,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function parseAuth(amplifyOutputsAuthProperties) {
|
|
24
|
+
if (!amplifyOutputsAuthProperties) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const { user_pool_id, user_pool_client_id, identity_pool_id, password_policy, mfa_configuration, mfa_methods, unauthenticated_identities_enabled, oauth, username_attributes, standard_required_attributes, } = amplifyOutputsAuthProperties;
|
|
28
|
+
const authConfig = {
|
|
29
|
+
Cognito: {
|
|
30
|
+
userPoolId: user_pool_id,
|
|
31
|
+
userPoolClientId: user_pool_client_id,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
if (identity_pool_id) {
|
|
35
|
+
authConfig.Cognito = {
|
|
36
|
+
...authConfig.Cognito,
|
|
37
|
+
identityPoolId: identity_pool_id,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (password_policy) {
|
|
41
|
+
authConfig.Cognito.passwordFormat = {
|
|
42
|
+
requireLowercase: password_policy.require_lowercase,
|
|
43
|
+
requireNumbers: password_policy.require_numbers,
|
|
44
|
+
requireUppercase: password_policy.require_uppercase,
|
|
45
|
+
requireSpecialCharacters: password_policy.require_symbols,
|
|
46
|
+
minLength: password_policy.min_length ?? 6,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (mfa_configuration) {
|
|
50
|
+
authConfig.Cognito.mfa = {
|
|
51
|
+
status: getMfaStatus(mfa_configuration),
|
|
52
|
+
smsEnabled: mfa_methods?.includes('SMS'),
|
|
53
|
+
totpEnabled: mfa_methods?.includes('TOTP'),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (unauthenticated_identities_enabled) {
|
|
57
|
+
authConfig.Cognito.allowGuestAccess = unauthenticated_identities_enabled;
|
|
58
|
+
}
|
|
59
|
+
if (oauth) {
|
|
60
|
+
authConfig.Cognito.loginWith = {
|
|
61
|
+
oauth: {
|
|
62
|
+
domain: oauth.domain,
|
|
63
|
+
redirectSignIn: oauth.redirect_sign_in_uri,
|
|
64
|
+
redirectSignOut: oauth.redirect_sign_out_uri,
|
|
65
|
+
responseType: oauth.response_type === 'token' ? 'token' : 'code',
|
|
66
|
+
scopes: oauth.scopes,
|
|
67
|
+
providers: getOAuthProviders(oauth.identity_providers),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (username_attributes?.includes('email')) {
|
|
72
|
+
authConfig.Cognito.loginWith = {
|
|
73
|
+
...authConfig.Cognito.loginWith,
|
|
74
|
+
email: true,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (username_attributes?.includes('phone_number')) {
|
|
78
|
+
authConfig.Cognito.loginWith = {
|
|
79
|
+
...authConfig.Cognito.loginWith,
|
|
80
|
+
phone: true,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (standard_required_attributes) {
|
|
84
|
+
authConfig.Cognito.userAttributes = standard_required_attributes.reduce((acc, curr) => ({ ...acc, [curr]: { required: true } }), {});
|
|
85
|
+
}
|
|
86
|
+
return authConfig;
|
|
87
|
+
}
|
|
88
|
+
function parseAnalytics(amplifyOutputsAnalyticsProperties) {
|
|
89
|
+
if (!amplifyOutputsAnalyticsProperties?.amazon_pinpoint) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
const { amazon_pinpoint } = amplifyOutputsAnalyticsProperties;
|
|
93
|
+
return {
|
|
94
|
+
Pinpoint: {
|
|
95
|
+
appId: amazon_pinpoint.app_id,
|
|
96
|
+
region: amazon_pinpoint.aws_region,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function parseGeo(amplifyOutputsAnalyticsProperties) {
|
|
101
|
+
if (!amplifyOutputsAnalyticsProperties) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
const { aws_region, geofence_collections, maps, search_indices } = amplifyOutputsAnalyticsProperties;
|
|
105
|
+
return {
|
|
106
|
+
LocationService: {
|
|
107
|
+
region: aws_region,
|
|
108
|
+
searchIndices: search_indices,
|
|
109
|
+
geofenceCollections: geofence_collections,
|
|
110
|
+
maps,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function parseData(amplifyOutputsDataProperties) {
|
|
115
|
+
if (!amplifyOutputsDataProperties) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
const { aws_region, default_authorization_type, url, api_key, model_introspection, } = amplifyOutputsDataProperties;
|
|
119
|
+
const GraphQL = {
|
|
120
|
+
endpoint: url,
|
|
121
|
+
defaultAuthMode: getGraphQLAuthMode(default_authorization_type),
|
|
122
|
+
region: aws_region,
|
|
123
|
+
apiKey: api_key,
|
|
124
|
+
modelIntrospection: model_introspection,
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
GraphQL,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function parseNotifications(amplifyOutputsNotificationsProperties) {
|
|
131
|
+
if (!amplifyOutputsNotificationsProperties) {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
const { aws_region, channels, amazon_pinpoint_app_id } = amplifyOutputsNotificationsProperties;
|
|
135
|
+
const hasInAppMessaging = channels.includes('IN_APP_MESSAGING');
|
|
136
|
+
const hasPushNotification = channels.includes('APNS') || channels.includes('FCM');
|
|
137
|
+
if (!(hasInAppMessaging || hasPushNotification)) {
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
// At this point, we know the Amplify outputs contains at least one supported channel
|
|
141
|
+
const notificationsConfig = {};
|
|
142
|
+
if (hasInAppMessaging) {
|
|
143
|
+
notificationsConfig.InAppMessaging = {
|
|
144
|
+
Pinpoint: {
|
|
145
|
+
appId: amazon_pinpoint_app_id,
|
|
146
|
+
region: aws_region,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (hasPushNotification) {
|
|
151
|
+
notificationsConfig.PushNotification = {
|
|
152
|
+
Pinpoint: {
|
|
153
|
+
appId: amazon_pinpoint_app_id,
|
|
154
|
+
region: aws_region,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return notificationsConfig;
|
|
159
|
+
}
|
|
160
|
+
function parseAmplifyOutputs(amplifyOutputs) {
|
|
161
|
+
const resourcesConfig = {};
|
|
162
|
+
if (amplifyOutputs.storage) {
|
|
163
|
+
resourcesConfig.Storage = parseStorage(amplifyOutputs.storage);
|
|
164
|
+
}
|
|
165
|
+
if (amplifyOutputs.auth) {
|
|
166
|
+
resourcesConfig.Auth = parseAuth(amplifyOutputs.auth);
|
|
167
|
+
}
|
|
168
|
+
if (amplifyOutputs.analytics) {
|
|
169
|
+
resourcesConfig.Analytics = parseAnalytics(amplifyOutputs.analytics);
|
|
170
|
+
}
|
|
171
|
+
if (amplifyOutputs.geo) {
|
|
172
|
+
resourcesConfig.Geo = parseGeo(amplifyOutputs.geo);
|
|
173
|
+
}
|
|
174
|
+
if (amplifyOutputs.data) {
|
|
175
|
+
resourcesConfig.API = parseData(amplifyOutputs.data);
|
|
176
|
+
}
|
|
177
|
+
if (amplifyOutputs.notifications) {
|
|
178
|
+
resourcesConfig.Notifications = parseNotifications(amplifyOutputs.notifications);
|
|
179
|
+
}
|
|
180
|
+
return resourcesConfig;
|
|
181
|
+
}
|
|
182
|
+
const authModeNames = {
|
|
183
|
+
AMAZON_COGNITO_USER_POOLS: 'userPool',
|
|
184
|
+
API_KEY: 'apiKey',
|
|
185
|
+
AWS_IAM: 'iam',
|
|
186
|
+
AWS_LAMBDA: 'lambda',
|
|
187
|
+
OPENID_CONNECT: 'oidc',
|
|
188
|
+
};
|
|
189
|
+
function getGraphQLAuthMode(authType) {
|
|
190
|
+
return authModeNames[authType];
|
|
191
|
+
}
|
|
192
|
+
const providerNames = {
|
|
193
|
+
GOOGLE: 'Google',
|
|
194
|
+
LOGIN_WITH_AMAZON: 'Amazon',
|
|
195
|
+
FACEBOOK: 'Facebook',
|
|
196
|
+
SIGN_IN_WITH_APPLE: 'Apple',
|
|
197
|
+
};
|
|
198
|
+
function getOAuthProviders(providers = []) {
|
|
199
|
+
return providers.map(provider => providerNames[provider]);
|
|
200
|
+
}
|
|
201
|
+
function getMfaStatus(mfaConfiguration) {
|
|
202
|
+
if (mfaConfiguration === 'OPTIONAL')
|
|
203
|
+
return 'optional';
|
|
204
|
+
if (mfaConfiguration === 'REQUIRED')
|
|
205
|
+
return 'on';
|
|
206
|
+
return 'off';
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export { isAmplifyOutputs, parseAmplifyOutputs, parseAnalytics };
|
|
210
|
+
//# sourceMappingURL=parseAmplifyOutputs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseAmplifyOutputs.mjs","sources":["../../src/parseAmplifyOutputs.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function isAmplifyOutputs(config) {\n // version format initially will be '1' but is expected to be something like x.y where x is major and y minor version\n const { version } = config;\n if (!version) {\n return false;\n }\n return version.startsWith('1');\n}\nfunction parseStorage(amplifyOutputsStorageProperties) {\n if (!amplifyOutputsStorageProperties) {\n return undefined;\n }\n const { bucket_name, aws_region } = amplifyOutputsStorageProperties;\n return {\n S3: {\n bucket: bucket_name,\n region: aws_region,\n },\n };\n}\nfunction parseAuth(amplifyOutputsAuthProperties) {\n if (!amplifyOutputsAuthProperties) {\n return undefined;\n }\n const { user_pool_id, user_pool_client_id, identity_pool_id, password_policy, mfa_configuration, mfa_methods, unauthenticated_identities_enabled, oauth, username_attributes, standard_required_attributes, } = amplifyOutputsAuthProperties;\n const authConfig = {\n Cognito: {\n userPoolId: user_pool_id,\n userPoolClientId: user_pool_client_id,\n },\n };\n if (identity_pool_id) {\n authConfig.Cognito = {\n ...authConfig.Cognito,\n identityPoolId: identity_pool_id,\n };\n }\n if (password_policy) {\n authConfig.Cognito.passwordFormat = {\n requireLowercase: password_policy.require_lowercase,\n requireNumbers: password_policy.require_numbers,\n requireUppercase: password_policy.require_uppercase,\n requireSpecialCharacters: password_policy.require_symbols,\n minLength: password_policy.min_length ?? 6,\n };\n }\n if (mfa_configuration) {\n authConfig.Cognito.mfa = {\n status: getMfaStatus(mfa_configuration),\n smsEnabled: mfa_methods?.includes('SMS'),\n totpEnabled: mfa_methods?.includes('TOTP'),\n };\n }\n if (unauthenticated_identities_enabled) {\n authConfig.Cognito.allowGuestAccess = unauthenticated_identities_enabled;\n }\n if (oauth) {\n authConfig.Cognito.loginWith = {\n oauth: {\n domain: oauth.domain,\n redirectSignIn: oauth.redirect_sign_in_uri,\n redirectSignOut: oauth.redirect_sign_out_uri,\n responseType: oauth.response_type === 'token' ? 'token' : 'code',\n scopes: oauth.scopes,\n providers: getOAuthProviders(oauth.identity_providers),\n },\n };\n }\n if (username_attributes?.includes('email')) {\n authConfig.Cognito.loginWith = {\n ...authConfig.Cognito.loginWith,\n email: true,\n };\n }\n if (username_attributes?.includes('phone_number')) {\n authConfig.Cognito.loginWith = {\n ...authConfig.Cognito.loginWith,\n phone: true,\n };\n }\n if (standard_required_attributes) {\n authConfig.Cognito.userAttributes = standard_required_attributes.reduce((acc, curr) => ({ ...acc, [curr]: { required: true } }), {});\n }\n return authConfig;\n}\nexport function parseAnalytics(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties?.amazon_pinpoint) {\n return undefined;\n }\n const { amazon_pinpoint } = amplifyOutputsAnalyticsProperties;\n return {\n Pinpoint: {\n appId: amazon_pinpoint.app_id,\n region: amazon_pinpoint.aws_region,\n },\n };\n}\nfunction parseGeo(amplifyOutputsAnalyticsProperties) {\n if (!amplifyOutputsAnalyticsProperties) {\n return undefined;\n }\n const { aws_region, geofence_collections, maps, search_indices } = amplifyOutputsAnalyticsProperties;\n return {\n LocationService: {\n region: aws_region,\n searchIndices: search_indices,\n geofenceCollections: geofence_collections,\n maps,\n },\n };\n}\nfunction parseData(amplifyOutputsDataProperties) {\n if (!amplifyOutputsDataProperties) {\n return undefined;\n }\n const { aws_region, default_authorization_type, url, api_key, model_introspection, } = amplifyOutputsDataProperties;\n const GraphQL = {\n endpoint: url,\n defaultAuthMode: getGraphQLAuthMode(default_authorization_type),\n region: aws_region,\n apiKey: api_key,\n modelIntrospection: model_introspection,\n };\n return {\n GraphQL,\n };\n}\nfunction parseNotifications(amplifyOutputsNotificationsProperties) {\n if (!amplifyOutputsNotificationsProperties) {\n return undefined;\n }\n const { aws_region, channels, amazon_pinpoint_app_id } = amplifyOutputsNotificationsProperties;\n const hasInAppMessaging = channels.includes('IN_APP_MESSAGING');\n const hasPushNotification = channels.includes('APNS') || channels.includes('FCM');\n if (!(hasInAppMessaging || hasPushNotification)) {\n return undefined;\n }\n // At this point, we know the Amplify outputs contains at least one supported channel\n const notificationsConfig = {};\n if (hasInAppMessaging) {\n notificationsConfig.InAppMessaging = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n if (hasPushNotification) {\n notificationsConfig.PushNotification = {\n Pinpoint: {\n appId: amazon_pinpoint_app_id,\n region: aws_region,\n },\n };\n }\n return notificationsConfig;\n}\nexport function parseAmplifyOutputs(amplifyOutputs) {\n const resourcesConfig = {};\n if (amplifyOutputs.storage) {\n resourcesConfig.Storage = parseStorage(amplifyOutputs.storage);\n }\n if (amplifyOutputs.auth) {\n resourcesConfig.Auth = parseAuth(amplifyOutputs.auth);\n }\n if (amplifyOutputs.analytics) {\n resourcesConfig.Analytics = parseAnalytics(amplifyOutputs.analytics);\n }\n if (amplifyOutputs.geo) {\n resourcesConfig.Geo = parseGeo(amplifyOutputs.geo);\n }\n if (amplifyOutputs.data) {\n resourcesConfig.API = parseData(amplifyOutputs.data);\n }\n if (amplifyOutputs.notifications) {\n resourcesConfig.Notifications = parseNotifications(amplifyOutputs.notifications);\n }\n return resourcesConfig;\n}\nconst authModeNames = {\n AMAZON_COGNITO_USER_POOLS: 'userPool',\n API_KEY: 'apiKey',\n AWS_IAM: 'iam',\n AWS_LAMBDA: 'lambda',\n OPENID_CONNECT: 'oidc',\n};\nfunction getGraphQLAuthMode(authType) {\n return authModeNames[authType];\n}\nconst providerNames = {\n GOOGLE: 'Google',\n LOGIN_WITH_AMAZON: 'Amazon',\n FACEBOOK: 'Facebook',\n SIGN_IN_WITH_APPLE: 'Apple',\n};\nfunction getOAuthProviders(providers = []) {\n return providers.map(provider => providerNames[provider]);\n}\nfunction getMfaStatus(mfaConfiguration) {\n if (mfaConfiguration === 'OPTIONAL')\n return 'optional';\n if (mfaConfiguration === 'REQUIRED')\n return 'on';\n return 'off';\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,gBAAgB,CAAC,MAAM,EAAE;AACzC;AACA,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;AAC/B,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AACD,SAAS,YAAY,CAAC,+BAA+B,EAAE;AACvD,IAAI,IAAI,CAAC,+BAA+B,EAAE;AAC1C,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,IAAI,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,+BAA+B,CAAC;AACxE,IAAI,OAAO;AACX,QAAQ,EAAE,EAAE;AACZ,YAAY,MAAM,EAAE,WAAW;AAC/B,YAAY,MAAM,EAAE,UAAU;AAC9B,SAAS;AACT,KAAK,CAAC;AACN,CAAC;AACD,SAAS,SAAS,CAAC,4BAA4B,EAAE;AACjD,IAAI,IAAI,CAAC,4BAA4B,EAAE;AACvC,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,IAAI,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,kCAAkC,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AAa,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC9D,CAAC;AACD,SAAS,YAAY,CAAC,gBAAgB,EAAE;AACxC,IAAI,IAAI,gBAAgB,KAAK,UAAU;AACvC,QAAQ,OAAO,UAAU,CAAC;AAC1B,IAAI,IAAI,gBAAgB,KAAK,UAAU;AACvC,QAAQ,OAAO,IAAI,CAAC;AACpB,IAAI,OAAO,KAAK,CAAC;AACjB;;;;"}
|
|
@@ -14,7 +14,7 @@ export interface LibraryAPIOptions {
|
|
|
14
14
|
}): Promise<Headers>;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
interface APIGraphQLConfig {
|
|
17
|
+
export interface APIGraphQLConfig {
|
|
18
18
|
/**
|
|
19
19
|
* Required GraphQL endpoint, must be a valid URL string.
|
|
20
20
|
*/
|
|
@@ -42,7 +42,7 @@ interface APIGraphQLConfig {
|
|
|
42
42
|
defaultAuthMode: GraphQLAuthMode;
|
|
43
43
|
modelIntrospection?: ModelIntrospectionSchema;
|
|
44
44
|
}
|
|
45
|
-
interface APIRestConfig {
|
|
45
|
+
export interface APIRestConfig {
|
|
46
46
|
/**
|
|
47
47
|
* Required REST endpoint, must be a valid URL string.
|
|
48
48
|
*/
|
|
@@ -68,7 +68,7 @@ export interface GraphQLProviderConfig {
|
|
|
68
68
|
GraphQL: APIGraphQLConfig;
|
|
69
69
|
}
|
|
70
70
|
export type APIConfig = AtLeastOne<RESTProviderConfig & GraphQLProviderConfig>;
|
|
71
|
-
export type GraphQLAuthMode = 'apiKey' | 'oidc' | 'userPool' | 'iam' | 'lambda' | 'none';
|
|
71
|
+
export type GraphQLAuthMode = 'apiKey' | 'oidc' | 'userPool' | 'iam' | 'identityPool' | 'lambda' | 'none';
|
|
72
72
|
/**
|
|
73
73
|
* Type representing a plain JavaScript object that can be serialized to JSON.
|
|
74
74
|
*/
|
|
@@ -193,4 +193,3 @@ export interface PrimaryKeyInfo {
|
|
|
193
193
|
primaryKeyFieldName: string;
|
|
194
194
|
sortKeyFieldNames: string[];
|
|
195
195
|
}
|
|
196
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthConfig, LegacyConfig, LibraryOptions, ResourcesConfig } from './types';
|
|
1
|
+
import { AmplifyOutputs, AuthConfig, LegacyConfig, LibraryOptions, ResourcesConfig } from './types';
|
|
2
2
|
import { AuthClass } from './Auth';
|
|
3
3
|
import { ADD_OAUTH_LISTENER } from './constants';
|
|
4
4
|
export declare class AmplifyClass {
|
|
@@ -25,7 +25,7 @@ export declare class AmplifyClass {
|
|
|
25
25
|
* @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
|
|
26
26
|
* @param libraryOptions - Additional options for customizing the behavior of the library.
|
|
27
27
|
*/
|
|
28
|
-
configure(resourcesConfig: ResourcesConfig | LegacyConfig, libraryOptions?: LibraryOptions): void;
|
|
28
|
+
configure(resourcesConfig: ResourcesConfig | LegacyConfig | AmplifyOutputs, libraryOptions?: LibraryOptions): void;
|
|
29
29
|
/**
|
|
30
30
|
* Provides access to the current back-end resource configuration for the Library.
|
|
31
31
|
*
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { Hub, AMPLIFY_SYMBOL } from '../Hub/index.mjs';
|
|
2
|
-
import { parseAWSExports } from '../parseAWSExports.mjs';
|
|
3
2
|
import '../utils/getClientInfo/getClientInfo.mjs';
|
|
4
3
|
import '../utils/retry/retry.mjs';
|
|
5
4
|
import { deepFreeze } from '../utils/deepFreeze.mjs';
|
|
6
|
-
import
|
|
5
|
+
import '../parseAWSExports.mjs';
|
|
7
6
|
import { ADD_OAUTH_LISTENER } from './constants.mjs';
|
|
7
|
+
import 'uuid';
|
|
8
|
+
import { parseAmplifyConfig } from '../utils/parseAmplifyConfig.mjs';
|
|
9
|
+
import '../types/errors.mjs';
|
|
10
|
+
import '../errors/errorHelpers.mjs';
|
|
11
|
+
import './Auth/utils/errorHelpers.mjs';
|
|
12
|
+
import { AuthClass } from './Auth/index.mjs';
|
|
13
|
+
import '@aws-crypto/sha256-js';
|
|
14
|
+
import '@smithy/util-hex-encoding';
|
|
15
|
+
import '../Platform/types.mjs';
|
|
16
|
+
import '../Platform/detection/index.mjs';
|
|
17
|
+
import '../BackgroundProcessManager/types.mjs';
|
|
18
|
+
import '../Reachability/Reachability.mjs';
|
|
19
|
+
import '../utils/sessionListener/index.mjs';
|
|
8
20
|
|
|
9
21
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
10
22
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -29,13 +41,7 @@ class AmplifyClass {
|
|
|
29
41
|
* @param libraryOptions - Additional options for customizing the behavior of the library.
|
|
30
42
|
*/
|
|
31
43
|
configure(resourcesConfig, libraryOptions) {
|
|
32
|
-
|
|
33
|
-
if (Object.keys(resourcesConfig).some(key => key.startsWith('aws_'))) {
|
|
34
|
-
resolvedResourceConfig = parseAWSExports(resourcesConfig);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
resolvedResourceConfig = resourcesConfig;
|
|
38
|
-
}
|
|
44
|
+
const resolvedResourceConfig = parseAmplifyConfig(resourcesConfig);
|
|
39
45
|
this.resourcesConfig = resolvedResourceConfig;
|
|
40
46
|
if (libraryOptions) {
|
|
41
47
|
this.libraryOptions = libraryOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Amplify.mjs","sources":["../../../src/singleton/Amplify.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AMPLIFY_SYMBOL, Hub } from '../Hub';\nimport {
|
|
1
|
+
{"version":3,"file":"Amplify.mjs","sources":["../../../src/singleton/Amplify.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AMPLIFY_SYMBOL, Hub } from '../Hub';\nimport { deepFreeze } from '../utils';\nimport { parseAmplifyConfig } from '../libraryUtils';\nimport { AuthClass } from './Auth';\nimport { ADD_OAUTH_LISTENER } from './constants';\nexport class AmplifyClass {\n constructor() {\n this.oAuthListener = undefined;\n this.resourcesConfig = {};\n this.libraryOptions = {};\n this.Auth = new AuthClass();\n }\n /**\n * Configures Amplify for use with your back-end resources.\n *\n * @remarks\n * This API does not perform any merging of either `resourcesConfig` or `libraryOptions`. The most recently\n * provided values will be used after configuration.\n *\n * @remarks\n * `configure` can be used to specify additional library options where available for supported categories.\n *\n * @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.\n * @param libraryOptions - Additional options for customizing the behavior of the library.\n */\n configure(resourcesConfig, libraryOptions) {\n const resolvedResourceConfig = parseAmplifyConfig(resourcesConfig);\n this.resourcesConfig = resolvedResourceConfig;\n if (libraryOptions) {\n this.libraryOptions = libraryOptions;\n }\n // Make resource config immutable\n this.resourcesConfig = deepFreeze(this.resourcesConfig);\n this.Auth.configure(this.resourcesConfig.Auth, this.libraryOptions.Auth);\n Hub.dispatch('core', {\n event: 'configure',\n data: this.resourcesConfig,\n }, 'Configure', AMPLIFY_SYMBOL);\n this.notifyOAuthListener();\n }\n /**\n * Provides access to the current back-end resource configuration for the Library.\n *\n * @returns Returns the immutable back-end resource configuration.\n */\n getConfig() {\n return this.resourcesConfig;\n }\n /** @internal */\n [ADD_OAUTH_LISTENER](listener) {\n if (this.resourcesConfig.Auth?.Cognito.loginWith?.oauth) {\n // when Amplify has been configured with a valid OAuth config while adding the listener, run it directly\n listener(this.resourcesConfig.Auth?.Cognito);\n }\n else {\n // otherwise register the listener and run it later when Amplify gets configured with a valid oauth config\n this.oAuthListener = listener;\n }\n }\n notifyOAuthListener() {\n if (!this.resourcesConfig.Auth?.Cognito.loginWith?.oauth ||\n !this.oAuthListener) {\n return;\n }\n this.oAuthListener(this.resourcesConfig.Auth?.Cognito);\n // the listener should only be notified once with a valid oauth config\n this.oAuthListener = undefined;\n }\n}\n/**\n * The `Amplify` utility is used to configure the library.\n *\n * @remarks\n * `Amplify` is responsible for orchestrating cross-category communication within the library.\n */\nexport const Amplify = new AmplifyClass();\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAMO,MAAM,YAAY,CAAC;AAC1B,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;AACvC,QAAQ,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;AAClC,QAAQ,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;AACjC,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI,SAAS,EAAE,CAAC;AACpC,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,eAAe,EAAE,cAAc,EAAE;AAC/C,QAAQ,MAAM,sBAAsB,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;AAC3E,QAAQ,IAAI,CAAC,eAAe,GAAG,sBAAsB,CAAC;AACtD,QAAQ,IAAI,cAAc,EAAE;AAC5B,YAAY,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;AACjD,SAAS;AACT;AACA,QAAQ,IAAI,CAAC,eAAe,GAAG,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAChE,QAAQ,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACjF,QAAQ,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE;AAC7B,YAAY,KAAK,EAAE,WAAW;AAC9B,YAAY,IAAI,EAAE,IAAI,CAAC,eAAe;AACtC,SAAS,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;AACxC,QAAQ,IAAI,CAAC,mBAAmB,EAAE,CAAC;AACnC,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,GAAG;AAChB,QAAQ,OAAO,IAAI,CAAC,eAAe,CAAC;AACpC,KAAK;AACL;AACA,IAAI,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE;AACnC,QAAQ,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE;AACjE;AACA,YAAY,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACzD,SAAS;AACT,aAAa;AACb;AACA,YAAY,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;AAC1C,SAAS;AACT,KAAK;AACL,IAAI,mBAAmB,GAAG;AAC1B,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,KAAK;AAChE,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE;AACjC,YAAY,OAAO;AACnB,SAAS;AACT,QAAQ,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC/D;AACA,QAAQ,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;AACvC,KAAK;AACL,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,OAAO,GAAG,IAAI,YAAY;;;;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export type AmplifyOutputsOAuthIdentityProvider = 'GOOGLE' | 'FACEBOOK' | 'LOGIN_WITH_AMAZON' | 'SIGN_IN_WITH_APPLE';
|
|
2
|
+
export type AmplifyOutputsAuthMFAConfiguration = 'OPTIONAL' | 'REQUIRED' | 'NONE';
|
|
3
|
+
export type AmplifyOutputsAuthMFAMethod = 'SMS' | 'TOTP';
|
|
4
|
+
export interface AmplifyOutputsAuthProperties {
|
|
5
|
+
aws_region: string;
|
|
6
|
+
authentication_flow_type?: 'USER_SRP_AUTH' | 'CUSTOM_AUTH';
|
|
7
|
+
user_pool_id: string;
|
|
8
|
+
user_pool_client_id: string;
|
|
9
|
+
identity_pool_id?: string;
|
|
10
|
+
password_policy?: {
|
|
11
|
+
min_length: number;
|
|
12
|
+
require_numbers: boolean;
|
|
13
|
+
require_lowercase: boolean;
|
|
14
|
+
require_uppercase: boolean;
|
|
15
|
+
require_symbols: boolean;
|
|
16
|
+
};
|
|
17
|
+
oauth?: {
|
|
18
|
+
identity_providers: string[];
|
|
19
|
+
domain: string;
|
|
20
|
+
scopes: string[];
|
|
21
|
+
redirect_sign_in_uri: string[];
|
|
22
|
+
redirect_sign_out_uri: string[];
|
|
23
|
+
response_type: string;
|
|
24
|
+
};
|
|
25
|
+
standard_required_attributes?: string[];
|
|
26
|
+
username_attributes?: string[];
|
|
27
|
+
user_verification_types?: string[];
|
|
28
|
+
unauthenticated_identities_enabled?: boolean;
|
|
29
|
+
mfa_configuration?: string;
|
|
30
|
+
mfa_methods?: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface AmplifyOutputsStorageProperties {
|
|
33
|
+
aws_region: string;
|
|
34
|
+
bucket_name: string;
|
|
35
|
+
}
|
|
36
|
+
export interface AmplifyOutputsGeoProperties {
|
|
37
|
+
aws_region: string;
|
|
38
|
+
maps?: {
|
|
39
|
+
items: Record<string, unknown>;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
42
|
+
search_indices?: {
|
|
43
|
+
items: string[];
|
|
44
|
+
default: string;
|
|
45
|
+
};
|
|
46
|
+
geofence_collections?: {
|
|
47
|
+
items: string[];
|
|
48
|
+
default: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface AmplifyOutputsAnalyticsProperties {
|
|
52
|
+
amazon_pinpoint?: {
|
|
53
|
+
aws_region: string;
|
|
54
|
+
app_id: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export type AuthType = 'AMAZON_COGNITO_USER_POOLS' | 'API_KEY' | 'AWS_IAM' | 'AWS_LAMBDA' | 'OPENID_CONNECT';
|
|
58
|
+
export interface AmplifyOutputsDataProperties {
|
|
59
|
+
aws_region: string;
|
|
60
|
+
url: string;
|
|
61
|
+
default_authorization_type: string;
|
|
62
|
+
authorization_types: string[];
|
|
63
|
+
model_introspection?: object;
|
|
64
|
+
api_key?: string;
|
|
65
|
+
conflict_resolution_mode?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface AmplifyOutputsNotificationsProperties {
|
|
68
|
+
aws_region: string;
|
|
69
|
+
amazon_pinpoint_app_id: string;
|
|
70
|
+
channels: string[];
|
|
71
|
+
}
|
|
72
|
+
export interface AmplifyOutputs {
|
|
73
|
+
version?: string;
|
|
74
|
+
storage?: AmplifyOutputsStorageProperties;
|
|
75
|
+
auth?: AmplifyOutputsAuthProperties;
|
|
76
|
+
analytics?: AmplifyOutputsAnalyticsProperties;
|
|
77
|
+
geo?: AmplifyOutputsGeoProperties;
|
|
78
|
+
data?: AmplifyOutputsDataProperties;
|
|
79
|
+
notifications?: AmplifyOutputsNotificationsProperties;
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -88,6 +88,7 @@ export interface AuthUserPoolConfig {
|
|
|
88
88
|
allowGuestAccess?: never;
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
|
+
export type CognitoUserPoolConfigMfaStatus = 'on' | 'off' | 'optional';
|
|
91
92
|
export interface CognitoUserPoolConfig {
|
|
92
93
|
userPoolClientId: string;
|
|
93
94
|
userPoolId: string;
|
|
@@ -101,7 +102,7 @@ export interface CognitoUserPoolConfig {
|
|
|
101
102
|
};
|
|
102
103
|
userAttributes?: AuthConfigUserAttributes;
|
|
103
104
|
mfa?: {
|
|
104
|
-
status?:
|
|
105
|
+
status?: CognitoUserPoolConfigMfaStatus;
|
|
105
106
|
totpEnabled?: boolean;
|
|
106
107
|
smsEnabled?: boolean;
|
|
107
108
|
};
|