Skip to content

Commit 7c43700

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/new-oid4vp-dc-api
2 parents c613e1f + c0f3eef commit 7c43700

File tree

3 files changed

+38
-19
lines changed

3 files changed

+38
-19
lines changed

apps/easypid/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "animo-easypid",
3-
"version": "1.7.1",
3+
"version": "1.8.0",
44
"main": "index.ts",
55
"private": true,
66
"scripts": {

apps/easypid/src/features/onboarding/screens/data-protection.tsx

+7-11
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@ export function OnboardingDataProtection({ goToNextStep }: OnboardingDataProtect
2626
const onToggleCloudHsm = () => {
2727
const newShouldUseCloudHsm = !shouldUseCloudHsm
2828

29-
if (newShouldUseCloudHsm === false && !isLocalSecureEnvironmentSupported()) {
30-
toast.show(`You device does not support on-device ${Platform.OS === 'ios' ? 'Secure Enclave' : 'Strongbox'}.`, {
31-
message: 'Only Cloud HSM supported for PID cryptogrpahic keys.',
32-
customData: {
33-
preset: 'danger',
34-
},
35-
})
36-
return
37-
}
38-
3929
toast.show(
4030
newShouldUseCloudHsm
4131
? 'Now using Cloud HSM for PID cryptographic keys.'
@@ -66,7 +56,13 @@ export function OnboardingDataProtection({ goToNextStep }: OnboardingDataProtect
6656
Read the Privacy Policy
6757
</Button.Text>
6858
<XStack gap="$2" width="100%">
69-
<Button.Outline bg="$grey-100" scaleOnPress width="$buttonHeight" onPress={onToggleCloudHsm}>
59+
<Button.Outline
60+
bg="$grey-100"
61+
scaleOnPress
62+
width="$buttonHeight"
63+
onPress={onToggleCloudHsm}
64+
disabled={!isLocalSecureEnvironmentSupported()}
65+
>
7066
{shouldUseCloudHsm ? <HeroIcons.Cloud /> : <HeroIcons.DevicePhoneMobile />}
7167
</Button.Outline>
7268
<Button.Solid scaleOnPress flexGrow={1} disabled={isLoading} onPress={onContinue}>

apps/easypid/src/features/share/FunkeMdocOfflineSharingScreen.tsx

+30-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { useAppAgent } from '@easypid/agent'
22
import { setWalletServiceProviderPin } from '@easypid/crypto/WalletServiceProviderClient'
33
import { InvalidPinError } from '@easypid/crypto/error'
4+
import { useDevelopmentMode } from '@easypid/hooks'
45
import { type FormattedSubmission, getSubmissionForMdocDocumentRequest } from '@package/agent'
56
import { usePushToWallet } from '@package/app/src/hooks/usePushToWallet'
67
import { useToastController } from '@package/ui'
7-
import { useEffect, useState } from 'react'
8+
import { useCallback, useEffect, useState } from 'react'
89
import { type ActivityStatus, addSharedActivityForCredentialsForRequest } from '../activity/activityRecord'
910
import { shareDeviceResponse, shutdownDataTransfer } from '../proximity'
1011
import { FunkeOfflineSharingScreen } from './FunkeOfflineSharingScreen'
@@ -23,6 +24,7 @@ export function FunkeMdocOfflineSharingScreen({
2324
const toast = useToastController()
2425
const pushToWallet = usePushToWallet()
2526
const { agent } = useAppAgent()
27+
const [isDevelopmentModeEnabled] = useDevelopmentMode()
2628

2729
const [submission, setSubmission] = useState<FormattedSubmission>()
2830
const [isProcessing, setIsProcessing] = useState(false)
@@ -32,6 +34,8 @@ export function FunkeMdocOfflineSharingScreen({
3234
.then(setSubmission)
3335
.catch((error) => {
3436
toast.show('Presentation information could not be extracted.', {
37+
message:
38+
error instanceof Error && isDevelopmentModeEnabled ? `Development mode error: ${error.message}` : undefined,
3539
customData: { preset: 'danger' },
3640
})
3741
agent.config.logger.error('Error getting credentials for mdoc device request', {
@@ -40,7 +44,16 @@ export function FunkeMdocOfflineSharingScreen({
4044

4145
pushToWallet()
4246
})
43-
}, [agent, deviceRequest, toast.show, pushToWallet])
47+
}, [agent, deviceRequest, toast.show, pushToWallet, isDevelopmentModeEnabled])
48+
49+
const handleError = useCallback(
50+
({ reason, description, redirect = true }: { reason: string; description?: string; redirect?: boolean }) => {
51+
toast.show(reason, { message: description, customData: { preset: 'danger' } })
52+
if (redirect) pushToWallet()
53+
return
54+
},
55+
[toast, pushToWallet]
56+
)
4457

4558
const onProofAccept = async ({ pin, onPinComplete, onPinError }: onPinSubmitProps) => {
4659
// Already checked for submission in the useEffect
@@ -59,6 +72,13 @@ export function FunkeMdocOfflineSharingScreen({
5972
if (e instanceof InvalidPinError) {
6073
onPinError?.()
6174
}
75+
76+
handleError({
77+
reason: 'Authentication Error',
78+
redirect: true,
79+
description:
80+
e instanceof Error && isDevelopmentModeEnabled ? `Development mode error: ${e.message}` : undefined,
81+
})
6282
}
6383

6484
// Once this returns we just assume it's successful
@@ -69,10 +89,14 @@ export function FunkeMdocOfflineSharingScreen({
6989
sessionTranscript,
7090
submission,
7191
})
72-
} catch (error) {
73-
agent.config.logger.error('Could not share device response', { error })
92+
} catch (e) {
7493
await addActivity('failed')
75-
pushToWallet()
94+
handleError({
95+
reason: 'Could not share device response',
96+
redirect: true,
97+
description:
98+
e instanceof Error && isDevelopmentModeEnabled ? `Development mode error: ${e.message}` : undefined,
99+
})
76100
}
77101

78102
await addActivity('success')
@@ -89,8 +113,7 @@ export function FunkeMdocOfflineSharingScreen({
89113
setIsProcessing(false)
90114

91115
shutdownDataTransfer()
92-
pushToWallet()
93-
toast.show('Proof has been declined.', { customData: { preset: 'danger' } })
116+
handleError({ reason: 'Proof has been declined', redirect: true })
94117
}
95118

96119
const onProofComplete = () => {

0 commit comments

Comments
 (0)