* Detect the authentication type from block content. * Returns 'oauth' if the block uses oauth-input credentials, * 'api-key' if it uses a plain API key field, or 'none' otherwise.
(blockContent: string)
| 575 | * 'api-key' if it uses a plain API key field, or 'none' otherwise. |
| 576 | */ |
| 577 | function extractAuthType(blockContent: string): 'oauth' | 'api-key' | 'none' { |
| 578 | // Prefer the authoritative `authMode` declaration when present. |
| 579 | if (/authMode\s*:\s*AuthMode\.OAuth\b/.test(blockContent)) return 'oauth' |
| 580 | if (/authMode\s*:\s*AuthMode\.(?:ApiKey|BotToken)\b/.test(blockContent)) return 'api-key' |
| 581 | // Fall back to credential subBlock heuristics for blocks without authMode. |
| 582 | if (/type\s*:\s*['"]oauth-input['"]/.test(blockContent)) return 'oauth' |
| 583 | if (/\bid\s*:\s*['"](?:apiKey|api_key|accessToken)['"]/.test(blockContent)) return 'api-key' |
| 584 | return 'none' |
| 585 | } |
| 586 | |
| 587 | /** |
| 588 | * Length-preserving copy of `content` with string-literal and comment |
no test coverage detected