UNPKG

@bitblit/ratchet-epsilon-common

Version:

Tiny adapter to simplify building API gateway Lambda APIS

31 lines (30 loc) 2.08 kB
import { APIGatewayEvent, APIGatewayEventRequestContext, AuthResponseContext } from 'aws-lambda'; import { EpsilonLoggerConfig } from '../config/epsilon-logger-config.js'; import { BasicAuthToken } from './auth/basic-auth-token.js'; import { LoggerLevelName } from '@bitblit/ratchet-common/logger/logger-level-name'; export declare class EventUtil { static readonly LOCAL_REGEX: RegExp[]; static readonly NON_ROUTABLE_REGEX: RegExp[]; private constructor(); static extractStage(event: APIGatewayEvent): string; static extractHostHeader(event: APIGatewayEvent): string; static extractProtocol(event: APIGatewayEvent): string; static extractApiGatewayStage(event: APIGatewayEvent): string; static extractRequestContext(event: APIGatewayEvent): APIGatewayEventRequestContext; static extractAuthorizer(event: APIGatewayEvent): AuthResponseContext; static ipAddressChain(event: APIGatewayEvent): string[]; static ipAddress(event: APIGatewayEvent): string; static extractFullPath(event: APIGatewayEvent, overrideProtocol?: string): string; static extractFullPrefix(event: APIGatewayEvent, overrideProtocol?: string): string; static jsonBodyToObject(evt: APIGatewayEvent): any; static calcLogLevelViaEventOrEnvParam(curLevel: LoggerLevelName, event: APIGatewayEvent, rConfig: EpsilonLoggerConfig): LoggerLevelName; static fixStillEncodedQueryParams(event: APIGatewayEvent): void; static applyTokenToEventForTesting(event: APIGatewayEvent, jwtToken: string): void; static extractBasicAuthenticationToken(event: APIGatewayEvent, throwErrorOnMissingBad?: boolean): BasicAuthToken; static eventIsAGraphQLIntrospection(event: APIGatewayEvent): boolean; static extractAuthorizationHeaderCaseInsensitive(evt: APIGatewayEvent): string; static extractBearerTokenFromEvent(evt: APIGatewayEvent): string; static hostMatchesRegexInList(host: string, list: RegExp[], caseSensitive?: boolean): boolean; static hostIsLocal(host: string): boolean; static hostIsLocalOrNotRoutableIP4(host: string): boolean; }