wingbot-jwt
v2.0.1
Published
JSON Web Token for wingbot
Downloads
71
Maintainers
Readme
JSON web token plugin for wingbot
Fast solution for webview requests authorization
Usage
const { Processor } = require('wingbot');
const { BotTokenStorage } = require('wingbot-jwt');
const processor = new Processor(bot, {
tokenStorage: new BotTokenStorage('<put a secret here>', { expiresIn: '30d' })
})
API
Classes
Typedefs
BotTokenStorage
Storage for JWT tokens
Kind: global class
- BotTokenStorage
- new BotTokenStorage(secretOrPrivateKey, [jwtOptions])
- .findByToken(token) ⇒ Promise.<(Token|null)>
- .getOrCreateToken(senderId, pageId) ⇒ Promise.<(Token|null)>
new BotTokenStorage(secretOrPrivateKey, [jwtOptions])
| Param | Type | | --- | --- | | secretOrPrivateKey | string | Buffer | | [jwtOptions] | Object |
botTokenStorage.findByToken(token) ⇒ Promise.<(Token|null)>
Kind: instance method of BotTokenStorage
| Param | Type | | --- | --- | | token | string |
botTokenStorage.getOrCreateToken(senderId, pageId) ⇒ Promise.<(Token|null)>
Kind: instance method of BotTokenStorage
| Param | Type | | --- | --- | | senderId | string | | pageId | string |
Token : Object
Kind: global typedef
Properties
| Name | Type | | --- | --- | | senderId | string | | pageId | string | | token | string |