expo-web-browser 10.1.1 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,7 +10,19 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
- ## 10.1.1 — 2022-02-01
13
+ ## 10.2.0 — 2022-04-18
14
+
15
+ ### 🎉 New features
16
+
17
+ - Native module on iOS is now written in Swift using the new API. ([#16201](https://github.com/expo/expo/pull/16201) by [@tsapeta](https://github.com/tsapeta))
18
+ - Add `presentationStyle` option to customize browser window appearance on iOS. ([#16919](https://github.com/expo/expo/pull/16919) by [@barthap](https://github.com/barthap))
19
+ - Add `preferEphemeralSession` option to `openAuthSessionAsync` to ask for a private auth session on iOS. ([#16926](https://github.com/expo/expo/pull/16926) by [@barthap](https://github.com/barthap))
20
+
21
+ ### ⚠️ Notices
22
+
23
+ - On Android bump `compileSdkVersion` to `31`, `targetSdkVersion` to `31` and `Java` version to `11`. ([#16941](https://github.com/expo/expo/pull/16941) by [@bbarthec](https://github.com/bbarthec))
24
+
25
+ ## 10.1.1 - 2022-02-01
14
26
 
15
27
  ### 🐛 Bug fixes
16
28
 
package/README.md CHANGED
@@ -4,12 +4,12 @@ Provides access to the system's web browser and supports handling redirects. On
4
4
 
5
5
  # API documentation
6
6
 
7
- - [Documentation for the master branch](https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/sdk/webbrowser.md)
8
- - [Documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/webbrowser/)
7
+ - [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/webbrowser.md)
8
+ - [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/webbrowser/)
9
9
 
10
10
  # Installation in managed Expo projects
11
11
 
12
- For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/webbrowser/).
12
+ For [managed](https://docs.expo.dev/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/webbrowser/).
13
13
 
14
14
  # Installation in bare React Native projects
15
15
 
@@ -3,21 +3,36 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '10.1.1'
6
+ version = '10.2.0'
7
7
 
8
8
 
9
9
  buildscript {
10
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
11
+ if (expoModulesCorePlugin.exists()) {
12
+ apply from: expoModulesCorePlugin
13
+ applyKotlinExpoModulesCorePlugin()
14
+ }
15
+
10
16
  // Simple helper that allows the root project to override versions declared by this library.
11
17
  ext.safeExtGet = { prop, fallback ->
12
18
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
13
19
  }
14
20
 
21
+ // Ensures backward compatibility
22
+ ext.getKotlinVersion = {
23
+ if (ext.has("kotlinVersion")) {
24
+ ext.kotlinVersion()
25
+ } else {
26
+ ext.safeExtGet("kotlinVersion", "1.6.10")
27
+ }
28
+ }
29
+
15
30
  repositories {
16
31
  mavenCentral()
17
32
  }
18
33
 
19
34
  dependencies {
20
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.4.21')}")
35
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
21
36
  }
22
37
  }
23
38
 
@@ -45,18 +60,22 @@ afterEvaluate {
45
60
  }
46
61
 
47
62
  android {
48
- compileSdkVersion safeExtGet("compileSdkVersion", 30)
63
+ compileSdkVersion safeExtGet("compileSdkVersion", 31)
49
64
 
50
65
  compileOptions {
51
- sourceCompatibility JavaVersion.VERSION_1_8
52
- targetCompatibility JavaVersion.VERSION_1_8
66
+ sourceCompatibility JavaVersion.VERSION_11
67
+ targetCompatibility JavaVersion.VERSION_11
68
+ }
69
+
70
+ kotlinOptions {
71
+ jvmTarget = JavaVersion.VERSION_11.majorVersion
53
72
  }
54
73
 
55
74
  defaultConfig {
56
75
  minSdkVersion safeExtGet("minSdkVersion", 21)
57
- targetSdkVersion safeExtGet("targetSdkVersion", 30)
76
+ targetSdkVersion safeExtGet("targetSdkVersion", 31)
58
77
  versionCode 18
59
- versionName '10.1.1'
78
+ versionName '10.2.0'
60
79
  }
61
80
  lintOptions {
62
81
  abortOnError false
@@ -68,10 +87,10 @@ dependencies {
68
87
 
69
88
  api "androidx.browser:browser:1.2.0"
70
89
 
71
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.4.21')}"
90
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
72
91
 
73
- if (project.findProject(':unimodules-test-core')) {
74
- testImplementation project(':unimodules-test-core')
92
+ if (project.findProject(':expo-modules-test-core')) {
93
+ testImplementation project(':expo-modules-test-core')
75
94
  }
76
95
  testImplementation "org.robolectric:robolectric:4.3.1"
77
96
  }
@@ -1,2 +1,3 @@
1
1
  declare const _default: import("expo-modules-core").ProxyNativeModule;
2
2
  export default _default;
3
+ //# sourceMappingURL=ExpoWebBrowser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoWebBrowser.d.ts","sourceRoot":"","sources":["../src/ExpoWebBrowser.ts"],"names":[],"mappings":";AACA,wBAAgE"}
@@ -13,3 +13,4 @@ declare const _default: {
13
13
  };
14
14
  export default _default;
15
15
  export declare function featureObjectToString(features: Record<string, any>): string;
16
+ //# sourceMappingURL=ExpoWebBrowser.web.d.ts.map
@@ -0,0 +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,sFAGV,QAAQ,2BAA2B,CAAC;;AAtEzC,wBAyJE;AAqIF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAY3E"}
@@ -98,7 +98,7 @@ export default {
98
98
  try {
99
99
  popupWindow.focus();
100
100
  }
101
- catch (e) { }
101
+ catch { }
102
102
  }
103
103
  else {
104
104
  throw new CodedError('ERR_WEB_BROWSER_BLOCKED', '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.');
@@ -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,EAAkB,MAAM,cAAc,CAAC;AAEpE,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;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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 compareUrls from 'compare-urls';\nimport { CodedError, Platform } from 'expo-modules-core';\nimport { AppState, Dimensions, AppStateStatus } 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, appStateListener, interval } = listenerMap.get(popupWindow);\n clearInterval(interval);\n window.removeEventListener('message', listener);\n AppState.removeEventListener('change', appStateListener);\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 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 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 (e) {}\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 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 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 appStateListener,\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 windowFeaturePairs[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,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AAEpE,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,SAAS,YAAY;IACnB,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO;KACR;IACD,WAAW,CAAC,KAAK,EAAE,CAAC;IACpB,IAAI,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;QAChC,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC,GA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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 } 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, appStateListener, interval } = listenerMap.get(popupWindow);\n clearInterval(interval);\n window.removeEventListener('message', listener);\n AppState.removeEventListener('change', appStateListener);\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 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 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 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 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 appStateListener,\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 windowFeaturePairs[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,5 +1,5 @@
1
- import { WebBrowserAuthSessionResult, WebBrowserCompleteAuthSessionOptions, WebBrowserCompleteAuthSessionResult, WebBrowserCoolDownResult, WebBrowserCustomTabsResults, WebBrowserMayInitWithUrlResult, WebBrowserOpenOptions, WebBrowserRedirectResult, WebBrowserResult, WebBrowserResultType, WebBrowserWarmUpResult, WebBrowserWindowFeatures } from './WebBrowser.types';
2
- export { WebBrowserAuthSessionResult, WebBrowserCompleteAuthSessionOptions, WebBrowserCompleteAuthSessionResult, WebBrowserCoolDownResult, WebBrowserCustomTabsResults, WebBrowserMayInitWithUrlResult, WebBrowserOpenOptions, WebBrowserRedirectResult, WebBrowserResult, WebBrowserResultType, WebBrowserWarmUpResult, WebBrowserWindowFeatures, };
1
+ import { WebBrowserAuthSessionResult, WebBrowserCompleteAuthSessionOptions, WebBrowserCompleteAuthSessionResult, WebBrowserCoolDownResult, WebBrowserCustomTabsResults, WebBrowserMayInitWithUrlResult, WebBrowserOpenOptions, WebBrowserRedirectResult, WebBrowserResult, WebBrowserResultType, WebBrowserWarmUpResult, WebBrowserWindowFeatures, WebBrowserPresentationStyle, AuthSessionOpenOptions } from './WebBrowser.types';
2
+ export { WebBrowserAuthSessionResult, WebBrowserCompleteAuthSessionOptions, WebBrowserCompleteAuthSessionResult, WebBrowserCoolDownResult, WebBrowserCustomTabsResults, WebBrowserMayInitWithUrlResult, WebBrowserOpenOptions, WebBrowserRedirectResult, WebBrowserResult, WebBrowserResultType, WebBrowserWarmUpResult, WebBrowserWindowFeatures, WebBrowserPresentationStyle, AuthSessionOpenOptions, };
3
3
  /**
4
4
  * Returns a list of applications package names supporting Custom Tabs, Custom Tabs
5
5
  * service, user chosen and preferred one. This may not be fully reliable, since it uses
@@ -102,7 +102,7 @@ export declare function dismissBrowser(): void;
102
102
  *
103
103
  * @param url The url to open in the web browser. This should be a login page.
104
104
  * @param redirectUrl _Optional_ - The url to deep link back into your app. By default, this will be [`Constants.linkingUrl`](./constants/#expoconstantslinkinguri).
105
- * @param browserParams _Optional_ - An object with the same keys as [`WebBrowserOpenOptions`](#webbrowseropenoptions).
105
+ * @param options _Optional_ - An object extending the [`WebBrowserOpenOptions`](#webbrowseropenoptions).
106
106
  * If there is no native AuthSession implementation available (which is the case on Android)
107
107
  * these params will be used in the browser polyfill. If there is a native AuthSession implementation,
108
108
  * these params will be ignored.
@@ -113,7 +113,7 @@ export declare function dismissBrowser(): void;
113
113
  * - If the browser is closed using [`dismissBrowser`](#webbrowserdismissbrowser),
114
114
  * the Promise fulfills with `{ type: 'dismiss' }` object.
115
115
  */
116
- export declare function openAuthSessionAsync(url: string, redirectUrl: string, browserParams?: WebBrowserOpenOptions): Promise<WebBrowserAuthSessionResult>;
116
+ export declare function openAuthSessionAsync(url: string, redirectUrl: string, options?: AuthSessionOpenOptions): Promise<WebBrowserAuthSessionResult>;
117
117
  export declare function dismissAuthSession(): void;
118
118
  /**
119
119
  * Possibly completes an authentication session on web in a window popup. The method
@@ -144,3 +144,4 @@ export declare function dismissAuthSession(): void;
144
144
  * @platform web
145
145
  */
146
146
  export declare function maybeCompleteAuthSession(options?: WebBrowserCompleteAuthSessionOptions): WebBrowserCompleteAuthSessionResult;
147
+ //# sourceMappingURL=WebBrowser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebBrowser.d.ts","sourceRoot":"","sources":["../src/WebBrowser.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,2BAA2B,EAC3B,oCAAoC,EACpC,mCAAmC,EACnC,wBAAwB,EACxB,2BAA2B,EAC3B,8BAA8B,EAC9B,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,2BAA2B,EAC3B,oCAAoC,EACpC,mCAAmC,EACnC,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Platform } from 'react-native';
3
3
  import ExponentWebBrowser from './ExpoWebBrowser';
4
- import { WebBrowserResultType, } from './WebBrowser.types';
5
- export { WebBrowserResultType, };
4
+ import { WebBrowserResultType, WebBrowserPresentationStyle, } from './WebBrowser.types';
5
+ export { WebBrowserResultType, WebBrowserPresentationStyle, };
6
6
  const emptyCustomTabsPackages = {
7
7
  defaultBrowserPackage: undefined,
8
8
  preferredBrowserPackage: undefined,
@@ -186,7 +186,7 @@ export function dismissBrowser() {
186
186
  *
187
187
  * @param url The url to open in the web browser. This should be a login page.
188
188
  * @param redirectUrl _Optional_ - The url to deep link back into your app. By default, this will be [`Constants.linkingUrl`](./constants/#expoconstantslinkinguri).
189
- * @param browserParams _Optional_ - An object with the same keys as [`WebBrowserOpenOptions`](#webbrowseropenoptions).
189
+ * @param options _Optional_ - An object extending the [`WebBrowserOpenOptions`](#webbrowseropenoptions).
190
190
  * If there is no native AuthSession implementation available (which is the case on Android)
191
191
  * these params will be used in the browser polyfill. If there is a native AuthSession implementation,
192
192
  * these params will be ignored.
@@ -197,18 +197,18 @@ export function dismissBrowser() {
197
197
  * - If the browser is closed using [`dismissBrowser`](#webbrowserdismissbrowser),
198
198
  * the Promise fulfills with `{ type: 'dismiss' }` object.
199
199
  */
200
- export async function openAuthSessionAsync(url, redirectUrl, browserParams = {}) {
200
+ export async function openAuthSessionAsync(url, redirectUrl, options = {}) {
201
201
  if (_authSessionIsNativelySupported()) {
202
202
  if (!ExponentWebBrowser.openAuthSessionAsync) {
203
203
  throw new UnavailabilityError('WebBrowser', 'openAuthSessionAsync');
204
204
  }
205
- if (Platform.OS === 'web') {
206
- return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl, browserParams);
205
+ if (['ios', 'web'].includes(Platform.OS)) {
206
+ return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl, options);
207
207
  }
208
208
  return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl);
209
209
  }
210
210
  else {
211
- return _openAuthSessionPolyfillAsync(url, redirectUrl, browserParams);
211
+ return _openAuthSessionPolyfillAsync(url, redirectUrl, options);
212
212
  }
213
213
  }
214
214
  // @docsMissing
@@ -297,15 +297,15 @@ function _onAppStateChangeAndroid(state) {
297
297
  async function _openBrowserAndWaitAndroidAsync(startUrl, browserParams = {}) {
298
298
  const appStateChangedToActive = new Promise((resolve) => {
299
299
  _onWebBrowserCloseAndroid = resolve;
300
- AppState.addEventListener('change', _onAppStateChangeAndroid);
301
300
  });
301
+ const stateChangeSubscription = AppState.addEventListener('change', _onAppStateChangeAndroid);
302
302
  let result = { type: WebBrowserResultType.CANCEL };
303
303
  let type = null;
304
304
  try {
305
305
  ({ type } = await openBrowserAsync(startUrl, browserParams));
306
306
  }
307
307
  catch (e) {
308
- AppState.removeEventListener('change', _onAppStateChangeAndroid);
308
+ stateChangeSubscription.remove();
309
309
  _onWebBrowserCloseAndroid = null;
310
310
  throw e;
311
311
  }
@@ -313,7 +313,7 @@ async function _openBrowserAndWaitAndroidAsync(startUrl, browserParams = {}) {
313
313
  await appStateChangedToActive;
314
314
  result = { type: WebBrowserResultType.DISMISS };
315
315
  }
316
- AppState.removeEventListener('change', _onAppStateChangeAndroid);
316
+ stateChangeSubscription.remove();
317
317
  _onWebBrowserCloseAndroid = null;
318
318
  return result;
319
319
  }
@@ -1 +1 @@
1
- {"version":3,"file":"WebBrowser.js","sourceRoot":"","sources":["../src/WebBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAkB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,kBAAkB,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAWL,oBAAoB,GAGrB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAUL,oBAAoB,GAGrB,CAAC;AAEF,MAAM,uBAAuB,GAAgC;IAC3D,qBAAqB,EAAE,SAAS;IAChC,uBAAuB,EAAE,S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,EAAE,CAAC;SACrC;QAED,uBAAuB,EAAE,CAAC;KAC3B;AACH,CAAC;AAED,SAAS,uBAAuB;IAC9B,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;KACH;IAED,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACrD,gBAAgB,GAAG,IAAI,CAAC;AAC1B,CAAC;AAED,SAAS,qBAAqB,CAAC,SAAiB;IAC9C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,gBAAgB,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC1C,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;gBACnC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;aAC9C;QACH,CAAC,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\nimport { AppState, AppStateStatus, Linking, Platform } from 'react-native';\n\nimport ExponentWebBrowser from './ExpoWebBrowser';\nimport {\n RedirectEvent,\n WebBrowserAuthSessionResult,\n WebBrowserCompleteAuthSessionOptions,\n WebBrowserCompleteAuthSessionResult,\n WebBrowserCoolDownResult,\n WebBrowserCustomTabsResults,\n WebBrowserMayInitWithUrlResult,\n WebBrowserOpenOptions,\n WebBrowserRedirectResult,\n WebBrowserResult,\n WebBrowserResultType,\n WebBrowserWarmUpResult,\n WebBrowserWindowFeatures,\n} from './WebBrowser.types';\n\nexport {\n WebBrowserAuthSessionResult,\n WebBrowserCompleteAuthSessionOptions,\n WebBrowserCompleteAuthSessionResult,\n WebBrowserCoolDownResult,\n WebBrowserCustomTabsResults,\n WebBrowserMayInitWithUrlResult,\n WebBrowserOpenOptions,\n WebBrowserRedirectResult,\n WebBrowserResult,\n WebBrowserResultType,\n WebBrowserWarmUpResult,\n WebBrowserWindowFeatures,\n};\n\nconst emptyCustomTabsPackages: WebBrowserCustomTabsResults = {\n defaultBrowserPackage: undefined,\n preferredBrowserPackage: undefined,\n browserPackages: [],\n servicePackages: [],\n};\n\n// @needsAudit\n/**\n * Returns a list of applications package names supporting Custom Tabs, Custom Tabs\n * service, user chosen and preferred one. This may not be fully reliable, since it uses\n * `PackageManager.getResolvingActivities` under the hood. (For example, some browsers might not be\n * present in browserPackages list once another browser is set to default.)\n *\n * @return The promise which fulfils with [`WebBrowserCustomTabsResults`](#webbrowsercustomtabsresults) object.\n * @platform android\n */\nexport async function getCustomTabsSupportingBrowsersAsync(): Promise<WebBrowserCustomTabsResults> {\n if (!ExponentWebBrowser.getCustomTabsSupportingBrowsersAsync) {\n throw new UnavailabilityError('WebBrowser', 'getCustomTabsSupportingBrowsersAsync');\n }\n if (Platform.OS !== 'android') {\n return emptyCustomTabsPackages;\n } else {\n return await ExponentWebBrowser.getCustomTabsSupportingBrowsersAsync();\n }\n}\n\n// @needsAudit\n/**\n * This method calls `warmUp` method on [CustomTabsClient](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#warmup(long))\n * for specified package.\n *\n * @param browserPackage Package of browser to be warmed up. If not set, preferred browser will be warmed.\n *\n * @return A promise which fulfils with `WebBrowserWarmUpResult` object.\n * @platform android\n */\nexport async function warmUpAsync(browserPackage?: string): Promise<WebBrowserWarmUpResult> {\n if (!ExponentWebBrowser.warmUpAsync) {\n throw new UnavailabilityError('WebBrowser', 'warmUpAsync');\n }\n if (Platform.OS !== 'android') {\n return {};\n } else {\n return await ExponentWebBrowser.warmUpAsync(browserPackage);\n }\n}\n\n// @needsAudit\n/**\n * This method initiates (if needed) [CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession.html#maylaunchurl)\n * and calls its `mayLaunchUrl` method for browser specified by the package.\n *\n * @param url The url of page that is likely to be loaded first when opening browser.\n * @param browserPackage Package of browser to be informed. If not set, preferred\n * browser will be used.\n *\n * @return A promise which fulfils with `WebBrowserMayInitWithUrlResult` object.\n * @platform android\n */\nexport async function mayInitWithUrlAsync(\n url: string,\n browserPackage?: string\n): Promise<WebBrowserMayInitWithUrlResult> {\n if (!ExponentWebBrowser.mayInitWithUrlAsync) {\n throw new UnavailabilityError('WebBrowser', 'mayInitWithUrlAsync');\n }\n if (Platform.OS !== 'android') {\n return {};\n } else {\n return await ExponentWebBrowser.mayInitWithUrlAsync(url, browserPackage);\n }\n}\n\n// @needsAudit\n/**\n * This methods removes all bindings to services created by [`warmUpAsync`](#webbrowserwarmupasyncbrowserpackage)\n * or [`mayInitWithUrlAsync`](#webbrowsermayinitwithurlasyncurl-browserpackage). You should call\n * this method once you don't need them to avoid potential memory leaks. However, those binding\n * would be cleared once your application is destroyed, which might be sufficient in most cases.\n *\n * @param browserPackage Package of browser to be cooled. If not set, preferred browser will be used.\n *\n * @return The promise which fulfils with ` WebBrowserCoolDownResult` when cooling is performed, or\n * an empty object when there was no connection to be dismissed.\n * @platform android\n */\nexport async function coolDownAsync(browserPackage?: string): Promise<WebBrowserCoolDownResult> {\n if (!ExponentWebBrowser.coolDownAsync) {\n throw new UnavailabilityError('WebBrowser', 'coolDownAsync');\n }\n if (Platform.OS !== 'android') {\n return {};\n } else {\n return await ExponentWebBrowser.coolDownAsync(browserPackage);\n }\n}\n\nlet browserLocked = false;\n\n// @needsAudit\n/**\n * Opens the url with Safari in a modal on iOS using [`SFSafariViewController`](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller),\n * and Chrome in a new [custom tab](https://developer.chrome.com/multidevice/android/customtabs)\n * on Android. On iOS, the modal Safari will not share cookies with the system Safari. If you need\n * this, use [`openAuthSessionAsync`](#webbrowseropenauthsessionasyncurl-redirecturl-browserparams).\n *\n * @param url The url to open in the web browser.\n * @param browserParams A dictionary of key-value pairs.\n *\n * @return The promise behaves differently based on the platform.\n * On Android promise resolves with `{type: 'opened'}` if we were able to open browser.\n * On iOS:\n * - If the user closed the web browser, the Promise resolves with `{ type: 'cancel' }`.\n * - If the browser is closed using [`dismissBrowser`](#webbrowserdismissbrowser), the Promise resolves with `{ type: 'dismiss' }`.\n */\nexport async function openBrowserAsync(\n url: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserResult> {\n if (!ExponentWebBrowser.openBrowserAsync) {\n throw new UnavailabilityError('WebBrowser', 'openBrowserAsync');\n }\n\n if (browserLocked) {\n // Prevent multiple sessions from running at the same time, WebBrowser doesn't\n // support it this makes the behavior predictable.\n if (__DEV__) {\n console.warn(\n 'Attempted to call WebBrowser.openBrowserAsync multiple times while already active. Only one WebBrowser controller can be active at any given time.'\n );\n }\n\n return { type: WebBrowserResultType.LOCKED };\n }\n browserLocked = true;\n\n let result: WebBrowserResult;\n try {\n result = await ExponentWebBrowser.openBrowserAsync(url, browserParams);\n } finally {\n // WebBrowser session complete, unset lock\n browserLocked = false;\n }\n\n return result;\n}\n\n// @needsAudit\n/**\n * Dismisses the presented web browser.\n *\n * @return The `void` on successful attempt, or throws error, if dismiss functionality is not avaiable.\n * @platform ios\n */\nexport function dismissBrowser(): void {\n if (!ExponentWebBrowser.dismissBrowser) {\n throw new UnavailabilityError('WebBrowser', 'dismissBrowser');\n }\n ExponentWebBrowser.dismissBrowser();\n}\n\n// @needsAudit\n/**\n * # On iOS:\n * Opens the url with Safari in a modal using `SFAuthenticationSession` on iOS 11 and greater,\n * and falling back on a `SFSafariViewController`. The user will be asked whether to allow the app\n * to authenticate using the given url.\n *\n * # On Android:\n * This will be done using a \"custom Chrome tabs\" browser, [AppState](../react-native/appstate/),\n * and [Linking](./linking/) APIs.\n *\n * # On web:\n * > This API can only be used in a secure environment (`https`). You can use expo `start:web --https`\n * to test this. Otherwise, an error with code [`ERR_WEB_BROWSER_CRYPTO`](#errwebbrowsercrypto) will be thrown.\n * This will use the browser's [`window.open()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) API.\n * - _Desktop_: This will create a new web popup window in the browser that can be closed later using `WebBrowser.maybeCompleteAuthSession()`.\n * - _Mobile_: This will open a new tab in the browser which can be closed using `WebBrowser.maybeCompleteAuthSession()`.\n *\n * How this works on web:\n * - A crypto state will be created for verifying the redirect.\n * - This means you need to run with `expo start:web --https`\n * - The state will be added to the window's `localstorage`. This ensures that auth cannot complete\n * unless it's done from a page running with the same origin as it was started.\n * Ex: if `openAuthSessionAsync` is invoked on `https://localhost:19006`, then `maybeCompleteAuthSession`\n * must be invoked on a page hosted from the origin `https://localhost:19006`. Using a different\n * website, or even a different host like `https://128.0.0.*:19006` for example will not work.\n * - A timer will be started to check for every 1000 milliseconds (1 second) to detect if the window\n * has been closed by the user. If this happens then a promise will resolve with `{ type: 'dismiss' }`.\n *\n * > On mobile web, Chrome and Safari will block any call to [`window.open()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/open)\n * which takes too long to fire after a user interaction. This method must be invoked immediately\n * after a user interaction. If the event is blocked, an error with code [`ERR_WEB_BROWSER_BLOCKED`](#errwebbrowserblocked) will be thrown.\n *\n * @param url The url to open in the web browser. This should be a login page.\n * @param redirectUrl _Optional_ - The url to deep link back into your app. By default, this will be [`Constants.linkingUrl`](./constants/#expoconstantslinkinguri).\n * @param browserParams _Optional_ - An object with the same keys as [`WebBrowserOpenOptions`](#webbrowseropenoptions).\n * If there is no native AuthSession implementation available (which is the case on Android)\n * these params will be used in the browser polyfill. If there is a native AuthSession implementation,\n * these params will be ignored.\n *\n * @return\n * - If the user does not permit the application to authenticate with the given url, the Promise fulfills with `{ type: 'cancel' }` object.\n * - If the user closed the web browser, the Promise fulfills with `{ type: 'cancel' }` object.\n * - If the browser is closed using [`dismissBrowser`](#webbrowserdismissbrowser),\n * the Promise fulfills with `{ type: 'dismiss' }` object.\n */\nexport async function openAuthSessionAsync(\n url: string,\n redirectUrl: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserAuthSessionResult> {\n if (_authSessionIsNativelySupported()) {\n if (!ExponentWebBrowser.openAuthSessionAsync) {\n throw new UnavailabilityError('WebBrowser', 'openAuthSessionAsync');\n }\n if (Platform.OS === 'web') {\n return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl, browserParams);\n }\n return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl);\n } else {\n return _openAuthSessionPolyfillAsync(url, redirectUrl, browserParams);\n }\n}\n\n// @docsMissing\nexport function dismissAuthSession(): void {\n if (_authSessionIsNativelySupported()) {\n if (!ExponentWebBrowser.dismissAuthSession) {\n throw new UnavailabilityError('WebBrowser', 'dismissAuthSession');\n }\n ExponentWebBrowser.dismissAuthSession();\n } else {\n if (!ExponentWebBrowser.dismissBrowser) {\n throw new UnavailabilityError('WebBrowser', 'dismissAuthSession');\n }\n ExponentWebBrowser.dismissBrowser();\n }\n}\n\n// @needsAudit\n/**\n * Possibly completes an authentication session on web in a window popup. The method\n * should be invoked on the page that the window redirects to.\n *\n * @param options\n *\n * @return Returns an object with message about why the redirect failed or succeeded:\n *\n * If `type` is set to `failed`, the reason depends on the message:\n * - `Not supported on this platform`: If the platform doesn't support this method (iOS, Android).\n * - `Cannot use expo-web-browser in a non-browser environment`: If the code was executed in an SSR\n * or node environment.\n * - `No auth session is currently in progress`: (the cached state wasn't found in local storage).\n * This can happen if the window redirects to an origin (website) that is different to the initial\n * website origin. If this happens in development, it may be because the auth started on localhost\n * and finished on your computer port (Ex: `128.0.0.*`). This is controlled by the `redirectUrl`\n * and `returnUrl`.\n * - `Current URL \"<URL>\" and original redirect URL \"<URL>\" do not match`: This can occur when the\n * redirect URL doesn't match what was initial defined as the `returnUrl`. You can skip this test\n * in development by passing `{ skipRedirectCheck: true }` to the function.\n *\n * If `type` is set to `success`, the parent window will attempt to close the child window immediately.\n *\n * If the error `ERR_WEB_BROWSER_REDIRECT` was thrown, it may mean that the parent window was\n * reloaded before the auth was completed. In this case you'll need to close the child window manually.\n *\n * @platform web\n */\nexport function maybeCompleteAuthSession(\n options: WebBrowserCompleteAuthSessionOptions = {}\n): WebBrowserCompleteAuthSessionResult {\n if (ExponentWebBrowser.maybeCompleteAuthSession) {\n return ExponentWebBrowser.maybeCompleteAuthSession(options);\n }\n return { type: 'failed', message: 'Not supported on this platform' };\n}\n\n/* iOS <= 10 and Android polyfill for SFAuthenticationSession flow */\n\nfunction _authSessionIsNativelySupported(): boolean {\n if (Platform.OS === 'android') {\n return false;\n } else if (Platform.OS === 'web') {\n return true;\n }\n\n const versionNumber = parseInt(String(Platform.Version), 10);\n return versionNumber >= 11;\n}\n\nlet _redirectHandler: ((event: RedirectEvent) => void) | null = null;\n\n/*\n * openBrowserAsync on Android doesn't wait until closed, so we need to polyfill\n * it with AppState\n */\n\n// Store the `resolve` function from a Promise to fire when the AppState\n// returns to active\nlet _onWebBrowserCloseAndroid: null | (() => void) = null;\n\n// If the initial AppState.currentState is null, we assume that the first call to\n// AppState#change event is not actually triggered by a real change,\n// is triggered instead by the bridge capturing the current state\n// (https://reactnative.dev/docs/appstate#basic-usage)\nlet _isAppStateAvailable: boolean = AppState.currentState !== null;\nfunction _onAppStateChangeAndroid(state: AppStateStatus) {\n if (!_isAppStateAvailable) {\n _isAppStateAvailable = true;\n return;\n }\n\n if (state === 'active' && _onWebBrowserCloseAndroid) {\n _onWebBrowserCloseAndroid();\n }\n}\n\nasync function _openBrowserAndWaitAndroidAsync(\n startUrl: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserResult> {\n const appStateChangedToActive = new Promise<void>((resolve) => {\n _onWebBrowserCloseAndroid = resolve;\n AppState.addEventListener('change', _onAppStateChangeAndroid);\n });\n\n let result: WebBrowserResult = { type: WebBrowserResultType.CANCEL };\n let type: string | null = null;\n\n try {\n ({ type } = await openBrowserAsync(startUrl, browserParams));\n } catch (e) {\n AppState.removeEventListener('change', _onAppStateChangeAndroid);\n _onWebBrowserCloseAndroid = null;\n throw e;\n }\n\n if (type === 'opened') {\n await appStateChangedToActive;\n result = { type: WebBrowserResultType.DISMISS };\n }\n\n AppState.removeEventListener('change', _onAppStateChangeAndroid);\n _onWebBrowserCloseAndroid = null;\n return result;\n}\n\nasync function _openAuthSessionPolyfillAsync(\n startUrl: string,\n returnUrl: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserAuthSessionResult> {\n if (_redirectHandler) {\n throw new Error(\n `The WebBrowser's auth session is in an invalid state with a redirect handler set when it should not be`\n );\n }\n\n if (_onWebBrowserCloseAndroid) {\n throw new Error(`WebBrowser is already open, only one can be open at a time`);\n }\n\n try {\n if (Platform.OS === 'android') {\n return await Promise.race([\n _openBrowserAndWaitAndroidAsync(startUrl, browserParams),\n _waitForRedirectAsync(returnUrl),\n ]);\n } else {\n return await Promise.race([\n openBrowserAsync(startUrl, browserParams),\n _waitForRedirectAsync(returnUrl),\n ]);\n }\n } finally {\n // We can't dismiss the browser on Android, only call this when it's available.\n // Users on Android need to manually press the 'x' button in Chrome Custom Tabs, sadly.\n if (ExponentWebBrowser.dismissBrowser) {\n ExponentWebBrowser.dismissBrowser();\n }\n\n _stopWaitingForRedirect();\n }\n}\n\nfunction _stopWaitingForRedirect() {\n if (!_redirectHandler) {\n throw new Error(\n `The WebBrowser auth session is in an invalid state with no redirect handler when one should be set`\n );\n }\n\n Linking.removeEventListener('url', _redirectHandler);\n _redirectHandler = null;\n}\n\nfunction _waitForRedirectAsync(returnUrl: string): Promise<WebBrowserRedirectResult> {\n return new Promise((resolve) => {\n _redirectHandler = (event: RedirectEvent) => {\n if (event.url.startsWith(returnUrl)) {\n resolve({ url: event.url, type: 'success' });\n }\n };\n\n Linking.addEventListener('url', _redirectHandler);\n });\n}\n"]}
1
+ {"version":3,"file":"WebBrowser.js","sourceRoot":"","sources":["../src/WebBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAkB,OAAO,EAAE,QAAQ,EAAE,MAA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AAC;SACJ;aAAM;YACL,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;gBACxB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,CAAC;gBACzC,qBAAqB,CAAC,SAAS,CAAC;aACjC,CAAC,CAAC;SACJ;KACF;YAAS;QACR,+EAA+E;QAC/E,uFAAuF;QACvF,IAAI,kBAAkB,CAAC,cAAc,EAAE;YACrC,kBAAkB,CAAC,cAAc,EAAE,CAAC;SACrC;QAED,uBAAuB,EAAE,CAAC;KAC3B;AACH,CAAC;AAED,SAAS,uBAAuB;IAC9B,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;KACH;IAED,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACrD,gBAAgB,GAAG,IAAI,CAAC;AAC1B,CAAC;AAED,SAAS,qBAAqB,CAAC,SAAiB;IAC9C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,gBAAgB,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC1C,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;gBACnC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;aAC9C;QACH,CAAC,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\nimport { AppState, AppStateStatus, Linking, Platform } from 'react-native';\n\nimport ExponentWebBrowser from './ExpoWebBrowser';\nimport {\n RedirectEvent,\n WebBrowserAuthSessionResult,\n WebBrowserCompleteAuthSessionOptions,\n WebBrowserCompleteAuthSessionResult,\n WebBrowserCoolDownResult,\n WebBrowserCustomTabsResults,\n WebBrowserMayInitWithUrlResult,\n WebBrowserOpenOptions,\n WebBrowserRedirectResult,\n WebBrowserResult,\n WebBrowserResultType,\n WebBrowserWarmUpResult,\n WebBrowserWindowFeatures,\n 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, browserParams);\n } finally {\n // WebBrowser session complete, unset lock\n browserLocked = false;\n }\n\n return result;\n}\n\n// @needsAudit\n/**\n * Dismisses the presented web browser.\n *\n * @return The `void` on successful attempt, or throws error, if dismiss functionality is not avaiable.\n * @platform ios\n */\nexport function dismissBrowser(): void {\n if (!ExponentWebBrowser.dismissBrowser) {\n throw new UnavailabilityError('WebBrowser', 'dismissBrowser');\n }\n ExponentWebBrowser.dismissBrowser();\n}\n\n// @needsAudit\n/**\n * # On iOS:\n * Opens the url with Safari in a modal using `SFAuthenticationSession` on iOS 11 and greater,\n * and falling back on a `SFSafariViewController`. The user will be asked whether to allow the app\n * to authenticate using the given url.\n *\n * # On Android:\n * This will be done using a \"custom Chrome tabs\" browser, [AppState](../react-native/appstate/),\n * and [Linking](./linking/) APIs.\n *\n * # On web:\n * > This API can only be used in a secure environment (`https`). You can use expo `start:web --https`\n * to test this. Otherwise, an error with code [`ERR_WEB_BROWSER_CRYPTO`](#errwebbrowsercrypto) will be thrown.\n * This will use the browser's [`window.open()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) API.\n * - _Desktop_: This will create a new web popup window in the browser that can be closed later using `WebBrowser.maybeCompleteAuthSession()`.\n * - _Mobile_: This will open a new tab in the browser which can be closed using `WebBrowser.maybeCompleteAuthSession()`.\n *\n * How this works on web:\n * - A crypto state will be created for verifying the redirect.\n * - This means you need to run with `expo start:web --https`\n * - The state will be added to the window's `localstorage`. This ensures that auth cannot complete\n * unless it's done from a page running with the same origin as it was started.\n * Ex: if `openAuthSessionAsync` is invoked on `https://localhost:19006`, then `maybeCompleteAuthSession`\n * must be invoked on a page hosted from the origin `https://localhost:19006`. Using a different\n * website, or even a different host like `https://128.0.0.*:19006` for example will not work.\n * - A timer will be started to check for every 1000 milliseconds (1 second) to detect if the window\n * has been closed by the user. If this happens then a promise will resolve with `{ type: 'dismiss' }`.\n *\n * > On mobile web, Chrome and Safari will block any call to [`window.open()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/open)\n * which takes too long to fire after a user interaction. This method must be invoked immediately\n * after a user interaction. If the event is blocked, an error with code [`ERR_WEB_BROWSER_BLOCKED`](#errwebbrowserblocked) will be thrown.\n *\n * @param url The url to open in the web browser. This should be a login page.\n * @param redirectUrl _Optional_ - The url to deep link back into your app. By default, this will be [`Constants.linkingUrl`](./constants/#expoconstantslinkinguri).\n * @param 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,\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, 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\n/* iOS <= 10 and Android polyfill for SFAuthenticationSession flow */\n\nfunction _authSessionIsNativelySupported(): boolean {\n if (Platform.OS === 'android') {\n return false;\n } else if (Platform.OS === 'web') {\n return true;\n }\n\n const versionNumber = parseInt(String(Platform.Version), 10);\n return versionNumber >= 11;\n}\n\nlet _redirectHandler: ((event: RedirectEvent) => void) | null = null;\n\n/*\n * openBrowserAsync on Android doesn't wait until closed, so we need to polyfill\n * it with AppState\n */\n\n// Store the `resolve` function from a Promise to fire when the AppState\n// returns to active\nlet _onWebBrowserCloseAndroid: null | (() => void) = null;\n\n// If the initial AppState.currentState is null, we assume that the first call to\n// AppState#change event is not actually triggered by a real change,\n// is triggered instead by the bridge capturing the current state\n// (https://reactnative.dev/docs/appstate#basic-usage)\nlet _isAppStateAvailable: boolean = AppState.currentState !== null;\nfunction _onAppStateChangeAndroid(state: AppStateStatus) {\n if (!_isAppStateAvailable) {\n _isAppStateAvailable = true;\n return;\n }\n\n if (state === 'active' && _onWebBrowserCloseAndroid) {\n _onWebBrowserCloseAndroid();\n }\n}\n\nasync function _openBrowserAndWaitAndroidAsync(\n startUrl: string,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserResult> {\n const appStateChangedToActive = new Promise<void>((resolve) => {\n _onWebBrowserCloseAndroid = resolve;\n });\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,\n browserParams: WebBrowserOpenOptions = {}\n): Promise<WebBrowserAuthSessionResult> {\n if (_redirectHandler) {\n throw new Error(\n `The WebBrowser's auth session is in an invalid state with a redirect handler set when it should not be`\n );\n }\n\n if (_onWebBrowserCloseAndroid) {\n throw new Error(`WebBrowser is already open, only one can be open at a time`);\n }\n\n try {\n if (Platform.OS === 'android') {\n return await Promise.race([\n _openBrowserAndWaitAndroidAsync(startUrl, browserParams),\n _waitForRedirectAsync(returnUrl),\n ]);\n } else {\n return await Promise.race([\n openBrowserAsync(startUrl, browserParams),\n _waitForRedirectAsync(returnUrl),\n ]);\n }\n } finally {\n // We can't dismiss the browser on Android, only call this when it's available.\n // Users on Android need to manually press the 'x' button in Chrome Custom Tabs, sadly.\n if (ExponentWebBrowser.dismissBrowser) {\n ExponentWebBrowser.dismissBrowser();\n }\n\n _stopWaitingForRedirect();\n }\n}\n\nfunction _stopWaitingForRedirect() {\n if (!_redirectHandler) {\n throw new Error(\n `The WebBrowser auth session is in an invalid state with no redirect handler when one should be set`\n );\n }\n\n Linking.removeEventListener('url', _redirectHandler);\n _redirectHandler = null;\n}\n\nfunction _waitForRedirectAsync(returnUrl: string): Promise<WebBrowserRedirectResult> {\n return new Promise((resolve) => {\n _redirectHandler = (event: RedirectEvent) => {\n if (event.url.startsWith(returnUrl)) {\n resolve({ url: event.url, type: 'success' });\n }\n };\n\n Linking.addEventListener('url', _redirectHandler);\n });\n}\n"]}
@@ -61,6 +61,13 @@ export declare type WebBrowserOpenOptions = {
61
61
  * @platform ios
62
62
  */
63
63
  readerMode?: boolean;
64
+ /**
65
+ * The [presentation style](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle)
66
+ * of the browser window.
67
+ * @default WebBrowser.WebBrowserPresentationStyle.OverFullScreen
68
+ * @platform ios
69
+ */
70
+ presentationStyle?: WebBrowserPresentationStyle;
64
71
  /**
65
72
  * Name to assign to the popup window.
66
73
  * @platform web
@@ -72,6 +79,21 @@ export declare type WebBrowserOpenOptions = {
72
79
  */
73
80
  windowFeatures?: string | WebBrowserWindowFeatures;
74
81
  };
82
+ /**
83
+ * If there is no native AuthSession implementation available (which is the case on Android) the params inherited from
84
+ * [`WebBrowserOpenOptions`](#webbrowseropenoptions) will be used in the browser polyfill. Otherwise, the browser parameters will be ignored.
85
+ */
86
+ export declare type AuthSessionOpenOptions = WebBrowserOpenOptions & {
87
+ /**
88
+ * Determines whether the session should ask the browser for a private authentication session.
89
+ * Set this to `true` to request that the browser doesn’t share cookies or other browsing data between the authentication session and the user’s normal browser session.
90
+ * Whether the request is honored depends on the user’s default web browser.
91
+ *
92
+ * @default false
93
+ * @platform ios 13+
94
+ */
95
+ preferEphemeralSession?: boolean;
96
+ };
75
97
  export declare type WebBrowserAuthSessionResult = WebBrowserRedirectResult | WebBrowserResult;
76
98
  export declare type WebBrowserCustomTabsResults = {
77
99
  /**
@@ -114,6 +136,48 @@ export declare enum WebBrowserResultType {
114
136
  OPENED = "opened",
115
137
  LOCKED = "locked"
116
138
  }
139
+ /**
140
+ * A browser presentation style. Its values are directly mapped to the [`UIModalPresentationStyle`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle).
141
+ *
142
+ * @platform ios
143
+ */
144
+ export declare enum WebBrowserPresentationStyle {
145
+ /**
146
+ * A presentation style in which the presented browser covers the screen.
147
+ */
148
+ FULL_SCREEN = "fullScreen",
149
+ /**
150
+ * A presentation style that partially covers the underlying content.
151
+ */
152
+ PAGE_SHEET = "pageSheet",
153
+ /**
154
+ * A presentation style that displays the browser centered in the screen.
155
+ */
156
+ FORM_SHEET = "formSheet",
157
+ /**
158
+ * A presentation style where the browser is displayed over the app's content.
159
+ */
160
+ CURRENT_CONTEXT = "currentContext",
161
+ /**
162
+ * A presentation style in which the browser view covers the screen.
163
+ */
164
+ OVER_FULL_SCREEN = "overFullScreen",
165
+ /**
166
+ * A presentation style where the browser is displayed over the app's content.
167
+ */
168
+ OVER_CURRENT_CONTEXT = "overCurrentContext",
169
+ /**
170
+ * A presentation style where the browser is displayed in a popover view.
171
+ */
172
+ POPOVER = "popover",
173
+ /**
174
+ * The default presentation style chosen by the system.
175
+ * On older iOS versions, falls back to `WebBrowserPresentationStyle.FullScreen`.
176
+ *
177
+ * @platform ios 13+
178
+ */
179
+ AUTOMATIC = "automatic"
180
+ }
117
181
  export declare type WebBrowserResult = {
118
182
  /**
119
183
  * Type of the result.
@@ -149,3 +213,4 @@ export declare type WebBrowserCompleteAuthSessionResult = {
149
213
  */
150
214
  message: string;
151
215
  };
216
+ //# sourceMappingURL=WebBrowser.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebBrowser.types.d.ts","sourceRoot":"","sources":["../src/WebBrowser.types.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAGF,oBAAY,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC;AAGjF,oBAAY,qBAAqB,GAAG;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACx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