Skip to content

Commit 764edfb

Browse files
committed
Logging to debug prod
1 parent 37ada3e commit 764edfb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

hono/auth/MsApiClient.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { buildUrl } from 'build-url-ts';
2+
import { apiLogger } from '../logger';
23

34
type Secrets = {
45
tenantId: string;
@@ -37,6 +38,8 @@ export class MsAuthClient {
3738
this.statesTail = (this.statesTail + 1) % this.maxStates;
3839
this.states[this.statesTail] = _state;
3940

41+
console.log(`New state added: ${_state}\nCurrent tail: ${this.statesTail}\nStates: ${this.states}`);
42+
4043
const url = buildUrl(this.msAuthEndpoint, {
4144
path: '/authorize',
4245
queryParams: {
@@ -55,10 +58,12 @@ export class MsAuthClient {
5558

5659
public async verifyAndConsumeCode(code: string, state: string) {
5760
const index = this.states.indexOf(state);
61+
console.log(`State ${state} at index ${index}\nState array: ${this.states}\nstates[index] = ${this.states[index]}`)
5862
if (index == -1) {
5963
throw new Error(`Failed to verify code: Mismatched state.`);
6064
}
6165
this.states[index] = undefined;
66+
console.log(`Removed state ${state} at index ${index}\nState array: ${this.states}\nstates[index] = ${this.states[index]}`)
6267

6368
const req = await fetch(`${this.msAuthEndpoint}/token`, {
6469
method: 'POST',

0 commit comments

Comments
 (0)