expo-web-browser 10.0.3 → 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,11 +10,25 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
- ## 10.0.32021-10-21
13
+ ## 10.2.0 — 2022-04-18
14
14
 
15
- _This version does not introduce any user-facing changes._
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
26
+
27
+ ### 🐛 Bug fixes
28
+
29
+ - Fix `Plugin with id 'maven' not found` build error from Android Gradle 7. ([#16080](https://github.com/expo/expo/pull/16080) by [@kudo](https://github.com/kudo))
16
30
 
17
- ## 10.0.2 — 2021-10-15
31
+ ## 10.1.0 — 2021-12-03
18
32
 
19
33
  _This version does not introduce any user-facing changes._
20
34
 
package/README.md CHANGED
@@ -4,16 +4,16 @@ 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
 
16
- For bare React Native projects, you must ensure that you have [installed and configured the `react-native-unimodules` package](https://github.com/expo/expo/tree/master/packages/react-native-unimodules) before continuing.
16
+ For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
17
17
 
18
18
  ### Add the package to your npm dependencies
19
19
 
@@ -1,64 +1,81 @@
1
1
  apply plugin: 'com.android.library'
2
2
  apply plugin: 'kotlin-android'
3
- apply plugin: 'maven'
3
+ apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '10.0.3'
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
 
24
- // Upload android library to maven with javadoc and android sources
25
- configurations {
26
- deployerJars
27
- }
28
-
29
39
  // Creating sources with comments
30
40
  task androidSourcesJar(type: Jar) {
31
41
  classifier = 'sources'
32
42
  from android.sourceSets.main.java.srcDirs
33
43
  }
34
44
 
35
- // Put the androidSources and javadoc to the artifacts
36
- artifacts {
37
- archives androidSourcesJar
38
- }
39
-
40
- uploadArchives {
41
- repositories {
42
- mavenDeployer {
43
- configuration = configurations.deployerJars
44
- repository(url: mavenLocal().url)
45
+ afterEvaluate {
46
+ publishing {
47
+ publications {
48
+ release(MavenPublication) {
49
+ from components.release
50
+ // Add additional sourcesJar to artifacts
51
+ artifact(androidSourcesJar)
52
+ }
53
+ }
54
+ repositories {
55
+ maven {
56
+ url = mavenLocal().url
57
+ }
45
58
  }
46
59
  }
47
60
  }
48
61
 
49
62
  android {
50
- compileSdkVersion safeExtGet("compileSdkVersion", 30)
63
+ compileSdkVersion safeExtGet("compileSdkVersion", 31)
51
64
 
52
65
  compileOptions {
53
- sourceCompatibility JavaVersion.VERSION_1_8
54
- 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
55
72
  }
56
73
 
57
74
  defaultConfig {
58
75
  minSdkVersion safeExtGet("minSdkVersion", 21)
59
- targetSdkVersion safeExtGet("targetSdkVersion", 30)
76
+ targetSdkVersion safeExtGet("targetSdkVersion", 31)
60
77
  versionCode 18
61
- versionName '10.0.3'
78
+ versionName '10.2.0'
62
79
  }
63
80
  lintOptions {
64
81
  abortOnError false
@@ -70,10 +87,10 @@ dependencies {
70
87
 
71
88
  api "androidx.browser:browser:1.2.0"
72
89
 
73
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.4.21')}"
90
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
74
91
 
75
- if (project.findProject(':unimodules-test-core')) {
76
- testImplementation project(':unimodules-test-core')
92
+ if (project.findProject(':expo-modules-test-core')) {
93
+ testImplementation project(':expo-modules-test-core')
77
94
  }
78
95
  testImplementation "org.robolectric:robolectric:4.3.1"
79
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;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,GAAG,CAAC,WAAW,CAAC,CAAC;QAC9E,aAAa,CAAC,QAAQ,CAAC,CAAC;Q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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}\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AAC;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,43 +1,48 @@
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
- * _Android only_. Returns a list of applications package names supporting Custom Tabs, Custom Tabs
4
+ * Returns a list of applications package names supporting Custom Tabs, Custom Tabs
5
5
  * service, user chosen and preferred one. This may not be fully reliable, since it uses
6
6
  * `PackageManager.getResolvingActivities` under the hood. (For example, some browsers might not be
7
7
  * present in browserPackages list once another browser is set to default.)
8
8
  *
9
9
  * @return The promise which fulfils with [`WebBrowserCustomTabsResults`](#webbrowsercustomtabsresults) object.
10
+ * @platform android
10
11
  */
11
12
  export declare function getCustomTabsSupportingBrowsersAsync(): Promise<WebBrowserCustomTabsResults>;
12
13
  /**
13
- * _Android only_. This method calls `warmUp` method on [CustomTabsClient](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#warmup(long))
14
+ * This method calls `warmUp` method on [CustomTabsClient](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#warmup(long))
14
15
  * for specified package.
15
16
  *
16
- * @param browserPackage _Optional_ - Package of browser to be warmed up. If not set, preferred browser will be warmed.
17
+ * @param browserPackage Package of browser to be warmed up. If not set, preferred browser will be warmed.
17
18
  *
18
- * @return A promise which fulfils with `{ package: string }` object.
19
+ * @return A promise which fulfils with `WebBrowserWarmUpResult` object.
20
+ * @platform android
19
21
  */
20
22
  export declare function warmUpAsync(browserPackage?: string): Promise<WebBrowserWarmUpResult>;
21
23
  /**
22
- * _Android only_. This method initiates (if needed) [CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession.html#maylaunchurl)
24
+ * This method initiates (if needed) [CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession.html#maylaunchurl)
23
25
  * and calls its `mayLaunchUrl` method for browser specified by the package.
24
26
  *
25
27
  * @param url The url of page that is likely to be loaded first when opening browser.
26
- * @param browserPackage _Optional_ - Package of browser to be informed. If not set, preferred browser will be used.
28
+ * @param browserPackage Package of browser to be informed. If not set, preferred
29
+ * browser will be used.
27
30
  *
28
- * @return A promise which fulfils with `{ package: string }` object.
31
+ * @return A promise which fulfils with `WebBrowserMayInitWithUrlResult` object.
32
+ * @platform android
29
33
  */
30
34
  export declare function mayInitWithUrlAsync(url: string, browserPackage?: string): Promise<WebBrowserMayInitWithUrlResult>;
31
35
  /**
32
- * _Android only_. This methods removes all bindings to services created by [`warmUpAsync`](#webbrowserwarmupasyncbrowserpackage)
36
+ * This methods removes all bindings to services created by [`warmUpAsync`](#webbrowserwarmupasyncbrowserpackage)
33
37
  * or [`mayInitWithUrlAsync`](#webbrowsermayinitwithurlasyncurl-browserpackage). You should call
34
38
  * this method once you don't need them to avoid potential memory leaks. However, those binding
35
39
  * would be cleared once your application is destroyed, which might be sufficient in most cases.
36
40
  *
37
- * @param browserPackage _Optional_ - Package of browser to be cooled. If not set, preferred browser will be used.
41
+ * @param browserPackage Package of browser to be cooled. If not set, preferred browser will be used.
38
42
  *
39
- * @return The promise which fulfils with `{ package: string }` when cooling is performed, or
43
+ * @return The promise which fulfils with ` WebBrowserCoolDownResult` when cooling is performed, or
40
44
  * an empty object when there was no connection to be dismissed.
45
+ * @platform android
41
46
  */
42
47
  export declare function coolDownAsync(browserPackage?: string): Promise<WebBrowserCoolDownResult>;
43
48
  /**
@@ -57,9 +62,10 @@ export declare function coolDownAsync(browserPackage?: string): Promise<WebBrows
57
62
  */
58
63
  export declare function openBrowserAsync(url: string, browserParams?: WebBrowserOpenOptions): Promise<WebBrowserResult>;
59
64
  /**
60
- * _iOS only_. Dismisses the presented web browser.
65
+ * Dismisses the presented web browser.
61
66
  *
62
- * @return The promise which fulfils with `{ type: 'dismiss' }` object.
67
+ * @return The `void` on successful attempt, or throws error, if dismiss functionality is not avaiable.
68
+ * @platform ios
63
69
  */
64
70
  export declare function dismissBrowser(): void;
65
71
  /**
@@ -96,7 +102,7 @@ export declare function dismissBrowser(): void;
96
102
  *
97
103
  * @param url The url to open in the web browser. This should be a login page.
98
104
  * @param redirectUrl _Optional_ - The url to deep link back into your app. By default, this will be [`Constants.linkingUrl`](./constants/#expoconstantslinkinguri).
99
- * @param browserParams _Optional_ - An object with the same keys as [`WebBrowserOpenOptions`](#webbrowseropenoptions).
105
+ * @param options _Optional_ - An object extending the [`WebBrowserOpenOptions`](#webbrowseropenoptions).
100
106
  * If there is no native AuthSession implementation available (which is the case on Android)
101
107
  * these params will be used in the browser polyfill. If there is a native AuthSession implementation,
102
108
  * these params will be ignored.
@@ -107,10 +113,10 @@ export declare function dismissBrowser(): void;
107
113
  * - If the browser is closed using [`dismissBrowser`](#webbrowserdismissbrowser),
108
114
  * the Promise fulfills with `{ type: 'dismiss' }` object.
109
115
  */
110
- 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>;
111
117
  export declare function dismissAuthSession(): void;
112
118
  /**
113
- * _Web only_. Possibly completes an authentication session on web in a window popup. The method
119
+ * Possibly completes an authentication session on web in a window popup. The method
114
120
  * should be invoked on the page that the window redirects to.
115
121
  *
116
122
  * @param options
@@ -134,5 +140,8 @@ export declare function dismissAuthSession(): void;
134
140
  *
135
141
  * If the error `ERR_WEB_BROWSER_REDIRECT` was thrown, it may mean that the parent window was
136
142
  * reloaded before the auth was completed. In this case you'll need to close the child window manually.
143
+ *
144
+ * @platform web
137
145
  */
138
146
  export declare function maybeCompleteAuthSession(options?: WebBrowserCompleteAuthSessionOptions): WebBrowserCompleteAuthSessionResult;
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,wBAAwB,EACxB,2BAA2B,EAC3B,8BAA8B,EAC9B,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,sBAAsB,GACvB,CAAC;AAUF;;;;;;;;GAQG;AACH,wBAAsB,oCAAoC,IAAI,OAAO,CAAC,2BAA2B,CAAC,CASjG;AAGD;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAS1F;AAGD;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,8BAA8B,CAAC,CASzC;AAGD;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAS9F;AAKD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,aAAa,GAAE,qBAA0B,GACxC,OAAO,CAAC,gBAAgB,CAAC,CA2B3B;AAGD;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAKrC;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,2BAA2B,CAAC,CAYtC;AAGD,wBAAgB,kBAAkB,IAAI,IAAI,CAYzC;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,oCAAyC,GACjD,mCAAmC,CAKrC"}
@@ -1,8 +1,8 @@
1
1
  import { UnavailabilityError } from 'expo-modules-core';
2
2
  import { AppState, Linking, 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,
@@ -11,12 +11,13 @@ const emptyCustomTabsPackages = {
11
11
  };
12
12
  // @needsAudit
13
13
  /**
14
- * _Android only_. Returns a list of applications package names supporting Custom Tabs, Custom Tabs
14
+ * Returns a list of applications package names supporting Custom Tabs, Custom Tabs
15
15
  * service, user chosen and preferred one. This may not be fully reliable, since it uses
16
16
  * `PackageManager.getResolvingActivities` under the hood. (For example, some browsers might not be
17
17
  * present in browserPackages list once another browser is set to default.)
18
18
  *
19
19
  * @return The promise which fulfils with [`WebBrowserCustomTabsResults`](#webbrowsercustomtabsresults) object.
20
+ * @platform android
20
21
  */
21
22
  export async function getCustomTabsSupportingBrowsersAsync() {
22
23
  if (!ExponentWebBrowser.getCustomTabsSupportingBrowsersAsync) {
@@ -31,12 +32,13 @@ export async function getCustomTabsSupportingBrowsersAsync() {
31
32
  }
32
33
  // @needsAudit
33
34
  /**
34
- * _Android only_. This method calls `warmUp` method on [CustomTabsClient](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#warmup(long))
35
+ * This method calls `warmUp` method on [CustomTabsClient](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#warmup(long))
35
36
  * for specified package.
36
37
  *
37
- * @param browserPackage _Optional_ - Package of browser to be warmed up. If not set, preferred browser will be warmed.
38
+ * @param browserPackage Package of browser to be warmed up. If not set, preferred browser will be warmed.
38
39
  *
39
- * @return A promise which fulfils with `{ package: string }` object.
40
+ * @return A promise which fulfils with `WebBrowserWarmUpResult` object.
41
+ * @platform android
40
42
  */
41
43
  export async function warmUpAsync(browserPackage) {
42
44
  if (!ExponentWebBrowser.warmUpAsync) {
@@ -51,13 +53,15 @@ export async function warmUpAsync(browserPackage) {
51
53
  }
52
54
  // @needsAudit
53
55
  /**
54
- * _Android only_. This method initiates (if needed) [CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession.html#maylaunchurl)
56
+ * This method initiates (if needed) [CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession.html#maylaunchurl)
55
57
  * and calls its `mayLaunchUrl` method for browser specified by the package.
56
58
  *
57
59
  * @param url The url of page that is likely to be loaded first when opening browser.
58
- * @param browserPackage _Optional_ - Package of browser to be informed. If not set, preferred browser will be used.
60
+ * @param browserPackage Package of browser to be informed. If not set, preferred
61
+ * browser will be used.
59
62
  *
60
- * @return A promise which fulfils with `{ package: string }` object.
63
+ * @return A promise which fulfils with `WebBrowserMayInitWithUrlResult` object.
64
+ * @platform android
61
65
  */
62
66
  export async function mayInitWithUrlAsync(url, browserPackage) {
63
67
  if (!ExponentWebBrowser.mayInitWithUrlAsync) {
@@ -72,15 +76,16 @@ export async function mayInitWithUrlAsync(url, browserPackage) {
72
76
  }
73
77
  // @needsAudit
74
78
  /**
75
- * _Android only_. This methods removes all bindings to services created by [`warmUpAsync`](#webbrowserwarmupasyncbrowserpackage)
79
+ * This methods removes all bindings to services created by [`warmUpAsync`](#webbrowserwarmupasyncbrowserpackage)
76
80
  * or [`mayInitWithUrlAsync`](#webbrowsermayinitwithurlasyncurl-browserpackage). You should call
77
81
  * this method once you don't need them to avoid potential memory leaks. However, those binding
78
82
  * would be cleared once your application is destroyed, which might be sufficient in most cases.
79
83
  *
80
- * @param browserPackage _Optional_ - Package of browser to be cooled. If not set, preferred browser will be used.
84
+ * @param browserPackage Package of browser to be cooled. If not set, preferred browser will be used.
81
85
  *
82
- * @return The promise which fulfils with `{ package: string }` when cooling is performed, or
86
+ * @return The promise which fulfils with ` WebBrowserCoolDownResult` when cooling is performed, or
83
87
  * an empty object when there was no connection to be dismissed.
88
+ * @platform android
84
89
  */
85
90
  export async function coolDownAsync(browserPackage) {
86
91
  if (!ExponentWebBrowser.coolDownAsync) {
@@ -135,9 +140,10 @@ export async function openBrowserAsync(url, browserParams = {}) {
135
140
  }
136
141
  // @needsAudit
137
142
  /**
138
- * _iOS only_. Dismisses the presented web browser.
143
+ * Dismisses the presented web browser.
139
144
  *
140
- * @return The promise which fulfils with `{ type: 'dismiss' }` object.
145
+ * @return The `void` on successful attempt, or throws error, if dismiss functionality is not avaiable.
146
+ * @platform ios
141
147
  */
142
148
  export function dismissBrowser() {
143
149
  if (!ExponentWebBrowser.dismissBrowser) {
@@ -180,7 +186,7 @@ export function dismissBrowser() {
180
186
  *
181
187
  * @param url The url to open in the web browser. This should be a login page.
182
188
  * @param redirectUrl _Optional_ - The url to deep link back into your app. By default, this will be [`Constants.linkingUrl`](./constants/#expoconstantslinkinguri).
183
- * @param browserParams _Optional_ - An object with the same keys as [`WebBrowserOpenOptions`](#webbrowseropenoptions).
189
+ * @param options _Optional_ - An object extending the [`WebBrowserOpenOptions`](#webbrowseropenoptions).
184
190
  * If there is no native AuthSession implementation available (which is the case on Android)
185
191
  * these params will be used in the browser polyfill. If there is a native AuthSession implementation,
186
192
  * these params will be ignored.
@@ -191,18 +197,18 @@ export function dismissBrowser() {
191
197
  * - If the browser is closed using [`dismissBrowser`](#webbrowserdismissbrowser),
192
198
  * the Promise fulfills with `{ type: 'dismiss' }` object.
193
199
  */
194
- export async function openAuthSessionAsync(url, redirectUrl, browserParams = {}) {
200
+ export async function openAuthSessionAsync(url, redirectUrl, options = {}) {
195
201
  if (_authSessionIsNativelySupported()) {
196
202
  if (!ExponentWebBrowser.openAuthSessionAsync) {
197
203
  throw new UnavailabilityError('WebBrowser', 'openAuthSessionAsync');
198
204
  }
199
- if (Platform.OS === 'web') {
200
- return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl, browserParams);
205
+ if (['ios', 'web'].includes(Platform.OS)) {
206
+ return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl, options);
201
207
  }
202
208
  return ExponentWebBrowser.openAuthSessionAsync(url, redirectUrl);
203
209
  }
204
210
  else {
205
- return _openAuthSessionPolyfillAsync(url, redirectUrl, browserParams);
211
+ return _openAuthSessionPolyfillAsync(url, redirectUrl, options);
206
212
  }
207
213
  }
208
214
  // @docsMissing
@@ -222,7 +228,7 @@ export function dismissAuthSession() {
222
228
  }
223
229
  // @needsAudit
224
230
  /**
225
- * _Web only_. Possibly completes an authentication session on web in a window popup. The method
231
+ * Possibly completes an authentication session on web in a window popup. The method
226
232
  * should be invoked on the page that the window redirects to.
227
233
  *
228
234
  * @param options
@@ -246,6 +252,8 @@ export function dismissAuthSession() {
246
252
  *
247
253
  * If the error `ERR_WEB_BROWSER_REDIRECT` was thrown, it may mean that the parent window was
248
254
  * reloaded before the auth was completed. In this case you'll need to close the child window manually.
255
+ *
256
+ * @platform web
249
257
  */
250
258
  export function maybeCompleteAuthSession(options = {}) {
251
259
  if (ExponentWebBrowser.maybeCompleteAuthSession) {
@@ -289,15 +297,15 @@ function _onAppStateChangeAndroid(state) {
289
297
  async function _openBrowserAndWaitAndroidAsync(startUrl, browserParams = {}) {
290
298
  const appStateChangedToActive = new Promise((resolve) => {
291
299
  _onWebBrowserCloseAndroid = resolve;
292
- AppState.addEventListener('change', _onAppStateChangeAndroid);
293
300
  });
301
+ const stateChangeSubscription = AppState.addEventListener('change', _onAppStateChangeAndroid);
294
302
  let result = { type: WebBrowserResultType.CANCEL };
295
303
  let type = null;
296
304
  try {
297
305
  ({ type } = await openBrowserAsync(startUrl, browserParams));
298
306
  }
299
307
  catch (e) {
300
- AppState.removeEventListener('change', _onAppStateChangeAndroid);
308
+ stateChangeSubscription.remove();
301
309
  _onWebBrowserCloseAndroid = null;
302
310
  throw e;
303
311
  }
@@ -305,7 +313,7 @@ async function _openBrowserAndWaitAndroidAsync(startUrl, browserParams = {}) {
305
313
  await appStateChangedToActive;
306
314
  result = { type: WebBrowserResultType.DISMISS };
307
315
  }
308
- AppState.removeEventListener('change', _onAppStateChangeAndroid);
316
+ stateChangeSubscription.remove();
309
317
  _onWebBrowserCloseAndroid = null;
310
318
  return result;
311
319
  }