Skip to content

Commit 3f67c48

Browse files
CP-12388: setup deepLink whitelist (#3334)
1 parent 06d744f commit 3f67c48

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* This is the whitelist of deeplinks that are allowed to be opened in the app
3+
* It is used to prevent malicious deeplinks from being opened in the app
4+
* It is also used to prevent deeplinks from being opened in the app that are not allowed
5+
**/
6+
export const DEEPLINK_WHITELIST = [
7+
'core://solanaLaunch',
8+
'core://stakecomplete',
9+
'core://watchlist',
10+
'core://portfolio',
11+
'core://onrampcompleted',
12+
'core://offrampcompleted',
13+
'core://receive',
14+
'core://trackTokenDetail',
15+
'core://track',
16+
'core://meld/onramp',
17+
'core://meld/offramp',
18+
'core://stake',
19+
'core://claimStakeReward',
20+
'core://addStake',
21+
'core://discoverCollectibles',
22+
'core://collectibleManagement',
23+
'core://tokenManagement',
24+
'core://send',
25+
'core://swap',
26+
'core://walletConnectScan',
27+
'core://activity',
28+
'core://browser',
29+
'core://browser/tabs',
30+
'core://browser/history',
31+
'core://accountSettings',
32+
'core://accountSettings/selectCurrency',
33+
'core://accountSettings/selectAppearance',
34+
'core://accountSettings/securityAndPrivacy',
35+
'core://accountSettings/connectedSites',
36+
'core://accountSettings/changePin',
37+
'core://accountSettings/manageAccounts',
38+
'core://accountSettings/manageNetworks',
39+
'core://accountSettings/addressBook',
40+
'core://accountSettings/selectAvatar',
41+
'core://accountSettings/notificationPreferences',
42+
'core://accountSettings/importWallet',
43+
'core://accountSettings/importPrivateKey',
44+
'core://accountSettings/importSeedWallet'
45+
]

packages/core-mobile/app/contexts/DeeplinkContext/utils/handleDeeplink.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import { dismissMeldStack } from 'features/meld/utils'
1111
import { offrampSend } from 'store/meld/slice'
1212
import { closeInAppBrowser } from 'utils/openInAppBrowser'
1313
import { ACTIONS, DeepLink, PROTOCOLS } from '../types'
14+
import { DEEPLINK_WHITELIST } from '../consts'
15+
16+
const lowercasedDeeplinkWhitelist = DEEPLINK_WHITELIST.map(url =>
17+
url.toLowerCase()
18+
)
1419

1520
export const handleDeeplink = ({
1621
deeplink,
@@ -74,6 +79,11 @@ export const handleDeeplink = ({
7479
closeInAppBrowser()
7580
dismissMeldStack(action, searchParams)
7681
} else {
82+
const baseUrl = deeplink.url.split('?')[0]?.toLowerCase()
83+
if (baseUrl && !lowercasedDeeplinkWhitelist.includes(baseUrl)) {
84+
Logger.warn(`${deeplink.url} is not allowed to be opened in the app`)
85+
return
86+
}
7787
const path = deeplink.url.split(':/')[1]
7888
path && navigateFromDeeplinkUrl(path)
7989
}

0 commit comments

Comments
 (0)