Skip to content
This repository was archived by the owner on Mar 29, 2025. It is now read-only.
/ paseto Public archive

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

License

Notifications You must be signed in to change notification settings

panva/paseto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

50186ee Β· Mar 29, 2025
Feb 18, 2025
Jun 21, 2024
Sep 12, 2022
Sep 12, 2022
Apr 27, 2023
Oct 18, 2022
Aug 3, 2021
Apr 26, 2023
Apr 6, 2021
Apr 27, 2023
Jul 19, 2021
Jul 19, 2021
Jul 2, 2019
Mar 29, 2025
Mar 29, 2025
Jun 23, 2024
Apr 27, 2023

Repository files navigation

Important

This project is now archived. It may get revived when v5 and v6 protocol versions get released and their underlying crypto becomes readily available in Web Cryptography API implementations across JavaScript runtimes.

paseto

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

Supported Library Versions

Version Security Fixes πŸ”‘ Other Bug Fixes 🐞 New Features ⭐
v3.x Security Policy ❌ ❌

Implemented Protocol Versions

v1 v2 v3 v4
local βœ… ❌ βœ… ❌
public βœ… βœ… βœ… βœ…

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

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