Skip to content

Commit

Permalink
feat: Wallet part of the https deeplinking (#82)
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Lanser <[email protected]>
Signed-off-by: Tom Lanser <[email protected]>
Co-authored-by: Jan <[email protected]>
  • Loading branch information
Tommylans and Jan authored Nov 30, 2023
1 parent a868ca2 commit 7ddd88f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
13 changes: 13 additions & 0 deletions apps/expo/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const invitationSchemes = [
'didcomm',
]

const associatedDomains = ['paradym.id', 'dev.paradym.id']

/**
* @type {import('@expo/config-types').ExpoConfig}
*/
Expand Down Expand Up @@ -77,6 +79,7 @@ const config = {
},
],
},
associatedDomains: associatedDomains.map((host) => 'applinks:' + host),
},
android: {
adaptiveIcon: {
Expand All @@ -92,6 +95,16 @@ const config = {
scheme,
},
})),
...associatedDomains.map((host) => ({
action: 'VIEW',
category: ['DEFAULT', 'BROWSABLE'],
autoVerify: true,
data: {
scheme: 'https',
host,
pathPrefix: '/invitation',
},
})),
],
},
extra: {
Expand Down
16 changes: 13 additions & 3 deletions apps/expo/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { AppAgent } from '@internal/agent'

import {
setupMediationWithDid,
AgentProvider,
hasMediationConfigured,
initializeAgent,
setupMediationWithDid,
useMessagePickup,
} from '@internal/agent'
import { config, Heading, Page, Paragraph, useToastController, XStack, YStack } from '@internal/ui'
Expand All @@ -15,7 +15,7 @@ import { Provider } from 'app/provider'
import { NoInternetToastProvider } from 'app/provider/NoInternetToastProvider'
import { isAndroid } from 'app/utils/platform'
import { useFonts } from 'expo-font'
import { Stack, SplashScreen } from 'expo-router'
import { SplashScreen, Stack } from 'expo-router'
import { useEffect, useState } from 'react'
import { useSafeAreaInsets } from 'react-native-safe-area-context'

Expand Down Expand Up @@ -64,8 +64,8 @@ export default function HomeLayout() {
if (!walletKey) return

const agent = await initializeAgent(walletKey).catch(() => {
toast.show('Could not initialize agent.')
setAgentInitializationFailed(true)
toast.show('Could not initialize agent.')
})
if (!agent) return

Expand Down Expand Up @@ -143,6 +143,16 @@ export default function HomeLayout() {
<NoInternetToastProvider>
<DeeplinkHandler>
<Stack screenOptions={{ headerShown: false }}>
{/**
* Workaround:
* The following screens are not rendered by the router.
* They are used to prevent the internal route to be executed.
* So now they are being redirected to the home screen. So the user will not see a 404.
**/}
<Stack.Screen name="invitation/[id]" redirect />
<Stack.Screen name="https/[...dummy]" redirect />
<Stack.Screen name="http/[...dummy]" redirect />

<Stack.Screen
options={{
presentation: 'modal',
Expand Down
5 changes: 5 additions & 0 deletions apps/expo/app/http/[...dummy].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Workaround: To prevent the routing of the deeplinks

export default function Screen() {
return <span></span>
}
5 changes: 5 additions & 0 deletions apps/expo/app/https/[...dummy].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Workaround: To prevent the routing of the deeplinks

export default function Screen() {
return <span></span>
}
5 changes: 5 additions & 0 deletions apps/expo/app/invitation/[id].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Workaround: To prevent the routing of the deeplinks

export default function Screen() {
return <span></span>
}
1 change: 1 addition & 0 deletions packages/agent/src/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export enum QrTypes {
OPENID = 'openid://',
OPENID_VC = 'openid-vc://',
DIDCOMM = 'didcomm://',
HTTPS = 'https://',
}

export const isOpenIdCredentialOffer = (url: string) => {
Expand Down

0 comments on commit 7ddd88f

Please sign in to comment.