@aws-amplify/core 6.4.4-email-mfa-test.4e655bc.0 → 6.4.4-events.d7ac57c.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/index.js +3 -8
- package/dist/cjs/Platform/index.js.map +1 -1
- package/dist/cjs/Platform/version.js +1 -1
- package/dist/cjs/Platform/version.js.map +1 -1
- package/dist/cjs/parseAWSExports.js +20 -1
- package/dist/cjs/parseAWSExports.js.map +1 -1
- package/dist/cjs/parseAmplifyOutputs.js +10 -1
- package/dist/cjs/parseAmplifyOutputs.js.map +1 -1
- package/dist/esm/Platform/index.d.ts +0 -2
- package/dist/esm/Platform/index.mjs +3 -7
- package/dist/esm/Platform/index.mjs.map +1 -1
- 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 +1 -1
- package/dist/esm/parseAWSExports.mjs +20 -1
- package/dist/esm/parseAWSExports.mjs.map +1 -1
- package/dist/esm/parseAmplifyOutputs.mjs +10 -1
- package/dist/esm/parseAmplifyOutputs.mjs.map +1 -1
- package/dist/esm/singleton/API/types.d.ts +6 -0
- package/dist/esm/singleton/Amplify.mjs +1 -1
- package/dist/esm/singleton/AmplifyOutputs/types.d.ts +6 -0
- package/package.json +3 -3
- package/src/Platform/index.ts +2 -9
- package/src/Platform/version.ts +1 -1
- package/src/libraryUtils.ts +0 -1
- package/src/parseAWSExports.ts +24 -0
- package/src/parseAmplifyOutputs.ts +13 -0
- package/src/singleton/API/types.ts +7 -0
- package/src/singleton/AmplifyOutputs/types.ts +7 -0
|
@@ -3,18 +3,15 @@
|
|
|
3
3
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getAmplifyUserAgent = exports.getAmplifyUserAgentObject = exports.Platform =
|
|
6
|
+
exports.getAmplifyUserAgent = exports.getAmplifyUserAgentObject = exports.Platform = void 0;
|
|
7
7
|
const types_1 = require("./types");
|
|
8
8
|
const version_1 = require("./version");
|
|
9
9
|
const detectFramework_1 = require("./detectFramework");
|
|
10
10
|
const customUserAgent_1 = require("./customUserAgent");
|
|
11
11
|
const BASE_USER_AGENT = `aws-amplify`;
|
|
12
|
-
/** Sanitize Amplify version string be removing special character + and character post the special character */
|
|
13
|
-
const sanitizeAmplifyVersion = (amplifyVersion) => amplifyVersion.replace(/\+.*/, '');
|
|
14
|
-
exports.sanitizeAmplifyVersion = sanitizeAmplifyVersion;
|
|
15
12
|
class PlatformBuilder {
|
|
16
13
|
constructor() {
|
|
17
|
-
this.userAgent = `${BASE_USER_AGENT}/${
|
|
14
|
+
this.userAgent = `${BASE_USER_AGENT}/${version_1.version}`;
|
|
18
15
|
}
|
|
19
16
|
get framework() {
|
|
20
17
|
return (0, detectFramework_1.detectFramework)();
|
|
@@ -29,9 +26,7 @@ class PlatformBuilder {
|
|
|
29
26
|
}
|
|
30
27
|
exports.Platform = new PlatformBuilder();
|
|
31
28
|
const getAmplifyUserAgentObject = ({ category, action, } = {}) => {
|
|
32
|
-
const userAgent = [
|
|
33
|
-
[BASE_USER_AGENT, (0, exports.sanitizeAmplifyVersion)(version_1.version)],
|
|
34
|
-
];
|
|
29
|
+
const userAgent = [[BASE_USER_AGENT, version_1.version]];
|
|
35
30
|
if (category) {
|
|
36
31
|
userAgent.push([category, action]);
|
|
37
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/Platform/index.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.getAmplifyUserAgent = exports.getAmplifyUserAgentObject = exports.Platform =
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/Platform/index.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.getAmplifyUserAgent = exports.getAmplifyUserAgentObject = exports.Platform = void 0;\nconst types_1 = require(\"./types\");\nconst version_1 = require(\"./version\");\nconst detectFramework_1 = require(\"./detectFramework\");\nconst customUserAgent_1 = require(\"./customUserAgent\");\nconst BASE_USER_AGENT = `aws-amplify`;\nclass PlatformBuilder {\n constructor() {\n this.userAgent = `${BASE_USER_AGENT}/${version_1.version}`;\n }\n get framework() {\n return (0, detectFramework_1.detectFramework)();\n }\n get isReactNative() {\n return (this.framework === types_1.Framework.ReactNative ||\n this.framework === types_1.Framework.Expo);\n }\n observeFrameworkChanges(fcn) {\n (0, detectFramework_1.observeFrameworkChanges)(fcn);\n }\n}\nexports.Platform = new PlatformBuilder();\nconst getAmplifyUserAgentObject = ({ category, action, } = {}) => {\n const userAgent = [[BASE_USER_AGENT, version_1.version]];\n if (category) {\n userAgent.push([category, action]);\n }\n userAgent.push(['framework', (0, detectFramework_1.detectFramework)()]);\n if (category && action) {\n const customState = (0, customUserAgent_1.getCustomUserAgent)(category, action);\n if (customState) {\n customState.forEach(state => {\n userAgent.push(state);\n });\n }\n }\n return userAgent;\n};\nexports.getAmplifyUserAgentObject = getAmplifyUserAgentObject;\nconst getAmplifyUserAgent = (customUserAgentDetails) => {\n const userAgent = (0, exports.getAmplifyUserAgentObject)(customUserAgentDetails);\n const userAgentString = userAgent\n .map(([agentKey, agentValue]) => agentKey && agentValue ? `${agentKey}/${agentValue}` : agentKey)\n .join(' ');\n return userAgentString;\n};\nexports.getAmplifyUserAgent = getAmplifyUserAgent;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC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+
exports.version = '6.6.4-events.d7ac57c.0+d7ac57c';
|
|
7
7
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.6.4-
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.6.4-events.d7ac57c.0+d7ac57c';\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AACzB;AACA,OAAO,CAAC,OAAO,GAAG,gCAAgC;;"}
|
|
@@ -37,7 +37,7 @@ const parseAWSExports = (config = {}) => {
|
|
|
37
37
|
recoverySuggestion: 'Ensure passing the config object imported from `amplifyconfiguration.json`.',
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
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;
|
|
40
|
+
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, data, events, } = config;
|
|
41
41
|
const amplifyConfig = {};
|
|
42
42
|
// Analytics
|
|
43
43
|
if (aws_mobile_analytics_app_id) {
|
|
@@ -99,6 +99,25 @@ const parseAWSExports = (config = {}) => {
|
|
|
99
99
|
amplifyConfig.API.GraphQL.modelIntrospection = modelIntrospection;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
+
// Events
|
|
103
|
+
if ((data && data.events) || events) {
|
|
104
|
+
const eventsConfig = data.events ?? events;
|
|
105
|
+
// @ts-expect-error temp
|
|
106
|
+
amplifyConfig.API = amplifyConfig.API ?? {};
|
|
107
|
+
// @ts-expect-error temp
|
|
108
|
+
amplifyConfig.API.GraphQL = amplifyConfig.API.GraphQL ?? {};
|
|
109
|
+
// @ts-expect-error temp
|
|
110
|
+
amplifyConfig.API.GraphQL = {
|
|
111
|
+
// @ts-expect-error temp
|
|
112
|
+
...amplifyConfig.API.GraphQL,
|
|
113
|
+
events: {
|
|
114
|
+
url: eventsConfig.url,
|
|
115
|
+
region: eventsConfig.aws_region,
|
|
116
|
+
defaultAuthMode: eventsConfig.default_authorization_type,
|
|
117
|
+
apiKey: eventsConfig.aws_region,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
102
121
|
// Auth
|
|
103
122
|
const mfaConfig = aws_cognito_mfa_configuration
|
|
104
123
|
? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseAWSExports.js","sources":["../../src/parseAWSExports.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.parseAWSExports = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst Logger_1 = require(\"./Logger\");\nconst errors_1 = require(\"./errors\");\nconst logger = new Logger_1.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 */\nconst parseAWSExports = (config = {}) => {\n if (!Object.prototype.hasOwnProperty.call(config, 'aws_project_region')) {\n throw new errors_1.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};\nexports.parseAWSExports = parseAWSExports;\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":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACjC;AACA;AACA,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrC,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;AAC7D,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;AACA,MAAM,eAAe,GAAG,CAAC,MAAM,GAAG,EAAE,KAAK;AACzC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAAE;AAC7E,QAAQ,MAAM,IAAI,QAAQ,CAAC,YAAY,CAAC;AACxC,YAAY,IAAI,EAAE,2BAA2B;AAC7C,YAAY,OAAO,EAAE,2BAA2B;AAChD,YAAY,kBAAkB,EAAE,8EAA8E;AAC9G,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAAM,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,2BAA2B,EAAE,kBAAkB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,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.js","sources":["../../src/parseAWSExports.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.parseAWSExports = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst Logger_1 = require(\"./Logger\");\nconst errors_1 = require(\"./errors\");\nconst logger = new Logger_1.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 */\nconst parseAWSExports = (config = {}) => {\n if (!Object.prototype.hasOwnProperty.call(config, 'aws_project_region')) {\n throw new errors_1.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, data, events, } = 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 // Events\n if ((data && data.events) || events) {\n const eventsConfig = data.events ?? events;\n // @ts-expect-error temp\n amplifyConfig.API = amplifyConfig.API ?? {};\n // @ts-expect-error temp\n amplifyConfig.API.GraphQL = amplifyConfig.API.GraphQL ?? {};\n // @ts-expect-error temp\n amplifyConfig.API.GraphQL = {\n // @ts-expect-error temp\n ...amplifyConfig.API.GraphQL,\n events: {\n url: eventsConfig.url,\n region: eventsConfig.aws_region,\n defaultAuthMode: eventsConfig.default_authorization_type,\n apiKey: eventsConfig.aws_region,\n },\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};\nexports.parseAWSExports = parseAWSExports;\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":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACjC;AACA;AACA,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrC,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;AAC7D,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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Q,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;;"}
|
|
@@ -119,13 +119,22 @@ function parseData(amplifyOutputsDataProperties) {
|
|
|
119
119
|
if (!amplifyOutputsDataProperties) {
|
|
120
120
|
return undefined;
|
|
121
121
|
}
|
|
122
|
-
const { aws_region, default_authorization_type, url, api_key, model_introspection, } = amplifyOutputsDataProperties;
|
|
122
|
+
const { aws_region, default_authorization_type, url, api_key, model_introspection, events, } = amplifyOutputsDataProperties;
|
|
123
123
|
const GraphQL = {
|
|
124
124
|
endpoint: url,
|
|
125
125
|
defaultAuthMode: getGraphQLAuthMode(default_authorization_type),
|
|
126
126
|
region: aws_region,
|
|
127
127
|
apiKey: api_key,
|
|
128
128
|
modelIntrospection: model_introspection,
|
|
129
|
+
// TODO: clean up
|
|
130
|
+
events: events === undefined
|
|
131
|
+
? undefined
|
|
132
|
+
: {
|
|
133
|
+
url: events.url,
|
|
134
|
+
region: events.aws_region,
|
|
135
|
+
apiKey: events.api_key,
|
|
136
|
+
defaultAuthMode: getGraphQLAuthMode(events.default_authorization_type),
|
|
137
|
+
},
|
|
129
138
|
};
|
|
130
139
|
return {
|
|
131
140
|
GraphQL,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseAmplifyOutputs.js","sources":["../../src/parseAmplifyOutputs.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.parseAmplifyOutputs = exports.parseAnalytics = exports.isAmplifyOutputs = void 0;\nfunction 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}\nexports.isAmplifyOutputs = isAmplifyOutputs;\nfunction parseStorage(amplifyOutputsStorageProperties) {\n if (!amplifyOutputsStorageProperties) {\n return undefined;\n }\n const { bucket_name, aws_region, buckets } = amplifyOutputsStorageProperties;\n return {\n S3: {\n bucket: bucket_name,\n region: aws_region,\n buckets: buckets && createBucketInfoMap(buckets),\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) {\n authConfig.Cognito.loginWith = {\n ...authConfig.Cognito.loginWith,\n email: username_attributes.includes('email'),\n phone: username_attributes.includes('phone_number'),\n // Signing in with a username is not currently supported in Gen2, this should always evaluate to false\n username: username_attributes.includes('username'),\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}\nfunction 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}\nexports.parseAnalytics = parseAnalytics;\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}\nfunction 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}\nexports.parseAmplifyOutputs = parseAmplifyOutputs;\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.reduce((oAuthProviders, provider) => {\n if (providerNames[provider] !== undefined) {\n oAuthProviders.push(providerNames[provider]);\n }\n return oAuthProviders;\n }, []);\n}\nfunction getMfaStatus(mfaConfiguration) {\n if (mfaConfiguration === 'OPTIONAL')\n return 'optional';\n if (mfaConfiguration === 'REQUIRED')\n return 'on';\n return 'off';\n}\nfunction createBucketInfoMap(buckets) {\n const mappedBuckets = {};\n buckets.forEach(({ name, bucket_name: bucketName, aws_region: region }) => {\n if (name in mappedBuckets) {\n throw new Error(`Duplicate friendly name found: ${name}. Name must be unique.`);\n }\n mappedBuckets[name] = {\n bucketName,\n region,\n };\n });\n return mappedBuckets;\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AACzF,SAAS,gBAAgB,CAAC,MAAM,EAAE;AAClC;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,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AAC5C,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,OAAO,EAAE,GAAG,+BAA+B,CAAC;AACjF,IAAI,OAAO;AACX,QAAQ,EAAE,EAAE;AACZ,YAAY,MAAM,EAAE,WAAW;AAC/B,YAAY,MAAM,EAAE,UAAU;AAC9B,YAAY,OAAO,EAAE,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC;AAC5D,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,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AAC3C,IAAI,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,QAAQ,KAAK;AAC1D,QAAQ,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE;AACnD,YAAY,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzD,SAAS;AACT,QAAQ,OAAO,cAAc,CAAC;AAC9B,KAAK,EAAE,EAAE,CAAC,CAAC;AACX,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,CAAC;AACD,SAAS,mBAAmB,CAAC,OAAO,EAAE;AACtC,IAAI,MAAM,aAAa,GAAG,EAAE,CAAC;AAC7B,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK;AAC/E,QAAQ,IAAI,IAAI,IAAI,aAAa,EAAE;AACnC,YAAY,MAAM,IAAI,KAAK,CAAC,CAAC,+BAA+B,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAC5F,SAAS;AACT,QAAQ,aAAa,CAAC,IAAI,CAAC,GAAG;AAC9B,YAAY,UAAU;AACtB,YAAY,MAAM;AAClB,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,aAAa,CAAC;AACzB;;"}
|
|
1
|
+
{"version":3,"file":"parseAmplifyOutputs.js","sources":["../../src/parseAmplifyOutputs.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.parseAmplifyOutputs = exports.parseAnalytics = exports.isAmplifyOutputs = void 0;\nfunction 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}\nexports.isAmplifyOutputs = isAmplifyOutputs;\nfunction parseStorage(amplifyOutputsStorageProperties) {\n if (!amplifyOutputsStorageProperties) {\n return undefined;\n }\n const { bucket_name, aws_region, buckets } = amplifyOutputsStorageProperties;\n return {\n S3: {\n bucket: bucket_name,\n region: aws_region,\n buckets: buckets && createBucketInfoMap(buckets),\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) {\n authConfig.Cognito.loginWith = {\n ...authConfig.Cognito.loginWith,\n email: username_attributes.includes('email'),\n phone: username_attributes.includes('phone_number'),\n // Signing in with a username is not currently supported in Gen2, this should always evaluate to false\n username: username_attributes.includes('username'),\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}\nfunction 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}\nexports.parseAnalytics = parseAnalytics;\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, events, } = 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 // TODO: clean up\n events: events === undefined\n ? undefined\n : {\n url: events.url,\n region: events.aws_region,\n apiKey: events.api_key,\n defaultAuthMode: getGraphQLAuthMode(events.default_authorization_type),\n },\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}\nfunction 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}\nexports.parseAmplifyOutputs = parseAmplifyOutputs;\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.reduce((oAuthProviders, provider) => {\n if (providerNames[provider] !== undefined) {\n oAuthProviders.push(providerNames[provider]);\n }\n return oAuthProviders;\n }, []);\n}\nfunction getMfaStatus(mfaConfiguration) {\n if (mfaConfiguration === 'OPTIONAL')\n return 'optional';\n if (mfaConfiguration === 'REQUIRED')\n return 'on';\n return 'off';\n}\nfunction createBucketInfoMap(buckets) {\n const mappedBuckets = {};\n buckets.forEach(({ name, bucket_name: bucketName, aws_region: region }) => {\n if (name in mappedBuckets) {\n throw new Error(`Duplicate friendly name found: ${name}. Name must be unique.`);\n }\n mappedBuckets[name] = {\n bucketName,\n region,\n };\n });\n return mappedBuckets;\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AACzF,SAAS,gBAAgB,CAAC,MAAM,EAAE;AAClC;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,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AAC5C,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,OAAO,EAAE,GAAG,+BAA+B,CAAC;AACjF,IAAI,OAAO;AACX,QAAQ,EAAE,EAAE;AACZ,YAAY,MAAM,EAAE,WAAW;AAC/B,YAAY,MAAM,EAAE,UAAU;AAC9B,YAAY,OAAO,EAAE,OAAO,IA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AAU,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK;AAC/E,QAAQ,IAAI,IAAI,IAAI,aAAa,EAAE;AACnC,YAAY,MAAM,IAAI,KAAK,CAAC,CAAC,+BAA+B,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAC5F,SAAS;AACT,QAAQ,aAAa,CAAC,IAAI,CAAC,GAAG;AAC9B,YAAY,UAAU;AACtB,YAAY,MAAM;AAClB,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,aAAa,CAAC;AACzB;;"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { UserAgent as AWSUserAgent } from '@aws-sdk/types';
|
|
2
2
|
import { CustomUserAgentDetails, Framework } from './types';
|
|
3
|
-
/** Sanitize Amplify version string be removing special character + and character post the special character */
|
|
4
|
-
export declare const sanitizeAmplifyVersion: (amplifyVersion: string) => string;
|
|
5
3
|
declare class PlatformBuilder {
|
|
6
4
|
userAgent: string;
|
|
7
5
|
get framework(): Framework;
|
|
@@ -6,11 +6,9 @@ import { getCustomUserAgent } from './customUserAgent.mjs';
|
|
|
6
6
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
7
|
// SPDX-License-Identifier: Apache-2.0
|
|
8
8
|
const BASE_USER_AGENT = `aws-amplify`;
|
|
9
|
-
/** Sanitize Amplify version string be removing special character + and character post the special character */
|
|
10
|
-
const sanitizeAmplifyVersion = (amplifyVersion) => amplifyVersion.replace(/\+.*/, '');
|
|
11
9
|
class PlatformBuilder {
|
|
12
10
|
constructor() {
|
|
13
|
-
this.userAgent = `${BASE_USER_AGENT}/${
|
|
11
|
+
this.userAgent = `${BASE_USER_AGENT}/${version}`;
|
|
14
12
|
}
|
|
15
13
|
get framework() {
|
|
16
14
|
return detectFramework();
|
|
@@ -25,9 +23,7 @@ class PlatformBuilder {
|
|
|
25
23
|
}
|
|
26
24
|
const Platform = new PlatformBuilder();
|
|
27
25
|
const getAmplifyUserAgentObject = ({ category, action, } = {}) => {
|
|
28
|
-
const userAgent = [
|
|
29
|
-
[BASE_USER_AGENT, sanitizeAmplifyVersion(version)],
|
|
30
|
-
];
|
|
26
|
+
const userAgent = [[BASE_USER_AGENT, version]];
|
|
31
27
|
if (category) {
|
|
32
28
|
userAgent.push([category, action]);
|
|
33
29
|
}
|
|
@@ -50,5 +46,5 @@ const getAmplifyUserAgent = (customUserAgentDetails) => {
|
|
|
50
46
|
return userAgentString;
|
|
51
47
|
};
|
|
52
48
|
|
|
53
|
-
export { Platform, getAmplifyUserAgent, getAmplifyUserAgentObject
|
|
49
|
+
export { Platform, getAmplifyUserAgent, getAmplifyUserAgentObject };
|
|
54
50
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/Platform/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Framework } from './types';\nimport { version } from './version';\nimport { detectFramework, observeFrameworkChanges } from './detectFramework';\nimport { getCustomUserAgent } from './customUserAgent';\nconst BASE_USER_AGENT = `aws-amplify`;\
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/Platform/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Framework } from './types';\nimport { version } from './version';\nimport { detectFramework, observeFrameworkChanges } from './detectFramework';\nimport { getCustomUserAgent } from './customUserAgent';\nconst BASE_USER_AGENT = `aws-amplify`;\nclass PlatformBuilder {\n constructor() {\n this.userAgent = `${BASE_USER_AGENT}/${version}`;\n }\n get framework() {\n return detectFramework();\n }\n get isReactNative() {\n return (this.framework === Framework.ReactNative ||\n this.framework === Framework.Expo);\n }\n observeFrameworkChanges(fcn) {\n observeFrameworkChanges(fcn);\n }\n}\nexport const Platform = new PlatformBuilder();\nexport const getAmplifyUserAgentObject = ({ category, action, } = {}) => {\n const userAgent = [[BASE_USER_AGENT, version]];\n if (category) {\n userAgent.push([category, action]);\n }\n userAgent.push(['framework', detectFramework()]);\n if (category && action) {\n const customState = getCustomUserAgent(category, action);\n if (customState) {\n customState.forEach(state => {\n userAgent.push(state);\n });\n }\n }\n return userAgent;\n};\nexport const getAmplifyUserAgent = (customUserAgentDetails) => {\n const userAgent = getAmplifyUserAgentObject(customUserAgentDetails);\n const userAgentString = userAgent\n .map(([agentKey, agentValue]) => agentKey && agentValue ? `${agentKey}/${agentValue}` : agentKey)\n .join(' ');\n return userAgentString;\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKA,MAAM,eAAe,GAAG,CAAC,WAAW,CAAC,CAAC;AACtC,MAAM,eAAe,CAAC;AACtB,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AACzD,KAAK;AACL,IAAI,IAAI,SAAS,GAAG;AACpB,QAAQ,OAAO,eAAe,EAAE,CAAC;AACjC,KAAK;AACL,IAAI,IAAI,aAAa,GAAG;AACxB,QAAQ,QAAQ,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,WAAW;AACxD,YAAY,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI,EAAE;AAC/C,KAAK;AACL,IAAI,uBAAuB,CAAC,GAAG,EAAE;AACjC,QAAQ,uBAAuB,CAAC,GAAG,CAAC,CAAC;AACrC,KAAK;AACL,CAAC;AACW,MAAC,QAAQ,GAAG,IAAI,eAAe,GAAG;AAClC,MAAC,yBAAyB,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,EAAE,KAAK;AACzE,IAAI,MAAM,SAAS,GAAG,CAAC,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;AACnD,IAAI,IAAI,QAAQ,EAAE;AAClB,QAAQ,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAC3C,KAAK;AACL,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;AACrD,IAAI,IAAI,QAAQ,IAAI,MAAM,EAAE;AAC5B,QAAQ,MAAM,WAAW,GAAG,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AACjE,QAAQ,IAAI,WAAW,EAAE;AACzB,YAAY,WAAW,CAAC,OAAO,CAAC,KAAK,IAAI;AACzC,gBAAgB,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtC,aAAa,CAAC,CAAC;AACf,SAAS;AACT,KAAK;AACL,IAAI,OAAO,SAAS,CAAC;AACrB,EAAE;AACU,MAAC,mBAAmB,GAAG,CAAC,sBAAsB,KAAK;AAC/D,IAAI,MAAM,SAAS,GAAG,yBAAyB,CAAC,sBAAsB,CAAC,CAAC;AACxE,IAAI,MAAM,eAAe,GAAG,SAAS;AACrC,SAAS,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,KAAK,QAAQ,IAAI,UAAU,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,QAAQ,CAAC;AACzG,SAAS,IAAI,CAAC,GAAG,CAAC,CAAC;AACnB,IAAI,OAAO,eAAe,CAAC;AAC3B;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.6.4-
|
|
1
|
+
export declare const version = "6.6.4-events.d7ac57c.0+d7ac57c";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.6.4-
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.6.4-events.d7ac57c.0+d7ac57c';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
|
|
@@ -16,7 +16,7 @@ export { Signer } from './Signer';
|
|
|
16
16
|
export { JWT, CognitoIdentityPoolConfig, JwtPayload, AuthStandardAttributeKey, AuthVerifiableAttributeKey, AWSCredentials, } from './singleton/Auth/types';
|
|
17
17
|
export { haveCredentialsChanged } from './utils/haveCredentialsChanged';
|
|
18
18
|
export { Platform, getAmplifyUserAgentObject, getAmplifyUserAgent, } from './Platform';
|
|
19
|
-
export { AiAction, ApiAction, AuthAction, AnalyticsAction, Category, CustomUserAgentDetails, DataStoreAction, Framework, GeoAction, InteractionsAction, InAppMessagingAction, PredictionsAction, PubSubAction, PushNotificationAction, StorageAction, SetCustomUserAgentInput, StorageUserAgentInput, AuthUserAgentInput, InAppMessagingUserAgentInput, GeoUserAgentInput,
|
|
19
|
+
export { AiAction, ApiAction, AuthAction, AnalyticsAction, Category, CustomUserAgentDetails, DataStoreAction, Framework, GeoAction, InteractionsAction, InAppMessagingAction, PredictionsAction, PubSubAction, PushNotificationAction, StorageAction, SetCustomUserAgentInput, StorageUserAgentInput, AuthUserAgentInput, InAppMessagingUserAgentInput, GeoUserAgentInput, } from './Platform/types';
|
|
20
20
|
export { setCustomUserAgent } from './Platform/customUserAgent';
|
|
21
21
|
export { AmplifyError, PlatformNotSupportedError, createAssertionFunction, ApiError, ApiErrorParams, ApiErrorResponse, } from './errors';
|
|
22
22
|
export { AmplifyErrorCode, AmplifyErrorMap, AmplifyErrorParams, AssertionFunction, ServiceError, } from './types';
|
|
@@ -36,7 +36,7 @@ const parseAWSExports = (config = {}) => {
|
|
|
36
36
|
recoverySuggestion: 'Ensure passing the config object imported from `amplifyconfiguration.json`.',
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
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;
|
|
39
|
+
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, data, events, } = config;
|
|
40
40
|
const amplifyConfig = {};
|
|
41
41
|
// Analytics
|
|
42
42
|
if (aws_mobile_analytics_app_id) {
|
|
@@ -98,6 +98,25 @@ const parseAWSExports = (config = {}) => {
|
|
|
98
98
|
amplifyConfig.API.GraphQL.modelIntrospection = modelIntrospection;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
+
// Events
|
|
102
|
+
if ((data && data.events) || events) {
|
|
103
|
+
const eventsConfig = data.events ?? events;
|
|
104
|
+
// @ts-expect-error temp
|
|
105
|
+
amplifyConfig.API = amplifyConfig.API ?? {};
|
|
106
|
+
// @ts-expect-error temp
|
|
107
|
+
amplifyConfig.API.GraphQL = amplifyConfig.API.GraphQL ?? {};
|
|
108
|
+
// @ts-expect-error temp
|
|
109
|
+
amplifyConfig.API.GraphQL = {
|
|
110
|
+
// @ts-expect-error temp
|
|
111
|
+
...amplifyConfig.API.GraphQL,
|
|
112
|
+
events: {
|
|
113
|
+
url: eventsConfig.url,
|
|
114
|
+
region: eventsConfig.aws_region,
|
|
115
|
+
defaultAuthMode: eventsConfig.default_authorization_type,
|
|
116
|
+
apiKey: eventsConfig.aws_region,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
101
120
|
// Auth
|
|
102
121
|
const mfaConfig = aws_cognito_mfa_configuration
|
|
103
122
|
? {
|
|
@@ -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 = {\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,kBAAkB,EAAE,8EAA8E;AAC9G,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAAM,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,eAAe,EAAE,4BAA4B,EAAE,uCAAuC,EAAE,6BAA6B,EAA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W,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, data, events, } = 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 // Events\n if ((data && data.events) || events) {\n const eventsConfig = data.events ?? events;\n // @ts-expect-error temp\n amplifyConfig.API = amplifyConfig.API ?? {};\n // @ts-expect-error temp\n amplifyConfig.API.GraphQL = amplifyConfig.API.GraphQL ?? {};\n // @ts-expect-error temp\n amplifyConfig.API.GraphQL = {\n // @ts-expect-error temp\n ...amplifyConfig.API.GraphQL,\n events: {\n url: eventsConfig.url,\n region: eventsConfig.aws_region,\n defaultAuthMode: eventsConfig.default_authorization_type,\n apiKey: eventsConfig.aws_region,\n },\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,kBAAkB,EAAE,8EAA8E;AAC9G,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAAM,EAAE,kBAAkB,EAAE,8BAA8B,E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AAC9D,wBAAwB,QAAQ,EAAE,EAAE,OAAO,EAAE;AAC7C,qBAAqB;AACrB,iBAAiB;AACjB,aAAa;AACb,cAAc,WAAW,CAAC;AAC1B,KAAK;AACL,IAAI,OAAO,aAAa,CAAC;AACzB,EAAE;AACF,MAAM,cAAc,GAAG,CAAC,WAAW,KAAK,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AACtE,MAAM,cAAc,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,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;;;;"}
|
|
@@ -113,13 +113,22 @@ function parseData(amplifyOutputsDataProperties) {
|
|
|
113
113
|
if (!amplifyOutputsDataProperties) {
|
|
114
114
|
return undefined;
|
|
115
115
|
}
|
|
116
|
-
const { aws_region, default_authorization_type, url, api_key, model_introspection, } = amplifyOutputsDataProperties;
|
|
116
|
+
const { aws_region, default_authorization_type, url, api_key, model_introspection, events, } = amplifyOutputsDataProperties;
|
|
117
117
|
const GraphQL = {
|
|
118
118
|
endpoint: url,
|
|
119
119
|
defaultAuthMode: getGraphQLAuthMode(default_authorization_type),
|
|
120
120
|
region: aws_region,
|
|
121
121
|
apiKey: api_key,
|
|
122
122
|
modelIntrospection: model_introspection,
|
|
123
|
+
// TODO: clean up
|
|
124
|
+
events: events === undefined
|
|
125
|
+
? undefined
|
|
126
|
+
: {
|
|
127
|
+
url: events.url,
|
|
128
|
+
region: events.aws_region,
|
|
129
|
+
apiKey: events.api_key,
|
|
130
|
+
defaultAuthMode: getGraphQLAuthMode(events.default_authorization_type),
|
|
131
|
+
},
|
|
123
132
|
};
|
|
124
133
|
return {
|
|
125
134
|
GraphQL,
|
|
@@ -1 +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, buckets } = amplifyOutputsStorageProperties;\n return {\n S3: {\n bucket: bucket_name,\n region: aws_region,\n buckets: buckets && createBucketInfoMap(buckets),\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) {\n authConfig.Cognito.loginWith = {\n ...authConfig.Cognito.loginWith,\n email: username_attributes.includes('email'),\n phone: username_attributes.includes('phone_number'),\n // Signing in with a username is not currently supported in Gen2, this should always evaluate to false\n username: username_attributes.includes('username'),\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.reduce((oAuthProviders, provider) => {\n if (providerNames[provider] !== undefined) {\n oAuthProviders.push(providerNames[provider]);\n }\n return oAuthProviders;\n }, []);\n}\nfunction getMfaStatus(mfaConfiguration) {\n if (mfaConfiguration === 'OPTIONAL')\n return 'optional';\n if (mfaConfiguration === 'REQUIRED')\n return 'on';\n return 'off';\n}\nfunction createBucketInfoMap(buckets) {\n const mappedBuckets = {};\n buckets.forEach(({ name, bucket_name: bucketName, aws_region: region }) => {\n if (name in mappedBuckets) {\n throw new Error(`Duplicate friendly name found: ${name}. Name must be unique.`);\n }\n mappedBuckets[name] = {\n bucketName,\n region,\n };\n });\n return mappedBuckets;\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,OAAO,EAAE,GAAG,+BAA+B,CAAC;AACjF,IAAI,OAAO;AACX,QAAQ,EAAE,EAAE;AACZ,YAAY,MAAM,EAAE,WAAW;AAC/B,YAAY,MAAM,EAAE,UAAU;AAC9B,YAAY,OAAO,EAAE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mplifyOutputs.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, buckets } = amplifyOutputsStorageProperties;\n return {\n S3: {\n bucket: bucket_name,\n region: aws_region,\n buckets: buckets && createBucketInfoMap(buckets),\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) {\n authConfig.Cognito.loginWith = {\n ...authConfig.Cognito.loginWith,\n email: username_attributes.includes('email'),\n phone: username_attributes.includes('phone_number'),\n // Signing in with a username is not currently supported in Gen2, this should always evaluate to false\n username: username_attributes.includes('username'),\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, events, } = 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 // TODO: clean up\n events: events === undefined\n ? undefined\n : {\n url: events.url,\n region: events.aws_region,\n apiKey: events.api_key,\n defaultAuthMode: getGraphQLAuthMode(events.default_authorization_type),\n },\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.reduce((oAuthProviders, provider) => {\n if (providerNames[provider] !== undefined) {\n oAuthProviders.push(providerNames[provider]);\n }\n return oAuthProviders;\n }, []);\n}\nfunction getMfaStatus(mfaConfiguration) {\n if (mfaConfiguration === 'OPTIONAL')\n return 'optional';\n if (mfaConfiguration === 'REQUIRED')\n return 'on';\n return 'off';\n}\nfunction createBucketInfoMap(buckets) {\n const mappedBuckets = {};\n buckets.forEach(({ name, bucket_name: bucketName, aws_region: region }) => {\n if (name in mappedBuckets) {\n throw new Error(`Duplicate friendly name found: ${name}. Name must be unique.`);\n }\n mappedBuckets[name] = {\n bucketName,\n region,\n };\n });\n return mappedBuckets;\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,OAAO,EAAE,GAAG,+BAA+B,CAAC;AACjF,IAAI,OAAO;AACX,QAAQ,EAAE,EAAE;AACZ,YAAY,MAAM,EAAE,WAAW;AAC/B,YAAY,MAAM,EAAE,UAAU;AAC9B,YAAY,OAAO,EAAE,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC;AAC5D,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,E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"}
|
|
@@ -41,6 +41,12 @@ export interface APIGraphQLConfig {
|
|
|
41
41
|
*/
|
|
42
42
|
defaultAuthMode: GraphQLAuthMode;
|
|
43
43
|
modelIntrospection?: ModelIntrospectionSchema;
|
|
44
|
+
events?: {
|
|
45
|
+
url: string;
|
|
46
|
+
region: string;
|
|
47
|
+
defaultAuthMode: GraphQLAuthMode;
|
|
48
|
+
apiKey?: string;
|
|
49
|
+
};
|
|
44
50
|
}
|
|
45
51
|
export interface APIRestConfig {
|
|
46
52
|
/**
|
|
@@ -12,8 +12,8 @@ import './Auth/utils/errorHelpers.mjs';
|
|
|
12
12
|
import { AuthClass } from './Auth/index.mjs';
|
|
13
13
|
import '@aws-crypto/sha256-js';
|
|
14
14
|
import '@smithy/util-hex-encoding';
|
|
15
|
-
import '../Platform/index.mjs';
|
|
16
15
|
import '../Platform/types.mjs';
|
|
16
|
+
import '../Platform/detection/index.mjs';
|
|
17
17
|
import '../BackgroundProcessManager/types.mjs';
|
|
18
18
|
import '../Reachability/Reachability.mjs';
|
|
19
19
|
import '../utils/sessionListener/index.mjs';
|
|
@@ -75,6 +75,12 @@ export interface AmplifyOutputsDataProperties {
|
|
|
75
75
|
model_introspection?: object;
|
|
76
76
|
api_key?: string;
|
|
77
77
|
conflict_resolution_mode?: string;
|
|
78
|
+
events?: {
|
|
79
|
+
url: string;
|
|
80
|
+
aws_region: string;
|
|
81
|
+
default_authorization_type: string;
|
|
82
|
+
api_key?: string;
|
|
83
|
+
};
|
|
78
84
|
}
|
|
79
85
|
export interface AmplifyOutputsNotificationsProperties {
|
|
80
86
|
aws_region: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/core",
|
|
3
|
-
"version": "6.4.4-
|
|
3
|
+
"version": "6.4.4-events.d7ac57c.0+d7ac57c",
|
|
4
4
|
"description": "Core category of aws-amplify",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"uuid": "^9.0.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@aws-amplify/react-native": "1.1.7-
|
|
63
|
+
"@aws-amplify/react-native": "1.1.7-events.d7ac57c.0+d7ac57c",
|
|
64
64
|
"@types/js-cookie": "3.0.2",
|
|
65
65
|
"genversion": "^2.2.0",
|
|
66
66
|
"typescript": "5.0.2"
|
|
@@ -192,5 +192,5 @@
|
|
|
192
192
|
]
|
|
193
193
|
}
|
|
194
194
|
},
|
|
195
|
-
"gitHead": "
|
|
195
|
+
"gitHead": "d7ac57cf0d4c02aa74b5d27ad4e625a4dd996b17"
|
|
196
196
|
}
|
package/src/Platform/index.ts
CHANGED
|
@@ -10,12 +10,8 @@ import { getCustomUserAgent } from './customUserAgent';
|
|
|
10
10
|
|
|
11
11
|
const BASE_USER_AGENT = `aws-amplify`;
|
|
12
12
|
|
|
13
|
-
/** Sanitize Amplify version string be removing special character + and character post the special character */
|
|
14
|
-
export const sanitizeAmplifyVersion = (amplifyVersion: string) =>
|
|
15
|
-
amplifyVersion.replace(/\+.*/, '');
|
|
16
|
-
|
|
17
13
|
class PlatformBuilder {
|
|
18
|
-
userAgent = `${BASE_USER_AGENT}/${
|
|
14
|
+
userAgent = `${BASE_USER_AGENT}/${version}`;
|
|
19
15
|
get framework() {
|
|
20
16
|
return detectFramework();
|
|
21
17
|
}
|
|
@@ -38,10 +34,7 @@ export const getAmplifyUserAgentObject = ({
|
|
|
38
34
|
category,
|
|
39
35
|
action,
|
|
40
36
|
}: CustomUserAgentDetails = {}): AWSUserAgent => {
|
|
41
|
-
const userAgent: AWSUserAgent = [
|
|
42
|
-
[BASE_USER_AGENT, sanitizeAmplifyVersion(version)],
|
|
43
|
-
];
|
|
44
|
-
|
|
37
|
+
const userAgent: AWSUserAgent = [[BASE_USER_AGENT, version]];
|
|
45
38
|
if (category) {
|
|
46
39
|
userAgent.push([category, action]);
|
|
47
40
|
}
|
package/src/Platform/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '6.6.4-
|
|
2
|
+
export const version = '6.6.4-events.d7ac57c.0+d7ac57c';
|
package/src/libraryUtils.ts
CHANGED
package/src/parseAWSExports.ts
CHANGED
|
@@ -77,6 +77,8 @@ export const parseAWSExports = (
|
|
|
77
77
|
aws_cloud_logic_custom,
|
|
78
78
|
Notifications,
|
|
79
79
|
modelIntrospection,
|
|
80
|
+
data,
|
|
81
|
+
events,
|
|
80
82
|
} = config;
|
|
81
83
|
const amplifyConfig: ResourcesConfig = {};
|
|
82
84
|
|
|
@@ -146,6 +148,28 @@ export const parseAWSExports = (
|
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
150
|
|
|
151
|
+
// Events
|
|
152
|
+
if ((data && data.events) || events) {
|
|
153
|
+
const eventsConfig = data.events ?? events;
|
|
154
|
+
|
|
155
|
+
// @ts-expect-error temp
|
|
156
|
+
amplifyConfig.API = amplifyConfig.API ?? {};
|
|
157
|
+
// @ts-expect-error temp
|
|
158
|
+
amplifyConfig.API.GraphQL = amplifyConfig.API.GraphQL ?? {};
|
|
159
|
+
|
|
160
|
+
// @ts-expect-error temp
|
|
161
|
+
amplifyConfig.API.GraphQL = {
|
|
162
|
+
// @ts-expect-error temp
|
|
163
|
+
...amplifyConfig.API.GraphQL,
|
|
164
|
+
events: {
|
|
165
|
+
url: eventsConfig.url,
|
|
166
|
+
region: eventsConfig.aws_region,
|
|
167
|
+
defaultAuthMode: eventsConfig.default_authorization_type,
|
|
168
|
+
apiKey: eventsConfig.aws_region,
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
149
173
|
// Auth
|
|
150
174
|
const mfaConfig = aws_cognito_mfa_configuration
|
|
151
175
|
? {
|
|
@@ -208,6 +208,7 @@ function parseData(
|
|
|
208
208
|
url,
|
|
209
209
|
api_key,
|
|
210
210
|
model_introspection,
|
|
211
|
+
events,
|
|
211
212
|
} = amplifyOutputsDataProperties;
|
|
212
213
|
|
|
213
214
|
const GraphQL: APIGraphQLConfig = {
|
|
@@ -216,6 +217,18 @@ function parseData(
|
|
|
216
217
|
region: aws_region,
|
|
217
218
|
apiKey: api_key,
|
|
218
219
|
modelIntrospection: model_introspection as ModelIntrospectionSchema,
|
|
220
|
+
// TODO: clean up
|
|
221
|
+
events:
|
|
222
|
+
events === undefined
|
|
223
|
+
? undefined
|
|
224
|
+
: {
|
|
225
|
+
url: events.url,
|
|
226
|
+
region: events.aws_region,
|
|
227
|
+
apiKey: events.api_key,
|
|
228
|
+
defaultAuthMode: getGraphQLAuthMode(
|
|
229
|
+
events.default_authorization_type,
|
|
230
|
+
),
|
|
231
|
+
},
|
|
219
232
|
};
|
|
220
233
|
|
|
221
234
|
return {
|
|
@@ -45,6 +45,13 @@ export interface APIGraphQLConfig {
|
|
|
45
45
|
*/
|
|
46
46
|
defaultAuthMode: GraphQLAuthMode;
|
|
47
47
|
modelIntrospection?: ModelIntrospectionSchema;
|
|
48
|
+
// @experimental
|
|
49
|
+
events?: {
|
|
50
|
+
url: string;
|
|
51
|
+
region: string;
|
|
52
|
+
defaultAuthMode: GraphQLAuthMode;
|
|
53
|
+
apiKey?: string;
|
|
54
|
+
};
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
export interface APIRestConfig {
|
|
@@ -92,6 +92,13 @@ export interface AmplifyOutputsDataProperties {
|
|
|
92
92
|
model_introspection?: object;
|
|
93
93
|
api_key?: string;
|
|
94
94
|
conflict_resolution_mode?: string;
|
|
95
|
+
// @experimental
|
|
96
|
+
events?: {
|
|
97
|
+
url: string;
|
|
98
|
+
aws_region: string;
|
|
99
|
+
default_authorization_type: string;
|
|
100
|
+
api_key?: string;
|
|
101
|
+
};
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
export interface AmplifyOutputsNotificationsProperties {
|