22import { goto } from " $app/navigation" ;
33import { Hero } from " $lib/fragments" ;
44import type { GlobalState } from " $lib/global" ;
5- import { InputPin } from " $lib/ui" ;
5+ import { InputPin , Drawer } from " $lib/ui" ;
66import * as Button from " $lib/ui/Button" ;
77import {
88 type AuthOptions ,
@@ -17,6 +17,7 @@ let clearPin = $state(async () => {});
1717let handlePinInput = $state ((pin : string ) => {});
1818let globalState: GlobalState | undefined = $state (undefined );
1919let hasPendingDeepLink = $state (false );
20+ let isDeletedVaultModalOpen = $state (false );
2021
2122const authOpts: AuthOptions = {
2223 allowDeviceCredential: false ,
@@ -32,6 +33,18 @@ const authOpts: AuthOptions = {
3233 confirmationRequired: true ,
3334};
3435
36+ const getGlobalState = getContext <() => GlobalState >(" globalState" );
37+ const setGlobalState = getContext <(value : GlobalState ) => void >(" setGlobalState" );
38+
39+ async function nukeWallet() {
40+ if (! globalState ) return ;
41+ const newGlobalState = await globalState .reset ();
42+ setGlobalState (newGlobalState );
43+ globalState = newGlobalState ;
44+ isDeletedVaultModalOpen = false ;
45+ await goto (" /onboarding" );
46+ }
47+
3548onMount (async () => {
3649 globalState = getContext <() => GlobalState >(" globalState" )();
3750 if (! globalState ) {
@@ -63,6 +76,27 @@ onMount(async () => {
6376 return ;
6477 }
6578
79+ // Check eVault health after successful login
80+ try {
81+ const vault = await globalState ?.vaultController .vault ;
82+ if (vault ?.ename ) {
83+ const healthCheck = await globalState .vaultController .checkHealth (vault .ename );
84+ if (! healthCheck .healthy ) {
85+ console .warn (" eVault health check failed:" , healthCheck .error );
86+
87+ // If eVault was deleted (404), show modal
88+ if (healthCheck .deleted ) {
89+ isDeletedVaultModalOpen = true ;
90+ return ; // Don't continue to app
91+ }
92+ // For other errors, continue to app - non-blocking
93+ }
94+ }
95+ } catch (error ) {
96+ console .error (" Error during eVault health check:" , error );
97+ // Continue to app even if health check fails - non-blocking
98+ }
99+
66100 // Check if there's a pending deep link to process
67101 const pendingDeepLink = sessionStorage .getItem (" pendingDeepLink" );
68102 if (pendingDeepLink ) {
@@ -108,6 +142,27 @@ onMount(async () => {
108142 authOpts ,
109143 );
110144
145+ // Check eVault health after successful biometric login
146+ try {
147+ const vault = await globalState .vaultController .vault ;
148+ if (vault ?.ename ) {
149+ const healthCheck = await globalState .vaultController .checkHealth (vault .ename );
150+ if (! healthCheck .healthy ) {
151+ console .warn (" eVault health check failed:" , healthCheck .error );
152+
153+ // If eVault was deleted (404), show modal
154+ if (healthCheck .deleted ) {
155+ isDeletedVaultModalOpen = true ;
156+ return ; // Don't continue to app
157+ }
158+ // For other errors, continue to app - non-blocking
159+ }
160+ }
161+ } catch (error ) {
162+ console .error (" Error during eVault health check:" , error );
163+ // Continue to app even if health check fails - non-blocking
164+ }
165+
111166 // Check if there's a pending deep link to process
112167 const pendingDeepLink = sessionStorage .getItem (" pendingDeepLink" );
113168 if (pendingDeepLink ) {
@@ -189,3 +244,35 @@ onMount(async () => {
189244 Clear PIN
190245 </Button .Action >
191246</main >
247+
248+ <!-- Deleted eVault Modal - Non-dismissible -->
249+ <Drawer bind:isPaneOpen ={isDeletedVaultModalOpen } dismissible ={false }>
250+ <div class =" text-center" >
251+ <h4 class =" mt-[2.3svh] mb-[0.5svh] text-red-600" >
252+ 🗑️ eVault Has Been Deleted
253+ </h4 >
254+ <p class =" text-black-700 mb-4" >
255+ Your eVault has been deleted from the registry and is no longer accessible.
256+ </p >
257+ <div class =" bg-red-50 border border-red-200 rounded-md p-4 mb-6" >
258+ <p class =" text-red-800 font-medium" >
259+ To continue using the app, you need to delete your local account data and start fresh.
260+ </p >
261+ </div >
262+ <ul class =" text-left text-black-700 mb-6 space-y-2" >
263+ <li >• All your local data will be deleted</li >
264+ <li >• Your ePassport will be removed</li >
265+ <li >• You will need to onboard again</li >
266+ <li >• This action cannot be undone</li >
267+ </ul >
268+ <p class =" text-black-800 mb-4 font-semibold" >
269+ You must delete your local data to continue.
270+ </p >
271+ <div class =" flex gap-3" >
272+ <Button .Action
273+ class =" flex-1 bg-red-600 hover:bg-red-700"
274+ callback ={nukeWallet }>Delete Local Data</Button .Action
275+ >
276+ </div >
277+ </div >
278+ </Drawer >
0 commit comments