@unchainedshop/core-users 4.3.5 → 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/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/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/lib/users-index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"users-index.d.ts","sourceRoot":"","sources":["../src/users-index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,uDAAuD,CAAC;AACtE,cAAc,kCAAkC,CAAC;AACjD,cAAc,0CAA0C,CAAC;AACzD,cAAc,qBAAqB,CAAC"}
|
package/lib/users-index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"users-index.js","sourceRoot":"","sources":["../src/users-index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,uDAAuD,CAAC;AACtE,cAAc,kCAAkC,CAAC;AACjD,cAAc,0CAA0C,CAAC;AACzD,cAAc,qBAAqB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"users-settings.d.ts","sourceRoot":"","sources":["../src/users-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,MAAM,WAAW,oBAAqB,SAAQ,OAAO,CAAC,IAAI,CAAC;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,4BAA4B,CAAC,EAAE,GAAG,CAAC;CACpC;AAED,oBAAY,iBAAiB;IAC3B,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,iBAAiB,sBAAsB;IACvC,cAAc,mBAAmB;CAClC;AACD,MAAM,WAAW,YAAY;IAC3B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,8BAA8B,EAAE,O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
7
|
-
isDocumentDBCompatModeEnabled,
|
|
8
|
-
} from '@unchainedshop/mongodb';
|
|
9
|
-
import { DateFilterInput } from '@unchainedshop/utils';
|
|
10
|
-
|
|
11
|
-
export interface UserProfile {
|
|
12
|
-
displayName?: string;
|
|
13
|
-
birthday?: Date;
|
|
14
|
-
phoneMobile?: string;
|
|
15
|
-
gender?: string;
|
|
16
|
-
address?: Address;
|
|
17
|
-
}
|
|
18
|
-
export interface UserLastLogin {
|
|
19
|
-
timestamp?: Date;
|
|
20
|
-
locale?: string;
|
|
21
|
-
countryCode?: string;
|
|
22
|
-
remoteAddress?: string;
|
|
23
|
-
remotePort?: number;
|
|
24
|
-
userAgent?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface PushSubscriptionObject {
|
|
28
|
-
userAgent: string;
|
|
29
|
-
endpoint: string;
|
|
30
|
-
expirationTime: number;
|
|
31
|
-
keys: {
|
|
32
|
-
auth: string;
|
|
33
|
-
p256dh: string;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface Email {
|
|
38
|
-
address: string;
|
|
39
|
-
verified: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type User = {
|
|
43
|
-
_id: string;
|
|
44
|
-
deleted?: Date;
|
|
45
|
-
avatarId?: string;
|
|
46
|
-
emails: Email[];
|
|
47
|
-
guest: boolean;
|
|
48
|
-
initialPassword: boolean;
|
|
49
|
-
lastBillingAddress?: Address;
|
|
50
|
-
lastContact?: Contact;
|
|
51
|
-
lastLogin?: UserLastLogin;
|
|
52
|
-
profile?: UserProfile;
|
|
53
|
-
roles: string[];
|
|
54
|
-
services: any;
|
|
55
|
-
tags?: string[];
|
|
56
|
-
pushSubscriptions: PushSubscriptionObject[];
|
|
57
|
-
username?: string;
|
|
58
|
-
meta?: any;
|
|
59
|
-
} & TimestampFields;
|
|
60
|
-
|
|
61
|
-
export type UserQuery = mongodb.Filter<User> & {
|
|
62
|
-
includeGuests?: boolean;
|
|
63
|
-
includeDeleted?: boolean;
|
|
64
|
-
queryString?: string;
|
|
65
|
-
emailVerified?: boolean;
|
|
66
|
-
lastLogin?: DateFilterInput;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const UsersCollection = async (db: mongodb.Db) => {
|
|
70
|
-
const Users = db.collection<User>('users');
|
|
71
|
-
|
|
72
|
-
if (!isDocumentDBCompatModeEnabled()) {
|
|
73
|
-
await buildDbIndexes<User>(Users, [
|
|
74
|
-
{
|
|
75
|
-
index: {
|
|
76
|
-
_id: 'text',
|
|
77
|
-
username: 'text',
|
|
78
|
-
'emails.address': 'text',
|
|
79
|
-
'profile.displayName': 'text',
|
|
80
|
-
'lastBillingAddress.firstName': 'text',
|
|
81
|
-
'lastBillingAddress.lastName': 'text',
|
|
82
|
-
'lastBillingAddress.company': 'text',
|
|
83
|
-
'lastBillingAddress.addressLine': 'text',
|
|
84
|
-
'lastBillingAddress.addressLine2': 'text',
|
|
85
|
-
} as any,
|
|
86
|
-
options: {
|
|
87
|
-
weights: {
|
|
88
|
-
_id: 9,
|
|
89
|
-
'emails.address': 7,
|
|
90
|
-
'profile.displayName': 5,
|
|
91
|
-
'lastBillingAddress.firstName': 3,
|
|
92
|
-
'lastBillingAddress.lastName': 3,
|
|
93
|
-
'lastBillingAddress.company': 1,
|
|
94
|
-
'lastBillingAddress.addressLine': 1,
|
|
95
|
-
'lastBillingAddress.addressLine2': 1,
|
|
96
|
-
},
|
|
97
|
-
name: 'user_fulltext_search',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
]);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
await buildDbIndexes<User>(Users, [
|
|
104
|
-
{
|
|
105
|
-
index: {
|
|
106
|
-
deleted: 1,
|
|
107
|
-
created: 1,
|
|
108
|
-
guest: 1,
|
|
109
|
-
},
|
|
110
|
-
options: {},
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
index: {
|
|
114
|
-
guest: 1,
|
|
115
|
-
},
|
|
116
|
-
options: {
|
|
117
|
-
sparse: true,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
index: {
|
|
122
|
-
created: 1,
|
|
123
|
-
},
|
|
124
|
-
options: {},
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
index: {
|
|
128
|
-
username: 1,
|
|
129
|
-
},
|
|
130
|
-
options: {
|
|
131
|
-
unique: true,
|
|
132
|
-
sparse: true,
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
index: {
|
|
137
|
-
'emails.address': 1,
|
|
138
|
-
} as any,
|
|
139
|
-
options: {
|
|
140
|
-
unique: true,
|
|
141
|
-
sparse: true,
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
{
|
|
146
|
-
index: {
|
|
147
|
-
'services.email.verificationTokens.token': 1,
|
|
148
|
-
} as any,
|
|
149
|
-
options: {
|
|
150
|
-
sparse: true,
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
{
|
|
155
|
-
index: {
|
|
156
|
-
'services.password.reset.token': 1,
|
|
157
|
-
} as any,
|
|
158
|
-
options: {
|
|
159
|
-
sparse: true,
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
{
|
|
164
|
-
index: {
|
|
165
|
-
'services.token.secret': 1,
|
|
166
|
-
},
|
|
167
|
-
options: {
|
|
168
|
-
sparse: true,
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
]);
|
|
172
|
-
|
|
173
|
-
return Users;
|
|
174
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { mongodb, buildDbIndexes } from '@unchainedshop/mongodb';
|
|
2
|
-
|
|
3
|
-
export interface WebAuthnCredentialsCreationRequest {
|
|
4
|
-
challenge: string;
|
|
5
|
-
username: string;
|
|
6
|
-
origin: string;
|
|
7
|
-
factor: 'first' | 'second' | 'either';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type Collection = WebAuthnCredentialsCreationRequest & { _id: number };
|
|
11
|
-
|
|
12
|
-
export const WebAuthnCredentialsCreationRequestsCollection = async (db: mongodb.Db) => {
|
|
13
|
-
const WebAuthnCredentialsCreationRequests = db.collection<Collection>(
|
|
14
|
-
'accounts_webauthn_credentials_creation_requests',
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
await buildDbIndexes<Collection>(WebAuthnCredentialsCreationRequests, [
|
|
18
|
-
{
|
|
19
|
-
index: {
|
|
20
|
-
username: 1,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
]);
|
|
24
|
-
|
|
25
|
-
return WebAuthnCredentialsCreationRequests;
|
|
26
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
import { buildFindSelector } from './configureUsersModule.js';
|
|
4
|
-
|
|
5
|
-
describe('buildFindSelector', () => {
|
|
6
|
-
it('Return the correct filter when no parameter is passed', () => {
|
|
7
|
-
assert.deepStrictEqual(buildFindSelector({}), {
|
|
8
|
-
deleted: null,
|
|
9
|
-
guest: { $ne: true },
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
it('Return the correct filter when no parameter is passed queryString and includeGuest: true', () => {
|
|
13
|
-
assert.deepStrictEqual(buildFindSelector({ queryString: 'Hello world', includeGuests: true }), {
|
|
14
|
-
deleted: null,
|
|
15
|
-
$text: { $search: 'Hello world' },
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('Should include additional user field selector in addition too queryString and includeGuests', () => {
|
|
20
|
-
assert.deepStrictEqual(
|
|
21
|
-
buildFindSelector({
|
|
22
|
-
queryString: 'Hello world',
|
|
23
|
-
includeGuests: false,
|
|
24
|
-
'profile.displayName': 'mikael',
|
|
25
|
-
}),
|
|
26
|
-
{
|
|
27
|
-
'profile.displayName': 'mikael',
|
|
28
|
-
deleted: null,
|
|
29
|
-
guest: { $ne: true },
|
|
30
|
-
$text: { $search: 'Hello world' },
|
|
31
|
-
},
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
});
|