UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

17 lines • 768 B
/** * Normalise an {@link AuthorizeResult} to allow/deny + status. Only `true` and an object whose * `allowed` is exactly `true` allow; anything else (including a malformed value from an untyped hook) * denies — `401` only when the decision says `reason: 'unauthenticated'`, `403` otherwise. */ export function resolveAuthorizeResult(result) { if (result === true) return { allowed: true }; if (typeof result === 'object' && result !== null) { const decision = result; if (decision.allowed === true) return { allowed: true }; return { allowed: false, status: decision.reason === 'unauthenticated' ? 401 : 403 }; } return { allowed: false, status: 403 }; } //# sourceMappingURL=authorize-decision.js.map