@curless/hotel-storefront 0.61.0 → 0.61.1

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.
@@ -0,0 +1,96 @@
1
+ // WHAT THE BACKEND SAID WHEN IT SAID NO (0.61.1, questions #55): the mall's
2
+ // `/member/*` and the backend's `/ota/*` answer "Password cannot be empty",
3
+ // "wrong password" and "user name taken" all as `code: 500` - only their `msg`
4
+ // tells them apart. It goes on the failure (`said`), into the log line, and
5
+ // onto the page as they wrote it (robin: 供应方原文照原样显示) - so it is cleaned
6
+ // here first, once:
7
+ //
8
+ // - one line: newlines and tabs become a space; control, zero-width and bidi
9
+ // characters go;
10
+ // - at most 120 characters;
11
+ // - ⚠️ WHAT WE SENT IS NOT IN IT: a user name, email, phone or name the request
12
+ // carried is replaced by "…" wherever it appears; and a message that holds a
13
+ // password or a token is not kept at all - not even with that part hidden, as
14
+ // where the "…" sits would tell what was there.
15
+ export const SAID_MAX = 120;
16
+ const gone = (c) => c < 0x20 ||
17
+ (c >= 0x7f && c <= 0x9f) ||
18
+ (c >= 0x200b && c <= 0x200f) ||
19
+ (c >= 0x202a && c <= 0x202e) ||
20
+ (c >= 0x2066 && c <= 0x2069) ||
21
+ c === 0x2028 ||
22
+ c === 0x2029 ||
23
+ c === 0xfeff;
24
+ const spaced = (c) => c === 0x09 || c === 0x0a || c === 0x0d || c === 0x2028 || c === 0x2029;
25
+ /** One line with nothing invisible in it: a line break is a space, the rest goes. */
26
+ const flat = (s) => Array.from(s)
27
+ .map((ch) => {
28
+ const c = ch.codePointAt(0) ?? 0;
29
+ return spaced(c) ? ' ' : gone(c) ? '' : ch;
30
+ })
31
+ .join('');
32
+ const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
33
+ const hasIn = (s, v) => new RegExp(escapeRe(v), 'iu').test(s);
34
+ /**
35
+ * The forms a value we sent may come back in: as sent, an email's name before
36
+ * its "@", a phone's digits on their own.
37
+ */
38
+ const formsOf = (v) => {
39
+ const out = [v];
40
+ const at = v.lastIndexOf('@');
41
+ if (at > 0)
42
+ out.push(v.slice(0, at));
43
+ if (/^[+\d\s().-]+$/.test(v)) {
44
+ const digits = v.replace(/\D/g, '');
45
+ if (digits.length >= 6)
46
+ out.push(digits);
47
+ }
48
+ return out;
49
+ };
50
+ /**
51
+ * Values worth looking for: a name of one character says nothing of anyone, and
52
+ * a password of one or two would hide every message it happens to be in.
53
+ */
54
+ const usable = (vs, min) => vs.map((v) => flat(String(v ?? '')).trim()).filter((v) => Array.from(v).length >= min);
55
+ /**
56
+ * The backend's `msg`, cleaned for a log line and a page - or undefined when
57
+ * there is none, or when it carries a secret we sent.
58
+ *
59
+ * @param shown what the request carried that names someone (user name, email,
60
+ * phone, name): replaced by "…".
61
+ * @param secret what it carried that must never be written (password, tokens):
62
+ * the message is dropped whole.
63
+ */
64
+ export const saidOf = (msg, shown = [], secret = []) => {
65
+ if (typeof msg !== 'string')
66
+ return undefined;
67
+ // A message far longer than we keep is cut first, with room for a value
68
+ // across the cut - which the last cut below takes off anyway.
69
+ let s = flat(msg.slice(0, 4000));
70
+ for (const v of usable(secret, 3))
71
+ if (hasIn(s, v))
72
+ return undefined;
73
+ const names = usable(shown, 2)
74
+ .flatMap(formsOf)
75
+ .filter((v) => Array.from(v).length >= 2)
76
+ // The longest first: an email before the user name inside it.
77
+ .sort((a, b) => b.length - a.length);
78
+ for (const v of names)
79
+ s = s.replace(new RegExp(escapeRe(v), 'giu'), '…');
80
+ s = s.replace(/\s+/g, ' ').trim();
81
+ if (!s)
82
+ return undefined;
83
+ const chars = Array.from(s);
84
+ return chars.length > SAID_MAX ? `${chars.slice(0, SAID_MAX - 1).join('')}…` : s;
85
+ };
86
+ /** The `msg` of an answer's body, if it is JSON that has one. */
87
+ export const msgIn = (text) => {
88
+ try {
89
+ const p = JSON.parse(text);
90
+ return p && typeof p === 'object' ? p.msg : undefined;
91
+ }
92
+ catch {
93
+ return undefined;
94
+ }
95
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C,CAAC,CAAC,CAAC;IAC5B,OAAO,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC;AAEF,iEAAiE;AACjE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAW,EAAE;IAC7C,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY,CAAC;QACtC,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,CAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC"}
package/dist/server.d.ts CHANGED
@@ -29,7 +29,7 @@ export declare const INITIALIZE_PER_MINUTE = 300;
29
29
  * number. Found by reading the boot banner of a container that had just been
30
30
  * deployed (2026-09-22): seventeen tools listed, and "0.7.0" above them.
31
31
  */
32
- export declare const VERSION = "0.61.0";
32
+ export declare const VERSION = "0.61.1";
33
33
  /**
34
34
  * The card's resource URI.
35
35
  *
package/dist/server.js CHANGED
@@ -50,7 +50,7 @@ export const INITIALIZE_PER_MINUTE = 300;
50
50
  * number. Found by reading the boot banner of a container that had just been
51
51
  * deployed (2026-09-22): seventeen tools listed, and "0.7.0" above them.
52
52
  */
53
- export const VERSION = '0.61.0';
53
+ export const VERSION = '0.61.1';
54
54
  /**
55
55
  * The card's resource URI.
56
56
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curless/hotel-storefront",
3
- "version": "0.61.0",
3
+ "version": "0.61.1",
4
4
  "type": "module",
5
5
  "description": "One hotel-booking MCP connector, driven by a config file. Brand, tool names, vocabulary and where the rooms come from live in a HotelConfig, so the second hotel group is a JSON file rather than a fork.",
6
6
  "keywords": [