MCPcopy
hub / github.com/lingodotdev/lingo.dev / validateAuth

Function validateAuth

packages/cli/src/cli/cmd/i18n.ts:578–599  ·  view source on GitHub ↗
(settings: ReturnType<typeof getSettings>)

Source from the content-addressed store, hash-verified

576
577// Export validateAuth for use in other commands
578export 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
601function validateParams(i18nConfig: I18nConfig | null, flags: ReturnType<typeof parseFlags>) {
602 if (!i18nConfig) {

Callers 1

i18n.tsFile · 0.85

Calls 2

createAuthenticatorFunction · 0.90
whoamiMethod · 0.80

Tested by

no test coverage detected