UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines 944 B
import{randomBytes}from"node:crypto";const WORKFLOW_CONTINUATION_SECURITY_KEY=`eve.harness.workflowContinuationSecurity`;function ensureWorkflowContinuationSecurity(e){return e.state?.[WORKFLOW_CONTINUATION_SECURITY_KEY]===void 0?{...e,state:{...e.state,[WORKFLOW_CONTINUATION_SECURITY_KEY]:{signingKey:randomBytes(32).toString(`base64url`),version:1}}}:(getWorkflowContinuationSecurity(e),e)}function readWorkflowContinuationSecurity(e){let t=e.state?.[WORKFLOW_CONTINUATION_SECURITY_KEY];if(typeof t==`object`&&t&&t.version===1&&typeof t.signingKey==`string`&&/^[A-Za-z0-9_-]{43}$/.test(t.signingKey))return{signingKey:t.signingKey,maxAgeMs:31536e6}}function getWorkflowContinuationSecurity(e){let t=readWorkflowContinuationSecurity(e);if(t===void 0)throw Error(`Workflow continuation security state is missing or invalid.`);return t}export{ensureWorkflowContinuationSecurity,getWorkflowContinuationSecurity,readWorkflowContinuationSecurity};