Skip to main content

An unofficial Node.js port of the Python library itsdangerous.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
3 weeks ago (2.0.3)
c
BadDataError

Base class for errors that are thrown when encountering invalid or corrupteddata. This class serves as the foundation for all specific error typesdefined in this module.

c
BadHeaderError

Error thrown when a signed header is found to be invalid during verification.This may occur when a serializer uses a header alongside the signature thatdoes not match expected values.

c
BadPayloadError

Error thrown when a payload is determined to be invalid, potentially due toissues with deserialization, or if an invalid signature allowed the payloadto be processed.

c
BadSignatureError

Error thrown when a data signature does not match the expected value. Thiserror provides access to the original payload, which may still hold valuedespite the tampering indicated by the invalid signature.

c
BadTimeSignatureError

Error thrown when a time-based signature is invalid, typically due to anincorrect or expired timestamp. Extends BadSignatureError and adds atimestamp indicating when the data was originally signed.

f
base64Decode

Decodes a Base64-encoded string or Uint8Array back into a Uint8Array. Theinput can be either a URL-safe Base64 string or a Uint8Array containingsuch a string.

f
base64Encode

Encodes a string or Uint8Array into a Base64-encoded Uint8Array. Theoutput is URL-safe and does not include padding characters.

f
bufferToInt

Converts a Uint8Array into a number or bigint. This function handles up to64-bit integers. If the resulting value can fit within JavaScript's safeinteger range, a number is returned; otherwise, a bigint is returned.

T
DefaultSerializer

A serializer interface that defines methods for serializing and deserializingdata. This is typically used to convert JavaScript objects to strings andvice versa.

c
HMACAlgorithm

A signature algorithm that generates signatures using HMAC (Hash-basedMessage Authentication Code).

f
intToBuffer

Converts a number or bigint into a Uint8Array. The resulting array is theminimal length needed to represent the number. This method supports both64-bit integers and large bigint values.

E
KeyDerivation

Enum representing the available key derivation methods.

c
NoneAlgorithm

A signature algorithm that does not perform any signing and always returns anempty signature.

c
Serializer

The Serializer class provides methods to serialize and securely sign data,as well as verify and deserialize signed data. It uses a Signer to signdata and can work with custom serialization formats.

T
SerializerOptions
No documentation available
c
SignatureExpiredError

Error thrown when a signature has expired. This occurs when a signature isvalid only for a certain period (maxAge) and that period has elapsed.

c
Signer

The Signer class securely signs data and verifies that it hasn't beentampered with by checking the signature. It supports various signingalgorithms and key derivation methods.

T
SignerOptions

Defines the options that can be provided to a Signer instance.

c
SigningAlgorithm

A base class for implementing signature algorithms. Subclasses must implementthe getSignature method.

c
TimedSerializer

The TimedSerializer class extends the Serializer class, using aTimestampSigner to sign values with a timestamp. This allows for thecreation of time-sensitive signatures that can expire.

c
TimestampSigner

The TimestampSigner class extends the functionality of the Signer classby including a timestamp when signing data. This allows signatures to have anexpiration time, after which they are considered invalid. The unsign methodcan throw SignatureExpiredError if the signature is expired.

c
URLSafeSerializer
No documentation available
c
URLSafeTimedSerializer

A specialized serializer that extends TimedSerializer with URL-safecompression and encoding. This serializer encodes the data into a stringformat that is safe for use in URLs, using characters from the alphabet andthe symbols '_', '-', and '.'.

f
wantBuffer

Converts an input, either a string or a Uint8Array, to a Uint8Array. Ifthe input is already a Uint8Array, it is returned unchanged. If it is astring, it is encoded as UTF-8.