1.0.13 • Published 1 year ago
doix-http-cookie-jwt v1.0.13
node-doix-http-cookie-jwt is a plug in for the doix framework providing an HTTP cookie based session mechanism using JSON Web Tokens.
Here, the whole user information record (seen as this.user in each Job instance) is completely included in the cookie value as the sub property of the JSON Web Token's claim.
Installation
npm install doix-http-cookie-jwtUsage
Upon instantiating your WebService descendant as myWebService:
const {CookieJWT} = require ('doix-http-cookie-jwt')
const sessionProvider = new CookieJWT ({
// name: 'sid',
// ttl: 60,
// claim: {},
// sign: {},
// verify: {},
})
// sessionProvider.getPrivateKey = async () => {...}
// sessionProvider.getPublicKey = async () => {...}
sessionProvider.plugInto (myWebService)Options
| Name | Type | Default | Description | Note |
|---|---|---|---|---|
name | String | 'sid' | name of the cookie | |
ttl | int | 60 | time to live, in minutes | defines the expiresIn JWT property |
claim | Object | {} | the claim part of the JWT | the sub property is always overridden with the user info |
sign | Object | {} | options for sign () | |
verify | Object | {} | options for verify () |
Methods
| Name | Description | Default implementation |
|---|---|---|
getPrivateKey () | returns the private key for using with sign () | ' ' |
getPublicKey () | returns the public key for using with verify () | ' ' |