@@ -69,13 +69,52 @@ export class MigrationService extends EventEmitter {
6969 message : "Provisioning new evault..." ,
7070 } ) ;
7171
72+ // Get public key from old evault
73+ console . log (
74+ `[MIGRATION] Retrieving public key from old evault for ${ eName } ` ,
75+ ) ;
76+ let publicKey = "0x0000000000000000000000000000000000000000" ; // Default fallback
77+
78+ try {
79+ const whoisResponse = await axios . get (
80+ new URL ( "/whois" , migration . oldEvaultUri || "" ) . toString ( ) ,
81+ {
82+ headers : {
83+ "X-ENAME" : eName ,
84+ } ,
85+ } ,
86+ ) ;
87+ if ( whoisResponse . data . publicKey ) {
88+ publicKey = whoisResponse . data . publicKey ;
89+ console . log (
90+ `[MIGRATION] Retrieved public key from old evault: ${ publicKey . substring ( 0 , 20 ) } ...` ,
91+ ) ;
92+ migration . logs += `[MIGRATION] Retrieved public key from old evault\n` ;
93+ } else {
94+ console . warn (
95+ `[MIGRATION] No public key found in old evault, using default` ,
96+ ) ;
97+ migration . logs += `[MIGRATION] Warning: No public key found in old evault, using default\n` ;
98+ }
99+ } catch ( error ) {
100+ console . error (
101+ `[MIGRATION ERROR] Failed to retrieve public key from old evault:` ,
102+ error ,
103+ ) ;
104+ migration . logs += `[MIGRATION ERROR] Failed to retrieve public key, using default\n` ;
105+ // Continue with default public key - don't fail the migration
106+ }
107+
72108 // Get entropy from registry
73109 const entropyResponse = await axios . get (
74110 new URL ( "/entropy" , this . registryUrl ) . toString ( ) ,
75111 ) ;
76112 const registryEntropy = entropyResponse . data . token ;
77113
78- // Provision new evault
114+ // Provision new evault with preserved public key
115+ console . log (
116+ `[MIGRATION] Provisioning new evault with public key: ${ publicKey . substring ( 0 , 20 ) } ...` ,
117+ ) ;
79118 const provisionResponse = await axios . post (
80119 new URL ( "/provision" , provisionerUrl ) . toString ( ) ,
81120 {
@@ -84,7 +123,7 @@ export class MigrationService extends EventEmitter {
84123 verificationId :
85124 process . env . DEMO_VERIFICATION_CODE ||
86125 "d66b7138-538a-465f-a6ce-f6985854c3f4" ,
87- publicKey : "0x0000000000000000000000000000000000000000" ,
126+ publicKey : publicKey ,
88127 } ,
89128 ) ;
90129
@@ -103,8 +142,12 @@ export class MigrationService extends EventEmitter {
103142 migration . newEvaultId = evaultId ;
104143 migration . newEvaultUri = uri ;
105144 migration . logs += `[MIGRATION] New evault provisioned: ${ evaultId } , URI: ${ uri } \n` ;
145+ migration . logs += `[MIGRATION] Public key preserved: ${ publicKey . substring ( 0 , 20 ) } ...\n` ;
106146 await this . migrationRepository . save ( migration ) ;
107147
148+ // Note: Public key will be copied automatically when copying metaEnvelopes
149+ // (User node is copied as part of the copyMetaEnvelopes operation)
150+
108151 console . log (
109152 `[MIGRATION] New evault provisioned: ${ evaultId } for ${ eName } ` ,
110153 ) ;
0 commit comments