UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

30 lines (29 loc) • 1.65 kB
import { t as ErrorCodes } from "./gateway-error-details-B69XiHdh.mjs"; import { t as respondError } from "./response-C7fEiIN1.mjs"; import { a as readGatewayRequestMutationAuthority } from "./session-mutation-guards-Bjnk_O0z.mjs"; import { r as redeemFactoryGitHubProof } from "./factory-github-proof-BtzKPxNQ.mjs"; //#region src/gateway/server-methods/factory-github-proof.ts const factoryGitHubProofHandlers = { "factory.githubPublication.redeem": (e) => { const { client: t, context: n, params: r, respond: i } = e; if (process.env.FACTORY_AUTH_MODE !== "github" || t?.internal?.isLocalClient !== true || t.internal.authenticatedOperator !== true || t.internal.operatorRoleActor?.kind !== "system" || t.connect.role !== "operator" || !t.connect.scopes?.includes("operator.admin") || !t.connId || n.isConnectionActive?.(t.connId) === false) { respondError(i, ErrorCodes.FORBIDDEN, "Private GitHub proof redemption is unavailable."); return; } const a = r && typeof r === "object" && "proof" in r ? r.proof : void 0; if (!r || typeof r !== "object" || Array.isArray(r) || Object.keys(r).length !== 1 || typeof a !== "string") { respondError(i, ErrorCodes.INVALID_REQUEST, "GitHub proof request is invalid."); return; } try { const r = readGatewayRequestMutationAuthority(e); r.assertCurrent(); const o = redeemFactoryGitHubProof(a); r.assertCurrent(); if (n.isConnectionActive?.(t.connId) === false) throw new Error("Private GitHub proof caller is no longer active."); i(true, o); } catch { respondError(i, ErrorCodes.FORBIDDEN, "GitHub proof is unavailable."); } } }; //#endregion export { factoryGitHubProofHandlers };