expo-web-browser 10.0.0 → 10.1.0
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 +8 -0
- package/README.md +1 -1
- package/android/build.gradle +2 -2
- package/build/WebBrowser.d.ts +21 -13
- package/build/WebBrowser.js +21 -13
- package/build/WebBrowser.js.map +1 -1
- package/build/WebBrowser.types.d.ts +27 -16
- package/build/WebBrowser.types.js +3 -3
- package/build/WebBrowser.types.js.map +1 -1
- package/package.json +6 -4
- package/src/WebBrowser.ts +21 -13
- package/src/WebBrowser.types.ts +27 -16
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 10.1.0 — 2021-12-03
|
|
14
|
+
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
16
|
+
|
|
17
|
+
## 10.0.1 — 2021-10-01
|
|
18
|
+
|
|
19
|
+
_This version does not introduce any user-facing changes._
|
|
20
|
+
|
|
13
21
|
## 10.0.0 — 2021-09-28
|
|
14
22
|
|
|
15
23
|
### 🛠 Breaking changes
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-
|
|
|
13
13
|
|
|
14
14
|
# Installation in bare React Native projects
|
|
15
15
|
|
|
16
|
-
For bare React Native projects, you must ensure that you have [installed and configured the `
|
|
16
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
17
17
|
|
|
18
18
|
### Add the package to your npm dependencies
|
|
19
19
|
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '10.
|
|
6
|
+
version = '10.1.0'
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
buildscript {
|
|
@@ -58,7 +58,7 @@ android {
|
|
|
58
58
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
59
59
|
targetSdkVersion safeExtGet("targetSdkVersion", 30)
|
|
60
60
|
versionCode 18
|
|
61
|
-
versionName '10.
|
|
61
|
+
versionName '10.1.0'
|
|
62
62
|
}
|
|
63
63
|
lintOptions {
|
|
64
64
|
abortOnError false
|
package/build/WebBrowser.d.ts
CHANGED
|
@@ -1,43 +1,48 @@
|
|
|
1
1
|
import { WebBrowserAuthSessionResult, WebBrowserCompleteAuthSessionOptions, WebBrowserCompleteAuthSessionResult, WebBrowserCoolDownResult, WebBrowserCustomTabsResults, WebBrowserMayInitWithUrlResult, WebBrowserOpenOptions, WebBrowserRedirectResult, WebBrowserResult, WebBrowserResultType, WebBrowserWarmUpResult, WebBrowserWindowFeatures } from './WebBrowser.types';
|
|
2
2
|
export { WebBrowserAuthSessionResult, WebBrowserCompleteAuthSessionOptions, WebBrowserCompleteAuthSessionResult, WebBrowserCoolDownResult, WebBrowserCustomTabsResults, WebBrowserMayInitWithUrlResult, WebBrowserOpenOptions, WebBrowserRedirectResult, WebBrowserResult, WebBrowserResultType, WebBrowserWarmUpResult, WebBrowserWindowFeatures, };
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Returns a list of applications package names supporting Custom Tabs, Custom Tabs
|
|
5
5
|
* service, user chosen and preferred one. This may not be fully reliable, since it uses
|
|
6
6
|
* `PackageManager.getResolvingActivities` under the hood. (For example, some browsers might not be
|
|
7
7
|
* present in browserPackages list once another browser is set to default.)
|
|
8
8
|
*
|
|
9
9
|
* @return The promise which fulfils with [`WebBrowserCustomTabsResults`](#webbrowsercustomtabsresults) object.
|
|
10
|
+
* @platform android
|
|
10
11
|
*/
|
|
11
12
|
export declare function getCustomTabsSupportingBrowsersAsync(): Promise<WebBrowserCustomTabsResults>;
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
+
* This method calls `warmUp` method on [CustomTabsClient](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#warmup(long))
|
|
14
15
|
* for specified package.
|
|
15
16
|
*
|
|
16
|
-
* @param browserPackage
|
|
17
|
+
* @param browserPackage Package of browser to be warmed up. If not set, preferred browser will be warmed.
|
|
17
18
|
*
|
|
18
|
-
* @return A promise which fulfils with `
|
|
19
|
+
* @return A promise which fulfils with `WebBrowserWarmUpResult` object.
|
|
20
|
+
* @platform android
|
|
19
21
|
*/
|
|
20
22
|
export declare function warmUpAsync(browserPackage?: string): Promise<WebBrowserWarmUpResult>;
|
|
21
23
|
/**
|
|
22
|
-
*
|
|
24
|
+
* This method initiates (if needed) [CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession.html#maylaunchurl)
|
|
23
25
|
* and calls its `mayLaunchUrl` method for browser specified by the package.
|
|
24
26
|
*
|
|
25
27
|
* @param url The url of page that is likely to be loaded first when opening browser.
|
|
26
|
-
* @param browserPackage
|
|
28
|
+
* @param browserPackage Package of browser to be informed. If not set, preferred
|
|
29
|
+
* browser will be used.
|
|
27
30
|
*
|
|
28
|
-
* @return A promise which fulfils with `
|
|
31
|
+
* @return A promise which fulfils with `WebBrowserMayInitWithUrlResult` object.
|
|
32
|
+
* @platform android
|
|
29
33
|
*/
|
|
30
34
|
export declare function mayInitWithUrlAsync(url: string, browserPackage?: string): Promise<WebBrowserMayInitWithUrlResult>;
|
|
31
35
|
/**
|
|
32
|
-
*
|
|
36
|
+
* This methods removes all bindings to services created by [`warmUpAsync`](#webbrowserwarmupasyncbrowserpackage)
|
|
33
37
|
* or [`mayInitWithUrlAsync`](#webbrowsermayinitwithurlasyncurl-browserpackage). You should call
|
|
34
38
|
* this method once you don't need them to avoid potential memory leaks. However, those binding
|
|
35
39
|
* would be cleared once your application is destroyed, which might be sufficient in most cases.
|
|
36
40
|
*
|
|
37
|
-
* @param browserPackage
|
|
41
|
+
* @param browserPackage Package of browser to be cooled. If not set, preferred browser will be used.
|
|
38
42
|
*
|
|
39
|
-
* @return The promise which fulfils with `
|
|
43
|
+
* @return The promise which fulfils with ` WebBrowserCoolDownResult` when cooling is performed, or
|
|
40
44
|
* an empty object when there was no connection to be dismissed.
|
|
45
|
+
* @platform android
|
|
41
46
|
*/
|
|
42
47
|
export declare function coolDownAsync(browserPackage?: string): Promise<WebBrowserCoolDownResult>;
|
|
43
48
|
/**
|
|
@@ -57,9 +62,10 @@ export declare function coolDownAsync(browserPackage?: string): Promise<WebBrows
|
|
|
57
62
|
*/
|
|
58
63
|
export declare function openBrowserAsync(url: string, browserParams?: WebBrowserOpenOptions): Promise<WebBrowserResult>;
|
|
59
64
|
/**
|
|
60
|
-
*
|
|
65
|
+
* Dismisses the presented web browser.
|
|
61
66
|
*
|
|
62
|
-
* @return The
|
|
67
|
+
* @return The `void` on successful attempt, or throws error, if dismiss functionality is not avaiable.
|
|
68
|
+
* @platform ios
|
|
63
69
|
*/
|
|
64
70
|
export declare function dismissBrowser(): void;
|
|
65
71
|
/**
|
|
@@ -110,7 +116,7 @@ export declare function dismissBrowser(): void;
|
|
|
110
116
|
export declare function openAuthSessionAsync(url: string, redirectUrl: string, browserParams?: WebBrowserOpenOptions): Promise<WebBrowserAuthSessionResult>;
|
|
111
117
|
export declare function dismissAuthSession(): void;
|
|
112
118
|
/**
|
|
113
|
-
*
|
|
119
|
+
* Possibly completes an authentication session on web in a window popup. The method
|
|
114
120
|
* should be invoked on the page that the window redirects to.
|
|
115
121
|
*
|
|
116
122
|
* @param options
|
|
@@ -134,5 +140,7 @@ export declare function dismissAuthSession(): void;
|
|
|
134
140
|
*
|
|
135
141
|
* If the error `ERR_WEB_BROWSER_REDIRECT` was thrown, it may mean that the parent window was
|
|
136
142
|
* reloaded before the auth was completed. In this case you'll need to close the child window manually.
|
|
143
|
+
*
|
|
144
|
+
* @platform web
|
|
137
145
|
*/
|
|
138
146
|
export declare function maybeCompleteAuthSession(options?: WebBrowserCompleteAuthSessionOptions): WebBrowserCompleteAuthSessionResult;
|
package/build/WebBrowser.js
CHANGED
|
@@ -11,12 +11,13 @@ const emptyCustomTabsPackages = {
|
|
|
11
11
|
};
|
|
12
12
|
// @needsAudit
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Returns a list of applications package names supporting Custom Tabs, Custom Tabs
|
|
15
15
|
* service, user chosen and preferred one. This may not be fully reliable, since it uses
|
|
16
16
|
* `PackageManager.getResolvingActivities` under the hood. (For example, some browsers might not be
|
|
17
17
|
* present in browserPackages list once another browser is set to default.)
|
|
18
18
|
*
|
|
19
19
|
* @return The promise which fulfils with [`WebBrowserCustomTabsResults`](#webbrowsercustomtabsresults) object.
|
|
20
|
+
* @platform android
|
|
20
21
|
*/
|
|
21
22
|
export async function getCustomTabsSupportingBrowsersAsync() {
|
|
22
23
|
if (!ExponentWebBrowser.getCustomTabsSupportingBrowsersAsync) {
|
|
@@ -31,12 +32,13 @@ export async function getCustomTabsSupportingBrowsersAsync() {
|
|
|
31
32
|
}
|
|
32
33
|
// @needsAudit
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
+
* This method calls `warmUp` method on [CustomTabsClient](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#warmup(long))
|
|
35
36
|
* for specified package.
|
|
36
37
|
*
|
|
37
|
-
* @param browserPackage
|
|
38
|
+
* @param browserPackage Package of browser to be warmed up. If not set, preferred browser will be warmed.
|
|
38
39
|
*
|
|
39
|
-
* @return A promise which fulfils with `
|
|
40
|
+
* @return A promise which fulfils with `WebBrowserWarmUpResult` object.
|
|
41
|
+
* @platform android
|
|
40
42
|
*/
|
|
41
43
|
export async function warmUpAsync(browserPackage) {
|
|
42
44
|
if (!ExponentWebBrowser.warmUpAsync) {
|
|
@@ -51,13 +53,15 @@ export async function warmUpAsync(browserPackage) {
|
|
|
51
53
|
}
|
|
52
54
|
// @needsAudit
|
|
53
55
|
/**
|
|
54
|
-
*
|
|
56
|
+
* This method initiates (if needed) [CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession.html#maylaunchurl)
|
|
55
57
|
* and calls its `mayLaunchUrl` method for browser specified by the package.
|
|
56
58
|
*
|
|
57
59
|
* @param url The url of page that is likely to be loaded first when opening browser.
|
|
58
|
-
* @param browserPackage
|
|
60
|
+
* @param browserPackage Package of browser to be informed. If not set, preferred
|
|
61
|
+
* browser will be used.
|
|
59
62
|
*
|
|
60
|
-
* @return A promise which fulfils with `
|
|
63
|
+
* @return A promise which fulfils with `WebBrowserMayInitWithUrlResult` object.
|
|
64
|
+
* @platform android
|
|
61
65
|
*/
|
|
62
66
|
export async function mayInitWithUrlAsync(url, browserPackage) {
|
|
63
67
|
if (!ExponentWebBrowser.mayInitWithUrlAsync) {
|
|
@@ -72,15 +76,16 @@ export async function mayInitWithUrlAsync(url, browserPackage) {
|
|
|
72
76
|
}
|
|
73
77
|
// @needsAudit
|
|
74
78
|
/**
|
|
75
|
-
*
|
|
79
|
+
* This methods removes all bindings to services created by [`warmUpAsync`](#webbrowserwarmupasyncbrowserpackage)
|
|
76
80
|
* or [`mayInitWithUrlAsync`](#webbrowsermayinitwithurlasyncurl-browserpackage). You should call
|
|
77
81
|
* this method once you don't need them to avoid potential memory leaks. However, those binding
|
|
78
82
|
* would be cleared once your application is destroyed, which might be sufficient in most cases.
|
|
79
83
|
*
|
|
80
|
-
* @param browserPackage
|
|
84
|
+
* @param browserPackage Package of browser to be cooled. If not set, preferred browser will be used.
|
|
81
85
|
*
|
|
82
|
-
* @return The promise which fulfils with `
|
|
86
|
+
* @return The promise which fulfils with ` WebBrowserCoolDownResult` when cooling is performed, or
|
|
83
87
|
* an empty object when there was no connection to be dismissed.
|
|
88
|
+
* @platform android
|
|
84
89
|
*/
|
|
85
90
|
export async function coolDownAsync(browserPackage) {
|
|
86
91
|
if (!ExponentWebBrowser.coolDownAsync) {
|
|
@@ -135,9 +140,10 @@ export async function openBrowserAsync(url, browserParams = {}) {
|
|
|
135
140
|
}
|
|
136
141
|
// @needsAudit
|
|
137
142
|
/**
|
|
138
|
-
*
|
|
143
|
+
* Dismisses the presented web browser.
|
|
139
144
|
*
|
|
140
|
-
* @return The
|
|
145
|
+
* @return The `void` on successful attempt, or throws error, if dismiss functionality is not avaiable.
|
|
146
|
+
* @platform ios
|
|
141
147
|
*/
|
|
142
148
|
export function dismissBrowser() {
|
|
143
149
|
if (!ExponentWebBrowser.dismissBrowser) {
|
|
@@ -222,7 +228,7 @@ export function dismissAuthSession() {
|
|
|
222
228
|
}
|
|
223
229
|
// @needsAudit
|
|
224
230
|
/**
|
|
225
|
-
*
|
|
231
|
+
* Possibly completes an authentication session on web in a window popup. The method
|
|
226
232
|
* should be invoked on the page that the window redirects to.
|
|
227
233
|
*
|
|
228
234
|
* @param options
|
|
@@ -246,6 +252,8 @@ export function dismissAuthSession() {
|
|
|
246
252
|
*
|
|
247
253
|
* If the error `ERR_WEB_BROWSER_REDIRECT` was thrown, it may mean that the parent window was
|
|
248
254
|
* reloaded before the auth was completed. In this case you'll need to close the child window manually.
|
|
255
|
+
*
|
|
256
|
+
* @platform web
|
|
249
257
|
*/
|
|
250
258
|
export function maybeCompleteAuthSession(options = {}) {
|
|
251
259
|
if (ExponentWebBrowser.maybeCompleteAuthSession) {
|
package/build/WebBrowser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebBrowser.js","sourceRoot":"","sources":["../src/WebBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAkB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,kBAAkB,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAWL,oBAAoB,GAGrB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAUL,oBAAoB,GAGrB,CAAC;AAEF,MAAM,uBAAuB,GAAgC;IAC3D,qBAAqB,EAAE,SAAS;IAChC,uBAAuB,EAAE,SAAS;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ACrC;QAED,uBAAuB,EAAE,CAAC;KAC3B;AACH,CAAC;AAED,SAAS,uBAAuB;IAC9B,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;KACH;IAED,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACrD,gBAAgB,GAAG,IAAI,CAAC;AAC1B,CAAC;AAED,SAAS,qBAAqB,CAAC,SAAiB;IAC9C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,gBAAgB,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC1C,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;gBACnC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;aAC9C;QACH,CAAC,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\nimport { AppState, AppStateStatus, Linking, Platform } from 'react-native';\n\nimport ExponentWebBrowser from './ExpoWebBrowser';\nimport {\n RedirectEvent,\n WebBrowserAuthSessionResult,\n WebBrowserCompleteAuthSessionOptions,\n WebBrowserCompleteAuthSessionResult,\n WebBrowserCoolDownResult,\n WebBrowserCustomTabsResults,\n WebBrowserMayInitWithUrlResult,\n WebBrowserOpenOptions,\n WebBrowserRedirectResult,\n WebBrowserResult,\n WebBrowserResultType,\n WebBrowserWarmUpResult,\n WebBrowserWindowFeatures,\n} from './WebBrowser.types';\n\nexport {\n WebBrowserAuthSessionResult,\n WebBrowserCompleteAuthSessionOptions,\n WebBrowserCompleteAuthSessionResult,\n WebBrowserCoolDownResult,\n WebBrowserCustomTabsResults,\n WebBrowserMayInitWithUrlResult,\n WebBrowserOpenOptions,\n WebBrowserRedirectResult,\n WebBrowserResult,\n WebBrowserResultType,\n WebBrowserWarmUpResult,\n WebBrowserWindowFeatures,\n};\n\nconst emptyCustomTabsPackages: WebBrowserCustomTabsResults = {\n defaultBrowserPackage: undefined,\n preferredBrowserPackage: undefined,\n browserPackages: [],\n servicePackages: [],\n};\n\n// @needsAudit\n/**\n * _Android only_. Returns a list of applications package names supporting Custom Tabs, Custom Tabs\n * service, user chosen and preferred one. This may not be fully reliable, since it uses\n * `PackageManager.getResolvingActivities` under the hood. (For example, some browsers might not be\n * present in browserPackages list once another browser is set to default.)\n *\n * @return The promise which fulfils with [`WebBrowserCustomTabsResults`](#webbrowsercustomtabsresults) object.\n */\nexport async function getCustomTabsSupportingBrowsersAsync(): Promise<WebBrowserCustomTabsResults> {\n if (!ExponentWebBrowser.getCustomTabsSupportingBrowsersAsync) {\n throw new UnavailabilityError('WebBrowser', 'getCustomTabsSupportingBrowsersAsync');\n }\n if (Platform.OS !== 'android') {\n return emptyCustomTabsPackages;\n } else {\n return await ExponentWebBrowser.getCustomTabsSupportingBrowsersAsync();\n }\n}\n\n// @needsAudit\n/**\n * _Android only_. This method calls `warmUp` method on [CustomTabsClient](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#warmup(long))\n * for specified package.\n *\n * @param browserPackage _Optional_ - Package of browser to be warmed up. If not set, preferred browser will be warmed.\n *\n * @return A promise which fulfils with `{ package: string }` object.\n */\nexport async function warmUpAsync(browserPackage?: string): Promise<WebBrowserWarmUpResult> {\n if (!ExponentWebBrowser.warmUpAsync) {\n throw new UnavailabilityError('WebBrowser', 'warmUpAsync');\n }\n if (Platform.OS !== 'android') {\n return {};\n } else {\n return await ExponentWebBrowser.warmUpAsync(browserPackage);\n }\n}\n\n// @needsAudit\n/**\n * _Android only_. This method initiates (if needed) [CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession.html#maylaunchurl)\n * and calls its `mayLaunchUrl` method for browser specified by the package.\n *\n * @param url The url of page that is likely to be loaded first when opening browser.\n * @param browserPackage _Optional_ - Package of browser to be informed. If not set, preferred browser will be used.\n *\n * @return A promise which fulfils with `{ package: string }` object.\n */\nexport async function mayInitWithUrlAsync(\n url: string,\n browserPackage?: string\n): Promise<WebBrowserMayInitWithUrlResult> {\n if (!ExponentWebBrowser.mayInitWithUrlAsync) {\n throw new UnavailabilityError('WebBrowser', 'mayInitWithUrlAsync');\n }\n if (Platform.OS !== 'android') {\n return {};\n } else {\n return await ExponentWebBrowser.mayInitWithUrlAsync(url, browserPackage);\n }\n}\n\n// @needsAudit\n/**\n * _Android only_. This methods removes all bindings to services created by [`warmUpAsync`](#webbrowserwarmupasyncbrowserpackage)\n * or [`mayInitWithUrlAsync`](#webbrowsermayinitwithurlasyncurl-browserpackage). You should call\n * this method once you don't need them to avoid potential memory leaks. However, those binding\n * would be cleared once your application is destroyed, which might be sufficient in most cases.\n *\n * @param browserPackage _Optional_ - Package of browser to be cooled. If not set, preferred browser will be used.\n *\n * @return The promise which fulfils with `{ package: string }` when cooling is performed, or\n * an empty object when there was no connection to be dismissed.\n */\nexport async function coolDownAsync(browserPackage?: string): Promise<WebBrowserCoolDownResult> {\n if (!ExponentWebBrowser.coolDownAsync) {\n throw new UnavailabilityError('WebBrowser', 'coolDownAsync');\n }\n if (Platform.OS !== 'android') {\n return {};\n } else {\n return await ExponentWebBrowser.coolDownAsync(browserPackage);\n }\n}\n\nlet browserLocked = false;\n\n// @needsAudit\n/**\n * Opens the url with Safari in a modal on iOS using [`SFSafariViewController`](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller),\n * and Chrome in a new [custom tab](https://developer.chrome.com/multidevice/android/customtabs)\n * on Android. On iOS, the modal Safari will not share cookies with the system Safari. If you need\n * this, use [`openAuthSessionAsync`](#webbrowseropenauthsessionasyncurl-redirecturl-browserparams).\n *\n * @param url The url to open in the web browser.\n * @param browserParams A dictionary of key-value pairs.\n *\n * @return The promise behaves differently based on the platform.\n * On Android promise resolves with `{type: 'opened'}` if we were able to open browser.\n * On iOS:\n * - If the user closed the web browser, the Promise resolves with `{ type: 'cancel' }`.\n * - If the browser is closed using [`dismissBrowser`](#webbrowserdismissbrowser), the Promise resolves with `{ type: 'dismiss' }`.\n */\nexport async function openBrowserAsync(\n url: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserResult> {\n if (!ExponentWebBrowser.openBrowserAsync) {\n throw new UnavailabilityError('WebBrowser', 'openBrowserAsync');\n }\n\n if (browserLocked) {\n // Prevent multiple sessions from running at the same time, WebBrowser doesn't\n // support it this makes the behavior predictable.\n if (__DEV__) {\n console.warn(\n 'Attempted to call WebBrowser.openBrowserAsync multiple times while already active. Only one WebBrowser controller can be active at any given time.'\n );\n }\n\n return { type: WebBrowserResultType.LOCKED };\n }\n browserLocked = true;\n\n let result: WebBrowserResult;\n try {\n result = await ExponentWebBrowser.openBrowserAsync(url, browserParams);\n } finally {\n // WebBrowser session complete, unset lock\n browserLocked = false;\n }\n\n return result;\n}\n\n// @needsAudit\n/**\n * _iOS only_. Dismisses the presented web browser.\n *\n * @return The promise which fulfils with `{ type: 'dismiss' }` object.\n */\nexport function dismissBrowser(): void {\n if (!ExponentWebBrowser.dismissBrowser) {\n throw new UnavailabilityError('WebBrowser', 'dismissBrowser');\n }\n ExponentWebBrowser.dismissBrowser();\n}\n\n// @needsAudit\n/**\n * # On iOS:\n * Opens the url with Safari in a modal using `SFAuthenticationSession` on iOS 11 and greater,\n * and falling back on a `SFSafariViewController`. The user will be asked whether to allow the app\n * to authenticate using the given url.\n *\n * # On Android:\n * This will be done using a \"custom Chrome tabs\" browser, [AppState](../react-native/appstate/),\n * and [Linking](./linking/) APIs.\n *\n * # On web:\n * > This API can only be used in a secure environment (`https`). You can use expo `start:web --https`\n * to test this. Otherwise, an error with code [`ERR_WEB_BROWSER_CRYPTO`](#errwebbrowsercrypto) will be thrown.\n * This will use the browser's [`window.open()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) API.\n * - _Desktop_: This will create a new web popup window in the browser that can be closed later using `WebBrowser.maybeCompleteAuthSession()`.\n * - _Mobile_: This will open a new tab in the browser which can be closed using `WebBrowser.maybeCompleteAuthSession()`.\n *\n * How this works on web:\n * - A crypto state will be created for verifying the redirect.\n * - This means you need to run with `expo start:web --https`\n * - The state will be added to the window's `localstorage`. This ensures that auth cannot complete\n * unless it's done from a page running with the same origin as it was started.\n * Ex: if `openAuthSessionAsync` is invoked on `https://localhost:19006`, then `maybeCompleteAuthSession`\n * must be invoked on a page hosted from the origin `https://localhost:19006`. Using a different\n * website, or even a different host like `https://128.0.0.*:19006` for example will not work.\n * - A timer will be started to check for every 1000 milliseconds (1 second) to detect if the window\n * has been closed by the user. If this happens then a promise will resolve with `{ type: 'dismiss' }`.\n *\n * > On mobile web, Chrome and Safari will block any call to [`window.open()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/open)\n * which takes too long to fire after a user interaction. This method must be invoked immediately\n * after a user interaction. If the event is blocked, an error with code [`ERR_WEB_BROWSER_BLOCKED`](#errwebbrowserblocked) will be thrown.\n *\n * @param url The url to open in the web browser. This should be a login page.\n * @param redirectUrl _Optional_ - The url to deep link back into your app. By default, this will be [`Constants.linkingUrl`](./constants/#expoconstantslinkinguri).\n * @param browserParams _Optional_ - An object with the same keys as [`WebBrowserOpenOptions`](#webbrowseropenoptions).\n * If there is no native AuthSession implementation available (which is the case on Android)\n * these params will be used in the browser polyfill. If there is a native AuthSession implementation,\n * these params will be ignored.\n *\n * @return\n * - If the user does not permit the application to authenticate with the given url, the Promise fulfills with `{ type: 'cancel' }` object.\n * - If the user closed the web browser, the Promise fulfills with `{ type: 'cancel' }` object.\n * - If the browser is closed using [`dismissBrowser`](#webbrowserdismissbrowser),\n * the Promise fulfills with `{ type: 'dismiss' }` object.\n */\nexport async function openAuthSessionAsync(\n url: string,\n redirectUrl: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserAuthSessionResult> {\n if (_authSessionIsNativelySupported()) {\n if (!ExponentWebBrowser.openAuthSessionAsync) {\n throw new UnavailabilityError('WebBrowser', 'openAuthSessionAsync');\n }\n if (Platform.OS === 'web') {\n return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl, browserParams);\n }\n return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl);\n } else {\n return _openAuthSessionPolyfillAsync(url, redirectUrl, browserParams);\n }\n}\n\n// @docsMissing\nexport function dismissAuthSession(): void {\n if (_authSessionIsNativelySupported()) {\n if (!ExponentWebBrowser.dismissAuthSession) {\n throw new UnavailabilityError('WebBrowser', 'dismissAuthSession');\n }\n ExponentWebBrowser.dismissAuthSession();\n } else {\n if (!ExponentWebBrowser.dismissBrowser) {\n throw new UnavailabilityError('WebBrowser', 'dismissAuthSession');\n }\n ExponentWebBrowser.dismissBrowser();\n }\n}\n\n// @needsAudit\n/**\n * _Web only_. Possibly completes an authentication session on web in a window popup. The method\n * should be invoked on the page that the window redirects to.\n *\n * @param options\n *\n * @return Returns an object with message about why the redirect failed or succeeded:\n *\n * If `type` is set to `failed`, the reason depends on the message:\n * - `Not supported on this platform`: If the platform doesn't support this method (iOS, Android).\n * - `Cannot use expo-web-browser in a non-browser environment`: If the code was executed in an SSR\n * or node environment.\n * - `No auth session is currently in progress`: (the cached state wasn't found in local storage).\n * This can happen if the window redirects to an origin (website) that is different to the initial\n * website origin. If this happens in development, it may be because the auth started on localhost\n * and finished on your computer port (Ex: `128.0.0.*`). This is controlled by the `redirectUrl`\n * and `returnUrl`.\n * - `Current URL \"<URL>\" and original redirect URL \"<URL>\" do not match`: This can occur when the\n * redirect URL doesn't match what was initial defined as the `returnUrl`. You can skip this test\n * in development by passing `{ skipRedirectCheck: true }` to the function.\n *\n * If `type` is set to `success`, the parent window will attempt to close the child window immediately.\n *\n * If the error `ERR_WEB_BROWSER_REDIRECT` was thrown, it may mean that the parent window was\n * reloaded before the auth was completed. In this case you'll need to close the child window manually.\n */\nexport function maybeCompleteAuthSession(\n options: WebBrowserCompleteAuthSessionOptions = {}\n): WebBrowserCompleteAuthSessionResult {\n if (ExponentWebBrowser.maybeCompleteAuthSession) {\n return ExponentWebBrowser.maybeCompleteAuthSession(options);\n }\n return { type: 'failed', message: 'Not supported on this platform' };\n}\n\n/* iOS <= 10 and Android polyfill for SFAuthenticationSession flow */\n\nfunction _authSessionIsNativelySupported(): boolean {\n if (Platform.OS === 'android') {\n return false;\n } else if (Platform.OS === 'web') {\n return true;\n }\n\n const versionNumber = parseInt(String(Platform.Version), 10);\n return versionNumber >= 11;\n}\n\nlet _redirectHandler: ((event: RedirectEvent) => void) | null = null;\n\n/*\n * openBrowserAsync on Android doesn't wait until closed, so we need to polyfill\n * it with AppState\n */\n\n// Store the `resolve` function from a Promise to fire when the AppState\n// returns to active\nlet _onWebBrowserCloseAndroid: null | (() => void) = null;\n\n// If the initial AppState.currentState is null, we assume that the first call to\n// AppState#change event is not actually triggered by a real change,\n// is triggered instead by the bridge capturing the current state\n// (https://reactnative.dev/docs/appstate#basic-usage)\nlet _isAppStateAvailable: boolean = AppState.currentState !== null;\nfunction _onAppStateChangeAndroid(state: AppStateStatus) {\n if (!_isAppStateAvailable) {\n _isAppStateAvailable = true;\n return;\n }\n\n if (state === 'active' && _onWebBrowserCloseAndroid) {\n _onWebBrowserCloseAndroid();\n }\n}\n\nasync function _openBrowserAndWaitAndroidAsync(\n startUrl: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserResult> {\n const appStateChangedToActive = new Promise<void>((resolve) => {\n _onWebBrowserCloseAndroid = resolve;\n AppState.addEventListener('change', _onAppStateChangeAndroid);\n });\n\n let result: WebBrowserResult = { type: WebBrowserResultType.CANCEL };\n let type: string | null = null;\n\n try {\n ({ type } = await openBrowserAsync(startUrl, browserParams));\n } catch (e) {\n AppState.removeEventListener('change', _onAppStateChangeAndroid);\n _onWebBrowserCloseAndroid = null;\n throw e;\n }\n\n if (type === 'opened') {\n await appStateChangedToActive;\n result = { type: WebBrowserResultType.DISMISS };\n }\n\n AppState.removeEventListener('change', _onAppStateChangeAndroid);\n _onWebBrowserCloseAndroid = null;\n return result;\n}\n\nasync function _openAuthSessionPolyfillAsync(\n startUrl: string,\n returnUrl: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserAuthSessionResult> {\n if (_redirectHandler) {\n throw new Error(\n `The WebBrowser's auth session is in an invalid state with a redirect handler set when it should not be`\n );\n }\n\n if (_onWebBrowserCloseAndroid) {\n throw new Error(`WebBrowser is already open, only one can be open at a time`);\n }\n\n try {\n if (Platform.OS === 'android') {\n return await Promise.race([\n _openBrowserAndWaitAndroidAsync(startUrl, browserParams),\n _waitForRedirectAsync(returnUrl),\n ]);\n } else {\n return await Promise.race([\n openBrowserAsync(startUrl, browserParams),\n _waitForRedirectAsync(returnUrl),\n ]);\n }\n } finally {\n // We can't dismiss the browser on Android, only call this when it's available.\n // Users on Android need to manually press the 'x' button in Chrome Custom Tabs, sadly.\n if (ExponentWebBrowser.dismissBrowser) {\n ExponentWebBrowser.dismissBrowser();\n }\n\n _stopWaitingForRedirect();\n }\n}\n\nfunction _stopWaitingForRedirect() {\n if (!_redirectHandler) {\n throw new Error(\n `The WebBrowser auth session is in an invalid state with no redirect handler when one should be set`\n );\n }\n\n Linking.removeEventListener('url', _redirectHandler);\n _redirectHandler = null;\n}\n\nfunction _waitForRedirectAsync(returnUrl: string): Promise<WebBrowserRedirectResult> {\n return new Promise((resolve) => {\n _redirectHandler = (event: RedirectEvent) => {\n if (event.url.startsWith(returnUrl)) {\n resolve({ url: event.url, type: 'success' });\n }\n };\n\n Linking.addEventListener('url', _redirectHandler);\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"WebBrowser.js","sourceRoot":"","sources":["../src/WebBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAkB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,kBAAkB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,CAAC,QAAQ,EAAE,aAAa,CAAC;gBACzC,qBAAqB,CAAC,SAAS,CAAC;aACjC,CAAC,CAAC;SACJ;KACF;YAAS;QACR,+EAA+E;QAC/E,uFAAuF;QACvF,IAAI,kBAAkB,CAAC,cAAc,EAAE;YACrC,kBAAkB,CAAC,cAAc,EAAE,CAAC;SACrC;QAED,uBAAuB,EAAE,CAAC;KAC3B;AACH,CAAC;AAED,SAAS,uBAAuB;IAC9B,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;KACH;IAED,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACrD,gBAAgB,GAAG,IAAI,CAAC;AAC1B,CAAC;AAED,SAAS,qBAAqB,CAAC,SAAiB;IAC9C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,gBAAgB,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC1C,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;gBACnC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;aAC9C;QACH,CAAC,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\nimport { AppState, AppStateStatus, Linking, Platform } from 'react-native';\n\nimport ExponentWebBrowser from './ExpoWebBrowser';\nimport {\n RedirectEvent,\n WebBrowserAuthSessionResult,\n WebBrowserCompleteAuthSessionOptions,\n WebBrowserCompleteAuthSessionResult,\n WebBrowserCoolDownResult,\n WebBrowserCustomTabsResults,\n WebBrowserMayInitWithUrlResult,\n WebBrowserOpenOptions,\n WebBrowserRedirectResult,\n WebBrowserResult,\n WebBrowserResultType,\n WebBrowserWarmUpResult,\n WebBrowserWindowFeatures,\n} from './WebBrowser.types';\n\nexport {\n WebBrowserAuthSessionResult,\n WebBrowserCompleteAuthSessionOptions,\n WebBrowserCompleteAuthSessionResult,\n WebBrowserCoolDownResult,\n WebBrowserCustomTabsResults,\n WebBrowserMayInitWithUrlResult,\n WebBrowserOpenOptions,\n WebBrowserRedirectResult,\n WebBrowserResult,\n WebBrowserResultType,\n WebBrowserWarmUpResult,\n WebBrowserWindowFeatures,\n};\n\nconst emptyCustomTabsPackages: WebBrowserCustomTabsResults = {\n defaultBrowserPackage: undefined,\n preferredBrowserPackage: undefined,\n browserPackages: [],\n servicePackages: [],\n};\n\n// @needsAudit\n/**\n * Returns a list of applications package names supporting Custom Tabs, Custom Tabs\n * service, user chosen and preferred one. This may not be fully reliable, since it uses\n * `PackageManager.getResolvingActivities` under the hood. (For example, some browsers might not be\n * present in browserPackages list once another browser is set to default.)\n *\n * @return The promise which fulfils with [`WebBrowserCustomTabsResults`](#webbrowsercustomtabsresults) object.\n * @platform android\n */\nexport async function getCustomTabsSupportingBrowsersAsync(): Promise<WebBrowserCustomTabsResults> {\n if (!ExponentWebBrowser.getCustomTabsSupportingBrowsersAsync) {\n throw new UnavailabilityError('WebBrowser', 'getCustomTabsSupportingBrowsersAsync');\n }\n if (Platform.OS !== 'android') {\n return emptyCustomTabsPackages;\n } else {\n return await ExponentWebBrowser.getCustomTabsSupportingBrowsersAsync();\n }\n}\n\n// @needsAudit\n/**\n * This method calls `warmUp` method on [CustomTabsClient](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#warmup(long))\n * for specified package.\n *\n * @param browserPackage Package of browser to be warmed up. If not set, preferred browser will be warmed.\n *\n * @return A promise which fulfils with `WebBrowserWarmUpResult` object.\n * @platform android\n */\nexport async function warmUpAsync(browserPackage?: string): Promise<WebBrowserWarmUpResult> {\n if (!ExponentWebBrowser.warmUpAsync) {\n throw new UnavailabilityError('WebBrowser', 'warmUpAsync');\n }\n if (Platform.OS !== 'android') {\n return {};\n } else {\n return await ExponentWebBrowser.warmUpAsync(browserPackage);\n }\n}\n\n// @needsAudit\n/**\n * This method initiates (if needed) [CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession.html#maylaunchurl)\n * and calls its `mayLaunchUrl` method for browser specified by the package.\n *\n * @param url The url of page that is likely to be loaded first when opening browser.\n * @param browserPackage Package of browser to be informed. If not set, preferred\n * browser will be used.\n *\n * @return A promise which fulfils with `WebBrowserMayInitWithUrlResult` object.\n * @platform android\n */\nexport async function mayInitWithUrlAsync(\n url: string,\n browserPackage?: string\n): Promise<WebBrowserMayInitWithUrlResult> {\n if (!ExponentWebBrowser.mayInitWithUrlAsync) {\n throw new UnavailabilityError('WebBrowser', 'mayInitWithUrlAsync');\n }\n if (Platform.OS !== 'android') {\n return {};\n } else {\n return await ExponentWebBrowser.mayInitWithUrlAsync(url, browserPackage);\n }\n}\n\n// @needsAudit\n/**\n * This methods removes all bindings to services created by [`warmUpAsync`](#webbrowserwarmupasyncbrowserpackage)\n * or [`mayInitWithUrlAsync`](#webbrowsermayinitwithurlasyncurl-browserpackage). You should call\n * this method once you don't need them to avoid potential memory leaks. However, those binding\n * would be cleared once your application is destroyed, which might be sufficient in most cases.\n *\n * @param browserPackage Package of browser to be cooled. If not set, preferred browser will be used.\n *\n * @return The promise which fulfils with ` WebBrowserCoolDownResult` when cooling is performed, or\n * an empty object when there was no connection to be dismissed.\n * @platform android\n */\nexport async function coolDownAsync(browserPackage?: string): Promise<WebBrowserCoolDownResult> {\n if (!ExponentWebBrowser.coolDownAsync) {\n throw new UnavailabilityError('WebBrowser', 'coolDownAsync');\n }\n if (Platform.OS !== 'android') {\n return {};\n } else {\n return await ExponentWebBrowser.coolDownAsync(browserPackage);\n }\n}\n\nlet browserLocked = false;\n\n// @needsAudit\n/**\n * Opens the url with Safari in a modal on iOS using [`SFSafariViewController`](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller),\n * and Chrome in a new [custom tab](https://developer.chrome.com/multidevice/android/customtabs)\n * on Android. On iOS, the modal Safari will not share cookies with the system Safari. If you need\n * this, use [`openAuthSessionAsync`](#webbrowseropenauthsessionasyncurl-redirecturl-browserparams).\n *\n * @param url The url to open in the web browser.\n * @param browserParams A dictionary of key-value pairs.\n *\n * @return The promise behaves differently based on the platform.\n * On Android promise resolves with `{type: 'opened'}` if we were able to open browser.\n * On iOS:\n * - If the user closed the web browser, the Promise resolves with `{ type: 'cancel' }`.\n * - If the browser is closed using [`dismissBrowser`](#webbrowserdismissbrowser), the Promise resolves with `{ type: 'dismiss' }`.\n */\nexport async function openBrowserAsync(\n url: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserResult> {\n if (!ExponentWebBrowser.openBrowserAsync) {\n throw new UnavailabilityError('WebBrowser', 'openBrowserAsync');\n }\n\n if (browserLocked) {\n // Prevent multiple sessions from running at the same time, WebBrowser doesn't\n // support it this makes the behavior predictable.\n if (__DEV__) {\n console.warn(\n 'Attempted to call WebBrowser.openBrowserAsync multiple times while already active. Only one WebBrowser controller can be active at any given time.'\n );\n }\n\n return { type: WebBrowserResultType.LOCKED };\n }\n browserLocked = true;\n\n let result: WebBrowserResult;\n try {\n result = await ExponentWebBrowser.openBrowserAsync(url, browserParams);\n } finally {\n // WebBrowser session complete, unset lock\n browserLocked = false;\n }\n\n return result;\n}\n\n// @needsAudit\n/**\n * Dismisses the presented web browser.\n *\n * @return The `void` on successful attempt, or throws error, if dismiss functionality is not avaiable.\n * @platform ios\n */\nexport function dismissBrowser(): void {\n if (!ExponentWebBrowser.dismissBrowser) {\n throw new UnavailabilityError('WebBrowser', 'dismissBrowser');\n }\n ExponentWebBrowser.dismissBrowser();\n}\n\n// @needsAudit\n/**\n * # On iOS:\n * Opens the url with Safari in a modal using `SFAuthenticationSession` on iOS 11 and greater,\n * and falling back on a `SFSafariViewController`. The user will be asked whether to allow the app\n * to authenticate using the given url.\n *\n * # On Android:\n * This will be done using a \"custom Chrome tabs\" browser, [AppState](../react-native/appstate/),\n * and [Linking](./linking/) APIs.\n *\n * # On web:\n * > This API can only be used in a secure environment (`https`). You can use expo `start:web --https`\n * to test this. Otherwise, an error with code [`ERR_WEB_BROWSER_CRYPTO`](#errwebbrowsercrypto) will be thrown.\n * This will use the browser's [`window.open()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) API.\n * - _Desktop_: This will create a new web popup window in the browser that can be closed later using `WebBrowser.maybeCompleteAuthSession()`.\n * - _Mobile_: This will open a new tab in the browser which can be closed using `WebBrowser.maybeCompleteAuthSession()`.\n *\n * How this works on web:\n * - A crypto state will be created for verifying the redirect.\n * - This means you need to run with `expo start:web --https`\n * - The state will be added to the window's `localstorage`. This ensures that auth cannot complete\n * unless it's done from a page running with the same origin as it was started.\n * Ex: if `openAuthSessionAsync` is invoked on `https://localhost:19006`, then `maybeCompleteAuthSession`\n * must be invoked on a page hosted from the origin `https://localhost:19006`. Using a different\n * website, or even a different host like `https://128.0.0.*:19006` for example will not work.\n * - A timer will be started to check for every 1000 milliseconds (1 second) to detect if the window\n * has been closed by the user. If this happens then a promise will resolve with `{ type: 'dismiss' }`.\n *\n * > On mobile web, Chrome and Safari will block any call to [`window.open()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/open)\n * which takes too long to fire after a user interaction. This method must be invoked immediately\n * after a user interaction. If the event is blocked, an error with code [`ERR_WEB_BROWSER_BLOCKED`](#errwebbrowserblocked) will be thrown.\n *\n * @param url The url to open in the web browser. This should be a login page.\n * @param redirectUrl _Optional_ - The url to deep link back into your app. By default, this will be [`Constants.linkingUrl`](./constants/#expoconstantslinkinguri).\n * @param browserParams _Optional_ - An object with the same keys as [`WebBrowserOpenOptions`](#webbrowseropenoptions).\n * If there is no native AuthSession implementation available (which is the case on Android)\n * these params will be used in the browser polyfill. If there is a native AuthSession implementation,\n * these params will be ignored.\n *\n * @return\n * - If the user does not permit the application to authenticate with the given url, the Promise fulfills with `{ type: 'cancel' }` object.\n * - If the user closed the web browser, the Promise fulfills with `{ type: 'cancel' }` object.\n * - If the browser is closed using [`dismissBrowser`](#webbrowserdismissbrowser),\n * the Promise fulfills with `{ type: 'dismiss' }` object.\n */\nexport async function openAuthSessionAsync(\n url: string,\n redirectUrl: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserAuthSessionResult> {\n if (_authSessionIsNativelySupported()) {\n if (!ExponentWebBrowser.openAuthSessionAsync) {\n throw new UnavailabilityError('WebBrowser', 'openAuthSessionAsync');\n }\n if (Platform.OS === 'web') {\n return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl, browserParams);\n }\n return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl);\n } else {\n return _openAuthSessionPolyfillAsync(url, redirectUrl, browserParams);\n }\n}\n\n// @docsMissing\nexport function dismissAuthSession(): void {\n if (_authSessionIsNativelySupported()) {\n if (!ExponentWebBrowser.dismissAuthSession) {\n throw new UnavailabilityError('WebBrowser', 'dismissAuthSession');\n }\n ExponentWebBrowser.dismissAuthSession();\n } else {\n if (!ExponentWebBrowser.dismissBrowser) {\n throw new UnavailabilityError('WebBrowser', 'dismissAuthSession');\n }\n ExponentWebBrowser.dismissBrowser();\n }\n}\n\n// @needsAudit\n/**\n * Possibly completes an authentication session on web in a window popup. The method\n * should be invoked on the page that the window redirects to.\n *\n * @param options\n *\n * @return Returns an object with message about why the redirect failed or succeeded:\n *\n * If `type` is set to `failed`, the reason depends on the message:\n * - `Not supported on this platform`: If the platform doesn't support this method (iOS, Android).\n * - `Cannot use expo-web-browser in a non-browser environment`: If the code was executed in an SSR\n * or node environment.\n * - `No auth session is currently in progress`: (the cached state wasn't found in local storage).\n * This can happen if the window redirects to an origin (website) that is different to the initial\n * website origin. If this happens in development, it may be because the auth started on localhost\n * and finished on your computer port (Ex: `128.0.0.*`). This is controlled by the `redirectUrl`\n * and `returnUrl`.\n * - `Current URL \"<URL>\" and original redirect URL \"<URL>\" do not match`: This can occur when the\n * redirect URL doesn't match what was initial defined as the `returnUrl`. You can skip this test\n * in development by passing `{ skipRedirectCheck: true }` to the function.\n *\n * If `type` is set to `success`, the parent window will attempt to close the child window immediately.\n *\n * If the error `ERR_WEB_BROWSER_REDIRECT` was thrown, it may mean that the parent window was\n * reloaded before the auth was completed. In this case you'll need to close the child window manually.\n *\n * @platform web\n */\nexport function maybeCompleteAuthSession(\n options: WebBrowserCompleteAuthSessionOptions = {}\n): WebBrowserCompleteAuthSessionResult {\n if (ExponentWebBrowser.maybeCompleteAuthSession) {\n return ExponentWebBrowser.maybeCompleteAuthSession(options);\n }\n return { type: 'failed', message: 'Not supported on this platform' };\n}\n\n/* iOS <= 10 and Android polyfill for SFAuthenticationSession flow */\n\nfunction _authSessionIsNativelySupported(): boolean {\n if (Platform.OS === 'android') {\n return false;\n } else if (Platform.OS === 'web') {\n return true;\n }\n\n const versionNumber = parseInt(String(Platform.Version), 10);\n return versionNumber >= 11;\n}\n\nlet _redirectHandler: ((event: RedirectEvent) => void) | null = null;\n\n/*\n * openBrowserAsync on Android doesn't wait until closed, so we need to polyfill\n * it with AppState\n */\n\n// Store the `resolve` function from a Promise to fire when the AppState\n// returns to active\nlet _onWebBrowserCloseAndroid: null | (() => void) = null;\n\n// If the initial AppState.currentState is null, we assume that the first call to\n// AppState#change event is not actually triggered by a real change,\n// is triggered instead by the bridge capturing the current state\n// (https://reactnative.dev/docs/appstate#basic-usage)\nlet _isAppStateAvailable: boolean = AppState.currentState !== null;\nfunction _onAppStateChangeAndroid(state: AppStateStatus) {\n if (!_isAppStateAvailable) {\n _isAppStateAvailable = true;\n return;\n }\n\n if (state === 'active' && _onWebBrowserCloseAndroid) {\n _onWebBrowserCloseAndroid();\n }\n}\n\nasync function _openBrowserAndWaitAndroidAsync(\n startUrl: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserResult> {\n const appStateChangedToActive = new Promise<void>((resolve) => {\n _onWebBrowserCloseAndroid = resolve;\n AppState.addEventListener('change', _onAppStateChangeAndroid);\n });\n\n let result: WebBrowserResult = { type: WebBrowserResultType.CANCEL };\n let type: string | null = null;\n\n try {\n ({ type } = await openBrowserAsync(startUrl, browserParams));\n } catch (e) {\n AppState.removeEventListener('change', _onAppStateChangeAndroid);\n _onWebBrowserCloseAndroid = null;\n throw e;\n }\n\n if (type === 'opened') {\n await appStateChangedToActive;\n result = { type: WebBrowserResultType.DISMISS };\n }\n\n AppState.removeEventListener('change', _onAppStateChangeAndroid);\n _onWebBrowserCloseAndroid = null;\n return result;\n}\n\nasync function _openAuthSessionPolyfillAsync(\n startUrl: string,\n returnUrl: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserAuthSessionResult> {\n if (_redirectHandler) {\n throw new Error(\n `The WebBrowser's auth session is in an invalid state with a redirect handler set when it should not be`\n );\n }\n\n if (_onWebBrowserCloseAndroid) {\n throw new Error(`WebBrowser is already open, only one can be open at a time`);\n }\n\n try {\n if (Platform.OS === 'android') {\n return await Promise.race([\n _openBrowserAndWaitAndroidAsync(startUrl, browserParams),\n _waitForRedirectAsync(returnUrl),\n ]);\n } else {\n return await Promise.race([\n openBrowserAsync(startUrl, browserParams),\n _waitForRedirectAsync(returnUrl),\n ]);\n }\n } finally {\n // We can't dismiss the browser on Android, only call this when it's available.\n // Users on Android need to manually press the 'x' button in Chrome Custom Tabs, sadly.\n if (ExponentWebBrowser.dismissBrowser) {\n ExponentWebBrowser.dismissBrowser();\n }\n\n _stopWaitingForRedirect();\n }\n}\n\nfunction _stopWaitingForRedirect() {\n if (!_redirectHandler) {\n throw new Error(\n `The WebBrowser auth session is in an invalid state with no redirect handler when one should be set`\n );\n }\n\n Linking.removeEventListener('url', _redirectHandler);\n _redirectHandler = null;\n}\n\nfunction _waitForRedirectAsync(returnUrl: string): Promise<WebBrowserRedirectResult> {\n return new Promise((resolve) => {\n _redirectHandler = (event: RedirectEvent) => {\n if (event.url.startsWith(returnUrl)) {\n resolve({ url: event.url, type: 'success' });\n }\n };\n\n Linking.addEventListener('url', _redirectHandler);\n });\n}\n"]}
|
|
@@ -8,8 +8,9 @@ export declare type WebBrowserOpenOptions = {
|
|
|
8
8
|
*/
|
|
9
9
|
toolbarColor?: string;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Package name of a browser to be used to handle Custom Tabs. List of
|
|
12
12
|
* available packages is to be queried by [`getCustomTabsSupportingBrowsers`](#webbrowsergetcustomtabssupportingbrowsersasync) method.
|
|
13
|
+
* @platform android
|
|
13
14
|
*/
|
|
14
15
|
browserPackage?: string;
|
|
15
16
|
/**
|
|
@@ -17,47 +18,57 @@ export declare type WebBrowserOpenOptions = {
|
|
|
17
18
|
*/
|
|
18
19
|
enableBarCollapsing?: boolean;
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
+
* Color of the secondary toolbar in either `#AARRGGBB` or `#RRGGBB` format.
|
|
22
|
+
* @platform android
|
|
21
23
|
*/
|
|
22
24
|
secondaryToolbarColor?: string;
|
|
23
25
|
/**
|
|
24
|
-
*
|
|
26
|
+
* A boolean determining whether the browser should show the title of website on the toolbar.
|
|
27
|
+
* @platform android
|
|
25
28
|
*/
|
|
26
29
|
showTitle?: boolean;
|
|
27
30
|
/**
|
|
28
|
-
*
|
|
31
|
+
* A boolean determining whether a default share item should be added to the menu.
|
|
32
|
+
* @platform android
|
|
29
33
|
*/
|
|
30
34
|
enableDefaultShareMenuItem?: boolean;
|
|
31
35
|
/**
|
|
32
|
-
*
|
|
36
|
+
* A boolean determining whether browsed website should be shown as separate
|
|
33
37
|
* entry in Android recents/multitasking view. Requires `createTask` to be `true` (default).
|
|
34
|
-
* @default
|
|
38
|
+
* @default false
|
|
39
|
+
* @platform android
|
|
35
40
|
*/
|
|
36
41
|
showInRecents?: boolean;
|
|
37
42
|
/**
|
|
38
|
-
*
|
|
43
|
+
* A boolean determining whether the browser should open in a new task or in
|
|
39
44
|
* the same task as your app.
|
|
40
|
-
* @default
|
|
45
|
+
* @default true
|
|
46
|
+
* @platform android
|
|
41
47
|
*/
|
|
42
48
|
createTask?: boolean;
|
|
43
49
|
/**
|
|
44
|
-
*
|
|
50
|
+
* Tint color for controls in SKSafariViewController in `#AARRGGBB` or `#RRGGBB` format.
|
|
51
|
+
* @platform ios
|
|
45
52
|
*/
|
|
46
53
|
controlsColor?: string;
|
|
47
54
|
/**
|
|
48
|
-
*
|
|
55
|
+
* The style of the dismiss button. Should be one of: `done`, `close`, or `cancel`.
|
|
56
|
+
* @platform ios
|
|
49
57
|
*/
|
|
50
58
|
dismissButtonStyle?: 'done' | 'close' | 'cancel';
|
|
51
59
|
/**
|
|
52
|
-
*
|
|
60
|
+
* A boolean determining whether Safari should enter Reader mode, if it is available.
|
|
61
|
+
* @platform ios
|
|
53
62
|
*/
|
|
54
63
|
readerMode?: boolean;
|
|
55
64
|
/**
|
|
56
|
-
*
|
|
65
|
+
* Name to assign to the popup window.
|
|
66
|
+
* @platform web
|
|
57
67
|
*/
|
|
58
68
|
windowName?: string;
|
|
59
69
|
/**
|
|
60
|
-
*
|
|
70
|
+
* Features to use with `window.open()`.
|
|
71
|
+
* @platform web
|
|
61
72
|
*/
|
|
62
73
|
windowFeatures?: string | WebBrowserWindowFeatures;
|
|
63
74
|
};
|
|
@@ -90,15 +101,15 @@ export declare type WebBrowserCustomTabsResults = {
|
|
|
90
101
|
};
|
|
91
102
|
export declare enum WebBrowserResultType {
|
|
92
103
|
/**
|
|
93
|
-
*
|
|
104
|
+
* @platform ios
|
|
94
105
|
*/
|
|
95
106
|
CANCEL = "cancel",
|
|
96
107
|
/**
|
|
97
|
-
*
|
|
108
|
+
* @platform ios
|
|
98
109
|
*/
|
|
99
110
|
DISMISS = "dismiss",
|
|
100
111
|
/**
|
|
101
|
-
*
|
|
112
|
+
* @platform android
|
|
102
113
|
*/
|
|
103
114
|
OPENED = "opened",
|
|
104
115
|
LOCKED = "locked"
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
export var WebBrowserResultType;
|
|
3
3
|
(function (WebBrowserResultType) {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* @platform ios
|
|
6
6
|
*/
|
|
7
7
|
WebBrowserResultType["CANCEL"] = "cancel";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* @platform ios
|
|
10
10
|
*/
|
|
11
11
|
WebBrowserResultType["DISMISS"] = "dismiss";
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* @platform android
|
|
14
14
|
*/
|
|
15
15
|
WebBrowserResultType["OPENED"] = "opened";
|
|
16
16
|
WebBrowserResultType["LOCKED"] = "locked";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebBrowser.types.js","sourceRoot":"","sources":["../src/WebBrowser.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebBrowser.types.js","sourceRoot":"","sources":["../src/WebBrowser.types.ts"],"names":[],"mappings":"AA6GA,2BAA2B;AAC3B,MAAM,CAAN,IAAY,oBAcX;AAdD,WAAY,oBAAoB;IAC9B;;OAEG;IACH,yCAAiB,CAAA;IACjB;;OAEG;IACH,2CAAmB,CAAA;IACnB;;OAEG;IACH,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;AACnB,CAAC,EAdW,oBAAoB,KAApB,oBAAoB,QAc/B","sourcesContent":["export type RedirectEvent = {\n url: string;\n};\n\n// @needsAudit @docsMissing\nexport type WebBrowserWindowFeatures = Record<string, number | boolean | string>;\n\n// @needsAudit\nexport type WebBrowserOpenOptions = {\n /**\n * Color of the toolbar in either `#AARRGGBB` or `#RRGGBB` format.\n */\n toolbarColor?: string;\n /**\n * Package name of a browser to be used to handle Custom Tabs. List of\n * available packages is to be queried by [`getCustomTabsSupportingBrowsers`](#webbrowsergetcustomtabssupportingbrowsersasync) method.\n * @platform android\n */\n browserPackage?: string;\n /**\n * A boolean determining whether the toolbar should be hiding when a user scrolls the website.\n */\n enableBarCollapsing?: boolean;\n /**\n * Color of the secondary toolbar in either `#AARRGGBB` or `#RRGGBB` format.\n * @platform android\n */\n secondaryToolbarColor?: string;\n /**\n * A boolean determining whether the browser should show the title of website on the toolbar.\n * @platform android\n */\n showTitle?: boolean;\n /**\n * A boolean determining whether a default share item should be added to the menu.\n * @platform android\n */\n enableDefaultShareMenuItem?: boolean;\n /**\n * A boolean determining whether browsed website should be shown as separate\n * entry in Android recents/multitasking view. Requires `createTask` to be `true` (default).\n * @default false\n * @platform android\n */\n showInRecents?: boolean;\n /**\n * A boolean determining whether the browser should open in a new task or in\n * the same task as your app.\n * @default true\n * @platform android\n */\n createTask?: boolean;\n /**\n * Tint color for controls in SKSafariViewController in `#AARRGGBB` or `#RRGGBB` format.\n * @platform ios\n */\n controlsColor?: string;\n /**\n * The style of the dismiss button. Should be one of: `done`, `close`, or `cancel`.\n * @platform ios\n */\n dismissButtonStyle?: 'done' | 'close' | 'cancel';\n /**\n * A boolean determining whether Safari should enter Reader mode, if it is available.\n * @platform ios\n */\n readerMode?: boolean;\n /**\n * Name to assign to the popup window.\n * @platform web\n */\n windowName?: string;\n /**\n * Features to use with `window.open()`.\n * @platform web\n */\n windowFeatures?: string | WebBrowserWindowFeatures;\n};\n\nexport type WebBrowserAuthSessionResult = WebBrowserRedirectResult | WebBrowserResult;\n\n// @needsAudit\nexport type WebBrowserCustomTabsResults = {\n /**\n * Default package chosen by user, `null` if there is no such packages. Also `null` usually means,\n * that user will be prompted to choose from available packages.\n */\n defaultBrowserPackage?: string;\n /**\n * Package preferred by `CustomTabsClient` to be used to handle Custom Tabs. It favors browser\n * chosen by user as default, as long as it is present on both `browserPackages` and\n * `servicePackages` lists. Only such browsers are considered as fully supporting Custom Tabs.\n * It might be `null` when there is no such browser installed or when default browser is not in\n * `servicePackages` list.\n */\n preferredBrowserPackage?: string;\n /**\n * All packages recognized by `PackageManager` as capable of handling Custom Tabs. Empty array\n * means there is no supporting browsers on device.\n */\n browserPackages: string[];\n /**\n * All packages recognized by `PackageManager` as capable of handling Custom Tabs Service.\n * This service is used by [`warmUpAsync`](#webbrowserwarmupasyncbrowserpackage), [`mayInitWithUrlAsync`](#webbrowsermayinitwithurlasyncurl-browserpackage)\n * and [`coolDownAsync`](#webbrowsercooldownasyncbrowserpackage).\n */\n servicePackages: string[];\n};\n\n// @needsAudit @docsMissing\nexport enum WebBrowserResultType {\n /**\n * @platform ios\n */\n CANCEL = 'cancel',\n /**\n * @platform ios\n */\n DISMISS = 'dismiss',\n /**\n * @platform android\n */\n OPENED = 'opened',\n LOCKED = 'locked',\n}\n\n// @needsAudit\nexport type WebBrowserResult = {\n /**\n * Type of the result.\n */\n type: WebBrowserResultType;\n};\n\n// @needsAudit @docsMissing\nexport type WebBrowserRedirectResult = {\n /**\n * Type of the result.\n */\n type: 'success';\n url: string;\n};\n\nexport type ServiceActionResult = {\n servicePackage?: string;\n};\n\nexport type WebBrowserMayInitWithUrlResult = ServiceActionResult;\nexport type WebBrowserWarmUpResult = ServiceActionResult;\nexport type WebBrowserCoolDownResult = ServiceActionResult;\n\n// @needsAudit\nexport type WebBrowserCompleteAuthSessionOptions = {\n /**\n * Attempt to close the window without checking to see if the auth redirect matches the cached redirect URL.\n */\n skipRedirectCheck?: boolean;\n};\n\n// @needsAudit\nexport type WebBrowserCompleteAuthSessionResult = {\n /**\n * Type of the result.\n */\n type: 'success' | 'failed';\n /**\n * Additional description or reasoning of the result.\n */\n message: string;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-web-browser",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"description": "Provides access to the system's web browser and supports handling redirects. On iOS, it uses SFSafariViewController or SFAuthenticationSession, depending on the method you call, and on Android it uses ChromeCustomTabs. As of iOS 11, SFSafariViewController no longer shares cookies with Safari, so if you are using WebBrowser for authentication you will want to use WebBrowser.openAuthSessionAsync, and if you just want to open a webpage (such as your app privacy policy), then use WebBrowser.openBrowserAsync.",
|
|
5
5
|
"main": "build/WebBrowser.js",
|
|
6
6
|
"types": "build/WebBrowser.d.ts",
|
|
@@ -36,11 +36,13 @@
|
|
|
36
36
|
"preset": "expo-module-scripts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"compare-urls": "^2.0.0"
|
|
40
|
-
"expo-modules-core": "~0.4.0"
|
|
39
|
+
"compare-urls": "^2.0.0"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
42
|
"expo-module-scripts": "^2.0.0"
|
|
44
43
|
},
|
|
45
|
-
"
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"expo": "*"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "4ac89934e2acc4ef1fad59f338d9019fe2d92240"
|
|
46
48
|
}
|
package/src/WebBrowser.ts
CHANGED
|
@@ -42,12 +42,13 @@ const emptyCustomTabsPackages: WebBrowserCustomTabsResults = {
|
|
|
42
42
|
|
|
43
43
|
// @needsAudit
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Returns a list of applications package names supporting Custom Tabs, Custom Tabs
|
|
46
46
|
* service, user chosen and preferred one. This may not be fully reliable, since it uses
|
|
47
47
|
* `PackageManager.getResolvingActivities` under the hood. (For example, some browsers might not be
|
|
48
48
|
* present in browserPackages list once another browser is set to default.)
|
|
49
49
|
*
|
|
50
50
|
* @return The promise which fulfils with [`WebBrowserCustomTabsResults`](#webbrowsercustomtabsresults) object.
|
|
51
|
+
* @platform android
|
|
51
52
|
*/
|
|
52
53
|
export async function getCustomTabsSupportingBrowsersAsync(): Promise<WebBrowserCustomTabsResults> {
|
|
53
54
|
if (!ExponentWebBrowser.getCustomTabsSupportingBrowsersAsync) {
|
|
@@ -62,12 +63,13 @@ export async function getCustomTabsSupportingBrowsersAsync(): Promise<WebBrowser
|
|
|
62
63
|
|
|
63
64
|
// @needsAudit
|
|
64
65
|
/**
|
|
65
|
-
*
|
|
66
|
+
* This method calls `warmUp` method on [CustomTabsClient](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#warmup(long))
|
|
66
67
|
* for specified package.
|
|
67
68
|
*
|
|
68
|
-
* @param browserPackage
|
|
69
|
+
* @param browserPackage Package of browser to be warmed up. If not set, preferred browser will be warmed.
|
|
69
70
|
*
|
|
70
|
-
* @return A promise which fulfils with `
|
|
71
|
+
* @return A promise which fulfils with `WebBrowserWarmUpResult` object.
|
|
72
|
+
* @platform android
|
|
71
73
|
*/
|
|
72
74
|
export async function warmUpAsync(browserPackage?: string): Promise<WebBrowserWarmUpResult> {
|
|
73
75
|
if (!ExponentWebBrowser.warmUpAsync) {
|
|
@@ -82,13 +84,15 @@ export async function warmUpAsync(browserPackage?: string): Promise<WebBrowserWa
|
|
|
82
84
|
|
|
83
85
|
// @needsAudit
|
|
84
86
|
/**
|
|
85
|
-
*
|
|
87
|
+
* This method initiates (if needed) [CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession.html#maylaunchurl)
|
|
86
88
|
* and calls its `mayLaunchUrl` method for browser specified by the package.
|
|
87
89
|
*
|
|
88
90
|
* @param url The url of page that is likely to be loaded first when opening browser.
|
|
89
|
-
* @param browserPackage
|
|
91
|
+
* @param browserPackage Package of browser to be informed. If not set, preferred
|
|
92
|
+
* browser will be used.
|
|
90
93
|
*
|
|
91
|
-
* @return A promise which fulfils with `
|
|
94
|
+
* @return A promise which fulfils with `WebBrowserMayInitWithUrlResult` object.
|
|
95
|
+
* @platform android
|
|
92
96
|
*/
|
|
93
97
|
export async function mayInitWithUrlAsync(
|
|
94
98
|
url: string,
|
|
@@ -106,15 +110,16 @@ export async function mayInitWithUrlAsync(
|
|
|
106
110
|
|
|
107
111
|
// @needsAudit
|
|
108
112
|
/**
|
|
109
|
-
*
|
|
113
|
+
* This methods removes all bindings to services created by [`warmUpAsync`](#webbrowserwarmupasyncbrowserpackage)
|
|
110
114
|
* or [`mayInitWithUrlAsync`](#webbrowsermayinitwithurlasyncurl-browserpackage). You should call
|
|
111
115
|
* this method once you don't need them to avoid potential memory leaks. However, those binding
|
|
112
116
|
* would be cleared once your application is destroyed, which might be sufficient in most cases.
|
|
113
117
|
*
|
|
114
|
-
* @param browserPackage
|
|
118
|
+
* @param browserPackage Package of browser to be cooled. If not set, preferred browser will be used.
|
|
115
119
|
*
|
|
116
|
-
* @return The promise which fulfils with `
|
|
120
|
+
* @return The promise which fulfils with ` WebBrowserCoolDownResult` when cooling is performed, or
|
|
117
121
|
* an empty object when there was no connection to be dismissed.
|
|
122
|
+
* @platform android
|
|
118
123
|
*/
|
|
119
124
|
export async function coolDownAsync(browserPackage?: string): Promise<WebBrowserCoolDownResult> {
|
|
120
125
|
if (!ExponentWebBrowser.coolDownAsync) {
|
|
@@ -179,9 +184,10 @@ export async function openBrowserAsync(
|
|
|
179
184
|
|
|
180
185
|
// @needsAudit
|
|
181
186
|
/**
|
|
182
|
-
*
|
|
187
|
+
* Dismisses the presented web browser.
|
|
183
188
|
*
|
|
184
|
-
* @return The
|
|
189
|
+
* @return The `void` on successful attempt, or throws error, if dismiss functionality is not avaiable.
|
|
190
|
+
* @platform ios
|
|
185
191
|
*/
|
|
186
192
|
export function dismissBrowser(): void {
|
|
187
193
|
if (!ExponentWebBrowser.dismissBrowser) {
|
|
@@ -271,7 +277,7 @@ export function dismissAuthSession(): void {
|
|
|
271
277
|
|
|
272
278
|
// @needsAudit
|
|
273
279
|
/**
|
|
274
|
-
*
|
|
280
|
+
* Possibly completes an authentication session on web in a window popup. The method
|
|
275
281
|
* should be invoked on the page that the window redirects to.
|
|
276
282
|
*
|
|
277
283
|
* @param options
|
|
@@ -295,6 +301,8 @@ export function dismissAuthSession(): void {
|
|
|
295
301
|
*
|
|
296
302
|
* If the error `ERR_WEB_BROWSER_REDIRECT` was thrown, it may mean that the parent window was
|
|
297
303
|
* reloaded before the auth was completed. In this case you'll need to close the child window manually.
|
|
304
|
+
*
|
|
305
|
+
* @platform web
|
|
298
306
|
*/
|
|
299
307
|
export function maybeCompleteAuthSession(
|
|
300
308
|
options: WebBrowserCompleteAuthSessionOptions = {}
|
package/src/WebBrowser.types.ts
CHANGED
|
@@ -12,8 +12,9 @@ export type WebBrowserOpenOptions = {
|
|
|
12
12
|
*/
|
|
13
13
|
toolbarColor?: string;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Package name of a browser to be used to handle Custom Tabs. List of
|
|
16
16
|
* available packages is to be queried by [`getCustomTabsSupportingBrowsers`](#webbrowsergetcustomtabssupportingbrowsersasync) method.
|
|
17
|
+
* @platform android
|
|
17
18
|
*/
|
|
18
19
|
browserPackage?: string;
|
|
19
20
|
/**
|
|
@@ -21,47 +22,57 @@ export type WebBrowserOpenOptions = {
|
|
|
21
22
|
*/
|
|
22
23
|
enableBarCollapsing?: boolean;
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
+
* Color of the secondary toolbar in either `#AARRGGBB` or `#RRGGBB` format.
|
|
26
|
+
* @platform android
|
|
25
27
|
*/
|
|
26
28
|
secondaryToolbarColor?: string;
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
30
|
+
* A boolean determining whether the browser should show the title of website on the toolbar.
|
|
31
|
+
* @platform android
|
|
29
32
|
*/
|
|
30
33
|
showTitle?: boolean;
|
|
31
34
|
/**
|
|
32
|
-
*
|
|
35
|
+
* A boolean determining whether a default share item should be added to the menu.
|
|
36
|
+
* @platform android
|
|
33
37
|
*/
|
|
34
38
|
enableDefaultShareMenuItem?: boolean;
|
|
35
39
|
/**
|
|
36
|
-
*
|
|
40
|
+
* A boolean determining whether browsed website should be shown as separate
|
|
37
41
|
* entry in Android recents/multitasking view. Requires `createTask` to be `true` (default).
|
|
38
|
-
* @default
|
|
42
|
+
* @default false
|
|
43
|
+
* @platform android
|
|
39
44
|
*/
|
|
40
45
|
showInRecents?: boolean;
|
|
41
46
|
/**
|
|
42
|
-
*
|
|
47
|
+
* A boolean determining whether the browser should open in a new task or in
|
|
43
48
|
* the same task as your app.
|
|
44
|
-
* @default
|
|
49
|
+
* @default true
|
|
50
|
+
* @platform android
|
|
45
51
|
*/
|
|
46
52
|
createTask?: boolean;
|
|
47
53
|
/**
|
|
48
|
-
*
|
|
54
|
+
* Tint color for controls in SKSafariViewController in `#AARRGGBB` or `#RRGGBB` format.
|
|
55
|
+
* @platform ios
|
|
49
56
|
*/
|
|
50
57
|
controlsColor?: string;
|
|
51
58
|
/**
|
|
52
|
-
*
|
|
59
|
+
* The style of the dismiss button. Should be one of: `done`, `close`, or `cancel`.
|
|
60
|
+
* @platform ios
|
|
53
61
|
*/
|
|
54
62
|
dismissButtonStyle?: 'done' | 'close' | 'cancel';
|
|
55
63
|
/**
|
|
56
|
-
*
|
|
64
|
+
* A boolean determining whether Safari should enter Reader mode, if it is available.
|
|
65
|
+
* @platform ios
|
|
57
66
|
*/
|
|
58
67
|
readerMode?: boolean;
|
|
59
68
|
/**
|
|
60
|
-
*
|
|
69
|
+
* Name to assign to the popup window.
|
|
70
|
+
* @platform web
|
|
61
71
|
*/
|
|
62
72
|
windowName?: string;
|
|
63
73
|
/**
|
|
64
|
-
*
|
|
74
|
+
* Features to use with `window.open()`.
|
|
75
|
+
* @platform web
|
|
65
76
|
*/
|
|
66
77
|
windowFeatures?: string | WebBrowserWindowFeatures;
|
|
67
78
|
};
|
|
@@ -99,15 +110,15 @@ export type WebBrowserCustomTabsResults = {
|
|
|
99
110
|
// @needsAudit @docsMissing
|
|
100
111
|
export enum WebBrowserResultType {
|
|
101
112
|
/**
|
|
102
|
-
*
|
|
113
|
+
* @platform ios
|
|
103
114
|
*/
|
|
104
115
|
CANCEL = 'cancel',
|
|
105
116
|
/**
|
|
106
|
-
*
|
|
117
|
+
* @platform ios
|
|
107
118
|
*/
|
|
108
119
|
DISMISS = 'dismiss',
|
|
109
120
|
/**
|
|
110
|
-
*
|
|
121
|
+
* @platform android
|
|
111
122
|
*/
|
|
112
123
|
OPENED = 'opened',
|
|
113
124
|
LOCKED = 'locked',
|