1- import { PUBLIC_REGISTRY_URL , PUBLIC_PROVISIONER_URL , PUBLIC_EID_WALLET_TOKEN } from "$env/static/public" ;
1+ import {
2+ PUBLIC_REGISTRY_URL ,
3+ PUBLIC_PROVISIONER_URL ,
4+ PUBLIC_EID_WALLET_TOKEN ,
5+ } from "$env/static/public" ;
26import type { Store } from "@tauri-apps/plugin-store" ;
37import axios from "axios" ;
48import { GraphQLClient } from "graphql-request" ;
@@ -52,7 +56,11 @@ export class VaultController {
5256 #profileCreationStatus: "idle" | "loading" | "success" | "failed" = "idle" ;
5357 #notificationService: NotificationService ;
5458
55- constructor ( store : Store , userController : UserController , keyService ?: KeyService ) {
59+ constructor (
60+ store : Store ,
61+ userController : UserController ,
62+ keyService ?: KeyService ,
63+ ) {
5664 this . #store = store ;
5765 this . #userController = userController ;
5866 this . #keyService = keyService || null ;
@@ -86,12 +94,16 @@ export class VaultController {
8694 // Check if we've already saved the public key
8795 const savedKey = localStorage . getItem ( `publicKeySaved_${ eName } ` ) ;
8896 if ( savedKey === "true" ) {
89- console . log ( `Public key already saved for ${ eName } , skipping sync` ) ;
97+ console . log (
98+ `Public key already saved for ${ eName } , skipping sync` ,
99+ ) ;
90100 return ;
91101 }
92102
93103 if ( ! this . #keyService) {
94- console . warn ( "KeyService not available, cannot sync public key" ) ;
104+ console . warn (
105+ "KeyService not available, cannot sync public key" ,
106+ ) ;
95107 return ;
96108 }
97109
@@ -121,29 +133,39 @@ export class VaultController {
121133 // Get public key using the exact same logic as onboarding/verification flow
122134 // KEY_ID is always "default", context depends on whether user is pre-verification
123135 const KEY_ID = "default" ;
124-
136+
125137 // Determine context: check if user is pre-verification (fake/demo user)
126138 const isFake = await this . #userController. isFake ;
127139 const context = isFake ? "pre-verification" : "onboarding" ;
128140
129141 // Get public key using the same method as getApplicationPublicKey() in onboarding/verify
130142 let publicKey : string | undefined ;
131143 try {
132- publicKey = await this . #keyService. getPublicKey ( KEY_ID , context ) ;
144+ publicKey = await this . #keyService. getPublicKey (
145+ KEY_ID ,
146+ context ,
147+ ) ;
133148 } catch ( error ) {
134- console . error ( `Failed to get public key for ${ KEY_ID } with context ${ context } :` , error ) ;
149+ console . error (
150+ `Failed to get public key for ${ KEY_ID } with context ${ context } :` ,
151+ error ,
152+ ) ;
135153 return ;
136154 }
137155
138156 if ( ! publicKey ) {
139- console . warn ( `No public key found for ${ KEY_ID } with context ${ context } , cannot sync` ) ;
157+ console . warn (
158+ `No public key found for ${ KEY_ID } with context ${ context } , cannot sync` ,
159+ ) ;
140160 return ;
141161 }
142162
143163 // Get authentication token from environment variable
144164 const authToken = PUBLIC_EID_WALLET_TOKEN || null ;
145165 if ( ! authToken ) {
146- console . warn ( "PUBLIC_EID_WALLET_TOKEN not set, request may fail authentication" ) ;
166+ console . warn (
167+ "PUBLIC_EID_WALLET_TOKEN not set, request may fail authentication" ,
168+ ) ;
147169 }
148170
149171 // Call PATCH /public-key to save the public key
@@ -157,11 +179,7 @@ export class VaultController {
157179 headers [ "Authorization" ] = `Bearer ${ authToken } ` ;
158180 }
159181
160- await axios . patch (
161- patchUrl ,
162- { publicKey } ,
163- { headers }
164- ) ;
182+ await axios . patch ( patchUrl , { publicKey } , { headers } ) ;
165183
166184 // Mark as saved
167185 localStorage . setItem ( `publicKeySaved_${ eName } ` , "true" ) ;
0 commit comments