MCPcopy
hub / github.com/opentrace/opentrace / resolveToken

Function resolveToken

plugins/opencode/src/index.ts:83–94  ·  view source on GitHub ↗

* Resolve the best git token for *url*. * * Sources, in priority order: * 1. The OpenCode-managed credential from the plugin's AuthHook. * Used only when *url* resolves to a known git host * (github.com / gitlab.com). The keychain stores one token at a * time and doesn't recor

(url?: string)

Source from the content-addressed store, hash-verified

81 * CLI just doesn't receive a `--token` flag.
82 */
83async function resolveToken(url?: string): Promise<string | null> {
84 const hostname = url ? extractHostname(url) : null
85 const token = await getStoredToken(hostname)
86 // Only log when we actually tried to match a host — "no token for a
87 // local path" isn't useful; the auth plumbing only does anything when
88 // there's a hostname to match against, and local-path indexing ignores
89 // the returned token anyway (indexRepo skips --token for non-URLs).
90 if (!token && hostname) {
91 debug("auth", "resolveToken: no token for", hostname)
92 }
93 return token
94}
95
96const server: Plugin = async (
97 input: PluginInput,

Callers 1

executeFunction · 0.85

Calls 3

extractHostnameFunction · 0.85
getStoredTokenFunction · 0.85
debugFunction · 0.85

Tested by

no test coverage detected