@corbit2/node-red-corbit-sms 1.0.1 → 1.0.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.3 (2026-11-08)
4
+
5
+ - A Saudi mobile number must have exactly 9 digits after 966 (9665XXXXXXXX). Numbers with a digit too many or too few, such as 9665012345678, are rejected before sending instead of going to a wrong number.
6
+
7
+ ## 1.0.2 (2026-11-08)
8
+
9
+ - Lists of numbers are read like the Corbit SMS app: the Arabic comma and semicolon (« ، » « ؛ », typed by the Arabic iPhone keyboard) and tabs (from a spreadsheet) separate numbers too, and numbers separated only by spaces are read one by one. A number copied from phone contacts with spaces, such as `+966 50 123 4567`, stays one number.
10
+
3
11
  ## 1.0.1 (2026-11-08)
4
12
 
5
13
  - No change to the node itself.
package/README.md CHANGED
@@ -49,7 +49,7 @@ By default the node reads these message properties. Each field can be changed to
49
49
  |---|---|---|
50
50
  | `msg.payload` | Send, Send to many | Text of the SMS, up to 1600 characters. Numbers (such as an OTP) are accepted. |
51
51
  | `msg.to` | Send | Mobile number, e.g. `966501234567` |
52
- | `msg.numbers` | Send to many | Array of numbers, or text separated by commas or new lines |
52
+ | `msg.numbers` | Send to many | Array of numbers, or text separated by commas (also the Arabic « ، »), semicolons, tabs, new lines or spaces |
53
53
  | `msg.messageId` | Get status, Get report | The `messageId` returned by a send |
54
54
  | `msg.sender` | Send, Send to many | Sender name, used when the **Sender** field is empty |
55
55
  | `msg.allowDuplicate` | Send, Send to many | `true` or `false`; overrides the **Duplicates** box |
@@ -306,7 +306,7 @@ By default the node reads these message properties. You can change each field to
306
306
 
307
307
  : payload (string | number) : the text of the SMS, up to 1600 characters (Send and Send to many).
308
308
  : to (string) : the mobile number (Send). Use the international format, e.g. `966501234567`.
309
- : numbers (array | string) : the mobile numbers (Send to many), as an array or as text separated by commas or new lines.
309
+ : numbers (array | string) : the mobile numbers (Send to many), as an array or as text separated by commas (also the Arabic « ، »), semicolons, tabs, new lines or spaces.
310
310
  : messageId (string) : the ID returned by a send (Get message status, Get delivery report).
311
311
  : sender (string) : the sender name, used when the Sender field is empty.
312
312
  : allowDuplicate (boolean) : `true` sends even if the same text went to the same number in the last hour; `false` blocks it even if the box is ticked.
@@ -56,18 +56,41 @@ function normalizeNumber(raw) {
56
56
  }
57
57
  // "+966 (0)50 …": drop the trunk zero after the Saudi country code.
58
58
  if (/^9660\d{9}$/.test(digits)) digits = '966' + digits.slice(4);
59
+ // A Saudi mobile number is exactly 9665 + 8 digits; anything else would reach a wrong number.
60
+ if (digits.startsWith('9665') && !/^9665\d{8}$/.test(digits)) return undefined;
59
61
  return /^[1-9]\d{7,14}$/.test(digits) ? digits : undefined;
60
62
  }
61
63
 
62
- /** Splits a list given as text (commas, semicolons or new lines) or as an array. */
64
+ // What separates one number from the next in a pasted list: comma, semicolon,
65
+ // new line, tab, and the Arabic comma and semicolon (what the Arabic iPhone
66
+ // keyboard types). A space alone is not a separator: see splitNumbers.
67
+ const LIST_SEPARATORS = /[,;،؛\r\n\t]+/;
68
+ // A piece that reads as one number written with spaces (as copied from phone contacts).
69
+ const SPACED_NUMBER = /^\+?[0-9٠-٩۰-۹()\-\s]+$/;
70
+
71
+ /**
72
+ * Splits a list given as text or as an array, the same way the Corbit SMS app does.
73
+ * "+966 50 123 4567" stays one number; "0501234567 0509876543" becomes two, because a
74
+ * piece is split on its spaces only when it is not a number once the spaces are removed.
75
+ */
63
76
  function splitNumbers(value) {
64
77
  if (Array.isArray(value)) return value.flatMap((v) => splitNumbers(v));
65
78
  if (value === null || value === undefined) return [];
66
79
  if (typeof value === 'number') return [value];
67
- return String(value)
68
- .split(/[,;\r\n]+/)
69
- .map((v) => v.trim())
70
- .filter((v) => v !== '');
80
+ const tokens = [];
81
+ for (const piece of String(value).split(LIST_SEPARATORS)) {
82
+ const p = piece.trim();
83
+ if (p === '') continue;
84
+ if (SPACED_NUMBER.test(p)) {
85
+ const joined = p.replace(/\s+/g, '');
86
+ if (normalizeNumber(joined)) {
87
+ tokens.push(joined);
88
+ continue;
89
+ }
90
+ }
91
+ tokens.push(...p.split(/\s+/).filter((t) => t !== ''));
92
+ }
93
+ return tokens;
71
94
  }
72
95
 
73
96
  /** Checks the SMS text and returns it as a string (numbers, e.g. an OTP, are converted). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corbit2/node-red-corbit-sms",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Node-RED node for Corbit SMS: send SMS (single and bulk), check delivery status and reports, read the balance and sender names.",
5
5
  "license": "MIT",
6
6
  "author": {