123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- import * as jwt from 'jsonwebtoken';
- import { Agent } from 'http';
- export declare const ALGORITHM_RS256: jwt.Algorithm;
- export type Dictionary = {
- [key: string]: any;
- };
- export type DecodedToken = {
- header: Dictionary;
- payload: Dictionary;
- };
- export interface SignatureVerifier {
- verify(token: string): Promise<void>;
- }
- interface KeyFetcher {
- fetchPublicKeys(): Promise<{
- [key: string]: string;
- }>;
- }
- export declare class JwksFetcher implements KeyFetcher {
- private publicKeys;
- private publicKeysExpireAt;
- private client;
- constructor(jwksUrl: string);
- fetchPublicKeys(): Promise<{
- [key: string]: string;
- }>;
- private shouldRefresh;
- private refresh;
- }
- export declare class UrlKeyFetcher implements KeyFetcher {
- private clientCertUrl;
- private readonly httpAgent?;
- private publicKeys;
- private publicKeysExpireAt;
- constructor(clientCertUrl: string, httpAgent?: Agent | undefined);
-
- fetchPublicKeys(): Promise<{
- [key: string]: string;
- }>;
-
- private shouldRefresh;
- private refresh;
- }
- export declare class PublicKeySignatureVerifier implements SignatureVerifier {
- private keyFetcher;
- constructor(keyFetcher: KeyFetcher);
- static withCertificateUrl(clientCertUrl: string, httpAgent?: Agent): PublicKeySignatureVerifier;
- static withJwksUrl(jwksUrl: string): PublicKeySignatureVerifier;
- verify(token: string): Promise<void>;
- private verifyWithoutKid;
- private verifyWithAllKeys;
- }
- export declare class EmulatorSignatureVerifier implements SignatureVerifier {
- verify(token: string): Promise<void>;
- }
- export declare function verifyJwtSignature(token: string, secretOrPublicKey: jwt.Secret | jwt.GetPublicKeyOrSecret, options?: jwt.VerifyOptions): Promise<void>;
- export declare function decodeJwt(jwtToken: string): Promise<DecodedToken>;
- export declare class JwtError extends Error {
- readonly code: JwtErrorCode;
- readonly message: string;
- constructor(code: JwtErrorCode, message: string);
- }
- export declare enum JwtErrorCode {
- INVALID_ARGUMENT = "invalid-argument",
- INVALID_CREDENTIAL = "invalid-credential",
- TOKEN_EXPIRED = "token-expired",
- INVALID_SIGNATURE = "invalid-token",
- NO_MATCHING_KID = "no-matching-kid-error",
- NO_KID_IN_HEADER = "no-kid-error",
- KEY_FETCH_ERROR = "key-fetch-error"
- }
- export {};
|