@@ -8,7 +8,7 @@ import axios from "axios";
88import { getContext , onMount } from " svelte" ;
99import { Shadow } from " svelte-loading-spinners" ;
1010import { writable } from " svelte/store" ;
11- import { Selfie , permissionGranted , verifStep , verificaitonId , status , reason } from " ../store" ;
11+ import { Selfie , permissionGranted , verifStep , verificaitonId , status , reason , verificationPerson , verificationDocument , verificationWebsocketData } from " ../store" ;
1212import type { GlobalState } from " $lib/global" ;
1313import { capitalize } from " $lib/utils" ;
1414import { v4 as uuidv4 } from " uuid" ;
@@ -23,11 +23,6 @@ let showResults = $state(false);
2323let loading = $state (false );
2424let globalState: GlobalState | undefined = $state (undefined );
2525
26- // Store websocket data
27- let person: any = $state (null );
28- let document: any = $state (null );
29- let websocketData: { w3id? : string } | null = $state (null );
30-
3126async function requestCameraPermission() {
3227 try {
3328 stream = await navigator .mediaDevices .getUserMedia ({
@@ -54,13 +49,6 @@ function stopCamera() {
5449$effect (() => {
5550 if ($status && $verifStep === 3 ) {
5651 showResults = true ;
57- // Get person/document data from context if needed
58- const verifyContext = getContext <any >(" verifyData" );
59- if (verifyContext ) {
60- person = verifyContext .person ;
61- document = verifyContext .document ;
62- websocketData = verifyContext .websocketData ;
63- }
6452 }
6553});
6654
@@ -120,33 +108,37 @@ async function handleContinue() {
120108 return verifStep .set (0 );
121109 }
122110 if (! globalState ) throw new Error (" Global state is not defined" );
111+ if (! $verificationPerson || ! $verificationDocument ) {
112+ console .error (" Missing verification data" );
113+ return ;
114+ }
123115
124116 loading = true ;
125117
126118 try {
127119 globalState .userController .user = {
128120 name: capitalize (
129- ` ${person .firstName .value } ${person .lastName .value ?? " " } ` ,
121+ ` ${$verificationPerson .firstName .value } ${$verificationPerson .lastName .value ?? " " } ` ,
130122 ),
131- " Date of Birth" : new Date (person .dateOfBirth .value ).toDateString (),
123+ " Date of Birth" : new Date ($verificationPerson .dateOfBirth .value ).toDateString (),
132124 " ID submitted" :
133- document .type .value === " passport"
134- ? ` Passport - ${document .country .value } `
135- : document .type .value === " drivers_license"
136- ? ` Driving License - ${document .country .value } `
137- : ` ID Card - ${document .country .value } ` ,
138- " Document Number" : document .number .value ,
125+ $verificationDocument .type .value === " passport"
126+ ? ` Passport - ${$verificationDocument .country .value } `
127+ : $verificationDocument .type .value === " drivers_license"
128+ ? ` Driving License - ${$verificationDocument .country .value } `
129+ : ` ID Card - ${$verificationDocument .country .value } ` ,
130+ " Document Number" : $verificationDocument .number .value ,
139131 };
140132 globalState .userController .document = {
141- " Valid From" : new Date (document .validFrom .value ).toDateString (),
142- " Valid Until" : new Date (document .validUntil .value ).toDateString (),
133+ " Valid From" : new Date ($verificationDocument .validFrom .value ).toDateString (),
134+ " Valid Until" : new Date ($verificationDocument .validUntil .value ).toDateString (),
143135 " Verified On" : new Date ().toDateString (),
144136 };
145137 globalState .userController .isFake = false ;
146138
147139 if ($status === " duplicate" ) {
148140 // For duplicate case, skip provision and resolve the existing eVault URI
149- const existingW3id = websocketData ?.w3id ;
141+ const existingW3id = $verificationWebsocketData ?.w3id ;
150142 if (! existingW3id ) {
151143 throw new Error (" No w3id provided for duplicate eVault" );
152144 }
0 commit comments