From 6c760888cd7aa3df88cc65f14d9e6043b3dc7ecc Mon Sep 17 00:00:00 2001 From: Trezy Date: Fri, 08 May 2026 18:28:12 +0000 Subject: [PATCH] fix: cleanup derelict items after successful auth Signed-off-by: Trezy Signed-off-by: Trezy --- packages/oauth-client-node/src/node-client.ts | 8 ++++++++ 1 file(s) changed, 8 insertion(s)(+), 0 deletion(s)(-) diff --git a/packages/oauth-client-node/src/node-client.ts b/packages/oauth-client-node/src/node-client.ts --- a/packages/oauth-client-node/src/node-client.ts +++ b/packages/oauth-client-node/src/node-client.ts @@ -57,6 +57,7 @@ pdsUrl: string; tokenEndpoint: string; state: string; issuer: string; + authUrl?: string; } interface AuthServerMetadata { @@ -187,6 +188,8 @@ client_id: this.clientId, request_uri: parData.request_uri, }), ); + pendingState.authUrl = url.href; + await this.storage.set(`pending-auth:${state}`, JSON.stringify(pendingState)); await this.storage.set(`pending-auth-url:${url.href}`, state); return url; } @@ -194,6 +197,8 @@ const url = new URL( `${authMeta.authorization_endpoint}?${authParams}`, ); + pendingState.authUrl = url.href; + await this.storage.set(`pending-auth:${state}`, JSON.stringify(pendingState)); await this.storage.set(`pending-auth-url:${url.href}`, state); return url; } @@ -320,6 +325,9 @@ dpopKey: pending.rawJwk, }); await this.storage.delete(`pending-auth:${state}`); + if (pending.authUrl) { + await this.storage.delete(`pending-auth-url:${pending.authUrl}`); + } return { session, state }; } catch (err) { -- tangled.sh