MCPcopy
hub / github.com/21st-dev/1code / getApiCredential

Method getApiCredential

src/main/lib/credential-manager.ts:191–208  ·  view source on GitHub ↗

* Get API credential for a source (handles basic auth JSON parsing)

(source: LoadedSource)

Source from the content-addressed store, hash-verified

189 * Get API credential for a source (handles basic auth JSON parsing)
190 */
191 async getApiCredential(source: LoadedSource): Promise<ApiCredential | null> {
192 const cred = await this.load(source);
193 if (!cred?.value) return null;
194
195 // Check for basic auth (JSON with username/password)
196 if (source.config.api?.authType === 'basic') {
197 try {
198 const parsed = JSON.parse(cred.value);
199 if (parsed.username && parsed.password) {
200 return parsed as BasicAuthCredential;
201 }
202 } catch {
203 // Not JSON, treat as regular credential
204 }
205 }
206
207 return cred.value;
208 }
209
210 // ============================================================
211 // Credential ID Resolution

Callers

nothing calls this directly

Calls 1

loadMethod · 0.95

Tested by

no test coverage detected