1export type RedirectEvent = {
2  url: string;
3};
4
5// @needsAudit @docsMissing
6export type WebBrowserWindowFeatures = Record<string, number | boolean | string>;
7
8// @needsAudit
9export type WebBrowserOpenOptions = {
10  /**
11   * Color of the toolbar. Supports React Native [color formats](https://reactnative.dev/docs/colors).
12   */
13  toolbarColor?: string;
14  /**
15   * Package name of a browser to be used to handle Custom Tabs. List of
16   * available packages is to be queried by [`getCustomTabsSupportingBrowsers`](#webbrowsergetcustomtabssupportingbrowsersasync) method.
17   * @platform android
18   */
19  browserPackage?: string;
20  /**
21   * A boolean determining whether the toolbar should be hiding when a user scrolls the website.
22   */
23  enableBarCollapsing?: boolean;
24  /**
25   * Color of the secondary toolbar. Supports React Native [color formats](https://reactnative.dev/docs/colors).
26   * @platform android
27   */
28  secondaryToolbarColor?: string;
29  /**
30   * A boolean determining whether the browser should show the title of website on the toolbar.
31   * @platform android
32   */
33  showTitle?: boolean;
34  /**
35   * A boolean determining whether a default share item should be added to the menu.
36   * @platform android
37   */
38  enableDefaultShareMenuItem?: boolean;
39  /**
40   * A boolean determining whether browsed website should be shown as separate
41   * entry in Android recents/multitasking view. Requires `createTask` to be `true` (default).
42   * @default false
43   * @platform android
44   */
45  showInRecents?: boolean;
46  /**
47   * A boolean determining whether the browser should open in a new task or in
48   * the same task as your app.
49   * @default true
50   * @platform android
51   */
52  createTask?: boolean;
53  /**
54   * Tint color for controls in SKSafariViewController. Supports React Native [color formats](https://reactnative.dev/docs/colors).
55   * @platform ios
56   */
57  controlsColor?: string;
58  /**
59   * The style of the dismiss button. Should be one of: `done`, `close`, or `cancel`.
60   * @platform ios
61   */
62  dismissButtonStyle?: 'done' | 'close' | 'cancel';
63  /**
64   * A boolean determining whether Safari should enter Reader mode, if it is available.
65   * @platform ios
66   */
67  readerMode?: boolean;
68  /**
69   * The [presentation style](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle)
70   * of the browser window.
71   * @default WebBrowser.WebBrowserPresentationStyle.OverFullScreen
72   * @platform ios
73   */
74  presentationStyle?: WebBrowserPresentationStyle;
75  /**
76   * Name to assign to the popup window.
77   * @platform web
78   */
79  windowName?: string;
80  /**
81   * Features to use with `window.open()`.
82   * @platform web
83   */
84  windowFeatures?: string | WebBrowserWindowFeatures;
85};
86
87/**
88 * If there is no native AuthSession implementation available (which is the case on Android) the params inherited from
89 * [`WebBrowserOpenOptions`](#webbrowseropenoptions) will be used in the browser polyfill. Otherwise, the browser parameters will be ignored.
90 */
91export type AuthSessionOpenOptions = WebBrowserOpenOptions & {
92  /**
93   * Determines whether the session should ask the browser for a private authentication session.
94   * Set this to `true` to request that the browser doesn’t share cookies or other browsing data between the authentication session and the user’s normal browser session.
95   * Whether the request is honored depends on the user’s default web browser.
96   *
97   * @default false
98   * @platform ios 13+
99   */
100  preferEphemeralSession?: boolean;
101};
102
103export type WebBrowserAuthSessionResult = WebBrowserRedirectResult | WebBrowserResult;
104
105// @needsAudit
106export type WebBrowserCustomTabsResults = {
107  /**
108   * Default package chosen by user, `null` if there is no such packages. Also `null` usually means,
109   * that user will be prompted to choose from available packages.
110   */
111  defaultBrowserPackage?: string;
112  /**
113   * Package preferred by `CustomTabsClient` to be used to handle Custom Tabs. It favors browser
114   * chosen by user as default, as long as it is present on both `browserPackages` and
115   * `servicePackages` lists. Only such browsers are considered as fully supporting Custom Tabs.
116   * It might be `null` when there is no such browser installed or when default browser is not in
117   * `servicePackages` list.
118   */
119  preferredBrowserPackage?: string;
120  /**
121   * All packages recognized by `PackageManager` as capable of handling Custom Tabs. Empty array
122   * means there is no supporting browsers on device.
123   */
124  browserPackages: string[];
125  /**
126   * All packages recognized by `PackageManager` as capable of handling Custom Tabs Service.
127   * This service is used by [`warmUpAsync`](#webbrowserwarmupasyncbrowserpackage), [`mayInitWithUrlAsync`](#webbrowsermayinitwithurlasyncurl-browserpackage)
128   * and [`coolDownAsync`](#webbrowsercooldownasyncbrowserpackage).
129   */
130  servicePackages: string[];
131};
132
133// @needsAudit @docsMissing
134export enum WebBrowserResultType {
135  /**
136   * @platform ios
137   */
138  CANCEL = 'cancel',
139  /**
140   * @platform ios
141   */
142  DISMISS = 'dismiss',
143  /**
144   * @platform android
145   */
146  OPENED = 'opened',
147  LOCKED = 'locked',
148}
149
150// @needsAudit
151/**
152 * A browser presentation style. Its values are directly mapped to the [`UIModalPresentationStyle`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle).
153 *
154 * @platform ios
155 */
156export enum WebBrowserPresentationStyle {
157  /**
158   * A presentation style in which the presented browser covers the screen.
159   */
160  FULL_SCREEN = 'fullScreen',
161  /**
162   * A presentation style that partially covers the underlying content.
163   */
164  PAGE_SHEET = 'pageSheet',
165  /**
166   * A presentation style that displays the browser centered in the screen.
167   */
168  FORM_SHEET = 'formSheet',
169  /**
170   * A presentation style where the browser is displayed over the app's content.
171   */
172  CURRENT_CONTEXT = 'currentContext',
173  /**
174   * A presentation style in which the browser view covers the screen.
175   */
176  OVER_FULL_SCREEN = 'overFullScreen',
177  /**
178   * A presentation style where the browser is displayed over the app's content.
179   */
180  OVER_CURRENT_CONTEXT = 'overCurrentContext',
181  /**
182   * A presentation style where the browser is displayed in a popover view.
183   */
184  POPOVER = 'popover',
185  /**
186   * The default presentation style chosen by the system.
187   * On older iOS versions, falls back to `WebBrowserPresentationStyle.FullScreen`.
188   *
189   * @platform ios 13+
190   */
191  AUTOMATIC = 'automatic',
192}
193
194// @needsAudit
195export type WebBrowserResult = {
196  /**
197   * Type of the result.
198   */
199  type: WebBrowserResultType;
200};
201
202// @needsAudit @docsMissing
203export type WebBrowserRedirectResult = {
204  /**
205   * Type of the result.
206   */
207  type: 'success';
208  url: string;
209};
210
211export type ServiceActionResult = {
212  servicePackage?: string;
213};
214
215export type WebBrowserMayInitWithUrlResult = ServiceActionResult;
216export type WebBrowserWarmUpResult = ServiceActionResult;
217export type WebBrowserCoolDownResult = ServiceActionResult;
218
219// @needsAudit
220export type WebBrowserCompleteAuthSessionOptions = {
221  /**
222   * Attempt to close the window without checking to see if the auth redirect matches the cached redirect URL.
223   */
224  skipRedirectCheck?: boolean;
225};
226
227// @needsAudit
228export type WebBrowserCompleteAuthSessionResult = {
229  /**
230   * Type of the result.
231   */
232  type: 'success' | 'failed';
233  /**
234   * Additional description or reasoning of the result.
235   */
236  message: string;
237};
238