From 9227acd0570466417ff4ab2edf98b977b0cc4c27 Mon Sep 17 00:00:00 2001 From: Trezy Date: Fri, 8 May 2026 13:28:12 -0500 Subject: [PATCH] fix: cleanup derelict items after successful auth Signed-off-by: Trezy --- packages/oauth-client-node/src/node-client.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/oauth-client-node/src/node-client.ts b/packages/oauth-client-node/src/node-client.ts index 2ca23f9..f14bbc1 100644 --- a/packages/oauth-client-node/src/node-client.ts +++ b/packages/oauth-client-node/src/node-client.ts @@ -57,6 +57,7 @@ interface PendingAuthState { tokenEndpoint: string; state: string; issuer: string; + authUrl?: string; } interface AuthServerMetadata { @@ -187,6 +188,8 @@ export class HappyViewNodeClient extends HappyViewOAuthClient { 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 @@ export class HappyViewNodeClient extends HappyViewOAuthClient { 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 @@ export class HappyViewNodeClient extends HappyViewOAuthClient { }); await this.storage.delete(`pending-auth:${state}`); + if (pending.authUrl) { + await this.storage.delete(`pending-auth-url:${pending.authUrl}`); + } return { session, state }; } catch (err) { -- 2.51.2