auth0-lambda-authorizer
Version:
An Auth0 Authorizer for AWS Lambda
31 lines (30 loc) • 1.1 kB
TypeScript
import { Either } from "fp-ts/lib/Either";
import * as jwksClient from "jwks-rsa";
export interface TokenConfig {
client: jwksClient.JwksClient;
algorithm: string;
auth0Audience: string;
}
export interface AuthResponse {
policyDocument: PolicyDocument;
principalId: string;
context: any;
}
export interface ResponseWithPayload {
authResponse: AuthResponse;
payload: any;
}
export declare type AuthorizerCallback = (error?: any, authResponse?: AuthResponse) => void;
export interface Statement {
Action: string;
Effect: string;
Resource: string;
}
export interface PolicyDocument {
Version: string;
Statement: Statement[];
}
export declare const getPolicyDocument: (effect: string, resource: string) => PolicyDocument;
export declare const getKeys: (token: any, client: jwksClient.JwksClient) => Promise<any[]>;
export declare const getSigningKey: (client: jwksClient.JwksClient, kid: string) => Promise<string>;
export declare const authenticate: (apiGatewayEvent: any, tokenConfig: TokenConfig) => Promise<Either<Error, ResponseWithPayload>>;