@hampus/itsdangerous@2.0.3
An unofficial Node.js port of the Python library itsdangerous.
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.
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.
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.
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.
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.
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.
Encodes a string or Uint8Array
into a Base64-encoded Uint8Array
. Theoutput is URL-safe and does not include padding characters.
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.
A serializer interface that defines methods for serializing and deserializingdata. This is typically used to convert JavaScript objects to strings andvice versa.
A signature algorithm that generates signatures using HMAC (Hash-basedMessage Authentication Code).
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.
Enum representing the available key derivation methods.
A signature algorithm that does not perform any signing and always returns anempty signature.
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.
Error thrown when a signature has expired. This occurs when a signature isvalid only for a certain period (maxAge) and that period has elapsed.
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.
Defines the options that can be provided to a Signer
instance.
A base class for implementing signature algorithms. Subclasses must implementthe getSignature
method.
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.
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.
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 '.'
.
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.