From 764edfbb3d86a86a7c7ea8ebd2184c32114f9cc3 Mon Sep 17 00:00:00 2001 From: Dropheart Date: Sun, 22 Sep 2024 02:47:01 +0300 Subject: [PATCH] Logging to debug prod --- hono/auth/MsApiClient.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hono/auth/MsApiClient.ts b/hono/auth/MsApiClient.ts index 48322df..19cf5b2 100644 --- a/hono/auth/MsApiClient.ts +++ b/hono/auth/MsApiClient.ts @@ -1,4 +1,5 @@ import { buildUrl } from 'build-url-ts'; +import { apiLogger } from '../logger'; type Secrets = { tenantId: string; @@ -37,6 +38,8 @@ export class MsAuthClient { this.statesTail = (this.statesTail + 1) % this.maxStates; this.states[this.statesTail] = _state; + console.log(`New state added: ${_state}\nCurrent tail: ${this.statesTail}\nStates: ${this.states}`); + const url = buildUrl(this.msAuthEndpoint, { path: '/authorize', queryParams: { @@ -55,10 +58,12 @@ export class MsAuthClient { public async verifyAndConsumeCode(code: string, state: string) { const index = this.states.indexOf(state); + console.log(`State ${state} at index ${index}\nState array: ${this.states}\nstates[index] = ${this.states[index]}`) if (index == -1) { throw new Error(`Failed to verify code: Mismatched state.`); } this.states[index] = undefined; + console.log(`Removed state ${state} at index ${index}\nState array: ${this.states}\nstates[index] = ${this.states[index]}`) const req = await fetch(`${this.msAuthEndpoint}/token`, { method: 'POST',