UNPKG

oauth-entra-id

Version:

🛡️ A Secure, Performant, and Feature-Rich OAuth 2.0 Integration for Microsoft Entra ID — Fully Abstracted and Production-Ready.

53 lines (50 loc) 2.01 kB
import { L as LiteConfig, R as Result, J as JwtPayload, M as Metadata, B as B2BResult } from './types-jPLS3OFl.js'; export { C as CallbackFunction, H as HttpErrorCodes, b as MsalResponse, c as OAuthConfig, O as OAuthError, d as OAuthProvider, a as ResultErr, U as UserInfo } from './types-jPLS3OFl.js'; import '@azure/msal-node'; import 'jsonwebtoken'; /** * Lightweight provider for verifying JWTs and obtaining B2B app tokens. * Does not support PKCE, refresh tokens, encrypted state/cookies, or OBO flow. */ declare class LiteProvider { private readonly azure; private readonly jwksClient; /** * @param configuration The OAuth configuration object: * - `azure`: clientId, tenantId, and optional clientSecret with B2B apps. * @throws {OAuthError} if the config fails validation or has duplicate service names */ constructor(configuration: LiteConfig); /** * Verifies a JWT token and extracts its payload and metadata. * @param jwtToken - Microsoft Entra ID Access Token (JWT). * @returns A result containing the JWT payload and metadata. */ $verifyJwt(jwtToken: string | undefined): Promise<Result<{ payload: JwtPayload; meta: Metadata; }>>; /** * Acquire client-credential tokens for one or multiple B2B apps. * Caches tokens for better performance. * * @overload * @param params.appName - The name of the B2B app to get the token for. * @returns A result containing the B2B app token and metadata. * * @overload * @param params.appsNames - An array of B2B app names to get tokens for. * @returns Results containing an array of B2B app tokens and metadata. */ tryGetB2BToken(params: { app: string; }): Promise<Result<{ result: B2BResult; }>>; tryGetB2BToken(params: { apps: string[]; }): Promise<Result<{ results: B2BResult[]; }>>; } export { JwtPayload, LiteConfig, LiteProvider, Metadata, Result };