Skip to content

Commit ce3b3f6

Browse files
committed
chore(runway): cherry-pick fix: support webcredentials cp-7.71.0 (#27741)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This pr patch the expo-web-browser to support https redirect schema Taking reference from expo-web-browser sdk 55 https://github.com/expo/expo/blob/308031a6665f885811760aff7aebb68aea4a846a/packages/expo-web-browser/ios/WebAuthSession.swift#L36 <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: expo-web-browser support https redirect scheme CHANGELOG entry: use webcredential for ios google login ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Moderate risk because it changes iOS `ASWebAuthenticationSession` callback configuration and entitlements, which can affect login/redirect flows and associated-domain behavior. > > **Overview** > Enables **HTTPS redirect-based auth callbacks** on iOS by patching `expo-web-browser`’s `WebAuthSession` to use iOS 17.4+/macOS 14.4+ `.https(host:path)` callbacks when the `redirectUrl` is `https`, falling back to the legacy `callbackURLScheme` behavior otherwise. > > Updates iOS entitlements (`MetaMask.entitlements` and `MetaMaskDebug.entitlements`) to include `webcredentials:link.metamask.io`, and wires the patch into the build via a Yarn `resolutions` entry plus corresponding `yarn.lock` changes. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7730be3. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent aa8a788 commit ce3b3f6

5 files changed

Lines changed: 65 additions & 2 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
diff --git a/ios/WebAuthSession.swift b/ios/WebAuthSession.swift
2+
index 0d8101b01d7c6cd803acf6a359ceaa026993bdd0..c1beeabd962e561bf48392d58c084272247a95cc 100644
3+
--- a/ios/WebAuthSession.swift
4+
+++ b/ios/WebAuthSession.swift
5+
@@ -20,17 +20,34 @@ final internal class WebAuthSession {
6+
private var presentationContextProvider = PresentationContextProvider()
7+
8+
init(authUrl: URL, redirectUrl: URL?, options: AuthSessionOptions) {
9+
- self.authSession = ASWebAuthenticationSession(
10+
- url: authUrl,
11+
- callbackURLScheme: redirectUrl?.scheme,
12+
- completionHandler: { callbackUrl, error in
13+
- self.finish(with: [
14+
- "type": callbackUrl != nil ? "success" : "cancel",
15+
- "url": callbackUrl?.absoluteString,
16+
- "error": error?.localizedDescription
17+
- ])
18+
- }
19+
- )
20+
+ let completionHandler: (URL?, Error?) -> Void = { callbackUrl, error in
21+
+ self.finish(with: [
22+
+ "type": callbackUrl != nil ? "success" : "cancel",
23+
+ "url": callbackUrl?.absoluteString,
24+
+ "error": error?.localizedDescription
25+
+ ])
26+
+ }
27+
+
28+
+ // iOS 17.4+/macOS 14.4+ supports HTTPS callbacks with host/path matching
29+
+ if #available(iOS 17.4, macOS 14.4, *),
30+
+ let redirectUrl,
31+
+ redirectUrl.scheme?.lowercased() == "https",
32+
+ let host = redirectUrl.host(percentEncoded: false),
33+
+ !host.isEmpty {
34+
+ let rawPath = redirectUrl.path
35+
+ let path = (rawPath.isEmpty || rawPath == "/") ? "" : rawPath
36+
+ self.authSession = ASWebAuthenticationSession(
37+
+ url: authUrl,
38+
+ callback: .https(host: host, path: path),
39+
+ completionHandler: completionHandler
40+
+ )
41+
+ } else {
42+
+ self.authSession = ASWebAuthenticationSession(
43+
+ url: authUrl,
44+
+ callbackURLScheme: redirectUrl?.scheme,
45+
+ completionHandler: completionHandler
46+
+ )
47+
+ }
48+
self.authSession?.prefersEphemeralWebBrowserSession = options.preferEphemeralSession
49+
}
50+

ios/MetaMask/MetaMask.entitlements

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<string>applinks:metamask-alternate.app.link</string>
1616
<string>applinks:link.metamask.io</string>
1717
<string>applinks:link-test.metamask.io</string>
18+
<string>webcredentials:link.metamask.io</string>
1819
</array>
1920
<key>com.apple.developer.in-app-payments</key>
2021
<array>

ios/MetaMask/MetaMaskDebug.entitlements

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<string>applinks:metamask-alternate.app.link</string>
1616
<string>applinks:link.metamask.io</string>
1717
<string>applinks:link-test.metamask.io</string>
18+
<string>webcredentials:link.metamask.io</string>
1819
</array>
1920
<key>com.apple.developer.in-app-payments</key>
2021
<array>

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@
185185
"@metamask/accounts-controller": "37.0.0",
186186
"@metamask/core-backend": "^5.0.0",
187187
"bn.js@npm:4.11.6": "4.12.3",
188-
"bn.js@npm:5.2.1": "5.2.3"
188+
"bn.js@npm:5.2.1": "5.2.3",
189+
"expo-web-browser@npm:~14.0.2": "patch:expo-web-browser@npm%3A14.0.2#~/.yarn/patches/expo-web-browser-npm-14.0.2-98d00ce880.patch"
189190
},
190191
"dependencies": {
191192
"@config-plugins/detox": "^9.0.0",

yarn.lock

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29212,7 +29212,7 @@ __metadata:
2921229212
languageName: node
2921329213
linkType: hard
2921429214

29215-
"expo-web-browser@npm:~14.0.2":
29215+
"expo-web-browser@npm:14.0.2":
2921629216
version: 14.0.2
2921729217
resolution: "expo-web-browser@npm:14.0.2"
2921829218
peerDependencies:
@@ -29222,6 +29222,16 @@ __metadata:
2922229222
languageName: node
2922329223
linkType: hard
2922429224

29225+
"expo-web-browser@patch:expo-web-browser@npm%3A14.0.2#~/.yarn/patches/expo-web-browser-npm-14.0.2-98d00ce880.patch":
29226+
version: 14.0.2
29227+
resolution: "expo-web-browser@patch:expo-web-browser@npm%3A14.0.2#~/.yarn/patches/expo-web-browser-npm-14.0.2-98d00ce880.patch::version=14.0.2&hash=158d79"
29228+
peerDependencies:
29229+
expo: "*"
29230+
react-native: "*"
29231+
checksum: 10/68989f3d82afed74782e67aa9106df73c76a817cea8f7dbee54206177efb7176962f050b421699cebeb87a0cf2acad501e2dcf9d1e94d487b3fde07c8c20dc99
29232+
languageName: node
29233+
linkType: hard
29234+
2922529235
"expo@npm:~52.0.47":
2922629236
version: 52.0.47
2922729237
resolution: "expo@npm:52.0.47"

0 commit comments

Comments
 (0)