MCPcopy
hub / github.com/redis/node-redis / MSALIdentityProvider

Class MSALIdentityProvider

packages/entraid/lib/msal-identity-provider.ts:6–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import { IdentityProvider, TokenResponse } from '@redis/client/dist/lib/authx';
5
6export class MSALIdentityProvider implements IdentityProvider<AuthenticationResult> {
7 private readonly getToken: () => Promise<AuthenticationResult>;
8
9 constructor(getToken: () => Promise<AuthenticationResult>) {
10 this.getToken = getToken;
11 }
12
13 async requestToken(): Promise<TokenResponse<AuthenticationResult>> {
14 const result = await this.getToken();
15
16 if (!result?.accessToken || !result?.expiresOn) {
17 throw new Error('Invalid token response');
18 }
19 return {
20 token: result,
21 ttlMs: result.expiresOn.getTime() - Date.now()
22 };
23 }
24
25}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected