Repository navigation
Responding to a new authentication
We may need to record a successful sign-in or create a local account. onAuthenticated supplies that point in the flow.
const options = {
clientKey,
onAuthenticated(user: AuthUser): void {
console.log('Authentication completed for', user.id);
},
};Import AuthUser as a type from @authwave/typescript-client. Pass these options to Authenticator or any runtime adapter. In JavaScript, omit the annotations.
The callback runs synchronously during construction after decryption and session mutation, before the cleanup redirect. It does not run when restoring an existing user. Put per-request work after construction, guarded by isLoggedIn().
The callback marker is stored before invocation. A thrown exception propagates and skips the cleanup redirect. Reprocessing that response does not invoke the callback again. Runtime adapters persist the marker even on callback failure.
The callback runs at most once per authentication exchange. Make external work idempotent and arrange retries in the application. Keep the callback synchronous; queue asynchronous work through application infrastructure.
A new login exchange creates fresh session data and can invoke the callback again.
Next, see Provider configuration and return URIs.
Authwave’s TypeScript client connects your Node.js, Express or Next.js application to an Authwave provider.