@aws-amplify/auth 6.15.0 → 6.15.1-unstable.6236acf.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.
@@ -87,14 +87,16 @@ const oauthSignIn = async ({ oauthConfig, provider, clientId, customState, prefe
87
87
  params.append('code_challenge', toCodeChallenge());
88
88
  params.append('code_challenge_method', method);
89
89
  }
90
- const oAuthUrl = new URL('/oauth2/authorize', `https://${domain}/`);
91
- oAuthUrl.search = params.toString();
90
+ // Using URL object is not supported in React Native as the `search` property is read-only
91
+ // See: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Blob/URL.js
92
+ const oAuthUrl = `https://${domain}/oauth2/authorize?${params.toString()}`;
92
93
  // this will only take effect in the following scenarios:
93
94
  // 1. the user cancels the OAuth flow on web via back button, and
94
95
  // 2. when bfcache is enabled
95
96
  (0, cancelOAuthFlow_1.listenForOAuthFlowCancellation)(oauth_1.oAuthStore);
96
97
  // the following is effective only in react-native as openAuthSession resolves only in react-native
97
- const { type, error, url } = (await openAuthSession(oAuthUrl.href, redirectSignIn, preferPrivateSession)) ?? {};
98
+ const { type, error, url } = (await openAuthSession(oAuthUrl, redirectSignIn, preferPrivateSession)) ??
99
+ {};
98
100
  try {
99
101
  if (type === 'error') {
100
102
  throw (0, createOAuthError_1.createOAuthError)(String(error));
@@ -1 +1 @@
1
- {"version":3,"file":"signInWithRedirect.js","sources":["../../../../../src/providers/cognito/apis/signInWithRedirect.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.signInWithRedirect = signInWithRedirect;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nrequire(\"../utils/oauth/enableOAuthListener\");\nconst models_1 = require(\"../types/models\");\nconst utils_2 = require(\"../../../utils\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst oauth_1 = require(\"../utils/oauth\");\nconst createOAuthError_1 = require(\"../utils/oauth/createOAuthError\");\nconst cancelOAuthFlow_1 = require(\"../utils/oauth/cancelOAuthFlow\");\n/**\n * Signs in a user with OAuth. Redirects the application to an Identity Provider.\n *\n * @param input - The SignInWithRedirectInput object, if empty it will redirect to Cognito HostedUI\n *\n * @throws AuthTokenConfigException - Thrown when the user pool config is invalid.\n * @throws OAuthNotConfigureException - Thrown when the oauth config is invalid.\n */\nasync function signInWithRedirect(input) {\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n (0, utils_1.assertOAuthConfig)(authConfig);\n oauth_1.oAuthStore.setAuthConfig(authConfig);\n if (!input?.options?.prompt) {\n await (0, signInHelpers_1.assertUserNotAuthenticated)();\n }\n let provider = 'COGNITO'; // Default\n if (typeof input?.provider === 'string') {\n provider = models_1.cognitoHostedUIIdentityProviderMap[input.provider];\n }\n else if (input?.provider?.custom) {\n provider = input.provider.custom;\n }\n return oauthSignIn({\n oauthConfig: authConfig.loginWith.oauth,\n clientId: authConfig.userPoolClientId,\n provider,\n customState: input?.customState,\n preferPrivateSession: input?.options?.preferPrivateSession,\n options: {\n loginHint: input?.options?.loginHint,\n lang: input?.options?.lang,\n nonce: input?.options?.nonce,\n prompt: input?.options?.prompt,\n },\n authSessionOpener: input?.options?.authSessionOpener,\n });\n}\nconst oauthSignIn = async ({ oauthConfig, provider, clientId, customState, preferPrivateSession, options, authSessionOpener, }) => {\n const { domain, redirectSignIn, responseType, scopes } = oauthConfig;\n const { loginHint, lang, nonce, prompt } = options ?? {};\n const randomState = (0, oauth_1.generateState)();\n const openAuthSession = authSessionOpener || utils_2.openAuthSession;\n /* encodeURIComponent is not URL safe, use urlSafeEncode instead. Cognito\n single-encodes/decodes url on first sign in and double-encodes/decodes url\n when user already signed in. Using encodeURIComponent, Base32, Base64 add\n characters % or = which on further encoding becomes unsafe. '=' create issue\n for parsing query params.\n Refer: https://github.com/aws-amplify/amplify-js/issues/5218 */\n const state = customState\n ? `${randomState}-${(0, utils_1.urlSafeEncode)(customState)}`\n : randomState;\n const { value, method, toCodeChallenge } = (0, oauth_1.generateCodeVerifier)(128);\n const redirectUri = (0, oauth_1.getRedirectUrl)(oauthConfig.redirectSignIn);\n if ((0, utils_1.isBrowser)())\n oauth_1.oAuthStore.storeOAuthInFlight(true);\n oauth_1.oAuthStore.storeOAuthState(state);\n oauth_1.oAuthStore.storePKCE(value);\n const params = new URLSearchParams([\n ['redirect_uri', redirectUri],\n ['response_type', responseType],\n ['client_id', clientId],\n ['identity_provider', provider],\n ['scope', scopes.join(' ')],\n ]);\n loginHint && params.append('login_hint', loginHint);\n lang && params.append('lang', lang);\n nonce && params.append('nonce', nonce);\n prompt && params.append('prompt', prompt.toLowerCase());\n params.append('state', state);\n if (responseType === 'code') {\n params.append('code_challenge', toCodeChallenge());\n params.append('code_challenge_method', method);\n }\n const oAuthUrl = new URL('/oauth2/authorize', `https://${domain}/`);\n oAuthUrl.search = params.toString();\n // this will only take effect in the following scenarios:\n // 1. the user cancels the OAuth flow on web via back button, and\n // 2. when bfcache is enabled\n (0, cancelOAuthFlow_1.listenForOAuthFlowCancellation)(oauth_1.oAuthStore);\n // the following is effective only in react-native as openAuthSession resolves only in react-native\n const { type, error, url } = (await openAuthSession(oAuthUrl.href, redirectSignIn, preferPrivateSession)) ?? {};\n try {\n if (type === 'error') {\n throw (0, createOAuthError_1.createOAuthError)(String(error));\n }\n if (type === 'success' && url) {\n await (0, oauth_1.completeOAuthFlow)({\n currentUrl: url,\n clientId,\n domain,\n redirectUri,\n responseType,\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.SignInWithRedirect),\n preferPrivateSession,\n });\n }\n }\n catch (err) {\n await (0, oauth_1.handleFailure)(err);\n // rethrow the error so it can be caught by `await signInWithRedirect()` in react-native\n throw err;\n }\n};\n"],"names":[],"mappings":";;AACA;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QAAQ,MAAM,IAAI,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;AAC7C;AACA,QAAQ,MAAM,GAAG;AACjB,IAAI;AACJ,CAAC;;"}
1
+ {"version":3,"file":"signInWithRedirect.js","sources":["../../../../../src/providers/cognito/apis/signInWithRedirect.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.signInWithRedirect = signInWithRedirect;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nrequire(\"../utils/oauth/enableOAuthListener\");\nconst models_1 = require(\"../types/models\");\nconst utils_2 = require(\"../../../utils\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst oauth_1 = require(\"../utils/oauth\");\nconst createOAuthError_1 = require(\"../utils/oauth/createOAuthError\");\nconst cancelOAuthFlow_1 = require(\"../utils/oauth/cancelOAuthFlow\");\n/**\n * Signs in a user with OAuth. Redirects the application to an Identity Provider.\n *\n * @param input - The SignInWithRedirectInput object, if empty it will redirect to Cognito HostedUI\n *\n * @throws AuthTokenConfigException - Thrown when the user pool config is invalid.\n * @throws OAuthNotConfigureException - Thrown when the oauth config is invalid.\n */\nasync function signInWithRedirect(input) {\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n (0, utils_1.assertOAuthConfig)(authConfig);\n oauth_1.oAuthStore.setAuthConfig(authConfig);\n if (!input?.options?.prompt) {\n await (0, signInHelpers_1.assertUserNotAuthenticated)();\n }\n let provider = 'COGNITO'; // Default\n if (typeof input?.provider === 'string') {\n provider = models_1.cognitoHostedUIIdentityProviderMap[input.provider];\n }\n else if (input?.provider?.custom) {\n provider = input.provider.custom;\n }\n return oauthSignIn({\n oauthConfig: authConfig.loginWith.oauth,\n clientId: authConfig.userPoolClientId,\n provider,\n customState: input?.customState,\n preferPrivateSession: input?.options?.preferPrivateSession,\n options: {\n loginHint: input?.options?.loginHint,\n lang: input?.options?.lang,\n nonce: input?.options?.nonce,\n prompt: input?.options?.prompt,\n },\n authSessionOpener: input?.options?.authSessionOpener,\n });\n}\nconst oauthSignIn = async ({ oauthConfig, provider, clientId, customState, preferPrivateSession, options, authSessionOpener, }) => {\n const { domain, redirectSignIn, responseType, scopes } = oauthConfig;\n const { loginHint, lang, nonce, prompt } = options ?? {};\n const randomState = (0, oauth_1.generateState)();\n const openAuthSession = authSessionOpener || utils_2.openAuthSession;\n /* encodeURIComponent is not URL safe, use urlSafeEncode instead. Cognito\n single-encodes/decodes url on first sign in and double-encodes/decodes url\n when user already signed in. Using encodeURIComponent, Base32, Base64 add\n characters % or = which on further encoding becomes unsafe. '=' create issue\n for parsing query params.\n Refer: https://github.com/aws-amplify/amplify-js/issues/5218 */\n const state = customState\n ? `${randomState}-${(0, utils_1.urlSafeEncode)(customState)}`\n : randomState;\n const { value, method, toCodeChallenge } = (0, oauth_1.generateCodeVerifier)(128);\n const redirectUri = (0, oauth_1.getRedirectUrl)(oauthConfig.redirectSignIn);\n if ((0, utils_1.isBrowser)())\n oauth_1.oAuthStore.storeOAuthInFlight(true);\n oauth_1.oAuthStore.storeOAuthState(state);\n oauth_1.oAuthStore.storePKCE(value);\n const params = new URLSearchParams([\n ['redirect_uri', redirectUri],\n ['response_type', responseType],\n ['client_id', clientId],\n ['identity_provider', provider],\n ['scope', scopes.join(' ')],\n ]);\n loginHint && params.append('login_hint', loginHint);\n lang && params.append('lang', lang);\n nonce && params.append('nonce', nonce);\n prompt && params.append('prompt', prompt.toLowerCase());\n params.append('state', state);\n if (responseType === 'code') {\n params.append('code_challenge', toCodeChallenge());\n params.append('code_challenge_method', method);\n }\n // Using URL object is not supported in React Native as the `search` property is read-only\n // See: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Blob/URL.js\n const oAuthUrl = `https://${domain}/oauth2/authorize?${params.toString()}`;\n // this will only take effect in the following scenarios:\n // 1. the user cancels the OAuth flow on web via back button, and\n // 2. when bfcache is enabled\n (0, cancelOAuthFlow_1.listenForOAuthFlowCancellation)(oauth_1.oAuthStore);\n // the following is effective only in react-native as openAuthSession resolves only in react-native\n const { type, error, url } = (await openAuthSession(oAuthUrl, redirectSignIn, preferPrivateSession)) ??\n {};\n try {\n if (type === 'error') {\n throw (0, createOAuthError_1.createOAuthError)(String(error));\n }\n if (type === 'success' && url) {\n await (0, oauth_1.completeOAuthFlow)({\n currentUrl: url,\n clientId,\n domain,\n redirectUri,\n responseType,\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.SignInWithRedirect),\n preferPrivateSession,\n });\n }\n }\n catch (err) {\n await (0, oauth_1.handleFailure)(err);\n // rethrow the error so it can be caught by `await signInWithRedirect()` in react-native\n throw err;\n }\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;AAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,OAAO,CAAC,oCAAoC,CAAC;AAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;AACzC,MAAM,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC;AACzD,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;AACzC,MAAM,kBAAkB,GAAG,OAAO,CAAC,iCAAiC,CAAC;AACrE,MAAM,iBAAiB,GAAG,OAAO,CAAC,gCAAgC,CAAC;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB,CAAC,KAAK,EAAE;AACzC,IAAI,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BAAgB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;AACzE,QAAQ;AACR,QAAQ,IAAI,IAAI,KAAK,SAAS,IAAI,GAAG,EAAE;AACvC,YAAY,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE;AACjD,gBAAgB,UAAU,EAAE,GAAG;AAC/B,gBAAgB,QAAQ;AACxB,gBAAgB,MAAM;AACtB,gBAAgB,WAAW;AAC3B,gBAAgB,YAAY;AAC5B,gBAAgB,cAAc,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC;AACzG,gBAAgB,oBAAoB;AACpC,aAAa,CAAC;AACd,QAAQ;AACR,IAAI;AACJ,IAAI,OAAO,GAAG,EAAE;AAChB,QAAQ,MAAM,IAAI,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;AAC7C;AACA,QAAQ,MAAM,GAAG;AACjB,IAAI;AACJ,CAAC;;"}
@@ -94,14 +94,16 @@ const oauthSignIn = async ({ oauthConfig, provider, clientId, customState, prefe
94
94
  params.append('code_challenge', toCodeChallenge());
95
95
  params.append('code_challenge_method', method);
96
96
  }
97
- const oAuthUrl = new URL('/oauth2/authorize', `https://${domain}/`);
98
- oAuthUrl.search = params.toString();
97
+ // Using URL object is not supported in React Native as the `search` property is read-only
98
+ // See: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Blob/URL.js
99
+ const oAuthUrl = `https://${domain}/oauth2/authorize?${params.toString()}`;
99
100
  // this will only take effect in the following scenarios:
100
101
  // 1. the user cancels the OAuth flow on web via back button, and
101
102
  // 2. when bfcache is enabled
102
103
  listenForOAuthFlowCancellation(oAuthStore);
103
104
  // the following is effective only in react-native as openAuthSession resolves only in react-native
104
- const { type, error, url } = (await openAuthSession$1(oAuthUrl.href, redirectSignIn, preferPrivateSession)) ?? {};
105
+ const { type, error, url } = (await openAuthSession$1(oAuthUrl, redirectSignIn, preferPrivateSession)) ??
106
+ {};
105
107
  try {
106
108
  if (type === 'error') {
107
109
  throw createOAuthError(String(error));
@@ -1 +1 @@
1
- {"version":3,"file":"signInWithRedirect.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithRedirect.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { AuthAction, assertOAuthConfig, assertTokenProviderConfig, isBrowser, urlSafeEncode, } from '@aws-amplify/core/internals/utils';\nimport '../utils/oauth/enableOAuthListener';\nimport { cognitoHostedUIIdentityProviderMap } from '../types/models';\nimport { openAuthSession as _openAuthSession, getAuthUserAgentValue, } from '../../../utils';\nimport { assertUserNotAuthenticated } from '../utils/signInHelpers';\nimport { completeOAuthFlow, generateCodeVerifier, generateState, getRedirectUrl, handleFailure, oAuthStore, } from '../utils/oauth';\nimport { createOAuthError } from '../utils/oauth/createOAuthError';\nimport { listenForOAuthFlowCancellation } from '../utils/oauth/cancelOAuthFlow';\n/**\n * Signs in a user with OAuth. Redirects the application to an Identity Provider.\n *\n * @param input - The SignInWithRedirectInput object, if empty it will redirect to Cognito HostedUI\n *\n * @throws AuthTokenConfigException - Thrown when the user pool config is invalid.\n * @throws OAuthNotConfigureException - Thrown when the oauth config is invalid.\n */\nexport async function signInWithRedirect(input) {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n assertOAuthConfig(authConfig);\n oAuthStore.setAuthConfig(authConfig);\n if (!input?.options?.prompt) {\n await assertUserNotAuthenticated();\n }\n let provider = 'COGNITO'; // Default\n if (typeof input?.provider === 'string') {\n provider = cognitoHostedUIIdentityProviderMap[input.provider];\n }\n else if (input?.provider?.custom) {\n provider = input.provider.custom;\n }\n return oauthSignIn({\n oauthConfig: authConfig.loginWith.oauth,\n clientId: authConfig.userPoolClientId,\n provider,\n customState: input?.customState,\n preferPrivateSession: input?.options?.preferPrivateSession,\n options: {\n loginHint: input?.options?.loginHint,\n lang: input?.options?.lang,\n nonce: input?.options?.nonce,\n prompt: input?.options?.prompt,\n },\n authSessionOpener: input?.options?.authSessionOpener,\n });\n}\nconst oauthSignIn = async ({ oauthConfig, provider, clientId, customState, preferPrivateSession, options, authSessionOpener, }) => {\n const { domain, redirectSignIn, responseType, scopes } = oauthConfig;\n const { loginHint, lang, nonce, prompt } = options ?? {};\n const randomState = generateState();\n const openAuthSession = authSessionOpener || _openAuthSession;\n /* encodeURIComponent is not URL safe, use urlSafeEncode instead. Cognito\n single-encodes/decodes url on first sign in and double-encodes/decodes url\n when user already signed in. Using encodeURIComponent, Base32, Base64 add\n characters % or = which on further encoding becomes unsafe. '=' create issue\n for parsing query params.\n Refer: https://github.com/aws-amplify/amplify-js/issues/5218 */\n const state = customState\n ? `${randomState}-${urlSafeEncode(customState)}`\n : randomState;\n const { value, method, toCodeChallenge } = generateCodeVerifier(128);\n const redirectUri = getRedirectUrl(oauthConfig.redirectSignIn);\n if (isBrowser())\n oAuthStore.storeOAuthInFlight(true);\n oAuthStore.storeOAuthState(state);\n oAuthStore.storePKCE(value);\n const params = new URLSearchParams([\n ['redirect_uri', redirectUri],\n ['response_type', responseType],\n ['client_id', clientId],\n ['identity_provider', provider],\n ['scope', scopes.join(' ')],\n ]);\n loginHint && params.append('login_hint', loginHint);\n lang && params.append('lang', lang);\n nonce && params.append('nonce', nonce);\n prompt && params.append('prompt', prompt.toLowerCase());\n params.append('state', state);\n if (responseType === 'code') {\n params.append('code_challenge', toCodeChallenge());\n params.append('code_challenge_method', method);\n }\n const oAuthUrl = new URL('/oauth2/authorize', `https://${domain}/`);\n oAuthUrl.search = params.toString();\n // this will only take effect in the following scenarios:\n // 1. the user cancels the OAuth flow on web via back button, and\n // 2. when bfcache is enabled\n listenForOAuthFlowCancellation(oAuthStore);\n // the following is effective only in react-native as openAuthSession resolves only in react-native\n const { type, error, url } = (await openAuthSession(oAuthUrl.href, redirectSignIn, preferPrivateSession)) ?? {};\n try {\n if (type === 'error') {\n throw createOAuthError(String(error));\n }\n if (type === 'success' && url) {\n await completeOAuthFlow({\n currentUrl: url,\n clientId,\n domain,\n redirectUri,\n responseType,\n userAgentValue: getAuthUserAgentValue(AuthAction.SignInWithRedirect),\n preferPrivateSession,\n });\n }\n }\n catch (err) {\n await handleFailure(err);\n // rethrow the error so it can be caught by `await signInWithRedirect()` in react-native\n throw err;\n }\n};\n"],"names":["openAuthSession","_openAuthSession"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,kBAAkB,CAAC,KAAK,EAAE;AAChD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,iBAAiB,CAAC,UAAU,CAAC;AACjC,IAAI,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC;AACxC,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE;AACjC,QAAQ,MAAM,0BAA0B,EAAE;AAC1C,IAAI;AACJ,IAAI,IAAI,QAAQ,GAAG,SAAS,CAAC;AAC7B,IAAI,IAAI,OAAO,KAAK,EAAE,QAAQ,KAAK,QAAQ,EAAE;AAC7C,QAAQ,QAAQ,GAAG,kCAAkC,CAAC,KAAK,CAAC,QAAQ,CAAC;AACrE,IAAI;AACJ,SAAS,IAAI,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE;AACtC,QAAQ,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM;AACxC,IAAI;AACJ,IAAI,OAAO,WAAW,CAAC;AACvB,QAAQ,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,KAAK;AAC/C,QAAQ,QAAQ,EAAE,UAAU,CAAC,gBAAgB;AAC7C,QAAQ,QAAQ;AAChB,QAAQ,WAAW,EAAE,KAAK,EAAE,WAAW;AACvC,QAAQ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GAAG,CAAC,MAAMD,iBAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,oBAAoB,CAAC,KAAK,EAAE;AACnH,IAAI,IAAI;AACR,QAAQ,IAAI,IAAI,KAAK,OAAO,EAAE;AAC9B,YAAY,MAAM,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjD,QAAQ;AACR,QAAQ,IAAI,IAAI,KAAK,SAAS,IAAI,GAAG,EAAE;AACvC,YAAY,MAAM,iBAAiB,CAAC;AACpC,gBAAgB,UAAU,EAAE,GAAG;AAC/B,gBAAgB,QAAQ;AACxB,gBAAgB,MAAM;AACtB,gBAAgB,WAAW;AAC3B,gBAAgB,YAAY;AAC5B,gBAAgB,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,kBAAkB,CAAC;AACpF,gBAAgB,oBAAoB;AACpC,aAAa,CAAC;AACd,QAAQ;AACR,IAAI;AACJ,IAAI,OAAO,GAAG,EAAE;AAChB,QAAQ,MAAM,aAAa,CAAC,GAAG,CAAC;AAChC;AACA,QAAQ,MAAM,GAAG;AACjB,IAAI;AACJ,CAAC;;;;"}
1
+ {"version":3,"file":"signInWithRedirect.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithRedirect.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { AuthAction, assertOAuthConfig, assertTokenProviderConfig, isBrowser, urlSafeEncode, } from '@aws-amplify/core/internals/utils';\nimport '../utils/oauth/enableOAuthListener';\nimport { cognitoHostedUIIdentityProviderMap } from '../types/models';\nimport { openAuthSession as _openAuthSession, getAuthUserAgentValue, } from '../../../utils';\nimport { assertUserNotAuthenticated } from '../utils/signInHelpers';\nimport { completeOAuthFlow, generateCodeVerifier, generateState, getRedirectUrl, handleFailure, oAuthStore, } from '../utils/oauth';\nimport { createOAuthError } from '../utils/oauth/createOAuthError';\nimport { listenForOAuthFlowCancellation } from '../utils/oauth/cancelOAuthFlow';\n/**\n * Signs in a user with OAuth. Redirects the application to an Identity Provider.\n *\n * @param input - The SignInWithRedirectInput object, if empty it will redirect to Cognito HostedUI\n *\n * @throws AuthTokenConfigException - Thrown when the user pool config is invalid.\n * @throws OAuthNotConfigureException - Thrown when the oauth config is invalid.\n */\nexport async function signInWithRedirect(input) {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n assertOAuthConfig(authConfig);\n oAuthStore.setAuthConfig(authConfig);\n if (!input?.options?.prompt) {\n await assertUserNotAuthenticated();\n }\n let provider = 'COGNITO'; // Default\n if (typeof input?.provider === 'string') {\n provider = cognitoHostedUIIdentityProviderMap[input.provider];\n }\n else if (input?.provider?.custom) {\n provider = input.provider.custom;\n }\n return oauthSignIn({\n oauthConfig: authConfig.loginWith.oauth,\n clientId: authConfig.userPoolClientId,\n provider,\n customState: input?.customState,\n preferPrivateSession: input?.options?.preferPrivateSession,\n options: {\n loginHint: input?.options?.loginHint,\n lang: input?.options?.lang,\n nonce: input?.options?.nonce,\n prompt: input?.options?.prompt,\n },\n authSessionOpener: input?.options?.authSessionOpener,\n });\n}\nconst oauthSignIn = async ({ oauthConfig, provider, clientId, customState, preferPrivateSession, options, authSessionOpener, }) => {\n const { domain, redirectSignIn, responseType, scopes } = oauthConfig;\n const { loginHint, lang, nonce, prompt } = options ?? {};\n const randomState = generateState();\n const openAuthSession = authSessionOpener || _openAuthSession;\n /* encodeURIComponent is not URL safe, use urlSafeEncode instead. Cognito\n single-encodes/decodes url on first sign in and double-encodes/decodes url\n when user already signed in. Using encodeURIComponent, Base32, Base64 add\n characters % or = which on further encoding becomes unsafe. '=' create issue\n for parsing query params.\n Refer: https://github.com/aws-amplify/amplify-js/issues/5218 */\n const state = customState\n ? `${randomState}-${urlSafeEncode(customState)}`\n : randomState;\n const { value, method, toCodeChallenge } = generateCodeVerifier(128);\n const redirectUri = getRedirectUrl(oauthConfig.redirectSignIn);\n if (isBrowser())\n oAuthStore.storeOAuthInFlight(true);\n oAuthStore.storeOAuthState(state);\n oAuthStore.storePKCE(value);\n const params = new URLSearchParams([\n ['redirect_uri', redirectUri],\n ['response_type', responseType],\n ['client_id', clientId],\n ['identity_provider', provider],\n ['scope', scopes.join(' ')],\n ]);\n loginHint && params.append('login_hint', loginHint);\n lang && params.append('lang', lang);\n nonce && params.append('nonce', nonce);\n prompt && params.append('prompt', prompt.toLowerCase());\n params.append('state', state);\n if (responseType === 'code') {\n params.append('code_challenge', toCodeChallenge());\n params.append('code_challenge_method', method);\n }\n // Using URL object is not supported in React Native as the `search` property is read-only\n // See: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Blob/URL.js\n const oAuthUrl = `https://${domain}/oauth2/authorize?${params.toString()}`;\n // this will only take effect in the following scenarios:\n // 1. the user cancels the OAuth flow on web via back button, and\n // 2. when bfcache is enabled\n listenForOAuthFlowCancellation(oAuthStore);\n // the following is effective only in react-native as openAuthSession resolves only in react-native\n const { type, error, url } = (await openAuthSession(oAuthUrl, redirectSignIn, preferPrivateSession)) ??\n {};\n try {\n if (type === 'error') {\n throw createOAuthError(String(error));\n }\n if (type === 'success' && url) {\n await completeOAuthFlow({\n currentUrl: url,\n clientId,\n domain,\n redirectUri,\n responseType,\n userAgentValue: getAuthUserAgentValue(AuthAction.SignInWithRedirect),\n preferPrivateSession,\n });\n }\n }\n catch (err) {\n await handleFailure(err);\n // rethrow the error so it can be caught by `await signInWithRedirect()` in react-native\n throw err;\n }\n};\n"],"names":["openAuthSession","_openAuthSession"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,kBAAkB,CAAC,KAAK,EAAE;AAChD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,iBAAiB,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,EAAE;AAChB,QAAQ,MAAM,aAAa,CAAC,GAAG,CAAC;AAChC;AACA,QAAQ,MAAM,GAAG;AACjB,IAAI;AACJ,CAAC;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { AuthStandardAttributeKey, AuthVerifiableAttributeKey } from '@aws-amplify/core/internals/utils';
2
- import { AWSAuthUser, AuthCodeDeliveryDetails, AuthDevice, AuthUserAttribute } from '../../../types';
2
+ import { AWSAuthUser, AuthCodeDeliveryDetails, AuthDevice } from '../../../types';
3
3
  import { AuthProvider } from '../../../types/inputs';
4
4
  import { SignUpOutput } from './outputs';
5
5
  /**
@@ -43,11 +43,12 @@ export type AutoSignInEventData = {
43
43
  } | {
44
44
  event: 'autoSignIn';
45
45
  };
46
+ type DeviceAttributeKey = 'device_status' | 'device_name' | 'last_ip_used';
46
47
  /**
47
48
  * Holds the device specific information along with it's id and name.
48
49
  */
49
50
  export type AWSAuthDevice = AuthDevice & {
50
- attributes: AuthUserAttribute<UserAttributeKey>;
51
+ attributes: Partial<Record<DeviceAttributeKey, string>> & Record<string, string>;
51
52
  createDate?: Date;
52
53
  lastAuthenticatedDate?: Date;
53
54
  lastModifiedDate?: Date;
@@ -69,3 +70,4 @@ export interface AuthUser extends AWSAuthUser {
69
70
  * Holds data describing the dispatch of a confirmation code.
70
71
  */
71
72
  export type CodeDeliveryDetails<CognitoUserAttributeKey extends UserAttributeKey = UserAttributeKey> = AuthCodeDeliveryDetails<CognitoUserAttributeKey>;
73
+ export {};
package/package.json CHANGED
@@ -1,107 +1,107 @@
1
1
  {
2
- "name": "@aws-amplify/auth",
3
- "version": "6.15.0",
4
- "description": "Auth category of aws-amplify",
5
- "main": "./dist/cjs/index.js",
6
- "module": "./dist/esm/index.mjs",
7
- "typings": "./dist/esm/index.d.ts",
8
- "react-native": "./dist/cjs/index.js",
9
- "sideEffects": [
10
- "./dist/cjs/providers/cognito/apis/signInWithRedirect.js",
11
- "./dist/esm/providers/cognito/apis/signInWithRedirect.mjs",
12
- "./dist/cjs/providers/cognito/utils/oauth/enableOAuthListener.js",
13
- "./dist/esm/providers/cognito/utils/oauth/enableOAuthListener.mjs"
14
- ],
15
- "publishConfig": {
16
- "access": "public"
17
- },
18
- "scripts": {
19
- "test": "yarn lint --fix && jest -w 1 --coverage --logHeapUsage",
20
- "build-with-test": "npm test && npm run build",
21
- "build:umd": "webpack && webpack --config ./webpack.config.dev.js",
22
- "build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
23
- "build:watch": "npm run build:esm-cjs -- --watch",
24
- "build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
25
- "clean": "npm run clean:size && rimraf lib-esm lib dist",
26
- "clean:size": "rimraf dual-publish-tmp tmp*",
27
- "format": "echo \"Not implemented\"",
28
- "lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
29
- "lint:fix": "eslint '**/*.{ts,tsx}' --fix",
30
- "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 91.18"
31
- },
32
- "typesVersions": {
33
- ">=4.2": {
34
- "cognito": [
35
- "./dist/esm/providers/cognito/index.d.ts"
36
- ],
37
- "cognito/server": [
38
- "./dist/esm/providers/cognito/apis/server/index.d.ts"
39
- ],
40
- "server": [
41
- "./dist/esm/server.d.ts"
42
- ]
43
- }
44
- },
45
- "exports": {
46
- ".": {
47
- "react-native": "./dist/cjs/index.js",
48
- "types": "./dist/esm/index.d.ts",
49
- "import": "./dist/esm/index.mjs",
50
- "require": "./dist/cjs/index.js"
51
- },
52
- "./cognito": {
53
- "react-native": "./dist/cjs/providers/cognito/index.js",
54
- "types": "./dist/esm/providers/cognito/index.d.ts",
55
- "import": "./dist/esm/providers/cognito/index.mjs",
56
- "require": "./dist/cjs/providers/cognito/index.js"
57
- },
58
- "./cognito/server": {
59
- "types": "./dist/esm/providers/cognito/apis/server/index.d.ts",
60
- "import": "./dist/esm/providers/cognito/apis/server/index.mjs",
61
- "require": "./dist/cjs/providers/cognito/apis/server/index.js"
62
- },
63
- "./server": {
64
- "types": "./dist/esm/server.d.ts",
65
- "import": "./dist/esm/server.mjs",
66
- "require": "./dist/cjs/server.js"
67
- },
68
- "./enable-oauth-listener": {
69
- "types": "./dist/esm/providers/cognito/utils/oauth/enableOAuthListener.d.ts",
70
- "import": "./dist/esm/providers/cognito/utils/oauth/enableOAuthListener.mjs",
71
- "require": "./dist/cjs/providers/cognito/utils/oauth/enableOAuthListener.js"
72
- },
73
- "./package.json": "./package.json"
74
- },
75
- "repository": {
76
- "type": "git",
77
- "url": "https://github.com/aws-amplify/amplify-js.git"
78
- },
79
- "author": "Amazon Web Services",
80
- "license": "Apache-2.0",
81
- "bugs": {
82
- "url": "https://github.com/aws/aws-amplify/issues"
83
- },
84
- "homepage": "https://aws-amplify.github.io/",
85
- "files": [
86
- "dist/cjs",
87
- "dist/esm",
88
- "src",
89
- "cognito",
90
- "server",
91
- "enable-oauth-listener"
92
- ],
93
- "dependencies": {
94
- "@aws-crypto/sha256-js": "5.2.0",
95
- "@smithy/types": "^3.3.0",
96
- "tslib": "^2.5.0"
97
- },
98
- "peerDependencies": {
99
- "@aws-amplify/core": "^6.1.0"
100
- },
101
- "devDependencies": {
102
- "@aws-amplify/core": "6.13.1",
103
- "@aws-amplify/react-native": "1.1.10",
104
- "@jest/test-sequencer": "^29.7.0"
105
- },
106
- "gitHead": "0b91f4857921a599b31999f04e858a4221eb9c51"
2
+ "name": "@aws-amplify/auth",
3
+ "version": "6.15.1-unstable.6236acf.0+6236acf",
4
+ "description": "Auth category of aws-amplify",
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/esm/index.mjs",
7
+ "typings": "./dist/esm/index.d.ts",
8
+ "react-native": "./dist/cjs/index.js",
9
+ "sideEffects": [
10
+ "./dist/cjs/providers/cognito/apis/signInWithRedirect.js",
11
+ "./dist/esm/providers/cognito/apis/signInWithRedirect.mjs",
12
+ "./dist/cjs/providers/cognito/utils/oauth/enableOAuthListener.js",
13
+ "./dist/esm/providers/cognito/utils/oauth/enableOAuthListener.mjs"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "scripts": {
19
+ "test": "yarn lint --fix && jest -w 1 --coverage --logHeapUsage",
20
+ "build-with-test": "npm test && npm run build",
21
+ "build:umd": "webpack && webpack --config ./webpack.config.dev.js",
22
+ "build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
23
+ "build:watch": "npm run build:esm-cjs -- --watch",
24
+ "build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
25
+ "clean": "npm run clean:size && rimraf lib-esm lib dist",
26
+ "clean:size": "rimraf dual-publish-tmp tmp*",
27
+ "format": "echo \"Not implemented\"",
28
+ "lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
29
+ "lint:fix": "eslint '**/*.{ts,tsx}' --fix",
30
+ "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 91.18"
31
+ },
32
+ "typesVersions": {
33
+ ">=4.2": {
34
+ "cognito": [
35
+ "./dist/esm/providers/cognito/index.d.ts"
36
+ ],
37
+ "cognito/server": [
38
+ "./dist/esm/providers/cognito/apis/server/index.d.ts"
39
+ ],
40
+ "server": [
41
+ "./dist/esm/server.d.ts"
42
+ ]
43
+ }
44
+ },
45
+ "exports": {
46
+ ".": {
47
+ "react-native": "./dist/cjs/index.js",
48
+ "types": "./dist/esm/index.d.ts",
49
+ "import": "./dist/esm/index.mjs",
50
+ "require": "./dist/cjs/index.js"
51
+ },
52
+ "./cognito": {
53
+ "react-native": "./dist/cjs/providers/cognito/index.js",
54
+ "types": "./dist/esm/providers/cognito/index.d.ts",
55
+ "import": "./dist/esm/providers/cognito/index.mjs",
56
+ "require": "./dist/cjs/providers/cognito/index.js"
57
+ },
58
+ "./cognito/server": {
59
+ "types": "./dist/esm/providers/cognito/apis/server/index.d.ts",
60
+ "import": "./dist/esm/providers/cognito/apis/server/index.mjs",
61
+ "require": "./dist/cjs/providers/cognito/apis/server/index.js"
62
+ },
63
+ "./server": {
64
+ "types": "./dist/esm/server.d.ts",
65
+ "import": "./dist/esm/server.mjs",
66
+ "require": "./dist/cjs/server.js"
67
+ },
68
+ "./enable-oauth-listener": {
69
+ "types": "./dist/esm/providers/cognito/utils/oauth/enableOAuthListener.d.ts",
70
+ "import": "./dist/esm/providers/cognito/utils/oauth/enableOAuthListener.mjs",
71
+ "require": "./dist/cjs/providers/cognito/utils/oauth/enableOAuthListener.js"
72
+ },
73
+ "./package.json": "./package.json"
74
+ },
75
+ "repository": {
76
+ "type": "git",
77
+ "url": "https://github.com/aws-amplify/amplify-js.git"
78
+ },
79
+ "author": "Amazon Web Services",
80
+ "license": "Apache-2.0",
81
+ "bugs": {
82
+ "url": "https://github.com/aws/aws-amplify/issues"
83
+ },
84
+ "homepage": "https://aws-amplify.github.io/",
85
+ "files": [
86
+ "dist/cjs",
87
+ "dist/esm",
88
+ "src",
89
+ "cognito",
90
+ "server",
91
+ "enable-oauth-listener"
92
+ ],
93
+ "dependencies": {
94
+ "@aws-crypto/sha256-js": "5.2.0",
95
+ "@smithy/types": "^3.3.0",
96
+ "tslib": "^2.5.0"
97
+ },
98
+ "peerDependencies": {
99
+ "@aws-amplify/core": "6.13.2-unstable.6236acf.0+6236acf"
100
+ },
101
+ "devDependencies": {
102
+ "@aws-amplify/core": "6.13.2-unstable.6236acf.0+6236acf",
103
+ "@aws-amplify/react-native": "1.1.11-unstable.6236acf.0+6236acf",
104
+ "@jest/test-sequencer": "^29.7.0"
105
+ },
106
+ "gitHead": "6236acf8ed80d647a15b6f777727b2647154f3a8"
107
107
  }
@@ -130,8 +130,10 @@ const oauthSignIn = async ({
130
130
  params.append('code_challenge', toCodeChallenge());
131
131
  params.append('code_challenge_method', method);
132
132
  }
133
- const oAuthUrl = new URL('/oauth2/authorize', `https://${domain}/`);
134
- oAuthUrl.search = params.toString();
133
+
134
+ // Using URL object is not supported in React Native as the `search` property is read-only
135
+ // See: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Blob/URL.js
136
+ const oAuthUrl = `https://${domain}/oauth2/authorize?${params.toString()}`;
135
137
 
136
138
  // this will only take effect in the following scenarios:
137
139
  // 1. the user cancels the OAuth flow on web via back button, and
@@ -140,11 +142,8 @@ const oauthSignIn = async ({
140
142
 
141
143
  // the following is effective only in react-native as openAuthSession resolves only in react-native
142
144
  const { type, error, url } =
143
- (await openAuthSession(
144
- oAuthUrl.href,
145
- redirectSignIn,
146
- preferPrivateSession,
147
- )) ?? {};
145
+ (await openAuthSession(oAuthUrl, redirectSignIn, preferPrivateSession)) ??
146
+ {};
148
147
 
149
148
  try {
150
149
  if (type === 'error') {
@@ -10,7 +10,6 @@ import {
10
10
  AWSAuthUser,
11
11
  AuthCodeDeliveryDetails,
12
12
  AuthDevice,
13
- AuthUserAttribute,
14
13
  } from '../../../types';
15
14
  import { AuthProvider } from '../../../types/inputs';
16
15
 
@@ -89,11 +88,15 @@ export type AutoSignInEventData =
89
88
  | {
90
89
  event: 'autoSignIn';
91
90
  };
91
+
92
+ type DeviceAttributeKey = 'device_status' | 'device_name' | 'last_ip_used';
93
+
92
94
  /**
93
95
  * Holds the device specific information along with it's id and name.
94
96
  */
95
97
  export type AWSAuthDevice = AuthDevice & {
96
- attributes: AuthUserAttribute<UserAttributeKey>;
98
+ attributes: Partial<Record<DeviceAttributeKey, string>> &
99
+ Record<string, string>;
97
100
  createDate?: Date;
98
101
  lastAuthenticatedDate?: Date;
99
102
  lastModifiedDate?: Date;