Detalhes do pacote

paseto

panva116.8kMIT3.1.4

PASETO for Node.js with no dependencies

decode, decrypt, encrypt, local

readme (leia-me)

paseto

PASETO: Platform-Agnostic SEcurity TOkens for Node.js with no dependencies.

Implemented Protocol Versions

v1 v2 v3 v4
local
public

Support

If you or your business use paseto, please consider becoming a sponsor so I can continue maintaining it and adding new features carefree.

Documentation

Usage

Installing paseto

npm install paseto

Usage

const paseto = require('paseto')

// Generic (all versions) APIs
const { decode } = paseto

// PASETO Protocol Version v1 specific API
const { V1 } = paseto // { sign, verify, encrypt, decrypt, generateKey }

// PASETO Protocol Version v2 specific API
const { V2 } = paseto // { sign, verify, generateKey }

// PASETO Protocol Version v3 specific API
const { V3 } = paseto // { sign, verify, encrypt, decrypt, generateKey }

// PASETO Protocol Version v4 specific API
const { V4 } = paseto // { sign, verify, generateKey }

// errors utilized by paseto
const { errors } = paseto

Producing tokens

const { V4: { sign } } = paseto

(async () => {
  {
    const token = await sign({ sub: 'johndoe' }, privateKey)
    // v4.public.eyJzdWIiOiJqb2huZG9lIiwiaWF0IjoiMjAyMS0wOC0wM1QwNTozOTozNy42NzNaIn3AW3ri7P5HpdakJmZvhqssz7Wtzi2Rb3JafwKplLoCWuMkITYOo5KNNR5NMaeAR6ePZ3xWUcbO0R11YLb02awO
  }
})()

Consuming tokens

const { V4: { verify } } = paseto

(async () => {
  {
    const payload = await verify(token, publicKey)
    // { sub: 'johndoe', iat: '2019-07-01T15:22:47.982Z' }
  }
})()

FAQ

Supported Library Versions

Version Security Fixes 🔑 Other Bug Fixes 🐞 New Features ⭐ Node.js version supported
3.x.x >= 16.0.0
2.x.x ^12.19.0 || >=14.15.0
1.x.x >= 12.0.0

Semver?

Yes. Everything that's either exported in the TypeScript definitions file or documented is subject to Semantic Versioning 2.0.0. The rest is to be considered private API and is subject to change between any versions.

How do I use it outside of Node.js

It is only built for Node.js environment versions >=16.0.0

changelog (log de mudanças)

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

3.1.4 (2023-04-27)

Bug Fixes

  • stick with Record<string,unknown> types (ca8bfab)

3.1.3 (2023-04-26)

Bug Fixes

  • add generics to complete payload results and decode (#43) (df20460)

3.1.2 (2022-10-27)

Bug Fixes

3.1.1 (2022-09-12)

Bug Fixes

  • verify/decrypt without a footer (0d8be5e), closes #33

3.1.0 (2021-10-18)

Features

  • support PASERK in key generation (bffbda4), closes #25
  • support PASERK Type secret, local, public keys (f41bfc3), closes #25

3.0.1 (2021-08-04)

3.0.0 (2021-08-03)

⚠ BREAKING CHANGES

  • Node.js runtime version v16.0.0 or greater is now required

Features

  • add v3.local, v3.public, and v4.public (2139643)

2.1.3 (2021-07-22)

Bug Fixes

  • return correct version from v1 decrypt with buffer and complete options (eebab05)
  • throw when options are provided while in raw buffer mode (5434b46)

2.1.2 (2021-07-17)

Bug Fixes

  • defer decryption after tag verification passes (a34d9df)
  • return correct version from v1 verify with buffer and complete options (00f0dd6)

2.1.1 (2021-04-06)

Performance

  • improve base64url encoding when native is available (385689e)
  • use native sign/verify non-blocking callback when available (995b278)

2.1.0 (2021-02-24)

Features

2.0.0 (2021-02-23)

⚠ BREAKING CHANGES

  • removed v2.local encrypt, decrypt, and key generation
  • requires Node.js version ^12.19.0 || >=14.15.0

Features

  • removed the libsodium dependency (0fe5de6)

1.0.8 (2020-11-19)

1.0.7 (2020-07-09)

Performance Improvements

  • omit serializing KeyObjects when Node.js >= 14.5.0 is used (3d5c148)

1.0.6 (2020-04-21)

Performance Improvements

  • faster V1 encrypt/decrypt by grouping the crypto worker operations (dbbdfa6)
  • removed regexp checking for base64url padding and charset (f113782)

1.0.5 (2019-12-26)

1.0.4 (2019-11-14)

1.0.3 (2019-10-21)

Bug Fixes

  • typescript: actually bundle the types with a package release (5f4e961)

1.0.2 (2019-10-18)

Bug Fixes

  • symmetric keys are 32 bytes, not 256 (error message was wrong) (d223704)

1.0.1 (2019-09-30)

Bug Fixes

  • typescript: move ts files around and fix missing DecodeResult (c797404)

1.0.0 (2019-09-27)

0.9.1 (2019-07-02)

Features