expo-auth-session 57.0.0 → 57.0.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,10 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 57.0.1 — 2026-06-30
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
13
17
  ## 57.0.0 — 2026-06-25
14
18
 
15
19
  _This version does not introduce any user-facing changes._
@@ -10,7 +10,7 @@ export declare function dismiss(): void;
10
10
  export declare const getDefaultReturnUrl: (urlPath?: string, options?: Omit<Linking.CreateURLOptions, "queryParams">) => string;
11
11
  /**
12
12
  * 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.
13
- * > **Note** This method will throw an exception if you're using the bare workflow on native.
13
+ * > **Note** This method will throw an exception in an existing React Native project on native.
14
14
  *
15
15
  * @param path
16
16
  * @return
@@ -28,10 +28,10 @@ export declare const getDefaultReturnUrl: (urlPath?: string, options?: Omit<Link
28
28
  export declare function getRedirectUrl(path?: string): string;
29
29
  /**
30
30
  * Create a redirect url for the current platform and environment. You need to manually define the redirect that will be used in
31
- * a bare workflow React Native app, or an Expo standalone app, this is because it cannot be inferred automatically.
31
+ * an existing React Native project or a production build, because it cannot be inferred automatically.
32
32
  * - **Web:** Generates a path based on the current `window.location`. For production web apps, you should hard code the URL as well.
33
- * - **Managed workflow:** Uses the `scheme` property of your app config.
34
- * - **Bare workflow:** Will fallback to using the `native` option for bare workflow React Native apps.
33
+ * - **CNG projects:** Uses the `scheme` property of your app config.
34
+ * - **Existing React Native apps:** Falls back to using the `native` option.
35
35
  *
36
36
  * @param options Additional options for configuring the path.
37
37
  * @return The `redirectUri` to use in an authentication request.
@@ -16,7 +16,7 @@ export const getDefaultReturnUrl = sessionUrlProvider.getDefaultReturnUrl;
16
16
  // @needsAudit @docsMissing
17
17
  /**
18
18
  * 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.
19
- * > **Note** This method will throw an exception if you're using the bare workflow on native.
19
+ * > **Note** This method will throw an exception in an existing React Native project on native.
20
20
  *
21
21
  * @param path
22
22
  * @return
@@ -37,10 +37,10 @@ export function getRedirectUrl(path) {
37
37
  // @needsAudit
38
38
  /**
39
39
  * Create a redirect url for the current platform and environment. You need to manually define the redirect that will be used in
40
- * a bare workflow React Native app, or an Expo standalone app, this is because it cannot be inferred automatically.
40
+ * an existing React Native project or a production build, because it cannot be inferred automatically.
41
41
  * - **Web:** Generates a path based on the current `window.location`. For production web apps, you should hard code the URL as well.
42
- * - **Managed workflow:** Uses the `scheme` property of your app config.
43
- * - **Bare workflow:** Will fallback to using the `native` option for bare workflow React Native apps.
42
+ * - **CNG projects:** Uses the `scheme` property of your app config.
43
+ * - **Existing React Native apps:** Falls back to using the `native` option.
44
44
  *
45
45
  * @param options Additional options for configuring the path.
46
46
  * @return The `redirectUri` to use in an authentication request.
@@ -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,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,cAAc;AACd;;GAEG;AACH,MAAM,UAAU,OAAO;IACrB,kBAAkB,EAAE,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC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;IACxC,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;IACjE,MAAM,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC1C,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'expo-modules-core';\nimport { dismissAuthSession } from 'expo-web-browser';\n\nimport { AuthRequest } from './AuthRequest';\nimport type { AuthRequestConfig } from './AuthRequest.types';\nimport type { AuthSessionRedirectUriOptions } from './AuthSession.types';\nimport type { IssuerOrDiscovery } from './Discovery';\nimport { resolveDiscoveryAsync } from './Discovery';\nimport sessionUrlProvider from './SessionUrlProvider';\n\n// @needsAudit\n/**\n * Cancels an active `AuthSession` if there is one.\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()` 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.\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 * // Development Build: my-scheme://redirect\n * // Expo Go: exp://127.0.0.1:8081/--/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 * // Development Build: scheme2:///\n * // Expo Go: exp://localhost:8081\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}: 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 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\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"]}
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,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,cAAc;AACd;;GAEG;AACH,MAAM,UAAU,OAAO;IACrB,kBAAkB,EAAE,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC;AAE1E,2BAA2B;AAC3B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAAC,IAAa;IAC1C,OAAO,kBAAkB,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,cAAc;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,MAAM,EACN,MAAM,EACN,eAAe,EACf,WAAW,EACX,IAAI,EACJ,eAAe,MACkB,EAAE;IACnC,IACE,QAAQ,CAAC,EAAE,KAAK,KAAK;QACrB,MAAM;QACN,CAAC,oBAAoB,CAAC,UAAU,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC,QAAQ,CACnE,SAAS,CAAC,oBAAoB,CAC/B,EACD,CAAC;QACD,iEAAiE;QACjE,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,EAAE;QACxC,eAAe;QACf,MAAM;QACN,WAAW;KACZ,CAAC,CAAC;IAEH,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CACzB,oKAAoK,CACrK,CAAC;QACF,uCAAuC;QACvC,IAAI,SAAS,EAAE,MAAM,EAAE,CAAC;YACtB,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,OAAO,GAAG,QAAQ,YAAY,IAAI,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,cAAc;AACd;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAyB,EACzB,iBAAoC;IAEpC,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;IACjE,MAAM,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC1C,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'expo-modules-core';\nimport { dismissAuthSession } from 'expo-web-browser';\n\nimport { AuthRequest } from './AuthRequest';\nimport type { AuthRequestConfig } from './AuthRequest.types';\nimport type { AuthSessionRedirectUriOptions } from './AuthSession.types';\nimport type { IssuerOrDiscovery } from './Discovery';\nimport { resolveDiscoveryAsync } from './Discovery';\nimport sessionUrlProvider from './SessionUrlProvider';\n\n// @needsAudit\n/**\n * Cancels an active `AuthSession` if there is one.\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 in an existing React Native project 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()` 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 * an existing React Native project or a production build, 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 * - **CNG projects:** Uses the `scheme` property of your app config.\n * - **Existing React Native apps:** Falls back to using the `native` option.\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 * // Development Build: my-scheme://redirect\n * // Expo Go: exp://127.0.0.1:8081/--/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 * // Development Build: scheme2:///\n * // Expo Go: exp://localhost:8081\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}: 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 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\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"]}
@@ -68,8 +68,8 @@ export type AuthSessionRedirectUriOptions = {
68
68
  */
