Skip to content

Commit

Permalink
feat(ios): proximity flow (#267)
Browse files Browse the repository at this point in the history
Signed-off-by: Berend Sliedrecht <[email protected]>
  • Loading branch information
berendsliedrecht authored Jan 24, 2025
1 parent 5b3d08d commit 723c9d4
Show file tree
Hide file tree
Showing 20 changed files with 4,115 additions and 4,266 deletions.
6 changes: 5 additions & 1 deletion apps/easypid/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const config = {
'@animo-id/expo-mdoc-data-transfer',
{
ios: {
buildStatic: [],
buildStatic: ['RNReanimated', 'RNScreens', 'aries-askar', 'anoncreds', 'react-native-executorch'],
},
},
],
Expand All @@ -87,6 +87,10 @@ const config = {
useLegacyPackaging: true,
extraMavenRepos: ['https://s01.oss.sonatype.org/content/repositories/snapshots/'],
},
ios: {
deploymentTarget: '15.1',
useFrameworks: 'dynamic',
},
},
],
[
Expand Down
21 changes: 15 additions & 6 deletions apps/easypid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@expo-google-fonts/raleway": "^0.2.3",
"@hyperledger/anoncreds-react-native": "catalog:",
"@hyperledger/aries-askar-react-native": "catalog:",
"@hyperledger/indy-vdr-react-native": "catalog:",
"@package/agent": "workspace:*",
"@package/app": "workspace:*",
"@package/scanner": "workspace:*",
Expand Down Expand Up @@ -56,24 +55,34 @@
"react": "catalog:",
"react-native": "catalog:",
"react-native-argon2": "^2.0.1",
"react-native-executorch": "^0.1.2",
"react-native-executorch": "0.1.3",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "~2.16.2",
"react-native-gesture-handler": "~2.18.1",
"react-native-get-random-values": "~1.11.0",
"react-native-keychain": "^8.2.0",
"react-native-mmkv": "^2.12.2",
"react-native-qrcode-svg": "^6.3.12",
"react-native-reanimated": "~3.10.1",
"react-native-reanimated": "~3.15.5",
"react-native-reanimated-carousel": "^3.5.1",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "~3.31.1",
"react-native-screens": "~3.34.1",
"react-native-svg": "15.9.0"
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@tamagui/babel-plugin": "1.109.5",
"@tamagui/babel-plugin": "1.122.6",
"babel-plugin-syntax-hermes-parser": "^0.25.1",
"expo-build-properties": "^0.12.5",
"typescript": "catalog:"
},
"expo": {
"install": {
"exclude": [
"react-native@~0.74.0",
"react-native-reanimated@~3.10.0",
"react-native-gesture-handler@~2.16.1",
"react-native-screens@~3.31.1"
]
}
}
}
17 changes: 8 additions & 9 deletions apps/easypid/src/features/proximity/mdocProximity.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { mdocDataTransfer } from '@animo-id/expo-mdoc-data-transfer'
import {
COSEKey,
DataItem,
Expand All @@ -15,9 +16,6 @@ import type { EasyPIDAppAgent, FormattedSubmission, MdocRecord } from '@package/
import { handleBatchCredential } from '@package/agent/src/batch'
import { type Permission, PermissionsAndroid, Platform } from 'react-native'

const requireMdocDataTransfer = () =>
require('@animo-id/expo-mdoc-data-transfer') as typeof import('@animo-id/expo-mdoc-data-transfer')

type ShareDeviceResponseOptions = {
sessionTranscript: Uint8Array
deviceRequest: Uint8Array
Expand Down Expand Up @@ -53,8 +51,7 @@ export const checkMdocPermissions = async () => {
}

export const getMdocQrCode = async () => {
const mdt = requireMdocDataTransfer().mdocDataTransfer.instance()
mdt.enableNfc()
const mdt = mdocDataTransfer.instance()
const qrData = await mdt.startQrEngagement()
return qrData
}
Expand All @@ -67,10 +64,12 @@ export const getMdocQrCode = async () => {
*
*/
export const waitForDeviceRequest = async () => {
const mdt = requireMdocDataTransfer().mdocDataTransfer.instance()
const mdt = mdocDataTransfer.instance()
const { deviceRequest, sessionTranscript } = await mdt.waitForDeviceRequest()

const encodedSessionTranscript = cborEncode(DataItem.fromData(cborDecode(sessionTranscript)))
// current bug on android required re-encapsulation
const encodedSessionTranscript =
Platform.OS === 'android' ? cborEncode(DataItem.fromData(cborDecode(sessionTranscript))) : sessionTranscript

return { deviceRequest, sessionTranscript: encodedSessionTranscript }
}
Expand Down Expand Up @@ -114,7 +113,7 @@ export const shareDeviceResponse = async (options: ShareDeviceResponseOptions) =
crypto: MdocContext['crypto']
}

const mdt = requireMdocDataTransfer().mdocDataTransfer.instance()
const mdt = mdocDataTransfer.instance()

if (mdoc.documents.length > 1) {
throw new Error('Only one mdoc supported at the moment due to only being able to sign with one device key')
Expand All @@ -138,6 +137,6 @@ export const shareDeviceResponse = async (options: ShareDeviceResponseOptions) =
}

export const shutdownDataTransfer = () => {
const mdt = requireMdocDataTransfer().mdocDataTransfer.instance()
const mdt = mdocDataTransfer.instance()
mdt.shutdown()
}
10 changes: 2 additions & 8 deletions apps/easypid/src/features/wallet/FunkeOfflineQrScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
useToastController,
} from '@package/ui'
import { useRouter } from 'expo-router'
import { useHaptics } from 'packages/app/src'
import { isIos, useHaptics } from 'packages/app/src'
import { useEffect, useState } from 'react'
import { Alert, Linking, useWindowDimensions } from 'react-native'
import { useMMKVBoolean } from 'react-native-mmkv'
Expand Down Expand Up @@ -56,6 +56,7 @@ export function FunkeOfflineQrScreen() {
}, [arePermissionsGranted])

