UNPKG

koa-jwt

Version:

Koa middleware for validating JSON Web Tokens

13 lines (12 loc) 502 B
/** * resolveCookies - Attempts to retrieve the token from a cookie * * This function uses the opts.cookie option to retrieve the token * * @param {Object} ctx The ctx object passed to the middleware * @param {Object} opts This middleware's options * @return {String|null|undefined} The resolved token or null if not found or undefined if opts.cookie is not set */ module.exports = function resolveCookies(ctx, opts) { return opts.cookie && ctx.cookies.get(opts.cookie); };