UNPKG

twilio-flex-token-validator

Version:
41 lines (40 loc) 1.38 kB
declare namespace Twilio { class Response { appendHeader(key: string, value: string): void; setStatusCode(code: number): void; setBody(body: string): void; } } export interface Context { ACCOUNT_SID: string; AUTH_TOKEN: string; TWILIO_REGION?: string; API_KEY?: string; API_SECRET?: string; } export interface Event { Token: string; TokenResult?: object; } export interface ApiCredentials { Sid: string; Secret: string; } export declare type Callback = (error: any, response: Twilio.Response) => void; export declare type HandlerFn = (context: Context, event: Event, callback: Callback) => void; /** * Validates that the Token is valid * * @param token the token to validate * @param accountSid the accountSid * @param authToken the authToken * @param apiCredentials optional api credentials to use instead of root account credentials */ export declare const validator: (token: string, accountSid: string, authToken?: string | undefined, realm?: string | undefined, apiCredentials?: ApiCredentials | undefined) => Promise<object>; /** * A validator to be used with Twilio Function. It uses the {@link validator} to validate the token * * @param handlerFn the Twilio Runtime Handler Function */ export declare const functionValidator: (handlerFn: HandlerFn) => HandlerFn; export {};