const handlePermissions = async () => {
if (isIos()) return { granted: true, shouldShowSettings: false }
const permissions = await requestMdocPermissions()

if (!permissions) {
Expand Down Expand Up @@ -126,13 +127,6 @@ export function FunkeOfflineQrScreen() {
})
)

useEffect(() => {
// Cleanup function that runs when component unmounts
return () => {
shutdownDataTransfer()
}
}, [])

const onCancel = () => {
back()
shutdownDataTransfer()
Expand Down
5 changes: 0 additions & 5 deletions apps/easypid/src/features/wallet/FunkeWalletScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ export function FunkeWalletScreen() {
const pushToPidSetup = withHaptics(() => push('/pidSetup'))
const pushToAbout = withHaptics(() => push('/menu/about'))
const pushToOffline = () => {
if (Platform.OS === 'ios') {
toast.show('This feature is not supported on your OS yet.', { customData: { preset: 'warning' } })
return
}

withHaptics(() => push('/offline'))()
}

Expand Down
19 changes: 14 additions & 5 deletions apps/paradym/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"@animo-id/expo-secure-environment": "catalog:",
"@hyperledger/anoncreds-react-native": "catalog:",
"@hyperledger/aries-askar-react-native": "catalog:",
"@hyperledger/indy-vdr-react-native": "catalog:",
"@package/agent": "workspace:*",
"@package/app": "workspace:*",
"@package/ui": "workspace:*",
Expand Down Expand Up @@ -42,16 +41,26 @@
"react": "catalog:",
"react-native": "catalog:",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "~2.16.2",
"react-native-gesture-handler": "~2.18.1",
"react-native-get-random-values": "~1.11.0",
"react-native-reanimated": "~3.10.1",
"react-native-reanimated": "~3.15.5",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "~3.31.1",
"react-native-screens": "~3.34.1",
"react-native-svg": "15.9.0"
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@tamagui/babel-plugin": "1.109.5",
"@tamagui/babel-plugin": "1.122.6",
"typescript": "catalog:"
},
"expo": {
"install": {
"exclude": [
"react-native@~0.74.0",
"react-native-reanimated@~3.10.0",
"react-native-gesture-handler@~2.16.1",
"react-native-screens@~3.31.1"
]
}
}
}
20 changes: 15 additions & 5 deletions apps/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
"react": "catalog:",
"react-device-frameset": "^1.3.4",
"react-native": "catalog:",
"react-native-gesture-handler": "~2.16.2",
"react-native-gesture-handler": "~2.18.1",
"react-native-get-random-values": "~1.11.0",
"react-native-reanimated": "~3.10.1",
"react-native-reanimated": "~3.15.5",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "~3.31.1",
"react-native-screens": "~3.34.1",
"react-native-svg": "15.9.0"
},
"devDependencies": {
Expand All @@ -60,14 +60,24 @@
"@storybook/react": "^7.6.18",
"@storybook/react-native": "^7.6.18",
"@storybook/react-webpack5": "^7.6.18",
"@tamagui/babel-plugin": "1.109.5",
"@tamagui/babel-plugin": "1.122.6",
"@types/react": "~18.2.79",
"babel-loader": "^8.2.3",
"babel-plugin-react-docgen-typescript": "^1.5.1",
"babel-plugin-react-native-web": "^0.19.10",
"cross-env": "^7.0.3",
"storybook": "^7.6.18",
"tamagui-loader": "1.109.5",
"tamagui-loader": "1.122.6",
"typescript": "catalog:"
},
"expo": {
"install": {
"exclude": [
"react-native@~0.74.0",
"react-native-reanimated@~3.10.0",
"react-native-gesture-handler@~2.16.1",
"react-native-screens@~3.31.1"
]
}
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"devDependencies": {
"@biomejs/biome": "1.8.1",
"check-dependency-version-consistency": "^3.0.3",
"check-dependency-version-consistency": "^3.3.0",
"typescript": "catalog:"
},
"pnpm": {
Expand All @@ -37,17 +37,17 @@
"@credo-ts/node": "catalog:",
"@credo-ts/cheqd": "catalog:",
"@credo-ts/core": "catalog:",
"@credo-ts/indy-vdr": "catalog:",
"@credo-ts/openid4vc": "catalog:",
"@credo-ts/question-answer": "catalog:",
"@credo-ts/react-native": "catalog:",
"@sphereon/pex-models": "catalog:",
"@openid-federation/core": "catalog:"
},
"patchedDependencies": {
"@hyperledger/[email protected]": "patches/@[email protected]",
"@credo-ts/[email protected]": "patches/@[email protected]",
"@sphereon/kmp-mdl-mdoc": "patches/@sphereon__kmp-mdl-mdoc.patch"
"@sphereon/kmp-mdl-mdoc": "patches/@sphereon__kmp-mdl-mdoc.patch",
"@hyperledger/[email protected]": "patches/@[email protected]",
"@hyperledger/[email protected]": "patches/@[email protected]"
}
},
"packageManager": "[email protected]+sha256.06e65a4965baff6d6097f9c8f75c35f6d420974dbc03d775009056a69edfd271"
Expand Down
12 changes: 10 additions & 2 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"@credo-ts/askar": "catalog:",
"@credo-ts/cheqd": "catalog:",
"@credo-ts/core": "catalog:",
"@credo-ts/indy-vdr": "catalog:",
"@credo-ts/openid4vc": "catalog:",
"@credo-ts/question-answer": "catalog:",
"@credo-ts/react-hooks": "catalog:",
Expand All @@ -26,10 +25,19 @@
"peerDependencies": {
"@hyperledger/anoncreds-react-native": "catalog:",
"@hyperledger/aries-askar-react-native": "catalog:",
"@hyperledger/indy-vdr-react-native": "catalog:",
"expo": "catalog:"
},
"devDependencies": {
"@types/fast-text-encoding": "^1.0.3"
},
"expo": {
"install": {
"exclude": [
"react-native@~0.74.0",
"react-native-reanimated@~3.10.0",
"react-native-gesture-handler@~2.16.1",
"react-native-screens@~3.31.1"
]
}
}
}
17 changes: 2 additions & 15 deletions packages/agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,13 @@ import {
WsOutboundTransport,
X509Module,
} from '@credo-ts/core'
import {
IndyVdrAnonCredsRegistry,
IndyVdrIndyDidResolver,
IndyVdrModule,
IndyVdrSovDidResolver,
} from '@credo-ts/indy-vdr'
import { OpenId4VcHolderModule } from '@credo-ts/openid4vc'
import { useAgent as useAgentLib } from '@credo-ts/react-hooks'
import { agentDependencies } from '@credo-ts/react-native'
import { anoncreds } from '@hyperledger/anoncreds-react-native'
import { ariesAskar } from '@hyperledger/aries-askar-react-native'
import { indyVdr } from '@hyperledger/indy-vdr-react-native'

