CsrfService

Double-submit CSRF token helper. Generates cryptographically secure tokens via WebCryptoService and persists them in the configured storage. Pair with withCsrfHeader() functional interceptor for automatic header injection.

TypeScriptexample.ts
import { CsrfService } from '@angular-helpers/security'

# Methods

MethodSignatureReturnsDescription
isSupportedisSupported(): booleanbooleanPublic method isSupported.
generateTokengenerateToken(): stringstringGenerates a new CSRF token as a 32-byte hex string. The token is NOT persisted automatically — call to save it.
storeTokenstoreToken(token: string): voidvoidPersists the token to the configured storage.
getTokengetToken(): string | nullstring | nullReturns the stored token, or `null` when unset or outside a browser environment.
clearTokenclearToken(): voidvoidRemoves the stored token.
LCP N/A
CLS N/A
INP N/A