@@ -174,13 +174,15 @@ export abstract class BasePrivateStore implements PrivateStore {
174174 const profilesSnapshot = new Map ( this . profiles ) ;
175175 const legacySnapshot = new Map ( this . legacyPasswords ) ;
176176 const claimRequestsSnapshot = new Map ( this . claimRequests ) ;
177+ const passwordTokensSnapshot = new Map ( this . passwordTokens ) ;
177178
178179 // Staged mutations applied only in-memory during the handler
179180 const stagedProfilePuts : Map < string , PrivateProfile > = new Map ( ) ;
180181 const stagedProfileDeletes : Set < string > = new Set ( ) ;
181182 const stagedLegacyPuts : Map < string , LegacyPasswordCredential > = new Map ( ) ;
182183 const stagedLegacyDeletes : Set < string > = new Set ( ) ;
183184 const stagedClaimRequestPuts : Map < string , AccountClaimRequest > = new Map ( ) ;
185+ const stagedPersonPurges : Set < string > = new Set ( ) ;
184186
185187 const tx : PrivateStoreTx = {
186188 putProfile : ( profile ) => {
@@ -205,6 +207,11 @@ export abstract class BasePrivateStore implements PrivateStore {
205207 const parsed = AccountClaimRequestSchema . parse ( req ) ;
206208 stagedClaimRequestPuts . set ( parsed . id , parsed ) ;
207209 } ,
210+ deletePersonData : ( personId ) => {
211+ stagedPersonPurges . add ( personId ) ;
212+ stagedProfilePuts . delete ( personId ) ;
213+ stagedLegacyPuts . delete ( personId ) ;
214+ } ,
208215 } ;
209216
210217 let result : T ;
@@ -215,6 +222,7 @@ export abstract class BasePrivateStore implements PrivateStore {
215222 this . profiles = profilesSnapshot ;
216223 this . legacyPasswords = legacySnapshot ;
217224 this . claimRequests = claimRequestsSnapshot ;
225+ this . passwordTokens = passwordTokensSnapshot ;
218226 this . rebuildIndices ( ) ;
219227 throw err ;
220228 }
@@ -235,19 +243,33 @@ export abstract class BasePrivateStore implements PrivateStore {
235243 for ( const [ id , req ] of stagedClaimRequestPuts ) {
236244 this . claimRequests . set ( id , req ) ;
237245 }
246+ for ( const personId of stagedPersonPurges ) {
247+ this . profiles . delete ( personId ) ;
248+ this . legacyPasswords . delete ( personId ) ;
249+ for ( const [ id , req ] of this . claimRequests ) {
250+ if ( req . claimedPersonId === personId || req . requesterPersonId === personId ) this . claimRequests . delete ( id ) ;
251+ }
252+ for ( const [ hash , token ] of this . passwordTokens ) {
253+ if ( token . personId === personId ) this . passwordTokens . delete ( hash ) ;
254+ }
255+ }
238256 this . rebuildIndices ( ) ;
239257
240258 // Flush to backend
241259 const flushOps : Promise < void > [ ] = [ ] ;
242- if ( stagedProfilePuts . size > 0 || stagedProfileDeletes . size > 0 ) {
260+ const purging = stagedPersonPurges . size > 0 ;
261+ if ( purging || stagedProfilePuts . size > 0 || stagedProfileDeletes . size > 0 ) {
243262 flushOps . push ( this . flushProfiles ( ) ) ;
244263 }
245- if ( stagedLegacyPuts . size > 0 || stagedLegacyDeletes . size > 0 ) {
264+ if ( purging || stagedLegacyPuts . size > 0 || stagedLegacyDeletes . size > 0 ) {
246265 flushOps . push ( this . flushLegacyPasswords ( ) ) ;
247266 }
248- if ( stagedClaimRequestPuts . size > 0 ) {
267+ if ( purging || stagedClaimRequestPuts . size > 0 ) {
249268 flushOps . push ( this . flushClaimRequests ( ) ) ;
250269 }
270+ if ( purging ) {
271+ flushOps . push ( this . flushPasswordTokens ( ) ) ;
272+ }
251273
252274 try {
253275 await Promise . all ( flushOps ) ;
@@ -257,6 +279,7 @@ export abstract class BasePrivateStore implements PrivateStore {
257279 this . profiles = profilesSnapshot ;
258280 this . legacyPasswords = legacySnapshot ;
259281 this . claimRequests = claimRequestsSnapshot ;
282+ this . passwordTokens = passwordTokensSnapshot ;
260283 this . rebuildIndices ( ) ;
261284 throw new PrivateStoreError (
262285 'private_store_unavailable' ,
0 commit comments