import { bdrPidIssuerCertificate, pidSchemes } from '../../../apps/easypid/src/constants'
import { indyNetworks } from './indyNetworks'
import { appLogger } from './logger'

const askarModule = new AskarModule({
Expand Down Expand Up @@ -161,12 +153,11 @@ export const initializeFullAgent = async ({
new KeyDidResolver(),
new JwkDidResolver(),
// new CheqdDidResolver(),
new IndyVdrSovDidResolver(),
new IndyVdrIndyDidResolver(),
],
}),
anoncreds: new AnonCredsModule({
registries: [new IndyVdrAnonCredsRegistry() /* new CheqdAnonCredsRegistry(), new DidWebAnonCredsRegistry() */],
// @ts-expect-error: will be fixed when cheqd is introduced
registries: [],
anoncreds,
}),

Expand All @@ -175,10 +166,6 @@ export const initializeFullAgent = async ({
mediatorPickupStrategy: MediatorPickupStrategy.None,
}),

indyVdr: new IndyVdrModule({
indyVdr,
networks: indyNetworks,
}),
connections: new ConnectionsModule({
autoAcceptConnections: true,
}),
Expand Down
11 changes: 0 additions & 11 deletions packages/agent/src/indyNetworks.ts

This file was deleted.

Loading

0 comments on commit 723c9d4

Please sign in to comment.