@unchainedshop/core-users 4.8.31 → 4.8.33

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.
@@ -806,7 +806,13 @@ export const configureUsersModule = async (moduleInput) => {
806
806
  return user;
807
807
  },
808
808
  addPushSubscription: async (userId, subscription, subscriptionOptions) => {
809
- const updateResult = await Users.updateOne({ _id: userId, 'pushSubscriptions.keys.p256dh': { $ne: subscription?.keys?.p256dh } }, {
809
+ const p256dh = subscription?.keys?.p256dh;
810
+ if (typeof p256dh !== 'string') {
811
+ throw new Error('Push subscription needs a keys.p256dh string', {
812
+ cause: 'PUSH_SUBSCRIPTION_INVALID',
813
+ });
814
+ }
815
+ const updateResult = await Users.updateOne({ _id: userId, 'pushSubscriptions.keys.p256dh': { $ne: p256dh } }, {
810
816
  $push: {
811
817
  pushSubscriptions: {
812
818
  userAgent: subscriptionOptions?.userAgent,
@@ -815,9 +821,9 @@ export const configureUsersModule = async (moduleInput) => {
815
821
  },
816
822
  }, {});
817
823
  if (updateResult.modifiedCount === 1 && subscriptionOptions?.unsubscribeFromOtherUsers) {
818
- await Users.updateMany({ _id: { $ne: userId }, 'pushSubscriptions.keys.p256dh': subscription?.keys?.p256dh }, {
824
+ await Users.updateMany({ _id: { $ne: userId }, 'pushSubscriptions.keys.p256dh': p256dh }, {
819
825
  $pull: {
820
- pushSubscriptions: { 'keys.p256dh': subscription?.keys?.p256dh },
826
+ pushSubscriptions: { 'keys.p256dh': p256dh },
821
827
  },
822
828
  });
823
829
  }
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.8.31",
4
+ "version": "4.8.33",
5
5
  "main": "lib/users-index.js",
6
6
  "types": "lib/users-index.d.ts",
7
7
  "type": "module",
@@ -35,12 +35,12 @@
35
35
  },
36
36
  "homepage": "https://github.com/unchainedshop/unchained#readme",
37
37
  "dependencies": {
38
- "@passwordless-id/webauthn": "^2.3.1",
39
- "@unchainedshop/events": "^4.8.27",
40
- "@unchainedshop/logger": "^4.8.27",
41
- "@unchainedshop/mongodb": "^4.8.27",
42
- "@unchainedshop/utils": "^4.8.27",
43
- "bcryptjs": "^3.0.2"
38
+ "@passwordless-id/webauthn": "^2.4.1",
39
+ "@unchainedshop/events": "^4.8.31",
40
+ "@unchainedshop/logger": "^4.8.31",
41
+ "@unchainedshop/mongodb": "^4.8.31",
42
+ "@unchainedshop/utils": "^4.8.31",
43
+ "bcryptjs": "^3.0.3"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@noble/curves": "^2.0.0",
@@ -57,7 +57,7 @@
57
57
  "devDependencies": {
58
58
  "@noble/curves": "^2.0.0",
59
59
  "@noble/hashes": "^2.0.0",
60
- "@types/node": "^26.2.0",
60
+ "@types/node": "^26.6.5",
61
61
  "typescript": "^6.0.3"
62
62
  }
63
63
  }