Skip to main content

API Reference

Complete API reference for @nauth-toolkit/client.

Core SDK

ExportTypeDescription
NAuthClientClassMain client class for all authentication operations
NAuthClientConfigInterfaceConfiguration options
NAuthClientErrorClassError class for SDK operations
BrowserStorageClasslocalStorage/sessionStorage adapter
InMemoryStorageClassIn-memory storage adapter

Types

All TypeScript types are exported from the main package:

import {
// Auth types
AuthChallenge, // See [AuthChallenge](./types/auth-challenge)
AuthResponse, // See [AuthResponse](./types/auth-response)
ChallengeResponse, // See [ChallengeResponse](./types/challenge-response)
SignupRequest, // See [SignupRequest](./types/signup-request)
TokenResponse, // See [TokenResponse](./types/token-response)

// Challenge helper utilities
getMaskedDestination, // See [Challenge Helpers](./utilities/challenge-helpers#getmaskeddestination)
getMFAMethod, // See [Challenge Helpers](./utilities/challenge-helpers#getmfamethod)
requiresPhoneCollection, // See [Challenge Helpers](./utilities/challenge-helpers#requiresphonecollection)
getChallengeInstructions, // See [Challenge Helpers](./utilities/challenge-helpers#getchallengeinstructions)
isOTPChallenge, // See [Challenge Helpers](./utilities/challenge-helpers#isotpchallenge)

// User types
AuthUser, // See [AuthUser](./types/auth-user)
AuthUserSummary, // See [AuthUserSummary](./types/auth-user-summary)
ChangePasswordRequest, // See [ChangePasswordRequest](./types/change-password-request)
UpdateProfileRequest, // See [UpdateProfileRequest](./types/update-profile-request)

// MFA types
BackupCodesResponse, // See [BackupCodesResponse](./types/backup-codes-response)
GetChallengeDataResponse, // See [GetChallengeDataResponse](./types/get-challenge-data-response)
GetSetupDataResponse, // See [GetSetupDataResponse](./types/get-setup-data-response)
MFAChallengeMethod, // See [MFAChallengeMethod](./types/mfa-challenge-method)
MFADevice, // See [MFADevice](./types/mfa-device)
MFAMethod, // See [MFAMethod](./types/mfa-method)
MFAStatus, // See [MFAStatus](./types/mfa-status)

// Social types
LinkedAccountsResponse, // See [LinkedAccountsResponse](./types/linked-accounts-response)
SocialLoginOptions, // See [SocialLoginOptions](./types/social-login-options)
SocialVerifyRequest, // See [SocialVerifyRequest](./types/social-verify-request)

// Config types
NAuthEndpoints, // See [NAuthEndpoints](./types/nauth-endpoints)
NAuthStorageAdapter, // See [NAuthStorageAdapter](./types/nauth-storage-adapter)
TokenDeliveryMode, // See [TokenDeliveryMode](./types/token-delivery-mode)

// Audit types
AuditHistoryResponse, // See [AuditHistoryResponse](./types/audit-history-response)
AuthAuditEvent, // See [AuthAuditEvent](./types/auth-audit-event)
AuthAuditEventStatus, // See [AuthAuditEventStatus](./types/auth-audit-event-status)
AuthAuditEventType, // See [AuthAuditEventType](./types/auth-audit-event-type)

// Error types
NAuthClientError, // See [NAuthClientError](./nauth-client-error)
NAuthError, // See [NAuthError](./types/nauth-error)
NAuthErrorCode, // See [NAuthErrorCode](./types/nauth-error-code)
} from '@nauth-toolkit/client';

See individual type pages in the Types section for full documentation.

Utilities

ExportTypeDescription
Challenge HelpersFunctionsHelper utilities for working with challenges

See Challenge Helpers for complete documentation.

Angular Adapter

import {
NAUTH_CLIENT_CONFIG,
AuthService,
authInterceptor,
AuthInterceptor,
authGuard,
AuthGuard,
NAuthModule,
} from '@nauth-toolkit/client-angular';
ExportTypeDescription
NAUTH_CLIENT_CONFIGInjectionTokenDI token for configuration
AuthServiceServiceAngular wrapper with Observables
authInterceptorHttpInterceptorFnFunctional HTTP interceptor
AuthInterceptorClassClass-based interceptor for NgModule
authGuardCanActivateFnFunctional route guard
AuthGuardClassClass-based guard for NgModule
NAuthModuleNgModuleModule with forRoot() for NgModule apps

Quick Import Examples

Vanilla JavaScript/TypeScript

import { NAuthClient, BrowserStorage } from '@nauth-toolkit/client';
import type { AuthResponse, AuthUser } from '@nauth-toolkit/client';

const client = new NAuthClient({
baseUrl: 'https://api.example.com/auth',
tokenDelivery: 'cookies',
onSessionExpired: () => {},
});

Angular Standalone

import { NAUTH_CLIENT_CONFIG, authInterceptor, AuthService, authGuard } from '@nauth-toolkit/client-angular';
import { provideHttpClient, withInterceptors } from '@angular/common/http';

export const appConfig = {
providers: [
{
provide: NAUTH_CLIENT_CONFIG,
useValue: {
/* config */
},
},
provideHttpClient(withInterceptors([authInterceptor])),
],
};

Angular NgModule

import { NAuthModule, AuthInterceptor, AuthGuard } from '@nauth-toolkit/client-angular';
import { HTTP_INTERCEPTORS } from '@angular/common/http';

@NgModule({
imports: [
NAuthModule.forRoot({
/* config */
}),
],
providers: [{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }],
})
export class AppModule {}