expo-auth-session 3.6.0 → 3.7.1

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/CHANGELOG.md CHANGED
@@ -10,6 +10,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 3.7.1 — 2022-07-16
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
17
+ ## 3.7.0 — 2022-07-07
18
+
19
+ ### 🎉 New features
20
+
21
+ - Add projectNameForProxy option. ([#17327](https://github.com/expo/expo/pull/17327) by [@wschurman](https://github.com/wschurman))
22
+
13
23
  ## 3.6.0 — 2022-04-18
14
24
 
15
25
  ### 💡 Others
@@ -126,7 +126,7 @@ export class AuthRequest {
126
126
  let returnUrl = this.redirectUri;
127
127
  if (options.useProxy) {
128
128
  returnUrl = sessionUrlProvider.getDefaultReturnUrl(proxyOptions?.path, proxyOptions);
129
- startUrl = sessionUrlProvider.getStartUrl(url, returnUrl);
129
+ startUrl = sessionUrlProvider.getStartUrl(url, returnUrl, options.projectNameForProxy);
130
130
  }
131
131
  // Prevent multiple sessions from running at the same time, WebBrowser doesn't
132
132
  // support it this makes the behavior predictable.
@@ -1 +1 @@
1
- {"version":3,"file":"AuthRequest.js","sourceRoot":"","sources":["../src/AuthRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAGL,mBAAmB,EACnB,YAAY,GAEb,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,gBA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AC,qBAAqB,IAAI,KAAK,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAEO,KAAK,CAAC,sBAAsB;QAClC,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,OAAO;SACR;QAED,kEAAkE;QAClE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAEpE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF","sourcesContent":["import * as WebBrowser from 'expo-web-browser';\nimport invariant from 'invariant';\nimport { Platform } from 'react-native';\n\nimport {\n AuthRequestConfig,\n AuthRequestPromptOptions,\n CodeChallengeMethod,\n ResponseType,\n Prompt,\n} from './AuthRequest.types';\nimport { AuthSessionResult } from './AuthSession.types';\nimport { DiscoveryDocument } from './Discovery';\nimport { AuthError } from './Errors';\nimport * as PKCE from './PKCE';\nimport * as QueryParams from './QueryParams';\nimport sessionUrlProvider from './SessionUrlProvider';\nimport { TokenResponse } from './TokenRequest';\n\nlet _authLock: boolean = false;\n\ntype AuthDiscoveryDocument = Pick<DiscoveryDocument, 'authorizationEndpoint'>;\n\n// @needsAudit @docsMissing\n/**\n * Used to manage an authorization request according to the OAuth spec: [Section 4.1.1][https://tools.ietf.org/html/rfc6749#section-4.1.1].\n * You can use this class directly for more info around the authorization.\n *\n * **Common use-cases:**\n *\n * - Parse a URL returned from the authorization server with `parseReturnUrlAsync()`.\n * - Get the built authorization URL with `makeAuthUrlAsync()`.\n * - Get a loaded JSON representation of the auth request with crypto state loaded with `getAuthRequestConfigAsync()`.\n *\n * @example\n * ```ts\n * // Create a request.\n * const request = new AuthRequest({ ... });\n *\n * // Prompt for an auth code\n * const result = await request.promptAsync(discovery, { useProxy: true });\n *\n * // Get the URL to invoke\n * const url = await request.makeAuthUrlAsync(discovery);\n *\n * // Get the URL to invoke\n * const parsed = await request.parseReturnUrlAsync(\"<URL From Server>\");\n * ```\n */\nexport class AuthRequest implements Omit<AuthRequestConfig, 'state'> {\n /**\n * Used for protection against [Cross-Site Request Forgery](https://tools.ietf.org/html/rfc6749#section-10.12).\n */\n public state: string;\n public url: string | null = null;\n public codeVerifier?: string;\n public codeChallenge?: string;\n\n readonly responseType: ResponseType | string;\n readonly clientId: string;\n readonly extraParams: Record<string, string>;\n readonly usePKCE?: boolean;\n readonly codeChallengeMethod: CodeChallengeMethod;\n readonly redirectUri: string;\n readonly scopes?: string[];\n readonly clientSecret?: string;\n readonly prompt?: Prompt;\n\n constructor(request: AuthRequestConfig) {\n this.responseType = request.responseType ?? ResponseType.Code;\n this.clientId = request.clientId;\n this.redirectUri = request.redirectUri;\n this.scopes = request.scopes;\n this.clientSecret = request.clientSecret;\n this.prompt = request.prompt;\n this.state = request.state ?? PKCE.generateRandom(10);\n this.extraParams = request.extraParams ?? {};\n this.codeChallengeMethod = request.codeChallengeMethod ?? CodeChallengeMethod.S256;\n // PKCE defaults to true\n this.usePKCE = request.usePKCE ?? true;\n\n // Some warnings in development about potential confusing application code\n if (__DEV__) {\n if (this.prompt && this.extraParams.prompt) {\n console.warn(`\\`AuthRequest\\` \\`extraParams.prompt\\` will be overwritten by \\`prompt\\`.`);\n }\n if (this.clientSecret && this.extraParams.client_secret) {\n console.warn(\n `\\`AuthRequest\\` \\`extraParams.client_secret\\` will be overwritten by \\`clientSecret\\`.`\n );\n }\n if (this.codeChallengeMethod && this.extraParams.code_challenge_method) {\n console.warn(\n `\\`AuthRequest\\` \\`extraParams.code_challenge_method\\` will be overwritten by \\`codeChallengeMethod\\`.`\n );\n }\n }\n\n invariant(\n this.codeChallengeMethod !== CodeChallengeMethod.Plain,\n `\\`AuthRequest\\` does not support \\`CodeChallengeMethod.Plain\\` as it's not secure.`\n );\n invariant(\n this.redirectUri,\n `\\`AuthRequest\\` requires a valid \\`redirectUri\\`. Ex: ${Platform.select({\n web: 'https://yourwebsite.com/',\n default: 'com.your.app:/oauthredirect',\n })}`\n );\n }\n\n /**\n * Load and return a valid auth request based on the input config.\n */\n async getAuthRequestConfigAsync(): Promise<AuthRequestConfig> {\n if (this.usePKCE) {\n await this.ensureCodeIsSetupAsync();\n }\n\n return {\n responseType: this.responseType,\n clientId: this.clientId,\n redirectUri: this.redirectUri,\n scopes: this.scopes,\n clientSecret: this.clientSecret,\n codeChallenge: this.codeChallenge,\n codeChallengeMethod: this.codeChallengeMethod,\n prompt: this.prompt,\n state: this.state,\n extraParams: this.extraParams,\n usePKCE: this.usePKCE,\n };\n }\n\n /**\n * Prompt a user to authorize for a code.\n *\n * @param discovery\n * @param promptOptions\n */\n async promptAsync(\n discovery: AuthDiscoveryDocument,\n { url, proxyOptions, ...options }: AuthRequestPromptOptions = {}\n ): Promise<AuthSessionResult> {\n if (!url) {\n if (!this.url) {\n // Generate a new url\n return this.promptAsync(discovery, {\n ...options,\n url: await this.makeAuthUrlAsync(discovery),\n });\n }\n // Reuse the preloaded url\n url = this.url;\n }\n\n // Prevent accidentally starting to an empty url\n invariant(\n url,\n 'No authUrl provided to AuthSession.startAsync. An authUrl is required -- it points to the page where the user will be able to sign in.'\n );\n\n let startUrl: string = url!;\n let returnUrl: string = this.redirectUri;\n if (options.useProxy) {\n returnUrl = sessionUrlProvider.getDefaultReturnUrl(proxyOptions?.path, proxyOptions);\n startUrl = sessionUrlProvider.getStartUrl(url, returnUrl);\n }\n // Prevent multiple sessions from running at the same time, WebBrowser doesn't\n // support it this makes the behavior predictable.\n if (_authLock) {\n if (__DEV__) {\n console.warn(\n 'Attempted to call AuthSession.startAsync multiple times while already active. Only one AuthSession can be active at any given time.'\n );\n }\n\n return { type: 'locked' };\n }\n\n // About to start session, set lock\n _authLock = true;\n\n let result: WebBrowser.WebBrowserAuthSessionResult;\n try {\n const { useProxy, ...openOptions } = options;\n result = await WebBrowser.openAuthSessionAsync(startUrl, returnUrl, openOptions);\n } finally {\n _authLock = false;\n }\n\n if (result.type === 'opened') {\n // This should never happen\n throw new Error('An unexpected error occurred');\n }\n if (result.type !== 'success') {\n return { type: result.type };\n }\n\n return this.parseReturnUrl(result.url);\n }\n\n parseReturnUrl(url: string): AuthSessionResult {\n const { params, errorCode } = QueryParams.getQueryParams(url);\n const { state, error = errorCode } = params;\n\n let parsedError: AuthError | null = null;\n let authentication: TokenResponse | null = null;\n if (state !== this.state) {\n // This is a non-standard error\n parsedError = new AuthError({\n error: 'state_mismatch',\n error_description:\n 'Cross-Site request verification failed. Cached state and returned state do not match.',\n });\n } else if (error) {\n parsedError = new AuthError({ error, ...params });\n }\n if (params.access_token) {\n authentication = TokenResponse.fromQueryParams(params);\n }\n\n return {\n type: parsedError ? 'error' : 'success',\n error: parsedError,\n url,\n params,\n authentication,\n\n // Return errorCode for legacy\n errorCode,\n };\n }\n\n /**\n * Create the URL for authorization.\n *\n * @param discovery\n */\n async makeAuthUrlAsync(discovery: AuthDiscoveryDocument): Promise<string> {\n const request = await this.getAuthRequestConfigAsync();\n if (!request.state) throw new Error('Cannot make request URL without a valid `state` loaded');\n\n // Create a query string\n const params: Record<string, string> = {};\n\n if (request.codeChallenge) {\n params.code_challenge = request.codeChallenge;\n }\n\n // copy over extra params\n for (const extra in request.extraParams) {\n if (extra in request.extraParams) {\n params[extra] = request.extraParams[extra];\n }\n }\n\n if (request.usePKCE && request.codeChallengeMethod) {\n params.code_challenge_method = request.codeChallengeMethod;\n }\n\n if (request.clientSecret) {\n params.client_secret = request.clientSecret;\n }\n\n if (request.prompt) {\n params.prompt = request.prompt;\n }\n\n // These overwrite any extra params\n params.redirect_uri = request.redirectUri;\n params.client_id = request.clientId;\n params.response_type = request.responseType!;\n params.state = request.state;\n\n if (request.scopes?.length) {\n params.scope = request.scopes.join(' ');\n }\n\n const query = QueryParams.buildQueryString(params);\n // Store the URL for later\n this.url = `${discovery.authorizationEndpoint}?${query}`;\n return this.url;\n }\n\n private async ensureCodeIsSetupAsync(): Promise<void> {\n if (this.codeVerifier) {\n return;\n }\n\n // This method needs to be resolved like all other native methods.\n const { codeVerifier, codeChallenge } = await PKCE.buildCodeAsync();\n\n this.codeVerifier = codeVerifier;\n this.codeChallenge = codeChallenge;\n }\n}\n"]}
1
+ {"version":3,"file":"AuthRequest.js","sourceRoot":"","sources":["../src/AuthRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAGL,mBAAmB,EACnB,YAAY,GAEb,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,IAAI,SAAS,GAAY,KAAK,CAAC;AAI/B,2BAA2B;AAC3B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,WAAW;IACtB;;OAEG;IACI,KAAK,CAAS;IACd,GAAG,GAAkB,IAAI,CAAC;IAC1B,YAAY,CAAU;IACtB,aAAa,CAAU;IAErB,YAAY,CAAwB;IACpC,QAAQ,CAAS;IACjB,WAAW,CAAyB;IACpC,OAAO,CAAW;IAClB,mBAAmB,CAAsB;IACzC,WAAW,CAAS;IACpB,MAAM,CAAY;IAClB,YAAY,CAAU;IACtB,MAAM,CAAU;IAEzB,YAAY,OAA0B;QACpC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,YAAY,CAAC,IAAI,CAAC;QAC9D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC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GAAG,OAAO,CAAC,YAAY,CAAC;SAC7C;QAED,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;SAChC;QAED,mCAAmC;QACnC,MAAM,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;QAC1C,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;QACpC,MAAM,CAAC,aAAa,GAAG,OAAO,CAAC,YAAa,CAAC;QAC7C,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAE7B,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE;YAC1B,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACzC;QAED,MAAM,KAAK,GAAG,WAAW,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACnD,0BAA0B;QAC1B,IAAI,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC,qBAAqB,IAAI,KAAK,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAEO,KAAK,CAAC,sBAAsB;QAClC,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,OAAO;SACR;QAED,kEAAkE;QAClE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAEpE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF","sourcesContent":["import * as WebBrowser from 'expo-web-browser';\nimport invariant from 'invariant';\nimport { Platform } from 'react-native';\n\nimport {\n AuthRequestConfig,\n AuthRequestPromptOptions,\n CodeChallengeMethod,\n ResponseType,\n Prompt,\n} from './AuthRequest.types';\nimport { AuthSessionResult } from './AuthSession.types';\nimport { DiscoveryDocument } from './Discovery';\nimport { AuthError } from './Errors';\nimport * as PKCE from './PKCE';\nimport * as QueryParams from './QueryParams';\nimport sessionUrlProvider from './SessionUrlProvider';\nimport { TokenResponse } from './TokenRequest';\n\nlet _authLock: boolean = false;\n\ntype AuthDiscoveryDocument = Pick<DiscoveryDocument, 'authorizationEndpoint'>;\n\n// @needsAudit @docsMissing\n/**\n * Used to manage an authorization request according to the OAuth spec: [Section 4.1.1][https://tools.ietf.org/html/rfc6749#section-4.1.1].\n * You can use this class directly for more info around the authorization.\n *\n * **Common use-cases:**\n *\n * - Parse a URL returned from the authorization server with `parseReturnUrlAsync()`.\n * - Get the built authorization URL with `makeAuthUrlAsync()`.\n * - Get a loaded JSON representation of the auth request with crypto state loaded with `getAuthRequestConfigAsync()`.\n *\n * @example\n * ```ts\n * // Create a request.\n * const request = new AuthRequest({ ... });\n *\n * // Prompt for an auth code\n * const result = await request.promptAsync(discovery, { useProxy: true });\n *\n * // Get the URL to invoke\n * const url = await request.makeAuthUrlAsync(discovery);\n *\n * // Get the URL to invoke\n * const parsed = await request.parseReturnUrlAsync(\"<URL From Server>\");\n * ```\n */\nexport class AuthRequest implements Omit<AuthRequestConfig, 'state'> {\n /**\n * Used for protection against [Cross-Site Request Forgery](https://tools.ietf.org/html/rfc6749#section-10.12).\n */\n public state: string;\n public url: string | null = null;\n public codeVerifier?: string;\n public codeChallenge?: string;\n\n readonly responseType: ResponseType | string;\n readonly clientId: string;\n readonly extraParams: Record<string, string>;\n readonly usePKCE?: boolean;\n readonly codeChallengeMethod: CodeChallengeMethod;\n readonly redirectUri: string;\n readonly scopes?: string[];\n readonly clientSecret?: string;\n readonly prompt?: Prompt;\n\n constructor(request: AuthRequestConfig) {\n this.responseType = request.responseType ?? ResponseType.Code;\n this.clientId = request.clientId;\n this.redirectUri = request.redirectUri;\n this.scopes = request.scopes;\n this.clientSecret = request.clientSecret;\n this.prompt = request.prompt;\n this.state = request.state ?? PKCE.generateRandom(10);\n this.extraParams = request.extraParams ?? {};\n this.codeChallengeMethod = request.codeChallengeMethod ?? CodeChallengeMethod.S256;\n // PKCE defaults to true\n this.usePKCE = request.usePKCE ?? true;\n\n // Some warnings in development about potential confusing application code\n if (__DEV__) {\n if (this.prompt && this.extraParams.prompt) {\n console.warn(`\\`AuthRequest\\` \\`extraParams.prompt\\` will be overwritten by \\`prompt\\`.`);\n }\n if (this.clientSecret && this.extraParams.client_secret) {\n console.warn(\n `\\`AuthRequest\\` \\`extraParams.client_secret\\` will be overwritten by \\`clientSecret\\`.`\n );\n }\n if (this.codeChallengeMethod && this.extraParams.code_challenge_method) {\n console.warn(\n `\\`AuthRequest\\` \\`extraParams.code_challenge_method\\` will be overwritten by \\`codeChallengeMethod\\`.`\n );\n }\n }\n\n invariant(\n this.codeChallengeMethod !== CodeChallengeMethod.Plain,\n `\\`AuthRequest\\` does not support \\`CodeChallengeMethod.Plain\\` as it's not secure.`\n );\n invariant(\n this.redirectUri,\n `\\`AuthRequest\\` requires a valid \\`redirectUri\\`. Ex: ${Platform.select({\n web: 'https://yourwebsite.com/',\n default: 'com.your.app:/oauthredirect',\n })}`\n );\n }\n\n /**\n * Load and return a valid auth request based on the input config.\n */\n async getAuthRequestConfigAsync(): Promise<AuthRequestConfig> {\n if (this.usePKCE) {\n await this.ensureCodeIsSetupAsync();\n }\n\n return {\n responseType: this.responseType,\n clientId: this.clientId,\n redirectUri: this.redirectUri,\n scopes: this.scopes,\n clientSecret: this.clientSecret,\n codeChallenge: this.codeChallenge,\n codeChallengeMethod: this.codeChallengeMethod,\n prompt: this.prompt,\n state: this.state,\n extraParams: this.extraParams,\n usePKCE: this.usePKCE,\n };\n }\n\n /**\n * Prompt a user to authorize for a code.\n *\n * @param discovery\n * @param promptOptions\n */\n async promptAsync(\n discovery: AuthDiscoveryDocument,\n { url, proxyOptions, ...options }: AuthRequestPromptOptions = {}\n ): Promise<AuthSessionResult> {\n if (!url) {\n if (!this.url) {\n // Generate a new url\n return this.promptAsync(discovery, {\n ...options,\n url: await this.makeAuthUrlAsync(discovery),\n });\n }\n // Reuse the preloaded url\n url = this.url;\n }\n\n // Prevent accidentally starting to an empty url\n invariant(\n url,\n 'No authUrl provided to AuthSession.startAsync. An authUrl is required -- it points to the page where the user will be able to sign in.'\n );\n\n let startUrl: string = url!;\n let returnUrl: string = this.redirectUri;\n if (options.useProxy) {\n returnUrl = sessionUrlProvider.getDefaultReturnUrl(proxyOptions?.path, proxyOptions);\n startUrl = sessionUrlProvider.getStartUrl(url, returnUrl, options.projectNameForProxy);\n }\n // Prevent multiple sessions from running at the same time, WebBrowser doesn't\n // support it this makes the behavior predictable.\n if (_authLock) {\n if (__DEV__) {\n console.warn(\n 'Attempted to call AuthSession.startAsync multiple times while already active. Only one AuthSession can be active at any given time.'\n );\n }\n\n return { type: 'locked' };\n }\n\n // About to start session, set lock\n _authLock = true;\n\n let result: WebBrowser.WebBrowserAuthSessionResult;\n try {\n const { useProxy, ...openOptions } = options;\n result = await WebBrowser.openAuthSessionAsync(startUrl, returnUrl, openOptions);\n } finally {\n _authLock = false;\n }\n\n if (result.type === 'opened') {\n // This should never happen\n throw new Error('An unexpected error occurred');\n }\n if (result.type !== 'success') {\n return { type: result.type };\n }\n\n return this.parseReturnUrl(result.url);\n }\n\n parseReturnUrl(url: string): AuthSessionResult {\n const { params, errorCode } = QueryParams.getQueryParams(url);\n const { state, error = errorCode } = params;\n\n let parsedError: AuthError | null = null;\n let authentication: TokenResponse | null = null;\n if (state !== this.state) {\n // This is a non-standard error\n parsedError = new AuthError({\n error: 'state_mismatch',\n error_description:\n 'Cross-Site request verification failed. Cached state and returned state do not match.',\n });\n } else if (error) {\n parsedError = new AuthError({ error, ...params });\n }\n if (params.access_token) {\n authentication = TokenResponse.fromQueryParams(params);\n }\n\n return {\n type: parsedError ? 'error' : 'success',\n error: parsedError,\n url,\n params,\n authentication,\n\n // Return errorCode for legacy\n errorCode,\n };\n }\n\n /**\n * Create the URL for authorization.\n *\n * @param discovery\n */\n async makeAuthUrlAsync(discovery: AuthDiscoveryDocument): Promise<string> {\n const request = await this.getAuthRequestConfigAsync();\n if (!request.state) throw new Error('Cannot make request URL without a valid `state` loaded');\n\n // Create a query string\n const params: Record<string, string> = {};\n\n if (request.codeChallenge) {\n params.code_challenge = request.codeChallenge;\n }\n\n // copy over extra params\n for (const extra in request.extraParams) {\n if (extra in request.extraParams) {\n params[extra] = request.extraParams[extra];\n }\n }\n\n if (request.usePKCE && request.codeChallengeMethod) {\n params.code_challenge_method = request.codeChallengeMethod;\n }\n\n if (request.clientSecret) {\n params.client_secret = request.clientSecret;\n }\n\n if (request.prompt) {\n params.prompt = request.prompt;\n }\n\n // These overwrite any extra params\n params.redirect_uri = request.redirectUri;\n params.client_id = request.clientId;\n params.response_type = request.responseType!;\n params.state = request.state;\n\n if (request.scopes?.length) {\n params.scope = request.scopes.join(' ');\n }\n\n const query = QueryParams.buildQueryString(params);\n // Store the URL for later\n this.url = `${discovery.authorizationEndpoint}?${query}`;\n return this.url;\n }\n\n private async ensureCodeIsSetupAsync(): Promise<void> {\n if (this.codeVerifier) {\n return;\n }\n\n // This method needs to be resolved like all other native methods.\n const { codeVerifier, codeChallenge } = await PKCE.buildCodeAsync();\n\n this.codeVerifier = codeVerifier;\n this.codeChallenge = codeChallenge;\n }\n}\n"]}
@@ -76,6 +76,10 @@ export declare type AuthRequestPromptOptions = Omit<WebBrowserOpenOptions, 'wind
76
76
  * @default false
77
77
  */
78
78
  useProxy?: boolean;
79
+ /**
80
+ * Project name to use for the \`auth.expo.io\` proxy when `useProxy` is true.
81
+ */
82
+ projectNameForProxy?: string;
79
83
  /**
80
84
  * URL options to be used when creating the redirect URL for the auth proxy.
81
85
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AuthRequest.types.d.ts","sourceRoot":"","sources":["../src/AuthRequest.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAGnF,oB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IAChC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IACrC;;;;;;;;OAQG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"AuthRequest.types.js","sourceRoot":"","sources":["../src/AuthRequest.types.ts"],"names":[],"mappings":"AAGA,cAAc;AACd,MAAM,CAAN,IAAY,mBAYX;AAZD,WAAY,mBAAmB;IAC7B;;;;;OAKG;IACH,oCAAa,CAAA;IACb;;OAEG;IACH,sCAAe,CAAA;AACjB,CAAC,EAZW,mBAAmB,KAAnB,mBAAmB,QAY9B;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAN,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB;;OAEG;IACH,6BAAa,CAAA;IACb;;OAEG;IACH,+BAAe,CAAA;IACf;;OAEG;IACH,oCAAoB,CAAA;AACtB,CAAC,EAbW,YAAY,KAAZ,YAAY,QAavB;AAED,cAAc;AACd;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,MAsBX;AAtBD,WAAY,MAAM;IAChB;;;;OAIG;IACH,uBAAa,CAAA;IACb;;;OAGG;IACH,yBAAe,CAAA;IACf;;;OAGG;IACH,6BAAmB,CAAA;IACnB;;;OAGG;IACH,0CAAgC,CAAA;AAClC,CAAC,EAtBW,MAAM,KAAN,MAAM,QAsBjB","sourcesContent":["import { CreateURLOptions } from 'expo-linking';\nimport { WebBrowserOpenOptions, WebBrowserWindowFeatures } from 'expo-web-browser';\n\n// @needsAudit\nexport enum CodeChallengeMethod {\n /**\n * The default and recommended method for transforming the code verifier.\n * - Convert the code verifier to ASCII.\n * - Create a digest of the string using crypto method SHA256.\n * - Convert the digest to Base64 and URL encode it.\n */\n S256 = 'S256',\n /**\n * This should not be used. When used, the code verifier will be sent to the server as-is.\n */\n Plain = 'plain',\n}\n\n// @needsAudit\n/**\n * The client informs the authorization server of the desired grant type by using the response type.\n *\n * @see [Section 3.1.1](https://tools.ietf.org/html/rfc6749#section-3.1.1).\n */\nexport enum ResponseType {\n /**\n * For requesting an authorization code as described by [Section 4.1.1](https://tools.ietf.org/html/rfc6749#section-4.1.1).\n */\n Code = 'code',\n /**\n * For requesting an access token (implicit grant) as described by [Section 4.2.1](https://tools.ietf.org/html/rfc6749#section-4.2.1).\n */\n Token = 'token',\n /**\n * A custom registered type for getting an `id_token` from Google OAuth.\n */\n IdToken = 'id_token',\n}\n\n// @needsAudit\n/**\n * Informs the server if the user should be prompted to login or consent again.\n * This can be used to present a dialog for switching accounts after the user has already been logged in.\n * You should use this in favor of clearing cookies (which is mostly not possible on iOS).\n *\n * @see [Section 3.1.2.1](https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationRequest).\n */\nexport enum Prompt {\n /**\n * Server must not display any auth or consent UI. Can be used to check for existing auth or consent.\n * An error is returned if a user isn't already authenticated or the client doesn't have pre-configured consent for the requested claims, or does not fulfill other conditions for processing the request.\n * The error code will typically be `login_required`, `interaction_required`, or another code defined in [Section 3.1.2.6](https://openid.net/specs/openid-connect-core-1_0.html#AuthError).\n */\n None = 'none',\n /**\n * The server should prompt the user to reauthenticate.\n * If it cannot reauthenticate the End-User, it must return an error, typically `login_required`.\n */\n Login = 'login',\n /**\n * Server should prompt the user for consent before returning information to the client.\n * If it cannot obtain consent, it must return an error, typically `consent_required`.\n */\n Consent = 'consent',\n /**\n * Server should prompt the user to select an account. Can be used to switch accounts.\n * If it can't obtain an account selection choice made by the user, it must return an error, typically `account_selection_required`.\n */\n SelectAccount = 'select_account',\n}\n\n// @needsAudit\n/**\n * Options passed to the `promptAsync()` method of `AuthRequest`s.\n * This can be used to configure how the web browser should look and behave.\n */\nexport type AuthRequestPromptOptions = Omit<WebBrowserOpenOptions, 'windowFeatures'> & {\n /**\n * URL to open when prompting the user. This usually should be defined internally and left `undefined` in most cases.\n */\n url?: string;\n /**\n * Should the authentication request use the Expo proxy service `auth.expo.io`.\n * @default false\n */\n useProxy?: boolean;\n /**\n * URL options to be used when creating the redirect URL for the auth proxy.\n */\n proxyOptions?: Omit<CreateURLOptions, 'queryParams'> & { path?: string };\n /**\n * Features to use with `window.open()`.\n * @platform web\n */\n windowFeatures?: WebBrowserWindowFeatures;\n};\n\n// @needsAudit\n/**\n * Represents an OAuth authorization request as JSON.\n */\nexport interface AuthRequestConfig {\n /**\n * Specifies what is returned from the authorization server.\n *\n * [Section 3.1.1](https://tools.ietf.org/html/rfc6749#section-3.1.1)\n *\n * @default ResponseType.Code\n */\n responseType?: ResponseType | string;\n /**\n * A unique string representing the registration information provided by the client.\n * The client identifier is not a secret; it is exposed to the resource owner and shouldn't be used\n * alone for client authentication.\n *\n * The client identifier is unique to the authorization server.\n *\n * [Section 2.2](https://tools.ietf.org/html/rfc6749#section-2.2)\n */\n clientId: string;\n /**\n * After completing an interaction with a resource owner the\n * server will redirect to this URI. Learn more about [linking in Expo](https://docs.expo.dev/versions/latest/workflow/linking/).\n *\n * [Section 3.1.2](https://tools.ietf.org/html/rfc6749#section-3.1.2)\n */\n redirectUri: string;\n /**\n * List of strings to request access to.\n *\n * [Section 3.3](https://tools.ietf.org/html/rfc6749#section-3.3)\n */\n scopes?: string[];\n /**\n * Client secret supplied by an auth provider.\n * There is no secure way to store this on the client.\n *\n * [Section 2.3.1](https://tools.ietf.org/html/rfc6749#section-2.3.1)\n */\n clientSecret?: string;\n /**\n * Method used to generate the code challenge. You should never use `Plain` as it's not good enough for secure verification.\n * @default CodeChallengeMethod.S256\n */\n codeChallengeMethod?: CodeChallengeMethod;\n /**\n * Derived from the code verifier by using the `CodeChallengeMethod`.\n *\n * [Section 4.2](https://tools.ietf.org/html/rfc7636#section-4.2)\n */\n codeChallenge?: string;\n /**\n * Informs the server if the user should be prompted to login or consent again.\n * This can be used to present a dialog for switching accounts after the user has already been logged in.\n *\n * [Section 3.1.2.1](https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationRequest)\n */\n prompt?: Prompt;\n /**\n * Used for protection against [Cross-Site Request Forgery](https://tools.ietf.org/html/rfc6749#section-10.12).\n */\n state?: string;\n /**\n * Extra query params that'll be added to the query string.\n */\n extraParams?: Record<string, string>;\n /**\n * Should use [Proof Key for Code Exchange](https://oauth.net/2/pkce/).\n * @default true\n */\n usePKCE?: boolean;\n}\n"]}
1
+ {"version":3,"file":"AuthRequest.types.js","sourceRoot":"","sources":["../src/AuthRequest.types.ts"],"names":[],"mappings":"AAGA,cAAc;AACd,MAAM,CAAN,IAAY,mBAYX;AAZD,WAAY,mBAAmB;IAC7B;;;;;OAKG;IACH,oCAAa,CAAA;IACb;;OAEG;IACH,sCAAe,CAAA;AACjB,CAAC,EAZW,mBAAmB,KAAnB,mBAAmB,QAY9B;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAN,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB;;OAEG;IACH,6BAAa,CAAA;IACb;;OAEG;IACH,+BAAe,CAAA;IACf;;OAEG;IACH,oCAAoB,CAAA;AACtB,CAAC,EAbW,YAAY,KAAZ,YAAY,QAavB;AAED,cAAc;AACd;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,MAsBX;AAtBD,WAAY,MAAM;IAChB;;;;OAIG;IACH,uBAAa,CAAA;IACb;;;OAGG;IACH,yBAAe,CAAA;IACf;;;OAGG;IACH,6BAAmB,CAAA;IACnB;;;OAGG;IACH,0CAAgC,CAAA;AAClC,CAAC,EAtBW,MAAM,KAAN,MAAM,QAsBjB","sourcesContent":["import { CreateURLOptions } from 'expo-linking';\nimport { WebBrowserOpenOptions, WebBrowserWindowFeatures } from 'expo-web-browser';\n\n// @needsAudit\nexport enum CodeChallengeMethod {\n /**\n * The default and recommended method for transforming the code verifier.\n * - Convert the code verifier to ASCII.\n * - Create a digest of the string using crypto method SHA256.\n * - Convert the digest to Base64 and URL encode it.\n */\n S256 = 'S256',\n /**\n * This should not be used. When used, the code verifier will be sent to the server as-is.\n */\n Plain = 'plain',\n}\n\n// @needsAudit\n/**\n * The client informs the authorization server of the desired grant type by using the response type.\n *\n * @see [Section 3.1.1](https://tools.ietf.org/html/rfc6749#section-3.1.1).\n */\nexport enum ResponseType {\n /**\n * For requesting an authorization code as described by [Section 4.1.1](https://tools.ietf.org/html/rfc6749#section-4.1.1).\n */\n Code = 'code',\n /**\n * For requesting an access token (implicit grant) as described by [Section 4.2.1](https://tools.ietf.org/html/rfc6749#section-4.2.1).\n */\n Token = 'token',\n /**\n * A custom registered type for getting an `id_token` from Google OAuth.\n */\n IdToken = 'id_token',\n}\n\n// @needsAudit\n/**\n * Informs the server if the user should be prompted to login or consent again.\n * This can be used to present a dialog for switching accounts after the user has already been logged in.\n * You should use this in favor of clearing cookies (which is mostly not possible on iOS).\n *\n * @see [Section 3.1.2.1](https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationRequest).\n */\nexport enum Prompt {\n /**\n * Server must not display any auth or consent UI. Can be used to check for existing auth or consent.\n * An error is returned if a user isn't already authenticated or the client doesn't have pre-configured consent for the requested claims, or does not fulfill other conditions for processing the request.\n * The error code will typically be `login_required`, `interaction_required`, or another code defined in [Section 3.1.2.6](https://openid.net/specs/openid-connect-core-1_0.html#AuthError).\n */\n None = 'none',\n /**\n * The server should prompt the user to reauthenticate.\n * If it cannot reauthenticate the End-User, it must return an error, typically `login_required`.\n */\n Login = 'login',\n /**\n * Server should prompt the user for consent before returning information to the client.\n * If it cannot obtain consent, it must return an error, typically `consent_required`.\n */\n Consent = 'consent',\n /**\n * Server should prompt the user to select an account. Can be used to switch accounts.\n * If it can't obtain an account selection choice made by the user, it must return an error, typically `account_selection_required`.\n */\n SelectAccount = 'select_account',\n}\n\n// @needsAudit\n/**\n * Options passed to the `promptAsync()` method of `AuthRequest`s.\n * This can be used to configure how the web browser should look and behave.\n */\nexport type AuthRequestPromptOptions = Omit<WebBrowserOpenOptions, 'windowFeatures'> & {\n /**\n * URL to open when prompting the user. This usually should be defined internally and left `undefined` in most cases.\n */\n url?: string;\n /**\n * Should the authentication request use the Expo proxy service `auth.expo.io`.\n * @default false\n */\n useProxy?: boolean;\n /**\n * Project name to use for the \\`auth.expo.io\\` proxy when `useProxy` is true.\n */\n projectNameForProxy?: string;\n /**\n * URL options to be used when creating the redirect URL for the auth proxy.\n */\n proxyOptions?: Omit<CreateURLOptions, 'queryParams'> & { path?: string };\n /**\n * Features to use with `window.open()`.\n * @platform web\n */\n windowFeatures?: WebBrowserWindowFeatures;\n};\n\n// @needsAudit\n/**\n * Represents an OAuth authorization request as JSON.\n */\nexport interface AuthRequestConfig {\n /**\n * Specifies what is returned from the authorization server.\n *\n * [Section 3.1.1](https://tools.ietf.org/html/rfc6749#section-3.1.1)\n *\n * @default ResponseType.Code\n */\n responseType?: ResponseType | string;\n /**\n * A unique string representing the registration information provided by the client.\n * The client identifier is not a secret; it is exposed to the resource owner and shouldn't be used\n * alone for client authentication.\n *\n * The client identifier is unique to the authorization server.\n *\n * [Section 2.2](https://tools.ietf.org/html/rfc6749#section-2.2)\n */\n clientId: string;\n /**\n * After completing an interaction with a resource owner the\n * server will redirect to this URI. Learn more about [linking in Expo](https://docs.expo.dev/versions/latest/workflow/linking/).\n *\n * [Section 3.1.2](https://tools.ietf.org/html/rfc6749#section-3.1.2)\n */\n redirectUri: string;\n /**\n * List of strings to request access to.\n *\n * [Section 3.3](https://tools.ietf.org/html/rfc6749#section-3.3)\n */\n scopes?: string[];\n /**\n * Client secret supplied by an auth provider.\n * There is no secure way to store this on the client.\n *\n * [Section 2.3.1](https://tools.ietf.org/html/rfc6749#section-2.3.1)\n */\n clientSecret?: string;\n /**\n * Method used to generate the code challenge. You should never use `Plain` as it's not good enough for secure verification.\n * @default CodeChallengeMethod.S256\n */\n codeChallengeMethod?: CodeChallengeMethod;\n /**\n * Derived from the code verifier by using the `CodeChallengeMethod`.\n *\n * [Section 4.2](https://tools.ietf.org/html/rfc7636#section-4.2)\n */\n codeChallenge?: string;\n /**\n * Informs the server if the user should be prompted to login or consent again.\n * This can be used to present a dialog for switching accounts after the user has already been logged in.\n *\n * [Section 3.1.2.1](https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationRequest)\n */\n prompt?: Prompt;\n /**\n * Used for protection against [Cross-Site Request Forgery](https://tools.ietf.org/html/rfc6749#section-10.12).\n */\n state?: string;\n /**\n * Extra query params that'll be added to the query string.\n */\n extraParams?: Record<string, string>;\n /**\n * Should use [Proof Key for Code Exchange](https://oauth.net/2/pkce/).\n * @default true\n */\n usePKCE?: boolean;\n}\n"]}
@@ -5,7 +5,7 @@ import { AuthSessionOptions, AuthSessionRedirectUriOptions, AuthSessionResult }
5
5
  import { DiscoveryDocument, fetchDiscoveryAsync, Issuer, IssuerOrDiscovery, ProviderMetadata, resolveDiscoveryAsync } from './Discovery';
6
6
  import { generateHexStringAsync } from './PKCE';
7
7
  /**
8
- * Initiate an authentication session with the given options. Only one `AuthSession` can be active at any given time in your application.
8
+ * Initiate a proxied authentication session with the given options. Only one `AuthSession` can be active at any given time in your application.
9
9
  * If you attempt to open a second session while one is still in progress, the second session will return a value to indicate that `AuthSession` is locked.
10
10
  *
11
11
  * @param options An object of type `AuthSessionOptions`.
@@ -77,7 +77,7 @@ export declare function getRedirectUrl(path?: string): string;
77
77
  * // Web prod: https://yourwebsite.com
78
78
  * ```
79
79
  */
80
- export declare function makeRedirectUri({ native, scheme, isTripleSlashed, queryParams, path, preferLocalhost, useProxy, }?: AuthSessionRedirectUriOptions): string;
80
+ export declare function makeRedirectUri({ native, scheme, isTripleSlashed, queryParams, path, preferLocalhost, useProxy, projectNameForProxy, }?: AuthSessionRedirectUriOptions): string;
81
81
  /**
82
82
  * Build an `AuthRequest` and load it before returning.
83
83
  *
@@ -1 +1 @@
1
- {"version":3,"file":"AuthSession.d.ts","sourceRoot":"","sources":["../src/AuthSession.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAIxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,MAAM,EACN,YAAY,EACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,6BAA6B,EAC7B,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,MAAM,EACN,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAOhD;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAwDxF;AAGD;;;GAGG;AACH,wBAAgB,OAAO,SAEtB;AAED,eAAO,MAAM,mBAAmB,+GAAyC,CAAC;AAG1E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEpD;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,MAAM,EACN,eAAe,EACf,WAAW,EACX,IAAI,EACJ,eAAe,EACf,QA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jB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,cAAc,sBAAsB,CAAC;AAGrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import Constants, { ExecutionEnvironment } from 'expo-constants';
2
2
  import * as Linking from 'expo-linking';
3
3
  import { Platform } from 'expo-modules-core';
4
- import { dismissAuthSession, openAuthSessionAsync } from 'expo-web-browser';
4
+ import { dismissAuthSession, openAuthSessionAsync, } from 'expo-web-browser';
5
5
  import { AuthRequest } from './AuthRequest';
6
6
  import { CodeChallengeMethod, Prompt, ResponseType, } from './AuthRequest.types';
7
7
  import { fetchDiscoveryAsync, resolveDiscoveryAsync, } from './Discovery';
@@ -11,7 +11,7 @@ import sessionUrlProvider from './SessionUrlProvider';
11
11
  let _authLock = false;
12
12
  // @needsAudit
13
13
  /**
14
- * Initiate an authentication session with the given options. Only one `AuthSession` can be active at any given time in your application.
14
+ * Initiate a proxied authentication session with the given options. Only one `AuthSession` can be active at any given time in your application.
15
15
  * If you attempt to open a second session while one is still in progress, the second session will return a value to indicate that `AuthSession` is locked.
16
16
  *
17
17
  * @param options An object of type `AuthSessionOptions`.
@@ -32,7 +32,7 @@ export async function startAsync(options) {
32
32
  return { type: 'locked' };
33
33
  }
34
34
  const returnUrl = options.returnUrl || sessionUrlProvider.getDefaultReturnUrl();
35
- const startUrl = sessionUrlProvider.getStartUrl(authUrl, returnUrl);
35
+ const startUrl = sessionUrlProvider.getStartUrl(authUrl, returnUrl, options.projectNameForProxy);
36
36
  const showInRecents = options.showInRecents || false;
37
37
  // About to start session, set lock
38
38
  _authLock = true;
@@ -48,8 +48,8 @@ export async function startAsync(options) {
48
48
  if (!result) {
49
49
  throw new Error('Unexpected missing AuthSession result');
50
50
  }
51
- if (!result.url) {
52
- if (result.type) {
51
+ if (!('url' in result)) {
52
+ if ('type' in result) {
53
53
  return result;
54
54
  }
55
55
  else {
@@ -93,7 +93,7 @@ export const getDefaultReturnUrl = sessionUrlProvider.getDefaultReturnUrl;
93
93
  * @deprecated Use `makeRedirectUri({ path, useProxy })` instead.
94
94
  */
95
95
  export function getRedirectUrl(path) {
96
- return sessionUrlProvider.getRedirectUrl(path);
96
+ return sessionUrlProvider.getRedirectUrl({ urlPath: path });
97
97
  }
98
98
  // @needsAudit
99
99
  /**
@@ -137,7 +137,7 @@ export function getRedirectUrl(path) {
137
137
  * // Web prod: https://yourwebsite.com
138
138
  * ```
139
139
  */
140
- export function makeRedirectUri({ native, scheme, isTripleSlashed, queryParams, path, preferLocalhost, useProxy, } = {}) {
140
+ export function makeRedirectUri({ native, scheme, isTripleSlashed, queryParams, path, preferLocalhost, useProxy, projectNameForProxy, } = {}) {
141
141
  if (Platform.OS !== 'web' &&
142
142
  native &&
143
143
  [ExecutionEnvironment.Standalone, ExecutionEnvironment.Bare].includes(Constants.executionEnvironment)) {
@@ -161,7 +161,7 @@ export function makeRedirectUri({ native, scheme, isTripleSlashed, queryParams,
161
161
  return url;
162
162
  }
163
163
  // Attempt to use the proxy
164
- return sessionUrlProvider.getRedirectUrl(path);
164
+ return sessionUrlProvider.getRedirectUrl({ urlPath: path, projectNameForProxy });
165
165
  }
166
166
  // @needsAudit
167
167
  /**
@@ -179,7 +179,6 @@ export async function loadAsync(config, issuerOrDiscovery) {
179
179
  return request;
180
180
  }
181
181
  async function _openWebBrowserAsync(startUrl, returnUrl, showInRecents) {
182
- // $FlowIssue: Flow thinks the awaited result can be a promise
183
182
  const result = await openAuthSessionAsync(startUrl, returnUrl, { showInRecents });
184
183
  if (result.type === 'cancel' || result.type === 'dismiss') {
185
184
  return { type: result.type };
@@ -1 +1 @@
1
- {"version":3,"file":"AuthSession.js","sourceRoot":"","sources":["../src/AuthSession.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,K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,EAAE,SAAS,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAClF,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE;QACzD,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;KAC9B;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,EAIL,WAAW,EAGX,mBAAmB,EAInB,MAAM,EAEN,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,GACvB,CAAC;AAEF,OAAO;AACL,gBAAgB;AAChB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB;AAClB,gBAAgB;AAChB,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,cAAc;AACd,cAAc,sBAAsB,CAAC","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'expo-modules-core';\nimport { dismissAuthSession, openAuthSessionAsync } from 'expo-web-browser';\n\nimport { AuthRequest } from './AuthRequest';\nimport {\n AuthRequestConfig,\n AuthRequestPromptOptions,\n CodeChallengeMethod,\n Prompt,\n ResponseType,\n} from './AuthRequest.types';\nimport {\n AuthSessionOptions,\n AuthSessionRedirectUriOptions,\n AuthSessionResult,\n} from './AuthSession.types';\nimport {\n DiscoveryDocument,\n fetchDiscoveryAsync,\n Issuer,\n IssuerOrDiscovery,\n ProviderMetadata,\n resolveDiscoveryAsync,\n} from './Discovery';\nimport { generateHexStringAsync } from './PKCE';\nimport { getQueryParams } from './QueryParams';\nimport sessionUrlProvider from './SessionUrlProvider';\n\nlet _authLock = false;\n\n// @needsAudit\n/**\n * Initiate an authentication session with the given options. Only one `AuthSession` can be active at any given time in your application.\n * If you attempt to open a second session while one is still in progress, the second session will return a value to indicate that `AuthSession` is locked.\n *\n * @param options An object of type `AuthSessionOptions`.\n * @return Returns a Promise that resolves to an `AuthSessionResult` object.\n */\nexport async function startAsync(options: AuthSessionOptions): Promise<AuthSessionResult> {\n const authUrl = options.authUrl;\n // Prevent accidentally starting to an empty url\n if (!authUrl) {\n throw new Error(\n 'No authUrl provided to AuthSession.startAsync. An authUrl is required -- it points to the page where the user will be able to sign in.'\n );\n }\n // Prevent multiple sessions from running at the same time, WebBrowser doesn't\n // support it this makes the behavior predictable.\n if (_authLock) {\n if (__DEV__) {\n console.warn(\n 'Attempted to call AuthSession.startAsync multiple times while already active. Only one AuthSession can be active at any given time.'\n );\n }\n\n return { type: 'locked' };\n }\n\n const returnUrl = options.returnUrl || sessionUrlProvider.getDefaultReturnUrl();\n const startUrl = sessionUrlProvider.getStartUrl(authUrl, returnUrl);\n const showInRecents = options.showInRecents || false;\n\n // About to start session, set lock\n _authLock = true;\n\n let result;\n try {\n result = await _openWebBrowserAsync(startUrl, returnUrl, showInRecents);\n } finally {\n // WebBrowser session complete, unset lock\n _authLock = false;\n }\n\n // Handle failures\n if (!result) {\n throw new Error('Unexpected missing AuthSession result');\n }\n if (!result.url) {\n if (result.type) {\n return result;\n } else {\n throw new Error('Unexpected AuthSession result with missing type');\n }\n }\n\n const { params, errorCode } = getQueryParams(result.url);\n\n return {\n type: errorCode ? 'error' : 'success',\n params,\n errorCode,\n authentication: null,\n url: result.url,\n };\n}\n\n// @needsAudit\n/**\n * Cancels an active `AuthSession` if there is one. No return value, but if there is an active `AuthSession`\n * then the Promise returned by the `AuthSession.startAsync()` that initiated it resolves to `{ type: 'dismiss' }`.\n */\nexport function dismiss() {\n dismissAuthSession();\n}\n\nexport const getDefaultReturnUrl = sessionUrlProvider.getDefaultReturnUrl;\n\n// @needsAudit @docsMissing\n/**\n * Get the URL that your authentication provider needs to redirect to. For example: `https://auth.expo.io/@your-username/your-app-slug`. You can pass an additional path component to be appended to the default redirect URL.\n * > **Note** This method will throw an exception if you're using the bare workflow on native.\n *\n * @param path\n * @return\n *\n * @example\n * ```ts\n * const url = AuthSession.getRedirectUrl('redirect');\n *\n * // Managed: https://auth.expo.io/@your-username/your-app-slug/redirect\n * // Web: https://localhost:19006/redirect\n * ```\n *\n * @deprecated Use `makeRedirectUri({ path, useProxy })` instead.\n */\nexport function getRedirectUrl(path?: string): string {\n return sessionUrlProvider.getRedirectUrl(path);\n}\n\n// @needsAudit\n/**\n * Create a redirect url for the current platform and environment. You need to manually define the redirect that will be used in\n * a bare workflow React Native app, or an Expo standalone app, this is because it cannot be inferred automatically.\n * - **Web:** Generates a path based on the current `window.location`. For production web apps, you should hard code the URL as well.\n * - **Managed workflow:** Uses the `scheme` property of your `app.config.js` or `app.json`.\n * - **Proxy:** Uses `auth.expo.io` as the base URL for the path. This only works in Expo Go and standalone environments.\n * - **Bare workflow:** Will fallback to using the `native` option for bare workflow React Native apps.\n *\n * @param options Additional options for configuring the path.\n * @return The `redirectUri` to use in an authentication request.\n *\n * @example\n * ```ts\n * const redirectUri = makeRedirectUri({\n * scheme: 'my-scheme',\n * path: 'redirect'\n * });\n * // Custom app: my-scheme://redirect\n * // Expo Go: exp://127.0.0.1:19000/--/redirect\n * // Web dev: https://localhost:19006/redirect\n * // Web prod: https://yourwebsite.com/redirect\n *\n * const redirectUri2 = makeRedirectUri({\n * scheme: 'scheme2',\n * preferLocalhost: true,\n * isTripleSlashed: true,\n * });\n * // Custom app: scheme2:///\n * // Expo Go: exp://localhost:19000\n * // Web dev: https://localhost:19006\n * // Web prod: https://yourwebsite.com\n *\n * const redirectUri3 = makeRedirectUri({\n * useProxy: true,\n * });\n * // Custom app: https://auth.expo.io/@username/slug\n * // Expo Go: https://auth.expo.io/@username/slug\n * // Web dev: https://localhost:19006\n * // Web prod: https://yourwebsite.com\n * ```\n */\nexport function makeRedirectUri({\n native,\n scheme,\n isTripleSlashed,\n queryParams,\n path,\n preferLocalhost,\n useProxy,\n}: AuthSessionRedirectUriOptions = {}): string {\n if (\n Platform.OS !== 'web' &&\n native &&\n [ExecutionEnvironment.Standalone, ExecutionEnvironment.Bare].includes(\n Constants.executionEnvironment\n )\n ) {\n // Should use the user-defined native scheme in standalone builds\n return native;\n }\n if (!useProxy || Platform.OS === 'web') {\n const url = Linking.createURL(path || '', {\n isTripleSlashed,\n scheme,\n queryParams,\n });\n\n if (preferLocalhost) {\n const ipAddress = url.match(\n /\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b/\n );\n // Only replace if an IP address exists\n if (ipAddress?.length) {\n const [protocol, path] = url.split(ipAddress[0]);\n return `${protocol}localhost${path}`;\n }\n }\n\n return url;\n }\n // Attempt to use the proxy\n return sessionUrlProvider.getRedirectUrl(path);\n}\n\n// @needsAudit\n/**\n * Build an `AuthRequest` and load it before returning.\n *\n * @param config A valid [`AuthRequestConfig`](#authrequestconfig) that specifies what provider to use.\n * @param issuerOrDiscovery A loaded [`DiscoveryDocument`](#discoverydocument) or issuer URL.\n * (Only `authorizationEndpoint` is required for requesting an authorization code).\n * @return Returns an instance of `AuthRequest` that can be used to prompt the user for authorization.\n */\nexport async function loadAsync(\n config: AuthRequestConfig,\n issuerOrDiscovery: IssuerOrDiscovery\n): Promise<AuthRequest> {\n const request = new AuthRequest(config);\n const discovery = await resolveDiscoveryAsync(issuerOrDiscovery);\n await request.makeAuthUrlAsync(discovery);\n return request;\n}\n\nasync function _openWebBrowserAsync(startUrl: string, returnUrl: string, showInRecents: boolean) {\n // $FlowIssue: Flow thinks the awaited result can be a promise\n const result = await openAuthSessionAsync(startUrl, returnUrl, { showInRecents });\n if (result.type === 'cancel' || result.type === 'dismiss') {\n return { type: result.type };\n }\n\n return result;\n}\n\nexport { useAutoDiscovery, useAuthRequest } from './AuthRequestHooks';\nexport { AuthError, TokenError } from './Errors';\n\nexport {\n AuthSessionOptions,\n AuthSessionRedirectUriOptions,\n AuthSessionResult,\n AuthRequest,\n AuthRequestConfig,\n AuthRequestPromptOptions,\n CodeChallengeMethod,\n DiscoveryDocument,\n Issuer,\n IssuerOrDiscovery,\n Prompt,\n ProviderMetadata,\n ResponseType,\n resolveDiscoveryAsync,\n fetchDiscoveryAsync,\n generateHexStringAsync,\n};\n\nexport {\n // Token classes\n TokenResponse,\n AccessTokenRequest,\n RefreshTokenRequest,\n RevokeTokenRequest,\n // Token methods\n revokeAsync,\n refreshAsync,\n exchangeCodeAsync,\n fetchUserInfoAsync,\n} from './TokenRequest';\n\n// Token types\nexport * from './TokenRequest.types';\n\n// Provider specific types\nexport { GoogleAuthRequestConfig } from './providers/Google';\nexport { FacebookAuthRequestConfig } from './providers/Facebook';\n"]}
1
+ {"version":3,"file":"AuthSession.js","sourceRoot":"","sources":["../src/AuthSession.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAClB,oBAAoB,GAErB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAGL,mBAAmB,EACnB,MAAM,EACN,YAAY,GACb,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAEL,mBAAmB,EAInB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AA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AAW,EAGX,mBAAmB,EAInB,MAAM,EAEN,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,GACvB,CAAC;AAEF,OAAO;AACL,gBAAgB;AAChB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB;AAClB,gBAAgB;AAChB,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,cAAc;AACd,cAAc,sBAAsB,CAAC","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'expo-modules-core';\nimport {\n dismissAuthSession,\n openAuthSessionAsync,\n WebBrowserAuthSessionResult,\n} from 'expo-web-browser';\n\nimport { AuthRequest } from './AuthRequest';\nimport {\n AuthRequestConfig,\n AuthRequestPromptOptions,\n CodeChallengeMethod,\n Prompt,\n ResponseType,\n} from './AuthRequest.types';\nimport {\n AuthSessionOptions,\n AuthSessionRedirectUriOptions,\n AuthSessionResult,\n} from './AuthSession.types';\nimport {\n DiscoveryDocument,\n fetchDiscoveryAsync,\n Issuer,\n IssuerOrDiscovery,\n ProviderMetadata,\n resolveDiscoveryAsync,\n} from './Discovery';\nimport { generateHexStringAsync } from './PKCE';\nimport { getQueryParams } from './QueryParams';\nimport sessionUrlProvider from './SessionUrlProvider';\n\nlet _authLock = false;\n\n// @needsAudit\n/**\n * Initiate a proxied authentication session with the given options. Only one `AuthSession` can be active at any given time in your application.\n * If you attempt to open a second session while one is still in progress, the second session will return a value to indicate that `AuthSession` is locked.\n *\n * @param options An object of type `AuthSessionOptions`.\n * @return Returns a Promise that resolves to an `AuthSessionResult` object.\n */\nexport async function startAsync(options: AuthSessionOptions): Promise<AuthSessionResult> {\n const authUrl = options.authUrl;\n // Prevent accidentally starting to an empty url\n if (!authUrl) {\n throw new Error(\n 'No authUrl provided to AuthSession.startAsync. An authUrl is required -- it points to the page where the user will be able to sign in.'\n );\n }\n // Prevent multiple sessions from running at the same time, WebBrowser doesn't\n // support it this makes the behavior predictable.\n if (_authLock) {\n if (__DEV__) {\n console.warn(\n 'Attempted to call AuthSession.startAsync multiple times while already active. Only one AuthSession can be active at any given time.'\n );\n }\n\n return { type: 'locked' };\n }\n\n const returnUrl = options.returnUrl || sessionUrlProvider.getDefaultReturnUrl();\n const startUrl = sessionUrlProvider.getStartUrl(authUrl, returnUrl, options.projectNameForProxy);\n const showInRecents = options.showInRecents || false;\n\n // About to start session, set lock\n _authLock = true;\n\n let result: WebBrowserAuthSessionResult;\n try {\n result = await _openWebBrowserAsync(startUrl, returnUrl, showInRecents);\n } finally {\n // WebBrowser session complete, unset lock\n _authLock = false;\n }\n\n // Handle failures\n if (!result) {\n throw new Error('Unexpected missing AuthSession result');\n }\n if (!('url' in result)) {\n if ('type' in result) {\n return result;\n } else {\n throw new Error('Unexpected AuthSession result with missing type');\n }\n }\n\n const { params, errorCode } = getQueryParams(result.url);\n\n return {\n type: errorCode ? 'error' : 'success',\n params,\n errorCode,\n authentication: null,\n url: result.url,\n };\n}\n\n// @needsAudit\n/**\n * Cancels an active `AuthSession` if there is one. No return value, but if there is an active `AuthSession`\n * then the Promise returned by the `AuthSession.startAsync()` that initiated it resolves to `{ type: 'dismiss' }`.\n */\nexport function dismiss() {\n dismissAuthSession();\n}\n\nexport const getDefaultReturnUrl = sessionUrlProvider.getDefaultReturnUrl;\n\n// @needsAudit @docsMissing\n/**\n * Get the URL that your authentication provider needs to redirect to. For example: `https://auth.expo.io/@your-username/your-app-slug`. You can pass an additional path component to be appended to the default redirect URL.\n * > **Note** This method will throw an exception if you're using the bare workflow on native.\n *\n * @param path\n * @return\n *\n * @example\n * ```ts\n * const url = AuthSession.getRedirectUrl('redirect');\n *\n * // Managed: https://auth.expo.io/@your-username/your-app-slug/redirect\n * // Web: https://localhost:19006/redirect\n * ```\n *\n * @deprecated Use `makeRedirectUri({ path, useProxy })` instead.\n */\nexport function getRedirectUrl(path?: string): string {\n return sessionUrlProvider.getRedirectUrl({ urlPath: path });\n}\n\n// @needsAudit\n/**\n * Create a redirect url for the current platform and environment. You need to manually define the redirect that will be used in\n * a bare workflow React Native app, or an Expo standalone app, this is because it cannot be inferred automatically.\n * - **Web:** Generates a path based on the current `window.location`. For production web apps, you should hard code the URL as well.\n * - **Managed workflow:** Uses the `scheme` property of your `app.config.js` or `app.json`.\n * - **Proxy:** Uses `auth.expo.io` as the base URL for the path. This only works in Expo Go and standalone environments.\n * - **Bare workflow:** Will fallback to using the `native` option for bare workflow React Native apps.\n *\n * @param options Additional options for configuring the path.\n * @return The `redirectUri` to use in an authentication request.\n *\n * @example\n * ```ts\n * const redirectUri = makeRedirectUri({\n * scheme: 'my-scheme',\n * path: 'redirect'\n * });\n * // Custom app: my-scheme://redirect\n * // Expo Go: exp://127.0.0.1:19000/--/redirect\n * // Web dev: https://localhost:19006/redirect\n * // Web prod: https://yourwebsite.com/redirect\n *\n * const redirectUri2 = makeRedirectUri({\n * scheme: 'scheme2',\n * preferLocalhost: true,\n * isTripleSlashed: true,\n * });\n * // Custom app: scheme2:///\n * // Expo Go: exp://localhost:19000\n * // Web dev: https://localhost:19006\n * // Web prod: https://yourwebsite.com\n *\n * const redirectUri3 = makeRedirectUri({\n * useProxy: true,\n * });\n * // Custom app: https://auth.expo.io/@username/slug\n * // Expo Go: https://auth.expo.io/@username/slug\n * // Web dev: https://localhost:19006\n * // Web prod: https://yourwebsite.com\n * ```\n */\nexport function makeRedirectUri({\n native,\n scheme,\n isTripleSlashed,\n queryParams,\n path,\n preferLocalhost,\n useProxy,\n projectNameForProxy,\n}: AuthSessionRedirectUriOptions = {}): string {\n if (\n Platform.OS !== 'web' &&\n native &&\n [ExecutionEnvironment.Standalone, ExecutionEnvironment.Bare].includes(\n Constants.executionEnvironment\n )\n ) {\n // Should use the user-defined native scheme in standalone builds\n return native;\n }\n if (!useProxy || Platform.OS === 'web') {\n const url = Linking.createURL(path || '', {\n isTripleSlashed,\n scheme,\n queryParams,\n });\n\n if (preferLocalhost) {\n const ipAddress = url.match(\n /\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b/\n );\n // Only replace if an IP address exists\n if (ipAddress?.length) {\n const [protocol, path] = url.split(ipAddress[0]);\n return `${protocol}localhost${path}`;\n }\n }\n\n return url;\n }\n // Attempt to use the proxy\n return sessionUrlProvider.getRedirectUrl({ urlPath: path, projectNameForProxy });\n}\n\n// @needsAudit\n/**\n * Build an `AuthRequest` and load it before returning.\n *\n * @param config A valid [`AuthRequestConfig`](#authrequestconfig) that specifies what provider to use.\n * @param issuerOrDiscovery A loaded [`DiscoveryDocument`](#discoverydocument) or issuer URL.\n * (Only `authorizationEndpoint` is required for requesting an authorization code).\n * @return Returns an instance of `AuthRequest` that can be used to prompt the user for authorization.\n */\nexport async function loadAsync(\n config: AuthRequestConfig,\n issuerOrDiscovery: IssuerOrDiscovery\n): Promise<AuthRequest> {\n const request = new AuthRequest(config);\n const discovery = await resolveDiscoveryAsync(issuerOrDiscovery);\n await request.makeAuthUrlAsync(discovery);\n return request;\n}\n\nasync function _openWebBrowserAsync(startUrl: string, returnUrl: string, showInRecents: boolean) {\n const result = await openAuthSessionAsync(startUrl, returnUrl, { showInRecents });\n if (result.type === 'cancel' || result.type === 'dismiss') {\n return { type: result.type };\n }\n\n return result;\n}\n\nexport { useAutoDiscovery, useAuthRequest } from './AuthRequestHooks';\nexport { AuthError, TokenError } from './Errors';\n\nexport {\n AuthSessionOptions,\n AuthSessionRedirectUriOptions,\n AuthSessionResult,\n AuthRequest,\n AuthRequestConfig,\n AuthRequestPromptOptions,\n CodeChallengeMethod,\n DiscoveryDocument,\n Issuer,\n IssuerOrDiscovery,\n Prompt,\n ProviderMetadata,\n ResponseType,\n resolveDiscoveryAsync,\n fetchDiscoveryAsync,\n generateHexStringAsync,\n};\n\nexport {\n // Token classes\n TokenResponse,\n AccessTokenRequest,\n RefreshTokenRequest,\n RevokeTokenRequest,\n // Token methods\n revokeAsync,\n refreshAsync,\n exchangeCodeAsync,\n fetchUserInfoAsync,\n} from './TokenRequest';\n\n// Token types\nexport * from './TokenRequest.types';\n\n// Provider specific types\nexport { GoogleAuthRequestConfig } from './providers/Google';\nexport { FacebookAuthRequestConfig } from './providers/Facebook';\n"]}
@@ -6,9 +6,8 @@ export declare type AuthSessionOptions = {
6
6
  */
7
7
  authUrl: string;
8
8
  /**
9
- * The URL to return to the application. In managed apps, it's optional (defaults to `${Constants.linkingUrl}expo-auth-session`,
10
- * for example, `exp://expo.dev/@yourname/your-app-slug+expo-auth-session`).
11
- * However, in the bare app, it's required - `AuthSession` needs to know where to wait for the response.
9
+ * The URL to return to the application. In managed apps, it's optional and defaults to output of [`Linking.createURL('expo-auth-session', params)`](./linking/#linkingcreateurlpath-namedparameters)
10
+ * call with `scheme` and `queryParams` params. However, in the bare app, it's required - `AuthSession` needs to know where to wait for the response.
12
11
  * Hence, this method will throw an exception, if you don't provide `returnUrl`.
13
12
  */
14
13
  returnUrl?: string;
@@ -18,6 +17,10 @@ export declare type AuthSessionOptions = {
18
17
  * @platform android
19
18
  */
20
19
  showInRecents?: boolean;
20
+ /**
21
+ * Project name to use for the \`auth.expo.io\` proxy.
22
+ */
23
+ projectNameForProxy?: string;
21
24
  };
22
25
  /**
23
26
  * Object returned after an auth request has completed.
@@ -32,7 +35,7 @@ export declare type AuthSessionResult = {
32
35
  /**
33
36
  * How the auth completed.
34
37
  */
35
- type: 'cancel' | 'dismiss' | 'locked';
38
+ type: 'cancel' | 'dismiss' | 'opened' | 'locked';
36
39
  } | {
37
40
  /**
38
41
  * How the auth completed.
@@ -91,6 +94,10 @@ export declare type AuthSessionRedirectUriOptions = {
91
94
  * @default false
92
95
  */
93
96
  useProxy?: boolean;
97
+ /**
98
+ * Project name to use for the \`auth.expo.io\` proxy when `useProxy` is true.
99
+ */
100
+ projectNameForProxy?: string;
94
101
  /**
95
102
  * Attempt to convert the Expo server IP address to localhost.
96
103
  * This is useful for testing when your IP changes often, this will only work for iOS simulator.
@@ -1 +1 @@
1
- {"version":3,"file":"AuthSession.types.d.ts","sourceRoot":"","sources":["../src/AuthSession.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,oBAAY,kBAAkB,GAAG;IAC/B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAGF;;;;;;;;GAQG;AACH,oBAAY,iBAAiB,GACzB;IACE;;OAEG;IACH,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;CACvC,GACD;IACE;;OAEG;IACH,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B;;OAEG;IACH,cAAc,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAGN;;GAEG;AACH,oBAAY,6BAA6B,GAAG;IAC1C;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACjD;;;;OAIG;IACH,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AAM,CAAC;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACjD;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"AuthSession.types.js","sourceRoot":"","sources":["../src/AuthSession.types.ts"],"names":[],"mappings":"","sourcesContent":["import { AuthError } from './Errors';\nimport { TokenResponse } from './TokenRequest';\n\n// @needsAudit\nexport type AuthSessionOptions = {\n /**\n * The URL that points to the sign in page that you would like to open the user to.\n */\n authUrl: string;\n /**\n * The URL to return to the application. In managed apps, it's optional (defaults to `${Constants.linkingUrl}expo-auth-session`,\n * for example, `exp://expo.dev/@yourname/your-app-slug+expo-auth-session`).\n * However, in the bare app, it's required - `AuthSession` needs to know where to wait for the response.\n * Hence, this method will throw an exception, if you don't provide `returnUrl`.\n */\n returnUrl?: string;\n /**\n * A boolean determining whether browsed website should be shown as separate entry in Android recents/multitasking view.\n * @default false\n * @platform android\n */\n showInRecents?: boolean;\n};\n\n// @needsAudit\n/**\n * Object returned after an auth request has completed.\n * - If the user cancelled the authentication session by closing the browser, the result is `{ type: 'cancel' }`.\n * - If the authentication is dismissed manually with `AuthSession.dismiss()`, the result is `{ type: 'dismiss' }`.\n * - If the authentication flow is successful, the result is `{ type: 'success', params: Object, event: Object }`.\n * - If the authentication flow is returns an error, the result is `{ type: 'error', params: Object, error: string, event: Object }`.\n * - If you call `AuthSession.startAsync()` more than once before the first call has returned, the result is `{ type: 'locked' }`,\n * because only one `AuthSession` can be in progress at any time.\n */\nexport type AuthSessionResult =\n | {\n /**\n * How the auth completed.\n */\n type: 'cancel' | 'dismiss' | 'locked';\n }\n | {\n /**\n * How the auth completed.\n */\n type: 'error' | 'success';\n /**\n * @deprecated Legacy error code query param, use `error` instead.\n */\n errorCode: string | null;\n /**\n * Possible error if the auth failed with type `error`.\n */\n error?: AuthError | null;\n /**\n * Query params from the `url` as an object.\n */\n params: Record<string, string>;\n /**\n * Returned when the auth finishes with an `access_token` property.\n */\n authentication: TokenResponse | null;\n /**\n * Auth URL that was opened\n */\n url: string;\n };\n\n// @needsAudit\n/**\n * Options passed to `makeRedirectUriAsync`.\n */\nexport type AuthSessionRedirectUriOptions = {\n /**\n * Optional path to append to a URI. This will not be added to `native`.\n */\n path?: string;\n /**\n * URI protocol `<scheme>://` that must be built into your native app.\n * Passed to `Linking.createURL()` when `useProxy` is `false`.\n */\n scheme?: string;\n /**\n * Optional native scheme to use when proxy is disabled.\n * URI protocol `<scheme>://` that must be built into your native app.\n * Passed to `Linking.createURL()` when `useProxy` is `false`.\n */\n queryParams?: Record<string, string | undefined>;\n /**\n * Should the URI be triple slashed `scheme:///path` or double slashed `scheme://path`.\n * Defaults to `false`.\n * Passed to `Linking.createURL()` when `useProxy` is `false`.\n */\n isTripleSlashed?: boolean;\n /**\n * Should use the \\`auth.expo.io\\` proxy.\n * This is useful for testing managed native apps that require a custom URI scheme.\n *\n * @default false\n */\n useProxy?: boolean;\n /**\n * Attempt to convert the Expo server IP address to localhost.\n * This is useful for testing when your IP changes often, this will only work for iOS simulator.\n *\n * @default false\n */\n preferLocalhost?: boolean;\n /**\n * Manual scheme to use in Bare and Standalone native app contexts. Takes precedence over all other properties.\n * You must define the URI scheme that will be used in a custom built native application or standalone Expo application.\n * The value should conform to your native app's URI schemes.\n * You can see conformance with `npx uri-scheme list`.\n */\n native?: string;\n};\n"]}
1
+ {"version":3,"file":"AuthSession.types.js","sourceRoot":"","sources":["../src/AuthSession.types.ts"],"names":[],"mappings":"","sourcesContent":["import { AuthError } from './Errors';\nimport { TokenResponse } from './TokenRequest';\n\n// @needsAudit\nexport type AuthSessionOptions = {\n /**\n * The URL that points to the sign in page that you would like to open the user to.\n */\n authUrl: string;\n /**\n * The URL to return to the application. In managed apps, it's optional and defaults to output of [`Linking.createURL('expo-auth-session', params)`](./linking/#linkingcreateurlpath-namedparameters)\n * call with `scheme` and `queryParams` params. However, in the bare app, it's required - `AuthSession` needs to know where to wait for the response.\n * Hence, this method will throw an exception, if you don't provide `returnUrl`.\n */\n returnUrl?: string;\n /**\n * A boolean determining whether browsed website should be shown as separate entry in Android recents/multitasking view.\n * @default false\n * @platform android\n */\n showInRecents?: boolean;\n /**\n * Project name to use for the \\`auth.expo.io\\` proxy.\n */\n projectNameForProxy?: string;\n};\n\n// @needsAudit\n/**\n * Object returned after an auth request has completed.\n * - If the user cancelled the authentication session by closing the browser, the result is `{ type: 'cancel' }`.\n * - If the authentication is dismissed manually with `AuthSession.dismiss()`, the result is `{ type: 'dismiss' }`.\n * - If the authentication flow is successful, the result is `{ type: 'success', params: Object, event: Object }`.\n * - If the authentication flow is returns an error, the result is `{ type: 'error', params: Object, error: string, event: Object }`.\n * - If you call `AuthSession.startAsync()` more than once before the first call has returned, the result is `{ type: 'locked' }`,\n * because only one `AuthSession` can be in progress at any time.\n */\nexport type AuthSessionResult =\n | {\n /**\n * How the auth completed.\n */\n type: 'cancel' | 'dismiss' | 'opened' | 'locked';\n }\n | {\n /**\n * How the auth completed.\n */\n type: 'error' | 'success';\n /**\n * @deprecated Legacy error code query param, use `error` instead.\n */\n errorCode: string | null;\n /**\n * Possible error if the auth failed with type `error`.\n */\n error?: AuthError | null;\n /**\n * Query params from the `url` as an object.\n */\n params: Record<string, string>;\n /**\n * Returned when the auth finishes with an `access_token` property.\n */\n authentication: TokenResponse | null;\n /**\n * Auth URL that was opened\n */\n url: string;\n };\n\n// @needsAudit\n/**\n * Options passed to `makeRedirectUriAsync`.\n */\nexport type AuthSessionRedirectUriOptions = {\n /**\n * Optional path to append to a URI. This will not be added to `native`.\n */\n path?: string;\n /**\n * URI protocol `<scheme>://` that must be built into your native app.\n * Passed to `Linking.createURL()` when `useProxy` is `false`.\n */\n scheme?: string;\n /**\n * Optional native scheme to use when proxy is disabled.\n * URI protocol `<scheme>://` that must be built into your native app.\n * Passed to `Linking.createURL()` when `useProxy` is `false`.\n */\n queryParams?: Record<string, string | undefined>;\n /**\n * Should the URI be triple slashed `scheme:///path` or double slashed `scheme://path`.\n * Defaults to `false`.\n * Passed to `Linking.createURL()` when `useProxy` is `false`.\n */\n isTripleSlashed?: boolean;\n /**\n * Should use the \\`auth.expo.io\\` proxy.\n * This is useful for testing managed native apps that require a custom URI scheme.\n *\n * @default false\n */\n useProxy?: boolean;\n /**\n * Project name to use for the \\`auth.expo.io\\` proxy when `useProxy` is true.\n */\n projectNameForProxy?: string;\n /**\n * Attempt to convert the Expo server IP address to localhost.\n * This is useful for testing when your IP changes often, this will only work for iOS simulator.\n *\n * @default false\n */\n preferLocalhost?: boolean;\n /**\n * Manual scheme to use in Bare and Standalone native app contexts. Takes precedence over all other properties.\n * You must define the URI scheme that will be used in a custom built native application or standalone Expo application.\n * The value should conform to your native app's URI schemes.\n * You can see conformance with `npx uri-scheme list`.\n */\n native?: string;\n};\n"]}
@@ -3,8 +3,11 @@ export declare class SessionUrlProvider {
3
3
  private static readonly BASE_URL;
4
4
  private static readonly SESSION_PATH;
5
5
  getDefaultReturnUrl(urlPath?: string, options?: Omit<Linking.CreateURLOptions, 'queryParams'>): string;
6
- getStartUrl(authUrl: string, returnUrl: string): string;
7
- getRedirectUrl(urlPath?: string): string;
6
+ getStartUrl(authUrl: string, returnUrl: string, projectNameForProxy: string | undefined): string;
7
+ getRedirectUrl(options: {
8
+ projectNameForProxy?: string;
9
+ urlPath?: string;
10
+ }): string;
8
11
  private static getHostAddressQueryParams;
9
12
  private static warnIfAnonymous;
10
13
  private static removeScheme;
@@ -1 +1 @@
1
- {"version":3,"file":"SessionUrlProvider.d.ts","sourceRoot":"","sources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;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IA8CnF,OAAO,CAAC,MAAM,CAAC,yBAAyB;IA6BxC,OAAO,CAAC,MAAM,CAAC,eAAe;IAQ9B,OAAO,CAAC,MAAM,CAAC,YAAY;IAI3B,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAGlC;;AAED,wBAAwC"}
@@ -18,7 +18,7 @@ export class SessionUrlProvider {
18
18
  isTripleSlashed: options?.isTripleSlashed,
19
19
  });
20
20
  }
21
- getStartUrl(authUrl, returnUrl) {
21
+ getStartUrl(authUrl, returnUrl, projectNameForProxy) {
22
22
  if (Platform.OS === 'web' && !Platform.isDOMAvailable) {
23
23
  // Return nothing in SSR envs
24
24
  return '';
@@ -27,22 +27,22 @@ export class SessionUrlProvider {
27
27
  authUrl,
28
28
  returnUrl,
29
29
  });
30
- return `${this.getRedirectUrl()}/start?${queryString}`;
30
+ return `${this.getRedirectUrl({ projectNameForProxy })}/start?${queryString}`;
31
31
  }
32
- getRedirectUrl(urlPath) {
32
+ getRedirectUrl(options) {
33
33
  if (Platform.OS === 'web') {
34
34
  if (Platform.isDOMAvailable) {
35
- return [window.location.origin, urlPath].filter(Boolean).join('/');
35
+ return [window.location.origin, options.urlPath].filter(Boolean).join('/');
36
36
  }
37
37
  else {
38
38
  // Return nothing in SSR envs
39
39
  return '';
40
40
  }
41
41
  }
42
- const legacyExpoProjectId = Constants.manifest?.originalFullName ||
43
- Constants.manifest2?.extra?.expoClient?.originalFullName ||
42
+ const legacyExpoProjectFullName = options.projectNameForProxy ||
43
+ Constants.expoConfig?.originalFullName ||
44
44
  Constants.manifest?.id;
45
- if (!legacyExpoProjectId) {
45
+ if (!legacyExpoProjectFullName) {
46
46
  let nextSteps = '';
47
47
  if (__DEV__) {
48
48
  if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {
@@ -54,11 +54,16 @@ export class SessionUrlProvider {
54
54
  ' Please report this as a bug with the contents of `expo config --type public`.';
55
55
  }
56
56
  }
57
- throw new Error('Cannot use AuthSession proxy because the project ID is not defined.' + nextSteps);
57
+ if (Constants.manifest2) {
58
+ nextSteps =
59
+ ' Prefer AuthRequest (with the useProxy option set to false) in combination with an Expo Development Client build of your application.' +
60
+ ' To continue using the AuthSession proxy, specify the project full name (@owner/slug) using the projectNameForProxy option.';
61
+ }
62
+ throw new Error('Cannot use the AuthSession proxy because the project full name is not defined.' + nextSteps);
58
63
  }
59
- const redirectUrl = `${SessionUrlProvider.BASE_URL}/${legacyExpoProjectId}`;
64
+ const redirectUrl = `${SessionUrlProvider.BASE_URL}/${legacyExpoProjectFullName}`;
60
65
  if (__DEV__) {
61
- SessionUrlProvider.warnIfAnonymous(legacyExpoProjectId, redirectUrl);
66
+ SessionUrlProvider.warnIfAnonymous(legacyExpoProjectFullName, redirectUrl);
62
67
  // TODO: Verify with the dev server that the manifest is up to date.
63
68
  }
64
69
  return redirectUrl;
@@ -1 +1 @@
1
- {"version":3,"file":"SessionUrlProvider.js","sourceRoot":"","sources":["../src/SessionUrlProvider.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAgB,MAAM,IAAI,CAAC;AAElC,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAU,QAAQ,GAAG,sBAAsB,CAAC;IAClD,MAAM,CAAU,YAAY,GAAG,mBAAmB,CAAC;IAE3D,mBAAmB,CACjB,OAAgB,EAChB,OAAuD;QAEvD,MAAM,WAAW,GAAG,kBAAkB,CAAC,yBAAyB,EAAE,CAAC;QACnE,IAAI,IAAI,GAAG,kBAAkB,CAAC,YAAY,CAAC;QAC3C,IAAI,OAAO,EAAE;YACX,IAAI,GAAG,CAAC,IAAI,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAA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C,CAAC;SAChC;QAAC,MAAM,GAAE;QAEV,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,GAAG;QACpC,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;YAChC,OAAO,CAAC,IAAI,CACV,+HAA+H,GAAG,6TAA6T,CAChc,CAAC;SACH;IACH,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,GAAW;QACrC,OAAO,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAClD,CAAC;IAEO,MAAM,CAAC,kBAAkB,CAAC,GAAW;QAC3C,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC;;AAGH,eAAe,IAAI,kBAAkB,EAAE,CAAC","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'expo-modules-core';\nimport qs, { ParsedQs } from 'qs';\n\nexport class SessionUrlProvider {\n private static readonly BASE_URL = `https://auth.expo.io`;\n private static readonly SESSION_PATH = 'expo-auth-session';\n\n getDefaultReturnUrl(\n urlPath?: string,\n options?: Omit<Linking.CreateURLOptions, 'queryParams'>\n ): string {\n const queryParams = SessionUrlProvider.getHostAddressQueryParams();\n let path = SessionUrlProvider.SESSION_PATH;\n if (urlPath) {\n path = [path, SessionUrlProvider.removeLeadingSlash(urlPath)].filter(Boolean).join('/');\n }\n\n return Linking.createURL(path, {\n // The redirect URL doesn't matter for the proxy as long as it's valid, so silence warnings if needed.\n scheme: options?.scheme ?? Linking.resolveScheme({ isSilent: true }),\n queryParams,\n isTripleSlashed: options?.isTripleSlashed,\n });\n }\n\n getStartUrl(authUrl: string, returnUrl: string): string {\n if (Platform.OS === 'web' && !Platform.isDOMAvailable) {\n // Return nothing in SSR envs\n return '';\n }\n const queryString = qs.stringify({\n authUrl,\n returnUrl,\n });\n\n return `${this.getRedirectUrl()}/start?${queryString}`;\n }\n\n getRedirectUrl(urlPath?: string): string {\n if (Platform.OS === 'web') {\n if (Platform.isDOMAvailable) {\n return [window.location.origin, urlPath].filter(Boolean).join('/');\n } else {\n // Return nothing in SSR envs\n return '';\n }\n }\n\n const legacyExpoProjectId =\n Constants.manifest?.originalFullName ||\n Constants.manifest2?.extra?.expoClient?.originalFullName ||\n Constants.manifest?.id;\n\n if (!legacyExpoProjectId) {\n let nextSteps = '';\n if (__DEV__) {\n if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {\n nextSteps =\n ' Please ensure you have the latest version of expo-constants installed and rebuild your native app. You can verify that originalFullName is defined by running `expo config --type public` and inspecting the output.';\n } else if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n nextSteps =\n ' Please report this as a bug with the contents of `expo config --type public`.';\n }\n }\n throw new Error(\n 'Cannot use AuthSession proxy because the project ID is not defined.' + nextSteps\n );\n }\n\n const redirectUrl = `${SessionUrlProvider.BASE_URL}/${legacyExpoProjectId}`;\n if (__DEV__) {\n SessionUrlProvider.warnIfAnonymous(legacyExpoProjectId, redirectUrl);\n // TODO: Verify with the dev server that the manifest is up to date.\n }\n return redirectUrl;\n }\n\n private static getHostAddressQueryParams(): ParsedQs | undefined {\n let hostUri: string | undefined =\n Constants.manifest?.hostUri ?? Constants.manifest2?.extra?.expoClient?.hostUri;\n if (\n !hostUri &&\n (ExecutionEnvironment.StoreClient === Constants.executionEnvironment ||\n Linking.resolveScheme({}))\n ) {\n if (!Constants.linkingUri) {\n hostUri = '';\n } else {\n // we're probably not using up-to-date xdl, so just fake it for now\n // we have to remove the /--/ on the end since this will be inserted again later\n hostUri = SessionUrlProvider.removeScheme(Constants.linkingUri).replace(/\\/--(\\/.*)?$/, '');\n }\n }\n\n if (!hostUri) {\n return undefined;\n }\n\n const uriParts = hostUri?.split('?');\n try {\n return qs.parse(uriParts?.[1]);\n } catch {}\n\n return undefined;\n }\n\n private static warnIfAnonymous(id, url): void {\n if (id.startsWith('@anonymous/')) {\n console.warn(\n `You are not currently signed in to Expo on your development machine. As a result, the redirect URL for AuthSession will be \"${url}\". If you are using an OAuth provider that requires adding redirect URLs to an allow list, we recommend that you do not add this URL -- instead, you should sign in to Expo to acquire a unique redirect URL. Additionally, if you do decide to publish this app using Expo, you will need to register an account to do it.`\n );\n }\n }\n\n private static removeScheme(url: string) {\n return url.replace(/^[a-zA-Z0-9+.-]+:\\/\\//, '');\n }\n\n private static removeLeadingSlash(url: string) {\n return url.replace(/^\\//, '');\n }\n}\n\nexport default new SessionUrlProvider();\n"]}
1
+ {"version":3,"file":"SessionUrlProvider.js","sourceRoot":"","sources":["../src/SessionUrlProvider.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAgB,MAAM,IAAI,CAAC;AAElC,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAU,QAAQ,GAAG,sBAAsB,CAAC;IAClD,MAAM,CAAU,YAAY,GAAG,mBAAmB,CAAC;IAE3D,mBAAmB,CACjB,OAAgB,EAChB,OAAuD;QAEvD,MAAM,WAAW,GAAG,kBAAkB,CAAC,yBAAyB,EAAE,CAAC;QACnE,IAAI,IAAI,GAAG,kBAAkB,CAAC,YAAY,CAAC;QAC3C,IAAI,OAAO,EAAE;YACX,IAAI,GAAG,CAAC,IAAI,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACzF;QAED,OAAO,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE;YAC7B,sGAAsG;YACtG,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,OAAO,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,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pC,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;YAChC,OAAO,CAAC,IAAI,CACV,+HAA+H,GAAG,6TAA6T,CAChc,CAAC;SACH;IACH,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,GAAW;QACrC,OAAO,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAClD,CAAC;IAEO,MAAM,CAAC,kBAAkB,CAAC,GAAW;QAC3C,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC;;AAGH,eAAe,IAAI,kBAAkB,EAAE,CAAC","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'expo-modules-core';\nimport qs, { ParsedQs } from 'qs';\n\nexport class SessionUrlProvider {\n private static readonly BASE_URL = `https://auth.expo.io`;\n private static readonly SESSION_PATH = 'expo-auth-session';\n\n getDefaultReturnUrl(\n urlPath?: string,\n options?: Omit<Linking.CreateURLOptions, 'queryParams'>\n ): string {\n const queryParams = SessionUrlProvider.getHostAddressQueryParams();\n let path = SessionUrlProvider.SESSION_PATH;\n if (urlPath) {\n path = [path, SessionUrlProvider.removeLeadingSlash(urlPath)].filter(Boolean).join('/');\n }\n\n return Linking.createURL(path, {\n // The redirect URL doesn't matter for the proxy as long as it's valid, so silence warnings if needed.\n scheme: options?.scheme ?? Linking.resolveScheme({ isSilent: true }),\n queryParams,\n isTripleSlashed: options?.isTripleSlashed,\n });\n }\n\n getStartUrl(authUrl: string, returnUrl: string, projectNameForProxy: string | undefined): string {\n if (Platform.OS === 'web' && !Platform.isDOMAvailable) {\n // Return nothing in SSR envs\n return '';\n }\n const queryString = qs.stringify({\n authUrl,\n returnUrl,\n });\n\n return `${this.getRedirectUrl({ projectNameForProxy })}/start?${queryString}`;\n }\n\n getRedirectUrl(options: { projectNameForProxy?: string; urlPath?: string }): string {\n if (Platform.OS === 'web') {\n if (Platform.isDOMAvailable) {\n return [window.location.origin, options.urlPath].filter(Boolean).join('/');\n } else {\n // Return nothing in SSR envs\n return '';\n }\n }\n\n const legacyExpoProjectFullName =\n options.projectNameForProxy ||\n Constants.expoConfig?.originalFullName ||\n Constants.manifest?.id;\n\n if (!legacyExpoProjectFullName) {\n let nextSteps = '';\n if (__DEV__) {\n if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {\n nextSteps =\n ' Please ensure you have the latest version of expo-constants installed and rebuild your native app. You can verify that originalFullName is defined by running `expo config --type public` and inspecting the output.';\n } else if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n nextSteps =\n ' Please report this as a bug with the contents of `expo config --type public`.';\n }\n }\n\n if (Constants.manifest2) {\n nextSteps =\n ' Prefer AuthRequest (with the useProxy option set to false) in combination with an Expo Development Client build of your application.' +\n ' To continue using the AuthSession proxy, specify the project full name (@owner/slug) using the projectNameForProxy option.';\n }\n\n throw new Error(\n 'Cannot use the AuthSession proxy because the project full name is not defined.' + nextSteps\n );\n }\n\n const redirectUrl = `${SessionUrlProvider.BASE_URL}/${legacyExpoProjectFullName}`;\n if (__DEV__) {\n SessionUrlProvider.warnIfAnonymous(legacyExpoProjectFullName, redirectUrl);\n // TODO: Verify with the dev server that the manifest is up to date.\n }\n return redirectUrl;\n }\n\n private static getHostAddressQueryParams(): ParsedQs | undefined {\n let hostUri: string | undefined =\n Constants.manifest?.hostUri ?? Constants.manifest2?.extra?.expoClient?.hostUri;\n if (\n !hostUri &&\n (ExecutionEnvironment.StoreClient === Constants.executionEnvironment ||\n Linking.resolveScheme({}))\n ) {\n if (!Constants.linkingUri) {\n hostUri = '';\n } else {\n // we're probably not using up-to-date xdl, so just fake it for now\n // we have to remove the /--/ on the end since this will be inserted again later\n hostUri = SessionUrlProvider.removeScheme(Constants.linkingUri).replace(/\\/--(\\/.*)?$/, '');\n }\n }\n\n if (!hostUri) {\n return undefined;\n }\n\n const uriParts = hostUri?.split('?');\n try {\n return qs.parse(uriParts?.[1]);\n } catch {}\n\n return undefined;\n }\n\n private static warnIfAnonymous(id, url): void {\n if (id.startsWith('@anonymous/')) {\n console.warn(\n `You are not currently signed in to Expo on your development machine. As a result, the redirect URL for AuthSession will be \"${url}\". If you are using an OAuth provider that requires adding redirect URLs to an allow list, we recommend that you do not add this URL -- instead, you should sign in to Expo to acquire a unique redirect URL. Additionally, if you do decide to publish this app using Expo, you will need to register an account to do it.`\n );\n }\n }\n\n private static removeScheme(url: string) {\n return url.replace(/^[a-zA-Z0-9+.-]+:\\/\\//, '');\n }\n\n private static removeLeadingSlash(url: string) {\n return url.replace(/^\\//, '');\n }\n}\n\nexport default new SessionUrlProvider();\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Facebook.d.ts","sourceRoot":"","sources":["../../src/providers/Facebook.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,6BAA6B,EAC7B,iBAAiB,EACjB,iBAAiB,EAGlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAS7D,eAAO,MAAM,SAAS,EAAE,iBAGvB,CAAC;AAGF,MAAM,WAAW,yBAA0B,SAAQ,yBAAyB;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD;;GAEG;AACH,cAAM,mBAAoB,SAAQ,WAAW;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;gBAEH,EACV,QAAQ,EAER,WAAgB,EAChB,YAAY,EACZ,GAAG,MAAM,EACV,EAAE,yBAAyB;IA6B5B;;OAEG;IACG,yBAAyB,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAa9D;AAED;;;;;;;;;GASG;AACH,wB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,EAAE,wBAAwB,KAAK,OAAO,CAAC,iBAAiB,CAAC;CACnE,CA6DA"}
@@ -102,6 +102,7 @@ export function useAuthRequest(config = {}, redirectUriOptions = {}) {
102
102
  // The redirect URI should be created using fb + client ID on native.
103
103
  native: `fb${clientId}://authorize`,
104
104
  useProxy,
105
+ projectNameForProxy: '@community/native-component-list',
105
106
  ...redirectUriOptions,
106
107
  });
107
108
  }, [useProxy, clientId, config.redirectUri, redirectUriOptions]);
@@ -1 +1 @@
1
- {"version":3,"file":"Facebook.js","sourceRoot":"","sources":["../../src/providers/Facebook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,WAAW,EAKX,eAAe,EACf,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvE,MAAM,QAAQ,GAAG;IACf,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IAC3C,kFAAkF;IAClF,aAAa,EAAE,CAAC,gBAAgB,EAAE,OAAO,CAAC;CAC3C,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC1C,qBAAqB,EAAE,4CAA4C;IACnE,aAAa,EAAE,oDAAoD;CACpE,CAAC;AAUF,cAAc;AACd;;GAEG;AACH,MAAM,mBAAoB,SAAQ,WAAW;IAC3C,KAAK,CAAU;IAEf,YAAY,EACV,QAAQ;IACR,6DAA6D;IAC7D,WAAW,GAAG,EAAE,EAChB,YAAY,EACZ,GAAG,MAAM,EACiB;QAC1B,MAAM,WAAW,GAA2B;YAC1C,OAAO,EAAE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Q,CAAC,CAAC,CAAC;IAE1C,MAAM,OAAO,GAAG,oBAAoB,CAClC;QACE,GAAG,MAAM;QACT,WAAW;QACX,QAAQ;QACR,WAAW;KACZ,EACD,SAAS,EACT,mBAAmB,CACpB,CAAC;IAEF,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,oBAAoB,CAAC,OAAO,EAAE,SAAS,EAAE;QACrE,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,QAAQ;KACT,CAAC,CAAC;IAEH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { useMemo } from 'react';\nimport { Platform } from 'react-native';\n\nimport { AuthRequestConfig } from '../AuthRequest.types';\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport {\n AuthRequest,\n AuthRequestPromptOptions,\n AuthSessionRedirectUriOptions,\n AuthSessionResult,\n DiscoveryDocument,\n makeRedirectUri,\n ResponseType,\n} from '../AuthSession';\nimport { generateHexStringAsync } from '../PKCE';\nimport { ProviderAuthRequestConfig } from './Provider.types';\nimport { applyRequiredScopes, useProxyEnabled } from './ProviderUtils';\n\nconst settings = {\n windowFeatures: { width: 700, height: 600 },\n // These are required for Firebase to work properly which is a reasonable default.\n minimumScopes: ['public_profile', 'email'],\n};\n\nexport const discovery: DiscoveryDocument = {\n authorizationEndpoint: 'https://www.facebook.com/v6.0/dialog/oauth',\n tokenEndpoint: 'https://graph.facebook.com/v6.0/oauth/access_token',\n};\n\n// @needsAudit @docsMissing\nexport interface FacebookAuthRequestConfig extends ProviderAuthRequestConfig {\n webClientId?: string;\n iosClientId?: string;\n androidClientId?: string;\n expoClientId?: string;\n}\n\n// @needsAudit\n/**\n * Extends [`AuthRequest`](#authrequest) and accepts [`FacebookAuthRequest`](#facebookauthrequest) in the constructor.\n */\nclass FacebookAuthRequest extends AuthRequest {\n nonce?: string;\n\n constructor({\n language,\n // Account selection cannot be reliably emulated on Facebook.\n extraParams = {},\n clientSecret,\n ...config\n }: FacebookAuthRequestConfig) {\n const inputParams: Record<string, string> = {\n display: 'popup',\n ...extraParams,\n };\n if (language) {\n inputParams.locale = language;\n }\n\n // Apply the default scopes\n const scopes = applyRequiredScopes(config.scopes, settings.minimumScopes);\n let inputClientSecret: string | undefined;\n // Facebook will throw if you attempt to use the client secret\n if (config.responseType && config.responseType !== ResponseType.Code) {\n // TODO: maybe warn that you shouldn't store the client secret on the client\n inputClientSecret = clientSecret;\n }\n // Default to implicit auth\n if (!config.responseType) {\n config.responseType = ResponseType.Token;\n }\n super({\n ...config,\n clientSecret: inputClientSecret,\n scopes,\n extraParams: inputParams,\n });\n }\n\n /**\n * Load and return a valid auth request based on the input config.\n */\n async getAuthRequestConfigAsync(): Promise<AuthRequestConfig> {\n const { extraParams = {}, ...config } = await super.getAuthRequestConfigAsync();\n if (!extraParams.nonce && !this.nonce) {\n if (!this.nonce) {\n this.nonce = await generateHexStringAsync(16);\n }\n extraParams.auth_nonce = this.nonce;\n }\n return {\n ...config,\n extraParams,\n };\n }\n}\n\n/**\n * Load an authorization request.\n * Returns a loaded request, a response, and a prompt method.\n * When the prompt method completes then the response will be fulfilled.\n *\n * - [Get Started](https://docs.expo.dev/guides/authentication/#facebook)\n *\n * @param config\n * @param redirectUriOptions\n */\nexport function useAuthRequest(\n config: Partial<FacebookAuthRequestConfig> = {},\n redirectUriOptions: Partial<AuthSessionRedirectUriOptions> = {}\n): [\n FacebookAuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>\n] {\n const useProxy = useProxyEnabled(redirectUriOptions);\n\n const clientId = useMemo((): string => {\n const propertyName = useProxy\n ? 'expoClientId'\n : Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n });\n return config[propertyName as any] ?? config.clientId;\n }, [\n useProxy,\n config.expoClientId,\n config.iosClientId,\n config.androidClientId,\n config.webClientId,\n config.clientId,\n ]);\n\n const redirectUri = useMemo((): string => {\n if (typeof config.redirectUri !== 'undefined') {\n return config.redirectUri;\n }\n\n return makeRedirectUri({\n // The redirect URI should be created using fb + client ID on native.\n native: `fb${clientId}://authorize`,\n useProxy,\n ...redirectUriOptions,\n });\n }, [useProxy, clientId, config.redirectUri, redirectUriOptions]);\n\n const extraParams = useMemo((): FacebookAuthRequestConfig['extraParams'] => {\n const output = config.extraParams ? { ...config.extraParams } : {};\n\n if (config.language) {\n output.locale = config.language;\n }\n return output;\n }, [config.extraParams, config.language]);\n\n const request = useLoadedAuthRequest(\n {\n ...config,\n extraParams,\n clientId,\n redirectUri,\n },\n discovery,\n FacebookAuthRequest\n );\n\n const [result, promptAsync] = useAuthRequestResult(request, discovery, {\n windowFeatures: settings.windowFeatures,\n useProxy,\n });\n\n return [request, result, promptAsync];\n}\n"]}
1
+ {"version":3,"file":"Facebook.js","sourceRoot":"","sources":["../../src/providers/Facebook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,WAAW,EAKX,eAAe,EACf,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvE,MAAM,QAAQ,GAAG;IACf,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IAC3C,kFAAkF;IAClF,aAAa,EAAE,CAAC,gBAAgB,EAAE,OAAO,CAAC;CAC3C,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC1C,qBAAqB,EAAE,4CAA4C;IACnE,aAAa,EAAE,oDAAoD;CACpE,CAAC;AAUF,c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MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAEnE,IAAI,MAAM,CAAC,QAAQ,EAAE;YACnB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;SACjC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE1C,MAAM,OAAO,GAAG,oBAAoB,CAClC;QACE,GAAG,MAAM;QACT,WAAW;QACX,QAAQ;QACR,WAAW;KACZ,EACD,SAAS,EACT,mBAAmB,CACpB,CAAC;IAEF,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,oBAAoB,CAAC,OAAO,EAAE,SAAS,EAAE;QACrE,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,QAAQ;KACT,CAAC,CAAC;IAEH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { useMemo } from 'react';\nimport { Platform } from 'react-native';\n\nimport { AuthRequestConfig } from '../AuthRequest.types';\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport {\n AuthRequest,\n AuthRequestPromptOptions,\n AuthSessionRedirectUriOptions,\n AuthSessionResult,\n DiscoveryDocument,\n makeRedirectUri,\n ResponseType,\n} from '../AuthSession';\nimport { generateHexStringAsync } from '../PKCE';\nimport { ProviderAuthRequestConfig } from './Provider.types';\nimport { applyRequiredScopes, useProxyEnabled } from './ProviderUtils';\n\nconst settings = {\n windowFeatures: { width: 700, height: 600 },\n // These are required for Firebase to work properly which is a reasonable default.\n minimumScopes: ['public_profile', 'email'],\n};\n\nexport const discovery: DiscoveryDocument = {\n authorizationEndpoint: 'https://www.facebook.com/v6.0/dialog/oauth',\n tokenEndpoint: 'https://graph.facebook.com/v6.0/oauth/access_token',\n};\n\n// @needsAudit @docsMissing\nexport interface FacebookAuthRequestConfig extends ProviderAuthRequestConfig {\n webClientId?: string;\n iosClientId?: string;\n androidClientId?: string;\n expoClientId?: string;\n}\n\n// @needsAudit\n/**\n * Extends [`AuthRequest`](#authrequest) and accepts [`FacebookAuthRequest`](#facebookauthrequest) in the constructor.\n */\nclass FacebookAuthRequest extends AuthRequest {\n nonce?: string;\n\n constructor({\n language,\n // Account selection cannot be reliably emulated on Facebook.\n extraParams = {},\n clientSecret,\n ...config\n }: FacebookAuthRequestConfig) {\n const inputParams: Record<string, string> = {\n display: 'popup',\n ...extraParams,\n };\n if (language) {\n inputParams.locale = language;\n }\n\n // Apply the default scopes\n const scopes = applyRequiredScopes(config.scopes, settings.minimumScopes);\n let inputClientSecret: string | undefined;\n // Facebook will throw if you attempt to use the client secret\n if (config.responseType && config.responseType !== ResponseType.Code) {\n // TODO: maybe warn that you shouldn't store the client secret on the client\n inputClientSecret = clientSecret;\n }\n // Default to implicit auth\n if (!config.responseType) {\n config.responseType = ResponseType.Token;\n }\n super({\n ...config,\n clientSecret: inputClientSecret,\n scopes,\n extraParams: inputParams,\n });\n }\n\n /**\n * Load and return a valid auth request based on the input config.\n */\n async getAuthRequestConfigAsync(): Promise<AuthRequestConfig> {\n const { extraParams = {}, ...config } = await super.getAuthRequestConfigAsync();\n if (!extraParams.nonce && !this.nonce) {\n if (!this.nonce) {\n this.nonce = await generateHexStringAsync(16);\n }\n extraParams.auth_nonce = this.nonce;\n }\n return {\n ...config,\n extraParams,\n };\n }\n}\n\n/**\n * Load an authorization request.\n * Returns a loaded request, a response, and a prompt method.\n * When the prompt method completes then the response will be fulfilled.\n *\n * - [Get Started](https://docs.expo.dev/guides/authentication/#facebook)\n *\n * @param config\n * @param redirectUriOptions\n */\nexport function useAuthRequest(\n config: Partial<FacebookAuthRequestConfig> = {},\n redirectUriOptions: Partial<AuthSessionRedirectUriOptions> = {}\n): [\n FacebookAuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>\n] {\n const useProxy = useProxyEnabled(redirectUriOptions);\n\n const clientId = useMemo((): string => {\n const propertyName = useProxy\n ? 'expoClientId'\n : Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n });\n return config[propertyName as any] ?? config.clientId;\n }, [\n useProxy,\n config.expoClientId,\n config.iosClientId,\n config.androidClientId,\n config.webClientId,\n config.clientId,\n ]);\n\n const redirectUri = useMemo((): string => {\n if (typeof config.redirectUri !== 'undefined') {\n return config.redirectUri;\n }\n\n return makeRedirectUri({\n // The redirect URI should be created using fb + client ID on native.\n native: `fb${clientId}://authorize`,\n useProxy,\n projectNameForProxy: '@community/native-component-list',\n ...redirectUriOptions,\n });\n }, [useProxy, clientId, config.redirectUri, redirectUriOptions]);\n\n const extraParams = useMemo((): FacebookAuthRequestConfig['extraParams'] => {\n const output = config.extraParams ? { ...config.extraParams } : {};\n\n if (config.language) {\n output.locale = config.language;\n }\n return output;\n }, [config.extraParams, config.language]);\n\n const request = useLoadedAuthRequest(\n {\n ...config,\n extraParams,\n clientId,\n redirectUri,\n },\n discovery,\n FacebookAuthRequest\n );\n\n const [result, promptAsync] = useAuthRequestResult(request, discovery, {\n windowFeatures: settings.windowFeatures,\n useProxy,\n });\n\n return [request, result, promptAsync];\n}\n"]}
@@ -46,7 +46,7 @@ export interface GoogleAuthRequestConfig extends ProviderAuthRequestConfig {
46
46
  * - _Standalone_: Automatically added, do nothing.
47
47
  * - _Bare workflow_: Run `npx uri-scheme add <your bundle id> --ios`
48
48
  * - To test this you can:
49
- * 1. Eject to bare: `expo eject` and run `yarn ios`
49
+ * 1. Prebuild to generate the native files: `expo prebuild` and run `yarn ios`
50
50
  * 2. Create a custom client: `expo client:ios`
51
51
  * 3. Build a production IPA: `expo build:ios`
52
52
  * - Whenever you change the values in `app.json` you'll need to rebuild the native app.
@@ -67,7 +67,7 @@ export interface GoogleAuthRequestConfig extends ProviderAuthRequestConfig {
67
67
  * - Run `expo credentials:manager -p android` then select "Update upload Keystore" -> "Generate new keystore" -> "Go back to experience overview"
68
68
  * - Copy your "Google Certificate Fingerprint", it will output a string that looks like `A1:B2:C3` but longer.
69
69
  * - To test this you can:
70
- * 1. Eject to bare: `expo eject` and run `yarn ios`
70
+ * 1. Prebuild to generate the native files: `expo prebuild` and run `yarn ios`
71
71
  * 2. Build a production IPA: `expo build:android`
72
72
  */
73
73
  androidClientId?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Google.js","sourceRoot":"","sources":["../../src/providers/Google.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,WAAW,EAMX,sBAAsB,EACtB,eAAe,EACf,MAAM,EACN,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE1F,MAAM,QAAQ,GAAG;IACf,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IAC3C,aAAa,EAAE;QACb,QAAQ;QACR,kDAAkD;QAClD,gDAAgD;KACjD;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC1C,qBAAqB,EAAE,8CAA8C;IACrE,aAAa,EAAE,qCAAqC;IACpD,kBAAkB,EAAE,sCAAsC;IAC1D,gBAAgB,EAAE,kDAAkD;CACrE,CAAC;AAqFF,cAAc;AACd;;GAEG;AACH,MAAM,iBAAkB,SAAQ,WAAW;IACzC,KAAK,CAAU;IAEf,YAAY,EACV,QAAQ,EACR,SAAS,EACT,a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;IAElD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,IAAI,sBAAsB,IAAI,MAAM,EAAE,IAAI,KAAK,SAAS,EAAE;YACxD,MAAM,eAAe,GAAG,IAAI,kBAAkB,CAAC;gBAC7C,QAAQ;gBACR,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,WAAW;gBACX,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;gBACxB,WAAW,EAAE;oBACX,aAAa,EAAE,OAAO,EAAE,YAAY,IAAI,EAAE;iBAC3C;aACF,CAAC,CAAC;YACH,eAAe,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,EAAE;gBAC9D,IAAI,SAAS,EAAE;oBACb,aAAa,CAAC;wBACZ,GAAG,MAAM;wBACT,MAAM,EAAE;4BACN,QAAQ,EAAE,cAAc,EAAE,OAAO,IAAI,EAAE;4BACvC,YAAY,EAAE,cAAc,CAAC,WAAW;4BACxC,GAAG,MAAM,CAAC,MAAM;yBACjB;wBACD,cAAc;qBACf,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,aAAa,CAAC,MAAM,CAAC,CAAC;SACvB;QACD,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,QAAQ;QACR,WAAW;QACX,sBAAsB;QACtB,MAAM,CAAC,YAAY;QACnB,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC;QACxB,OAAO,EAAE,YAAY;QACrB,MAAM;KACP,CAAC,CAAC;IAEH,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import * as Application from 'expo-application';\nimport { useEffect, useMemo, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport {\n AuthRequest,\n AuthRequestConfig,\n AuthRequestPromptOptions,\n AuthSessionRedirectUriOptions,\n AuthSessionResult,\n DiscoveryDocument,\n generateHexStringAsync,\n makeRedirectUri,\n Prompt,\n ResponseType,\n} from '../AuthSession';\nimport { AccessTokenRequest } from '../TokenRequest';\nimport { ProviderAuthRequestConfig } from './Provider.types';\nimport { applyRequiredScopes, invariantClientId, useProxyEnabled } from './ProviderUtils';\n\nconst settings = {\n windowFeatures: { width: 515, height: 680 },\n minimumScopes: [\n 'openid',\n 'https://www.googleapis.com/auth/userinfo.profile',\n 'https://www.googleapis.com/auth/userinfo.email',\n ],\n};\n\nexport const discovery: DiscoveryDocument = {\n authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth',\n tokenEndpoint: 'https://oauth2.googleapis.com/token',\n revocationEndpoint: 'https://oauth2.googleapis.com/revoke',\n userInfoEndpoint: 'https://openidconnect.googleapis.com/v1/userinfo',\n};\n\n// @needsAudit\nexport interface GoogleAuthRequestConfig extends ProviderAuthRequestConfig {\n /**\n * If the user's email address is known ahead of time, it can be supplied to be the default option.\n * If the user has approved access for this app in the past then auth may return without any further interaction.\n */\n loginHint?: string;\n /**\n * When `true`, the service will allow the user to switch between accounts (if possible).\n * @default false.\n */\n selectAccount?: boolean;\n /**\n * Proxy client ID for use in the Expo client on iOS and Android.\n *\n * This Google Client ID must be setup as follows:\n *\n * - **Application Type**: Web Application\n * - **URIs**: https://auth.expo.io\n * - **Authorized redirect URIs**: https://auth.expo.io/@your-username/your-project-slug\n */\n expoClientId?: string;\n /**\n * Expo web client ID for use in the browser.\n *\n * This Google Client ID must be setup as follows:\n *\n * - **Application Type**: Web Application\n * - Give it a name (e.g. \"Web App\").\n * - **URIs** (Authorized JavaScript origins): https://localhost:19006 & https://yourwebsite.com\n * - **Authorized redirect URIs**: https://localhost:19006 & https://yourwebsite.com\n * - To test this be sure to start your app with `expo start:web --https`.\n */\n webClientId?: string;\n /**\n * iOS native client ID for use in standalone, bare workflow, and custom clients.\n *\n * This Google Client ID must be setup as follows:\n *\n * - **Application Type**: iOS Application\n * - Give it a name (e.g. \"iOS App\").\n * - **Bundle ID**: Must match the value of `ios.bundleIdentifier` in your `app.json`.\n * - Your app needs to conform to the URI scheme matching your bundle identifier.\n * - _Standalone_: Automatically added, do nothing.\n * - _Bare workflow_: Run `npx uri-scheme add <your bundle id> --ios`\n * - To test this you can:\n * 1. Eject to bare: `expo eject` and run `yarn ios`\n * 2. Create a custom client: `expo client:ios`\n * 3. Build a production IPA: `expo build:ios`\n * - Whenever you change the values in `app.json` you'll need to rebuild the native app.\n */\n iosClientId?: string;\n /**\n * Android native client ID for use in standalone, and bare workflow.\n *\n * This Google Client ID must be setup as follows:\n *\n * - **Application Type**: Android Application\n * - Give it a name (e.g. \"Android App\").\n * - **Package name**: Must match the value of `android.package` in your `app.json`.\n * - Your app needs to conform to the URI scheme matching your `android.package` (ex. `com.myname.mycoolapp:/`).\n * - _Standalone_: Automatically added, do nothing.\n * - _Bare workflow_: Run `npx uri-scheme add <your android.package> --android`\n * - **Signing-certificate fingerprint**:\n * - Run `expo credentials:manager -p android` then select \"Update upload Keystore\" -> \"Generate new keystore\" -> \"Go back to experience overview\"\n * - Copy your \"Google Certificate Fingerprint\", it will output a string that looks like `A1:B2:C3` but longer.\n * - To test this you can:\n * 1. Eject to bare: `expo eject` and run `yarn ios`\n * 2. Build a production IPA: `expo build:android`\n */\n androidClientId?: string;\n /**\n * Should the hook automatically exchange the response code for an authentication token.\n *\n * Defaults to `true` on installed apps (iOS, Android) when `ResponseType.Code` is used (default).\n */\n shouldAutoExchangeCode?: boolean;\n /**\n * Language code ISO 3166-1 alpha-2 region code, such as 'it' or 'pt-PT'.\n */\n language?: string;\n}\n\n// @needsAudit\n/**\n * Extends [`AuthRequest`](#authrequest) and accepts [`GoogleAuthRequestConfig`](#googleauthrequestconfig) in the constructor.\n */\nclass GoogleAuthRequest extends AuthRequest {\n nonce?: string;\n\n constructor({\n language,\n loginHint,\n selectAccount,\n extraParams = {},\n clientSecret,\n ...config\n }: GoogleAuthRequestConfig) {\n const inputParams = {\n ...extraParams,\n };\n if (language) inputParams.hl = language;\n if (loginHint) inputParams.login_hint = loginHint;\n if (selectAccount) inputParams.prompt = Prompt.SelectAccount;\n\n // Apply the default scopes\n const scopes = applyRequiredScopes(config.scopes, settings.minimumScopes);\n const isImplicit =\n config.responseType === ResponseType.Token || config.responseType === ResponseType.IdToken;\n if (isImplicit) {\n // PKCE must be disabled in implicit mode.\n config.usePKCE = false;\n }\n let inputClientSecret: string | undefined;\n // Google will throw if you attempt to use the client secret\n if (config.responseType && config.responseType !== ResponseType.Code) {\n // TODO: maybe warn that you shouldn't store the client secret on the client\n inputClientSecret = clientSecret;\n }\n super({\n ...config,\n clientSecret: inputClientSecret,\n scopes,\n extraParams: inputParams,\n });\n }\n\n /**\n * Load and return a valid auth request based on the input config.\n */\n async getAuthRequestConfigAsync(): Promise<AuthRequestConfig> {\n const { extraParams = {}, ...config } = await super.getAuthRequestConfigAsync();\n if (config.responseType === ResponseType.IdToken && !extraParams.nonce && !this.nonce) {\n if (!this.nonce) {\n this.nonce = await generateHexStringAsync(16);\n }\n extraParams.nonce = this.nonce;\n }\n return {\n ...config,\n extraParams,\n };\n }\n}\n\n/**\n * Load an authorization request with an ID Token for authentication with Firebase.\n *\n * Returns a loaded request, a response, and a prompt method.\n * When the prompt method completes then the response will be fulfilled.\n *\n * The id token can be retrieved with `response.params.id_token`.\n *\n * - [Get Started](https://docs.expo.dev/guides/authentication/#google)\n *\n * @param config\n * @param redirectUriOptions\n */\nexport function useIdTokenAuthRequest(\n config: Partial<GoogleAuthRequestConfig>,\n redirectUriOptions: Partial<AuthSessionRedirectUriOptions> = {}\n): [\n GoogleAuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>\n] {\n const useProxy = useProxyEnabled(redirectUriOptions);\n\n const isWebAuth = useProxy || Platform.OS === 'web';\n\n return useAuthRequest(\n {\n ...config,\n responseType:\n // If the client secret is provided then code can be used\n !config.clientSecret &&\n // When web auth is used, we can request the `id_token` directly without exchanging a code.\n isWebAuth\n ? ResponseType.IdToken\n : undefined,\n },\n { ...redirectUriOptions, useProxy }\n );\n}\n\n/**\n * Load an authorization request.\n * Returns a loaded request, a response, and a prompt method.\n * When the prompt method completes, then the response will be fulfilled.\n *\n * - [Get Started](https://docs.expo.dev/guides/authentication/#google)\n *\n * @param config\n * @param redirectUriOptions\n */\nexport function useAuthRequest(\n config: Partial<GoogleAuthRequestConfig> = {},\n redirectUriOptions: Partial<AuthSessionRedirectUriOptions> = {}\n): [\n GoogleAuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>\n] {\n const useProxy = useProxyEnabled(redirectUriOptions);\n\n const clientId = useMemo((): string => {\n const propertyName = useProxy\n ? 'expoClientId'\n : Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n });\n\n const clientId = config[propertyName as any] ?? config.clientId;\n invariantClientId(propertyName, clientId, 'Google');\n return clientId;\n }, [\n useProxy,\n config.expoClientId,\n config.iosClientId,\n config.androidClientId,\n config.webClientId,\n config.clientId,\n ]);\n\n const responseType = useMemo(() => {\n // Allow overrides.\n if (typeof config.responseType !== 'undefined') {\n return config.responseType;\n }\n // You can only use `response_token=code` on installed apps (iOS, Android without proxy).\n // Installed apps can auto exchange without a client secret and get the token and id-token (Firebase).\n const isInstalledApp = Platform.OS !== 'web' && !useProxy;\n // If the user provided the client secret (they shouldn't!) then use code exchange by default.\n if (config.clientSecret || isInstalledApp) {\n return ResponseType.Code;\n }\n // This seems the most pragmatic option since it can result in a full authentication on web and proxy platforms as expected.\n return ResponseType.Token;\n }, [config.responseType, config.clientSecret, useProxy]);\n\n const redirectUri = useMemo((): string => {\n if (typeof config.redirectUri !== 'undefined') {\n return config.redirectUri;\n }\n\n return makeRedirectUri({\n native: `${Application.applicationId}:/oauthredirect`,\n useProxy,\n ...redirectUriOptions,\n // native: `com.googleusercontent.apps.${guid}:/oauthredirect`,\n });\n }, [useProxy, config.redirectUri, redirectUriOptions]);\n\n const extraParams = useMemo((): GoogleAuthRequestConfig['extraParams'] => {\n const output = config.extraParams ? { ...config.extraParams } : {};\n\n if (config.language) {\n output.hl = output.language;\n }\n if (config.loginHint) {\n output.login_hint = output.loginHint;\n }\n if (config.selectAccount) {\n output.prompt = Prompt.SelectAccount;\n }\n return output;\n }, [config.extraParams, config.language, config.loginHint, config.selectAccount]);\n\n const request = useLoadedAuthRequest(\n {\n ...config,\n responseType,\n extraParams,\n clientId,\n redirectUri,\n },\n discovery,\n GoogleAuthRequest\n );\n\n const [result, promptAsync] = useAuthRequestResult(request, discovery, {\n useProxy,\n windowFeatures: settings.windowFeatures,\n });\n\n const [fullResult, setFullResult] = useState<AuthSessionResult | null>(null);\n\n const shouldAutoExchangeCode = useMemo(() => {\n // allow overrides\n if (typeof config.shouldAutoExchangeCode !== 'undefined') {\n return config.shouldAutoExchangeCode;\n }\n\n // has a code to exchange and doesn't have an authentication yet.\n return result?.type === 'success' && result.params.code && !result.authentication;\n }, [config.shouldAutoExchangeCode, result?.type]);\n\n useEffect(() => {\n let isMounted = true;\n if (shouldAutoExchangeCode && result?.type === 'success') {\n const exchangeRequest = new AccessTokenRequest({\n clientId,\n clientSecret: config.clientSecret,\n redirectUri,\n scopes: config.scopes,\n code: result.params.code,\n extraParams: {\n code_verifier: request?.codeVerifier || '',\n },\n });\n exchangeRequest.performAsync(discovery).then((authentication) => {\n if (isMounted) {\n setFullResult({\n ...result,\n params: {\n id_token: authentication?.idToken || '',\n access_token: authentication.accessToken,\n ...result.params,\n },\n authentication,\n });\n }\n });\n } else {\n setFullResult(result);\n }\n return () => {\n isMounted = false;\n };\n }, [\n clientId,\n redirectUri,\n shouldAutoExchangeCode,\n config.clientSecret,\n config.scopes?.join(','),\n request?.codeVerifier,\n result,\n ]);\n\n return [request, fullResult, promptAsync];\n}\n"]}
1
+ {"version":3,"file":"Google.js","sourceRoot":"","sources":["../../src/providers/Google.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,WAAW,EAMX,sBAAsB,EACtB,eAAe,EACf,MAAM,EACN,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE1F,MAAM,QAAQ,GAAG;IACf,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IAC3C,aAAa,EAAE;QACb,QAAQ;QACR,kDAAkD;QAClD,gDAAgD;KACjD;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC1C,qBAAqB,EAAE,8CAA8C;IACrE,aAAa,EAAE,qCAAqC;IACpD,kBAAkB,EAAE,sCAAsC;IAC1D,gBAAgB,EAAE,kDAAkD;CACrE,CAAC;AAqFF,cAAc;AACd;;GAEG;AACH,MAAM,iBAAkB,SAAQ,WAAW;IACzC,KAAK,CAAU;IAEf,YAAY,EACV,QAAQ,EACR,SAAS,EACT,aAAa,EACb,WAAW,GAAG,EAAE,EAChB,YAAY,EACZ,GAAG,MAAM,EACe;QACxB,MAAM,WAAW,GAAG;YAClB,GAAG,WAAW;SACf,CAAC;QACF,IAAI,QAAQ;YAAE,WAAW,CAAC,EAAE,GAAG,QAAQ,CAAC;QACxC,IAAI,SAAS;YAAE,WAAW,CAA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M,CAAC,YAAY;gBACjC,WAAW;gBACX,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;gBACxB,WAAW,EAAE;oBACX,aAAa,EAAE,OAAO,EAAE,YAAY,IAAI,EAAE;iBAC3C;aACF,CAAC,CAAC;YACH,eAAe,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,EAAE;gBAC9D,IAAI,SAAS,EAAE;oBACb,aAAa,CAAC;wBACZ,GAAG,MAAM;wBACT,MAAM,EAAE;4BACN,QAAQ,EAAE,cAAc,EAAE,OAAO,IAAI,EAAE;4BACvC,YAAY,EAAE,cAAc,CAAC,WAAW;4BACxC,GAAG,MAAM,CAAC,MAAM;yBACjB;wBACD,cAAc;qBACf,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,aAAa,CAAC,MAAM,CAAC,CAAC;SACvB;QACD,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,QAAQ;QACR,WAAW;QACX,sBAAsB;QACtB,MAAM,CAAC,YAAY;QACnB,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC;QACxB,OAAO,EAAE,YAAY;QACrB,MAAM;KACP,CAAC,CAAC;IAEH,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import * as Application from 'expo-application';\nimport { useEffect, useMemo, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport {\n AuthRequest,\n AuthRequestConfig,\n AuthRequestPromptOptions,\n AuthSessionRedirectUriOptions,\n AuthSessionResult,\n DiscoveryDocument,\n generateHexStringAsync,\n makeRedirectUri,\n Prompt,\n ResponseType,\n} from '../AuthSession';\nimport { AccessTokenRequest } from '../TokenRequest';\nimport { ProviderAuthRequestConfig } from './Provider.types';\nimport { applyRequiredScopes, invariantClientId, useProxyEnabled } from './ProviderUtils';\n\nconst settings = {\n windowFeatures: { width: 515, height: 680 },\n minimumScopes: [\n 'openid',\n 'https://www.googleapis.com/auth/userinfo.profile',\n 'https://www.googleapis.com/auth/userinfo.email',\n ],\n};\n\nexport const discovery: DiscoveryDocument = {\n authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth',\n tokenEndpoint: 'https://oauth2.googleapis.com/token',\n revocationEndpoint: 'https://oauth2.googleapis.com/revoke',\n userInfoEndpoint: 'https://openidconnect.googleapis.com/v1/userinfo',\n};\n\n// @needsAudit\nexport interface GoogleAuthRequestConfig extends ProviderAuthRequestConfig {\n /**\n * If the user's email address is known ahead of time, it can be supplied to be the default option.\n * If the user has approved access for this app in the past then auth may return without any further interaction.\n */\n loginHint?: string;\n /**\n * When `true`, the service will allow the user to switch between accounts (if possible).\n * @default false.\n */\n selectAccount?: boolean;\n /**\n * Proxy client ID for use in the Expo client on iOS and Android.\n *\n * This Google Client ID must be setup as follows:\n *\n * - **Application Type**: Web Application\n * - **URIs**: https://auth.expo.io\n * - **Authorized redirect URIs**: https://auth.expo.io/@your-username/your-project-slug\n */\n expoClientId?: string;\n /**\n * Expo web client ID for use in the browser.\n *\n * This Google Client ID must be setup as follows:\n *\n * - **Application Type**: Web Application\n * - Give it a name (e.g. \"Web App\").\n * - **URIs** (Authorized JavaScript origins): https://localhost:19006 & https://yourwebsite.com\n * - **Authorized redirect URIs**: https://localhost:19006 & https://yourwebsite.com\n * - To test this be sure to start your app with `expo start:web --https`.\n */\n webClientId?: string;\n /**\n * iOS native client ID for use in standalone, bare workflow, and custom clients.\n *\n * This Google Client ID must be setup as follows:\n *\n * - **Application Type**: iOS Application\n * - Give it a name (e.g. \"iOS App\").\n * - **Bundle ID**: Must match the value of `ios.bundleIdentifier` in your `app.json`.\n * - Your app needs to conform to the URI scheme matching your bundle identifier.\n * - _Standalone_: Automatically added, do nothing.\n * - _Bare workflow_: Run `npx uri-scheme add <your bundle id> --ios`\n * - To test this you can:\n * 1. Prebuild to generate the native files: `expo prebuild` and run `yarn ios`\n * 2. Create a custom client: `expo client:ios`\n * 3. Build a production IPA: `expo build:ios`\n * - Whenever you change the values in `app.json` you'll need to rebuild the native app.\n */\n iosClientId?: string;\n /**\n * Android native client ID for use in standalone, and bare workflow.\n *\n * This Google Client ID must be setup as follows:\n *\n * - **Application Type**: Android Application\n * - Give it a name (e.g. \"Android App\").\n * - **Package name**: Must match the value of `android.package` in your `app.json`.\n * - Your app needs to conform to the URI scheme matching your `android.package` (ex. `com.myname.mycoolapp:/`).\n * - _Standalone_: Automatically added, do nothing.\n * - _Bare workflow_: Run `npx uri-scheme add <your android.package> --android`\n * - **Signing-certificate fingerprint**:\n * - Run `expo credentials:manager -p android` then select \"Update upload Keystore\" -> \"Generate new keystore\" -> \"Go back to experience overview\"\n * - Copy your \"Google Certificate Fingerprint\", it will output a string that looks like `A1:B2:C3` but longer.\n * - To test this you can:\n * 1. Prebuild to generate the native files: `expo prebuild` and run `yarn ios`\n * 2. Build a production IPA: `expo build:android`\n */\n androidClientId?: string;\n /**\n * Should the hook automatically exchange the response code for an authentication token.\n *\n * Defaults to `true` on installed apps (iOS, Android) when `ResponseType.Code` is used (default).\n */\n shouldAutoExchangeCode?: boolean;\n /**\n * Language code ISO 3166-1 alpha-2 region code, such as 'it' or 'pt-PT'.\n */\n language?: string;\n}\n\n// @needsAudit\n/**\n * Extends [`AuthRequest`](#authrequest) and accepts [`GoogleAuthRequestConfig`](#googleauthrequestconfig) in the constructor.\n */\nclass GoogleAuthRequest extends AuthRequest {\n nonce?: string;\n\n constructor({\n language,\n loginHint,\n selectAccount,\n extraParams = {},\n clientSecret,\n ...config\n }: GoogleAuthRequestConfig) {\n const inputParams = {\n ...extraParams,\n };\n if (language) inputParams.hl = language;\n if (loginHint) inputParams.login_hint = loginHint;\n if (selectAccount) inputParams.prompt = Prompt.SelectAccount;\n\n // Apply the default scopes\n const scopes = applyRequiredScopes(config.scopes, settings.minimumScopes);\n const isImplicit =\n config.responseType === ResponseType.Token || config.responseType === ResponseType.IdToken;\n if (isImplicit) {\n // PKCE must be disabled in implicit mode.\n config.usePKCE = false;\n }\n let inputClientSecret: string | undefined;\n // Google will throw if you attempt to use the client secret\n if (config.responseType && config.responseType !== ResponseType.Code) {\n // TODO: maybe warn that you shouldn't store the client secret on the client\n inputClientSecret = clientSecret;\n }\n super({\n ...config,\n clientSecret: inputClientSecret,\n scopes,\n extraParams: inputParams,\n });\n }\n\n /**\n * Load and return a valid auth request based on the input config.\n */\n async getAuthRequestConfigAsync(): Promise<AuthRequestConfig> {\n const { extraParams = {}, ...config } = await super.getAuthRequestConfigAsync();\n if (config.responseType === ResponseType.IdToken && !extraParams.nonce && !this.nonce) {\n if (!this.nonce) {\n this.nonce = await generateHexStringAsync(16);\n }\n extraParams.nonce = this.nonce;\n }\n return {\n ...config,\n extraParams,\n };\n }\n}\n\n/**\n * Load an authorization request with an ID Token for authentication with Firebase.\n *\n * Returns a loaded request, a response, and a prompt method.\n * When the prompt method completes then the response will be fulfilled.\n *\n * The id token can be retrieved with `response.params.id_token`.\n *\n * - [Get Started](https://docs.expo.dev/guides/authentication/#google)\n *\n * @param config\n * @param redirectUriOptions\n */\nexport function useIdTokenAuthRequest(\n config: Partial<GoogleAuthRequestConfig>,\n redirectUriOptions: Partial<AuthSessionRedirectUriOptions> = {}\n): [\n GoogleAuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>\n] {\n const useProxy = useProxyEnabled(redirectUriOptions);\n\n const isWebAuth = useProxy || Platform.OS === 'web';\n\n return useAuthRequest(\n {\n ...config,\n responseType:\n // If the client secret is provided then code can be used\n !config.clientSecret &&\n // When web auth is used, we can request the `id_token` directly without exchanging a code.\n isWebAuth\n ? ResponseType.IdToken\n : undefined,\n },\n { ...redirectUriOptions, useProxy }\n );\n}\n\n/**\n * Load an authorization request.\n * Returns a loaded request, a response, and a prompt method.\n * When the prompt method completes, then the response will be fulfilled.\n *\n * - [Get Started](https://docs.expo.dev/guides/authentication/#google)\n *\n * @param config\n * @param redirectUriOptions\n */\nexport function useAuthRequest(\n config: Partial<GoogleAuthRequestConfig> = {},\n redirectUriOptions: Partial<AuthSessionRedirectUriOptions> = {}\n): [\n GoogleAuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>\n] {\n const useProxy = useProxyEnabled(redirectUriOptions);\n\n const clientId = useMemo((): string => {\n const propertyName = useProxy\n ? 'expoClientId'\n : Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n });\n\n const clientId = config[propertyName as any] ?? config.clientId;\n invariantClientId(propertyName, clientId, 'Google');\n return clientId;\n }, [\n useProxy,\n config.expoClientId,\n config.iosClientId,\n config.androidClientId,\n config.webClientId,\n config.clientId,\n ]);\n\n const responseType = useMemo(() => {\n // Allow overrides.\n if (typeof config.responseType !== 'undefined') {\n return config.responseType;\n }\n // You can only use `response_token=code` on installed apps (iOS, Android without proxy).\n // Installed apps can auto exchange without a client secret and get the token and id-token (Firebase).\n const isInstalledApp = Platform.OS !== 'web' && !useProxy;\n // If the user provided the client secret (they shouldn't!) then use code exchange by default.\n if (config.clientSecret || isInstalledApp) {\n return ResponseType.Code;\n }\n // This seems the most pragmatic option since it can result in a full authentication on web and proxy platforms as expected.\n return ResponseType.Token;\n }, [config.responseType, config.clientSecret, useProxy]);\n\n const redirectUri = useMemo((): string => {\n if (typeof config.redirectUri !== 'undefined') {\n return config.redirectUri;\n }\n\n return makeRedirectUri({\n native: `${Application.applicationId}:/oauthredirect`,\n useProxy,\n ...redirectUriOptions,\n // native: `com.googleusercontent.apps.${guid}:/oauthredirect`,\n });\n }, [useProxy, config.redirectUri, redirectUriOptions]);\n\n const extraParams = useMemo((): GoogleAuthRequestConfig['extraParams'] => {\n const output = config.extraParams ? { ...config.extraParams } : {};\n\n if (config.language) {\n output.hl = output.language;\n }\n if (config.loginHint) {\n output.login_hint = output.loginHint;\n }\n if (config.selectAccount) {\n output.prompt = Prompt.SelectAccount;\n }\n return output;\n }, [config.extraParams, config.language, config.loginHint, config.selectAccount]);\n\n const request = useLoadedAuthRequest(\n {\n ...config,\n responseType,\n extraParams,\n clientId,\n redirectUri,\n },\n discovery,\n GoogleAuthRequest\n );\n\n const [result, promptAsync] = useAuthRequestResult(request, discovery, {\n useProxy,\n windowFeatures: settings.windowFeatures,\n });\n\n const [fullResult, setFullResult] = useState<AuthSessionResult | null>(null);\n\n const shouldAutoExchangeCode = useMemo(() => {\n // allow overrides\n if (typeof config.shouldAutoExchangeCode !== 'undefined') {\n return config.shouldAutoExchangeCode;\n }\n\n // has a code to exchange and doesn't have an authentication yet.\n return result?.type === 'success' && result.params.code && !result.authentication;\n }, [config.shouldAutoExchangeCode, result?.type]);\n\n useEffect(() => {\n let isMounted = true;\n if (shouldAutoExchangeCode && result?.type === 'success') {\n const exchangeRequest = new AccessTokenRequest({\n clientId,\n clientSecret: config.clientSecret,\n redirectUri,\n scopes: config.scopes,\n code: result.params.code,\n extraParams: {\n code_verifier: request?.codeVerifier || '',\n },\n });\n exchangeRequest.performAsync(discovery).then((authentication) => {\n if (isMounted) {\n setFullResult({\n ...result,\n params: {\n id_token: authentication?.idToken || '',\n access_token: authentication.accessToken,\n ...result.params,\n },\n authentication,\n });\n }\n });\n } else {\n setFullResult(result);\n }\n return () => {\n isMounted = false;\n };\n }, [\n clientId,\n redirectUri,\n shouldAutoExchangeCode,\n config.clientSecret,\n config.scopes?.join(','),\n request?.codeVerifier,\n result,\n ]);\n\n return [request, fullResult, promptAsync];\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-auth-session",
3
- "version": "3.6.0",
3
+ "version": "3.7.1",
4
4
  "description": "Expo module for browser-based authentication",
5
5
  "main": "build/AuthSession.js",
6
6
  "types": "build/AuthSession.d.ts",
@@ -34,10 +34,10 @@
34
34
  "license": "MIT",
35
35
  "homepage": "https://docs.expo.dev/versions/latest/sdk/auth-session",
36
36
  "dependencies": {
37
- "expo-constants": "~13.1.0",
38
- "expo-crypto": "~10.2.0",
39
- "expo-linking": "~3.1.0",
40
- "expo-web-browser": "~10.2.0",
37
+ "expo-constants": "~13.2.0",
38
+ "expo-crypto": "~11.0.0",
39
+ "expo-linking": "~3.2.0",
40
+ "expo-web-browser": "~11.0.0",
41
41
  "invariant": "^2.2.4",
42
42
  "qs": "6.9.1"
43
43
  },
@@ -56,5 +56,5 @@
56
56
  "jest": {
57
57
  "preset": "expo-module-scripts"
58
58
  },
59
- "gitHead": "89a27c0ca0ca8becd7546697298e874a15e94faf"
59
+ "gitHead": "c6678c65b68e45062d49a2deea8e822f69388278"
60
60
  }
@@ -164,7 +164,7 @@ export class AuthRequest implements Omit<AuthRequestConfig, 'state'> {
164
164
  let returnUrl: string = this.redirectUri;
165
165
  if (options.useProxy) {
166
166
  returnUrl = sessionUrlProvider.getDefaultReturnUrl(proxyOptions?.path, proxyOptions);
167
- startUrl = sessionUrlProvider.getStartUrl(url, returnUrl);
167
+ startUrl = sessionUrlProvider.getStartUrl(url, returnUrl, options.projectNameForProxy);
168
168
  }
169
169
  // Prevent multiple sessions from running at the same time, WebBrowser doesn't
170
170
  // support it this makes the behavior predictable.
@@ -84,6 +84,10 @@ export type AuthRequestPromptOptions = Omit<WebBrowserOpenOptions, 'windowFeatur
84
84
  * @default false
85
85
  */
86
86
  useProxy?: boolean;
87
+ /**
88
+ * Project name to use for the \`auth.expo.io\` proxy when `useProxy` is true.
89
+ */
90
+ projectNameForProxy?: string;
87
91
  /**
88
92
  * URL options to be used when creating the redirect URL for the auth proxy.
89
93
  */
@@ -1,7 +1,11 @@
1
1
  import Constants, { ExecutionEnvironment } from 'expo-constants';
2
2
  import * as Linking from 'expo-linking';
3
3
  import { Platform } from 'expo-modules-core';
4
- import { dismissAuthSession, openAuthSessionAsync } from 'expo-web-browser';
4
+ import {
5
+ dismissAuthSession,
6
+ openAuthSessionAsync,
7
+ WebBrowserAuthSessionResult,
8
+ } from 'expo-web-browser';
5
9
 
6
10
  import { AuthRequest } from './AuthRequest';
7
11
  import {
@@ -32,7 +36,7 @@ let _authLock = false;
32
36
 
33
37
  // @needsAudit
34
38
  /**
35
- * Initiate an authentication session with the given options. Only one `AuthSession` can be active at any given time in your application.
39
+ * Initiate a proxied authentication session with the given options. Only one `AuthSession` can be active at any given time in your application.
36
40
  * If you attempt to open a second session while one is still in progress, the second session will return a value to indicate that `AuthSession` is locked.
37
41
  *
38
42
  * @param options An object of type `AuthSessionOptions`.
@@ -59,13 +63,13 @@ export async function startAsync(options: AuthSessionOptions): Promise<AuthSessi
59
63
  }
60
64
 
61
65
  const returnUrl = options.returnUrl || sessionUrlProvider.getDefaultReturnUrl();
62
- const startUrl = sessionUrlProvider.getStartUrl(authUrl, returnUrl);
66
+ const startUrl = sessionUrlProvider.getStartUrl(authUrl, returnUrl, options.projectNameForProxy);
63
67
  const showInRecents = options.showInRecents || false;
64
68
 
65
69
  // About to start session, set lock
66
70
  _authLock = true;
67
71
 
68
- let result;
72
+ let result: WebBrowserAuthSessionResult;
69
73
  try {
70
74
  result = await _openWebBrowserAsync(startUrl, returnUrl, showInRecents);
71
75
  } finally {
@@ -77,8 +81,8 @@ export async function startAsync(options: AuthSessionOptions): Promise<AuthSessi
77
81
  if (!result) {
78
82
  throw new Error('Unexpected missing AuthSession result');
79
83
  }
80
- if (!result.url) {
81
- if (result.type) {
84
+ if (!('url' in result)) {
85
+ if ('type' in result) {
82
86
  return result;
83
87
  } else {
84
88
  throw new Error('Unexpected AuthSession result with missing type');
@@ -126,7 +130,7 @@ export const getDefaultReturnUrl = sessionUrlProvider.getDefaultReturnUrl;
126
130
  * @deprecated Use `makeRedirectUri({ path, useProxy })` instead.
127
131
  */
128
132
  export function getRedirectUrl(path?: string): string {
129
- return sessionUrlProvider.getRedirectUrl(path);
133
+ return sessionUrlProvider.getRedirectUrl({ urlPath: path });
130
134
  }
131
135
 
132
136
  // @needsAudit
@@ -179,6 +183,7 @@ export function makeRedirectUri({
179
183
  path,
180
184
  preferLocalhost,
181
185
  useProxy,
186
+ projectNameForProxy,
182
187
  }: AuthSessionRedirectUriOptions = {}): string {
183
188
  if (
184
189
  Platform.OS !== 'web' &&
@@ -211,7 +216,7 @@ export function makeRedirectUri({
211
216
  return url;
212
217
  }
213
218
  // Attempt to use the proxy
214
- return sessionUrlProvider.getRedirectUrl(path);
219
+ return sessionUrlProvider.getRedirectUrl({ urlPath: path, projectNameForProxy });
215
220
  }
216
221
 
217
222
  // @needsAudit
@@ -234,7 +239,6 @@ export async function loadAsync(
234
239
  }
235
240
 
236
241
  async function _openWebBrowserAsync(startUrl: string, returnUrl: string, showInRecents: boolean) {
237
- // $FlowIssue: Flow thinks the awaited result can be a promise
238
242
  const result = await openAuthSessionAsync(startUrl, returnUrl, { showInRecents });
239
243
  if (result.type === 'cancel' || result.type === 'dismiss') {
240
244
  return { type: result.type };
@@ -8,9 +8,8 @@ export type AuthSessionOptions = {
8
8
  */
9
9
  authUrl: string;
10
10
  /**
11
- * The URL to return to the application. In managed apps, it's optional (defaults to `${Constants.linkingUrl}expo-auth-session`,
12
- * for example, `exp://expo.dev/@yourname/your-app-slug+expo-auth-session`).
13
- * However, in the bare app, it's required - `AuthSession` needs to know where to wait for the response.
11
+ * The URL to return to the application. In managed apps, it's optional and defaults to output of [`Linking.createURL('expo-auth-session', params)`](./linking/#linkingcreateurlpath-namedparameters)
12
+ * call with `scheme` and `queryParams` params. However, in the bare app, it's required - `AuthSession` needs to know where to wait for the response.
14
13
  * Hence, this method will throw an exception, if you don't provide `returnUrl`.
15
14
  */
16
15
  returnUrl?: string;
@@ -20,6 +19,10 @@ export type AuthSessionOptions = {
20
19
  * @platform android
21
20
  */
22
21
  showInRecents?: boolean;
22
+ /**
23
+ * Project name to use for the \`auth.expo.io\` proxy.
24
+ */
25
+ projectNameForProxy?: string;
23
26
  };
24
27
 
25
28
  // @needsAudit
@@ -37,7 +40,7 @@ export type AuthSessionResult =
37
40
  /**
38
41
  * How the auth completed.
39
42
  */
40
- type: 'cancel' | 'dismiss' | 'locked';
43
+ type: 'cancel' | 'dismiss' | 'opened' | 'locked';
41
44
  }
42
45
  | {
43
46
  /**
@@ -99,6 +102,10 @@ export type AuthSessionRedirectUriOptions = {
99
102
  * @default false
100
103
  */
101
104
  useProxy?: boolean;
105
+ /**
106
+ * Project name to use for the \`auth.expo.io\` proxy when `useProxy` is true.
107
+ */
108
+ projectNameForProxy?: string;
102
109
  /**
103
110
  * Attempt to convert the Expo server IP address to localhost.
104
111
  * This is useful for testing when your IP changes often, this will only work for iOS simulator.
@@ -25,7 +25,7 @@ export class SessionUrlProvider {
25
25
  });
26
26
  }
27
27
 
28
- getStartUrl(authUrl: string, returnUrl: string): string {
28
+ getStartUrl(authUrl: string, returnUrl: string, projectNameForProxy: string | undefined): string {
29
29
  if (Platform.OS === 'web' && !Platform.isDOMAvailable) {
30
30
  // Return nothing in SSR envs
31
31
  return '';
@@ -35,25 +35,25 @@ export class SessionUrlProvider {
35
35
  returnUrl,
36
36
  });
37
37
 
38
- return `${this.getRedirectUrl()}/start?${queryString}`;
38
+ return `${this.getRedirectUrl({ projectNameForProxy })}/start?${queryString}`;
39
39
  }
40
40
 
41
- getRedirectUrl(urlPath?: string): string {
41
+ getRedirectUrl(options: { projectNameForProxy?: string; urlPath?: string }): string {
42
42
  if (Platform.OS === 'web') {
43
43
  if (Platform.isDOMAvailable) {
44
- return [window.location.origin, urlPath].filter(Boolean).join('/');
44
+ return [window.location.origin, options.urlPath].filter(Boolean).join('/');
45
45
  } else {
46
46
  // Return nothing in SSR envs
47
47
  return '';
48
48
  }
49
49
  }
50
50
 
51
- const legacyExpoProjectId =
52
- Constants.manifest?.originalFullName ||
53
- Constants.manifest2?.extra?.expoClient?.originalFullName ||
51
+ const legacyExpoProjectFullName =
52
+ options.projectNameForProxy ||
53
+ Constants.expoConfig?.originalFullName ||
54
54
  Constants.manifest?.id;
55
55
 
56
- if (!legacyExpoProjectId) {
56
+ if (!legacyExpoProjectFullName) {
57
57
  let nextSteps = '';
58
58
  if (__DEV__) {
59
59
  if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {
@@ -64,14 +64,21 @@ export class SessionUrlProvider {
64
64
  ' Please report this as a bug with the contents of `expo config --type public`.';
65
65
  }
66
66
  }
67
+
68
+ if (Constants.manifest2) {
69
+ nextSteps =
70
+ ' Prefer AuthRequest (with the useProxy option set to false) in combination with an Expo Development Client build of your application.' +
71
+ ' To continue using the AuthSession proxy, specify the project full name (@owner/slug) using the projectNameForProxy option.';
72
+ }
73
+
67
74
  throw new Error(
68
- 'Cannot use AuthSession proxy because the project ID is not defined.' + nextSteps
75
+ 'Cannot use the AuthSession proxy because the project full name is not defined.' + nextSteps
69
76
  );
70
77
  }
71
78
 
72
- const redirectUrl = `${SessionUrlProvider.BASE_URL}/${legacyExpoProjectId}`;
79
+ const redirectUrl = `${SessionUrlProvider.BASE_URL}/${legacyExpoProjectFullName}`;
73
80
  if (__DEV__) {
74
- SessionUrlProvider.warnIfAnonymous(legacyExpoProjectId, redirectUrl);
81
+ SessionUrlProvider.warnIfAnonymous(legacyExpoProjectFullName, redirectUrl);
75
82
  // TODO: Verify with the dev server that the manifest is up to date.
76
83
  }
77
84
  return redirectUrl;
@@ -142,6 +142,7 @@ export function useAuthRequest(
142
142
  // The redirect URI should be created using fb + client ID on native.
143
143
  native: `fb${clientId}://authorize`,
144
144
  useProxy,
145
+ projectNameForProxy: '@community/native-component-list',
145
146
  ...redirectUriOptions,
146
147
  });
147
148
  }, [useProxy, clientId, config.redirectUri, redirectUriOptions]);
@@ -81,7 +81,7 @@ export interface GoogleAuthRequestConfig extends ProviderAuthRequestConfig {
81
81
  * - _Standalone_: Automatically added, do nothing.
82
82
  * - _Bare workflow_: Run `npx uri-scheme add <your bundle id> --ios`
83
83
  * - To test this you can:
84
- * 1. Eject to bare: `expo eject` and run `yarn ios`
84
+ * 1. Prebuild to generate the native files: `expo prebuild` and run `yarn ios`
85
85
  * 2. Create a custom client: `expo client:ios`
86
86
  * 3. Build a production IPA: `expo build:ios`
87
87
  * - Whenever you change the values in `app.json` you'll need to rebuild the native app.
@@ -102,7 +102,7 @@ export interface GoogleAuthRequestConfig extends ProviderAuthRequestConfig {
102
102
  * - Run `expo credentials:manager -p android` then select "Update upload Keystore" -> "Generate new keystore" -> "Go back to experience overview"
103
103
  * - Copy your "Google Certificate Fingerprint", it will output a string that looks like `A1:B2:C3` but longer.
104
104
  * - To test this you can:
105
- * 1. Eject to bare: `expo eject` and run `yarn ios`
105
+ * 1. Prebuild to generate the native files: `expo prebuild` and run `yarn ios`
106
106
  * 2. Build a production IPA: `expo build:android`
107
107
  */
108
108
  androidClientId?: string;
package/tsconfig.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "outDir": "./build"
6
6
  },
7
7
  "include": ["./src"],
8
- "exclude": ["**/__mocks__/*", "**/__tests__/*"]
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*", "**/__stories__/*"]
9
9
  }