69
69
  preferLocalhost?: boolean;
70
70
  /**
71
- * Manual scheme to use in Bare and Standalone native app contexts. Takes precedence over all other properties.
72
- * You must define the URI scheme that will be used in a custom built native application or standalone Expo application.
71
+ * Manual scheme to use in existing React Native projects and production builds. Takes precedence over all other properties.
72
+ * You must define the URI scheme that will be used in a custom-built native application or production build.
73
73
  * The value should conform to your native app's URI schemes.
74
74
  * You can see conformance with `npx uri-scheme list`.
75
75
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AuthSession.types.js","sourceRoot":"","sources":["../src/AuthSession.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AuthError } from './Errors';\nimport type { TokenResponse } from './TokenRequest';\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 */\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 `makeRedirectUri`.\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 */\n scheme?: string;\n /**\n * Optional native scheme\n * URI protocol `<scheme>://` that must be built into your native app.\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 */\n isTripleSlashed?: 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 type { AuthError } from './Errors';\nimport type { TokenResponse } from './TokenRequest';\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 */\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 `makeRedirectUri`.\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 */\n scheme?: string;\n /**\n * Optional native scheme\n * URI protocol `<scheme>://` that must be built into your native app.\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 */\n isTripleSlashed?: 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 existing React Native projects and production builds. Takes precedence over all other properties.\n * You must define the URI scheme that will be used in a custom-built native application or production build.\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"]}
@@ -13,11 +13,11 @@ export type FacebookAuthRequestConfig = ProviderAuthRequestConfig & {
13
13
  */
14
14
  webClientId?: string;
15
15
  /**
16
- * iOS native client ID for use in development builds and bare workflow.
16
+ * iOS native client ID for use in development builds and existing React Native projects.
17
17
  */
18
18
  iosClientId?: string;
19
19
  /**
20
- * Android native client ID for use in development builds and bare workflow.
20
+ * Android native client ID for use in development builds and existing React Native projects.
21
21
  */
22
22
  androidClientId?: string;
23
23
  };
