Skip to content

Commit 7ddd6ce

Browse files
committed
chore: put query id in its own map
1 parent d1eae2d commit 7ddd6ce

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/siop-oid4vp/lib/rp/InMemoryRPSessionManager.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class InMemoryRPSessionManager implements IRPSessionManager {
2929
// stored by hashcode
3030
private readonly stateMapping: Record<number, string> = {}
3131
private readonly callbackMapping: Record<string, CallbackOpts> = {}
32+
private readonly queryIdMapping: Record<string, string> = {}
3233
private readonly maxAgeInSeconds: number
3334

3435
private static getKeysForCorrelationId(mapping: Record<number, string>, correlationId: string): number[] {
@@ -195,7 +196,7 @@ export class InMemoryRPSessionManager implements IRPSessionManager {
195196
try {
196197
const eventState = {
197198
correlationId: event.correlationId,
198-
queryId: event.queryId ?? this.authorizationRequests[event.correlationId].queryId,
199+
queryId: event.queryId ?? this.queryIdMapping[event.correlationId],
199200
...(type === 'request' && { request: event.subject }),
200201
...(type === 'response' && { response: event.subject }),
201202
...(event.error && { error: event.error }),
@@ -209,6 +210,9 @@ export class InMemoryRPSessionManager implements IRPSessionManager {
209210
this.authorizationRequests[event.correlationId] = state
210211
this.updateMapping(this.nonceMapping, event, 'nonce', event.correlationId, true)
211212
this.updateMapping(this.stateMapping, event, 'state', event.correlationId, true)
213+
if (event.queryId) {
214+
this.queryIdMapping[event.correlationId] = event.queryId
215+
}
212216
if (event.callback) {
213217
this.callbackMapping[event.correlationId] = event.callback
214218
}

0 commit comments

Comments
 (0)