expo-web-browser 12.0.0 โ 12.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 +10 -0
- package/README.md +1 -1
- package/android/build.gradle +4 -4
- package/build/ExpoWebBrowser.web.d.ts +1 -1
- package/build/ExpoWebBrowser.web.d.ts.map +1 -1
- package/build/WebBrowser.d.ts +4 -0
- package/build/WebBrowser.d.ts.map +1 -1
- package/build/WebBrowser.js +4 -0
- package/build/WebBrowser.js.map +1 -1
- package/build/WebBrowser.types.d.ts +14 -14
- package/build/WebBrowser.types.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/WebBrowser.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### ๐ก Others
|
|
12
12
|
|
|
13
|
+
## 12.1.0 โ 2023-02-03
|
|
14
|
+
|
|
15
|
+
### ๐ Bug fixes
|
|
16
|
+
|
|
17
|
+
- Add missing peer dependency on `url` for web. ([#20708](https://github.com/expo/expo/pull/20708) by [@EvanBacon](https://github.com/EvanBacon))
|
|
18
|
+
|
|
19
|
+
### ๐ก Others
|
|
20
|
+
|
|
21
|
+
- On Android bump `compileSdkVersion` and `targetSdkVersion` to `33`. ([#20721](https://github.com/expo/expo/pull/20721) by [@lukmccall](https://github.com/lukmccall))
|
|
22
|
+
|
|
13
23
|
## 12.0.0 โ 2022-10-25
|
|
14
24
|
|
|
15
25
|
### ๐ Breaking changes
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Provides access to the system's web browser and supports handling redirects. On
|
|
|
4
4
|
|
|
5
5
|
# API documentation
|
|
6
6
|
|
|
7
|
-
- [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/webbrowser.
|
|
7
|
+
- [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/webbrowser.mdx)
|
|
8
8
|
- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/webbrowser/)
|
|
9
9
|
|
|
10
10
|
# Installation in managed Expo projects
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '12.
|
|
6
|
+
version = '12.1.0'
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
buildscript {
|
|
@@ -60,7 +60,7 @@ afterEvaluate {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
android {
|
|
63
|
-
compileSdkVersion safeExtGet("compileSdkVersion",
|
|
63
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 33)
|
|
64
64
|
|
|
65
65
|
compileOptions {
|
|
66
66
|
sourceCompatibility JavaVersion.VERSION_11
|
|
@@ -73,9 +73,9 @@ android {
|
|
|
73
73
|
|
|
74
74
|
defaultConfig {
|
|
75
75
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
76
|
-
targetSdkVersion safeExtGet("targetSdkVersion",
|
|
76
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
77
77
|
versionCode 18
|
|
78
|
-
versionName '12.
|
|
78
|
+
versionName '12.1.0'
|
|
79
79
|
}
|
|
80
80
|
lintOptions {
|
|
81
81
|
abortOnError false
|
|
@@ -9,7 +9,7 @@ declare const _default: {
|
|
|
9
9
|
type: 'success' | 'failed';
|
|
10
10
|
message: string;
|
|
11
11
|
};
|
|
12
|
-
openAuthSessionAsync(url: string, redirectUrl?: string
|
|
12
|
+
openAuthSessionAsync(url: string, redirectUrl?: string, openOptions?: WebBrowserOpenOptions): Promise<WebBrowserAuthSessionResult>;
|
|
13
13
|
};
|
|
14
14
|
export default _default;
|
|
15
15
|
export declare function featureObjectToString(features: Record<string, any>): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoWebBrowser.web.d.ts","sourceRoot":"","sources":["../src/ExpoWebBrowser.web.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,gBAAgB,EAGjB,MAAM,oBAAoB,CAAC;;;0BAyCnB,MAAM,kBACI,qBAAqB,GACnC,QAAQ,gBAAgB,CAAC;;;;QAWsD;QAChF,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;QAC3B,OAAO,EAAE,MAAM,CAAC;KACjB;8BA8CM,MAAM,
|
|
1
|
+
{"version":3,"file":"ExpoWebBrowser.web.d.ts","sourceRoot":"","sources":["../src/ExpoWebBrowser.web.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,gBAAgB,EAGjB,MAAM,oBAAoB,CAAC;;;0BAyCnB,MAAM,kBACI,qBAAqB,GACnC,QAAQ,gBAAgB,CAAC;;;;QAWsD;QAChF,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;QAC3B,OAAO,EAAE,MAAM,CAAC;KACjB;8BA8CM,MAAM,gBACG,MAAM,gBACN,qBAAqB,GAClC,QAAQ,2BAA2B,CAAC;;AAtEzC,wBAyJE;AAqIF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAY3E"}
|
package/build/WebBrowser.d.ts
CHANGED
|
@@ -72,6 +72,10 @@ export declare function dismissBrowser(): void;
|
|
|
72
72
|
* # On iOS:
|
|
73
73
|
* Opens the url with Safari in a modal using `ASWebAuthenticationSession`. The user will be asked
|
|
74
74
|
* whether to allow the app to authenticate using the given url.
|
|
75
|
+
* To handle redirection back to the mobile application, the redirect URI set in the authentication server
|
|
76
|
+
* has to use the protocol provided as the scheme in **app.json** [`expo.scheme`](./../config/app/#scheme)
|
|
77
|
+
* e.g. `demo://` not `https://` protocol.
|
|
78
|
+
* Using `Linking.addEventListener` is not needed and can have side effects.
|
|
75
79
|
*
|
|
76
80
|
* # On Android:
|
|
77
81
|
* This will be done using a "custom Chrome tabs" browser, [AppState](../react-native/appstate/),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebBrowser.d.ts","sourceRoot":"","sources":["../src/WebBrowser.ts"],"names":[],"mappings":"AAWA,OAAO,EAEL,2BAA2B,EAC3B,oCAAoC,EACpC,mCAAmC,EACnC,wBAAwB,EACxB,2BAA2B,EAC3B,8BAA8B,EAC9B,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,2BAA2B,EAC3B,oCAAoC,EACpC,mCAAmC,EACnC,wBAAwB,EACxB,2BAA2B,EAC3B,8BAA8B,EAC9B,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,sBAAsB,GACvB,CAAC;AAUF;;;;;;;;GAQG;AACH,wBAAsB,oCAAoC,IAAI,OAAO,CAAC,2BAA2B,CAAC,CASjG;AAGD;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAS1F;AAGD;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,8BAA8B,CAAC,CASzC;AAGD;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAS9F;AAKD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,aAAa,GAAE,qBAA0B,GACxC,OAAO,CAAC,gBAAgB,CAAC,CA2B3B;AAGD;;;;;G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AAI,CAKrC;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,EACX,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,EAC3B,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,2BAA2B,CAAC,CAYtC;AAGD,wBAAgB,kBAAkB,IAAI,IAAI,CAYzC;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,oCAAyC,GACjD,mCAAmC,CAKrC"}
|
package/build/WebBrowser.js
CHANGED
|
@@ -156,6 +156,10 @@ export function dismissBrowser() {
|
|
|
156
156
|
* # On iOS:
|
|
157
157
|
* Opens the url with Safari in a modal using `ASWebAuthenticationSession`. The user will be asked
|
|
158
158
|
* whether to allow the app to authenticate using the given url.
|
|
159
|
+
* To handle redirection back to the mobile application, the redirect URI set in the authentication server
|
|
160
|
+
* has to use the protocol provided as the scheme in **app.json** [`expo.scheme`](./../config/app/#scheme)
|
|
161
|
+
* e.g. `demo://` not `https://` protocol.
|
|
162
|
+
* Using `Linking.addEventListener` is not needed and can have side effects.
|
|
159
163
|
*
|
|
160
164
|
* # On Android:
|
|
161
165
|
* This will be done using a "custom Chrome tabs" browser, [AppState](../react-native/appstate/),
|
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,EACL,QAAQ,EAER,OAAO,EACP,QAAQ,EAER,YAAY,GACb,MAAM,cAAc,CAAC;AAEtB,OAAO,kBAAkB,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAWL,oBAAoB,EAGpB,2BAA2B,GAE5B,MAAM,oBAAoB,CAAC;AAE5B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KAAK,SAAS,EAAE;YAC7B,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;gBACxB,+BAA+B,CAAC,QAAQ,EAAE,aAAa,CAAC;gBACxD,qBAAqB,CAAC,SAAS,CAAC;aACjC,CAAC,CAAC;SACJ;aAAM;YACL,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;gBACxB,gBAAgB,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,qBAAqB,EAAE;QAC1B,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;KACH;IAED,qBAAqB,CAAC,MAAM,EAAE,CAAC;IAC/B,qBAAqB,GAAG,IAAI,CAAC;AAC/B,CAAC;AAED,SAAS,qBAAqB,CAC5B,SAAoC;IAEpC,oEAAoE;IACpE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,eAAe,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC/C,IAAI,SAAS,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;gBAChD,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;aAC9C;QACH,CAAC,CAAC;QAEF,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\nimport {\n AppState,\n AppStateStatus,\n Linking,\n Platform,\n EmitterSubscription,\n processColor,\n} 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 WebBrowserPresentationStyle,\n AuthSessionOpenOptions,\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 WebBrowserPresentationStyle,\n AuthSessionOpenOptions,\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, _processOptions(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 `ASWebAuthenticationSession`. The user will be asked\n * whether to allow the app 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 `npx expo start --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.\n * On web, this defaults to the output of [`Linking.createURL(\"\")`](./linking/#linkingcreateurlpath-namedparameters).\n * @param options _Optional_ - An object extending the [`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 | null,\n options: AuthSessionOpenOptions = {}\n): Promise<WebBrowserAuthSessionResult> {\n if (_authSessionIsNativelySupported()) {\n if (!ExponentWebBrowser.openAuthSessionAsync) {\n throw new UnavailabilityError('WebBrowser', 'openAuthSessionAsync');\n }\n if (['ios', 'web'].includes(Platform.OS)) {\n return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl, _processOptions(options));\n }\n return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl);\n } else {\n return _openAuthSessionPolyfillAsync(url, redirectUrl, options);\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\nfunction _processOptions(options: WebBrowserOpenOptions) {\n return {\n ...options,\n controlsColor: processColor(options.controlsColor),\n toolbarColor: processColor(options.toolbarColor),\n secondaryToolbarColor: processColor(options.secondaryToolbarColor),\n };\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 _redirectSubscription: EmitterSubscription | 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 });\n const stateChangeSubscription = AppState.addEventListener('change', _onAppStateChangeAndroid);\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 stateChangeSubscription.remove();\n _onWebBrowserCloseAndroid = null;\n throw e;\n }\n\n if (type === 'opened') {\n await appStateChangedToActive;\n result = { type: WebBrowserResultType.DISMISS };\n }\n\n stateChangeSubscription.remove();\n _onWebBrowserCloseAndroid = null;\n return result;\n}\n\nasync function _openAuthSessionPolyfillAsync(\n startUrl: string,\n returnUrl: string | null | undefined,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserAuthSessionResult> {\n if (_redirectSubscription) {\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 (!_redirectSubscription) {\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 _redirectSubscription.remove();\n _redirectSubscription = null;\n}\n\nfunction _waitForRedirectAsync(\n returnUrl: string | null | undefined\n): Promise<WebBrowserRedirectResult> {\n // Note that this Promise never resolves when `returnUrl` is nullish\n return new Promise((resolve) => {\n const redirectHandler = (event: RedirectEvent) => {\n if (returnUrl && event.url.startsWith(returnUrl)) {\n resolve({ url: event.url, type: 'success' });\n }\n };\n\n _redirectSubscription = 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,EACL,QAAQ,EAER,OAAO,EACP,QAAQ,EAER,YAAY,GACb,MAAM,cAAc,CAAC;AAEtB,OAAO,kBAAkB,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAWL,oBAAoB,EAGpB,2BAA2B,GAE5B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAUL,oBAAoB,EAGpB,2BAA2B,GAE5B,CAAC;AAEF,MAAM,uBAAuB,GAAgC;IAC3D,qBAAqB,EAAE,SAAS;IAChC,uBAAuB,EAAE,SAAS;IAClC,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,EAAE;CACpB,CAAC;AAEF,cAAc;AACd;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,oCAAoC;IACxD,IAAI,CAAC,kBAAkB,CAAC,oCAAoC,EAAE;QAC5D,MAAM,IAAI,mBAAmB,CAAC,YAAY,EAAE,sCAAsC,CAAC,C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AAI,kBAAkB,CAAC,cAAc,EAAE;YACrC,kBAAkB,CAAC,cAAc,EAAE,CAAC;SACrC;QAED,uBAAuB,EAAE,CAAC;KAC3B;AACH,CAAC;AAED,SAAS,uBAAuB;IAC9B,IAAI,CAAC,qBAAqB,EAAE;QAC1B,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;KACH;IAED,qBAAqB,CAAC,MAAM,EAAE,CAAC;IAC/B,qBAAqB,GAAG,IAAI,CAAC;AAC/B,CAAC;AAED,SAAS,qBAAqB,CAC5B,SAAoC;IAEpC,oEAAoE;IACpE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,eAAe,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC/C,IAAI,SAAS,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;gBAChD,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;aAC9C;QACH,CAAC,CAAC;QAEF,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\nimport {\n AppState,\n AppStateStatus,\n Linking,\n Platform,\n EmitterSubscription,\n processColor,\n} 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 WebBrowserPresentationStyle,\n AuthSessionOpenOptions,\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 WebBrowserPresentationStyle,\n AuthSessionOpenOptions,\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, _processOptions(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 `ASWebAuthenticationSession`. The user will be asked\n * whether to allow the app to authenticate using the given url.\n * To handle redirection back to the mobile application, the redirect URI set in the authentication server\n * has to use the protocol provided as the scheme in **app.json** [`expo.scheme`](./../config/app/#scheme)\n * e.g. `demo://` not `https://` protocol.\n * Using `Linking.addEventListener` is not needed and can have side effects.\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 `npx expo start --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.\n * On web, this defaults to the output of [`Linking.createURL(\"\")`](./linking/#linkingcreateurlpath-namedparameters).\n * @param options _Optional_ - An object extending the [`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 | null,\n options: AuthSessionOpenOptions = {}\n): Promise<WebBrowserAuthSessionResult> {\n if (_authSessionIsNativelySupported()) {\n if (!ExponentWebBrowser.openAuthSessionAsync) {\n throw new UnavailabilityError('WebBrowser', 'openAuthSessionAsync');\n }\n if (['ios', 'web'].includes(Platform.OS)) {\n return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl, _processOptions(options));\n }\n return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl);\n } else {\n return _openAuthSessionPolyfillAsync(url, redirectUrl, options);\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\nfunction _processOptions(options: WebBrowserOpenOptions) {\n return {\n ...options,\n controlsColor: processColor(options.controlsColor),\n toolbarColor: processColor(options.toolbarColor),\n secondaryToolbarColor: processColor(options.secondaryToolbarColor),\n };\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 _redirectSubscription: EmitterSubscription | 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 });\n const stateChangeSubscription = AppState.addEventListener('change', _onAppStateChangeAndroid);\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 stateChangeSubscription.remove();\n _onWebBrowserCloseAndroid = null;\n throw e;\n }\n\n if (type === 'opened') {\n await appStateChangedToActive;\n result = { type: WebBrowserResultType.DISMISS };\n }\n\n stateChangeSubscription.remove();\n _onWebBrowserCloseAndroid = null;\n return result;\n}\n\nasync function _openAuthSessionPolyfillAsync(\n startUrl: string,\n returnUrl: string | null | undefined,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserAuthSessionResult> {\n if (_redirectSubscription) {\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 (!_redirectSubscription) {\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 _redirectSubscription.remove();\n _redirectSubscription = null;\n}\n\nfunction _waitForRedirectAsync(\n returnUrl: string | null | undefined\n): Promise<WebBrowserRedirectResult> {\n // Note that this Promise never resolves when `returnUrl` is nullish\n return new Promise((resolve) => {\n const redirectHandler = (event: RedirectEvent) => {\n if (returnUrl && event.url.startsWith(returnUrl)) {\n resolve({ url: event.url, type: 'success' });\n }\n };\n\n _redirectSubscription = Linking.addEventListener('url', redirectHandler);\n });\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type RedirectEvent = {
|
|
2
2
|
url: string;
|
|
3
3
|
};
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type WebBrowserWindowFeatures = Record<string, number | boolean | string>;
|
|
5
|
+
export type WebBrowserOpenOptions = {
|
|
6
6
|
/**
|
|
7
7
|
* Color of the toolbar. Supports React Native [color formats](https://reactnative.dev/docs/colors).
|
|
8
8
|
*/
|
|
@@ -83,7 +83,7 @@ export declare type WebBrowserOpenOptions = {
|
|
|
83
83
|
* If there is no native AuthSession implementation available (which is the case on Android) the params inherited from
|
|
84
84
|
* [`WebBrowserOpenOptions`](#webbrowseropenoptions) will be used in the browser polyfill. Otherwise, the browser parameters will be ignored.
|
|
85
85
|
*/
|
|
86
|
-
export
|
|
86
|
+
export type AuthSessionOpenOptions = WebBrowserOpenOptions & {
|
|
87
87
|
/**
|
|
88
88
|
* Determines whether the session should ask the browser for a private authentication session.
|
|
89
89
|
* 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.
|
|
@@ -94,8 +94,8 @@ export declare type AuthSessionOpenOptions = WebBrowserOpenOptions & {
|
|
|
94
94
|
*/
|
|
95
95
|
preferEphemeralSession?: boolean;
|
|
96
96
|
};
|
|
97
|
-
export
|
|
98
|
-
export
|
|
97
|
+
export type WebBrowserAuthSessionResult = WebBrowserRedirectResult | WebBrowserResult;
|
|
98
|
+
export type WebBrowserCustomTabsResults = {
|
|
99
99
|
/**
|
|
100
100
|
* Default package chosen by user, `null` if there is no such packages. Also `null` usually means,
|
|
101
101
|
* that user will be prompted to choose from available packages.
|
|
@@ -178,32 +178,32 @@ export declare enum WebBrowserPresentationStyle {
|
|
|
178
178
|
*/
|
|
179
179
|
AUTOMATIC = "automatic"
|
|
180
180
|
}
|
|
181
|
-
export
|
|
181
|
+
export type WebBrowserResult = {
|
|
182
182
|
/**
|
|
183
183
|
* Type of the result.
|
|
184
184
|
*/
|
|
185
185
|
type: WebBrowserResultType;
|
|
186
186
|
};
|
|
187
|
-
export
|
|
187
|
+
export type WebBrowserRedirectResult = {
|
|
188
188
|
/**
|
|
189
189
|
* Type of the result.
|
|
190
190
|
*/
|
|
191
191
|
type: 'success';
|
|
192
192
|
url: string;
|
|
193
193
|
};
|
|
194
|
-
export
|
|
194
|
+
export type ServiceActionResult = {
|
|
195
195
|
servicePackage?: string;
|
|
196
196
|
};
|
|
197
|
-
export
|
|
198
|
-
export
|
|
199
|
-
export
|
|
200
|
-
export
|
|
197
|
+
export type WebBrowserMayInitWithUrlResult = ServiceActionResult;
|
|
198
|
+
export type WebBrowserWarmUpResult = ServiceActionResult;
|
|
199
|
+
export type WebBrowserCoolDownResult = ServiceActionResult;
|
|
200
|
+
export type WebBrowserCompleteAuthSessionOptions = {
|
|
201
201
|
/**
|
|
202
202
|
* Attempt to close the window without checking to see if the auth redirect matches the cached redirect URL.
|
|
203
203
|
*/
|
|
204
204
|
skipRedirectCheck?: boolean;
|
|
205
205
|
};
|
|
206
|
-
export
|
|
206
|
+
export type WebBrowserCompleteAuthSessionResult = {
|
|
207
207
|
/**
|
|
208
208
|
* Type of the result.
|
|
209
209
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebBrowser.types.d.ts","sourceRoot":"","sources":["../src/WebBrowser.types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"WebBrowser.types.d.ts","sourceRoot":"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;IACH,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-web-browser",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.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,7 +36,8 @@
|
|
|
36
36
|
"preset": "expo-module-scripts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"compare-urls": "^2.0.0"
|
|
39
|
+
"compare-urls": "^2.0.0",
|
|
40
|
+
"url": "^0.11.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"expo-module-scripts": "^3.0.0"
|
|
@@ -44,5 +45,5 @@
|
|
|
44
45
|
"peerDependencies": {
|
|
45
46
|
"expo": "*"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "1815e2eaad8c753588c7b1eb74420174a28e01f4"
|
|
48
49
|
}
|
package/src/WebBrowser.ts
CHANGED
|
@@ -212,6 +212,10 @@ export function dismissBrowser(): void {
|
|
|
212
212
|
* # On iOS:
|
|
213
213
|
* Opens the url with Safari in a modal using `ASWebAuthenticationSession`. The user will be asked
|
|
214
214
|
* whether to allow the app to authenticate using the given url.
|
|
215
|
+
* To handle redirection back to the mobile application, the redirect URI set in the authentication server
|
|
216
|
+
* has to use the protocol provided as the scheme in **app.json** [`expo.scheme`](./../config/app/#scheme)
|
|
217
|
+
* e.g. `demo://` not `https://` protocol.
|
|
218
|
+
* Using `Linking.addEventListener` is not needed and can have side effects.
|
|
215
219
|
*
|
|
216
220
|
* # On Android:
|
|
217
221
|
* This will be done using a "custom Chrome tabs" browser, [AppState](../react-native/appstate/),
|