import BaseHandler from './base.js'; /** * Events that are emitted during an DID Connect process * * - scanned: when the qrcode is scanned by wallet * - succeed: when authentication complete * - error: when something goes wrong * * @class WalletHandlers * @extends {EventEmitter} */ declare class WalletHandlers extends BaseHandler { options: { prefix: string; cleanupDelay: number; tokenKey: string; encKey: string; versionKey: string; }; /** * Creates an instance of DID Auth Handlers. * * @class * @param {object} config * @param {object} config.tokenStorage - function to generate action token * @param {object} config.authenticator - Authenticator instance that can to jwt sign/verify * @param {function} [config.pathTransformer=null] - how should we update pathname * @param {function} [config.onConnect=noop] - function called before each auth request send back to app, used to check for permission, throw error to halt the auth process * @param {object} [config.options={}] - custom options to define all handlers attached * @param {string} [config.options.prefix='/api/did'] - url prefix for this group endpoints * @param {number} [config.options.cleanupDelay=60000] - how long to wait before cleanup finished session * @param {string} [config.options.tokenKey='_t_'] - query param key for `token` * @param {string} [config.options.encKey='_ek_'] - query param key for encryption key * @param {string} [config.options.versionKey='_v_'] - query param key for protocol `version` */ constructor({ pathTransformer, tokenStorage, authenticator, onConnect, options, }: { pathTransformer?: (v: string) => string; tokenStorage: any; authenticator: any; onConnect?: (...args: any[]) => any; options?: Partial<{ prefix: string; cleanupDelay: number; tokenKey: string; encKey: string; versionKey: string; }>; }); /** * Attach routes and handlers for authenticator * Now express app have route handlers attached to the following url * - `GET /api/did/{action}/token` create new token * - `GET /api/did/{action}/status` check for token status * - `GET /api/did/{action}/timeout` expire a token * - `GET /api/did/{action}/auth` create auth response * - `POST /api/did/{action}/auth` process payment request * * @method * @param {object} config * @param {object} config.app - express instance to attach routes to * @param {object} [config.claims] - claims for this request * @param {string} config.action - action of this group of routes * @param {function} [config.onStart=noop] - callback when a new action start * @param {function} [config.onConnect=noop] - callback when a new action start * @param {function} config.onAuth - callback when user completed auth in DID Wallet, and data posted back * @param {function} [config.onDecline=noop] - callback when user has declined in wallet * @param {function} [config.onComplete=noop] - callback when the whole auth process is done, action token is removed * @param {function} [config.onExpire=noop] - callback when the action token expired * @param {function} [config.onError=console.error] - callback when there are some errors * @param {boolean|string|did} [config.authPrincipal=true] - whether should we do auth principal claim first * @param {boolean} [config.persistentDynamicClaims=false] - whether should we persist dynamic claims * @return void */ attach({ app, action, claims, onStart, onConnect, onAuth, onDecline, onComplete, onExpire, onError, authPrincipal, persistentDynamicClaims, }: { app: any; action: string; claims?: any; onStart?: (...args: any[]) => any; onConnect?: (...args: any[]) => any; onAuth: (...args: any[]) => any; onDecline?: (...args: any[]) => any; onComplete?: (...args: any[]) => any; onExpire?: (...args: any[]) => any; onError?: (...args: any[]) => any; authPrincipal?: boolean | string | any; persistentDynamicClaims?: boolean; }): { generateSession: (req: import("../types.js").ConnectRequest, res: import("../types.js").ConnectResponse) => Promise; expireSession: (req: import("../types.js").ConnectRequest, res: import("../types.js").ConnectResponse) => Promise; checkSession: (req: import("../types.js").ConnectRequest, res: import("../types.js").ConnectResponse) => Promise; onAuthRequest: (req: import("../types.js").ConnectRequest, res: import("../types.js").ConnectResponse) => Promise; onAuthResponse: (req: import("../types.js").ConnectRequest, res: import("../types.js").ConnectResponse) => Promise; }; } export default WalletHandlers; //# sourceMappingURL=wallet.d.ts.map