* Validate brand_agent variant
(
data: BrandAgentVariant,
result: BrandValidationResult
)
| 387 | * Validate brand_agent variant |
| 388 | */ |
| 389 | private validateBrandAgentVariant( |
| 390 | data: BrandAgentVariant, |
| 391 | result: BrandValidationResult |
| 392 | ): void { |
| 393 | if (!data.brand_agent || typeof data.brand_agent !== 'object') { |
| 394 | result.errors.push({ |
| 395 | field: 'brand_agent', |
| 396 | message: 'brand_agent object is required', |
| 397 | severity: 'error', |
| 398 | }); |
| 399 | return; |
| 400 | } |
| 401 | |
| 402 | if (!data.brand_agent.id) { |
| 403 | result.errors.push({ |
| 404 | field: 'brand_agent.id', |
| 405 | message: 'brand_agent.id is required', |
| 406 | severity: 'error', |
| 407 | }); |
| 408 | } |
| 409 | |
| 410 | if (!data.brand_agent.url) { |
| 411 | result.errors.push({ |
| 412 | field: 'brand_agent.url', |
| 413 | message: 'brand_agent.url is required', |
| 414 | severity: 'error', |
| 415 | }); |
| 416 | } else { |
| 417 | try { |
| 418 | const url = new URL(data.brand_agent.url); |
| 419 | if (!url.protocol.startsWith('https:')) { |
| 420 | result.errors.push({ |
| 421 | field: 'brand_agent.url', |
| 422 | message: 'brand_agent.url must use HTTPS', |
| 423 | severity: 'error', |
| 424 | }); |
| 425 | } |
| 426 | } catch { |
| 427 | result.errors.push({ |
| 428 | field: 'brand_agent.url', |
| 429 | message: 'brand_agent.url must be a valid URL', |
| 430 | severity: 'error', |
| 431 | }); |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | // Validate auth if present |
| 436 | if (data.auth) { |
| 437 | if (data.auth.method === 'oauth2' && !data.auth.token_endpoint) { |
| 438 | result.warnings.push({ |
| 439 | field: 'auth.token_endpoint', |
| 440 | message: 'token_endpoint is recommended when using oauth2 authentication', |
| 441 | suggestion: 'Add token_endpoint for OAuth2 authentication flow', |
| 442 | }); |
| 443 | } |
| 444 | } |
| 445 | } |
| 446 |