UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 980 B
import{copy as e}from"../../i18n/copy.mjs";import t from"../../../constants/constants.mjs";import{decrypt as n,encrypt as r}from"../../../utils/helpers/encrypt-decrypt.mjs";import{isRecord as i}from"./paths.mjs";const a=e=>i(e)&&e[t.email.storage.encryptedValueMarker]===!0&&e.version===t.email.storage.encryptedValueVersion&&typeof e.value==`string`,o=(n,i)=>{try{return{error:void 0,data:{[t.email.storage.encryptedValueMarker]:!0,version:t.email.storage.encryptedValueVersion,value:r(JSON.stringify({value:n}),i)}}}catch{return{error:{type:`validation`,status:400,message:e(`server:core.email.storage.encrypt.failed`)},data:void 0}}},s=(t,r)=>{if(!a(t))return{error:void 0,data:t};try{let e=n(t.value,r);return{error:void 0,data:JSON.parse(e).value}}catch{return{error:{type:`validation`,status:400,message:e(`server:core.email.storage.decrypt.failed`)},data:void 0}}};export{s as decryptEmailStorageValue,o as encryptEmailStorageValue}; //# sourceMappingURL=encryption.mjs.map