eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 949 B
JavaScript
import{randomBytes}from"node:crypto";const WORKFLOW_CONTINUATION_SECURITY_KEY=`eve.harness.workflowContinuationSecurity`;function ensureWorkflowContinuationSecurity(n){return n.state?.[WORKFLOW_CONTINUATION_SECURITY_KEY]===void 0?{...n,state:{...n.state,[WORKFLOW_CONTINUATION_SECURITY_KEY]:{signingKey:randomBytes(32).toString(`base64url`),version:1}}}:(getWorkflowContinuationSecurity(n),n)}function readWorkflowContinuationSecurity(e){let n=e.state?.[WORKFLOW_CONTINUATION_SECURITY_KEY];if(!(typeof n!=`object`||!n||n.version!==1||typeof n.signingKey!=`string`||!/^[A-Za-z0-9_-]{43}$/.test(n.signingKey)))return{signingKey:n.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};