Skip to content

Commit

Permalink
chore: resolve feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Berend Sliedrecht <berend@animo.id>
  • Loading branch information
berendsliedrecht committed Jan 24, 2025
1 parent b1fcc65 commit 42a0738
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 25 deletions.
6 changes: 2 additions & 4 deletions apps/easypid/src/features/proximity/mdocProximity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,10 @@ export const shareDeviceResponse = async (options: ShareDeviceResponseOptions) =
.authenticateWithSignature(publicDeviceJwk, 'ES256')
.sign(mdocContext)

console.log(Platform.OS, ':', Buffer.from(deviceResponse.encode()).toString('hex'))

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

export const shutdownDataTransfer = () => {
// const mdt = mdocDataTransfer.instance()
// mdt.shutdown()
const mdt = mdocDataTransfer.instance()
mdt.shutdown()
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {
BiometricAuthenticationCancelledError,
type CredentialsForProofRequest,
type FormattedSubmissionEntrySatisfied,
getCredentialsForProofRequest,
getDisclosedAttributeNamesForDisplay,
shareProof,
} from '@package/agent'
import { useToastController } from '@package/ui'
Expand All @@ -10,6 +12,7 @@ import React, { useEffect, useState, useCallback } from 'react'

import { useAppAgent } from '@easypid/agent'
import { InvalidPinError } from '@easypid/crypto/error'
import { useOverAskingAi } from '@easypid/hooks'
import { useDevelopmentMode } from '@easypid/hooks'
import { usePushToWallet } from '@package/app/src/hooks/usePushToWallet'
import { setWalletServiceProviderPin } from '../../crypto/WalletServiceProviderClient'
Expand Down Expand Up @@ -58,6 +61,38 @@ export function FunkeOpenIdPresentationNotificationScreen() {
})
}, [credentialsForRequest, params.data, params.uri, toast.show, agent, pushToWallet, toast, isDevelopmentModeEnabled])

const { checkForOverAsking, isProcessingOverAsking, overAskingResponse, stopOverAsking } = useOverAskingAi()

useEffect(() => {
if (!credentialsForRequest?.formattedSubmission || !credentialsForRequest?.formattedSubmission.areAllSatisfied) {
return
}

if (isProcessingOverAsking || overAskingResponse) {
// Already generating or already has result
return
}

const submission = credentialsForRequest.formattedSubmission
const requestedCards = submission.entries
.filter((entry): entry is FormattedSubmissionEntrySatisfied => entry.isSatisfied)
.flatMap((entry) => entry.credentials)

void checkForOverAsking({
verifier: {
name: credentialsForRequest.verifier.name ?? 'No name provided',
domain: credentialsForRequest.verifier.hostName ?? 'No domain provided',
},
name: submission.name ?? 'No name provided',
purpose: submission.purpose ?? 'No purpose provided',
cards: requestedCards.map((credential) => ({
name: credential.credential.display.name ?? 'Card name',
subtitle: credential.credential.display.description ?? 'Card description',
requestedAttributes: getDisclosedAttributeNamesForDisplay(credential),
})),
})
}, [credentialsForRequest, checkForOverAsking, isProcessingOverAsking, overAskingResponse])

const onProofAccept = useCallback(
async (pin?: string): Promise<PresentationRequestResult> => {
if (!credentialsForRequest)
Expand All @@ -68,6 +103,7 @@ export function FunkeOpenIdPresentationNotificationScreen() {
},
}

stopOverAsking()
setIsSharing(true)

if (shouldUsePin) {
Expand Down Expand Up @@ -152,10 +188,11 @@ export function FunkeOpenIdPresentationNotificationScreen() {
}
}
},
[credentialsForRequest, agent, shouldUsePin, isDevelopmentModeEnabled]
[credentialsForRequest, agent, shouldUsePin, stopOverAsking, isDevelopmentModeEnabled]
)

const onProofDecline = async () => {
stopOverAsking()
if (credentialsForRequest) {
await addSharedActivityForCredentialsForRequest(
agent,
Expand All @@ -181,6 +218,7 @@ export function FunkeOpenIdPresentationNotificationScreen() {
trustedEntities={credentialsForRequest?.verifier.trustedEntities}
lastInteractionDate={lastInteractionDate}
onComplete={() => pushToWallet('replace')}
overAskingResponse={overAskingResponse}
/>
)
}
7 changes: 0 additions & 7 deletions apps/easypid/src/features/wallet/FunkeOfflineQrScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@ export function FunkeOfflineQrScreen() {
})
)

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

const onCancel = () => {
back()
shutdownDataTransfer()
Expand Down
1 change: 1 addition & 0 deletions apps/easypid/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './usePidCredential'
export * from './useWalletReset'
export * from './useOverAskingAi'
export * from './useDevelopmentMode'
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "wallets",
"private": true,
"scripts": {
"postinstall": "pnpm deps:check",
"build": "pnpm -r build",
"upgrade:tamagui": "pnpm up '*tamagui*'@latest '@tamagui/*'@latest",
"upgrade:tamagui:canary": "pnpm up '*tamagui*'@canary '@tamagui/*'@canary",
Expand Down
1 change: 0 additions & 1 deletion packages/agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { anoncreds } from '@hyperledger/anoncreds-react-native'
import { ariesAskar } from '@hyperledger/aries-askar-react-native'

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

const askarModule = new AskarModule({
Expand Down
11 changes: 0 additions & 11 deletions packages/agent/src/indyNetworks.ts

This file was deleted.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ packages:
- 'apps/*'

catalog:
expo: ~51.0.39
react-native: ~0.75.0
react: 18.3.1
"@types/react": ~18.2.79
Expand Down Expand Up @@ -33,5 +34,4 @@ catalog:
"@animo-id/mdoc": 0.2.39
"@unimodules/react-native-adapter": "./noop"
"@unimodules/core": "./noop"
expo: ~51.0.39
"@sphereon/pex-models": 2.3.2

0 comments on commit 42a0738

Please sign in to comment.