A basic JWT sign method, meant for browser-side testing and dummy implementations
FOR EDUCATIONAL PURPOSES ONLY. DO NOT USE IN PRODUCTION CODE!
npm i -D fake-jwt-sign
Given some data object (i.e. authStatus
as shown below) and a 'secret'
, the sign
method generates a valid JWT token, assigned to accessToken
below.
const authStatus = {
isAuthenticated: true,
userId: 'e4d1bc2ab25c',
userRole: 'manager@test.com'
}
const accessToken = sign(authStatus, 'secret', {
expiresIn: '1h',
algorithm: 'none',
})
Check out https://github.com/duluca/lemon-mart/ to see the package in action.
Based on this Codepen https://codepen.io/jpetitcolas/pen/zxGxKN