Skip to content

Development and testing

Greg Bowler edited this page Nov 1, 2026 · 2 revisions

During development we can test application behavior without visiting the provider by replacing session and redirect handlers or using fake login.

A local fake login

auth.fakeLogin('development-user');
// Or:
auth.fakeLogin('development-user', 'developer@example.test', '/members/');

This stores synthetic user data and redirects with an encrypted response. The next request processes it and redirects again to remove the response parameter. The default email is fakelogin@authwave.com.

Use a destination without an existing query: the implementation appends its own ? instead of merging parameters. The current instance's in-memory user is not refreshed by fakeLogin() itself, matching PHP.

Warning

Fake login bypasses the provider. Restrict it to local development. Never expose a production route accepting an arbitrary identity.

Only the default fake email uses local logout; custom fake email addresses use the provider logout flow.

Recording redirects in a test

class RecordingRedirectHandler extends RedirectHandler {
  destination: string | null = null;
  override redirect(uri: UriLike, code = 303): void {
    this.destination = String(uri);
  }
}
const auth = new Authenticator({
  clientKey, currentUriPath: '/',
  session: new SessionArrayWrapper({}),
  redirectHandler: new RecordingRedirectHandler(),
});

Import these symbols from @authwave/typescript-client, using import type for UriLike. Recording handlers intentionally return normally; production adapters use the default redirect signal.

Running the repository checks

npm ci
npm run typecheck
npm test
npm run test:parity

The parity suite executes the sibling php-client reference using PHP with Sodium and its installed Composer dependencies. Set AUTHWAVE_PHP_REFERENCE if the PHP checkout is elsewhere. It compares deterministic encrypted requests, redirects and session/user snapshots. PARITY.md maps the PHP classes and behaviors to TypeScript.

The tests exercise core behavior and runtime integrations with simulated provider responses. They do not prove a deployed provider completes a browser login or logout. Run those flows against your configured provider before deployment.


If login does not complete, see Troubleshooting.

Clone this wiki locally