@smartsoft001/auth-domain
Installation
npm i @smartsoft001/auth-domain
Token Factory
$3
Creates a new authentication token based on the provided credentials and grant type.
Param |
Description |
options.request: IAuthTokenRequest |
The authentication request containing credentials and grant type. |
options.httpReq?: Request |
Optional HTTP request object for context. |
options.payloadProvider?: ITokenPayloadProvider |
Optional provider for customizing JWT payload. |
options.validationProvider?: ITokenValidationProvider |
Optional provider for custom validation rules. |
options.userProvider?: ITokenUserProvider |
Optional provider for custom user retrieval. |
Interfaces
$3
Property |
Description |
grant_type |
"password" | "refresh_token" | "fb" | "google" |
username? |
Required for password grant type |
password? |
Required for password grant type |
refresh_token? |
Required for refresh_token grant type |
fb_token? |
Required for fb grant type |
google_token? |
Required for google grant type |
scope? |
Optional scope for the token |
client_id? |
Required for password, fb, and google grant types |
$3
Property |
Description |
access_token |
JWT token for authentication |
refresh_token |
Token for obtaining new access tokens |
expired_in |
Token expiration time in seconds |
token_type |
Always 'bearer' |
username? |
Optional username of authenticated user |
Providers
$3
Method |
Description |
change(basePayload, data) |
Modifies the JWT payload before token creation |
$3
Method |
Description |
check(data) |
Performs custom validation during token creation |
$3
Method |
Description |
get(query, request, httpReq?) |
Custom logic for user retrieval during authentication |
Running unit tests
Run nx test auth-domain to execute the unit tests via Jest.