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