UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

20 lines (19 loc) • 1.13 kB
import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs"; //#region src/agents/mcp-oauth-authorization-facts.ts /** Refreshable expiry does not end the grant; terminal rejection and logout do. */ function hasMcpOAuthAuthorization(e) { return Boolean(e.tokens?.access_token && e.credentialState === void 0 && e.pendingAuthorizationChallenge?.requiresAuthorization !== true); } function projectMcpOAuthAuthorization(e) { return { authorizationId: hasMcpOAuthAuthorization(e) ? e.authorizationId ?? null : null, ...!e.tokens?.refresh_token && e.tokenExpiresAt !== void 0 ? { expiresAt: e.tokenExpiresAt } : {} }; } function isMcpOAuthAuthorizationReceipt(e) { if (!isRecord(e) || e.kind !== "mcp-oauth-authorization" || typeof e.storeKey !== "string" || !isRecord(e.authorization)) return false; const { authorizationId: t, expiresAt: n } = e.authorization; return (t === null || typeof t === "string" && t.length > 0) && (n === void 0 || typeof n === "number" && Number.isFinite(n)); } //#endregion export { isMcpOAuthAuthorizationReceipt as n, projectMcpOAuthAuthorization as r, hasMcpOAuthAuthorization as t };