1.0.13 • Published 10 months ago

doix-http-cookie-jwt v1.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

workflow Jest coverage

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-jwt

Usage

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

NameTypeDefaultDescriptionNote
nameString'sid'name of the cookie
ttlint60time to live, in minutesdefines the expiresIn JWT property
claimObject{}the claim part of the JWTthe sub property is always overridden with the user info
signObject{}options for sign ()
verifyObject{}options for verify ()

Methods

NameDescriptionDefault implementation
getPrivateKey ()returns the private key for using with sign ()' '
getPublicKey ()returns the public key for using with verify ()' '
1.0.13

10 months ago

1.0.8

11 months ago

1.0.5

1 year ago

1.0.2

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago