
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
cca-auth-module
Advanced tools
This module provides endpoints and methods for user authentication, including login, logout, registration, and token refresh operations. It also includes a helper function to verify tokens.
Note: This module expects proper request payloads and uses DTOs (
LoginDTO
andRegisterDTO
) to enforce data structure. Custom error handling is assumed to be in place.
POST /auth/login
{
"email": "user@example.com",
"password": "yourPassword"
}
Status: 200 OK
{
"success": true,
"message": "Login successful",
"data": {
"accessToken": "string",
"userId": "string",
"expiresAt": "2025-08-06T12:00:00.000Z",
"auth": {
"hasAccessToken": true,
"enable": false,
"status": "BASIC_AUTH",
"verified": false
}
},
"meta": {
"timestamp": "2025-08-06T11:59:59.999Z"
}
}
POST /auth/admin-login
{
"email": "admin@example.com",
"password": "adminPassword",
"adminPassword": "superSecretAdminPassword"
}
Status: 201 Created
{
"success": true,
"message": "Admin login successful",
"data": {
"message": "Admin authenticated",
"auth": {
"hasAccessToken": true,
"enable": false,
"status": "BASIC_AUTH",
"verified": false
}
}
}
POST /auth/logout
{
"id": "userId"
}
Status: 200 OK
{
"success": true,
"message": "Logout successful",
"data": {
"auth": {
"hasAccessToken": false,
"enable": false,
"status": "LOGGED_OUT",
"verified": false
}
}
}
POST /auth/register
{
"email": "newuser@example.com",
"name": "New User",
"password": "userPassword",
"role": "user",
"adminPassword": "optionalAdminPassword"
}
Status: 200 OK
{
"success": true,
"message": "Registration successful",
"data": {
"auth": {
"hasAccessToken": false,
"enable": false,
"status": "REGISTERED",
"verified": false
}
},
"meta": {
"status": true
}
}
POST /auth/refresh-token
{
"refreshToken": "yourRefreshToken"
}
Status: 200 OK
{
"success": true,
"message": "Token refreshed successfully",
"data": {
"accessToken": "newAccessToken",
"refreshToken": "newRefreshToken",
"auth": {
"hasAccessToken": true,
"enable": false,
"status": "BASIC_AUTH",
"verified": false
}
}
}
POST /auth/2fa/setup
Authorization: Bearer <accessToken>
None
Status: 200 OK
{
"success": true,
"message": "2FA setup successful",
"data": {
"qrCode": "data:image/png;base64,...",
"auth": {
"hasAccessToken": true,
"enable": false,
"status": "NEEDS_SETUP"
}
},
"meta": {
"nextStep": "Scan the QR code and enter your first code to verify",
"redirectTo": "/2fa-enable"
}
}
POST /auth/2fa/enable
Authorization: Bearer <accessToken>
{
"userId": "userId",
"token": "2faToken"
}
Status: 200 OK
{
"success": true,
"message": "2FA enabled successfully",
"data": {
"isEnabled": true,
"enabledAt": "2025-08-06T12:00:00.000Z",
"auth": {
"hasAccessToken": true,
"enable": true,
"status": "PENDING_VERIFICATION"
}
},
"meta": {
"nextStep": "Proceed to verify with a valid 2FA token",
"redirectTo": "/verify-2fa"
}
}
POST /auth/2fa/verify
{
"userId": "userId",
"token": "2faVerificationToken"
}
Status: 200 OK
{
"success": true,
"message": "2FA verification successful",
"data": {
"token": "accessToken",
"refreshToken": "refreshToken",
"user": {
"id": "userId",
"email": "user@example.com",
"name": "User Name",
"role": "user"
},
"auth": {
"hasAccessToken": true,
"enable": true,
"status": "FULL_AUTH",
"verified": true
}
},
"meta": {
"recommendation": "You're fully authenticated",
"redirectTo": "/"
}
}
POST /auth/2fa/disable
Authorization: Bearer <accessToken>
{
"token": "current2faToken"
}
Status: 200 OK
{
"success": true,
"message": "2FA disabled successfully",
"data": {
"disabledAt": "2025-08-06T12:00:00.000Z",
"auth": {
"hasAccessToken": true,
"enable": false,
"status": "BASIC_AUTH",
"verified": false
}
},
"meta": {
"securityNote": "Account now relies only on password. Re-enable 2FA for better security.",
"redirectTo": "/login"
}
}
{
"success": false,
"error": "Error message"
}
This module is released under the MIT License.
This documentation provides an overview of the available endpoints and helper methods for authentication. For further details on business logic and DTO structures, please refer to the inline comments and source code within the module.
FAQs
A TypeScript project using pnpm as the package manager.
The npm package cca-auth-module receives a total of 82 weekly downloads. As such, cca-auth-module popularity was classified as not popular.
We found that cca-auth-module demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.