1import { AuthError } from './Errors'; 2import { TokenResponse } from './TokenRequest'; 3 4// @needsAudit 5export type AuthSessionOptions = { 6 /** 7 * The URL that points to the sign in page that you would like to open the user to. 8 */ 9 authUrl: string; 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. 14 * Hence, this method will throw an exception, if you don't provide `returnUrl`. 15 */ 16 returnUrl?: string; 17 /** 18 * A boolean determining whether browsed website should be shown as separate entry in Android recents/multitasking view. 19 * @default false 20 * @platform android 21 */ 22 showInRecents?: boolean; 23}; 24 25// @needsAudit 26/** 27 * Object returned after an auth request has completed. 28 * - If the user cancelled the authentication session by closing the browser, the result is `{ type: 'cancel' }`. 29 * - If the authentication is dismissed manually with `AuthSession.dismiss()`, the result is `{ type: 'dismiss' }`. 30 * - If the authentication flow is successful, the result is `{ type: 'success', params: Object, event: Object }`. 31 * - If the authentication flow is returns an error, the result is `{ type: 'error', params: Object, error: string, event: Object }`. 32 * - If you call `AuthSession.startAsync()` more than once before the first call has returned, the result is `{ type: 'locked' }`, 33 * because only one `AuthSession` can be in progress at any time. 34 */ 35export type AuthSessionResult = 36 | { 37 /** 38 * How the auth completed. 39 */ 40 type: 'cancel' | 'dismiss' | 'locked'; 41 } 42 | { 43 /** 44 * How the auth completed. 45 */ 46 type: 'error' | 'success'; 47 /** 48 * @deprecated Legacy error code query param, use `error` instead. 49 */ 50 errorCode: string | null; 51 /** 52 * Possible error if the auth failed with type `error`. 53 */ 54 error?: AuthError | null; 55 /** 56 * Query params from the `url` as an object. 57 */ 58 params: Record<string, string>; 59 /** 60 * Returned when the auth finishes with an `access_token` property. 61 */ 62 authentication: TokenResponse | null; 63 /** 64 * Auth URL that was opened 65 */ 66 url: string; 67 }; 68 69// @needsAudit 70/** 71 * Options passed to `makeRedirectUriAsync`. 72 */ 73export type AuthSessionRedirectUriOptions = { 74 /** 75 * Optional path to append to a URI. This will not be added to `native`. 76 */ 77 path?: string; 78 /** 79 * URI protocol `<scheme>://` that must be built into your native app. 80 * Passed to `Linking.createURL()` when `useProxy` is `false`. 81 */ 82 scheme?: string; 83 /** 84 * Optional native scheme to use when proxy is disabled. 85 * URI protocol `<scheme>://` that must be built into your native app. 86 * Passed to `Linking.createURL()` when `useProxy` is `false`. 87 */ 88 queryParams?: Record<string, string | undefined>; 89 /** 90 * Should the URI be triple slashed `scheme:///path` or double slashed `scheme://path`. 91 * Defaults to `false`. 92 * Passed to `Linking.createURL()` when `useProxy` is `false`. 93 */ 94 isTripleSlashed?: boolean; 95 /** 96 * Should use the \`auth.expo.io\` proxy. 97 * This is useful for testing managed native apps that require a custom URI scheme. 98 * 99 * @default false 100 */ 101 useProxy?: boolean; 102 /** 103 * Attempt to convert the Expo server IP address to localhost. 104 * This is useful for testing when your IP changes often, this will only work for iOS simulator. 105 * 106 * @default false 107 */ 108 preferLocalhost?: boolean; 109 /** 110 * Manual scheme to use in Bare and Standalone native app contexts. Takes precedence over all other properties. 111 * You must define the URI scheme that will be used in a custom built native application or standalone Expo application. 112 * The value should conform to your native app's URI schemes. 113 * You can see conformance with `npx uri-scheme list`. 114 */ 115 native?: string; 116}; 117