@unchainedshop/core-users 5.0.0-alpha.5 → 5.0.0-alpha.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/README.md +9 -130
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -13,143 +13,22 @@ npm install @unchainedshop/core-users
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
import { configureUsersModule } from '@unchainedshop/core-users';
|
|
18
|
-
|
|
19
|
-
const usersModule = await configureUsersModule({ db });
|
|
20
|
-
|
|
21
|
-
// Find users
|
|
22
|
-
const users = await usersModule.findUsers({
|
|
23
|
-
includeGuests: false,
|
|
24
|
-
limit: 50,
|
|
25
|
-
});
|
|
16
|
+
The platform initializes this module as `platform.unchainedAPI.modules.users`.
|
|
26
17
|
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
password: 'securePassword',
|
|
31
|
-
});
|
|
18
|
+
```typescript
|
|
19
|
+
const { users } = platform.unchainedAPI.modules;
|
|
20
|
+
const customers = await users.findUsers({ includeGuests: false, limit: 50 });
|
|
32
21
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
displayName: 'John Doe',
|
|
22
|
+
await users.updateProfile('user-123', {
|
|
23
|
+
profile: { displayName: 'Jane Doe' },
|
|
36
24
|
});
|
|
37
25
|
```
|
|
38
26
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Module Configuration
|
|
42
|
-
|
|
43
|
-
| Export | Description |
|
|
44
|
-
|--------|-------------|
|
|
45
|
-
| `configureUsersModule` | Configure and return the users module |
|
|
46
|
-
| `configureUsersWebAuthnModule` | Configure WebAuthn submodule |
|
|
47
|
-
|
|
48
|
-
### Queries
|
|
49
|
-
|
|
50
|
-
| Method | Description |
|
|
51
|
-
|--------|-------------|
|
|
52
|
-
| `findUser` | Find user by ID, email, or username |
|
|
53
|
-
| `findUsers` | Find users with filtering, sorting, and pagination |
|
|
54
|
-
| `count` | Count users matching query |
|
|
55
|
-
| `userExists` | Check if a user exists |
|
|
56
|
-
|
|
57
|
-
### Mutations
|
|
58
|
-
|
|
59
|
-
| Method | Description |
|
|
60
|
-
|--------|-------------|
|
|
61
|
-
| `createUser` | Create a new user account |
|
|
62
|
-
| `updateUser` | Update user data |
|
|
63
|
-
| `updateProfile` | Update user profile |
|
|
64
|
-
| `updateRoles` | Update user roles |
|
|
65
|
-
| `updateTags` | Update user tags |
|
|
66
|
-
| `updateAvatar` | Set user avatar |
|
|
67
|
-
| `updateBillingAddress` | Update billing address |
|
|
68
|
-
| `updatePassword` | Change user password |
|
|
69
|
-
| `updateUsername` | Change username |
|
|
70
|
-
| `delete` | Soft delete a user |
|
|
71
|
-
| `replaceUserId` | Migrate data between users |
|
|
72
|
-
|
|
73
|
-
### Authentication
|
|
74
|
-
|
|
75
|
-
| Method | Description |
|
|
76
|
-
|--------|-------------|
|
|
77
|
-
| `verifyPassword` | Verify password against stored hash |
|
|
78
|
-
| `hashPassword` | Hash a password for storage |
|
|
79
|
-
| `addEmail` | Add email address to user |
|
|
80
|
-
| `removeEmail` | Remove email address |
|
|
81
|
-
| `verifyEmail` | Mark email as verified |
|
|
82
|
-
| `updateHeartbeat` | Update last activity timestamp |
|
|
83
|
-
| `updateLastLogin` | Record login event |
|
|
84
|
-
|
|
85
|
-
### WebAuthn Submodule
|
|
86
|
-
|
|
87
|
-
| Method | Description |
|
|
88
|
-
|--------|-------------|
|
|
89
|
-
| `webAuthn.findCredentials` | Find WebAuthn credentials for user |
|
|
90
|
-
| `webAuthn.createCredential` | Register new WebAuthn credential |
|
|
91
|
-
| `webAuthn.removeCredential` | Remove WebAuthn credential |
|
|
92
|
-
|
|
93
|
-
### Settings
|
|
94
|
-
|
|
95
|
-
| Export | Description |
|
|
96
|
-
|--------|-------------|
|
|
97
|
-
| `userSettings` | Access user module settings |
|
|
98
|
-
| `UserAccountAction` | Account action types enum |
|
|
99
|
-
|
|
100
|
-
### Types
|
|
101
|
-
|
|
102
|
-
| Export | Description |
|
|
103
|
-
|--------|-------------|
|
|
104
|
-
| `User` | User document type |
|
|
105
|
-
| `UserQuery` | Query parameters type |
|
|
106
|
-
| `UserProfile` | User profile type |
|
|
107
|
-
| `Email` | Email address type |
|
|
108
|
-
| `UsersModule` | Module interface type |
|
|
109
|
-
| `UserSettingsOptions` | Configuration options type |
|
|
110
|
-
|
|
111
|
-
## Events
|
|
112
|
-
|
|
113
|
-
| Event | Description |
|
|
114
|
-
|-------|-------------|
|
|
115
|
-
| `USER_CREATE` | User created |
|
|
116
|
-
| `USER_UPDATE` | User updated |
|
|
117
|
-
| `USER_REMOVE` | User deleted |
|
|
118
|
-
| `USER_UPDATE_PROFILE` | Profile updated |
|
|
119
|
-
| `USER_UPDATE_PASSWORD` | Password changed |
|
|
120
|
-
| `USER_UPDATE_ROLES` | Roles changed |
|
|
121
|
-
| `USER_ACCOUNT_ACTION` | Account action triggered |
|
|
122
|
-
|
|
123
|
-
## Security
|
|
124
|
-
|
|
125
|
-
This module implements security best practices for user authentication and data protection.
|
|
126
|
-
|
|
127
|
-
### Password Security
|
|
128
|
-
|
|
129
|
-
- **Algorithm**: PBKDF2 with SHA-512
|
|
130
|
-
- **Iterations**: 300,000 (exceeds OWASP recommendation)
|
|
131
|
-
- **Salt**: 16 bytes, cryptographically random per password
|
|
132
|
-
- **Key Length**: 256 bytes
|
|
133
|
-
- **FIPS 140-3**: Compatible when running on FIPS-enabled Node.js
|
|
134
|
-
|
|
135
|
-
### Token Security
|
|
136
|
-
|
|
137
|
-
- **Generation**: `crypto.randomUUID()` (CSPRNG-based)
|
|
138
|
-
- **Storage**: SHA-256 hashed before database storage
|
|
139
|
-
- **Expiration**: Time-limited (configurable, default 1 hour)
|
|
140
|
-
- **Single-use**: Tokens invalidated after verification
|
|
141
|
-
|
|
142
|
-
### WebAuthn/FIDO2
|
|
143
|
-
|
|
144
|
-
Full support for passwordless authentication via hardware security keys and platform authenticators, providing phishing-resistant authentication.
|
|
145
|
-
|
|
146
|
-
### Data Protection
|
|
27
|
+
`updateProfile` accepts an object containing `profile` and optional `meta`. Account creation uses `createUser`; account deletion uses `markDeleted` or `deletePermanently`. Authentication flows and permissions are coordinated by the API layer.
|
|
147
28
|
|
|
148
|
-
|
|
149
|
-
- Soft delete preserves audit trail while removing PII
|
|
150
|
-
- Email addresses and profile data access-controlled via RBAC
|
|
29
|
+
See the [module settings](https://docs.unchained.shop/platform-configuration/modules/users), [authentication guide](https://docs.unchained.shop/concepts/authentication), [public exports](src/users-index.ts), and [module implementation](src/module/configureUsersModule.ts).
|
|
151
30
|
|
|
152
|
-
|
|
31
|
+
For security reporting and the implementation's security properties, see [SECURITY.md](../../SECURITY.md).
|
|
153
32
|
|
|
154
33
|
## License
|
|
155
34
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-users",
|
|
3
3
|
"description": "User management module for the Unchained Engine with authentication support",
|
|
4
|
-
"version": "5.0.0-alpha.
|
|
4
|
+
"version": "5.0.0-alpha.7",
|
|
5
5
|
"main": "lib/users-index.js",
|
|
6
6
|
"types": "lib/users-index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@passwordless-id/webauthn": "^2.3.1",
|
|
39
|
-
"@unchainedshop/events": "^5.0.0-alpha.
|
|
40
|
-
"@unchainedshop/logger": "^5.0.0-alpha.
|
|
41
|
-
"@unchainedshop/mongodb": "^5.0.0-alpha.
|
|
42
|
-
"@unchainedshop/utils": "^5.0.0-alpha.
|
|
39
|
+
"@unchainedshop/events": "^5.0.0-alpha.7",
|
|
40
|
+
"@unchainedshop/logger": "^5.0.0-alpha.7",
|
|
41
|
+
"@unchainedshop/mongodb": "^5.0.0-alpha.7",
|
|
42
|
+
"@unchainedshop/utils": "^5.0.0-alpha.7",
|
|
43
43
|
"bcryptjs": "^3.0.2"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|