diff --git a/src/core/config/ConfigurationProvider.spec.ts b/src/core/config/ConfigurationProvider.spec.ts index 8d7d46b..91c42bf 100644 --- a/src/core/config/ConfigurationProvider.spec.ts +++ b/src/core/config/ConfigurationProvider.spec.ts @@ -63,6 +63,12 @@ describe('ConfigurationProvider', () => { ); }); + it('points to the installer when a required value is missing', () => { + expect(() => provider.getValue('clientId')).toThrow( + /WORKOS_CLIENT_ID\)\. .*npx workos@latest install/, + ); + }); + it('converts boolean values from strings', () => { const source = vi.fn().mockReturnValue('false'); provider.configure(source); @@ -191,6 +197,10 @@ describe('ConfigurationProvider', () => { ); }); + it('points agents to the installer, which needs no WorkOS account', () => { + expect(() => provider.validate()).toThrow(/npx workos@latest install/); + }); + it('shows current length of invalid cookiePassword', () => { provider.configure({ clientId: 'test-client', diff --git a/src/core/config/ConfigurationProvider.ts b/src/core/config/ConfigurationProvider.ts index 54dc1c4..af5407e 100644 --- a/src/core/config/ConfigurationProvider.ts +++ b/src/core/config/ConfigurationProvider.ts @@ -14,6 +14,10 @@ const defaultSource: ValueSource = (key: string): string | undefined => { } }; +/** Coding agents read this from the error, so the fix needs no human or account. */ +const MISSING_CONFIG_HINT = + 'To set up AuthKit without a WorkOS account, run `npx workos@latest install`: it creates an environment you can claim later and writes these variables.'; + /** * Configuration class for AuthKit. * This class is used to manage configuration values and provide defaults. @@ -92,7 +96,7 @@ export class ConfigurationProvider { if (this.requiredKeys.includes(key)) { throw new Error( - `Missing required configuration value for ${key} (${envKey}).`, + `Missing required configuration value for ${key} (${envKey}). ${MISSING_CONFIG_HINT}`, ); } @@ -179,7 +183,8 @@ export class ConfigurationProvider { 'AuthKit configuration error. Missing or invalid environment variables:\n\n' + errors.map(e => ` • ${e}`).join('\n') + '\n\nSet these environment variables or call configure() with the required values.' + - '\nGet your values from the WorkOS Dashboard: https://dashboard.workos.com', + '\nGet your values from the WorkOS Dashboard: https://dashboard.workos.com' + + '\nNo WorkOS account yet? Run `npx workos@latest install`: it creates an environment you can claim later and writes these variables.', ); } }