@edgetoken/core
    Preparing search index...

    Function decryptPasetoV3Local

    • Authenticates and decrypts a PASETO v3.local token.

      Type Parameters

      • T = Record<string, unknown>

        The expected shape of the decrypted payload.

      Parameters

      • token: string

        The serialized PASETO token (v3.local.<body_base64>[.<footer_base64>]).

      • key: Uint8Array

        The 32-byte symmetric key used during encryption.

      Returns Promise<{ footer?: string; payload: T }>

      A Promise resolving to an object containing the decrypted payload and optional footer.

      If the provided key is not exactly 32 bytes.

      If the header does not match v3.local..

      If the ciphertext body is truncated or malformed.

      If HMAC authentication fails due to tampering or an incorrect key.

      try {
      const { payload, footer } = await decryptPasetoV3Local(token, key);
      console.log("Decrypted payload:", payload);
      } catch (err) {
      console.error("Token verification or decryption failed:", err.message);
      }