UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.39 kB
import{f as loadAuthProfileStoreForRuntimeAsync}from"../store-runtime-GNz-2GjY.mjs";import{n as resolveApiKeyForProfile}from"../oauth-DMxm8Ns0.mjs"; //!src/agents/mcp-auth-profile.runtime.ts async function resolveMcpAuthProfileBearerToken(e){const t=await loadAuthProfileStoreForRuntimeAsync(e.agentDir,{config:e.cfg,externalCliProfileIds:[e.profileId],readOnly:true,allowKeychainPrompt:false});const n=t.profiles[e.profileId];if(!n)throw new Error(`MCP server "${e.serverName}" references auth profile "${e.profileId}", but that profile was not found.`);if(n.type!==`oauth`)throw new Error(`MCP server "${e.serverName}" references auth profile "${e.profileId}", but ${n.type} profiles are not refreshable. Use a refresh-capable OAuth profile.`);const r=await resolveApiKeyForProfile({cfg:e.cfg,store:t,profileId:e.profileId,agentDir:e.agentDir});if(!r||r.profileType!==`oauth`||!r.apiKey)throw new Error(`MCP server "${e.serverName}" could not resolve refreshable OAuth auth profile "${e.profileId}". Re-authenticate the profile and retry.`);if(!r.credential||r.credential.type!==`oauth`||typeof r.credential.access!==`string`||r.credential.access.trim().length===0)throw new Error(`MCP server "${e.serverName}" resolved OAuth auth profile "${e.profileId}", but no raw access token was available for bearer projection.`);return r.credential.access}export{resolveMcpAuthProfileBearerToken};