@anzaui/engine - v0.6.0
    Preparing search index...

    Class Signer

    A validated signing key, built once at setup and available as Engine.signer. A running engine never signs with a missing, short or mismatched key, and inspect / JSON.stringify never print key material.

    import { Signer, signatureText } from '@anzaui/engine';

    const signer = Signer.from({ mode: 'hmac', secret: process.env.ANZA_SECRET! });
    const sig = signer.sign(signatureText(1724771200, 'feed', '<p>hi</p>'));
    signer.verify(signatureText(1724771200, 'feed', '<p>hi</p>'), sig!); // true
    Index
    mode: "ed25519" | "hmac" | "none"

    The signing mode.

    • get publicKey(): Buffer<ArrayBufferLike> | undefined

      The raw 32-byte Ed25519 public key that verifies this signer's signatures.

      Returns Buffer<ArrayBufferLike> | undefined

    • Sign message.

      Parameters

      • message: string | Uint8Array<ArrayBufferLike>

        The bytes to sign (strings are UTF-8 encoded).

      Returns string | undefined

      Lowercase hex signature, or undefined when signing is off.

    • Only the mode, never the key.

      Returns { mode: string }

      • mode: string

        The signing mode.

    • Check a lowercase-hex signature made by this signer (constant-time).

      Parameters

      • message: string | Uint8Array<ArrayBufferLike>

        The signed bytes (strings are UTF-8 encoded).

      • signatureHex: string

        The signature as lowercase hex.

      Returns boolean

      true when valid; always false when signing is off or the hex is malformed.

    • Validate options and decode its keys.

      Parameters

      • options: SignOptions = ...

        The signing options. Default { mode: 'none' }.

      Returns Signer

      The signer.

      AnzaError CRYPTO for a short or missing HMAC secret, a missing or malformed Ed25519 key, a mismatched public key, or an unknown mode.