Skip to content

Commit 5e444bd

Browse files
feat: add test app universal link support (MetaMask#27811)
<!-- 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** <!-- 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? --> This PR adds test app universal link support to facilitate testing non-production builds ## **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: ## **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] > **Low Risk** > Low risk: this only broadens the set of recognized universal-link hostnames and updates iOS associated-domain/Branch domain allowlists; no auth, signing, or transaction logic changes. > > **Overview** > Adds support for additional **test app** universal-link domains (including an alternate host) so non-production builds can open MetaMask via `https://metamask.test-app.link` and `https://metamask-alternate.test-app.link`. > > Updates universal-link validation/host allowlists in `handleUniversalLink` and deeplink utils, extends unit tests accordingly, and fixes iOS `Info.plist`/entitlements domain lists to use the `test-app.link` hostnames. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 2f29a9a. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 8a7bced commit 5e444bd

8 files changed

Lines changed: 31 additions & 11 deletions

File tree

app/core/AppConstants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ export default {
9696
},
9797
MM_UNIVERSAL_LINK_HOST: 'metamask.app.link',
9898
MM_UNIVERSAL_LINK_HOST_ALTERNATE: 'metamask-alternate.app.link',
99+
MM_UNIVERSAL_LINK_TEST_APP_HOST: 'metamask.test-app.link',
100+
MM_UNIVERSAL_LINK_TEST_APP_HOST_ALTERNATE: 'metamask-alternate.test-app.link',
99101
MM_IO_UNIVERSAL_LINK_HOST: 'link.metamask.io',
100102
MM_IO_UNIVERSAL_LINK_TEST_HOST: 'link-test.metamask.io',
101103
MM_DEEP_ITMS_APP_LINK: 'https://metamask.app.link/skAH3BaF99',

app/core/DeeplinkManager/handlers/legacy/handleUniversalLink.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ import Logger from '../../../../util/Logger';
5757
const {
5858
MM_UNIVERSAL_LINK_HOST,
5959
MM_UNIVERSAL_LINK_HOST_ALTERNATE,
60+
MM_UNIVERSAL_LINK_TEST_APP_HOST,
61+
MM_UNIVERSAL_LINK_TEST_APP_HOST_ALTERNATE,
6062
MM_IO_UNIVERSAL_LINK_HOST,
6163
MM_IO_UNIVERSAL_LINK_TEST_HOST,
6264
} = AppConstants;
@@ -221,6 +223,8 @@ async function handleUniversalLink({
221223
const isSupportedDomain =
222224
urlObj.hostname === MM_UNIVERSAL_LINK_HOST ||
223225
urlObj.hostname === MM_UNIVERSAL_LINK_HOST_ALTERNATE ||
226+
urlObj.hostname === MM_UNIVERSAL_LINK_TEST_APP_HOST ||
227+
urlObj.hostname === MM_UNIVERSAL_LINK_TEST_APP_HOST_ALTERNATE ||
224228
urlObj.hostname === MM_IO_UNIVERSAL_LINK_HOST ||
225229
urlObj.hostname === MM_IO_UNIVERSAL_LINK_TEST_HOST;
226230

app/core/DeeplinkManager/util/deeplinks/index.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ describe('deeplinks utils', () => {
1515
expect(
1616
isMetaMaskUniversalLink('https://metamask.test-app.link/home'),
1717
).toBe(true);
18+
expect(
19+
isMetaMaskUniversalLink(
20+
'https://metamask-alternate.test-app.link/swap',
21+
),
22+
).toBe(true);
1823
expect(
1924
isMetaMaskUniversalLink('https://link-test.metamask.io/send'),
2025
).toBe(true);
@@ -80,6 +85,9 @@ describe('deeplinks utils', () => {
8085
expect(isInternalDeepLink('https://metamask.test-app.link/home')).toBe(
8186
true,
8287
);
88+
expect(
89+
isInternalDeepLink('https://metamask-alternate.test-app.link/dapp/x'),
90+
).toBe(true);
8391
});
8492

8593
it('does not identify external URLs as internal', () => {

app/core/DeeplinkManager/util/deeplinks/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@ import AppConstants from '../../../AppConstants';
33
const {
44
MM_UNIVERSAL_LINK_HOST,
55
MM_UNIVERSAL_LINK_HOST_ALTERNATE,
6+
MM_UNIVERSAL_LINK_TEST_APP_HOST,
7+
MM_UNIVERSAL_LINK_TEST_APP_HOST_ALTERNATE,
68
MM_IO_UNIVERSAL_LINK_HOST,
79
MM_IO_UNIVERSAL_LINK_TEST_HOST,
810
} = AppConstants;
911

10-
const METAMASK_HOSTS = [
12+
const METAMASK_HOSTS: readonly string[] = [
1113
...new Set(
1214
[
13-
MM_UNIVERSAL_LINK_HOST || 'link.metamask.io',
14-
MM_UNIVERSAL_LINK_HOST_ALTERNATE || 'metamask-alternate.app.link',
15-
MM_IO_UNIVERSAL_LINK_HOST || 'link.metamask.io',
16-
MM_IO_UNIVERSAL_LINK_TEST_HOST || 'link-test.metamask.io',
17-
'metamask.app.link',
18-
'metamask.test-app.link',
15+
MM_UNIVERSAL_LINK_HOST,
16+
MM_UNIVERSAL_LINK_HOST_ALTERNATE,
17+
MM_IO_UNIVERSAL_LINK_HOST,
18+
MM_IO_UNIVERSAL_LINK_TEST_HOST,
19+
MM_UNIVERSAL_LINK_TEST_APP_HOST,
20+
MM_UNIVERSAL_LINK_TEST_APP_HOST_ALTERNATE,
1921
].filter(Boolean),
2022
),
2123
];

ios/MetaMask/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@
138138
<string>link.metamask.io</string>
139139
<string>link-test.metamask.io</string>
140140
<string>metamask-alternate.app.link</string>
141-
<string>metamask.test.app.link</string>
142-
<string>metamask-alternate.test.app.link</string>
141+
<string>metamask.test-app.link</string>
142+
<string>metamask-alternate.test-app.link</string>
143143
</array>
144144
<key>fox_code</key>
145145
<string>$(MM_FOX_CODE)</string>

ios/MetaMask/MetaMask-Flask-Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@
129129
<string>link.metamask.io</string>
130130
<string>link-test.metamask.io</string>
131131
<string>metamask-alternate.app.link</string>
132-
<string>metamask.test.app.link</string>
133-
<string>metamask-alternate.test.app.link</string>
132+
<string>metamask.test-app.link</string>
133+
<string>metamask-alternate.test-app.link</string>
134134
</array>
135135
<key>fox_code</key>
136136
<string>$(MM_FOX_CODE)</string>

ios/MetaMask/MetaMask.entitlements

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
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>applinks:metamask.test-app.link</string>
19+
<string>applinks:metamask-alternate.test-app.link</string>
1820
<string>webcredentials:link.metamask.io</string>
1921
</array>
2022
<key>com.apple.developer.in-app-payments</key>

ios/MetaMask/MetaMaskDebug.entitlements

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
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>applinks:metamask.test-app.link</string>
19+
<string>applinks:metamask-alternate.test-app.link</string>
1820
<string>webcredentials:link.metamask.io</string>
1921
</array>
2022
<key>com.apple.developer.in-app-payments</key>

0 commit comments

Comments
 (0)