@@ -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,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,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,EA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GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAEnE,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;QAClC,CAAC;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;KACxC,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 type { ProviderAuthRequestConfig } from './Provider.types';\nimport { applyRequiredScopes, invariantClientId } from './ProviderUtils';\nimport { AuthRequest } from '../AuthRequest';\nimport type { AuthRequestConfig, AuthRequestPromptOptions } from '../AuthRequest.types';\nimport { ResponseType } from '../AuthRequest.types';\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport { makeRedirectUri } from '../AuthSession';\nimport type { AuthSessionRedirectUriOptions, AuthSessionResult } from '../AuthSession.types';\nimport type { DiscoveryDocument } from '../Discovery';\nimport { generateHexStringAsync } from '../PKCE';\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\n/**\n * @deprecated See [Facebook authentication](/guides/facebook-authentication/).\n */\nexport type FacebookAuthRequestConfig = ProviderAuthRequestConfig & {\n /**\n * Expo web client ID for use in the browser.\n */\n webClientId?: string;\n /**\n * iOS native client ID for use in development builds and bare workflow.\n */\n iosClientId?: string;\n /**\n * Android native client ID for use in development builds and bare workflow.\n */\n androidClientId?: 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 clientId = useMemo(() => {\n const propertyName = Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n } as const);\n const clientId = config[propertyName] ?? config.clientId;\n invariantClientId(propertyName, clientId, 'Facebook');\n return clientId;\n }, [config.iosClientId, config.androidClientId, config.webClientId, config.clientId]);\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 ...redirectUriOptions,\n });\n }, [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 });\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,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,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,OAAO,MAAM,CAAC,WAAW,KAAK,WAAW,EAAE,CAAC;YAC9C,OAAO,MAAM,CAAC,WAAW,CAAC;QAC5B,CAAC;QAED,OAAO,eAAe,CAAC;YACrB,qEAAqE;YACrE,MAAM,EAAE,KAAK,QAAQ,cAAc;YACnC,GAAG,kBAAkB;SACtB,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAEvD,MAAM,WAAW,GAAG,OAAO,CAAC,GAA6C,EAAE;QACzE,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAEnE,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;QAClC,CAAC;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;KACxC,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 type { ProviderAuthRequestConfig } from './Provider.types';\nimport { applyRequiredScopes, invariantClientId } from './ProviderUtils';\nimport { AuthRequest } from '../AuthRequest';\nimport type { AuthRequestConfig, AuthRequestPromptOptions } from '../AuthRequest.types';\nimport { ResponseType } from '../AuthRequest.types';\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport { makeRedirectUri } from '../AuthSession';\nimport type { AuthSessionRedirectUriOptions, AuthSessionResult } from '../AuthSession.types';\nimport type { DiscoveryDocument } from '../Discovery';\nimport { generateHexStringAsync } from '../PKCE';\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\n/**\n * @deprecated See [Facebook authentication](/guides/facebook-authentication/).\n */\nexport type FacebookAuthRequestConfig = ProviderAuthRequestConfig & {\n /**\n * Expo web client ID for use in the browser.\n */\n webClientId?: string;\n /**\n * iOS native client ID for use in development builds and existing React Native projects.\n */\n iosClientId?: string;\n /**\n * Android native client ID for use in development builds and existing React Native projects.\n */\n androidClientId?: 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 clientId = useMemo(() => {\n const propertyName = Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n } as const);\n const clientId = config[propertyName] ?? config.clientId;\n invariantClientId(propertyName, clientId, 'Facebook');\n return clientId;\n }, [config.iosClientId, config.androidClientId, config.webClientId, config.clientId]);\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 ...redirectUriOptions,\n });\n }, [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 });\n\n return [request, result, promptAsync];\n}\n"]}
@@ -23,11 +23,11 @@ export type GoogleAuthRequestConfig = ProviderAuthRequestConfig & {
23
23
  */
24
24
  webClientId?: string;
25
25
  /**
26
- * iOS native client ID for use in standalone, bare workflow, and custom clients.
26
+ * iOS native client ID for use in production builds, existing React Native projects, and development builds.
27
27
  */
28
28
  iosClientId?: string;
29
29
  /**
30
- * Android native client ID for use in standalone, and bare workflow.
30
+ * Android native client ID for use in production builds and existing React Native projects.
31
31
  */
32
32
  androidClientId?: string;
33
33
  /**
@@ -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;AAGxC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,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,GA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E,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 type { ProviderAuthRequestConfig } from './Provider.types';\nimport { applyRequiredScopes, invariantClientId } from './ProviderUtils';\nimport { AuthRequest } from '../AuthRequest';\nimport type { AuthRequestConfig, AuthRequestPromptOptions } from '../AuthRequest.types';\nimport { Prompt, ResponseType } from '../AuthRequest.types';\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport { makeRedirectUri } from '../AuthSession';\nimport type { AuthSessionRedirectUriOptions, AuthSessionResult } from '../AuthSession.types';\nimport type { DiscoveryDocument } from '../Discovery';\nimport { generateHexStringAsync } from '../PKCE';\nimport { AccessTokenRequest } from '../TokenRequest';\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\n/**\n * @deprecated See [Google authentication](/guides/google-authentication/).\n */\nexport type GoogleAuthRequestConfig = 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 * Expo web client ID for use in the browser.\n */\n webClientId?: string;\n /**\n * iOS native client ID for use in standalone, bare workflow, and custom clients.\n */\n iosClientId?: string;\n /**\n * Android native client ID for use in standalone, and bare workflow.\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 (Android, iOS) 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 isWebAuth = 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 }\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 clientId = useMemo(() => {\n const propertyName = Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n } as const);\n const clientId = config[propertyName] ?? config.clientId;\n invariantClientId(propertyName, clientId, 'Google');\n return clientId;\n }, [config.iosClientId, config.androidClientId, config.webClientId, config.clientId]);\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';\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]);\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 ...redirectUriOptions,\n // native: `com.googleusercontent.apps.${guid}:/oauthredirect`,\n });\n }, [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 = config.language;\n }\n if (config.loginHint) {\n output.login_hint = config.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 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;AAGxC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,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;AAyCF,cAAc;AACd;;GAEG;AACH,MAAM,iBAAkB,SAAQ,WAAW;IACzC,KAAK,CAAU;IAEf,YAAY,EACV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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,IAAI,EAAE;gBAC9B,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,CAAC;oBACd,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;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,aAAa,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;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 type { ProviderAuthRequestConfig } from './Provider.types';\nimport { applyRequiredScopes, invariantClientId } from './ProviderUtils';\nimport { AuthRequest } from '../AuthRequest';\nimport type { AuthRequestConfig, AuthRequestPromptOptions } from '../AuthRequest.types';\nimport { Prompt, ResponseType } from '../AuthRequest.types';\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport { makeRedirectUri } from '../AuthSession';\nimport type { AuthSessionRedirectUriOptions, AuthSessionResult } from '../AuthSession.types';\nimport type { DiscoveryDocument } from '../Discovery';\nimport { generateHexStringAsync } from '../PKCE';\nimport { AccessTokenRequest } from '../TokenRequest';\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\n/**\n * @deprecated See [Google authentication](/guides/google-authentication/).\n */\nexport type GoogleAuthRequestConfig = 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 * Expo web client ID for use in the browser.\n */\n webClientId?: string;\n /**\n * iOS native client ID for use in production builds, existing React Native projects, and development builds.\n */\n iosClientId?: string;\n /**\n * Android native client ID for use in production builds and existing React Native projects.\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 (Android, iOS) 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 isWebAuth = 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 }\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 clientId = useMemo(() => {\n const propertyName = Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n } as const);\n const clientId = config[propertyName] ?? config.clientId;\n invariantClientId(propertyName, clientId, 'Google');\n return clientId;\n }, [config.iosClientId, config.androidClientId, config.webClientId, config.clientId]);\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';\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]);\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 ...redirectUriOptions,\n // native: `com.googleusercontent.apps.${guid}:/oauthredirect`,\n });\n }, [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 = config.language;\n }\n if (config.loginHint) {\n output.login_hint = config.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 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": "57.0.0",
3
+ "version": "57.0.1",
4
4
  "description": "Expo module for browser-based authentication",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -26,9 +26,9 @@
26
26
  "homepage": "https://docs.expo.dev/versions/latest/sdk/auth-session",
27
27
  "dependencies": {
28
28
  "expo-application": "~57.0.0",
29
- "expo-constants": "~57.0.0",
29
+ "expo-constants": "~57.0.2",
30
30
  "expo-crypto": "~57.0.0",
31
- "expo-linking": "~57.0.0",
31
+ "expo-linking": "~57.0.1",
32
32
  "expo-web-browser": "~57.0.0",
33
33
  "invariant": "^2.2.4"
34
34
  },
@@ -44,7 +44,7 @@
44
44
  "jest": {
45
45
  "preset": "expo-module-scripts"
46
46
  },
47
- "gitHead": "e3eb896c5fdcd89e0cded98ff4e35c9db12cc9c0",
47
+ "gitHead": "ab82681fbcef61d5283c1938290ba5cfe42e9cfd",
48
48
  "scripts": {
49
49
  "build": "expo-module build",
50
50
  "clean": "expo-module clean",
@@ -23,7 +23,7 @@ export const getDefaultReturnUrl = sessionUrlProvider.getDefaultReturnUrl;
23
23
  // @needsAudit @docsMissing
24
24
  /**
25
25
  * 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.
26
- * > **Note** This method will throw an exception if you're using the bare workflow on native.
26
+ * > **Note** This method will throw an exception in an existing React Native project on native.
27
27
  *
28
28
  * @param path
29
29
  * @return
@@ -45,10 +45,10 @@ export function getRedirectUrl(path?: string): string {
45
45
  // @needsAudit
46
46
  /**
47
47
  * Create a redirect url for the current platform and environment. You need to manually define the redirect that will be used in
48
- * a bare workflow React Native app, or an Expo standalone app, this is because it cannot be inferred automatically.
48
+ * an existing React Native project or a production build, because it cannot be inferred automatically.
49
49
  * - **Web:** Generates a path based on the current `window.location`. For production web apps, you should hard code the URL as well.
50
- * - **Managed workflow:** Uses the `scheme` property of your app config.
51
- * - **Bare workflow:** Will fallback to using the `native` option for bare workflow React Native apps.
50
+ * - **CNG projects:** Uses the `scheme` property of your app config.
51
+ * - **Existing React Native apps:** Falls back to using the `native` option.
52
52
  *
53
53
  * @param options Additional options for configuring the path.
54
54
  * @return The `redirectUri` to use in an authentication request.
@@ -74,8 +74,8 @@ export type AuthSessionRedirectUriOptions = {
74
74
  */
75
75
  preferLocalhost?: boolean;
76
76
  /**
77
- * Manual scheme to use in Bare and Standalone native app contexts. Takes precedence over all other properties.
78
- * You must define the URI scheme that will be used in a custom built native application or standalone Expo application.
77
+ * Manual scheme to use in existing React Native projects and production builds. Takes precedence over all other properties.
78
+ * You must define the URI scheme that will be used in a custom-built native application or production build.
79
79
  * The value should conform to your native app's URI schemes.
80
80
  * You can see conformance with `npx uri-scheme list`.
81
81
  */
@@ -33,11 +33,11 @@ export type FacebookAuthRequestConfig = ProviderAuthRequestConfig & {
33
33
  */
34
34
  webClientId?: string;
35
35
  /**
36
- * iOS native client ID for use in development builds and bare workflow.
36
+ * iOS native client ID for use in development builds and existing React Native projects.
37
37
  */
38
38
  iosClientId?: string;
39
39
  /**
40
- * Android native client ID for use in development builds and bare workflow.
40
+ * Android native client ID for use in development builds and existing React Native projects.
41
41
  */
42
42
  androidClientId?: string;
43
43
  };
@@ -50,11 +50,11 @@ export type GoogleAuthRequestConfig = ProviderAuthRequestConfig & {
50
50
  */
51
51
  webClientId?: string;
52
52
  /**
53
- * iOS native client ID for use in standalone, bare workflow, and custom clients.
53
+ * iOS native client ID for use in production builds, existing React Native projects, and development builds.
54
54
  */
55
55
  iosClientId?: string;
56
56
  /**
57
- * Android native client ID for use in standalone, and bare workflow.
57
+ * Android native client ID for use in production builds and existing React Native projects.
58
58
  */
59
59
  androidClientId?: string;
60
60
  /**