/hapi-jwt-token

Support json web token sign and verify function with default sign config and verify config

Primary LanguageJavaScriptMIT LicenseMIT

hapi-jwt-token Build Status

Not Maintained

❗ I haven't use Hapi framework for a long time. This repository is no longer maintained.

1. This plugin can let you plug jsonwebtoken sign function and verify function with config.

2. Sign method accessible by server.plugins['hapi-jwt-token'].sign.

3. Verify method accessible by server.plugins['hapi-jwt-token'].verify.

You may use server.method in the callback to prevent always typing the long path server.plugins['hapi-jwt-token']

server.method('sign', server.plugins['hapi-jwt-token'].sign);
server.method('verify', server.plugins['hapi-jwt-token'].verify);

If you want to make the function return Promise (i.e async function), you may interested in hapi-async-methods

Install

Note: jsonwebtoken is required.

npm install --save jsonwebtoken

npm install --save hapi-jwt-token

Options

signOptions(Optional) see here

verifyOptions(Optional) see here

key(Required): The second parameter of jsonwebtoken.sign and jsonwebtoken.verify. i.e (The secretOrPublicKey)

You can use this plugin with hapi-auth-jwt2 to provide user login with jsonwebtoken.

LICENSE

The MIT License (MIT)

Copyright (c) 2016 Sze Ka Wai Raymond

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.