Skip to content

Commit

Permalink
fix(mdoc): shutdown when required and nfc 'working' (#236)
Browse files Browse the repository at this point in the history
Signed-off-by: Berend Sliedrecht <[email protected]>
  • Loading branch information
berendsliedrecht authored Nov 26, 2024
1 parent a707da3 commit 0d27f52
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 13 deletions.
1 change: 1 addition & 0 deletions apps/easypid/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import 'fast-text-encoding'
import 'expo-router/entry'
3 changes: 2 additions & 1 deletion apps/easypid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@animo-id/expo-ausweis-sdk": "catalog:",
"@animo-id/expo-mdoc-data-transfer": "catalog:",
"@animo-id/expo-secure-environment": "catalog:",
"@animo-id/mdoc": "catalog:",
"@credo-ts/core": "catalog:",
"@expo-google-fonts/open-sans": "^0.2.3",
"@expo-google-fonts/raleway": "^0.2.3",
Expand All @@ -26,7 +27,6 @@
"@package/secure-store": "workspace:*",
"@package/ui": "workspace:*",
"@package/utils": "workspace:*",
"@animo-id/mdoc": "catalog:",
"@react-native-community/blur": "^4.3.2",
"@react-native-community/netinfo": "11.3.1",
"@react-native-masked-view/masked-view": "0.3.1",
Expand All @@ -51,6 +51,7 @@
"expo-system-ui": "~3.0.6",
"expo-updates": "~0.25.16",
"expo-web-browser": "~13.0.3",
"fast-text-encoding": "^1.0.6",
"react": "catalog:",
"react-native": "catalog:",
"react-native-argon2": "^2.0.1",
Expand Down
2 changes: 2 additions & 0 deletions apps/easypid/src/app/+native-intent.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'fast-text-encoding'

import { parseInvitationUrl } from '@package/agent'
import { deeplinkSchemes } from '@package/app'
import * as Haptics from 'expo-haptics'
Expand Down
2 changes: 2 additions & 0 deletions apps/easypid/src/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'fast-text-encoding'

import { BackgroundLockProvider, NoInternetToastProvider, Provider, useTransparentNavigationBar } from '@package/app'
import { SecureUnlockProvider } from '@package/secure-store/secureUnlock'
import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
Expand Down
6 changes: 6 additions & 0 deletions apps/easypid/src/features/proximity/mdocProximity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const checkMdocPermissions = async () => {

export const getMdocQrCode = async () => {
const mdt = requireMdocDataTransfer().mdocDataTransfer.instance()
mdt.enableNfc()
const qrData = await mdt.startQrEngagement()
return qrData
}
Expand Down Expand Up @@ -118,3 +119,8 @@ export const shareDeviceResponse = async (options: ShareDeviceResponseOptions) =

await mdt.sendDeviceResponse(deviceResponse.encode())
}

export const shutdownDataTransfer = () => {
const mdt = requireMdocDataTransfer().mdocDataTransfer.instance()
mdt.shutdown()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { usePushToWallet } from '@package/app/src/hooks/usePushToWallet'
import { useToastController } from '@package/ui'
import { useEffect, useState } from 'react'
import { type ActivityStatus, addSharedActivityForCredentialsForRequest } from '../activity/activityRecord'
import { shareDeviceResponse } from '../proximity'
import { shareDeviceResponse, shutdownDataTransfer } from '../proximity'
import { FunkeOfflineSharingScreen } from './FunkeOfflineSharingScreen'
import type { PresentationRequestResult } from './components/utils'

Expand Down Expand Up @@ -101,10 +101,16 @@ export function FunkeMdocOfflineSharingScreen({

setIsProcessing(false)

shutdownDataTransfer()
pushToWallet()
toast.show('Proof has been declined.', { customData: { preset: 'danger' } })
}

const onProofComplete = () => {
shutdownDataTransfer()
pushToWallet('replace')
}

const addActivity = async (status: ActivityStatus) => {
if (!submission) return
await addSharedActivityForCredentialsForRequest(
Expand All @@ -129,7 +135,7 @@ export function FunkeMdocOfflineSharingScreen({
submission={submission}
onAccept={onProofAccept}
onDecline={onProofDecline}
onComplete={() => pushToWallet('replace')}
onComplete={onProofComplete}
/>
)
}
1 change: 0 additions & 1 deletion packages/agent/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'react-native-get-random-values'
import 'fast-text-encoding'

import { Buffer } from '@credo-ts/core'
export {
Expand Down
17 changes: 10 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ catalog:
"@animo-id/oauth2": 0.1.4
"@animo-id/oauth2-utils": 0.1.4
"@animo-id/expo-secure-environment": 0.1.0-alpha.11
"@animo-id/expo-mdoc-data-transfer": 0.0.3-alpha.7
"@animo-id/expo-mdoc-data-transfer": 0.0.3-alpha.8
"@animo-id/mdoc": 0.2.39
"@unimodules/react-native-adapter": "./noop"
"@unimodules/core": "./noop"
expo: ~51.0.39
"@sphereon/pex-models": 2.3.2
"@sphereon/pex-models": 2.3.2

0 comments on commit 0d27f52

Please sign in to comment.