UNPKG

@intuitionrobotics/user-account

Version:
39 lines (38 loc) 1.41 kB
import { Module, ObjectTS } from "@intuitionrobotics/ts-common"; import { ApiException, ExpressRequest } from "@intuitionrobotics/thunderstorm/backend"; import * as jws from "jws"; import { Algorithm, Signature } from "jws"; export declare class TokenExpiredException extends ApiException { constructor(message: string, cause?: Error); } type Config = { secrets?: { [k: string]: any; }; validateKeyId: string; issuer?: string; }; type Secret = { kid: string; value: string; }; export declare class SecretsModule_Class extends Module<Config> { private DEFAULT_ISS; AUTHENTICATION_PREFIX: string; AUTHENTICATION_KEY: string; constructor(); getSecret(k: string): Secret; getAuthSecret: (kid: string) => Secret; private getConfig; validateRequestAndCheckExpiration(request: ExpressRequest, scopes: string[]): any; validateRequest(request: ExpressRequest, scopes: string[]): jws.Signature; validateScopes(_scopesToValidate: string, scopes: string[]): void; extractAuthToken(request: ExpressRequest): string; isExpired: (token: Signature) => boolean; getExpiration(token: Signature): any; generateJwt: (payload: ObjectTS, kid: string, algorithm?: Algorithm) => string; getIss: () => string; decodeJwt: (jwt: string) => jws.Signature | null; } export declare const SecretsModule: SecretsModule_Class; export {};