expo-web-browser 12.8.2 β†’ 13.0.1

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 CHANGED
@@ -10,13 +10,26 @@
10
10
 
11
11
  ### πŸ’‘ Others
12
12
 
13
- ## 12.8.2 β€” 2024-01-24
13
+ ## 13.0.1 β€” 2024-04-23
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
17
+ ## 13.0.0 β€” 2024-04-18
18
+
19
+ ### πŸ’‘ Others
20
+
21
+ - drop unused web `name` property. ([#27437](https://github.com/expo/expo/pull/27437) by [@EvanBacon](https://github.com/EvanBacon))
22
+ - Update error message to reflect that web crypto works on web with a localhost hostname and often doesn't require `https`. ([#26729](https://github.com/expo/expo/pull/26729) by [@EvanBacon](https://github.com/EvanBacon))
23
+ - Remove `compare-urls` and `url` dependencies in favor of built-in URL support. ([#26702](https://github.com/expo/expo/pull/26702) by [@EvanBacon](https://github.com/EvanBacon))
24
+ - Removed deprecated backward compatible Gradle settings. ([#28083](https://github.com/expo/expo/pull/28083) by [@kudo](https://github.com/kudo))
25
+
26
+ ## 12.8.2 - 2024-01-24
14
27
 
15
28
  ### πŸ’‘ Others
16
29
 
17
30
  - Updated `androidx.browser:browser` to `1.6.0` [#26619](https://github.com/expo/expo/pull/26619) by [@zoontek](https://github.com/zoontek)
18
31
 
19
- ## 12.8.1 β€” 2023-12-19
32
+ ## 12.8.1 - 2023-12-19
20
33
 
21
34
  _This version does not introduce any user-facing changes._
22
35
 
@@ -1,111 +1,25 @@
1
1
  apply plugin: 'com.android.library'
2
- apply plugin: 'kotlin-android'
3
- apply plugin: 'maven-publish'
4
2
 
5
3
  group = 'host.exp.exponent'
6
- version = '12.8.2'
4
+ version = '13.0.1'
7
5
 
8
6
 
9
7
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
10
- if (expoModulesCorePlugin.exists()) {
11
- apply from: expoModulesCorePlugin
12
- applyKotlinExpoModulesCorePlugin()
13
- // Remove this check, but keep the contents after SDK49 support is dropped
14
- if (safeExtGet("expoProvidesDefaultConfig", false)) {
15
- useExpoPublishing()
16
- useCoreDependencies()
17
- }
18
- }
19
-
20
- buildscript {
21
- // Simple helper that allows the root project to override versions declared by this library.
22
- ext.safeExtGet = { prop, fallback ->
23
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
24
- }
25
-
26
- // Ensures backward compatibility
27
- ext.getKotlinVersion = {
28
- if (ext.has("kotlinVersion")) {
29
- ext.kotlinVersion()
30
- } else {
31
- ext.safeExtGet("kotlinVersion", "1.8.10")
32
- }
33
- }
34
-
35
- repositories {
36
- mavenCentral()
37
- }
38
-
39
- dependencies {
40
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
41
- }
42
- }
43
-
44
- // Remove this if and it's contents, when support for SDK49 is dropped
45
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
46
- afterEvaluate {
47
- publishing {
48
- publications {
49
- release(MavenPublication) {
50
- from components.release
51
- }
52
- }
53
- repositories {
54
- maven {
55
- url = mavenLocal().url
56
- }
57
- }
58
- }
59
- }
60
- }
8
+ apply from: expoModulesCorePlugin
9
+ applyKotlinExpoModulesCorePlugin()
10
+ useCoreDependencies()
11
+ useDefaultAndroidSdkVersions()
12
+ useExpoPublishing()
61
13
 
62
14
  android {
63
- // Remove this if and it's contents, when support for SDK49 is dropped
64
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
65
- compileSdkVersion safeExtGet("compileSdkVersion", 34)
66
-
67
- defaultConfig {
68
- minSdkVersion safeExtGet("minSdkVersion", 23)
69
- targetSdkVersion safeExtGet("targetSdkVersion", 34)
70
- }
71
-
72
- publishing {
73
- singleVariant("release") {
74
- withSourcesJar()
75
- }
76
- }
77
-
78
- lintOptions {
79
- abortOnError false
80
- }
81
- }
82
-
83
- def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
84
- if (agpVersion.tokenize('.')[0].toInteger() < 8) {
85
- compileOptions {
86
- sourceCompatibility JavaVersion.VERSION_11
87
- targetCompatibility JavaVersion.VERSION_11
88
- }
89
-
90
- kotlinOptions {
91
- jvmTarget = JavaVersion.VERSION_11.majorVersion
92
- }
93
- }
94
-
95
15
  namespace "expo.modules.webbrowser"
96
16
  defaultConfig {
97
17
  versionCode 18
98
- versionName '12.8.2'
18
+ versionName '13.0.1'
99
19
  }
100
20
  }
101
21
 
102
22
  dependencies {
103
- // Remove this if and it's contents, when support for SDK49 is dropped
104
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
105
- implementation project(':expo-modules-core')
106
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
107
- }
108
-
109
23
  api "androidx.browser:browser:1.6.0"
110
24
 
111
25
  implementation "androidx.core:core-ktx:1.7.0"
@@ -65,7 +65,7 @@ class WebBrowserModule : Module() {
65
65
  }
66
66
 
67
67
  // throws CurrentActivityNotFoundException
68
- AsyncFunction("getCustomTabsSupportingBrowsersAsync") {
68
+ AsyncFunction<Bundle>("getCustomTabsSupportingBrowsersAsync") {
69
69
  val activities = customTabsResolver.customTabsResolvingActivities
70
70
  val services = customTabsResolver.customTabsResolvingServices
71
71
  val preferredPackage = customTabsResolver.getPreferredCustomTabsResolvingActivity(activities)
@@ -1,6 +1,6 @@
1
1
  import { WebBrowserAuthSessionResult, WebBrowserOpenOptions, WebBrowserResult } from './WebBrowser.types';
2
+ export declare function normalizeUrl(url: URL | Location): string;
2
3
  declare const _default: {
3
- readonly name: string;
4
4
  openBrowserAsync(url: string, browserParams?: WebBrowserOpenOptions): Promise<WebBrowserResult>;
5
5
  dismissAuthSession(): void;
6
6
  maybeCompleteAuthSession({ skipRedirectCheck }: {
@@ -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,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"}
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;AAa5B,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,UAG/C;;0BA2BQ,MAAM,kBACI,qBAAqB,GACnC,QAAQ,gBAAgB,CAAC;;;;QAasD;QAChF,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;QAC3B,OAAO,EAAE,MAAM,CAAC;KACjB;8BA8CM,MAAM,gBACG,MAAM,gBACN,qBAAqB,GAClC,QAAQ,2BAA2B,CAAC;;AArEzC,wBAkKE;AAoIF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAY3E"}
@@ -1,6 +1,5 @@
1
- import compareUrls from 'compare-urls';
2
- import { CodedError, Platform } from 'expo-modules-core';
3
- import { AppState, Dimensions } from 'react-native';
1
+ import { CodedError } from 'expo-modules-core';
2
+ import { AppState } from 'react-native';
4
3
  import { WebBrowserResultType, } from './WebBrowser.types';
5
4
  const POPUP_WIDTH = 500;
6
5
  const POPUP_HEIGHT = 650;
@@ -9,6 +8,10 @@ const listenerMap = new Map();
9
8
  const getHandle = () => 'ExpoWebBrowserRedirectHandle';
10
9
  const getOriginUrlHandle = (hash) => `ExpoWebBrowser_OriginUrl_${hash}`;
11
10
  const getRedirectUrlHandle = (hash) => `ExpoWebBrowser_RedirectUrl_${hash}`;
11
+ export function normalizeUrl(url) {
12
+ const origin = url.origin.replace(url.protocol, '').replace(/^\/+/, '').replace(/\/+$/, '');
13
+ return (origin + decodeURI(url.pathname.replace(/\/{2,}/g, '/'))).toLowerCase();
14
+ }
12
15
  function dismissPopup() {
13
16
  if (!popupWindow) {
14
17
  return;
@@ -30,24 +33,22 @@ function dismissPopup() {
30
33
  }
31
34
  }
32
35
  export default {
33
- get name() {
34
- return 'ExpoWebBrowser';
35
- },
36
36
  async openBrowserAsync(url, browserParams = {}) {
37
- if (!Platform.isDOMAvailable)
37
+ if (typeof window === 'undefined') {
38
38
  return { type: WebBrowserResultType.CANCEL };
39
+ }
39
40
  const { windowName = '_blank', windowFeatures } = browserParams;
40
41
  const features = getPopupFeaturesString(windowFeatures);
41
42
  window.open(url, windowName, features);
42
43
  return { type: WebBrowserResultType.OPENED };
43
44
  },
44
45
  dismissAuthSession() {
45
- if (!Platform.isDOMAvailable)
46
+ if (typeof window === 'undefined')
46
47
  return;
47
48
  dismissPopup();
48
49
  },
49
50
  maybeCompleteAuthSession({ skipRedirectCheck }) {
50
- if (!Platform.isDOMAvailable) {
51
+ if (typeof window === 'undefined') {
51
52
  return {
52
53
  type: 'failed',
53
54
  message: 'Cannot use expo-web-browser in a non-browser environment',
@@ -61,8 +62,8 @@ export default {
61
62
  if (skipRedirectCheck !== true) {
62
63
  const redirectUrl = window.localStorage.getItem(getRedirectUrlHandle(handle));
63
64
  // Compare the original redirect url against the current url with it's query params removed.
64
- const currentUrl = window.location.origin + window.location.pathname;
65
- if (!compareUrls(redirectUrl, currentUrl)) {
65
+ const currentUrl = normalizeUrl(window.location);
66
+ if (redirectUrl !== currentUrl) {
66
67
  return {
67
68
  type: 'failed',
68
69
  message: `Current URL "${currentUrl}" and original redirect URL "${redirectUrl}" do not match.`,
@@ -83,7 +84,7 @@ export default {
83
84
  },
84
85
  // This method should be invoked from user input.
85
86
  async openAuthSessionAsync(url, redirectUrl, openOptions) {
86
- if (!Platform.isDOMAvailable)
87
+ if (typeof window === 'undefined')
87
88
  return { type: WebBrowserResultType.CANCEL };
88
89
  redirectUrl = redirectUrl ?? getRedirectUrlFromUrlOrGenerate(url);
89
90
  if (popupWindow == null || popupWindow?.closed) {
@@ -102,8 +103,18 @@ export default {
102
103
  const state = await getStateFromUrlOrGenerateAsync(url);
103
104
  // Save handle for session
104
105
  window.localStorage.setItem(getHandle(), state);
106
+ const normalizedRedirectUrl = (() => {
107
+ if (!redirectUrl)
108
+ return redirectUrl;
109
+ try {
110
+ return normalizeUrl(new URL(redirectUrl));
111
+ }
112
+ catch {
113
+ return redirectUrl;
114
+ }
115
+ })();
105
116
  // Save redirect Url for further verification
106
- window.localStorage.setItem(getRedirectUrlHandle(state), redirectUrl);
117
+ window.localStorage.setItem(getRedirectUrlHandle(state), normalizedRedirectUrl);
107
118
  return new Promise(async (resolve) => {
108
119
  // Create a listener for messages sent from the popup
109
120
  const listener = (event) => {
@@ -159,7 +170,7 @@ export default {
159
170
  };
160
171
  // Crypto
161
172
  function isCryptoAvailable() {
162
- if (!Platform.isDOMAvailable)
173
+ if (typeof window === 'undefined')
163
174
  return false;
164
175
  return !!window?.crypto;
165
176
  }
@@ -190,7 +201,7 @@ function getRedirectUrlFromUrlOrGenerate(inputUrl) {
190
201
  const CHARSET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
191
202
  async function generateStateAsync() {
192
203
  if (!isSubtleCryptoAvailable()) {
193
- throw new CodedError('ERR_WEB_BROWSER_CRYPTO', `The current environment doesn't support crypto. Ensure you are running from a secure origin (https).`);
204
+ throw new CodedError('ERR_WEB_BROWSER_CRYPTO', `The current environment doesn't support crypto. Ensure you are running from a secure origin (localhost/https).`);
194
205
  }
195
206
  const encoder = new TextEncoder();
196
207
  const data = generateRandom(10);
@@ -248,9 +259,8 @@ function getPopupFeaturesString(options) {
248
259
  const windowFeatures = normalizePopupFeaturesString(options);
249
260
  const width = windowFeatures.width ?? POPUP_WIDTH;
250
261
  const height = windowFeatures.height ?? POPUP_HEIGHT;
251
- const dimensions = Dimensions.get('screen');
252
- const top = windowFeatures.top ?? Math.max(0, (dimensions.height - height) * 0.5);
253
- const left = windowFeatures.left ?? Math.max(0, (dimensions.width - width) * 0.5);
262
+ const top = windowFeatures.top ?? Math.max(0, (window.screen.height - height) * 0.5);
263
+ const left = windowFeatures.left ?? Math.max(0, (window.screen.width - width) * 0.5);
254
264
  // Create a reasonable popup
255
265
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features
256
266
  return featureObjectToString({
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoWebBrowser.web.js","sourceRoot":"","sources":["../src/ExpoWebBrowser.web.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAA2C,MAAM,cAAc,CAAC;AAE7F,OAAO,EAIL,oBAAoB,GAErB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB,IAAI,WAAW,GAAkB,IAAI,CAAC;AAEtC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;AAE9B,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,8BAA8B,CAAC;AACvD,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,4BAA4B,IAAI,EAAE,CAAC;AAChF,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,8BAA8B,IAAI,EAAE,CAA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QACrC,UAAU,EAAE,cAAc,CAAC,UAAU,IAAI,KAAK;QAC9C,GAAG;QACH,IAAI;QACJ,KAAK;QACL,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,QAA6B;IACjE,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAS,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;QAC5D,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;YAC9B,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;SAC9B;QACD,IAAI,OAAO,IAAI,KAAK,EAAE;YACpB,IAAI,IAAI;gBAAE,IAAI,IAAI,GAAG,CAAC;YACtB,OAAO,GAAG,IAAI,GAAG,OAAO,IAAI,KAAK,EAAE,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import compareUrls from 'compare-urls';\nimport { CodedError, Platform } from 'expo-modules-core';\nimport { AppState, Dimensions, AppStateStatus, NativeEventSubscription } from 'react-native';\n\nimport {\n WebBrowserAuthSessionResult,\n WebBrowserOpenOptions,\n WebBrowserResult,\n WebBrowserResultType,\n WebBrowserWindowFeatures,\n} from './WebBrowser.types';\n\nconst POPUP_WIDTH = 500;\nconst POPUP_HEIGHT = 650;\n\nlet popupWindow: Window | null = null;\n\nconst listenerMap = new Map();\n\nconst getHandle = () => 'ExpoWebBrowserRedirectHandle';\nconst getOriginUrlHandle = (hash: string) => `ExpoWebBrowser_OriginUrl_${hash}`;\nconst getRedirectUrlHandle = (hash: string) => `ExpoWebBrowser_RedirectUrl_${hash}`;\n\nfunction dismissPopup() {\n if (!popupWindow) {\n return;\n }\n popupWindow.close();\n if (listenerMap.has(popupWindow)) {\n const { listener, appStateSubscription, interval } = listenerMap.get(popupWindow);\n clearInterval(interval);\n window.removeEventListener('message', listener);\n (appStateSubscription as NativeEventSubscription).remove();\n listenerMap.delete(popupWindow);\n\n const handle = window.localStorage.getItem(getHandle());\n if (handle) {\n window.localStorage.removeItem(getHandle());\n window.localStorage.removeItem(getOriginUrlHandle(handle));\n window.localStorage.removeItem(getRedirectUrlHandle(handle));\n }\n\n popupWindow = null;\n }\n}\n\nexport default {\n get name() {\n return 'ExpoWebBrowser';\n },\n async openBrowserAsync(\n url: string,\n browserParams: WebBrowserOpenOptions = {}\n ): Promise<WebBrowserResult> {\n if (!Platform.isDOMAvailable) return { type: WebBrowserResultType.CANCEL };\n const { windowName = '_blank', windowFeatures } = browserParams;\n const features = getPopupFeaturesString(windowFeatures);\n window.open(url, windowName, features);\n return { type: WebBrowserResultType.OPENED };\n },\n dismissAuthSession() {\n if (!Platform.isDOMAvailable) return;\n dismissPopup();\n },\n maybeCompleteAuthSession({ skipRedirectCheck }: { skipRedirectCheck?: boolean }): {\n type: 'success' | 'failed';\n message: string;\n } {\n if (!Platform.isDOMAvailable) {\n return {\n type: 'failed',\n message: 'Cannot use expo-web-browser in a non-browser environment',\n };\n }\n const handle = window.localStorage.getItem(getHandle());\n\n if (!handle) {\n return { type: 'failed', message: 'No auth session is currently in progress' };\n }\n\n const url = window.location.href;\n\n if (skipRedirectCheck !== true) {\n const redirectUrl = window.localStorage.getItem(getRedirectUrlHandle(handle));\n // Compare the original redirect url against the current url with it's query params removed.\n const currentUrl = window.location.origin + window.location.pathname;\n if (!compareUrls(redirectUrl, currentUrl)) {\n return {\n type: 'failed',\n message: `Current URL \"${currentUrl}\" and original redirect URL \"${redirectUrl}\" do not match.`,\n };\n }\n }\n\n // Save the link for app state listener\n window.localStorage.setItem(getOriginUrlHandle(handle), url);\n\n // Get the window that created the current popup\n const parent = window.opener ?? window.parent;\n if (!parent) {\n throw new CodedError(\n 'ERR_WEB_BROWSER_REDIRECT',\n `The window cannot complete the redirect request because the invoking window doesn't have a reference to it's parent. This can happen if the parent window was reloaded.`\n );\n }\n // Send the URL back to the opening window.\n parent.postMessage({ url, expoSender: handle }, parent.location.toString());\n return { type: 'success', message: `Attempting to complete auth` };\n\n // Maybe set timer to throw an error if the window is still open after attempting to complete.\n },\n // This method should be invoked from user input.\n async openAuthSessionAsync(\n url: string,\n redirectUrl?: string,\n openOptions?: WebBrowserOpenOptions\n ): Promise<WebBrowserAuthSessionResult> {\n if (!Platform.isDOMAvailable) return { type: WebBrowserResultType.CANCEL };\n\n redirectUrl = redirectUrl ?? getRedirectUrlFromUrlOrGenerate(url);\n\n if (popupWindow == null || popupWindow?.closed) {\n const features = getPopupFeaturesString(openOptions?.windowFeatures);\n popupWindow = window.open(url, openOptions?.windowName, features);\n\n if (popupWindow) {\n try {\n popupWindow.focus();\n } catch {}\n } else {\n throw new CodedError(\n 'ERR_WEB_BROWSER_BLOCKED',\n 'Popup window was blocked by the browser or failed to open. This can happen in mobile browsers when the window.open() method was invoked too long after a user input was fired.'\n );\n }\n }\n\n const state = await getStateFromUrlOrGenerateAsync(url);\n\n // Save handle for session\n window.localStorage.setItem(getHandle(), state);\n // Save redirect Url for further verification\n window.localStorage.setItem(getRedirectUrlHandle(state), redirectUrl);\n\n return new Promise(async (resolve) => {\n // Create a listener for messages sent from the popup\n const listener = (event: MessageEvent) => {\n if (!event.isTrusted) return;\n // Ensure we trust the sender.\n if (event.origin !== window.location.origin) {\n return;\n }\n const { data } = event;\n // Use a crypto hash to invalid message.\n const handle = window.localStorage.getItem(getHandle());\n // Ensure the sender is also from expo-web-browser\n if (data.expoSender === handle) {\n dismissPopup();\n resolve({ type: 'success', url: data.url });\n }\n };\n\n // Add a listener for receiving messages from the popup.\n window.addEventListener('message', listener, false);\n\n // Create an app state listener as a fallback to the popup listener\n const appStateListener = (state: AppStateStatus) => {\n if (state !== 'active') {\n return;\n }\n const handle = window.localStorage.getItem(getHandle());\n if (handle) {\n const url = window.localStorage.getItem(getOriginUrlHandle(handle));\n if (url) {\n dismissPopup();\n resolve({ type: 'success', url });\n }\n }\n };\n\n const appStateSubscription = AppState.addEventListener('change', appStateListener);\n\n // Check if the window has been closed every second.\n const interval = setInterval(() => {\n if (popupWindow?.closed) {\n if (resolve) resolve({ type: WebBrowserResultType.DISMISS });\n clearInterval(interval);\n dismissPopup();\n }\n }, 1000);\n\n // Store the listener and interval for clean up.\n listenerMap.set(popupWindow, {\n listener,\n interval,\n appStateSubscription,\n });\n });\n },\n};\n\n// Crypto\nfunction isCryptoAvailable(): boolean {\n if (!Platform.isDOMAvailable) return false;\n return !!(window?.crypto as any);\n}\n\nfunction isSubtleCryptoAvailable(): boolean {\n if (!isCryptoAvailable()) return false;\n return !!(window.crypto.subtle as any);\n}\n\nasync function getStateFromUrlOrGenerateAsync(inputUrl: string): Promise<string> {\n const url = new URL(inputUrl);\n if (url.searchParams.has('state') && typeof url.searchParams.get('state') === 'string') {\n // Ensure we reuse the auth state if it's passed in.\n return url.searchParams.get('state')!;\n }\n // Generate a crypto state for verifying the return popup.\n return await generateStateAsync();\n}\n\nfunction getRedirectUrlFromUrlOrGenerate(inputUrl: string): string {\n const url = new URL(inputUrl);\n if (\n url.searchParams.has('redirect_uri') &&\n typeof url.searchParams.get('redirect_uri') === 'string'\n ) {\n // Ensure we reuse the redirect_uri if it's passed in the input url.\n return url.searchParams.get('redirect_uri')!;\n }\n // Emulate how native uses Constants.linkingUrl\n return location.origin + location.pathname;\n}\n\nconst CHARSET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\nasync function generateStateAsync(): Promise<string> {\n if (!isSubtleCryptoAvailable()) {\n throw new CodedError(\n 'ERR_WEB_BROWSER_CRYPTO',\n `The current environment doesn't support crypto. Ensure you are running from a secure origin (https).`\n );\n }\n const encoder = new TextEncoder();\n\n const data = generateRandom(10);\n const buffer = encoder.encode(data);\n const hashedData = await crypto.subtle.digest('SHA-256', buffer);\n const state = btoa(String.fromCharCode(...new Uint8Array(hashedData)));\n return state;\n}\n\nfunction generateRandom(size: number): string {\n let arr = new Uint8Array(size);\n if (arr.byteLength !== arr.length) {\n arr = new Uint8Array(arr.buffer);\n }\n const array = new Uint8Array(arr.length);\n if (isCryptoAvailable()) {\n window.crypto.getRandomValues(array);\n } else {\n for (let i = 0; i < size; i += 1) {\n array[i] = (Math.random() * CHARSET.length) | 0;\n }\n }\n return bufferToString(array);\n}\n\nfunction bufferToString(buffer): string {\n const state: string[] = [];\n for (let i = 0; i < buffer.byteLength; i += 1) {\n const index = buffer[i] % CHARSET.length;\n state.push(CHARSET[index]);\n }\n return state.join('');\n}\n\n// Window Features\n\n// Ensure feature string is an object\nfunction normalizePopupFeaturesString(\n options?: WebBrowserWindowFeatures | string\n): Record<string, any> {\n let windowFeatures: Record<string, any> = {};\n // This should be avoided because it adds extra time to the popup command.\n if (typeof options === 'string') {\n // Convert string of `key=value,foo=bar` into an object\n const windowFeaturePairs = options.split(',');\n for (const pair of windowFeaturePairs) {\n const [key, value] = pair.trim().split('=');\n if (key && value) {\n windowFeatures[key] = value;\n }\n }\n } else if (options) {\n windowFeatures = options;\n }\n return windowFeatures;\n}\n\n// Apply default values to the input feature set\nfunction getPopupFeaturesString(options?: WebBrowserWindowFeatures | string): string {\n const windowFeatures = normalizePopupFeaturesString(options);\n\n const width = windowFeatures.width ?? POPUP_WIDTH;\n const height = windowFeatures.height ?? POPUP_HEIGHT;\n\n const dimensions = Dimensions.get('screen');\n const top = windowFeatures.top ?? Math.max(0, (dimensions.height - height) * 0.5);\n const left = windowFeatures.left ?? Math.max(0, (dimensions.width - width) * 0.5);\n\n // Create a reasonable popup\n // https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features\n return featureObjectToString({\n ...windowFeatures,\n // Toolbar buttons (Back, Forward, Reload, Stop buttons).\n toolbar: windowFeatures.toolbar ?? 'no',\n menubar: windowFeatures.menubar ?? 'no',\n // Shows the location bar or the address bar.\n location: windowFeatures.location ?? 'yes',\n resizable: windowFeatures.resizable ?? 'yes',\n // If this feature is on, then the new secondary window has a status bar.\n status: windowFeatures.status ?? 'no',\n scrollbars: windowFeatures.scrollbars ?? 'yes',\n top,\n left,\n width,\n height,\n });\n}\n\nexport function featureObjectToString(features: Record<string, any>): string {\n return Object.keys(features).reduce<string>((prev, current) => {\n let value = features[current];\n if (typeof value === 'boolean') {\n value = value ? 'yes' : 'no';\n }\n if (current && value) {\n if (prev) prev += ',';\n return `${prev}${current}=${value}`;\n }\n return prev;\n }, '');\n}\n"]}
1
+ {"version":3,"file":"ExpoWebBrowser.web.js","sourceRoot":"","sources":["../src/ExpoWebBrowser.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,EAIL,oBAAoB,GAErB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB,IAAI,WAAW,GAAkB,IAAI,CAAC;AAEtC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;AAE9B,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,8BAA8B,CAAC;AACvD,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,4BAA4B,IAAI,EAAE,CAAC;AAChF,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,8BAA8B,IAAI,EAAE,CAAC;AAEpF,MAAM,UAAU,YAAY,CAAC,GAAmB;IAC9C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC5F,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,QAAQ,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I,IAAI;QACvC,6CAA6C;QAC7C,QAAQ,EAAE,cAAc,CAAC,QAAQ,IAAI,KAAK;QAC1C,SAAS,EAAE,cAAc,CAAC,SAAS,IAAI,KAAK;QAC5C,yEAAyE;QACzE,MAAM,EAAE,cAAc,CAAC,MAAM,IAAI,IAAI;QACrC,UAAU,EAAE,cAAc,CAAC,UAAU,IAAI,KAAK;QAC9C,GAAG;QACH,IAAI;QACJ,KAAK;QACL,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,QAA6B;IACjE,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAS,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;QAC5D,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;YAC9B,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;SAC9B;QACD,IAAI,OAAO,IAAI,KAAK,EAAE;YACpB,IAAI,IAAI;gBAAE,IAAI,IAAI,GAAG,CAAC;YACtB,OAAO,GAAG,IAAI,GAAG,OAAO,IAAI,KAAK,EAAE,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import { CodedError } from 'expo-modules-core';\nimport { AppState } from 'react-native';\nimport type { AppStateStatus, NativeEventSubscription } from 'react-native';\n\nimport {\n WebBrowserAuthSessionResult,\n WebBrowserOpenOptions,\n WebBrowserResult,\n WebBrowserResultType,\n WebBrowserWindowFeatures,\n} from './WebBrowser.types';\n\nconst POPUP_WIDTH = 500;\nconst POPUP_HEIGHT = 650;\n\nlet popupWindow: Window | null = null;\n\nconst listenerMap = new Map();\n\nconst getHandle = () => 'ExpoWebBrowserRedirectHandle';\nconst getOriginUrlHandle = (hash: string) => `ExpoWebBrowser_OriginUrl_${hash}`;\nconst getRedirectUrlHandle = (hash: string) => `ExpoWebBrowser_RedirectUrl_${hash}`;\n\nexport function normalizeUrl(url: URL | Location) {\n const origin = url.origin.replace(url.protocol, '').replace(/^\\/+/, '').replace(/\\/+$/, '');\n return (origin + decodeURI(url.pathname.replace(/\\/{2,}/g, '/'))).toLowerCase();\n}\n\nfunction dismissPopup() {\n if (!popupWindow) {\n return;\n }\n popupWindow.close();\n if (listenerMap.has(popupWindow)) {\n const { listener, appStateSubscription, interval } = listenerMap.get(popupWindow);\n clearInterval(interval);\n window.removeEventListener('message', listener);\n (appStateSubscription as NativeEventSubscription).remove();\n listenerMap.delete(popupWindow);\n\n const handle = window.localStorage.getItem(getHandle());\n if (handle) {\n window.localStorage.removeItem(getHandle());\n window.localStorage.removeItem(getOriginUrlHandle(handle));\n window.localStorage.removeItem(getRedirectUrlHandle(handle));\n }\n\n popupWindow = null;\n }\n}\n\nexport default {\n async openBrowserAsync(\n url: string,\n browserParams: WebBrowserOpenOptions = {}\n ): Promise<WebBrowserResult> {\n if (typeof window === 'undefined') {\n return { type: WebBrowserResultType.CANCEL };\n }\n const { windowName = '_blank', windowFeatures } = browserParams;\n const features = getPopupFeaturesString(windowFeatures);\n window.open(url, windowName, features);\n return { type: WebBrowserResultType.OPENED };\n },\n dismissAuthSession() {\n if (typeof window === 'undefined') return;\n dismissPopup();\n },\n maybeCompleteAuthSession({ skipRedirectCheck }: { skipRedirectCheck?: boolean }): {\n type: 'success' | 'failed';\n message: string;\n } {\n if (typeof window === 'undefined') {\n return {\n type: 'failed',\n message: 'Cannot use expo-web-browser in a non-browser environment',\n };\n }\n const handle = window.localStorage.getItem(getHandle());\n\n if (!handle) {\n return { type: 'failed', message: 'No auth session is currently in progress' };\n }\n\n const url = window.location.href;\n\n if (skipRedirectCheck !== true) {\n const redirectUrl = window.localStorage.getItem(getRedirectUrlHandle(handle));\n // Compare the original redirect url against the current url with it's query params removed.\n const currentUrl = normalizeUrl(window.location);\n if (redirectUrl !== currentUrl) {\n return {\n type: 'failed',\n message: `Current URL \"${currentUrl}\" and original redirect URL \"${redirectUrl}\" do not match.`,\n };\n }\n }\n\n // Save the link for app state listener\n window.localStorage.setItem(getOriginUrlHandle(handle), url);\n\n // Get the window that created the current popup\n const parent = window.opener ?? window.parent;\n if (!parent) {\n throw new CodedError(\n 'ERR_WEB_BROWSER_REDIRECT',\n `The window cannot complete the redirect request because the invoking window doesn't have a reference to it's parent. This can happen if the parent window was reloaded.`\n );\n }\n // Send the URL back to the opening window.\n parent.postMessage({ url, expoSender: handle }, parent.location.toString());\n return { type: 'success', message: `Attempting to complete auth` };\n\n // Maybe set timer to throw an error if the window is still open after attempting to complete.\n },\n // This method should be invoked from user input.\n async openAuthSessionAsync(\n url: string,\n redirectUrl?: string,\n openOptions?: WebBrowserOpenOptions\n ): Promise<WebBrowserAuthSessionResult> {\n if (typeof window === 'undefined') return { type: WebBrowserResultType.CANCEL };\n\n redirectUrl = redirectUrl ?? getRedirectUrlFromUrlOrGenerate(url);\n\n if (popupWindow == null || popupWindow?.closed) {\n const features = getPopupFeaturesString(openOptions?.windowFeatures);\n popupWindow = window.open(url, openOptions?.windowName, features);\n\n if (popupWindow) {\n try {\n popupWindow.focus();\n } catch {}\n } else {\n throw new CodedError(\n 'ERR_WEB_BROWSER_BLOCKED',\n 'Popup window was blocked by the browser or failed to open. This can happen in mobile browsers when the window.open() method was invoked too long after a user input was fired.'\n );\n }\n }\n\n const state = await getStateFromUrlOrGenerateAsync(url);\n\n // Save handle for session\n window.localStorage.setItem(getHandle(), state);\n\n const normalizedRedirectUrl = (() => {\n if (!redirectUrl) return redirectUrl;\n try {\n return normalizeUrl(new URL(redirectUrl));\n } catch {\n return redirectUrl;\n }\n })();\n\n // Save redirect Url for further verification\n window.localStorage.setItem(getRedirectUrlHandle(state), normalizedRedirectUrl);\n\n return new Promise(async (resolve) => {\n // Create a listener for messages sent from the popup\n const listener = (event: MessageEvent) => {\n if (!event.isTrusted) return;\n // Ensure we trust the sender.\n if (event.origin !== window.location.origin) {\n return;\n }\n const { data } = event;\n // Use a crypto hash to invalid message.\n const handle = window.localStorage.getItem(getHandle());\n // Ensure the sender is also from expo-web-browser\n if (data.expoSender === handle) {\n dismissPopup();\n resolve({ type: 'success', url: data.url });\n }\n };\n\n // Add a listener for receiving messages from the popup.\n window.addEventListener('message', listener, false);\n\n // Create an app state listener as a fallback to the popup listener\n const appStateListener = (state: AppStateStatus) => {\n if (state !== 'active') {\n return;\n }\n const handle = window.localStorage.getItem(getHandle());\n if (handle) {\n const url = window.localStorage.getItem(getOriginUrlHandle(handle));\n if (url) {\n dismissPopup();\n resolve({ type: 'success', url });\n }\n }\n };\n\n const appStateSubscription = AppState.addEventListener('change', appStateListener);\n\n // Check if the window has been closed every second.\n const interval = setInterval(() => {\n if (popupWindow?.closed) {\n if (resolve) resolve({ type: WebBrowserResultType.DISMISS });\n clearInterval(interval);\n dismissPopup();\n }\n }, 1000);\n\n // Store the listener and interval for clean up.\n listenerMap.set(popupWindow, {\n listener,\n interval,\n appStateSubscription,\n });\n });\n },\n};\n\n// Crypto\nfunction isCryptoAvailable(): boolean {\n if (typeof window === 'undefined') return false;\n return !!(window?.crypto as any);\n}\n\nfunction isSubtleCryptoAvailable(): boolean {\n if (!isCryptoAvailable()) return false;\n return !!(window.crypto.subtle as any);\n}\n\nasync function getStateFromUrlOrGenerateAsync(inputUrl: string): Promise<string> {\n const url = new URL(inputUrl);\n if (url.searchParams.has('state') && typeof url.searchParams.get('state') === 'string') {\n // Ensure we reuse the auth state if it's passed in.\n return url.searchParams.get('state')!;\n }\n // Generate a crypto state for verifying the return popup.\n return await generateStateAsync();\n}\n\nfunction getRedirectUrlFromUrlOrGenerate(inputUrl: string): string {\n const url = new URL(inputUrl);\n if (\n url.searchParams.has('redirect_uri') &&\n typeof url.searchParams.get('redirect_uri') === 'string'\n ) {\n // Ensure we reuse the redirect_uri if it's passed in the input url.\n return url.searchParams.get('redirect_uri')!;\n }\n // Emulate how native uses Constants.linkingUrl\n return location.origin + location.pathname;\n}\n\nconst CHARSET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\nasync function generateStateAsync(): Promise<string> {\n if (!isSubtleCryptoAvailable()) {\n throw new CodedError(\n 'ERR_WEB_BROWSER_CRYPTO',\n `The current environment doesn't support crypto. Ensure you are running from a secure origin (localhost/https).`\n );\n }\n const encoder = new TextEncoder();\n\n const data = generateRandom(10);\n const buffer = encoder.encode(data);\n const hashedData = await crypto.subtle.digest('SHA-256', buffer);\n const state = btoa(String.fromCharCode(...new Uint8Array(hashedData)));\n return state;\n}\n\nfunction generateRandom(size: number): string {\n let arr = new Uint8Array(size);\n if (arr.byteLength !== arr.length) {\n arr = new Uint8Array(arr.buffer);\n }\n const array = new Uint8Array(arr.length);\n if (isCryptoAvailable()) {\n window.crypto.getRandomValues(array);\n } else {\n for (let i = 0; i < size; i += 1) {\n array[i] = (Math.random() * CHARSET.length) | 0;\n }\n }\n return bufferToString(array);\n}\n\nfunction bufferToString(buffer): string {\n const state: string[] = [];\n for (let i = 0; i < buffer.byteLength; i += 1) {\n const index = buffer[i] % CHARSET.length;\n state.push(CHARSET[index]);\n }\n return state.join('');\n}\n\n// Window Features\n\n// Ensure feature string is an object\nfunction normalizePopupFeaturesString(\n options?: WebBrowserWindowFeatures | string\n): Record<string, any> {\n let windowFeatures: Record<string, any> = {};\n // This should be avoided because it adds extra time to the popup command.\n if (typeof options === 'string') {\n // Convert string of `key=value,foo=bar` into an object\n const windowFeaturePairs = options.split(',');\n for (const pair of windowFeaturePairs) {\n const [key, value] = pair.trim().split('=');\n if (key && value) {\n windowFeatures[key] = value;\n }\n }\n } else if (options) {\n windowFeatures = options;\n }\n return windowFeatures;\n}\n\n// Apply default values to the input feature set\nfunction getPopupFeaturesString(options?: WebBrowserWindowFeatures | string): string {\n const windowFeatures = normalizePopupFeaturesString(options);\n\n const width = windowFeatures.width ?? POPUP_WIDTH;\n const height = windowFeatures.height ?? POPUP_HEIGHT;\n\n const top = windowFeatures.top ?? Math.max(0, (window.screen.height - height) * 0.5);\n const left = windowFeatures.left ?? Math.max(0, (window.screen.width - width) * 0.5);\n\n // Create a reasonable popup\n // https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features\n return featureObjectToString({\n ...windowFeatures,\n // Toolbar buttons (Back, Forward, Reload, Stop buttons).\n toolbar: windowFeatures.toolbar ?? 'no',\n menubar: windowFeatures.menubar ?? 'no',\n // Shows the location bar or the address bar.\n location: windowFeatures.location ?? 'yes',\n resizable: windowFeatures.resizable ?? 'yes',\n // If this feature is on, then the new secondary window has a status bar.\n status: windowFeatures.status ?? 'no',\n scrollbars: windowFeatures.scrollbars ?? 'yes',\n top,\n left,\n width,\n height,\n });\n}\n\nexport function featureObjectToString(features: Record<string, any>): string {\n return Object.keys(features).reduce<string>((prev, current) => {\n let value = features[current];\n if (typeof value === 'boolean') {\n value = value ? 'yes' : 'no';\n }\n if (current && value) {\n if (prev) prev += ',';\n return `${prev}${current}=${value}`;\n }\n return prev;\n }, '');\n}\n"]}
@@ -82,7 +82,7 @@ export declare function dismissBrowser(): void;
82
82
  * Using `Linking.addEventListener` is not needed and can have side effects.
83
83
  *
84
84
  * # On web:
85
- * > This API can only be used in a secure environment (`https`). You can use expo `start:web --https`
85
+ * > This API can only be used in a secure environment (localhost/https).
86
86
  * to test this. Otherwise, an error with code [`ERR_WEB_BROWSER_CRYPTO`](#errwebbrowsercrypto) will be thrown.
87
87
  * This will use the browser's [`window.open()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) API.
88
88
  * - _Desktop_: This will create a new web popup window in the browser that can be closed later using `WebBrowser.maybeCompleteAuthSession()`.
@@ -166,7 +166,7 @@ export function dismissBrowser() {
166
166
  * Using `Linking.addEventListener` is not needed and can have side effects.
167
167
  *
168
168
  * # On web:
169
- * > This API can only be used in a secure environment (`https`). You can use expo `start:web --https`
169
+ * > This API can only be used in a secure environment (localhost/https).
170
170
  * to test this. Otherwise, an error with code [`ERR_WEB_BROWSER_CRYPTO`](#errwebbrowsercrypto) will be thrown.
171
171
  * This will use the browser's [`window.open()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) API.
172
172
  * - _Desktop_: This will create a new web popup window in the browser that can be closed later using `WebBrowser.maybeCompleteAuthSession()`.
@@ -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,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,CAAC;KACrF;IACD,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QAC7B,OAAO,uBAAuB,CAAC;KAChC;SAAM;QACL,OAAO,MAAM,kBAAkB,CAAC,oCAAoC,EAAE,CAAC;KACxE;AACH,CAAC;AAED,cAAc;AACd;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,cAAuB;IACvD,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE;QACnC,MAAM,IAAI,mBAAmB,CAAC,YA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AAqB,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 Android:\n * This will be done using a \"custom Chrome tabs\" browser, [AppState](https://reactnative.dev/docs/appstate),\n * and [Linking](./linking/) APIs.\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 * For example, `demo://` not `https://` protocol.\n * Using `Linking.addEventListener` is not needed and can have side effects.\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
+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E;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 Android:\n * This will be done using a \"custom Chrome tabs\" browser, [AppState](https://reactnative.dev/docs/appstate),\n * and [Linking](./linking/) APIs.\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 * For example, `demo://` not `https://` protocol.\n * Using `Linking.addEventListener` is not needed and can have side effects.\n *\n * # On web:\n * > This API can only be used in a secure environment (localhost/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"]}
@@ -90,7 +90,7 @@ export type AuthSessionOpenOptions = WebBrowserOpenOptions & {
90
90
  * Whether the request is honored depends on the user’s default web browser.
91
91
  *
92
92
  * @default false
93
- * @platform ios 13+
93
+ * @platform ios
94
94
  */
95
95
  preferEphemeralSession?: boolean;
96
96
  };
@@ -174,7 +174,7 @@ export declare enum WebBrowserPresentationStyle {
174
174
  * The default presentation style chosen by the system.
175
175
  * On older iOS versions, falls back to `WebBrowserPresentationStyle.FullScreen`.
176
176
  *
177
- * @platform ios 13+
177
+ * @platform ios
178
178
  */
179
179
  AUTOMATIC = "automatic"
180
180
  }
@@ -55,7 +55,7 @@ export var WebBrowserPresentationStyle;
55
55
  * The default presentation style chosen by the system.
56
56
  * On older iOS versions, falls back to `WebBrowserPresentationStyle.FullScreen`.
57
57
  *
58
- * @platform ios 13+
58
+ * @platform ios
59
59
  */
60
60
  WebBrowserPresentationStyle["AUTOMATIC"] = "automatic";
61
61
  })(WebBrowserPresentationStyle || (WebBrowserPresentationStyle = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"WebBrowser.types.js","sourceRoot":"","sources":["../src/WebBrowser.types.ts"],"names":[],"mappings":"AAoIA,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;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAN,IAAY,2BAoCX;AApCD,WAAY,2BAA2B;IACrC;;OAEG;IACH,yDAA0B,CAAA;IAC1B;;OAEG;IACH,uDAAwB,CAAA;IACxB;;OAEG;IACH,uDAAwB,CAAA;IACxB;;OAEG;IACH,iEAAkC,CAAA;IAClC;;OAEG;IACH,kEAAmC,CAAA;IACnC;;OAEG;IACH,0EAA2C,CAAA;IAC3C;;OAEG;IACH,kDAAmB,CAAA;IACnB;;;;;OAKG;IACH,sDAAuB,CAAA;AACzB,CAAC,EApCW,2BAA2B,KAA3B,2BAA2B,QAoCtC","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. Supports React Native [color formats](https://reactnative.dev/docs/colors).\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. Supports React Native [color formats](https://reactnative.dev/docs/colors).\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. Supports React Native [color formats](https://reactnative.dev/docs/colors).\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 * The [presentation style](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle)\n * of the browser window.\n * @default WebBrowser.WebBrowserPresentationStyle.OverFullScreen\n * @platform ios\n */\n presentationStyle?: WebBrowserPresentationStyle;\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\n/**\n * If there is no native AuthSession implementation available (which is the case on Android) the params inherited from\n * [`WebBrowserOpenOptions`](#webbrowseropenoptions) will be used in the browser polyfill. Otherwise, the browser parameters will be ignored.\n */\nexport type AuthSessionOpenOptions = WebBrowserOpenOptions & {\n /**\n * Determines whether the session should ask the browser for a private authentication session.\n * 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.\n * Whether the request is honored depends on the user’s default web browser.\n *\n * @default false\n * @platform ios 13+\n */\n preferEphemeralSession?: boolean;\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\n/**\n * A browser presentation style. Its values are directly mapped to the [`UIModalPresentationStyle`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle).\n *\n * @platform ios\n */\nexport enum WebBrowserPresentationStyle {\n /**\n * A presentation style in which the presented browser covers the screen.\n */\n FULL_SCREEN = 'fullScreen',\n /**\n * A presentation style that partially covers the underlying content.\n */\n PAGE_SHEET = 'pageSheet',\n /**\n * A presentation style that displays the browser centered in the screen.\n */\n FORM_SHEET = 'formSheet',\n /**\n * A presentation style where the browser is displayed over the app's content.\n */\n CURRENT_CONTEXT = 'currentContext',\n /**\n * A presentation style in which the browser view covers the screen.\n */\n OVER_FULL_SCREEN = 'overFullScreen',\n /**\n * A presentation style where the browser is displayed over the app's content.\n */\n OVER_CURRENT_CONTEXT = 'overCurrentContext',\n /**\n * A presentation style where the browser is displayed in a popover view.\n */\n POPOVER = 'popover',\n /**\n * The default presentation style chosen by the system.\n * On older iOS versions, falls back to `WebBrowserPresentationStyle.FullScreen`.\n *\n * @platform ios 13+\n */\n AUTOMATIC = 'automatic',\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"]}
1
+ {"version":3,"file":"WebBrowser.types.js","sourceRoot":"","sources":["../src/WebBrowser.types.ts"],"names":[],"mappings":"AAoIA,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;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAN,IAAY,2BAoCX;AApCD,WAAY,2BAA2B;IACrC;;OAEG;IACH,yDAA0B,CAAA;IAC1B;;OAEG;IACH,uDAAwB,CAAA;IACxB;;OAEG;IACH,uDAAwB,CAAA;IACxB;;OAEG;IACH,iEAAkC,CAAA;IAClC;;OAEG;IACH,kEAAmC,CAAA;IACnC;;OAEG;IACH,0EAA2C,CAAA;IAC3C;;OAEG;IACH,kDAAmB,CAAA;IACnB;;;;;OAKG;IACH,sDAAuB,CAAA;AACzB,CAAC,EApCW,2BAA2B,KAA3B,2BAA2B,QAoCtC","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. Supports React Native [color formats](https://reactnative.dev/docs/colors).\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. Supports React Native [color formats](https://reactnative.dev/docs/colors).\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. Supports React Native [color formats](https://reactnative.dev/docs/colors).\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 * The [presentation style](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle)\n * of the browser window.\n * @default WebBrowser.WebBrowserPresentationStyle.OverFullScreen\n * @platform ios\n */\n presentationStyle?: WebBrowserPresentationStyle;\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\n/**\n * If there is no native AuthSession implementation available (which is the case on Android) the params inherited from\n * [`WebBrowserOpenOptions`](#webbrowseropenoptions) will be used in the browser polyfill. Otherwise, the browser parameters will be ignored.\n */\nexport type AuthSessionOpenOptions = WebBrowserOpenOptions & {\n /**\n * Determines whether the session should ask the browser for a private authentication session.\n * 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.\n * Whether the request is honored depends on the user’s default web browser.\n *\n * @default false\n * @platform ios\n */\n preferEphemeralSession?: boolean;\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\n/**\n * A browser presentation style. Its values are directly mapped to the [`UIModalPresentationStyle`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle).\n *\n * @platform ios\n */\nexport enum WebBrowserPresentationStyle {\n /**\n * A presentation style in which the presented browser covers the screen.\n */\n FULL_SCREEN = 'fullScreen',\n /**\n * A presentation style that partially covers the underlying content.\n */\n PAGE_SHEET = 'pageSheet',\n /**\n * A presentation style that displays the browser centered in the screen.\n */\n FORM_SHEET = 'formSheet',\n /**\n * A presentation style where the browser is displayed over the app's content.\n */\n CURRENT_CONTEXT = 'currentContext',\n /**\n * A presentation style in which the browser view covers the screen.\n */\n OVER_FULL_SCREEN = 'overFullScreen',\n /**\n * A presentation style where the browser is displayed over the app's content.\n */\n OVER_CURRENT_CONTEXT = 'overCurrentContext',\n /**\n * A presentation style where the browser is displayed in a popover view.\n */\n POPOVER = 'popover',\n /**\n * The default presentation style chosen by the system.\n * On older iOS versions, falls back to `WebBrowserPresentationStyle.FullScreen`.\n *\n * @platform ios\n */\n AUTOMATIC = 'automatic',\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": "12.8.2",
3
+ "version": "13.0.1",
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",
@@ -35,15 +35,11 @@
35
35
  "jest": {
36
36
  "preset": "expo-module-scripts"
37
37
  },
38
- "dependencies": {
39
- "compare-urls": "^2.0.0",
40
- "url": "^0.11.0"
41
- },
42
38
  "devDependencies": {
43
39
  "expo-module-scripts": "^3.0.0"
44
40
  },
45
41
  "peerDependencies": {
46
42
  "expo": "*"
47
43
  },
48
- "gitHead": "dd467f9665171a9729dad8837ea595cd046936f4"
44
+ "gitHead": "ee4f30ef3b5fa567ad1bf94794197f7683fdd481"
49
45
  }
@@ -1,6 +1,6 @@
1
- import compareUrls from 'compare-urls';
2
- import { CodedError, Platform } from 'expo-modules-core';
3
- import { AppState, Dimensions, AppStateStatus, NativeEventSubscription } from 'react-native';
1
+ import { CodedError } from 'expo-modules-core';
2
+ import { AppState } from 'react-native';
3
+ import type { AppStateStatus, NativeEventSubscription } from 'react-native';
4
4
 
5
5
  import {
6
6
  WebBrowserAuthSessionResult,
@@ -21,6 +21,11 @@ const getHandle = () => 'ExpoWebBrowserRedirectHandle';
21
21
  const getOriginUrlHandle = (hash: string) => `ExpoWebBrowser_OriginUrl_${hash}`;
22
22
  const getRedirectUrlHandle = (hash: string) => `ExpoWebBrowser_RedirectUrl_${hash}`;
23
23
 
24
+ export function normalizeUrl(url: URL | Location) {
25
+ const origin = url.origin.replace(url.protocol, '').replace(/^\/+/, '').replace(/\/+$/, '');
26
+ return (origin + decodeURI(url.pathname.replace(/\/{2,}/g, '/'))).toLowerCase();
27
+ }
28
+
24
29
  function dismissPopup() {
25
30
  if (!popupWindow) {
26
31
  return;
@@ -45,28 +50,27 @@ function dismissPopup() {
45
50
  }
46
51
 
47
52
  export default {
48
- get name() {
49
- return 'ExpoWebBrowser';
50
- },
51
53
  async openBrowserAsync(
52
54
  url: string,
53
55
  browserParams: WebBrowserOpenOptions = {}
54
56
  ): Promise<WebBrowserResult> {
55
- if (!Platform.isDOMAvailable) return { type: WebBrowserResultType.CANCEL };
57
+ if (typeof window === 'undefined') {
58
+ return { type: WebBrowserResultType.CANCEL };
59
+ }
56
60
  const { windowName = '_blank', windowFeatures } = browserParams;
57
61
  const features = getPopupFeaturesString(windowFeatures);
58
62
  window.open(url, windowName, features);
59
63
  return { type: WebBrowserResultType.OPENED };
60
64
  },
61
65
  dismissAuthSession() {
62
- if (!Platform.isDOMAvailable) return;
66
+ if (typeof window === 'undefined') return;
63
67
  dismissPopup();
64
68
  },
65
69
  maybeCompleteAuthSession({ skipRedirectCheck }: { skipRedirectCheck?: boolean }): {
66
70
  type: 'success' | 'failed';
67
71
  message: string;
68
72
  } {
69
- if (!Platform.isDOMAvailable) {
73
+ if (typeof window === 'undefined') {
70
74
  return {
71
75
  type: 'failed',
72
76
  message: 'Cannot use expo-web-browser in a non-browser environment',
@@ -83,8 +87,8 @@ export default {
83
87
  if (skipRedirectCheck !== true) {
84
88
  const redirectUrl = window.localStorage.getItem(getRedirectUrlHandle(handle));
85
89
  // Compare the original redirect url against the current url with it's query params removed.
86
- const currentUrl = window.location.origin + window.location.pathname;
87
- if (!compareUrls(redirectUrl, currentUrl)) {
90
+ const currentUrl = normalizeUrl(window.location);
91
+ if (redirectUrl !== currentUrl) {
88
92
  return {
89
93
  type: 'failed',
90
94
  message: `Current URL "${currentUrl}" and original redirect URL "${redirectUrl}" do not match.`,
@@ -115,7 +119,7 @@ export default {
115
119
  redirectUrl?: string,
116
120
  openOptions?: WebBrowserOpenOptions
117
121
  ): Promise<WebBrowserAuthSessionResult> {
118
- if (!Platform.isDOMAvailable) return { type: WebBrowserResultType.CANCEL };
122
+ if (typeof window === 'undefined') return { type: WebBrowserResultType.CANCEL };
119
123
 
120
124
  redirectUrl = redirectUrl ?? getRedirectUrlFromUrlOrGenerate(url);
121
125
 
@@ -139,8 +143,18 @@ export default {
139
143
 
140
144
  // Save handle for session
141
145
  window.localStorage.setItem(getHandle(), state);
146
+
147
+ const normalizedRedirectUrl = (() => {
148
+ if (!redirectUrl) return redirectUrl;
149
+ try {
150
+ return normalizeUrl(new URL(redirectUrl));
151
+ } catch {
152
+ return redirectUrl;
153
+ }
154
+ })();
155
+
142
156
  // Save redirect Url for further verification
143
- window.localStorage.setItem(getRedirectUrlHandle(state), redirectUrl);
157
+ window.localStorage.setItem(getRedirectUrlHandle(state), normalizedRedirectUrl);
144
158
 
145
159
  return new Promise(async (resolve) => {
146
160
  // Create a listener for messages sent from the popup
@@ -201,7 +215,7 @@ export default {
201
215
 
202
216
  // Crypto
203
217
  function isCryptoAvailable(): boolean {
204
- if (!Platform.isDOMAvailable) return false;
218
+ if (typeof window === 'undefined') return false;
205
219
  return !!(window?.crypto as any);
206
220
  }
207
221
 
@@ -239,7 +253,7 @@ async function generateStateAsync(): Promise<string> {
239
253
  if (!isSubtleCryptoAvailable()) {
240
254
  throw new CodedError(
241
255
  'ERR_WEB_BROWSER_CRYPTO',
242
- `The current environment doesn't support crypto. Ensure you are running from a secure origin (https).`
256
+ `The current environment doesn't support crypto. Ensure you are running from a secure origin (localhost/https).`
243
257
  );
244
258
  }
245
259
  const encoder = new TextEncoder();
@@ -306,9 +320,8 @@ function getPopupFeaturesString(options?: WebBrowserWindowFeatures | string): st
306
320
  const width = windowFeatures.width ?? POPUP_WIDTH;
307
321
  const height = windowFeatures.height ?? POPUP_HEIGHT;
308
322
 
309
- const dimensions = Dimensions.get('screen');
310
- const top = windowFeatures.top ?? Math.max(0, (dimensions.height - height) * 0.5);
311
- const left = windowFeatures.left ?? Math.max(0, (dimensions.width - width) * 0.5);
323
+ const top = windowFeatures.top ?? Math.max(0, (window.screen.height - height) * 0.5);
324
+ const left = windowFeatures.left ?? Math.max(0, (window.screen.width - width) * 0.5);
312
325
 
313
326
  // Create a reasonable popup
314
327
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features
package/src/WebBrowser.ts CHANGED
@@ -222,7 +222,7 @@ export function dismissBrowser(): void {
222
222
  * Using `Linking.addEventListener` is not needed and can have side effects.
223
223
  *
224
224
  * # On web:
225
- * > This API can only be used in a secure environment (`https`). You can use expo `start:web --https`
225
+ * > This API can only be used in a secure environment (localhost/https).
226
226
  * to test this. Otherwise, an error with code [`ERR_WEB_BROWSER_CRYPTO`](#errwebbrowsercrypto) will be thrown.
227
227
  * This will use the browser's [`window.open()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) API.
228
228
  * - _Desktop_: This will create a new web popup window in the browser that can be closed later using `WebBrowser.maybeCompleteAuthSession()`.
@@ -95,7 +95,7 @@ export type AuthSessionOpenOptions = WebBrowserOpenOptions & {
95
95
  * Whether the request is honored depends on the user’s default web browser.
96
96
  *
97
97
  * @default false
98
- * @platform ios 13+
98
+ * @platform ios
99
99
  */
100
100
  preferEphemeralSession?: boolean;
101
101
  };
@@ -186,7 +186,7 @@ export enum WebBrowserPresentationStyle {
186
186
  * The default presentation style chosen by the system.
187
187
  * On older iOS versions, falls back to `WebBrowserPresentationStyle.FullScreen`.
188
188
  *
189
- * @platform ios 13+
189
+ * @platform ios
190
190
  */
191
191
  AUTOMATIC = 'automatic',
192
192
  }