From 34782426ebe3d926a85d6443befae7b247353f8a Mon Sep 17 00:00:00 2001 From: Nicholas Gomez Date: Wed, 16 Apr 2025 00:20:03 -0400 Subject: [PATCH] fix: correct ID token lookup logic when reading from cache In the obo client, when fetching the idTokens from cache, the fetched Map value was incorrectly being assessed with Object.entries() instead of Map.entries(). This would cause the function to always return null. --- lib/msal-node/src/client/OnBehalfOfClient.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/msal-node/src/client/OnBehalfOfClient.ts b/lib/msal-node/src/client/OnBehalfOfClient.ts index a590b06f2a..0091a29e59 100644 --- a/lib/msal-node/src/client/OnBehalfOfClient.ts +++ b/lib/msal-node/src/client/OnBehalfOfClient.ts @@ -192,10 +192,11 @@ export class OnBehalfOfClient extends BaseClient { this.cacheManager.getIdTokensByFilter(idTokenFilter); // When acquiring a token on behalf of an application, there might not be an id token in the cache - if (Object.values(idTokenMap).length < 1) { + const idTokensFromCache: IdTokenEntity[] = [...idTokenMap.values()]; + if (idTokensFromCache.length < 1) { return null; } - return Object.values(idTokenMap)[0] as IdTokenEntity; + return idTokensFromCache[0] as IdTokenEntity; } /**