import { Message, MessageProperties } from 'amqplib';
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, Context, SQSEvent } from 'aws-lambda';
import { SQSBatchResponse } from 'aws-lambda/trigger/sqs';
import { Jwt } from 'jsonwebtoken';
import { RabbitmqEvent } from './messaging/RabbitmqEvent';
export declare type BodyParam = any;
export declare type QueryParams = Record<string, string | string[] | undefined>;
export declare type PaginationParams = {
    pageSize: number | undefined;
    pageNumber: number | undefined;
};
export declare type LambdaContext = {
    event: LambdaEvent;
    context: Context;
};
export declare type ErrorResponse<T> = {
    error: T;
};
export declare type ApiGatewayEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
export declare type LambdaEvent = RabbitmqEvent | SQSEvent | ApiGatewayEvent | CronJobEvent;
export declare enum LambdaEventSourceKind {
    ApiGateway = "ApiGateway",
    ApiGatewayV2 = "ApiGatewayV2",
    RabbitMq = "RabbitMq",
    CronJob = "CronJob",
    Sqs = "Sqs"
}
export declare enum DfnsApiKind {
    OrgsApi = "orgs-api",
    StaffApi = "staff-api",
    PrivateApi = "private-api"
}
export declare type LambdaOptions = {
    logRequest?: boolean;
    logResponse?: boolean;
    traceRequest?: boolean;
};
export declare type LambdaHandler = (event: LambdaEvent, context: Context) => Promise<ApiGatewayResult | SQSBatchResponse | void>;
export declare type ApiOperationMapping = Readonly<{
    http: {
        method: string;
        path: string;
    };
    graphQl: {
        businessDomain: string;
        operationKind: string;
        operationName: string;
    };
}>;
export declare type HttpMapItem = {
    httpMethod: string;
    httpPath: string;
    pathTester: PathTester;
    businessLogic: BusinessLogicBase;
};
export declare type GraphQlMapItem = [string, string, BusinessLogicBase];
export declare type ApiGatewayResult = APIGatewayProxyResult & APIGatewayProxyStructuredResultV2;
export declare type ApiGatewayEventHandler = (event: ApiGatewayEvent, context: Context) => Promise<ApiGatewayResult>;
export declare type ApiRequestInput<TBody, TQuery, TAuthIdentity extends AuthIdentity = AuthIdentity> = {
    authDetails: AuthDetails<TAuthIdentity>;
    lambdaContext: LambdaContext;
    body: TBody;
    query: TQuery;
};
export declare type BusinessLogicBase<TBody = BodyParam, TQuery = QueryParams, TResp = any, TAuthIdentity extends AuthIdentity = AuthIdentity> = (input: ApiRequestInput<TBody, TQuery, TAuthIdentity>) => Promise<TResp>;
export declare type BusinessLogicGeneric<TBody = any, TQuery = any, TResp = any> = BusinessLogic<TBody, TQuery, TResp> | BusinessLogicStaff<TBody, TQuery, TResp> | BusinessLogicPrivate<TBody, TQuery, TResp>;
export declare type BusinessLogic<TBody, TQuery, TResp = any> = BusinessLogicBase<TBody, TQuery, TResp, OrgEmployeeIdentity | OrgApiKeyIdentity>;
export declare type BusinessLogicStaff<TBody, TQuery, TResp = any> = BusinessLogicBase<TBody, TQuery, TResp, DfnsStaffIdentity>;
export declare type BusinessLogicPrivate<TBody, TQuery, TResp = any> = BusinessLogicBase<TBody, TQuery, TResp, DfnsServiceIdentity>;
export declare type SQSEventHandler = (event: SQSEvent, context: Context) => Promise<SQSBatchResponse>;
export declare type SQSMessageHandler<M = any> = (message: M, context: {
    lambdaContext: Context;
    record: SQSEvent['Records'][number];
    sqsEvent: SQSEvent;
}) => Promise<void>;
export declare type SqsQueueMap = {
    queueArn: string | RegExp;
    handler: SQSMessageHandler;
};
export declare type CronJobEvent = {
    eventType: 'dfns:cron';
    eventTopic: string;
    payload?: any;
};
export declare type CronJobEventHandler = (cronJobEvent: CronJobEvent, context?: Context) => Promise<void>;
export declare type CronJobEventHandlerMap = {
    [cronJobTopic: string]: CronJobEventHandler;
};
export declare type EventHandlerFunction<E, C, R> = (request: E, context: C) => Promise<R>;
export declare type AwsMqMessage = {
    data: string;
    basicProperties: Message['properties'];
};
export declare type RabbitMqEventHandlerContext = {
    context: Context;
    queueName: string;
    redeliveredCount: number;
    basicProperties: MessageProperties;
};
export declare type RabbitMqEventHandler<E> = (event: E, context: RabbitMqEventHandlerContext) => Promise<any>;
export declare type RabbitMqEventHandlerMap<E> = {
    [topic: string]: RabbitMqEventHandler<E>;
};
export declare type RabbitMqEventHandlerOptions = {
    maxRetries?: number;
};
export declare type AuthDetails<TAuthIdentity extends AuthIdentity = AuthIdentity> = {
    authorization: string;
    identity: TAuthIdentity;
    authBlock?: DecodedAuthBlock;
    signedAttestationBlock?: AuthBlock;
};
export declare type AuthBlock = {
    request: string;
    auth: string;
};
export declare type AuthIdentity = OrgEmployeeIdentity | OrgApiKeyIdentity | DfnsStaffIdentity | DfnsServiceIdentity;
export declare enum AuthIdentityKind {
    DfnsStaff = "DfnsStaffIdentity",
    OrgEmployee = "OrgEmployeeIdentity",
    OrgApiKey = "OrgApiKeyIdentity",
    DfnsService = "DfnsService"
}
export declare type OrgAuthIdentityKind = AuthIdentityKind.OrgEmployee | AuthIdentityKind.OrgApiKey;
export declare type OrgEmployeeIdentity = {
    kind: AuthIdentityKind.OrgEmployee;
    orgId: string;
    employeeId: string;
    username: string;
    isOrgOwner: boolean;
    scope: string;
    permissions: string[];
};
export declare type OrgApiKeyIdentity = {
    kind: AuthIdentityKind.OrgApiKey;
    orgId: string;
    apiKeyId: string;
    scope: string;
    permissions: string[];
};
export declare type DfnsStaffIdentity = {
    kind: AuthIdentityKind.DfnsStaff;
    username: string;
    scope: string;
    permissions: string[];
};
export declare type DfnsServiceIdentity = {
    kind: AuthIdentityKind.DfnsService;
    serviceName: string;
};
export declare enum UserAuthKind {
    EndUser = "EndUser",
    Employee = "CustomerEmployee",
    Staff = "DfnsStaff"
}
export declare enum AppAuthKind {
    ClientSide = "ClientSideApplication",
    ServerSide = "ServerSideApplication"
}
export declare type DecodedAuthBlock = {
    request: DecodedRequest;
    auth: AuthInfo;
};
export declare type UserAuthInfo = {
    signed: boolean;
    secureDevice: boolean;
    hash: string;
    identity: {
        kind: UserAuthKind;
        isPat: boolean;
        isRegistrationCode: boolean;
        isServiceAccount: boolean;
        id: string;
        scopes: string[];
        permissions: string[];
        orgId: string;
    };
    challenge?: string;
    credentialKind?: CredentialKind;
};
export declare type AuthInfo = {
    authenticated: boolean;
    authorized: boolean;
    app: {
        signed: boolean;
        secureDevice: boolean;
        hash: string;
        identity: {
            kind: AppAuthKind;
            id: string;
            scopes: string[];
            permissions: string[];
            orgId: string;
        };
    };
    user?: UserAuthInfo;
};
export declare type DecodedRequest = {
    headers: {
        accept: string;
        acceptEncoding: string;
        authorization: string;
        clientId: string;
        clientSecret: string;
        connection: string;
        contentLength: string;
        contentType: string;
        host: string;
        nonce: string;
        userAction: string;
        userAgent: string;
    };
    body: string;
    http: {
        authority: string;
        method: string;
        path: string;
        scheme: string;
    };
};
export declare enum CredentialKind {
    Fido2 = "FIDO2",
    Key = "Key",
    Password = "Password",
    Totp = "Totp"
}
export declare type TokenPayload = {
    [key: string]: unknown;
    iss: string;
    sub: string;
    aud: string;
    nbf?: number | undefined;
    iat?: number | undefined;
    jti?: string | undefined;
};
export declare type VerifyAuthenticationResponse = VerifyAuthenticationResponseV0 | VerifyAuthenticationResponseV1;
export declare type VerifyAuthenticationResponseV0 = {
    token: string;
    decodedToken: Jwt;
    authIdentity: AuthIdentity;
    authBlock: undefined;
};
export declare type VerifyAuthenticationResponseV1 = {
    authBlock: AuthBlock;
    token: undefined;
    decodedToken: undefined;
    authIdentity: undefined;
};
export declare type Callback1Arg<A, R> = (arg?: A) => Promise<R>;
export declare type LoggerParams = {
    serverVendor?: string;
    serverRegion?: string;
    domain?: string;
    serviceName?: string;
    environment?: string;
    serviceKind?: string;
    serviceId?: string;
    level?: string;
};
export declare type LogPayload = {
    level: string;
    epochTimestamp: number;
    environment: string;
    isoTimestamp: string;
    serverVendor: string;
    serverRegion: string;
    domain: string;
    serviceName: string;
    serviceKind: string;
    message: string;
    checksum?: string;
    reconciliationId?: string;
    serviceId: string;
    payload: any;
};
export declare type PathTester = (httpPath: string) => QueryParams | null;
export declare type DfnsErrorObject = {
    name?: string;
    httpStatus: number;
    shouldTriggerInvestigation?: boolean;
    causes?: string[];
    message: string;
    stackTrace?: string;
};
export interface DfnsError {
    toErrorObject(): DfnsErrorObject;
    toString(): string;
}
