@microsoft/teams.apps
Version:
<p> <a href="https://www.npmjs.com/package/@microsoft/teams.apps" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.apps/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.apps?activeTab=code
61 lines (60 loc) • 2.13 kB
TypeScript
import { type JwtPayload } from 'jsonwebtoken';
import { ILogger } from '@microsoft/teams.common';
export interface IJwtValidationOptions {
/** Required: Application/Client ID for audience validation */
clientId: string;
/**
* This may be 'common', 'organizations', 'consumers' for multi-tenant apps,
* or a specific tenant ID for single-tenant apps.
*/
tenantId?: string;
/**
* JWKS URI options for fetching public keys
*/
jwksUriOptions: {
type: 'tenantId';
} | {
type: 'uri';
uri: string;
};
/** Optional: Validate required scope in token */
validateScope?: {
requiredScope: string;
};
/** Optional: Validate service URL (Bot Framework specific) */
validateServiceUrl?: {
expectedServiceUrl: string;
};
/** Optional: Custom issuer validation */
validateIssuer?: {
/** Allowed */
allowedIssuer: string;
} | {
/** For multi-tenant apps, restrict to specific tenant IDs */
allowedTenantIds?: string[];
};
/** Optional: Clock tolerance in seconds (default: 300) */
clockTolerance?: number;
}
export declare class JwtValidator {
readonly options: IJwtValidationOptions;
private readonly logger?;
private readonly jwksCache;
constructor(options: IJwtValidationOptions, logger?: ILogger);
/**
* Validates a JWT token using the configured options
*/
validateAccessToken(rawToken: string, overrideOptions?: Pick<IJwtValidationOptions, 'validateServiceUrl' | 'validateScope'>): Promise<JwtPayload | null>;
private getJwksClient;
private getSigningKey;
private validateIssuer;
private validateScope;
private validateServiceUrl;
private performCustomValidations;
}
export declare const createEntraTokenValidator: (tenantId: string, clientId: string, options?: {
allowedTenantIds?: string[];
requiredScope?: string;
logger?: ILogger;
}) => JwtValidator;
export declare const createServiceTokenValidator: (appId: string, tenantId?: string, serviceUrl?: string, logger?: ILogger) => JwtValidator;