@plyaz/types 1.27.6 → 1.27.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/auth-events.d.ts +107 -0
- package/dist/auth/index.cjs +69 -0
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.js +67 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/types.d.ts +38 -0
- package/dist/index.cjs +69 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +67 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/auth/types.d.ts
CHANGED
|
@@ -737,3 +737,41 @@ export interface AuthErrorOptions {
|
|
|
737
737
|
* Type for a single error definition object.
|
|
738
738
|
*/
|
|
739
739
|
export type AuthErrorDefinition = (typeof AUTH_ERROR_DEFINITIONS)[AuthErrorCodeValue];
|
|
740
|
+
/**
|
|
741
|
+
* @fileoverview Authentication error codes for @plyaz/auth
|
|
742
|
+
* @module @plyaz/auth/constants/auth-error-codes
|
|
743
|
+
*
|
|
744
|
+
* @description
|
|
745
|
+
* Standardized error codes for authentication system failures.
|
|
746
|
+
* These codes provide consistent error identification across the entire
|
|
747
|
+
* auth system, enabling proper error handling, logging, and user feedback.
|
|
748
|
+
* Used by error classes, services, and frontend components.
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* ```typescript
|
|
752
|
+
* import { AUTH_ERROR_CODES } from '@plyaz/auth';
|
|
753
|
+
*
|
|
754
|
+
* throw new InvalidCredentialsError(AUTH_ERROR_CODES.INVALID_CREDENTIALS);
|
|
755
|
+
*
|
|
756
|
+
* if (error.code === AUTH_ERROR_CODES.TOKEN_EXPIRED) {
|
|
757
|
+
* // Handle token expiration
|
|
758
|
+
* }
|
|
759
|
+
* ```
|
|
760
|
+
*/
|
|
761
|
+
/**
|
|
762
|
+
* Authentication error codes
|
|
763
|
+
* Standardized error identifiers for consistent error handling
|
|
764
|
+
*/
|
|
765
|
+
/**
|
|
766
|
+
* Type for authentication error codes
|
|
767
|
+
*/
|
|
768
|
+
export type AuthErrorCode = typeof AUTH_ERROR_CODES[keyof typeof AUTH_ERROR_CODES];
|
|
769
|
+
/**
|
|
770
|
+
* Error code to HTTP status mapping
|
|
771
|
+
* Maps error codes to appropriate HTTP status codes
|
|
772
|
+
*/
|
|
773
|
+
export declare const ERROR_CODE_TO_HTTP_STATUS: Record<AuthErrorCode, number>;
|
|
774
|
+
/**
|
|
775
|
+
* Error code descriptions for logging and debugging
|
|
776
|
+
*/
|
|
777
|
+
export declare const ERROR_CODE_DESCRIPTIONS: Record<AuthErrorCode, string>;
|
package/dist/index.cjs
CHANGED
|
@@ -6016,6 +6016,72 @@ var AUTH_ERROR_CODES = {
|
|
|
6016
6016
|
ACCOUNT_LOCKED: "AUTH_ACCOUNT_LOCKED",
|
|
6017
6017
|
ACCOUNT_SUSPENDED: "AUTH_ACCOUNT_SUSPENDED"
|
|
6018
6018
|
};
|
|
6019
|
+
var ERROR_CODE_TO_HTTP_STATUS = {
|
|
6020
|
+
[AUTH_ERROR_CODES.INVALID_CREDENTIALS]: 401,
|
|
6021
|
+
[AUTH_ERROR_CODES.TOKEN_EXPIRED]: 401,
|
|
6022
|
+
[AUTH_ERROR_CODES.TOKEN_INVALID]: 401,
|
|
6023
|
+
[AUTH_ERROR_CODES.TOKEN_REVOKED]: 401,
|
|
6024
|
+
[AUTH_ERROR_CODES.SESSION_EXPIRED]: 401,
|
|
6025
|
+
[AUTH_ERROR_CODES.MFA_REQUIRED]: 401,
|
|
6026
|
+
[AUTH_ERROR_CODES.MFA_INVALID]: 401,
|
|
6027
|
+
[AUTH_ERROR_CODES.INSUFFICIENT_PERMISSIONS]: 403,
|
|
6028
|
+
[AUTH_ERROR_CODES.ROLE_REQUIRED]: 403,
|
|
6029
|
+
[AUTH_ERROR_CODES.WALLET_SIGNATURE_INVALID]: 401,
|
|
6030
|
+
[AUTH_ERROR_CODES.NONCE_EXPIRED]: 401,
|
|
6031
|
+
[AUTH_ERROR_CODES.NONCE_ALREADY_USED]: 401,
|
|
6032
|
+
[AUTH_ERROR_CODES.ACCOUNT_LOCKED]: 423,
|
|
6033
|
+
[AUTH_ERROR_CODES.ACCOUNT_SUSPENDED]: 423
|
|
6034
|
+
};
|
|
6035
|
+
var ERROR_CODE_DESCRIPTIONS = {
|
|
6036
|
+
[AUTH_ERROR_CODES.INVALID_CREDENTIALS]: "errors.auth.invalid_credentials",
|
|
6037
|
+
[AUTH_ERROR_CODES.TOKEN_EXPIRED]: "errors.auth.token_expired",
|
|
6038
|
+
[AUTH_ERROR_CODES.TOKEN_INVALID]: "errors.auth.token_invalid",
|
|
6039
|
+
[AUTH_ERROR_CODES.TOKEN_REVOKED]: "errors.auth.token_revoked",
|
|
6040
|
+
[AUTH_ERROR_CODES.SESSION_EXPIRED]: "errors.auth.session_expired",
|
|
6041
|
+
[AUTH_ERROR_CODES.MFA_REQUIRED]: "errors.auth.mfa_required",
|
|
6042
|
+
[AUTH_ERROR_CODES.MFA_INVALID]: "errors.auth.mfa_invalid",
|
|
6043
|
+
[AUTH_ERROR_CODES.INSUFFICIENT_PERMISSIONS]: "errors.auth.insufficient_permissions",
|
|
6044
|
+
[AUTH_ERROR_CODES.ROLE_REQUIRED]: "errors.auth.role_required",
|
|
6045
|
+
[AUTH_ERROR_CODES.WALLET_SIGNATURE_INVALID]: "errors.auth.wallet_signature_invalid",
|
|
6046
|
+
[AUTH_ERROR_CODES.NONCE_EXPIRED]: "errors.auth.nonce_expired",
|
|
6047
|
+
[AUTH_ERROR_CODES.NONCE_ALREADY_USED]: "errors.auth.nonce_already_used",
|
|
6048
|
+
[AUTH_ERROR_CODES.ACCOUNT_LOCKED]: "errors.auth.account_locked",
|
|
6049
|
+
[AUTH_ERROR_CODES.ACCOUNT_SUSPENDED]: "errors.auth.account_suspended"
|
|
6050
|
+
};
|
|
6051
|
+
|
|
6052
|
+
// src/auth/auth-events.ts
|
|
6053
|
+
var AUTH_EVENTS = {
|
|
6054
|
+
/** User successfully authenticated */
|
|
6055
|
+
USER_AUTHENTICATED: "auth.user.authenticated",
|
|
6056
|
+
/** User signed up (new account created) */
|
|
6057
|
+
USER_SIGNED_UP: "auth.user.signed_up",
|
|
6058
|
+
/** User logged out */
|
|
6059
|
+
USER_LOGGED_OUT: "auth.user.logged_out",
|
|
6060
|
+
/** Authentication attempt failed */
|
|
6061
|
+
AUTHENTICATION_FAILED: "auth.authentication.failed",
|
|
6062
|
+
/** Session created */
|
|
6063
|
+
SESSION_CREATED: "auth.session.created",
|
|
6064
|
+
/** Session expired */
|
|
6065
|
+
SESSION_EXPIRED: "auth.session.expired",
|
|
6066
|
+
/** Session refreshed */
|
|
6067
|
+
SESSION_REFRESHED: "auth.session.refreshed",
|
|
6068
|
+
/** Session invalidated (logout) */
|
|
6069
|
+
SESSION_INVALIDATED: "auth.session.invalidated",
|
|
6070
|
+
/** Account linked to user */
|
|
6071
|
+
ACCOUNT_LINKED: "auth.account.linked",
|
|
6072
|
+
/** Account unlinked from user */
|
|
6073
|
+
ACCOUNT_UNLINKED: "auth.account.unlinked",
|
|
6074
|
+
/** Role assigned to user */
|
|
6075
|
+
ROLE_ASSIGNED: "auth.rbac.role_assigned",
|
|
6076
|
+
/** Role revoked from user */
|
|
6077
|
+
ROLE_REVOKED: "auth.rbac.role_revoked",
|
|
6078
|
+
/** Suspicious login attempt detected */
|
|
6079
|
+
SUSPICIOUS_LOGIN_ATTEMPT: "auth.security.suspicious_login",
|
|
6080
|
+
/** Password changed */
|
|
6081
|
+
PASSWORD_CHANGED: "auth.password.changed",
|
|
6082
|
+
/** Password reset requested */
|
|
6083
|
+
PASSWORD_RESET_REQUESTED: "auth.password.reset_requested"
|
|
6084
|
+
};
|
|
6019
6085
|
|
|
6020
6086
|
// src/core/modules.ts
|
|
6021
6087
|
var BACKEND_RUNTIMES = [
|
|
@@ -9050,6 +9116,7 @@ exports.ATHLETE_PROFILE_ERRORS = ATHLETE_PROFILE_ERRORS;
|
|
|
9050
9116
|
exports.AUDIT_OPERATION = AUDIT_OPERATION;
|
|
9051
9117
|
exports.AUTH_ERROR_CODES = AUTH_ERROR_CODES;
|
|
9052
9118
|
exports.AUTH_ERROR_DEFINITIONS = AUTH_ERROR_DEFINITIONS;
|
|
9119
|
+
exports.AUTH_EVENTS = AUTH_EVENTS;
|
|
9053
9120
|
exports.AUTH_PROVIDER = AUTH_PROVIDER;
|
|
9054
9121
|
exports.AUTH_PROVIDER_TYPE = AUTH_PROVIDER_TYPE;
|
|
9055
9122
|
exports.ApiEventAction = ApiEventAction;
|
|
@@ -9099,6 +9166,8 @@ exports.ENTITY_TYPE = ENTITY_TYPE;
|
|
|
9099
9166
|
exports.ERROR_CATEGORY = ERROR_CATEGORY;
|
|
9100
9167
|
exports.ERROR_CATEGORY_TO_EMITTER_KEY = ERROR_CATEGORY_TO_EMITTER_KEY;
|
|
9101
9168
|
exports.ERROR_CODES = ERROR_CODES;
|
|
9169
|
+
exports.ERROR_CODE_DESCRIPTIONS = ERROR_CODE_DESCRIPTIONS;
|
|
9170
|
+
exports.ERROR_CODE_TO_HTTP_STATUS = ERROR_CODE_TO_HTTP_STATUS;
|
|
9102
9171
|
exports.ERROR_DEFINITIONS = ERROR_DEFINITIONS;
|
|
9103
9172
|
exports.ERROR_EVENTS = ERROR_EVENTS;
|
|
9104
9173
|
exports.ERROR_EXCEPTIONS_NAMESPACES = ERROR_EXCEPTIONS_NAMESPACES;
|