eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 910 B
JavaScript
import{encodeLegacyCommand,resolveLegacyInbox}from"./inbox.js";import{isObject}from"#shared/guards.js";import{resumeHook}from"#internal/workflow/runtime.js";import{HookNotFoundError}from"#compiled/@workflow/errors/index.js";async function resumeAuthorizationCallback(e,t){try{await resumeHook(e,t);return}catch(e){if(!HookNotFoundError.is(e))throw e}let n=await resolveLegacyInbox(e);if(n.current)throw Error(`Authorization was interrupted by the session upgrade. Request authorization again.`);let r=await n.hook.metadata;await resumeHook(n.hook.token,encodeLegacyCommand({kind:`deliver`,payloads:t.payloads},isObject(r)?r.sessionInboxWireVersion:void 0))}async function handleExpiredLegacyAuthorization(){return Response.json({ok:!1,error:`This authorization link predates the session upgrade. Request authorization again.`},{status:410})}export{handleExpiredLegacyAuthorization,resumeAuthorizationCallback};