@unchainedshop/core-users 4.3.4 → 4.4.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 +124 -2
- package/lib/db/UsersCollection.d.ts +2 -3
- package/lib/db/UsersCollection.js +0 -1
- package/lib/db/WebAuthnCredentialsCreationRequestsCollection.d.ts +1 -2
- package/lib/db/WebAuthnCredentialsCreationRequestsCollection.js +0 -1
- package/lib/module/configureUsersModule.d.ts +4 -5
- package/lib/module/configureUsersModule.js +4 -15
- package/lib/module/configureUsersWebAuthnModule.d.ts +1 -2
- package/lib/module/configureUsersWebAuthnModule.js +2 -8
- package/lib/module/pbkdf2.d.ts +0 -1
- package/lib/module/pbkdf2.js +3 -7
- package/lib/users-index.d.ts +5 -6
- package/lib/users-index.js +5 -6
- package/lib/users-settings.d.ts +11 -11
- package/lib/users-settings.js +7 -10
- package/package.json +14 -13
- package/lib/db/UsersCollection.d.ts.map +0 -1
- package/lib/db/UsersCollection.js.map +0 -1
- package/lib/db/WebAuthnCredentialsCreationRequestsCollection.d.ts.map +0 -1
- package/lib/db/WebAuthnCredentialsCreationRequestsCollection.js.map +0 -1
- package/lib/module/addMigrations.d.ts +0 -3
- package/lib/module/addMigrations.d.ts.map +0 -1
- package/lib/module/addMigrations.js +0 -57
- package/lib/module/addMigrations.js.map +0 -1
- package/lib/module/configureUsersModule.d.ts.map +0 -1
- package/lib/module/configureUsersModule.js.map +0 -1
- package/lib/module/configureUsersWebAuthnModule.d.ts.map +0 -1
- package/lib/module/configureUsersWebAuthnModule.js.map +0 -1
- package/lib/module/pbkdf2.d.ts.map +0 -1
- package/lib/module/pbkdf2.js.map +0 -1
- package/lib/services/getUserCountryService.d.ts +0 -3
- package/lib/services/getUserCountryService.d.ts.map +0 -1
- package/lib/services/getUserCountryService.js +0 -7
- package/lib/services/getUserCountryService.js.map +0 -1
- package/lib/services/getUserLanguageService.d.ts +0 -3
- package/lib/services/getUserLanguageService.d.ts.map +0 -1
- package/lib/services/getUserLanguageService.js +0 -7
- package/lib/services/getUserLanguageService.js.map +0 -1
- package/lib/services/updateUserAvatarAfterUploadService.d.ts +0 -3
- package/lib/services/updateUserAvatarAfterUploadService.d.ts.map +0 -1
- package/lib/services/updateUserAvatarAfterUploadService.js +0 -24
- package/lib/services/updateUserAvatarAfterUploadService.js.map +0 -1
- package/lib/services/userServices.d.ts +0 -3
- package/lib/services/userServices.d.ts.map +0 -1
- package/lib/services/userServices.js +0 -9
- package/lib/services/userServices.js.map +0 -1
- package/lib/users-index.d.ts.map +0 -1
- package/lib/users-index.js.map +0 -1
- package/lib/users-settings.d.ts.map +0 -1
- package/lib/users-settings.js.map +0 -1
- package/src/db/UsersCollection.ts +0 -174
- package/src/db/WebAuthnCredentialsCreationRequestsCollection.ts +0 -26
- package/src/module/buildFindSelector.test.ts +0 -34
- package/src/module/configureUsersModule.ts +0 -857
- package/src/module/configureUsersWebAuthnModule.ts +0 -234
- package/src/module/pbkdf2.ts +0 -46
- package/src/module/removeConfidentialServiceHashes.test.ts +0 -12
- package/src/users-index.ts +0 -5
- package/src/users-settings.ts +0 -99
- package/tests/mock/user-mock.ts +0 -72
- package/tsconfig.json +0 -10
package/README.md
CHANGED
|
@@ -1,3 +1,125 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://npmjs.com/package/@unchainedshop/core-users)
|
|
2
|
+
[](https://opensource.org/licenses/EUPL-1.2)
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
# @unchainedshop/core-users
|
|
5
|
+
|
|
6
|
+
User management module for the Unchained Engine. Handles user accounts, authentication, profiles, and WebAuthn support.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @unchainedshop/core-users
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
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
|
+
});
|
|
26
|
+
|
|
27
|
+
// Create a user
|
|
28
|
+
const userId = await usersModule.createUser({
|
|
29
|
+
email: 'user@example.com',
|
|
30
|
+
password: 'securePassword',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Update profile
|
|
34
|
+
await usersModule.updateProfile(userId, {
|
|
35
|
+
displayName: 'John Doe',
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## API Overview
|
|
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
|
+
## License
|
|
124
|
+
|
|
125
|
+
EUPL-1.2
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TimestampFields, Address, Contact, mongodb } from '@unchainedshop/mongodb';
|
|
2
|
-
import { DateFilterInput } from '@unchainedshop/utils';
|
|
1
|
+
import { type TimestampFields, type Address, type Contact, type mongodb } from '@unchainedshop/mongodb';
|
|
2
|
+
import type { DateFilterInput } from '@unchainedshop/utils';
|
|
3
3
|
export interface UserProfile {
|
|
4
4
|
displayName?: string;
|
|
5
5
|
birthday?: Date;
|
|
@@ -54,4 +54,3 @@ export type UserQuery = mongodb.Filter<User> & {
|
|
|
54
54
|
lastLogin?: DateFilterInput;
|
|
55
55
|
};
|
|
56
56
|
export declare const UsersCollection: (db: mongodb.Db) => Promise<mongodb.Collection<User>>;
|
|
57
|
-
//# sourceMappingURL=UsersCollection.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mongodb } from '@unchainedshop/mongodb';
|
|
1
|
+
import { type mongodb } from '@unchainedshop/mongodb';
|
|
2
2
|
export interface WebAuthnCredentialsCreationRequest {
|
|
3
3
|
challenge: string;
|
|
4
4
|
username: string;
|
|
@@ -10,4 +10,3 @@ type Collection = WebAuthnCredentialsCreationRequest & {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const WebAuthnCredentialsCreationRequestsCollection: (db: mongodb.Db) => Promise<mongodb.Collection<Collection>>;
|
|
12
12
|
export {};
|
|
13
|
-
//# sourceMappingURL=WebAuthnCredentialsCreationRequestsCollection.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ModuleInput, Address, Contact, mongodb } from '@unchainedshop/mongodb';
|
|
2
|
-
import { User, UserQuery, Email, UserLastLogin, UserProfile } from '../db/UsersCollection.
|
|
3
|
-
import { SortOption } from '@unchainedshop/utils';
|
|
4
|
-
import { UserRegistrationData, UserSettingsOptions } from '../users-settings.
|
|
1
|
+
import { type ModuleInput, type Address, type Contact, type mongodb } from '@unchainedshop/mongodb';
|
|
2
|
+
import { type User, type UserQuery, type Email, type UserLastLogin, type UserProfile } from '../db/UsersCollection.ts';
|
|
3
|
+
import { type SortOption } from '@unchainedshop/utils';
|
|
4
|
+
import { type UserRegistrationData, type UserSettingsOptions } from '../users-settings.ts';
|
|
5
5
|
export declare const removeConfidentialServiceHashes: (rawUser: User) => User;
|
|
6
6
|
export declare const buildFindSelector: ({ includeGuests, includeDeleted, queryString, emailVerified, lastLogin, tags, ...rest }: UserQuery) => mongodb.Filter<User>;
|
|
7
7
|
export declare const configureUsersModule: (moduleInput: ModuleInput<UserSettingsOptions>) => Promise<{
|
|
@@ -99,4 +99,3 @@ export declare const configureUsersModule: (moduleInput: ModuleInput<UserSetting
|
|
|
99
99
|
existingTags: () => Promise<string[]>;
|
|
100
100
|
}>;
|
|
101
101
|
export type UsersModule = Awaited<ReturnType<typeof configureUsersModule>>;
|
|
102
|
-
//# sourceMappingURL=configureUsersModule.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as bcrypt from 'bcryptjs';
|
|
2
2
|
import { generateDbFilterById, buildSortOptions, generateDbObjectId, insensitiveTrimmedRegexOperator, assertDocumentDBCompatMode, } from '@unchainedshop/mongodb';
|
|
3
|
-
import { UsersCollection, } from
|
|
3
|
+
import { UsersCollection, } from "../db/UsersCollection.js";
|
|
4
4
|
import { emit, registerEvents } from '@unchainedshop/events';
|
|
5
5
|
import { systemLocale, SortDirection, sha256 } from '@unchainedshop/utils';
|
|
6
|
-
import { UserAccountAction, userSettings, } from
|
|
7
|
-
import { configureUsersWebAuthnModule } from
|
|
8
|
-
import * as pbkdf2 from
|
|
6
|
+
import { UserAccountAction, userSettings, } from "../users-settings.js";
|
|
7
|
+
import { configureUsersWebAuthnModule } from "./configureUsersWebAuthnModule.js";
|
|
8
|
+
import * as pbkdf2 from "./pbkdf2.js";
|
|
9
9
|
const USER_EVENTS = [
|
|
10
10
|
'USER_ACCOUNT_ACTION',
|
|
11
11
|
'USER_CREATE',
|
|
@@ -41,8 +41,6 @@ export const buildFindSelector = ({ includeGuests, includeDeleted, queryString,
|
|
|
41
41
|
selector.tags = { $in: tags };
|
|
42
42
|
}
|
|
43
43
|
if (emailVerified === false) {
|
|
44
|
-
// We need to use $ne here else we'd also find users with many emails where one is
|
|
45
|
-
// unverified
|
|
46
44
|
selector['emails.verified'] = { $ne: true };
|
|
47
45
|
}
|
|
48
46
|
if (lastLogin?.start) {
|
|
@@ -67,7 +65,6 @@ export const configureUsersModule = async (moduleInput) => {
|
|
|
67
65
|
const Users = await UsersCollection(db);
|
|
68
66
|
const webAuthn = await configureUsersWebAuthnModule(moduleInput);
|
|
69
67
|
return {
|
|
70
|
-
// Queries
|
|
71
68
|
webAuthn,
|
|
72
69
|
async count(query) {
|
|
73
70
|
const userCount = await Users.countDocuments(buildFindSelector(query));
|
|
@@ -182,7 +179,6 @@ export const configureUsersModule = async (moduleInput) => {
|
|
|
182
179
|
const userCount = await Users.countDocuments({ _id: userId, deleted: { $exists: false } }, { limit: 1 });
|
|
183
180
|
return userCount === 1;
|
|
184
181
|
},
|
|
185
|
-
// Transformations
|
|
186
182
|
primaryEmail(user) {
|
|
187
183
|
return (user.emails || []).toSorted((left, right) => Number(right.verified) - Number(left.verified))?.[0];
|
|
188
184
|
},
|
|
@@ -196,7 +192,6 @@ export const configureUsersModule = async (moduleInput) => {
|
|
|
196
192
|
return systemLocale;
|
|
197
193
|
}
|
|
198
194
|
},
|
|
199
|
-
// Mutations
|
|
200
195
|
async createUser(rawUserData, { skipMessaging, skipPasswordEnrollment, } = {}) {
|
|
201
196
|
const { password, email, username, initialPassword, roles, webAuthnPublicKeyCredentials, ...userData } = await userSettings.validateNewUser(rawUserData);
|
|
202
197
|
const webAuthnService = webAuthnPublicKeyCredentials &&
|
|
@@ -250,7 +245,6 @@ export const configureUsersModule = async (moduleInput) => {
|
|
|
250
245
|
}
|
|
251
246
|
}
|
|
252
247
|
catch {
|
|
253
|
-
/* */
|
|
254
248
|
}
|
|
255
249
|
const user = (await Users.findOne({ _id: userId }, {}));
|
|
256
250
|
await emit('USER_CREATE', {
|
|
@@ -384,7 +378,6 @@ export const configureUsersModule = async (moduleInput) => {
|
|
|
384
378
|
return null;
|
|
385
379
|
const updatedUser = await this.setPassword(resetToken.userId, newPassword);
|
|
386
380
|
if (updatedUser) {
|
|
387
|
-
// Now invalidate the reset token
|
|
388
381
|
await Users.updateOne({
|
|
389
382
|
_id: resetToken.userId,
|
|
390
383
|
}, {
|
|
@@ -500,8 +493,6 @@ export const configureUsersModule = async (moduleInput) => {
|
|
|
500
493
|
}, {});
|
|
501
494
|
}
|
|
502
495
|
if (meta) {
|
|
503
|
-
// eslint-disable-next-line
|
|
504
|
-
// @ts-ignore
|
|
505
496
|
modifier.$set.meta = meta;
|
|
506
497
|
}
|
|
507
498
|
const user = await Users.findOneAndUpdate(userFilter, modifier, {
|
|
@@ -561,7 +552,6 @@ export const configureUsersModule = async (moduleInput) => {
|
|
|
561
552
|
},
|
|
562
553
|
};
|
|
563
554
|
if ((!profile.phoneMobile || isGuest) && lastContact.telNumber) {
|
|
564
|
-
// Backport the contact phone number to the user profile
|
|
565
555
|
modifier.$set['profile.phoneMobile'] = lastContact.telNumber;
|
|
566
556
|
}
|
|
567
557
|
const updatedUser = await Users.findOneAndUpdate(userFilter, modifier, {
|
|
@@ -652,4 +642,3 @@ export const configureUsersModule = async (moduleInput) => {
|
|
|
652
642
|
},
|
|
653
643
|
};
|
|
654
644
|
};
|
|
655
|
-
//# sourceMappingURL=configureUsersModule.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleInput } from '@unchainedshop/mongodb';
|
|
1
|
+
import type { ModuleInput } from '@unchainedshop/mongodb';
|
|
2
2
|
import type { PublicKeyCredentialCreationOptions, PublicKeyCredentialRequestOptions } from 'fido2-lib';
|
|
3
3
|
type SerializedOptions<T> = Omit<T, 'challenge' | 'requestId'> & {
|
|
4
4
|
challenge: string;
|
|
@@ -23,4 +23,3 @@ export declare const configureUsersWebAuthnModule: ({ db }: ModuleInput<any>) =>
|
|
|
23
23
|
deleteUserWebAuthnCredentials: (username: string) => Promise<number>;
|
|
24
24
|
}>;
|
|
25
25
|
export {};
|
|
26
|
-
//# sourceMappingURL=configureUsersWebAuthnModule.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
-
import { WebAuthnCredentialsCreationRequestsCollection } from
|
|
2
|
+
import { WebAuthnCredentialsCreationRequestsCollection } from "../db/WebAuthnCredentialsCreationRequestsCollection.js";
|
|
3
3
|
const logger = createLogger('unchained:core-users');
|
|
4
4
|
const { ROOT_URL = 'http://localhost:4010', EMAIL_WEBSITE_NAME = 'Unchained' } = process.env;
|
|
5
5
|
let Fido2Lib;
|
|
@@ -16,8 +16,6 @@ const setupMDSCollection = async () => {
|
|
|
16
16
|
const tocResult = await fetch('https://mds.fidoalliance.org');
|
|
17
17
|
const tocBase64 = await tocResult.text();
|
|
18
18
|
const mc = Fido2Lib.createMdsCollection('FIDO MDS v3');
|
|
19
|
-
// eslint-disable-next-line
|
|
20
|
-
// @ts-ignore
|
|
21
19
|
const tocObj = await mc.addToc(tocBase64);
|
|
22
20
|
return tocObj.entries;
|
|
23
21
|
}
|
|
@@ -36,7 +34,6 @@ export function toArrayBuffer(buffer) {
|
|
|
36
34
|
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
37
35
|
}
|
|
38
36
|
export function buf2hex(buffer) {
|
|
39
|
-
// buffer is an ArrayBuffer
|
|
40
37
|
return Array.prototype.map
|
|
41
38
|
.call(new Uint8Array(buffer), (x) => `00${x.toString(16)}`.slice(-2))
|
|
42
39
|
.join('');
|
|
@@ -64,7 +61,6 @@ export const configureUsersWebAuthnModule = async ({ db }) => {
|
|
|
64
61
|
if (!f2l)
|
|
65
62
|
return null;
|
|
66
63
|
const registrationOptions = await f2l.attestationOptions(extensionOptions);
|
|
67
|
-
// Convert challenge to base64 without using Buffer
|
|
68
64
|
const challenge = btoa(String.fromCharCode(...new Uint8Array(registrationOptions.challenge)));
|
|
69
65
|
const { insertedId } = await WebAuthnCredentialsCreationRequests.insertOne({
|
|
70
66
|
_id: new Date().getTime(),
|
|
@@ -83,7 +79,6 @@ export const configureUsersWebAuthnModule = async ({ db }) => {
|
|
|
83
79
|
if (!f2l)
|
|
84
80
|
return null;
|
|
85
81
|
const loginOptions = await f2l.assertionOptions(extensionOptions);
|
|
86
|
-
// Convert challenge to base64 without using Buffer
|
|
87
82
|
const challenge = btoa(String.fromCharCode(...new Uint8Array(loginOptions.challenge)));
|
|
88
83
|
const { insertedId } = await WebAuthnCredentialsCreationRequests.insertOne({
|
|
89
84
|
_id: new Date().getTime(),
|
|
@@ -123,7 +118,7 @@ export const configureUsersWebAuthnModule = async ({ db }) => {
|
|
|
123
118
|
};
|
|
124
119
|
const registrationOptions = await f2l.attestationResult(attestationResponse, attestationExpectations);
|
|
125
120
|
const publicKey = registrationOptions?.authnrData?.get('credentialPublicKeyPem');
|
|
126
|
-
const aaguidArrayBuffer = registrationOptions?.authnrData?.get('aaguid');
|
|
121
|
+
const aaguidArrayBuffer = registrationOptions?.authnrData?.get('aaguid');
|
|
127
122
|
const counter = registrationOptions?.authnrData?.get('counter');
|
|
128
123
|
const aaguidConcatenated = buf2hex(aaguidArrayBuffer);
|
|
129
124
|
const aaguid = `${aaguidConcatenated.slice(0, 8)}-${aaguidConcatenated.slice(8, 12)}-${aaguidConcatenated.slice(12, 16)}-${aaguidConcatenated.slice(16, 20)}-${aaguidConcatenated.slice(20)}`;
|
|
@@ -175,4 +170,3 @@ export const configureUsersWebAuthnModule = async ({ db }) => {
|
|
|
175
170
|
},
|
|
176
171
|
};
|
|
177
172
|
};
|
|
178
|
-
//# sourceMappingURL=configureUsersWebAuthnModule.js.map
|
package/lib/module/pbkdf2.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare function generateSalt(saltLength?: number): string;
|
|
2
2
|
export declare function getDerivedKey(salt: string, password: string, iterations?: number, keyLength?: number): Promise<string>;
|
|
3
3
|
export declare function compare(password: string, hash: string, salt: string): Promise<boolean>;
|
|
4
|
-
//# sourceMappingURL=pbkdf2.d.ts.map
|
package/lib/module/pbkdf2.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const PBKDF2_SALT_LENGTH = 16; // Bytes
|
|
1
|
+
const PBKDF2_ITERATIONS = 300000;
|
|
2
|
+
const PBKDF2_KEY_LENGTH = 256;
|
|
3
|
+
const PBKDF2_SALT_LENGTH = 16;
|
|
5
4
|
export function generateSalt(saltLength = PBKDF2_SALT_LENGTH) {
|
|
6
5
|
const array = new Uint8Array(saltLength);
|
|
7
6
|
crypto.getRandomValues(array);
|
|
8
|
-
// Convert to hex string without using Buffer
|
|
9
7
|
return Array.from(array)
|
|
10
8
|
.map((b) => b.toString(16).padStart(2, '0'))
|
|
11
9
|
.join('');
|
|
@@ -22,7 +20,6 @@ export async function getDerivedKey(salt, password, iterations = PBKDF2_ITERATIO
|
|
|
22
20
|
salt: textEncoder.encode(salt),
|
|
23
21
|
iterations,
|
|
24
22
|
}, importedKey, keyLength);
|
|
25
|
-
// Convert ArrayBuffer to hex string without using Buffer
|
|
26
23
|
return Array.from(new Uint8Array(bits))
|
|
27
24
|
.map((b) => b.toString(16).padStart(2, '0'))
|
|
28
25
|
.join('');
|
|
@@ -31,4 +28,3 @@ export async function compare(password, hash, salt) {
|
|
|
31
28
|
const comparableHash = await getDerivedKey(salt, password);
|
|
32
29
|
return comparableHash === hash;
|
|
33
30
|
}
|
|
34
|
-
//# sourceMappingURL=pbkdf2.js.map
|
package/lib/users-index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export * from './db/UsersCollection.
|
|
2
|
-
export * from './db/WebAuthnCredentialsCreationRequestsCollection.
|
|
3
|
-
export * from './module/configureUsersModule.
|
|
4
|
-
export * from './module/configureUsersWebAuthnModule.
|
|
5
|
-
export * from './users-settings.
|
|
6
|
-
//# sourceMappingURL=users-index.d.ts.map
|
|
1
|
+
export * from './db/UsersCollection.ts';
|
|
2
|
+
export * from './db/WebAuthnCredentialsCreationRequestsCollection.ts';
|
|
3
|
+
export * from './module/configureUsersModule.ts';
|
|
4
|
+
export * from './module/configureUsersWebAuthnModule.ts';
|
|
5
|
+
export * from './users-settings.ts';
|
package/lib/users-index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
//# sourceMappingURL=users-index.js.map
|
|
1
|
+
export * from "./db/UsersCollection.js";
|
|
2
|
+
export * from "./db/WebAuthnCredentialsCreationRequestsCollection.js";
|
|
3
|
+
export * from "./module/configureUsersModule.js";
|
|
4
|
+
export * from "./module/configureUsersWebAuthnModule.js";
|
|
5
|
+
export * from "./users-settings.js";
|
package/lib/users-settings.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { mongodb } from '@unchainedshop/mongodb';
|
|
2
|
-
import { User } from './db/UsersCollection.
|
|
1
|
+
import { type mongodb } from '@unchainedshop/mongodb';
|
|
2
|
+
import type { User } from './db/UsersCollection.ts';
|
|
3
3
|
export interface UserRegistrationData extends Partial<User> {
|
|
4
4
|
email?: string;
|
|
5
5
|
password: string | null;
|
|
6
6
|
webAuthnPublicKeyCredentials?: any;
|
|
7
7
|
}
|
|
8
|
-
export declare
|
|
9
|
-
RESET_PASSWORD
|
|
10
|
-
VERIFY_EMAIL
|
|
11
|
-
ENROLL_ACCOUNT
|
|
12
|
-
PASSWORD_RESETTED
|
|
13
|
-
EMAIL_VERIFIED
|
|
14
|
-
}
|
|
8
|
+
export declare const UserAccountAction: {
|
|
9
|
+
readonly RESET_PASSWORD: "reset-password";
|
|
10
|
+
readonly VERIFY_EMAIL: "verify-email";
|
|
11
|
+
readonly ENROLL_ACCOUNT: "enroll-account";
|
|
12
|
+
readonly PASSWORD_RESETTED: "password-resetted";
|
|
13
|
+
readonly EMAIL_VERIFIED: "email-verified";
|
|
14
|
+
};
|
|
15
|
+
export type UserAccountAction = (typeof UserAccountAction)[keyof typeof UserAccountAction];
|
|
15
16
|
export interface UserSettings {
|
|
16
17
|
mergeUserCartsOnLogin: boolean;
|
|
17
18
|
autoMessagingAfterUserCreation: boolean;
|
|
18
|
-
earliestValidTokenDate: (type: UserAccountAction.VERIFY_EMAIL | UserAccountAction.RESET_PASSWORD) => Date;
|
|
19
|
+
earliestValidTokenDate: (type: typeof UserAccountAction.VERIFY_EMAIL | typeof UserAccountAction.RESET_PASSWORD) => Date;
|
|
19
20
|
validateEmail: (email: string) => Promise<boolean>;
|
|
20
21
|
validateUsername: (username: string) => Promise<boolean>;
|
|
21
22
|
validateNewUser: (user: UserRegistrationData) => Promise<UserRegistrationData>;
|
|
@@ -24,4 +25,3 @@ export interface UserSettings {
|
|
|
24
25
|
}
|
|
25
26
|
export type UserSettingsOptions = Omit<Partial<UserSettings>, 'configureSettings'>;
|
|
26
27
|
export declare const userSettings: UserSettings;
|
|
27
|
-
//# sourceMappingURL=users-settings.d.ts.map
|
package/lib/users-settings.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { insensitiveTrimmedRegexOperator } from '@unchainedshop/mongodb';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})(UserAccountAction || (UserAccountAction = {}));
|
|
2
|
+
export const UserAccountAction = {
|
|
3
|
+
RESET_PASSWORD: 'reset-password',
|
|
4
|
+
VERIFY_EMAIL: 'verify-email',
|
|
5
|
+
ENROLL_ACCOUNT: 'enroll-account',
|
|
6
|
+
PASSWORD_RESETTED: 'password-resetted',
|
|
7
|
+
EMAIL_VERIFIED: 'email-verified',
|
|
8
|
+
};
|
|
10
9
|
const defaultAutoMessagingAfterUserCreation = true;
|
|
11
10
|
const defaultMergeUserCartsOnLogin = true;
|
|
12
11
|
const defaultEarliestValidTokenDate = () => {
|
|
13
|
-
// 1 hour ago
|
|
14
12
|
return new Date(new Date().getTime() - 1000 * 60 * 60);
|
|
15
13
|
};
|
|
16
14
|
const defaultValidateNewUser = async (user) => {
|
|
@@ -63,4 +61,3 @@ export const userSettings = {
|
|
|
63
61
|
userSettings.validatePassword = validatePassword || defaultValidatePassword;
|
|
64
62
|
},
|
|
65
63
|
};
|
|
66
|
-
//# sourceMappingURL=users-settings.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-users",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"main": "lib/users-index.js",
|
|
5
5
|
"types": "lib/users-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"build": "tsc -b",
|
|
10
10
|
"prepublishOnly": "npm run clean && npm run build",
|
|
11
11
|
"watch": "tsc -w",
|
|
12
|
-
"test": "
|
|
13
|
-
"test:watch": "
|
|
12
|
+
"test": "node --test",
|
|
13
|
+
"test:watch": "node --test --watch"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
@@ -22,8 +22,10 @@
|
|
|
22
22
|
"core"
|
|
23
23
|
],
|
|
24
24
|
"authors": [
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"Pascal Kaufmann",
|
|
26
|
+
"Mikael Araya",
|
|
27
|
+
"Vedran Rudelj",
|
|
28
|
+
"Joël Meiller"
|
|
27
29
|
],
|
|
28
30
|
"license": "EUPL-1.2",
|
|
29
31
|
"bugs": {
|
|
@@ -32,12 +34,12 @@
|
|
|
32
34
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
33
35
|
"dependencies": {
|
|
34
36
|
"bcryptjs": "^3.0.2",
|
|
35
|
-
"@unchainedshop/events": "^4.
|
|
36
|
-
"@unchainedshop/file-upload": "^4.
|
|
37
|
-
"@unchainedshop/logger": "^4.
|
|
38
|
-
"@unchainedshop/mongodb": "^4.
|
|
39
|
-
"@unchainedshop/roles": "^4.
|
|
40
|
-
"@unchainedshop/utils": "^4.
|
|
37
|
+
"@unchainedshop/events": "^4.4.0",
|
|
38
|
+
"@unchainedshop/file-upload": "^4.4.0",
|
|
39
|
+
"@unchainedshop/logger": "^4.4.0",
|
|
40
|
+
"@unchainedshop/mongodb": "^4.4.0",
|
|
41
|
+
"@unchainedshop/roles": "^4.4.0",
|
|
42
|
+
"@unchainedshop/utils": "^4.4.0"
|
|
41
43
|
},
|
|
42
44
|
"peerDependencies": {
|
|
43
45
|
"fido2-lib": ">= 3.5 < 4"
|
|
@@ -48,9 +50,8 @@
|
|
|
48
50
|
}
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
|
-
"@types/node": "^
|
|
53
|
+
"@types/node": "^25.0.0",
|
|
52
54
|
"fido2-lib": "^3.5.3",
|
|
53
|
-
"tsx": "^4.20.3",
|
|
54
55
|
"typescript": "^5.8.3"
|
|
55
56
|
}
|
|
56
57
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UsersCollection.d.ts","sourceRoot":"","sources":["../../src/db/UsersCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,OAAO,EACP,OAAO,EACP,OAAO,EAGR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;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CreationRequestsCollection.d.ts","sourceRoot":"","sources":["../../src/db/WebAuthnCredentialsCreationRequestsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,wBAAwB,CAAC;AAEjE,MAAM,WAAW,kCAAkC;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACvC;AAED,KAAK,UAAU,GAAG,kCAAkC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE,eAAO,MAAM,6CAA6C,GAAU,IAAI,OAAO,CAAC,EAAE,4CAcjF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebAuthnCredentialsCreationRequestsCollection.js","sourceRoot":"","sources":["../../src/db/WebAuthnCredentialsCreationRequestsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAWjE,MAAM,CAAC,MAAM,6CAA6C,GAAG,KAAK,EAAE,EAAc,EAAE,EAAE;IACpF,MAAM,mCAAmC,GAAG,EAAE,CAAC,UAAU,CACvD,iDAAiD,CAClD,CAAC;IAEF,MAAM,cAAc,CAAa,mCAAmC,EAAE;QACpE;YACE,KAAK,EAAE;gBACL,QAAQ,EAAE,CAAC;aACZ;SACF;KACF,CAAC,CAAC;IAEH,OAAO,mCAAmC,CAAC;AAC7C,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addMigrations.d.ts","sourceRoot":"","sources":["../../src/module/addMigrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAsB9E,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,UAAU,EAAE,mBAAmB,CAAC,SAAS,CAAC,QAkD/E"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { UsersCollection } from '../db/UsersCollection.js';
|
|
2
|
-
const convertTagsToLowerCase = async (collection) => {
|
|
3
|
-
let bulk = collection.initializeUnorderedBulkOp();
|
|
4
|
-
let count = 0;
|
|
5
|
-
const cursor = await collection.find({ tags: { $regex: '.*[A-Z]' } });
|
|
6
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
7
|
-
for await (const doc of cursor) {
|
|
8
|
-
const transformedTags = doc.tags.map((tag) => tag.toLowerCase());
|
|
9
|
-
count += 1;
|
|
10
|
-
bulk.find({ _id: doc._id }).updateOne({ $set: { tags: transformedTags } });
|
|
11
|
-
if (count % 500 === 0) {
|
|
12
|
-
bulk.execute();
|
|
13
|
-
bulk = collection.initializeUnorderedBulkOp();
|
|
14
|
-
count = 0;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
if (count > 0)
|
|
18
|
-
bulk.execute();
|
|
19
|
-
};
|
|
20
|
-
export default function addMigrations(repository) {
|
|
21
|
-
repository?.register({
|
|
22
|
-
id: 20220603115000,
|
|
23
|
-
name: 'Copy user.profile.customFields to user.meta',
|
|
24
|
-
up: async () => {
|
|
25
|
-
const Users = await UsersCollection(repository.db);
|
|
26
|
-
const users = await Users.find({ meta: { $exists: false }, 'profile.customFields': { $exists: true } }, { projection: { _id: true, profile: true, meta: true } }).toArray();
|
|
27
|
-
await Promise.all(users.map(async (user) => {
|
|
28
|
-
await Users.updateOne({
|
|
29
|
-
_id: user._id,
|
|
30
|
-
}, {
|
|
31
|
-
$set: { meta: user.profile.customFields },
|
|
32
|
-
});
|
|
33
|
-
}));
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
repository?.register({
|
|
37
|
-
id: 20220920122500,
|
|
38
|
-
name: 'Convert user tags to lower case for easy search',
|
|
39
|
-
up: async () => {
|
|
40
|
-
const Users = await UsersCollection(repository.db);
|
|
41
|
-
await convertTagsToLowerCase(Users);
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
repository?.register({
|
|
45
|
-
id: 20230719105000,
|
|
46
|
-
name: 'Rename user.lastLogin.countryContext to user.lastLogin.countryCode',
|
|
47
|
-
up: async () => {
|
|
48
|
-
const Users = await UsersCollection(repository.db);
|
|
49
|
-
await Users.updateMany({
|
|
50
|
-
'lastLogin.countryContext': { $exists: true },
|
|
51
|
-
}, {
|
|
52
|
-
$rename: { 'lastLogin.countryContext': 'lastLogin.countryCode' },
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=addMigrations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addMigrations.js","sourceRoot":"","sources":["../../src/module/addMigrations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,sBAAsB,GAAG,KAAK,EAAE,UAAuD,EAAE,EAAE;IAC/F,IAAI,IAAI,GAAG,UAAU,CAAC,yBAAyB,EAAE,CAAC;IAClD,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IACtE,gDAAgD;IAChD,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAC/B,MAAM,eAAe,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;QACjE,KAAK,IAAI,CAAC,CAAC;QACX,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;QAC3E,IAAI,KAAK,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