* Load credential for a source * * For MCP sources, tries both OAuth and bearer credentials as fallback * (credentials may have been stored via different auth modes)
(source: LoadedSource)
| 108 | * (credentials may have been stored via different auth modes) |
| 109 | */ |
| 110 | async load(source: LoadedSource): Promise<StoredCredential | null> { |
| 111 | const manager = getCredentialManager(); |
| 112 | |
| 113 | // For MCP sources, try both OAuth and bearer credentials |
| 114 | // (stdio transport doesn't need credentials) |
| 115 | if (source.config.type === 'mcp' && source.config.mcp?.transport !== 'stdio' && source.config.mcp?.authType !== 'none') { |
| 116 | return this.loadMcpCredential(source); |
| 117 | } |
| 118 | |
| 119 | // For other sources, use the credential ID based on authType |
| 120 | const credentialId = this.getCredentialId(source); |
| 121 | const cred = await manager.get(credentialId); |
| 122 | |
| 123 | if (cred) { |
| 124 | debug(`[SourceCredentialManager] Found ${credentialId.type} for ${source.config.slug}`); |
| 125 | } |
| 126 | |
| 127 | return cred; |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Load MCP credential with fallback (OAuth -> bearer) |
no test coverage detected