@ooneex/user 0.0.17 → 1.0.0

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/README.md CHANGED
@@ -1 +1,55 @@
1
1
  # @ooneex/user
2
+
3
+ User identity types and interfaces defining profiles, authentication credentials, roles, and account metadata for user management systems.
4
+
5
+ ![Bun](https://img.shields.io/badge/Bun-Compatible-orange?style=flat-square&logo=bun)
6
+ ![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue?style=flat-square&logo=typescript)
7
+ ![MIT License](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)
8
+
9
+ ## Features
10
+
11
+ ✅ **User Interface** - `IUser` with email, roles, profile fields, two-factor auth, and session/account references
12
+
13
+ ✅ **Session Management** - `ISession` interface with token, refresh token, device info, location, and expiration tracking
14
+
15
+ ✅ **Multi-Provider Accounts** - `IAccount` interface supporting OAuth, email, credentials, and WebAuthn authentication types
16
+
17
+ ✅ **Verification System** - `IVerification` interface for email, phone, password reset, two-factor, and account activation flows
18
+
19
+ ✅ **Profile Update Auditing** - `IUserProfileUpdate` interface tracking field changes, previous/new values, and approval status
20
+
21
+ ✅ **Account Type Enums** - `EAccountType`, `EVerificationType`, and `EProfileUpdateStatus` enums with string literal types
22
+
23
+ ✅ **Zero Runtime** - Pure type definitions and enums with no runtime overhead
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ bun add @ooneex/user
29
+ ```
30
+
31
+ ## License
32
+
33
+ This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
34
+
35
+ ## Contributing
36
+
37
+ Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
38
+
39
+ ### Development Setup
40
+
41
+ 1. Clone the repository
42
+ 2. Install dependencies: `bun install`
43
+ 3. Run tests: `bun run test`
44
+ 4. Build the project: `bun run build`
45
+
46
+ ### Guidelines
47
+
48
+ - Write tests for new features
49
+ - Follow the existing code style
50
+ - Update documentation for API changes
51
+ - Ensure all tests pass before submitting PR
52
+
53
+ ---
54
+
55
+ Made with ❤️ by the Ooneex team
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { IImage } from "@ooneex/image";
2
1
  import { ERole } from "@ooneex/role";
3
- import { IBase } from "@ooneex/types";
2
+ import { LocaleType } from "@ooneex/translation";
4
3
  declare enum EAccountType {
5
4
  OAUTH = "oauth",
6
5
  EMAIL = "email",
@@ -23,14 +22,28 @@ declare enum EProfileUpdateStatus {
23
22
  type AccountType = `${EAccountType}`;
24
23
  type VerificationType = `${EVerificationType}`;
25
24
  type ProfileUpdateStatusType = `${EProfileUpdateStatus}`;
25
+ interface IBase {
26
+ id: string;
27
+ isLocked?: boolean;
28
+ lockedAt?: Date;
29
+ isBlocked?: boolean;
30
+ blockedAt?: Date;
31
+ blockReason?: string;
32
+ isPublic?: boolean;
33
+ createdAt?: Date;
34
+ updatedAt?: Date;
35
+ deletedAt?: Date;
36
+ language?: LocaleType;
37
+ }
26
38
  interface IUser extends IBase {
27
39
  email: string;
28
40
  roles: ERole[];
41
+ externalId?: string;
29
42
  name?: string;
30
43
  lastName?: string;
31
44
  firstName?: string;
32
45
  username?: string;
33
- avatar?: IImage;
46
+ avatar?: string;
34
47
  bio?: string;
35
48
  phone?: string;
36
49
  birthDate?: Date;
@@ -119,40 +132,4 @@ interface IUserProfileUpdate extends IBase {
119
132
  user?: IUser;
120
133
  verification?: IVerification;
121
134
  }
122
- interface IUserFollowed extends IBase {
123
- user?: IUser;
124
- userId?: string;
125
- followedBy?: string;
126
- followedById?: string;
127
- }
128
- interface IUserBlocked extends IBase {
129
- user?: IUser;
130
- userId?: string;
131
- blockedBy?: string;
132
- blockedById?: string;
133
- reason?: string;
134
- }
135
- interface IUserReport extends IBase {
136
- user?: IUser;
137
- userId?: string;
138
- reason: string;
139
- description?: string;
140
- reportedBy?: string;
141
- reportedById?: string;
142
- }
143
- interface IUserViewed extends IBase {
144
- user?: IUser;
145
- userId?: string;
146
- viewedBy?: string;
147
- viewedById?: string;
148
- }
149
- interface IUserStat extends IBase {
150
- user?: IUser;
151
- userId?: string;
152
- followersCount?: number;
153
- followingCount?: number;
154
- blockedCount?: number;
155
- viewsCount?: number;
156
- reportsCount?: number;
157
- }
158
- export { VerificationType, ProfileUpdateStatusType, IVerification, IUserViewed, IUserStat, IUserReport, IUserProfileUpdate, IUserFollowed, IUserBlocked, IUser, ISession, IAccount, EVerificationType, EProfileUpdateStatus, EAccountType, AccountType };
135
+ export { VerificationType, ProfileUpdateStatusType, IVerification, IUserProfileUpdate, IUser, ISession, IAccount, EVerificationType, EProfileUpdateStatus, EAccountType, AccountType };
package/dist/index.js.map CHANGED
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["src/types.ts"],
4
4
  "sourcesContent": [
5
- "import type { IImage } from \"@ooneex/image\";\nimport type { ERole } from \"@ooneex/role\";\nimport type { IBase } from \"@ooneex/types\";\n\nexport enum EAccountType {\n OAUTH = \"oauth\",\n EMAIL = \"email\",\n CREDENTIALS = \"credentials\",\n WEBAUTHN = \"webauthn\",\n}\n\nexport enum EVerificationType {\n EMAIL = \"email\",\n PHONE = \"phone\",\n PASSWORD_RESET = \"password_reset\",\n TWO_FACTOR = \"two_factor\",\n ACCOUNT_ACTIVATION = \"account_activation\",\n}\n\nexport enum EProfileUpdateStatus {\n PENDING = \"pending\",\n COMPLETED = \"completed\",\n FAILED = \"failed\",\n REVERTED = \"reverted\",\n}\n\nexport type AccountType = `${EAccountType}`;\nexport type VerificationType = `${EVerificationType}`;\nexport type ProfileUpdateStatusType = `${EProfileUpdateStatus}`;\n\nexport interface IUser extends IBase {\n email: string;\n roles: ERole[];\n name?: string;\n lastName?: string;\n firstName?: string;\n username?: string;\n avatar?: IImage;\n bio?: string;\n phone?: string;\n birthDate?: Date;\n timezone?: string;\n isEmailVerified?: boolean;\n isPhoneVerified?: boolean;\n lastActiveAt?: Date;\n emailVerifiedAt?: Date;\n phoneVerifiedAt?: Date;\n lastLoginAt?: Date;\n passwordChangedAt?: Date;\n twoFactorEnabled?: boolean;\n twoFactorSecret?: string;\n recoveryTokens?: string[];\n sessions?: ISession[];\n accounts?: IAccount[];\n verifications?: IVerification[];\n}\n\nexport interface ISession extends IBase {\n // Unique authentication token for the session\n token: string;\n // Token used to refresh the main session token when it expires\n refreshToken?: string;\n // Browser user agent string for device/browser identification\n userAgent?: string;\n // IP address from which the session was created\n ipAddress?: string;\n // Type of device (e.g., \"mobile\", \"desktop\", \"tablet\")\n deviceType?: string;\n // User-friendly device name (e.g., \"John's iPhone\", \"MacBook Pro\")\n deviceName?: string;\n // Browser name and version (e.g., \"Chrome 120.0\", \"Safari 17.1\")\n browser?: string;\n // Operating system information (e.g., \"macOS 14.2\", \"Windows 11\")\n operatingSystem?: string;\n // Geographic location where session was created (e.g., \"New York, US\")\n location?: string;\n // Whether the session is currently active and valid\n isActive: boolean;\n // When the session expires and becomes invalid\n expiresAt: Date;\n // Last time this session was used for authentication\n lastAccessAt?: Date;\n // When the session was manually revoked/terminated\n revokedAt?: Date;\n // Reason for session revocation (e.g., \"user_logout\", \"admin_revoked\", \"security_breach\")\n revokedReason?: string;\n user?: IUser;\n}\n\nexport interface IAccount extends IBase {\n // OAuth provider name (e.g., \"google\", \"github\", \"facebook\", \"microsoft\")\n provider?: string;\n // Unique account ID from the external provider\n providerAccountId?: string;\n // Authentication method used for this account\n type: EAccountType;\n // Hashed password for credentials-based accounts\n password?: string;\n // Token for accessing provider APIs on behalf of the user\n accessToken?: string;\n // When the access token expires and needs refresh\n accessTokenExpiresAt?: Date;\n // Token used to obtain new access tokens\n refreshToken?: string;\n // When the refresh token expires\n refreshTokenExpiresAt?: Date;\n // General expiration date for the account connection\n expiresAt?: Date;\n // e.g., \"Bearer\", \"Basic\", \"JWT\" - defines how the access token should be used\n tokenType?: string;\n // OAuth scopes granted (e.g., \"read:user,user:email\")\n scope?: string;\n // OpenID Connect ID token containing user identity claims\n idToken?: string;\n // OAuth session state parameter for security\n sessionState?: string;\n // Email address associated with this provider account\n email?: string;\n // Whether the email is verified by the provider\n emailVerified?: boolean;\n // Display name from the provider profile\n name?: string;\n // Profile picture/avatar from the provider\n picture?: string;\n // Additional profile data from the provider\n profile?: Record<string, unknown>;\n user?: IUser;\n}\n\nexport interface IVerification extends IBase {\n // Email address to be verified (for email verification types)\n email?: string;\n // Phone number to be verified (for phone verification types)\n phone?: string;\n // Secure token used for verification (typically UUID or similar)\n token: string;\n // Type of verification being performed\n type: EVerificationType;\n // Short numeric code sent to user (alternative to token for SMS/email)\n code?: string;\n // Whether this verification has been successfully completed\n isUsed: boolean;\n // When the verification was successfully completed\n usedAt?: Date;\n // When this verification expires and becomes invalid\n expiresAt: Date;\n // Number of verification attempts made so far\n attemptsCount: number;\n // Maximum allowed verification attempts before blocking\n maxAttempts: number;\n // IP address from which verification was requested\n ipAddress?: string;\n // Browser user agent string for security tracking\n userAgent?: string;\n // Additional data specific to the verification type\n metadata?: Record<string, unknown>;\n description?: string;\n user?: IUser;\n}\n\nexport interface IUserProfileUpdate extends IBase {\n // What fields were changed in this update\n changedFields: string[];\n // Previous values before the update (for audit trail)\n previousValues?: Record<string, unknown>;\n // New values after the update\n newValues?: Record<string, unknown>;\n // Reason for the update (e.g., \"profile_completion\", \"user_edit\", \"admin_correction\")\n updateReason?: string;\n // IP address from which the update was made\n ipAddress?: string;\n // Browser user agent string for security tracking\n userAgent?: string;\n // Whether this update requires verification (e.g., email/phone changes)\n requiresVerification?: boolean;\n // Status of the update (e.g., \"pending\", \"completed\", \"failed\", \"reverted\")\n status: EProfileUpdateStatus;\n // When the update was applied/completed\n appliedAt?: Date;\n // Additional metadata specific to the update\n metadata?: Record<string, unknown>;\n description?: string;\n user?: IUser;\n // Reference to verification if update requires it\n verification?: IVerification;\n}\n\nexport interface IUserFollowed extends IBase {\n user?: IUser;\n userId?: string;\n followedBy?: string;\n followedById?: string;\n}\n\nexport interface IUserBlocked extends IBase {\n user?: IUser;\n userId?: string;\n blockedBy?: string;\n blockedById?: string;\n reason?: string;\n}\n\nexport interface IUserReport extends IBase {\n user?: IUser;\n userId?: string;\n reason: string;\n description?: string;\n reportedBy?: string;\n reportedById?: string;\n}\n\nexport interface IUserViewed extends IBase {\n user?: IUser;\n userId?: string;\n viewedBy?: string;\n viewedById?: string;\n}\n\nexport interface IUserStat extends IBase {\n user?: IUser;\n userId?: string;\n followersCount?: number;\n followingCount?: number;\n blockedCount?: number;\n viewsCount?: number;\n reportsCount?: number;\n}\n"
5
+ "import type { ERole } from \"@ooneex/role\";\nimport type { LocaleType } from \"@ooneex/translation\";\n\nexport enum EAccountType {\n OAUTH = \"oauth\",\n EMAIL = \"email\",\n CREDENTIALS = \"credentials\",\n WEBAUTHN = \"webauthn\",\n}\n\nexport enum EVerificationType {\n EMAIL = \"email\",\n PHONE = \"phone\",\n PASSWORD_RESET = \"password_reset\",\n TWO_FACTOR = \"two_factor\",\n ACCOUNT_ACTIVATION = \"account_activation\",\n}\n\nexport enum EProfileUpdateStatus {\n PENDING = \"pending\",\n COMPLETED = \"completed\",\n FAILED = \"failed\",\n REVERTED = \"reverted\",\n}\n\nexport type AccountType = `${EAccountType}`;\nexport type VerificationType = `${EVerificationType}`;\nexport type ProfileUpdateStatusType = `${EProfileUpdateStatus}`;\n\ninterface IBase {\n id: string;\n isLocked?: boolean;\n lockedAt?: Date;\n isBlocked?: boolean;\n blockedAt?: Date;\n blockReason?: string;\n isPublic?: boolean;\n createdAt?: Date;\n updatedAt?: Date;\n deletedAt?: Date;\n language?: LocaleType;\n}\n\nexport interface IUser extends IBase {\n email: string;\n roles: ERole[];\n externalId?: string;\n name?: string;\n lastName?: string;\n firstName?: string;\n username?: string;\n avatar?: string;\n bio?: string;\n phone?: string;\n birthDate?: Date;\n timezone?: string;\n isEmailVerified?: boolean;\n isPhoneVerified?: boolean;\n lastActiveAt?: Date;\n emailVerifiedAt?: Date;\n phoneVerifiedAt?: Date;\n lastLoginAt?: Date;\n passwordChangedAt?: Date;\n twoFactorEnabled?: boolean;\n twoFactorSecret?: string;\n recoveryTokens?: string[];\n sessions?: ISession[];\n accounts?: IAccount[];\n verifications?: IVerification[];\n}\n\nexport interface ISession extends IBase {\n // Unique authentication token for the session\n token: string;\n // Token used to refresh the main session token when it expires\n refreshToken?: string;\n // Browser user agent string for device/browser identification\n userAgent?: string;\n // IP address from which the session was created\n ipAddress?: string;\n // Type of device (e.g., \"mobile\", \"desktop\", \"tablet\")\n deviceType?: string;\n // User-friendly device name (e.g., \"John's iPhone\", \"MacBook Pro\")\n deviceName?: string;\n // Browser name and version (e.g., \"Chrome 120.0\", \"Safari 17.1\")\n browser?: string;\n // Operating system information (e.g., \"macOS 14.2\", \"Windows 11\")\n operatingSystem?: string;\n // Geographic location where session was created (e.g., \"New York, US\")\n location?: string;\n // Whether the session is currently active and valid\n isActive: boolean;\n // When the session expires and becomes invalid\n expiresAt: Date;\n // Last time this session was used for authentication\n lastAccessAt?: Date;\n // When the session was manually revoked/terminated\n revokedAt?: Date;\n // Reason for session revocation (e.g., \"user_logout\", \"admin_revoked\", \"security_breach\")\n revokedReason?: string;\n user?: IUser;\n}\n\nexport interface IAccount extends IBase {\n // OAuth provider name (e.g., \"google\", \"github\", \"facebook\", \"microsoft\")\n provider?: string;\n // Unique account ID from the external provider\n providerAccountId?: string;\n // Authentication method used for this account\n type: EAccountType;\n // Hashed password for credentials-based accounts\n password?: string;\n // Token for accessing provider APIs on behalf of the user\n accessToken?: string;\n // When the access token expires and needs refresh\n accessTokenExpiresAt?: Date;\n // Token used to obtain new access tokens\n refreshToken?: string;\n // When the refresh token expires\n refreshTokenExpiresAt?: Date;\n // General expiration date for the account connection\n expiresAt?: Date;\n // e.g., \"Bearer\", \"Basic\", \"JWT\" - defines how the access token should be used\n tokenType?: string;\n // OAuth scopes granted (e.g., \"read:user,user:email\")\n scope?: string;\n // OpenID Connect ID token containing user identity claims\n idToken?: string;\n // OAuth session state parameter for security\n sessionState?: string;\n // Email address associated with this provider account\n email?: string;\n // Whether the email is verified by the provider\n emailVerified?: boolean;\n // Display name from the provider profile\n name?: string;\n // Profile picture/avatar from the provider\n picture?: string;\n // Additional profile data from the provider\n profile?: Record<string, unknown>;\n user?: IUser;\n}\n\nexport interface IVerification extends IBase {\n // Email address to be verified (for email verification types)\n email?: string;\n // Phone number to be verified (for phone verification types)\n phone?: string;\n // Secure token used for verification (typically UUID or similar)\n token: string;\n // Type of verification being performed\n type: EVerificationType;\n // Short numeric code sent to user (alternative to token for SMS/email)\n code?: string;\n // Whether this verification has been successfully completed\n isUsed: boolean;\n // When the verification was successfully completed\n usedAt?: Date;\n // When this verification expires and becomes invalid\n expiresAt: Date;\n // Number of verification attempts made so far\n attemptsCount: number;\n // Maximum allowed verification attempts before blocking\n maxAttempts: number;\n // IP address from which verification was requested\n ipAddress?: string;\n // Browser user agent string for security tracking\n userAgent?: string;\n // Additional data specific to the verification type\n metadata?: Record<string, unknown>;\n description?: string;\n user?: IUser;\n}\n\nexport interface IUserProfileUpdate extends IBase {\n // What fields were changed in this update\n changedFields: string[];\n // Previous values before the update (for audit trail)\n previousValues?: Record<string, unknown>;\n // New values after the update\n newValues?: Record<string, unknown>;\n // Reason for the update (e.g., \"profile_completion\", \"user_edit\", \"admin_correction\")\n updateReason?: string;\n // IP address from which the update was made\n ipAddress?: string;\n // Browser user agent string for security tracking\n userAgent?: string;\n // Whether this update requires verification (e.g., email/phone changes)\n requiresVerification?: boolean;\n // Status of the update (e.g., \"pending\", \"completed\", \"failed\", \"reverted\")\n status: EProfileUpdateStatus;\n // When the update was applied/completed\n appliedAt?: Date;\n // Additional metadata specific to the update\n metadata?: Record<string, unknown>;\n description?: string;\n user?: IUser;\n // Reference to verification if update requires it\n verification?: IVerification;\n}\n"
6
6
  ],
7
- "mappings": "AAIO,IAAK,GAAL,CAAK,IAAL,CACL,QAAQ,QACR,QAAQ,QACR,cAAc,cACd,WAAW,aAJD,QAOL,IAAK,GAAL,CAAK,IAAL,CACL,QAAQ,QACR,QAAQ,QACR,iBAAiB,iBACjB,aAAa,aACb,qBAAqB,uBALX,QAQL,IAAK,GAAL,CAAK,IAAL,CACL,UAAU,UACV,YAAY,YACZ,SAAS,SACT,WAAW,aAJD",
7
+ "mappings": "AAGO,IAAK,GAAL,CAAK,IAAL,CACL,QAAQ,QACR,QAAQ,QACR,cAAc,cACd,WAAW,aAJD,QAOL,IAAK,GAAL,CAAK,IAAL,CACL,QAAQ,QACR,QAAQ,QACR,iBAAiB,iBACjB,aAAa,aACb,qBAAqB,uBALX,QAQL,IAAK,GAAL,CAAK,IAAL,CACL,UAAU,UACV,YAAY,YACZ,SAAS,SACT,WAAW,aAJD",
8
8
  "debugId": "F14F79B7E6C44C2164756E2164756E21",
9
9
  "names": []
10
10
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ooneex/user",
3
- "description": "User entity types and interfaces for user profiles, authentication data, and role-based identity management",
4
- "version": "0.0.17",
3
+ "description": "User identity types and interfaces defining profiles, authentication credentials, roles, and account metadata for user management systems",
4
+ "version": "1.0.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -29,9 +29,8 @@
29
29
  },
30
30
  "dependencies": {},
31
31
  "devDependencies": {
32
- "@ooneex/image": "0.0.16",
33
- "@ooneex/role": "0.0.16",
34
- "@ooneex/types": "0.0.16"
32
+ "@ooneex/translation": "0.0.18",
33
+ "@ooneex/role": "0.0.18"
35
34
  },
36
35
  "keywords": [
37
36
  "account",