1.0.1 • Published 3 years ago

async-jsonwebtoken v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Async JsonWebToken

Async wrapper around jsonwebtoken for JavaScript and TypeScript

visit jsonwebtoken for more info

install

npm install async-jsonwebtoken

API Reference

Sign a Token

const [token, err] = await jwt.sign(
  {
    id: 123,
    yourdata: "put here",
  },
  "This is a super secret"
);
ParameterTypeDescription
payloadstring \| object \| BufferRequired. data to be signed
secretOrPrivateKeySecretRequired. A private key to sign
optionsSignOptionsOptions to be passed to jsonwebtoken sign method

Verify a Token

const [decoded, err] = await jwt.verify(
  "Your JWT token to verify",
  "This is a super secret"
);
ParameterTypeDescription
tokenstringRequired. token to be decoded
secretOrPublicKeySecret \| GetPublicKeyOrSecretRequired. A private key to sign
optionsVerifyOptionsOptions to be passed to jsonwebtoken verify method

Note the rest of the library just reexports the jsonwebtoken's exports