decrypt
@rotorsoft/act-root / act-crypto/src / decrypt
Function: decrypt()
decrypt(
encoded,resolve_key,reviver?):Promise<unknown>
Defined in: libs/act-crypto/src/envelope.ts:181
Decrypt a base64-framed string back into the original JS value.
Parameters
encoded
string
Output of a prior encrypt call.
resolve_key
() => Promise<Buffer<ArrayBufferLike>>
Key resolver from makeKeyResolver.
reviver?
(key, value) => unknown
Optional JSON.parse reviver. Encryption is meant to be
transparent, but encrypt serializes through JSON.stringify — so a
Date arrives back as an ISO string unless the caller revives it.
Adapters pass the same reviver they use for their plaintext columns,
which is what keeps an encrypted value the same runtime type as an
unencrypted one.
Returns
Promise<unknown>
The original payload after JSON.parse.
Throws
DecryptionError on:
- input too short to hold the header
- unknown version byte
- GCM auth-tag mismatch (wrong key or tampered ciphertext)
- any decryption-stage failure