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:161
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