@moneypot/hub 1.16.0-dev.4 → 1.16.0-dev.5

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.
@@ -12,7 +12,8 @@ const InputSchema = z.object({
12
12
  .string()
13
13
  .transform(normalizeUserMessageBody)
14
14
  .refine((body) => body.length > 0, "Body is required")
15
- .refine((body) => body.length <= 140, `Max body length: 140 chars`),
15
+ .refine((body) => body.length <= 140, `Max body length: 140 chars`)
16
+ .refine(onlyContainsValidCharacters, "Invalid characters detected"),
16
17
  });
17
18
  const RATE_LIMITS = [
18
19
  {
@@ -225,7 +226,35 @@ function normalizeUserMessageBody(body) {
225
226
  return (body
226
227
  .normalize("NFC")
227
228
  .replace(/(\p{M}{1,2})\p{M}+/gu, "$1")
228
- .replace(/[\u200B-\u200D\uFEFF]/g, "")
229
229
  .replace(/\s+/g, " ")
230
230
  .trim());
231
231
  }
232
+ function onlyContainsValidCharacters(body) {
233
+ for (let i = 0; i < body.length; i++) {
234
+ const code = body.charCodeAt(i);
235
+ if (code >= 32 && code <= 126)
236
+ continue;
237
+ if (code >= 128 && code <= 255)
238
+ continue;
239
+ if (code === 9 || code === 10 || code === 13)
240
+ continue;
241
+ const codePoint = body.codePointAt(i);
242
+ if (codePoint === undefined)
243
+ return false;
244
+ if (codePoint > 0xffff)
245
+ i++;
246
+ if ((codePoint >= 0x1f300 && codePoint <= 0x1f9ff) ||
247
+ (codePoint >= 0x2600 && codePoint <= 0x26ff) ||
248
+ (codePoint >= 0x2700 && codePoint <= 0x27bf) ||
249
+ (codePoint >= 0xfe00 && codePoint <= 0xfe0f) ||
250
+ (codePoint >= 0x1f600 && codePoint <= 0x1f64f) ||
251
+ (codePoint >= 0x1f680 && codePoint <= 0x1f6ff) ||
252
+ (codePoint >= 0x1f1e6 && codePoint <= 0x1f1ff) ||
253
+ (codePoint >= 0x200d && codePoint <= 0x200d) ||
254
+ (codePoint >= 0x20e3 && codePoint <= 0x20e3)) {
255
+ continue;
256
+ }
257
+ return false;
258
+ }
259
+ return true;
260
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneypot/hub",
3
- "version": "1.16.0-dev.4",
3
+ "version": "1.16.0-dev.5",
4
4
  "author": "moneypot.com",
5
5
  "homepage": "https://moneypot.com/hub",
6
6
  "keywords": [