import type { ClientRequest, ServerResponse } from 'http'; export interface ExpressRequest extends ClientRequest { body: CallbackPayload; headers: Record; } /** * @public */ export type CallbackPayload = { Action: string; CompanyId: string | number; Entity: string; FromUrl: string; ID: string | number; MemberId: string | number; Metadata: { key_url: string; }; Type: string; }; export type Entity = Record | Array>; /** * Load signing key and verify the message * @param callbackBody - * @param contentSignature - base64 content signature req.headers[x-content-signature] * @returns verifies callback signature * @public */ export declare function verifyCallback(callbackBody: CallbackPayload, contentSignature: string): Promise; /** * Validate a callback body against signed key * @param callbackBody - * @param contentSignature - * @param signingKey - * @returns boolean if verified * @public */ export declare function verifyMessage(callbackBody: CallbackPayload, contentSignature: string, signingKey: string): boolean; /** * * @example * Express style middleware * ``` * app.post('/your/api', cw.utils.middleware((err, req, res, verified, payload) => { * if (err) { * //handle error * res.status(500).end(); * } else if (!verified) { * // send 403 on verification failure * res.status(403).end(); * } else { * res.status(200).end() * } * const {action, id} = req.query; * // do something with the payload * })); * ``` * * @param cb - callback(err, req, res, verified, payload) * @public */ export declare function middleware(cb: (err: Error | null, req: ExpressRequest, res: ServerResponse, verified: boolean, payload: Entity | undefined) => void): (req: ExpressRequest, res: ServerResponse) => void; declare const _default: { middleware: typeof middleware; verifyCallback: typeof verifyCallback; verifyMessage: typeof verifyMessage; }; export default _default; //# sourceMappingURL=Callback.d.ts.map