nofax 0.2.12 → 0.2.14
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 +1 -1
- package/src/mcp-server.mjs +1 -1
- package/src/protocol.mjs +47 -5
package/package.json
CHANGED
package/src/mcp-server.mjs
CHANGED
|
@@ -74,7 +74,7 @@ const LIST_PENDING_OUTPUT_SCHEMA = z.object({
|
|
|
74
74
|
|
|
75
75
|
export function buildMcpServer({ handlers = createMcpToolHandlers() } = {}) {
|
|
76
76
|
const server = new McpServer(
|
|
77
|
-
{ name: 'nofax', version: '0.2.
|
|
77
|
+
{ name: 'nofax', version: '0.2.14' },
|
|
78
78
|
{ instructions: SERVER_INSTRUCTIONS }
|
|
79
79
|
);
|
|
80
80
|
|
package/src/protocol.mjs
CHANGED
|
@@ -9,10 +9,40 @@ const MAX_SUMMARY = 2200;
|
|
|
9
9
|
const MAX_RESPONSE_TEXT = 2000;
|
|
10
10
|
|
|
11
11
|
function normalizeSecretKeyName(key) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
let normalized = '';
|
|
13
|
+
|
|
14
|
+
for (let index = 0; index < key.length; index += 1) {
|
|
15
|
+
const char = key[index];
|
|
16
|
+
const code = char.charCodeAt(0);
|
|
17
|
+
const isUpper = code >= 65 && code <= 90;
|
|
18
|
+
const isLower = code >= 97 && code <= 122;
|
|
19
|
+
const isDigit = code >= 48 && code <= 57;
|
|
20
|
+
|
|
21
|
+
if (!isUpper && !isLower && !isDigit) {
|
|
22
|
+
if (normalized && !normalized.endsWith('_')) normalized += '_';
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const previousCode = index > 0 ? key.charCodeAt(index - 1) : -1;
|
|
27
|
+
const nextCode = index + 1 < key.length ? key.charCodeAt(index + 1) : -1;
|
|
28
|
+
const previousIsUpper = previousCode >= 65 && previousCode <= 90;
|
|
29
|
+
const previousIsLower = previousCode >= 97 && previousCode <= 122;
|
|
30
|
+
const previousIsDigit = previousCode >= 48 && previousCode <= 57;
|
|
31
|
+
const nextIsLower = nextCode >= 97 && nextCode <= 122;
|
|
32
|
+
|
|
33
|
+
if (
|
|
34
|
+
isUpper
|
|
35
|
+
&& normalized
|
|
36
|
+
&& !normalized.endsWith('_')
|
|
37
|
+
&& (previousIsLower || previousIsDigit || (previousIsUpper && nextIsLower))
|
|
38
|
+
) {
|
|
39
|
+
normalized += '_';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
normalized += char;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return normalized;
|
|
16
46
|
}
|
|
17
47
|
|
|
18
48
|
function isSecretKey(key) {
|
|
@@ -130,12 +160,24 @@ export function redactAndBound(value, options = {}) {
|
|
|
130
160
|
seen.add(value);
|
|
131
161
|
|
|
132
162
|
if (Array.isArray(value)) {
|
|
163
|
+
if (value.length === 2 && typeof value[0] === 'string' && isSecretKey(value[0])) {
|
|
164
|
+
return [boundString(value[0]), '[REDACTED]'];
|
|
165
|
+
}
|
|
133
166
|
return value.slice(0, MAX_ARRAY).map((item) => redactAndBound(item, { seen, depth: depth + 1 }));
|
|
134
167
|
}
|
|
135
168
|
|
|
169
|
+
const entryName = typeof value.name === 'string'
|
|
170
|
+
? value.name
|
|
171
|
+
: typeof value.key === 'string'
|
|
172
|
+
? value.key
|
|
173
|
+
: null;
|
|
174
|
+
const redactEntryValue = entryName !== null
|
|
175
|
+
&& Object.prototype.hasOwnProperty.call(value, 'value')
|
|
176
|
+
&& isSecretKey(entryName);
|
|
177
|
+
|
|
136
178
|
const out = {};
|
|
137
179
|
for (const [key, child] of Object.entries(value).slice(0, MAX_OBJECT_KEYS)) {
|
|
138
|
-
out[key] = isSecretKey(key)
|
|
180
|
+
out[key] = isSecretKey(key) || (redactEntryValue && key === 'value')
|
|
139
181
|
? '[REDACTED]'
|
|
140
182
|
: redactAndBound(child, { seen, depth: depth + 1 });
|
|
141
183
|
}
|