import type { TokenPayload, TokenPayloadEncoded, TokenSignatureEncoded, TokenHeaderSignature, TokenHeaderSignatureEncoded, SignedToken, SignedTokenEncoded } from './types.js'; import type { Key, PublicKey, PrivateKey, KeyPair } from '../keys/types.js'; import type { POJO } from '../types.js'; /** * Token represents a single token with methods to sign and verify. * This token is derived from a strict subset of the JWS specification. * The token payload must abide by the registered claims of JWS, additional * properties that do not conflict are allowed. * For public key signatures, it only supports `EdDSA` algorithm. * For MAC signatures, it only supports `BLAKE2b` algorithm. * Multiple signatures are allowed, including 0 signatures. * During signing, additional properties can be part of the protected header. * The encoded format is compatible with the General JWS JSON format. */ declare class Token

{ readonly payload: Readonly

; readonly payloadEncoded: TokenPayloadEncoded; protected _signatures: Array; protected _signaturesEncoded: Array; protected signatureSet: Set; static fromPayload

(payload: P): Token

; static fromSigned

(tokenSigned: SignedToken

): Token

; /** * Construct from encoded payload. * It is up the caller to decide what the payload type should be. */ static fromEncoded

(signedTokenEncoded: SignedTokenEncoded): Token

; constructor(payload: P, payloadEncoded: TokenPayloadEncoded, signatures?: Array, signaturesEncoded?: Array); get signatures(): Readonly>>; get signaturesEncoded(): Readonly>>; signWithKey(key: Key, additionalProtectedHeader?: POJO, force?: boolean): void; signWithPrivateKey(privateKeyOrKeyPair: PrivateKey | KeyPair, additionalProtectedHeader?: POJO, force?: boolean): void; /** * Iterates over the signatures and attempts MAC verification */ verifyWithKey(key: Key): boolean; /** * Iterates over the signatures and attempts digital signature verification */ verifyWithPublicKey(publicKey: PublicKey): boolean; /** * Exports this `Token` into `SignedToken` */ toSigned(): SignedToken

; /** * Exports this `Token` into `SignedTokenEncoded` */ toEncoded(): SignedTokenEncoded; /** * The JSON representation of this `Token` is `SignedTokenEncoded` */ toJSON(): SignedTokenEncoded; } export default Token;