@aws-amplify/core 6.0.6-unstable.f2b7a8d.0 → 6.0.7-unstable.1e96034.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Platform/version.js +1 -1
- package/dist/cjs/Platform/version.js.map +1 -1
- package/dist/cjs/parseAWSExports.js +6 -6
- package/dist/cjs/parseAWSExports.js.map +1 -1
- package/dist/cjs/utils/getClientInfo/getClientInfo.js +12 -6
- package/dist/cjs/utils/getClientInfo/getClientInfo.js.map +1 -1
- package/dist/esm/Hub/types/AuthTypes.d.ts +8 -0
- package/dist/esm/Platform/version.d.ts +1 -1
- package/dist/esm/Platform/version.mjs +1 -1
- package/dist/esm/Platform/version.mjs.map +1 -1
- package/dist/esm/adapterCore/serverContext/types/cookieStorage.d.ts +1 -1
- package/dist/esm/parseAWSExports.mjs +6 -6
- package/dist/esm/parseAWSExports.mjs.map +1 -1
- package/dist/esm/singleton/API/types.d.ts +3 -3
- package/dist/esm/singleton/Auth/types.d.ts +1 -0
- package/dist/esm/utils/getClientInfo/getClientInfo.mjs +12 -6
- package/dist/esm/utils/getClientInfo/getClientInfo.mjs.map +1 -1
- package/package.json +3 -43
- package/src/Cache/StorageCacheCommon.ts +1 -1
- package/src/Hub/types/AuthTypes.ts +9 -2
- package/src/Platform/version.ts +1 -1
- package/src/adapterCore/serverContext/types/cookieStorage.ts +5 -3
- package/src/clients/middleware/retry/middleware.ts +1 -1
- package/src/parseAWSExports.ts +14 -8
- package/src/singleton/API/types.ts +3 -3
- package/src/singleton/Auth/types.ts +3 -0
- package/src/utils/getClientInfo/getClientInfo.ts +19 -6
|
@@ -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.0.
|
|
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.0.7-unstable.1e96034.0+1e96034';\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,kCAAkC;;"}
|
|
@@ -106,11 +106,11 @@ const parseAWSExports = (config = {}) => {
|
|
|
106
106
|
...(aws_cognito_verification_mechanisms ?? []),
|
|
107
107
|
...(aws_cognito_signup_attributes ?? []),
|
|
108
108
|
]));
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
},
|
|
113
|
-
}));
|
|
109
|
+
const userAttributes = mergedUserAttributes.reduce((attributes, key) => ({
|
|
110
|
+
...attributes,
|
|
111
|
+
// All user attributes generated by the CLI are required
|
|
112
|
+
[key.toLowerCase()]: { required: true },
|
|
113
|
+
}), {});
|
|
114
114
|
const loginWithEmailEnabled = aws_cognito_username_attributes?.includes('EMAIL') ?? false;
|
|
115
115
|
const loginWithPhoneEnabled = aws_cognito_username_attributes?.includes('PHONE_NUMBER') ?? false;
|
|
116
116
|
if (aws_cognito_identity_pool_id || aws_user_pools_id) {
|
|
@@ -119,7 +119,7 @@ const parseAWSExports = (config = {}) => {
|
|
|
119
119
|
identityPoolId: aws_cognito_identity_pool_id,
|
|
120
120
|
allowGuestAccess: aws_mandatory_sign_in !== 'enable',
|
|
121
121
|
signUpVerificationMethod: aws_cognito_sign_up_verification_method,
|
|
122
|
-
userAttributes
|
|
122
|
+
userAttributes,
|
|
123
123
|
userPoolClientId: aws_user_pools_web_client_id,
|
|
124
124
|
userPoolId: aws_user_pools_id,
|
|
125
125
|
mfa: mfaConfig,
|
|
@@ -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 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 LAMBDA: 'lambda',\n};\n/**\n * This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object\n * consumable by Amplify.\n *\n * @param config A configuration object from `aws-exports.js`.\n *\n * @returns A {@link ResourcesConfig} object.\n */\nconst parseAWSExports = (config = {}) => {\n const { aws_appsync_apiKey, aws_appsync_authenticationType, aws_appsync_graphqlEndpoint, aws_appsync_region, aws_bots, 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 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 userAttributesConfig = mergedUserAttributes.map((s) => ({\n [s.toLowerCase()]: {\n required: true, // All user attributes generated by the CLI will be required\n },\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: userAttributesConfig,\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 ? false : true,\n email: loginWithEmailEnabled,\n phone: loginWithPhoneEnabled,\n },\n },\n };\n }\n const hasOAuthConfig = oauth ? Object.keys(oauth).length > 0 : false;\n const hasSocialProviderConfig = aws_cognito_social_providers\n ? aws_cognito_social_providers.length > 0\n : false;\n if (amplifyConfig.Auth && hasOAuthConfig) {\n amplifyConfig.Auth.Cognito.loginWith = {\n ...amplifyConfig.Auth.Cognito.loginWith,\n oauth: {\n ...getOAuthConfig(oauth),\n ...(hasSocialProviderConfig && {\n providers: parseSocialProviders(aws_cognito_social_providers),\n }),\n },\n };\n }\n // Storage\n if (aws_user_files_s3_bucket) {\n amplifyConfig.Storage = {\n S3: {\n bucket: aws_user_files_s3_bucket,\n region: aws_user_files_s3_bucket_region,\n dangerouslyConnectToHttpEndpointForTesting: aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing,\n },\n };\n }\n // Geo\n if (geo) {\n const { amazon_location_service } = geo;\n amplifyConfig.Geo = amazon_location_service\n ? {\n LocationService: {\n ...amazon_location_service,\n searchIndices: amazon_location_service.search_indices,\n region: amazon_location_service.region,\n },\n }\n : { ...geo };\n }\n // REST API\n if (aws_cloud_logic_custom) {\n amplifyConfig.API = {\n ...amplifyConfig.API,\n REST: aws_cloud_logic_custom.reduce((acc, api) => {\n const { name, endpoint, region, service } = api;\n return {\n ...acc,\n [name]: {\n endpoint,\n ...(service ? { service } : undefined),\n ...(region ? { region } : undefined),\n },\n };\n }, {}),\n };\n }\n // Predictions\n if (predictions) {\n // map VoiceId from speechGenerator defaults to voiceId\n const { VoiceId: voiceId } = predictions?.convert?.speechGenerator?.defaults ?? {};\n amplifyConfig.Predictions = voiceId\n ? {\n ...predictions,\n convert: {\n ...predictions.convert,\n speechGenerator: {\n ...predictions.convert.speechGenerator,\n defaults: { voiceId },\n },\n },\n }\n : predictions;\n }\n return amplifyConfig;\n};\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,MAAM,GAAG,IAAI,QAAQ,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;AAC7D,MAAM,eAAe,GAAG;AAC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;AAC/F,IAAI,MAAM;AACV,IAAI,MAAM,EAAE,KAAK;AACjB,IAAI,cAAc,EAAE,cAAc,CAAC,cAAc,CAAC;AAClD,IAAI,eAAe,EAAE,cAAc,CAAC,eAAe,CAAC;AACpD,IAAI,YAAY;AAChB,CAAC,CAAC,CAAC;AACH,MAAM,oBAAoB,GAAG,CAAC,4BAA4B,KAAK;AAC/D,IAAI,OAAO,4BAA4B,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK;AAC1D,QAAQ,MAAM,eAAe,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AACvD,QAAQ,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAClF,KAAK,CAAC,CAAC;AACP,CAAC;;"}
|
|
1
|
+
{"version":3,"file":"parseAWSExports.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 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 LAMBDA: 'lambda',\n};\n/**\n * This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object\n * consumable by Amplify.\n *\n * @param config A configuration object from `aws-exports.js`.\n *\n * @returns A {@link ResourcesConfig} object.\n */\nconst parseAWSExports = (config = {}) => {\n const { aws_appsync_apiKey, aws_appsync_authenticationType, aws_appsync_graphqlEndpoint, aws_appsync_region, aws_bots, 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 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 ? false : true,\n email: loginWithEmailEnabled,\n phone: loginWithPhoneEnabled,\n },\n },\n };\n }\n const hasOAuthConfig = oauth ? Object.keys(oauth).length > 0 : false;\n const hasSocialProviderConfig = aws_cognito_social_providers\n ? aws_cognito_social_providers.length > 0\n : false;\n if (amplifyConfig.Auth && hasOAuthConfig) {\n amplifyConfig.Auth.Cognito.loginWith = {\n ...amplifyConfig.Auth.Cognito.loginWith,\n oauth: {\n ...getOAuthConfig(oauth),\n ...(hasSocialProviderConfig && {\n providers: parseSocialProviders(aws_cognito_social_providers),\n }),\n },\n };\n }\n // Storage\n if (aws_user_files_s3_bucket) {\n amplifyConfig.Storage = {\n S3: {\n bucket: aws_user_files_s3_bucket,\n region: aws_user_files_s3_bucket_region,\n dangerouslyConnectToHttpEndpointForTesting: aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing,\n },\n };\n }\n // Geo\n if (geo) {\n const { amazon_location_service } = geo;\n amplifyConfig.Geo = amazon_location_service\n ? {\n LocationService: {\n ...amazon_location_service,\n searchIndices: amazon_location_service.search_indices,\n region: amazon_location_service.region,\n },\n }\n : { ...geo };\n }\n // REST API\n if (aws_cloud_logic_custom) {\n amplifyConfig.API = {\n ...amplifyConfig.API,\n REST: aws_cloud_logic_custom.reduce((acc, api) => {\n const { name, endpoint, region, service } = api;\n return {\n ...acc,\n [name]: {\n endpoint,\n ...(service ? { service } : undefined),\n ...(region ? { region } : undefined),\n },\n };\n }, {}),\n };\n }\n // Predictions\n if (predictions) {\n // map VoiceId from speechGenerator defaults to voiceId\n const { VoiceId: voiceId } = predictions?.convert?.speechGenerator?.defaults ?? {};\n amplifyConfig.Predictions = voiceId\n ? {\n ...predictions,\n convert: {\n ...predictions.convert,\n speechGenerator: {\n ...predictions.convert.speechGenerator,\n defaults: { voiceId },\n },\n },\n }\n : predictions;\n }\n return amplifyConfig;\n};\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,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,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,MAAM,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,QAAQ,EAAE,eAAe,EAAE,4BAA4B,EAAE,uCAAuC,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,wCAAwC,EAAE,mCAAmC,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,+BAA+B,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,+BAA+B,EAAE,wBAAwB,EAAE,+BAA+B,EAAE,kEAAkE,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,sBAAsB,EA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
|
+
// The latest user agents for Opera: https://www.whatismybrowser.com/guides/the-latest-user-agent/opera
|
|
45
|
+
const operaMatch = /.+(Opera[\s[A-Z]*|OPR[\sA-Z]*)\/([0-9.]+).*/i.exec(userAgent);
|
|
45
46
|
if (operaMatch) {
|
|
46
47
|
return { type: operaMatch[1], version: operaMatch[2] };
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
// The latest user agents for Edge: https://www.whatismybrowser.com/guides/the-latest-user-agent/edge
|
|
50
|
+
const ieMatch = /.+(Trident|Edge|Edg|EdgA|EdgiOS)\/([0-9.]+).*/i.exec(userAgent);
|
|
49
51
|
if (ieMatch) {
|
|
50
52
|
return { type: ieMatch[1], version: ieMatch[2] };
|
|
51
53
|
}
|
|
52
|
-
|
|
54
|
+
// The latest user agents for web browsers on Firefox and Chrome
|
|
55
|
+
// https://www.whatismybrowser.com/guides/the-latest-user-agent/firefox
|
|
56
|
+
// https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome
|
|
57
|
+
const cfMatch = /.+(Chrome|CriOS|Firefox|FxiOS)\/([0-9.]+).*/i.exec(userAgent);
|
|
53
58
|
if (cfMatch) {
|
|
54
59
|
return { type: cfMatch[1], version: cfMatch[2] };
|
|
55
60
|
}
|
|
56
|
-
|
|
61
|
+
// The latest user agents for Safari: https://www.whatismybrowser.com/guides/the-latest-user-agent/safari
|
|
62
|
+
const sMatch = /.+(Safari)\/([0-9.]+).*/i.exec(userAgent);
|
|
57
63
|
if (sMatch) {
|
|
58
64
|
return { type: sMatch[1], version: sMatch[2] };
|
|
59
65
|
}
|
|
60
|
-
const awkMatch = /.+(AppleWebKit)\/([0-9
|
|
66
|
+
const awkMatch = /.+(AppleWebKit)\/([0-9.]+).*/i.exec(userAgent);
|
|
61
67
|
if (awkMatch) {
|
|
62
68
|
return { type: awkMatch[1], version: awkMatch[2] };
|
|
63
69
|
}
|
|
64
|
-
const anyMatch = /.*([A-Z]+)\/([0-9
|
|
70
|
+
const anyMatch = /.*([A-Z]+)\/([0-9.]+).*/i.exec(userAgent);
|
|
65
71
|
if (anyMatch) {
|
|
66
72
|
return { type: anyMatch[1], version: anyMatch[2] };
|
|
67
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getClientInfo.js","sources":["../../../../src/utils/getClientInfo/getClientInfo.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getClientInfo = 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 logger = new Logger_1.ConsoleLogger('getClientInfo');\nfunction getClientInfo() {\n if (typeof window === 'undefined') {\n return {};\n }\n return browserClientInfo();\n}\nexports.getClientInfo = getClientInfo;\nfunction browserClientInfo() {\n if (typeof window === 'undefined') {\n logger.warn('No window object available to get browser client info');\n return {};\n }\n const nav = window.navigator;\n if (!nav) {\n logger.warn('No navigator object available to get browser client info');\n return {};\n }\n const { platform, product, vendor, userAgent, language } = nav;\n const type = getBrowserType(userAgent);\n const timezone = browserTimezone();\n return {\n platform,\n make: product || vendor,\n model: type.type,\n version: type.version,\n appVersion: [type.type, type.version].join('/'),\n language,\n timezone,\n };\n}\nfunction browserTimezone() {\n const tzMatch = /\\(([A-Za-z\\s].*)\\)/.exec(new Date().toString());\n return tzMatch ? tzMatch[1] || '' : '';\n}\nfunction getBrowserType(userAgent) {\n const operaMatch = /.+(Opera[\\s[A-Z]*|OPR[\\sA-Z]*)\\/([0-9
|
|
1
|
+
{"version":3,"file":"getClientInfo.js","sources":["../../../../src/utils/getClientInfo/getClientInfo.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getClientInfo = 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 logger = new Logger_1.ConsoleLogger('getClientInfo');\nfunction getClientInfo() {\n if (typeof window === 'undefined') {\n return {};\n }\n return browserClientInfo();\n}\nexports.getClientInfo = getClientInfo;\nfunction browserClientInfo() {\n if (typeof window === 'undefined') {\n logger.warn('No window object available to get browser client info');\n return {};\n }\n const nav = window.navigator;\n if (!nav) {\n logger.warn('No navigator object available to get browser client info');\n return {};\n }\n const { platform, product, vendor, userAgent, language } = nav;\n const type = getBrowserType(userAgent);\n const timezone = browserTimezone();\n return {\n platform,\n make: product || vendor,\n model: type.type,\n version: type.version,\n appVersion: [type.type, type.version].join('/'),\n language,\n timezone,\n };\n}\nfunction browserTimezone() {\n const tzMatch = /\\(([A-Za-z\\s].*)\\)/.exec(new Date().toString());\n return tzMatch ? tzMatch[1] || '' : '';\n}\nfunction getBrowserType(userAgent) {\n // The latest user agents for Opera: https://www.whatismybrowser.com/guides/the-latest-user-agent/opera\n const operaMatch = /.+(Opera[\\s[A-Z]*|OPR[\\sA-Z]*)\\/([0-9.]+).*/i.exec(userAgent);\n if (operaMatch) {\n return { type: operaMatch[1], version: operaMatch[2] };\n }\n // The latest user agents for Edge: https://www.whatismybrowser.com/guides/the-latest-user-agent/edge\n const ieMatch = /.+(Trident|Edge|Edg|EdgA|EdgiOS)\\/([0-9.]+).*/i.exec(userAgent);\n if (ieMatch) {\n return { type: ieMatch[1], version: ieMatch[2] };\n }\n // The latest user agents for web browsers on Firefox and Chrome\n // https://www.whatismybrowser.com/guides/the-latest-user-agent/firefox\n // https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome\n const cfMatch = /.+(Chrome|CriOS|Firefox|FxiOS)\\/([0-9.]+).*/i.exec(userAgent);\n if (cfMatch) {\n return { type: cfMatch[1], version: cfMatch[2] };\n }\n // The latest user agents for Safari: https://www.whatismybrowser.com/guides/the-latest-user-agent/safari\n const sMatch = /.+(Safari)\\/([0-9.]+).*/i.exec(userAgent);\n if (sMatch) {\n return { type: sMatch[1], version: sMatch[2] };\n }\n const awkMatch = /.+(AppleWebKit)\\/([0-9.]+).*/i.exec(userAgent);\n if (awkMatch) {\n return { type: awkMatch[1], version: awkMatch[2] };\n }\n const anyMatch = /.*([A-Z]+)\\/([0-9.]+).*/i.exec(userAgent);\n if (anyMatch) {\n return { type: anyMatch[1], version: anyMatch[2] };\n }\n return { type: '', version: '' };\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AAC/B;AACA;AACA,MAAM,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AACzC,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;AAC3D,SAAS,aAAa,GAAG;AACzB,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACvC,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,OAAO,iBAAiB,EAAE,CAAC;AAC/B,CAAC;AACD,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;AACtC,SAAS,iBAAiB,GAAG;AAC7B,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACvC,QAAQ,MAAM,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;AAC7E,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC;AACjC,IAAI,IAAI,CAAC,GAAG,EAAE;AACd,QAAQ,MAAM,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;AAChF,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;AACnE,IAAI,MAAM,IAAI,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;AAC3C,IAAI,M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,EAAE;AACjB,QAAQ,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;AACzD,KAAK;AACL;AACA,IAAI,MAAM,MAAM,GAAG,0BAA0B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC9D,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AACvD,KAAK;AACL,IAAI,MAAM,QAAQ,GAAG,+BAA+B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACrE,IAAI,IAAI,QAAQ,EAAE;AAClB,QAAQ,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3D,KAAK;AACL,IAAI,MAAM,QAAQ,GAAG,0BAA0B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAChE,IAAI,IAAI,QAAQ,EAAE;AAClB,QAAQ,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3D,KAAK;AACL,IAAI,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACrC;;"}
|
|
@@ -2,6 +2,11 @@ type AuthUser = {
|
|
|
2
2
|
username: string;
|
|
3
3
|
userId: string;
|
|
4
4
|
};
|
|
5
|
+
type AuthError = {
|
|
6
|
+
name: string;
|
|
7
|
+
message: string;
|
|
8
|
+
recoverySuggestion?: string;
|
|
9
|
+
};
|
|
5
10
|
export type AuthHubEventData =
|
|
6
11
|
/** Dispatched when a user signs in with an oauth provider such as Google.*/
|
|
7
12
|
{
|
|
@@ -10,6 +15,9 @@ export type AuthHubEventData =
|
|
|
10
15
|
/** Dispatched when there is an error in the oauth flow process.*/
|
|
11
16
|
| {
|
|
12
17
|
event: 'signInWithRedirect_failure';
|
|
18
|
+
data: {
|
|
19
|
+
error?: AuthError;
|
|
20
|
+
};
|
|
13
21
|
}
|
|
14
22
|
/** Dispatched when auth tokens are successfully refreshed.*/
|
|
15
23
|
| {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.0.
|
|
1
|
+
export declare const version = "6.0.7-unstable.1e96034.0+1e96034";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.0.
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.0.7-unstable.1e96034.0+1e96034';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CookieSerializeOptions } from 'cookie';
|
|
2
2
|
export declare namespace CookieStorage {
|
|
3
|
-
type SetCookieOptions = Pick<CookieSerializeOptions, 'domain' | 'expires' | 'httpOnly' | 'maxAge' | 'sameSite' | 'secure'
|
|
3
|
+
type SetCookieOptions = Partial<Pick<CookieSerializeOptions, 'domain' | 'expires' | 'httpOnly' | 'maxAge' | 'sameSite' | 'secure'>>;
|
|
4
4
|
type Cookie = {
|
|
5
5
|
name: string;
|
|
6
6
|
value?: string;
|
|
@@ -103,11 +103,11 @@ const parseAWSExports = (config = {}) => {
|
|
|
103
103
|
...(aws_cognito_verification_mechanisms ?? []),
|
|
104
104
|
...(aws_cognito_signup_attributes ?? []),
|
|
105
105
|
]));
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
}));
|
|
106
|
+
const userAttributes = mergedUserAttributes.reduce((attributes, key) => ({
|
|
107
|
+
...attributes,
|
|
108
|
+
// All user attributes generated by the CLI are required
|
|
109
|
+
[key.toLowerCase()]: { required: true },
|
|
110
|
+
}), {});
|
|
111
111
|
const loginWithEmailEnabled = aws_cognito_username_attributes?.includes('EMAIL') ?? false;
|
|
112
112
|
const loginWithPhoneEnabled = aws_cognito_username_attributes?.includes('PHONE_NUMBER') ?? false;
|
|
113
113
|
if (aws_cognito_identity_pool_id || aws_user_pools_id) {
|
|
@@ -116,7 +116,7 @@ const parseAWSExports = (config = {}) => {
|
|
|
116
116
|
identityPoolId: aws_cognito_identity_pool_id,
|
|
117
117
|
allowGuestAccess: aws_mandatory_sign_in !== 'enable',
|
|
118
118
|
signUpVerificationMethod: aws_cognito_sign_up_verification_method,
|
|
119
|
-
userAttributes
|
|
119
|
+
userAttributes,
|
|
120
120
|
userPoolClientId: aws_user_pools_web_client_id,
|
|
121
121
|
userPoolId: aws_user_pools_id,
|
|
122
122
|
mfa: mfaConfig,
|
|
@@ -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';\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 LAMBDA: 'lambda',\n};\n/**\n * This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object\n * consumable by Amplify.\n *\n * @param config A configuration object from `aws-exports.js`.\n *\n * @returns A {@link ResourcesConfig} object.\n */\nexport const parseAWSExports = (config = {}) => {\n const { aws_appsync_apiKey, aws_appsync_authenticationType, aws_appsync_graphqlEndpoint, aws_appsync_region, aws_bots, 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 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 userAttributesConfig = mergedUserAttributes.map((s) => ({\n [s.toLowerCase()]: {\n required: true, // All user attributes generated by the CLI will be required\n },\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: userAttributesConfig,\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 ? false : true,\n email: loginWithEmailEnabled,\n phone: loginWithPhoneEnabled,\n },\n },\n };\n }\n const hasOAuthConfig = oauth ? Object.keys(oauth).length > 0 : false;\n const hasSocialProviderConfig = aws_cognito_social_providers\n ? aws_cognito_social_providers.length > 0\n : false;\n if (amplifyConfig.Auth && hasOAuthConfig) {\n amplifyConfig.Auth.Cognito.loginWith = {\n ...amplifyConfig.Auth.Cognito.loginWith,\n oauth: {\n ...getOAuthConfig(oauth),\n ...(hasSocialProviderConfig && {\n providers: parseSocialProviders(aws_cognito_social_providers),\n }),\n },\n };\n }\n // Storage\n if (aws_user_files_s3_bucket) {\n amplifyConfig.Storage = {\n S3: {\n bucket: aws_user_files_s3_bucket,\n region: aws_user_files_s3_bucket_region,\n dangerouslyConnectToHttpEndpointForTesting: aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing,\n },\n };\n }\n // Geo\n if (geo) {\n const { amazon_location_service } = geo;\n amplifyConfig.Geo = amazon_location_service\n ? {\n LocationService: {\n ...amazon_location_service,\n searchIndices: amazon_location_service.search_indices,\n region: amazon_location_service.region,\n },\n }\n : { ...geo };\n }\n // REST API\n if (aws_cloud_logic_custom) {\n amplifyConfig.API = {\n ...amplifyConfig.API,\n REST: aws_cloud_logic_custom.reduce((acc, api) => {\n const { name, endpoint, region, service } = api;\n return {\n ...acc,\n [name]: {\n endpoint,\n ...(service ? { service } : undefined),\n ...(region ? { region } : undefined),\n },\n };\n }, {}),\n };\n }\n // Predictions\n if (predictions) {\n // map VoiceId from speechGenerator defaults to voiceId\n const { VoiceId: voiceId } = predictions?.convert?.speechGenerator?.defaults ?? {};\n amplifyConfig.Predictions = voiceId\n ? {\n ...predictions,\n convert: {\n ...predictions.convert,\n speechGenerator: {\n ...predictions.convert.speechGenerator,\n defaults: { voiceId },\n },\n },\n }\n : predictions;\n }\n return amplifyConfig;\n};\nconst getRedirectUrl = (redirectStr) => redirectStr?.split(',') ?? [];\nconst getOAuthConfig = ({ domain, scope, redirectSignIn, redirectSignOut, responseType, }) => ({\n domain,\n scopes: scope,\n redirectSignIn: getRedirectUrl(redirectSignIn),\n redirectSignOut: getRedirectUrl(redirectSignOut),\n responseType,\n});\nconst parseSocialProviders = (aws_cognito_social_providers) => {\n return aws_cognito_social_providers.map((provider) => {\n const updatedProvider = provider.toLowerCase();\n return updatedProvider.charAt(0).toUpperCase() + updatedProvider.slice(1);\n });\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEA,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,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,MAAM,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,QAAQ,EAAE,eAAe,EAAE,4BAA4B,EAAE,uCAAuC,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,wCAAwC,EAAE,mCAAmC,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,+BAA+B,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,+BAA+B,EAAE,wBAAwB,EAAE,+BAA+B,EAAE,kEAAkE,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,sBAAsB,EAAE,aAAa,EAAE,kBAAkB,GAAG,GAAG,MAAM,CAAC;AAC1xB,IAAI,MAAM,aAAa,GAAG,EAAE,CAAC;AAC7B;AACA,IAAI,IAAI,2BAA2B,EAAE;AACrC,QAAQ,aAAa,CAAC,SAAS,GAAG;AAClC,YAAY,QAAQ,EAAE;AACtB,gBAAgB,KAAK,EAAE,2BAA2B;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AAW,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;;;;"}
|
|
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';\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 LAMBDA: 'lambda',\n};\n/**\n * This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object\n * consumable by Amplify.\n *\n * @param config A configuration object from `aws-exports.js`.\n *\n * @returns A {@link ResourcesConfig} object.\n */\nexport const parseAWSExports = (config = {}) => {\n const { aws_appsync_apiKey, aws_appsync_authenticationType, aws_appsync_graphqlEndpoint, aws_appsync_region, aws_bots, 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 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 ? false : true,\n email: loginWithEmailEnabled,\n phone: loginWithPhoneEnabled,\n },\n },\n };\n }\n const hasOAuthConfig = oauth ? Object.keys(oauth).length > 0 : false;\n const hasSocialProviderConfig = aws_cognito_social_providers\n ? aws_cognito_social_providers.length > 0\n : false;\n if (amplifyConfig.Auth && hasOAuthConfig) {\n amplifyConfig.Auth.Cognito.loginWith = {\n ...amplifyConfig.Auth.Cognito.loginWith,\n oauth: {\n ...getOAuthConfig(oauth),\n ...(hasSocialProviderConfig && {\n providers: parseSocialProviders(aws_cognito_social_providers),\n }),\n },\n };\n }\n // Storage\n if (aws_user_files_s3_bucket) {\n amplifyConfig.Storage = {\n S3: {\n bucket: aws_user_files_s3_bucket,\n region: aws_user_files_s3_bucket_region,\n dangerouslyConnectToHttpEndpointForTesting: aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing,\n },\n };\n }\n // Geo\n if (geo) {\n const { amazon_location_service } = geo;\n amplifyConfig.Geo = amazon_location_service\n ? {\n LocationService: {\n ...amazon_location_service,\n searchIndices: amazon_location_service.search_indices,\n region: amazon_location_service.region,\n },\n }\n : { ...geo };\n }\n // REST API\n if (aws_cloud_logic_custom) {\n amplifyConfig.API = {\n ...amplifyConfig.API,\n REST: aws_cloud_logic_custom.reduce((acc, api) => {\n const { name, endpoint, region, service } = api;\n return {\n ...acc,\n [name]: {\n endpoint,\n ...(service ? { service } : undefined),\n ...(region ? { region } : undefined),\n },\n };\n }, {}),\n };\n }\n // Predictions\n if (predictions) {\n // map VoiceId from speechGenerator defaults to voiceId\n const { VoiceId: voiceId } = predictions?.convert?.speechGenerator?.defaults ?? {};\n amplifyConfig.Predictions = voiceId\n ? {\n ...predictions,\n convert: {\n ...predictions.convert,\n speechGenerator: {\n ...predictions.convert.speechGenerator,\n defaults: { voiceId },\n },\n },\n }\n : predictions;\n }\n return amplifyConfig;\n};\nconst getRedirectUrl = (redirectStr) => redirectStr?.split(',') ?? [];\nconst getOAuthConfig = ({ domain, scope, redirectSignIn, redirectSignOut, responseType, }) => ({\n domain,\n scopes: scope,\n redirectSignIn: getRedirectUrl(redirectSignIn),\n redirectSignOut: getRedirectUrl(redirectSignOut),\n responseType,\n});\nconst parseSocialProviders = (aws_cognito_social_providers) => {\n return aws_cognito_social_providers.map((provider) => {\n const updatedProvider = provider.toLowerCase();\n return updatedProvider.charAt(0).toUpperCase() + updatedProvider.slice(1);\n });\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEA,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,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,MAAM,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,QAAQ,EAAE,eAAe,EAAE,4BAA4B,EAAE,uCAAuC,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,wCAAwC,EAAE,mCAAmC,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,+BAA+B,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,+BAA+B,EAAE,wBAAwB,EAAE,+BAA+B,EAAE,kEAAkE,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,sBAAsB,EAAE,aAAa,EAAE,kBAAkB,GAAG,GAAG,MAAM,C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B,oBAAoB,GAAG,WAAW,CAAC,OAAO;AAC1C,oBAAoB,eAAe,EAAE;AACrC,wBAAwB,GAAG,WAAW,CAAC,OAAO,CAAC,eAAe;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;;;;"}
|
|
@@ -2,10 +2,10 @@ import { Headers } from '../../clients';
|
|
|
2
2
|
import { AtLeastOne } from '../types';
|
|
3
3
|
export type LibraryAPIOptions = {
|
|
4
4
|
GraphQL?: {
|
|
5
|
-
headers?: (options
|
|
6
|
-
query
|
|
5
|
+
headers?: (options?: {
|
|
6
|
+
query?: string;
|
|
7
7
|
variables?: Record<string, DocumentType>;
|
|
8
|
-
}) => Promise<Headers>;
|
|
8
|
+
}) => Promise<Headers | {}>;
|
|
9
9
|
withCredentials?: boolean;
|
|
10
10
|
};
|
|
11
11
|
REST?: {
|
|
@@ -52,6 +52,7 @@ export type AuthTokens = {
|
|
|
52
52
|
accessToken: JWT;
|
|
53
53
|
};
|
|
54
54
|
export type AuthStandardAttributeKey = 'address' | 'birthdate' | 'email_verified' | 'family_name' | 'gender' | 'given_name' | 'locale' | 'middle_name' | 'name' | 'nickname' | 'phone_number_verified' | 'picture' | 'preferred_username' | 'profile' | 'sub' | 'updated_at' | 'website' | 'zoneinfo' | AuthVerifiableAttributeKey;
|
|
55
|
+
export type LegacyUserAttributeKey = Uppercase<AuthStandardAttributeKey>;
|
|
55
56
|
export type AuthVerifiableAttributeKey = 'email' | 'phone_number';
|
|
56
57
|
export type AuthConfigUserAttributes = Partial<Record<AuthStandardAttributeKey, {
|
|
57
58
|
required: boolean;
|
|
@@ -37,27 +37,33 @@ function browserTimezone() {
|
|
|
37
37
|
return tzMatch ? tzMatch[1] || '' : '';
|
|
38
38
|
}
|
|
39
39
|
function getBrowserType(userAgent) {
|
|
40
|
-
|
|
40
|
+
// The latest user agents for Opera: https://www.whatismybrowser.com/guides/the-latest-user-agent/opera
|
|
41
|
+
const operaMatch = /.+(Opera[\s[A-Z]*|OPR[\sA-Z]*)\/([0-9.]+).*/i.exec(userAgent);
|
|
41
42
|
if (operaMatch) {
|
|
42
43
|
return { type: operaMatch[1], version: operaMatch[2] };
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
+
// The latest user agents for Edge: https://www.whatismybrowser.com/guides/the-latest-user-agent/edge
|
|
46
|
+
const ieMatch = /.+(Trident|Edge|Edg|EdgA|EdgiOS)\/([0-9.]+).*/i.exec(userAgent);
|
|
45
47
|
if (ieMatch) {
|
|
46
48
|
return { type: ieMatch[1], version: ieMatch[2] };
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
// The latest user agents for web browsers on Firefox and Chrome
|
|
51
|
+
// https://www.whatismybrowser.com/guides/the-latest-user-agent/firefox
|
|
52
|
+
// https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome
|
|
53
|
+
const cfMatch = /.+(Chrome|CriOS|Firefox|FxiOS)\/([0-9.]+).*/i.exec(userAgent);
|
|
49
54
|
if (cfMatch) {
|
|
50
55
|
return { type: cfMatch[1], version: cfMatch[2] };
|
|
51
56
|
}
|
|
52
|
-
|
|
57
|
+
// The latest user agents for Safari: https://www.whatismybrowser.com/guides/the-latest-user-agent/safari
|
|
58
|
+
const sMatch = /.+(Safari)\/([0-9.]+).*/i.exec(userAgent);
|
|
53
59
|
if (sMatch) {
|
|
54
60
|
return { type: sMatch[1], version: sMatch[2] };
|
|
55
61
|
}
|
|
56
|
-
const awkMatch = /.+(AppleWebKit)\/([0-9
|
|
62
|
+
const awkMatch = /.+(AppleWebKit)\/([0-9.]+).*/i.exec(userAgent);
|
|
57
63
|
if (awkMatch) {
|
|
58
64
|
return { type: awkMatch[1], version: awkMatch[2] };
|
|
59
65
|
}
|
|
60
|
-
const anyMatch = /.*([A-Z]+)\/([0-9
|
|
66
|
+
const anyMatch = /.*([A-Z]+)\/([0-9.]+).*/i.exec(userAgent);
|
|
61
67
|
if (anyMatch) {
|
|
62
68
|
return { type: anyMatch[1], version: anyMatch[2] };
|
|
63
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getClientInfo.mjs","sources":["../../../../src/utils/getClientInfo/getClientInfo.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '../../Logger';\nconst logger = new ConsoleLogger('getClientInfo');\nexport function getClientInfo() {\n if (typeof window === 'undefined') {\n return {};\n }\n return browserClientInfo();\n}\nfunction browserClientInfo() {\n if (typeof window === 'undefined') {\n logger.warn('No window object available to get browser client info');\n return {};\n }\n const nav = window.navigator;\n if (!nav) {\n logger.warn('No navigator object available to get browser client info');\n return {};\n }\n const { platform, product, vendor, userAgent, language } = nav;\n const type = getBrowserType(userAgent);\n const timezone = browserTimezone();\n return {\n platform,\n make: product || vendor,\n model: type.type,\n version: type.version,\n appVersion: [type.type, type.version].join('/'),\n language,\n timezone,\n };\n}\nfunction browserTimezone() {\n const tzMatch = /\\(([A-Za-z\\s].*)\\)/.exec(new Date().toString());\n return tzMatch ? tzMatch[1] || '' : '';\n}\nfunction getBrowserType(userAgent) {\n const operaMatch = /.+(Opera[\\s[A-Z]*|OPR[\\sA-Z]*)\\/([0-9
|
|
1
|
+
{"version":3,"file":"getClientInfo.mjs","sources":["../../../../src/utils/getClientInfo/getClientInfo.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '../../Logger';\nconst logger = new ConsoleLogger('getClientInfo');\nexport function getClientInfo() {\n if (typeof window === 'undefined') {\n return {};\n }\n return browserClientInfo();\n}\nfunction browserClientInfo() {\n if (typeof window === 'undefined') {\n logger.warn('No window object available to get browser client info');\n return {};\n }\n const nav = window.navigator;\n if (!nav) {\n logger.warn('No navigator object available to get browser client info');\n return {};\n }\n const { platform, product, vendor, userAgent, language } = nav;\n const type = getBrowserType(userAgent);\n const timezone = browserTimezone();\n return {\n platform,\n make: product || vendor,\n model: type.type,\n version: type.version,\n appVersion: [type.type, type.version].join('/'),\n language,\n timezone,\n };\n}\nfunction browserTimezone() {\n const tzMatch = /\\(([A-Za-z\\s].*)\\)/.exec(new Date().toString());\n return tzMatch ? tzMatch[1] || '' : '';\n}\nfunction getBrowserType(userAgent) {\n // The latest user agents for Opera: https://www.whatismybrowser.com/guides/the-latest-user-agent/opera\n const operaMatch = /.+(Opera[\\s[A-Z]*|OPR[\\sA-Z]*)\\/([0-9.]+).*/i.exec(userAgent);\n if (operaMatch) {\n return { type: operaMatch[1], version: operaMatch[2] };\n }\n // The latest user agents for Edge: https://www.whatismybrowser.com/guides/the-latest-user-agent/edge\n const ieMatch = /.+(Trident|Edge|Edg|EdgA|EdgiOS)\\/([0-9.]+).*/i.exec(userAgent);\n if (ieMatch) {\n return { type: ieMatch[1], version: ieMatch[2] };\n }\n // The latest user agents for web browsers on Firefox and Chrome\n // https://www.whatismybrowser.com/guides/the-latest-user-agent/firefox\n // https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome\n const cfMatch = /.+(Chrome|CriOS|Firefox|FxiOS)\\/([0-9.]+).*/i.exec(userAgent);\n if (cfMatch) {\n return { type: cfMatch[1], version: cfMatch[2] };\n }\n // The latest user agents for Safari: https://www.whatismybrowser.com/guides/the-latest-user-agent/safari\n const sMatch = /.+(Safari)\\/([0-9.]+).*/i.exec(userAgent);\n if (sMatch) {\n return { type: sMatch[1], version: sMatch[2] };\n }\n const awkMatch = /.+(AppleWebKit)\\/([0-9.]+).*/i.exec(userAgent);\n if (awkMatch) {\n return { type: awkMatch[1], version: awkMatch[2] };\n }\n const anyMatch = /.*([A-Z]+)\\/([0-9.]+).*/i.exec(userAgent);\n if (anyMatch) {\n return { type: anyMatch[1], version: anyMatch[2] };\n }\n return { type: '', version: '' };\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,eAAe,CAAC,CAAC;AAC3C,SAAS,aAAa,GAAG;AAChC,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACvC,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,OAAO,iBAAiB,EAAE,CAAC;AAC/B,CAAC;AACD,SAAS,iBAAiB,GAAG;AAC7B,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACvC,QAAQ,MAAM,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;AAC7E,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC;AACjC,IAAI,IAAI,CA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package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/core",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.7-unstable.1e96034.0+1e96034",
|
|
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.0.
|
|
63
|
+
"@aws-amplify/react-native": "1.0.7-unstable.1e96034.0+1e96034",
|
|
64
64
|
"@rollup/plugin-typescript": "11.1.5",
|
|
65
65
|
"@types/js-cookie": "3.0.2",
|
|
66
66
|
"genversion": "^2.2.0",
|
|
@@ -194,45 +194,5 @@
|
|
|
194
194
|
]
|
|
195
195
|
}
|
|
196
196
|
},
|
|
197
|
-
"
|
|
198
|
-
"globals": {
|
|
199
|
-
"ts-jest": {
|
|
200
|
-
"diagnostics": false,
|
|
201
|
-
"tsConfig": false
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
"transform": {
|
|
205
|
-
"^.+\\.(js|jsx|ts|tsx)$": "ts-jest"
|
|
206
|
-
},
|
|
207
|
-
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$",
|
|
208
|
-
"testPathIgnorePatterns": [
|
|
209
|
-
"/testUtils/"
|
|
210
|
-
],
|
|
211
|
-
"moduleFileExtensions": [
|
|
212
|
-
"ts",
|
|
213
|
-
"tsx",
|
|
214
|
-
"js",
|
|
215
|
-
"json",
|
|
216
|
-
"jsx"
|
|
217
|
-
],
|
|
218
|
-
"setupFiles": [
|
|
219
|
-
"./__mocks__/SessionStorage.js",
|
|
220
|
-
"./__mocks__/LocalStorage.js"
|
|
221
|
-
],
|
|
222
|
-
"testEnvironment": "jsdom",
|
|
223
|
-
"coverageThreshold": {
|
|
224
|
-
"global": {
|
|
225
|
-
"branches": 0,
|
|
226
|
-
"functions": 0,
|
|
227
|
-
"lines": 0,
|
|
228
|
-
"statements": 0
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
"testURL": "http://localhost/",
|
|
232
|
-
"coveragePathIgnorePatterns": [
|
|
233
|
-
"/node_modules/",
|
|
234
|
-
"dist"
|
|
235
|
-
]
|
|
236
|
-
},
|
|
237
|
-
"gitHead": "f2b7a8d78058af2e1c04f7d507525641def667c3"
|
|
197
|
+
"gitHead": "1e9603474972c9c1c6cf8e25dc1312ae27cc0b18"
|
|
238
198
|
}
|
|
@@ -544,7 +544,7 @@ export abstract class StorageCacheCommon {
|
|
|
544
544
|
* @return The remaining valid keys
|
|
545
545
|
*/
|
|
546
546
|
private async clearInvalidAndGetRemainingKeys(): Promise<string[]> {
|
|
547
|
-
const remainingKeys = [];
|
|
547
|
+
const remainingKeys: string[] = [];
|
|
548
548
|
const keys = await this.getAllCacheKeys({
|
|
549
549
|
omitSizeKey: true,
|
|
550
550
|
});
|
|
@@ -5,12 +5,19 @@ type AuthUser = {
|
|
|
5
5
|
username: string;
|
|
6
6
|
userId: string;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type AuthError = {
|
|
9
|
+
name: string;
|
|
10
|
+
message: string;
|
|
11
|
+
recoverySuggestion?: string;
|
|
12
|
+
};
|
|
9
13
|
export type AuthHubEventData =
|
|
10
14
|
/** Dispatched when a user signs in with an oauth provider such as Google.*/
|
|
11
15
|
| { event: 'signInWithRedirect' }
|
|
12
16
|
/** Dispatched when there is an error in the oauth flow process.*/
|
|
13
|
-
| {
|
|
17
|
+
| {
|
|
18
|
+
event: 'signInWithRedirect_failure';
|
|
19
|
+
data: { error?: AuthError };
|
|
20
|
+
}
|
|
14
21
|
/** Dispatched when auth tokens are successfully refreshed.*/
|
|
15
22
|
| { event: 'tokenRefresh' }
|
|
16
23
|
/** Dispatched when there is an error in the refresh of tokens.*/
|
package/src/Platform/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '6.0.
|
|
2
|
+
export const version = '6.0.7-unstable.1e96034.0+1e96034';
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
import { CookieSerializeOptions } from 'cookie';
|
|
5
5
|
|
|
6
6
|
export namespace CookieStorage {
|
|
7
|
-
export type SetCookieOptions =
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export type SetCookieOptions = Partial<
|
|
8
|
+
Pick<
|
|
9
|
+
CookieSerializeOptions,
|
|
10
|
+
'domain' | 'expires' | 'httpOnly' | 'maxAge' | 'sameSite' | 'secure'
|
|
11
|
+
>
|
|
10
12
|
>;
|
|
11
13
|
|
|
12
14
|
export type Cookie = {
|
|
@@ -109,7 +109,7 @@ const cancellableSleep = (timeoutMs: number, abortSignal?: AbortSignal) => {
|
|
|
109
109
|
if (abortSignal?.aborted) {
|
|
110
110
|
return Promise.resolve();
|
|
111
111
|
}
|
|
112
|
-
let timeoutId:
|
|
112
|
+
let timeoutId: ReturnType<typeof setTimeout>;
|
|
113
113
|
let sleepPromiseResolveFn: Function;
|
|
114
114
|
const sleepPromise = new Promise<void>(resolve => {
|
|
115
115
|
sleepPromiseResolveFn = resolve;
|
package/src/parseAWSExports.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { ConsoleLogger } from './Logger';
|
|
4
4
|
import {
|
|
5
|
-
OAuthConfig,
|
|
6
5
|
AuthConfigUserAttributes,
|
|
6
|
+
LegacyUserAttributeKey,
|
|
7
|
+
OAuthConfig,
|
|
7
8
|
OAuthProvider,
|
|
8
9
|
} from './singleton/Auth/types';
|
|
9
10
|
import { ResourcesConfig } from './singleton/types';
|
|
@@ -161,17 +162,22 @@ export const parseAWSExports = (
|
|
|
161
162
|
) ?? false,
|
|
162
163
|
}
|
|
163
164
|
: undefined;
|
|
164
|
-
const mergedUserAttributes = Array.from(
|
|
165
|
+
const mergedUserAttributes: LegacyUserAttributeKey[] = Array.from(
|
|
165
166
|
new Set([
|
|
166
167
|
...(aws_cognito_verification_mechanisms ?? []),
|
|
167
168
|
...(aws_cognito_signup_attributes ?? []),
|
|
168
169
|
])
|
|
169
170
|
);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
|
|
172
|
+
const userAttributes: AuthConfigUserAttributes = mergedUserAttributes.reduce(
|
|
173
|
+
(attributes: AuthConfigUserAttributes, key: LegacyUserAttributeKey) => ({
|
|
174
|
+
...attributes,
|
|
175
|
+
// All user attributes generated by the CLI are required
|
|
176
|
+
[key.toLowerCase()]: { required: true },
|
|
177
|
+
}),
|
|
178
|
+
{}
|
|
179
|
+
);
|
|
180
|
+
|
|
175
181
|
const loginWithEmailEnabled =
|
|
176
182
|
aws_cognito_username_attributes?.includes('EMAIL') ?? false;
|
|
177
183
|
const loginWithPhoneEnabled =
|
|
@@ -182,7 +188,7 @@ export const parseAWSExports = (
|
|
|
182
188
|
identityPoolId: aws_cognito_identity_pool_id,
|
|
183
189
|
allowGuestAccess: aws_mandatory_sign_in !== 'enable',
|
|
184
190
|
signUpVerificationMethod: aws_cognito_sign_up_verification_method,
|
|
185
|
-
userAttributes
|
|
191
|
+
userAttributes,
|
|
186
192
|
userPoolClientId: aws_user_pools_web_client_id,
|
|
187
193
|
userPoolId: aws_user_pools_id,
|
|
188
194
|
mfa: mfaConfig,
|
|
@@ -6,10 +6,10 @@ import { AtLeastOne } from '../types';
|
|
|
6
6
|
export type LibraryAPIOptions = {
|
|
7
7
|
GraphQL?: {
|
|
8
8
|
// custom headers for given GraphQL service. Will be applied to all operations.
|
|
9
|
-
headers?: (options
|
|
10
|
-
query
|
|
9
|
+
headers?: (options?: {
|
|
10
|
+
query?: string;
|
|
11
11
|
variables?: Record<string, DocumentType>;
|
|
12
|
-
}) => Promise<Headers>;
|
|
12
|
+
}) => Promise<Headers | {}>;
|
|
13
13
|
withCredentials?: boolean;
|
|
14
14
|
};
|
|
15
15
|
REST?: {
|
|
@@ -93,6 +93,9 @@ export type AuthStandardAttributeKey =
|
|
|
93
93
|
| 'zoneinfo'
|
|
94
94
|
| AuthVerifiableAttributeKey;
|
|
95
95
|
|
|
96
|
+
// legacy config user attribute keys are uppercase
|
|
97
|
+
export type LegacyUserAttributeKey = Uppercase<AuthStandardAttributeKey>;
|
|
98
|
+
|
|
96
99
|
export type AuthVerifiableAttributeKey = 'email' | 'phone_number';
|
|
97
100
|
|
|
98
101
|
export type AuthConfigUserAttributes = Partial<
|
|
@@ -15,12 +15,14 @@ export function getClientInfo() {
|
|
|
15
15
|
function browserClientInfo() {
|
|
16
16
|
if (typeof window === 'undefined') {
|
|
17
17
|
logger.warn('No window object available to get browser client info');
|
|
18
|
+
|
|
18
19
|
return {};
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const nav = window.navigator;
|
|
22
23
|
if (!nav) {
|
|
23
24
|
logger.warn('No navigator object available to get browser client info');
|
|
25
|
+
|
|
24
26
|
return {};
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -41,38 +43,49 @@ function browserClientInfo() {
|
|
|
41
43
|
|
|
42
44
|
function browserTimezone() {
|
|
43
45
|
const tzMatch = /\(([A-Za-z\s].*)\)/.exec(new Date().toString());
|
|
46
|
+
|
|
44
47
|
return tzMatch ? tzMatch[1] || '' : '';
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
function getBrowserType(userAgent: string) {
|
|
48
|
-
|
|
51
|
+
// The latest user agents for Opera: https://www.whatismybrowser.com/guides/the-latest-user-agent/opera
|
|
52
|
+
const operaMatch = /.+(Opera[\s[A-Z]*|OPR[\sA-Z]*)\/([0-9.]+).*/i.exec(
|
|
49
53
|
userAgent
|
|
50
54
|
);
|
|
51
55
|
if (operaMatch) {
|
|
52
56
|
return { type: operaMatch[1], version: operaMatch[2] };
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
// The latest user agents for Edge: https://www.whatismybrowser.com/guides/the-latest-user-agent/edge
|
|
60
|
+
const ieMatch = /.+(Trident|Edge|Edg|EdgA|EdgiOS)\/([0-9.]+).*/i.exec(
|
|
61
|
+
userAgent
|
|
62
|
+
);
|
|
56
63
|
if (ieMatch) {
|
|
57
64
|
return { type: ieMatch[1], version: ieMatch[2] };
|
|
58
65
|
}
|
|
59
66
|
|
|
60
|
-
|
|
67
|
+
// The latest user agents for web browsers on Firefox and Chrome
|
|
68
|
+
// https://www.whatismybrowser.com/guides/the-latest-user-agent/firefox
|
|
69
|
+
// https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome
|
|
70
|
+
const cfMatch = /.+(Chrome|CriOS|Firefox|FxiOS)\/([0-9.]+).*/i.exec(
|
|
71
|
+
userAgent
|
|
72
|
+
);
|
|
61
73
|
if (cfMatch) {
|
|
62
74
|
return { type: cfMatch[1], version: cfMatch[2] };
|
|
63
75
|
}
|
|
64
76
|
|
|
65
|
-
|
|
77
|
+
// The latest user agents for Safari: https://www.whatismybrowser.com/guides/the-latest-user-agent/safari
|
|
78
|
+
const sMatch = /.+(Safari)\/([0-9.]+).*/i.exec(userAgent);
|
|
66
79
|
if (sMatch) {
|
|
67
80
|
return { type: sMatch[1], version: sMatch[2] };
|
|
68
81
|
}
|
|
69
82
|
|
|
70
|
-
const awkMatch = /.+(AppleWebKit)\/([0-9
|
|
83
|
+
const awkMatch = /.+(AppleWebKit)\/([0-9.]+).*/i.exec(userAgent);
|
|
71
84
|
if (awkMatch) {
|
|
72
85
|
return { type: awkMatch[1], version: awkMatch[2] };
|
|
73
86
|
}
|
|
74
87
|
|
|
75
|
-
const anyMatch = /.*([A-Z]+)\/([0-9
|
|
88
|
+
const anyMatch = /.*([A-Z]+)\/([0-9.]+).*/i.exec(userAgent);
|
|
76
89
|
if (anyMatch) {
|
|
77
90
|
return { type: anyMatch[1], version: anyMatch[2] };
|
|
78
91
|
}
|