@unchainedshop/core-users 4.8.11 → 5.0.0-alpha.2
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.
|
@@ -124,6 +124,10 @@ export declare const configureUsersModule: (moduleInput: ModuleInput<UserSetting
|
|
|
124
124
|
updateLastBillingAddress: (_id: string, lastBillingAddress: Address) => Promise<mongodb.WithId<User> | null>;
|
|
125
125
|
updateLastContact: (_id: string, lastContact: Contact) => Promise<mongodb.WithId<User> | null>;
|
|
126
126
|
updateRoles: (_id: string, roles: string[]) => Promise<mongodb.WithId<User> | null>;
|
|
127
|
+
incrementTokenVersion: (userId: string) => Promise<{
|
|
128
|
+
tokenVersion: number;
|
|
129
|
+
} | null>;
|
|
130
|
+
updateOidcLogoutAt: (userId: string, date: Date) => Promise<User | null>;
|
|
127
131
|
updateTags: (_id: string, tags: string[]) => Promise<mongodb.WithId<User> | null>;
|
|
128
132
|
updateUser: (selector: mongodb.Filter<User>, modifier: mongodb.UpdateFilter<User>, updateOptions?: mongodb.FindOneAndUpdateOptions) => Promise<mongodb.WithId<User> | null>;
|
|
129
133
|
addPushSubscription: (userId: string, subscription: any, subscriptionOptions?: {
|
|
@@ -587,9 +587,7 @@ export const configureUsersModule = async (moduleInput) => {
|
|
|
587
587
|
return user;
|
|
588
588
|
},
|
|
589
589
|
markDeleted: async (userId) => {
|
|
590
|
-
await
|
|
591
|
-
session: insensitiveTrimmedRegexOperator(`"user":"${userId}"`),
|
|
592
|
-
});
|
|
590
|
+
await Users.updateOne({ _id: userId }, { $inc: { tokenVersion: 1 } });
|
|
593
591
|
const user = await Users.findOneAndUpdate({ _id: userId }, {
|
|
594
592
|
$set: {
|
|
595
593
|
username: `deleted-${Date.now()}`,
|
|
@@ -722,6 +720,25 @@ export const configureUsersModule = async (moduleInput) => {
|
|
|
722
720
|
});
|
|
723
721
|
return user;
|
|
724
722
|
},
|
|
723
|
+
incrementTokenVersion: async (userId) => {
|
|
724
|
+
const user = await Users.findOneAndUpdate(generateDbFilterById(userId), {
|
|
725
|
+
$inc: { tokenVersion: 1 },
|
|
726
|
+
$set: { updated: new Date() },
|
|
727
|
+
}, { returnDocument: 'after' });
|
|
728
|
+
if (!user)
|
|
729
|
+
return null;
|
|
730
|
+
return { tokenVersion: user.tokenVersion ?? 1 };
|
|
731
|
+
},
|
|
732
|
+
updateOidcLogoutAt: async (userId, date) => {
|
|
733
|
+
const user = await Users.findOneAndUpdate(generateDbFilterById(userId), {
|
|
734
|
+
$set: {
|
|
735
|
+
oidcLogoutAt: date,
|
|
736
|
+
updated: new Date(),
|
|
737
|
+
},
|
|
738
|
+
$inc: { tokenVersion: 1 },
|
|
739
|
+
}, { returnDocument: 'after' });
|
|
740
|
+
return user;
|
|
741
|
+
},
|
|
725
742
|
updateTags: async (_id, tags) => {
|
|
726
743
|
const user = await Users.findOneAndUpdate(generateDbFilterById(_id), {
|
|
727
744
|
$set: {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { generateDbObjectId } from '@unchainedshop/mongodb';
|
|
2
2
|
import { createLogger } from '@unchainedshop/logger';
|
|
3
|
-
import
|
|
4
|
-
import ExpiryMap from 'expiry-map';
|
|
3
|
+
import { memoizeWithTTL } from '@unchainedshop/utils';
|
|
5
4
|
import { server as webauthnServer } from '@passwordless-id/webauthn';
|
|
6
5
|
import { WebAuthnCredentialsCreationRequestsCollection } from "../db/WebAuthnCredentialsCreationRequestsCollection.js";
|
|
7
6
|
const logger = createLogger('unchained:core-users');
|
|
@@ -37,8 +36,7 @@ async function fetchMDSEntriesImpl() {
|
|
|
37
36
|
}
|
|
38
37
|
return cache;
|
|
39
38
|
}
|
|
40
|
-
const
|
|
41
|
-
const fetchMDSEntries = pMemoize(fetchMDSEntriesImpl, { cache: mdsCache });
|
|
39
|
+
const fetchMDSEntries = memoizeWithTTL(fetchMDSEntriesImpl, ONE_DAY_MS);
|
|
42
40
|
export function toArrayBuffer(buffer) {
|
|
43
41
|
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
44
42
|
}
|
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": "
|
|
4
|
+
"version": "5.0.0-alpha.2",
|
|
5
5
|
"main": "lib/users-index.js",
|
|
6
6
|
"types": "lib/users-index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -36,15 +36,12 @@
|
|
|
36
36
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@passwordless-id/webauthn": "^2.3.1",
|
|
39
|
-
"@unchainedshop/events": "^
|
|
40
|
-
"@unchainedshop/
|
|
41
|
-
"@unchainedshop/
|
|
42
|
-
"@unchainedshop/
|
|
43
|
-
"@unchainedshop/
|
|
44
|
-
"
|
|
45
|
-
"bcryptjs": "^3.0.2",
|
|
46
|
-
"expiry-map": "^2.0.0",
|
|
47
|
-
"p-memoize": "^8.0.0"
|
|
39
|
+
"@unchainedshop/events": "^5.0.0-alpha.1",
|
|
40
|
+
"@unchainedshop/logger": "^5.0.0-alpha.1",
|
|
41
|
+
"@unchainedshop/mongodb": "^5.0.0-alpha.1",
|
|
42
|
+
"@unchainedshop/roles": "^5.0.0-alpha.1",
|
|
43
|
+
"@unchainedshop/utils": "^5.0.0-alpha.1",
|
|
44
|
+
"bcryptjs": "^3.0.2"
|
|
48
45
|
},
|
|
49
46
|
"peerDependencies": {
|
|
50
47
|
"@noble/curves": "^2.0.0",
|