(settings: ReturnType<typeof getSettings>)
| 576 | |
| 577 | // Export validateAuth for use in other commands |
| 578 | export async function validateAuth(settings: ReturnType<typeof getSettings>) { |
| 579 | if (!settings.auth.apiKey) { |
| 580 | throw new AuthenticationError({ |
| 581 | message: "Not authenticated. Please run `lingo.dev login` to authenticate.", |
| 582 | docUrl: "authError", |
| 583 | }); |
| 584 | } |
| 585 | |
| 586 | const authenticator = createAuthenticator({ |
| 587 | apiKey: settings.auth.apiKey, |
| 588 | apiUrl: settings.auth.apiUrl, |
| 589 | }); |
| 590 | const user = await authenticator.whoami(); |
| 591 | if (!user) { |
| 592 | throw new AuthenticationError({ |
| 593 | message: "Invalid API key. Please run `lingo.dev login` to authenticate.", |
| 594 | docUrl: "authError", |
| 595 | }); |
| 596 | } |
| 597 | |
| 598 | return user; |
| 599 | } |
| 600 | |
| 601 | function validateParams(i18nConfig: I18nConfig | null, flags: ReturnType<typeof parseFlags>) { |
| 602 | if (!i18nConfig) { |
no test coverage detected