UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.45 kB
import{i as ErrorCodes}from"./missing-scope-error-CkgBgh6d.mjs";import{t as respondError}from"./response-BYbuAh7a.mjs";import{a as readGatewayRequestMutationAuthority}from"./session-mutation-guards-Bqnc5JYL.mjs";import{r as redeemFactoryGitHubProof}from"./factory-github-proof-DwBlaUXF.mjs"; //!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.`)}}};export{factoryGitHubProofHandlers};