@@ -10,6 +10,7 @@ import {
1010import { SRPSession } from "./srp.ts" ;
1111import { readBigInt , readConfig , toBase64 , toBuffer } from "./utils.ts" ;
1212import { type Message , type SMSG } from "./types.ts" ;
13+ import { writeConfig } from "./utils.ts" ;
1314
1415const BROWSER_NAME = "Arc" ;
1516const VERSION = "1.0" ;
@@ -179,6 +180,7 @@ export class ApplePasswordManager {
179180
180181 constructor ( ) {
181182 this . session = SRPSession . new ( true ) ;
183+ writeConfig ( { } ) ;
182184 const { username, sharedKey, port } = readConfig ( ) ;
183185 this . remotePort = port ;
184186 if ( typeof sharedKey !== "bigint" ) return ;
@@ -276,7 +278,7 @@ export class ApplePasswordManager {
276278 }
277279
278280 async verifyChallenge ( password : string ) {
279- await this . session . setSharedKey ( password ) ;
281+ const newKey = await this . session . setSharedKey ( password ) ;
280282
281283 const m = await this . session . computeM ( ) ;
282284 const msg = await APWMessages . verifyChallenge ( this . session , m ) ;
@@ -327,6 +329,11 @@ export class ApplePasswordManager {
327329 "Invalid server verification: HAMK mismatch" ,
328330 ) ;
329331 }
332+ console . log ( "Challenge verified, updating config" ) ;
333+ await writeConfig ( {
334+ username : this . session . username . toString ( ) ,
335+ sharedKey : newKey ,
336+ } ) ;
330337 }
331338
332339 async getLoginNamesForURL ( url : string ) {
0 commit comments