@social-mail/social-mail-web-server 1.8.468 → 1.8.470

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-web-server",
3
- "version": "1.8.468",
3
+ "version": "1.8.470",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -3,6 +3,33 @@ import SocialMailContext from "../../../model/SocialMailContext.js";
3
3
  import BaseOtpToUserService from "./BaseOtpToUserService.js";
4
4
  import { globalEnv } from "../../../../common/globalEnv.js";
5
5
  import VerificationToken from "../../../model/entities/VerificationToken.js";
6
+ import EntityAccessError from "@entity-access/entity-access/dist/common/EntityAccessError.js";
7
+
8
+ const allowed = [
9
+
10
+ // us canada
11
+ "+1",
12
+ // europe + UK
13
+ "+43", "+32", "+385", "+420", "+45", "+33", "+49", "+30",
14
+ "+36", "+353", "+39", "+31", "+47", "+48", "+351", "+34",
15
+ "+46", "+41", "+44",
16
+ // india
17
+ "+91",
18
+ // australia
19
+ "+61",
20
+ // new zealand
21
+ "+64",
22
+ // hongkong
23
+ "+852",
24
+ // thailand
25
+ "+66",
26
+ // singapore
27
+ "+65",
28
+ // south korea
29
+ "+82",
30
+ // Japan
31
+ "+81"
32
+ ];
6
33
 
7
34
  @RegisterScoped
8
35
  export default class OtpToUserService extends BaseOtpToUserService {
@@ -12,6 +39,10 @@ export default class OtpToUserService extends BaseOtpToUserService {
12
39
 
13
40
  async create({ id = void 0, phone }) {
14
41
 
42
+ if(!allowed.some((x) => phone.startsWith(x))) {
43
+ throw new EntityAccessError("Cannot send text to your country");
44
+ }
45
+
15
46
  const { db } = this;
16
47
 
17
48
  let v: VerificationToken;
@@ -62,6 +62,8 @@ export default class SendWebPushNotification extends Workflow<{ emailID, mailbox
62
62
  console.error(`Push Subscription for ${iterator.sessionID} is no longer valid.`);
63
63
  await db.loginSessions.where(iterator, (p) => (x) => x.sessionID === p.sessionID)
64
64
  .update(void 0, (p) => (x) => ({ deviceToken: null, deviceTokenType: null }));
65
+ } else {
66
+ console.error(`Failed ${JSON.stringify(payload)} for ${iterator.deviceToken} for ${iterator.deviceTokenType}`);
65
67
  }
66
68
  console.error(error);
67
69
  }