bottender
Version:
A framework for building conversational user interfaces.
92 lines • 3.45 kB
TypeScript
/// <reference types="node" />
import { EventEmitter } from 'events';
import { JsonObject } from 'type-fest';
import { LineClient } from 'messaging-api-line';
import Session from '../session/Session';
import { Connector } from '../bot/Connector';
import { RequestContext } from '../types';
import LineContext from './LineContext';
import LineEvent from './LineEvent';
import { LineRawEvent, LineRequestBody, LineRequestContext } from './LineTypes';
declare type CommonConnectorOptions = {
getConfig?: GetConfigFunction;
getSessionKeyPrefix?: GetSessionKeyPrefixFunction;
shouldBatch?: boolean;
sendMethod?: string;
skipLegacyProfile?: boolean;
};
declare type Credential = {
accessToken: string;
channelSecret: string;
};
declare type GetConfigFunction = ({ params, }: {
params: Record<string, string>;
}) => Credential | Promise<Credential>;
export declare type GetSessionKeyPrefixFunction = (event: LineEvent, requestContext?: RequestContext) => string;
declare type CredentialOptions = Credential | {
getConfig: GetConfigFunction;
};
declare type ConnectorOptionsWithoutClient = CredentialOptions & {
origin?: string;
} & CommonConnectorOptions;
declare type ConnectorOptionsWithClient = {
client: LineClient;
channelSecret: string;
} & CommonConnectorOptions;
export declare type LineConnectorOptions = ConnectorOptionsWithoutClient | ConnectorOptionsWithClient;
export default class LineConnector implements Connector<LineRequestBody, LineClient> {
_client: LineClient | undefined;
_channelSecret: string | undefined;
_origin: string | undefined;
_skipLegacyProfile: boolean;
_getConfig: GetConfigFunction | undefined;
_getSessionKeyPrefix: GetSessionKeyPrefixFunction | undefined;
_shouldBatch: boolean;
_sendMethod: string;
constructor(options: LineConnectorOptions);
_isWebhookVerifyEvent(event: LineRawEvent): boolean;
isWebhookVerifyRequest(body: LineRequestBody): boolean;
get platform(): 'line';
get client(): LineClient | undefined;
getUniqueSessionKey(bodyOrEvent: LineRequestBody | LineEvent, requestContext?: RequestContext): string;
updateSession(session: Session, bodyOrEvent: LineRequestBody | LineEvent): Promise<void>;
mapRequestToEvents(body: LineRequestBody): LineEvent[];
createContext(params: {
event: LineEvent;
session?: Session | null;
initialState?: JsonObject | null;
requestContext?: LineRequestContext;
emitter?: EventEmitter | null;
}): Promise<LineContext>;
verifySignature(rawBody: string, signature: string, { channelSecret }: {
channelSecret: string;
}): boolean;
preprocess({ method, headers, rawBody, body, params, }: LineRequestContext): Promise<{
shouldNext: boolean;
response?: undefined;
} | {
shouldNext: boolean;
response: {
status: number;
body: {
error: {
message: string;
request: {
rawBody: string;
headers: {
'x-line-signature': string | undefined;
};
};
};
};
};
} | {
shouldNext: boolean;
response: {
status: number;
body: string;
};
}>;
}
export {};
//# sourceMappingURL=LineConnector.d.ts.map