Async wrapper around jsonwebtoken for JavaScript and TypeScript
npm install async-jsonwebtokenbash
npm install async-jsonwebtoken
`
API Reference
$3
`js
const [token, err] = await jwt.sign(
{
id: 123,
yourdata: "put here",
},
"This is a super secret"
);
`
| Parameter | Type | Description |
| :------------------- | :--------------------------- | :----------------------------------------------- |
| payload | string \| object \| Buffer | Required. data to be signed |
| secretOrPrivateKey | Secret | Required. A private key to sign |
| options | SignOptions | Options to be passed to jsonwebtoken sign method |
$3
`js
const [decoded, err] = await jwt.verify(
"Your JWT token to verify",
"This is a super secret"
);
`
| Parameter | Type | Description |
| :------------------ | :------------------------------- | :------------------------------------------------- |
| token | string | Required. token to be decoded |
| secretOrPublicKey | Secret \| GetPublicKeyOrSecret | Required. A private key to sign |
| options | VerifyOptions` | Options to be passed to jsonwebtoken verify method |