import { Options as bodyParserOptions } from 'koa-bodyparser'; import Koa from 'koa'; declare type SecretKeyReturnFunction = (key: string) => string | undefined; declare type SecretKeyPromiseFunction = (key: string) => Promise; declare type SecretKeyCallbackFunction = (key: string, callback: ((error: Error) => void) | ((error: undefined, secret: string) => void)) => void; declare type SecretForKeyFunction = SecretKeyReturnFunction | SecretKeyPromiseFunction | SecretKeyCallbackFunction; declare type onAcceptedFunction = (ctx: Koa.Context, next: Koa.Next) => void; declare type onRejectedFunction = (ctx: Koa.Context, next: Koa.Next, error: Error) => void; interface SimpleHMACAuthKoaOptions { secretForKey: SecretForKeyFunction; onAccepted?: onAcceptedFunction; onRejected: onRejectedFunction; bodySizeLimit: number; bodySizeLimitString?: string; bodyParser: bodyParserOptions; } /** * Return Koa middleware that authenticates incoming requests * * @param {object} options * @param {function} options.secretForKey - function that returns the secret for a specified API key. Can be a promise, direct return, or invoke the 2nd callback parameter * @param {function} [options.onRejected] - function invoked when a request fails authentication * @param {function} [options.onAccepted] - optional function invoked when a request passes authentication * @param {object} [options.bodyParser] - body parser parameters * @param {Array} [options.bodyParser.enableTypes=['json', 'form', 'text']] - optionally parse only a subset of data types * @returns {function} middleware function */ declare function middleware(options?: Partial): Koa.Middleware; export default middleware;