maka-agent 0.2.0-dev.64.20260929 → 0.2.0-dev.67.20261002
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/LICENSE +1 -1
- package/THIRD_PARTY_NOTICES.txt +3 -3
- package/dist/pi-tui-runner.js +26 -29
- package/dist/tui-copy-catalog.js +9 -9
- package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/settings.js +2 -2
- package/node_modules/@maka/core/dist/tool-ledger-scanner.js +53 -150
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +8 -1
- package/node_modules/@maka/runtime/dist/conversation-copy.js +6 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +17 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +25 -40
- package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +79 -13
- package/node_modules/@maka/runtime/dist/stream-graph-projection.js +64 -0
- package/node_modules/@maka/runtime/dist/stream-graph-read-model.js +138 -20
- package/node_modules/@maka/runtime/dist/tool-availability.js +10 -3
- package/node_modules/@maka/runtime-host/dist/candidate-entry.js +15 -0
- package/node_modules/@maka/runtime-host/dist/candidate-startup-failure.js +5 -0
- package/node_modules/@maka/runtime-host/dist/client/session-catalog-summary.js +1 -0
- package/node_modules/@maka/runtime-host/dist/client/startup-error.js +5 -0
- package/node_modules/@maka/runtime-host/dist/protocol/agent-graph.js +46 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +14 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +12 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-retirement.js +46 -10
- package/node_modules/@maka/runtime-host/dist/protocol/storage-usage.js +155 -0
- package/node_modules/@maka/runtime-host/dist/server/agent-graph-coordinator.js +23 -0
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +5 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +27 -6
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +112 -36
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +27 -1
- package/node_modules/@maka/runtime-host/dist/server/storage-usage-coordinator.js +67 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-inspection-tool.js +208 -0
- package/node_modules/@maka/storage/dist/git-worktree-child-executor.js +3 -1
- package/node_modules/@maka/storage/dist/operational-state-store.js +0 -13
- package/node_modules/@maka/storage/dist/session-store.js +9 -6
- package/node_modules/@maka/storage/dist/sqlite-file-set.js +22 -0
- package/node_modules/@maka/storage/dist/sqlite-long-term-memory-store.js +1 -3
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +10 -260
- package/node_modules/@maka/storage/dist/sqlite-session-catalog-query.js +1 -0
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +18 -6
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +28 -6
- package/node_modules/@maka/storage/dist/storage-footprint.js +239 -0
- package/node_modules/@maka/storage/dist/storage-writer-composition.js +10 -1
- package/node_modules/axios/CHANGELOG.md +62 -0
- package/node_modules/axios/README.md +297 -5
- package/node_modules/axios/dist/axios.js +728 -170
- package/node_modules/axios/dist/axios.min.js +3 -3
- package/node_modules/axios/dist/browser/axios.cjs +871 -188
- package/node_modules/axios/dist/esm/axios.js +871 -188
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/node/axios.cjs +1037 -225
- package/node_modules/axios/lib/adapters/fetch.js +64 -11
- package/node_modules/axios/lib/adapters/http.js +140 -67
- package/node_modules/axios/lib/adapters/xhr.js +52 -3
- package/node_modules/axios/lib/core/Axios.js +43 -20
- package/node_modules/axios/lib/core/AxiosError.js +33 -2
- package/node_modules/axios/lib/core/AxiosHeaders.js +124 -1
- package/node_modules/axios/lib/core/InterceptorManager.js +107 -8
- package/node_modules/axios/lib/core/buildFullPath.js +41 -15
- package/node_modules/axios/lib/core/dispatchRequest.js +8 -2
- package/node_modules/axios/lib/core/mergeConfig.js +19 -4
- package/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/axios/lib/core/setFormDataHeaders.js +27 -0
- package/node_modules/axios/lib/defaults/index.js +2 -1
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +12 -1
- package/node_modules/axios/lib/helpers/combineURLs.js +11 -3
- package/node_modules/axios/lib/helpers/composeSignals.js +12 -1
- package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +115 -54
- package/node_modules/axios/lib/helpers/formDataToJSON.js +11 -5
- package/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
- package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +5 -3
- package/node_modules/axios/lib/helpers/progressEventReducer.js +4 -4
- package/node_modules/axios/lib/helpers/resolveConfig.js +5 -17
- package/node_modules/axios/lib/helpers/shouldBypassProxy.js +300 -5
- package/node_modules/axios/lib/helpers/throttle.js +3 -2
- package/node_modules/axios/lib/helpers/toFormData.js +17 -23
- package/node_modules/axios/lib/platform/node/classes/Buffer.js +11 -0
- package/node_modules/axios/lib/utils.js +151 -18
- package/node_modules/axios/package.json +21 -19
- package/node_modules/brace-expansion/dist/commonjs/index.js +69 -25
- package/node_modules/brace-expansion/dist/esm/index.js +68 -24
- package/node_modules/brace-expansion/package.json +2 -1
- package/node_modules/fast-uri/index.js +10 -6
- package/node_modules/fast-uri/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
const LOOPBACK_HOSTNAMES = new Set(['localhost', '0.0.0.0']);
|
|
2
2
|
|
|
3
|
+
const trimTrailingDots = (value) => {
|
|
4
|
+
let end = value.length;
|
|
5
|
+
|
|
6
|
+
while (end && value.charCodeAt(end - 1) === 46) {
|
|
7
|
+
end--;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return end === value.length ? value : value.slice(0, end);
|
|
11
|
+
};
|
|
12
|
+
|
|
3
13
|
const isIPv4Loopback = (host) => {
|
|
4
14
|
const parts = host.split('.');
|
|
5
15
|
if (parts.length !== 4) return false;
|
|
@@ -7,6 +17,112 @@ const isIPv4Loopback = (host) => {
|
|
|
7
17
|
return parts.every((p) => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
|
|
8
18
|
};
|
|
9
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Canonicalize an IPv4 address written in shorthand, octal, or hex form into
|
|
22
|
+
* dotted-decimal. IPv6 addresses and non-IP strings are returned unchanged so
|
|
23
|
+
* the existing IPv4-mapped IPv6 unmap path and the isLoopback path can still
|
|
24
|
+
* see them.
|
|
25
|
+
*
|
|
26
|
+
* Shorthand expansion mirrors Node's URL parser: literal parts fill from the
|
|
27
|
+
* left, the final part fills the remaining octets from the right with
|
|
28
|
+
* zero-padding on the left.
|
|
29
|
+
* 127.1 -> 127.0.0.1
|
|
30
|
+
* 127.0.1 -> 127.0.0.1
|
|
31
|
+
* 1.2.3 -> 1.2.0.3
|
|
32
|
+
*
|
|
33
|
+
* Each octet is parsed with an explicit base: 16 for `0x`/`0X` prefix, 8 for
|
|
34
|
+
* zero-prefixed multi-digit all-`0-7` parts, 10 otherwise. Zero-prefixed
|
|
35
|
+
* decimal-looking parts that contain `8` or `9` are rejected to match Node's
|
|
36
|
+
* URL parser, and the comparison layer falls through to non-bypass if either
|
|
37
|
+
* side rejects the form (fail-safe).
|
|
38
|
+
*
|
|
39
|
+
* Returns the input unchanged on any parse failure, out-of-range octet, or
|
|
40
|
+
* unusual shape (1-part, 5+ parts) so the comparison layer fails closed.
|
|
41
|
+
*/
|
|
42
|
+
const parseIPv4Octet = (text) => {
|
|
43
|
+
if (/^0[xX][0-9a-fA-F]+$/.test(text)) {
|
|
44
|
+
const n = parseInt(text.slice(2), 16);
|
|
45
|
+
return Number.isFinite(n) ? n : null;
|
|
46
|
+
}
|
|
47
|
+
if (text.length > 1 && /^0[0-7]+$/.test(text)) {
|
|
48
|
+
const n = parseInt(text, 8);
|
|
49
|
+
return Number.isFinite(n) ? n : null;
|
|
50
|
+
}
|
|
51
|
+
if (text.length > 1 && /^0[0-9]+$/.test(text)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (/^[0-9]+$/.test(text)) {
|
|
55
|
+
const n = parseInt(text, 10);
|
|
56
|
+
return Number.isFinite(n) ? n : null;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const normalizeIPAddress = (host) => {
|
|
62
|
+
if (typeof host !== 'string' || !host || host.indexOf(':') !== -1) {
|
|
63
|
+
return host;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let h = host;
|
|
67
|
+
if (h.charAt(0) === '[' && h.charAt(h.length - 1) === ']') {
|
|
68
|
+
h = h.slice(1, -1);
|
|
69
|
+
}
|
|
70
|
+
h = trimTrailingDots(h);
|
|
71
|
+
|
|
72
|
+
// Allowed characters for any IPv4 shape: digits, dot, 'x', 'X', hex digits.
|
|
73
|
+
if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
|
|
74
|
+
|
|
75
|
+
const parts = h.split('.');
|
|
76
|
+
|
|
77
|
+
// No part may be empty (e.g. "127..0.1" or "127.0.0."). Trailing dots are
|
|
78
|
+
// already stripped above; this guards against the empty-middle case.
|
|
79
|
+
if (parts.some((p) => p === '')) return host;
|
|
80
|
+
|
|
81
|
+
if (parts.length === 4) {
|
|
82
|
+
// Full IPv4 form: each part is an octet.
|
|
83
|
+
const octets = parts.map(parseIPv4Octet);
|
|
84
|
+
if (octets.some((n) => n === null || n < 0 || n > 255)) return host;
|
|
85
|
+
return octets.join('.');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (parts.length > 4) {
|
|
89
|
+
return host;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Shorthand: 1..3 parts. Node's URL parser treats a 1-part input as a 32-bit
|
|
93
|
+
// integer split into octets, which has surprising semantics (e.g. "127" ->
|
|
94
|
+
// "0.0.0.127"). Reject 1-part inputs to keep the helper predictable: the
|
|
95
|
+
// fail-safe returns the input unchanged and the comparison layer falls
|
|
96
|
+
// through to non-bypass.
|
|
97
|
+
if (parts.length === 1) return host;
|
|
98
|
+
|
|
99
|
+
// 2..3 parts: literal parts fill from the left, tail fills remaining octets
|
|
100
|
+
// from the right with zero-padding.
|
|
101
|
+
const literalOctets = parts.slice(0, -1);
|
|
102
|
+
const tail = parts[parts.length - 1];
|
|
103
|
+
const tailSlots = 4 - literalOctets.length;
|
|
104
|
+
|
|
105
|
+
// Tail is parsed as a full IPv4 number (hex/octal/decimal) and packed
|
|
106
|
+
// low-byte-right into the remaining octets, matching Node's URL parser.
|
|
107
|
+
// e.g. 127.65535 (tail 0xFFFF into 3 slots) -> 127.0.255.255;
|
|
108
|
+
// 127.0x00ff (tail 0xFF into 3 slots) -> 127.0.0.255;
|
|
109
|
+
// 127.0.65535 (tail 0xFFFF into 2 slots) -> 127.0.255.255.
|
|
110
|
+
const tailValue = parseIPv4Octet(tail);
|
|
111
|
+
if (tailValue === null) return host;
|
|
112
|
+
const maxTail = (1 << (8 * tailSlots)) - 1;
|
|
113
|
+
if (tailValue < 0 || tailValue > maxTail) return host;
|
|
114
|
+
|
|
115
|
+
const tailOctets = new Array(tailSlots).fill(0);
|
|
116
|
+
for (let i = tailSlots - 1, v = tailValue; i >= 0; i--, v >>= 8) {
|
|
117
|
+
tailOctets[i] = v & 0xff;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const literal = literalOctets.map(parseIPv4Octet);
|
|
121
|
+
if (literal.some((n) => n === null || n < 0 || n > 255)) return host;
|
|
122
|
+
|
|
123
|
+
return [...literal, ...tailOctets].join('.');
|
|
124
|
+
};
|
|
125
|
+
|
|
10
126
|
const isIPv6ZeroGroup = (group) => /^0{1,4}$/.test(group);
|
|
11
127
|
|
|
12
128
|
// The unspecified address (IPv4 0.0.0.0 / IPv6 ::) resolves to the local host
|
|
@@ -28,9 +144,7 @@ const isIPv6Unspecified = (host) => {
|
|
|
28
144
|
const explicitGroups = leftGroups.length + rightGroups.length;
|
|
29
145
|
|
|
30
146
|
return (
|
|
31
|
-
explicitGroups < 8 &&
|
|
32
|
-
leftGroups.every(isIPv6ZeroGroup) &&
|
|
33
|
-
rightGroups.every(isIPv6ZeroGroup)
|
|
147
|
+
explicitGroups < 8 && leftGroups.every(isIPv6ZeroGroup) && rightGroups.every(isIPv6ZeroGroup)
|
|
34
148
|
);
|
|
35
149
|
}
|
|
36
150
|
|
|
@@ -126,7 +240,8 @@ const parseNoProxyEntry = (entry) => {
|
|
|
126
240
|
// allowing the proxy-bypass policy to be circumvented by using the alternate
|
|
127
241
|
// representation. Returns the input unchanged when not IPv4-mapped.
|
|
128
242
|
const IPV4_MAPPED_DOTTED_RE = /^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:(\d+\.\d+\.\d+\.\d+)$/i;
|
|
129
|
-
const IPV4_MAPPED_HEX_RE =
|
|
243
|
+
const IPV4_MAPPED_HEX_RE =
|
|
244
|
+
/^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i;
|
|
130
245
|
|
|
131
246
|
const unmapIPv4MappedIPv6 = (host) => {
|
|
132
247
|
if (typeof host !== 'string' || host.indexOf(':') === -1) return host;
|
|
@@ -144,6 +259,57 @@ const unmapIPv4MappedIPv6 = (host) => {
|
|
|
144
259
|
return host;
|
|
145
260
|
};
|
|
146
261
|
|
|
262
|
+
const IPV4_OCTET_RE = /^(?:0|[1-9]\d{0,2})$/;
|
|
263
|
+
|
|
264
|
+
const ipv4ToBytes = (host) => {
|
|
265
|
+
const parts = host.split('.');
|
|
266
|
+
|
|
267
|
+
return parts.length === 4 &&
|
|
268
|
+
parts.every((part) => IPV4_OCTET_RE.test(part) && Number(part) <= 255)
|
|
269
|
+
? parts.map(Number)
|
|
270
|
+
: null;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const IPV6_GROUP_RE = /^[0-9a-f]{1,4}$/i;
|
|
274
|
+
|
|
275
|
+
const ipv6ToBytes = (host) => {
|
|
276
|
+
const halves = host.split('::');
|
|
277
|
+
|
|
278
|
+
if (halves.length > 2) {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const groups = halves[0] ? halves[0].split(':') : [];
|
|
283
|
+
|
|
284
|
+
if (halves.length === 2) {
|
|
285
|
+
const rear = halves[1] ? halves[1].split(':') : [];
|
|
286
|
+
const missing = 8 - groups.length - rear.length;
|
|
287
|
+
|
|
288
|
+
if (missing < 1) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
groups.push(...new Array(missing).fill('0'), ...rear);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE.test(group))) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return groups.flatMap((group) => {
|
|
300
|
+
const value = Number.parseInt(group, 16);
|
|
301
|
+
return [(value >> 8) & 0xff, value & 0xff];
|
|
302
|
+
});
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
const ipToBytes = (host) => {
|
|
306
|
+
if (typeof host !== 'string' || !host) {
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return host.indexOf(':') !== -1 ? ipv6ToBytes(host) : ipv4ToBytes(host);
|
|
311
|
+
};
|
|
312
|
+
|
|
147
313
|
const normalizeNoProxyHost = (hostname) => {
|
|
148
314
|
if (!hostname) {
|
|
149
315
|
return hostname;
|
|
@@ -153,7 +319,120 @@ const normalizeNoProxyHost = (hostname) => {
|
|
|
153
319
|
hostname = hostname.slice(1, -1);
|
|
154
320
|
}
|
|
155
321
|
|
|
156
|
-
|
|
322
|
+
const trimmed = trimTrailingDots(hostname);
|
|
323
|
+
|
|
324
|
+
// IPv4 shorthand/octal/hex → dotted-decimal; helper is a no-op for inputs
|
|
325
|
+
// containing ':' (IPv6 and IPv4-mapped IPv6) so we fall through to unmap.
|
|
326
|
+
const ipv4 = normalizeIPAddress(trimmed);
|
|
327
|
+
if (ipv4 !== trimmed) {
|
|
328
|
+
return ipv4;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return unmapIPv4MappedIPv6(trimmed);
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
const normalizeCidrBase = (input) => {
|
|
335
|
+
let base = input;
|
|
336
|
+
const startsBracket = base.charAt(0) === '[';
|
|
337
|
+
const endsBracket = base.charAt(base.length - 1) === ']';
|
|
338
|
+
const hasBracket = base.includes('[') || base.includes(']');
|
|
339
|
+
|
|
340
|
+
if (startsBracket || endsBracket) {
|
|
341
|
+
if (!startsBracket || !endsBracket) {
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
base = base.slice(1, -1);
|
|
346
|
+
|
|
347
|
+
if (base.indexOf(':') === -1 || base.includes('[') || base.includes(']')) {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
} else if (hasBracket) {
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (!base || base.charAt(base.length - 1) === '.') {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const wasIPv6 = base.indexOf(':') !== -1;
|
|
359
|
+
|
|
360
|
+
if (wasIPv6) {
|
|
361
|
+
try {
|
|
362
|
+
base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
|
|
363
|
+
} catch (_err) {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
} else {
|
|
367
|
+
base = normalizeIPAddress(base);
|
|
368
|
+
|
|
369
|
+
if (!ipv4ToBytes(base)) {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return { normalized: unmapIPv4MappedIPv6(base), wasIPv6 };
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
const CIDR_ENTRY_RE = /^(.+)\/(0|[1-9]\d{0,2})$/;
|
|
378
|
+
|
|
379
|
+
const parseCidrEntry = (entry) => {
|
|
380
|
+
if (entry.indexOf('/') === -1) {
|
|
381
|
+
return undefined;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const match = CIDR_ENTRY_RE.exec(entry);
|
|
385
|
+
|
|
386
|
+
if (!match) {
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
let prefix = Number(match[2]);
|
|
391
|
+
const parsedBase = normalizeCidrBase(match[1]);
|
|
392
|
+
|
|
393
|
+
if (!parsedBase) {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const { normalized, wasIPv6 } = parsedBase;
|
|
398
|
+
|
|
399
|
+
if (wasIPv6 && normalized.indexOf(':') === -1) {
|
|
400
|
+
if (prefix < 96) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
prefix -= 96;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
const bytes = ipToBytes(normalized);
|
|
408
|
+
|
|
409
|
+
if (!bytes || prefix > bytes.length * 8) {
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return { bytes, prefix };
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
const isInSubnet = (addressBytes, networkBytes, prefix) => {
|
|
417
|
+
const fullBytes = prefix >> 3;
|
|
418
|
+
|
|
419
|
+
for (let i = 0; i < fullBytes; i++) {
|
|
420
|
+
if (addressBytes[i] !== networkBytes[i]) {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const remainingBits = prefix & 7;
|
|
426
|
+
|
|
427
|
+
if (remainingBits) {
|
|
428
|
+
const mask = (0xff << (8 - remainingBits)) & 0xff;
|
|
429
|
+
|
|
430
|
+
if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return true;
|
|
157
436
|
};
|
|
158
437
|
|
|
159
438
|
export default function shouldBypassProxy(location) {
|
|
@@ -179,12 +458,28 @@ export default function shouldBypassProxy(location) {
|
|
|
179
458
|
Number.parseInt(parsed.port, 10) || DEFAULT_PORTS[parsed.protocol.split(':', 1)[0]] || 0;
|
|
180
459
|
|
|
181
460
|
const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
|
|
461
|
+
const hostnameBytes = ipToBytes(hostname);
|
|
182
462
|
|
|
183
463
|
return noProxy.split(/[\s,]+/).some((entry) => {
|
|
184
464
|
if (!entry) {
|
|
185
465
|
return false;
|
|
186
466
|
}
|
|
187
467
|
|
|
468
|
+
if (entry === '*') {
|
|
469
|
+
return true;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
const cidr = parseCidrEntry(entry);
|
|
473
|
+
|
|
474
|
+
if (cidr !== undefined) {
|
|
475
|
+
return (
|
|
476
|
+
cidr !== null &&
|
|
477
|
+
!!hostnameBytes &&
|
|
478
|
+
hostnameBytes.length === cidr.bytes.length &&
|
|
479
|
+
isInSubnet(hostnameBytes, cidr.bytes, cidr.prefix)
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
|
|
188
483
|
let [entryHost, entryPort] = parseNoProxyEntry(entry);
|
|
189
484
|
|
|
190
485
|
entryHost = normalizeNoProxyHost(entryHost);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Throttle decorator
|
|
3
3
|
* @param {Function} fn
|
|
4
4
|
* @param {Number} freq
|
|
5
|
-
* @return {Function}
|
|
5
|
+
* @return {Array<Function>}
|
|
6
6
|
*/
|
|
7
7
|
function throttle(fn, freq) {
|
|
8
8
|
let timestamp = 0;
|
|
@@ -37,8 +37,9 @@ function throttle(fn, freq) {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
const flush = () => lastArgs && invoke(lastArgs);
|
|
40
|
+
const flushWith = (...args) => invoke(args);
|
|
40
41
|
|
|
41
|
-
return [throttled, flush];
|
|
42
|
+
return [throttled, flush, flushWith];
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
export default throttle;
|
|
@@ -4,6 +4,7 @@ import utils from '../utils.js';
|
|
|
4
4
|
import AxiosError from '../core/AxiosError.js';
|
|
5
5
|
// temporary hotfix to avoid circular references until AxiosURLSearchParams is refactored
|
|
6
6
|
import PlatformFormData from '../platform/node/classes/FormData.js';
|
|
7
|
+
import PlatformBuffer from '../platform/node/classes/Buffer.js';
|
|
7
8
|
|
|
8
9
|
// Default nesting limit shared with the inverse transform (formDataToJSON) so
|
|
9
10
|
// the FormData <-> JSON round-trip stays symmetric.
|
|
@@ -98,28 +99,18 @@ function toFormData(obj, formData, options) {
|
|
|
98
99
|
// eslint-disable-next-line no-param-reassign
|
|
99
100
|
formData = formData || new (PlatformFormData || FormData)();
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
metaTokens: true,
|
|
106
|
-
dots: false,
|
|
107
|
-
indexes: false,
|
|
108
|
-
},
|
|
109
|
-
false,
|
|
110
|
-
function defined(option, source) {
|
|
111
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
112
|
-
return !utils.isUndefined(source[option]);
|
|
113
|
-
}
|
|
114
|
-
);
|
|
102
|
+
const option = (name, fallback) => {
|
|
103
|
+
const value = utils.getSafeProp(options, name);
|
|
104
|
+
return utils.isUndefined(value) ? fallback : value;
|
|
105
|
+
};
|
|
115
106
|
|
|
116
|
-
const metaTokens =
|
|
107
|
+
const metaTokens = option('metaTokens', true);
|
|
117
108
|
// eslint-disable-next-line no-use-before-define
|
|
118
|
-
const visitor =
|
|
119
|
-
const dots =
|
|
120
|
-
const indexes =
|
|
121
|
-
const _Blob =
|
|
122
|
-
const maxDepth =
|
|
109
|
+
const visitor = option('visitor') || defaultVisitor;
|
|
110
|
+
const dots = option('dots', false);
|
|
111
|
+
const indexes = option('indexes', false);
|
|
112
|
+
const _Blob = option('Blob') || (typeof Blob !== 'undefined' && Blob);
|
|
113
|
+
const maxDepth = option('maxDepth', DEFAULT_FORM_DATA_MAX_DEPTH);
|
|
123
114
|
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
|
124
115
|
const stack = [];
|
|
125
116
|
|
|
@@ -146,10 +137,13 @@ function toFormData(obj, formData, options) {
|
|
|
146
137
|
if (useBlob && typeof _Blob === 'function') {
|
|
147
138
|
return new _Blob([value]);
|
|
148
139
|
}
|
|
149
|
-
if (
|
|
150
|
-
return
|
|
140
|
+
if (PlatformBuffer && PlatformBuffer.isBufferAvailable()) {
|
|
141
|
+
return PlatformBuffer.from(value);
|
|
151
142
|
}
|
|
152
|
-
throw new AxiosError(
|
|
143
|
+
throw new AxiosError(
|
|
144
|
+
'Blob is not supported. Use a Buffer instead.',
|
|
145
|
+
AxiosError.ERR_NOT_SUPPORT
|
|
146
|
+
);
|
|
153
147
|
}
|
|
154
148
|
|
|
155
149
|
return value;
|
|
@@ -15,12 +15,65 @@ const hasOwnProperty = (
|
|
|
15
15
|
hasOwnProperty.call(obj, prop)
|
|
16
16
|
)(Object.prototype);
|
|
17
17
|
|
|
18
|
+
const isUnsafeObjectKey = (prop) =>
|
|
19
|
+
typeof prop === 'string' &&
|
|
20
|
+
(prop === '__proto__' || prop === 'constructor' || prop === 'prototype');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Determine whether an inherited object must be treated as a shared-prototype
|
|
24
|
+
* boundary. Cross-realm Object.prototype objects cannot be distinguished
|
|
25
|
+
* reliably from application-created null-prototype objects because their
|
|
26
|
+
* properties are mutable, so all inherited terminal prototypes are excluded
|
|
27
|
+
* as a fail-closed boundary. A null-prototype source still keeps its own
|
|
28
|
+
* properties, as produced by mergeConfig and other safe materialization paths.
|
|
29
|
+
*
|
|
30
|
+
* @param {*} obj The object to inspect
|
|
31
|
+
* @param {*} prototype The object's prototype
|
|
32
|
+
* @param {boolean} source Whether obj is the original traversal source
|
|
33
|
+
*
|
|
34
|
+
* @returns {boolean} True when obj is a safe prototype traversal boundary
|
|
35
|
+
*/
|
|
36
|
+
const isPrototypeBoundary = (obj, prototype, source) =>
|
|
37
|
+
obj === Object.prototype || (!source && prototype === null);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Determine whether an object can retain its identity through code paths that
|
|
41
|
+
* add, replace, and remove config properties without bypassing unsafe-key
|
|
42
|
+
* filtering. Immutable objects, unsafe-key-bearing objects, and objects with
|
|
43
|
+
* accessor or restricted data properties must be materialized instead.
|
|
44
|
+
*
|
|
45
|
+
* @param {*} obj The object to inspect
|
|
46
|
+
*
|
|
47
|
+
* @returns {boolean} True when every own property is safe and fully mutable
|
|
48
|
+
*/
|
|
49
|
+
const isSafeAndFullyMutable = (obj) => {
|
|
50
|
+
if (!Object.isExtensible(obj)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const props = Object.getOwnPropertyNames(obj);
|
|
55
|
+
|
|
56
|
+
if (Object.getOwnPropertySymbols) {
|
|
57
|
+
props.push(...Object.getOwnPropertySymbols(obj));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return props.every((prop) => {
|
|
61
|
+
if (isUnsafeObjectKey(prop)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
|
66
|
+
|
|
67
|
+
return !!descriptor && descriptor.configurable && descriptor.writable === true;
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
|
|
18
71
|
/**
|
|
19
|
-
* Walk the prototype chain (excluding the
|
|
20
|
-
* an own `prop`. This distinguishes genuine own/inherited members
|
|
21
|
-
* class accessors and template prototypes — from members injected
|
|
22
|
-
* Object.prototype pollution (e.g. `Object.prototype.username = '...'`),
|
|
23
|
-
* live on Object.prototype itself and are therefore never matched.
|
|
72
|
+
* Walk the prototype chain (excluding the source realm's Object.prototype)
|
|
73
|
+
* looking for an own `prop`. This distinguishes genuine own/inherited members
|
|
74
|
+
* — including class accessors and template prototypes — from members injected
|
|
75
|
+
* via Object.prototype pollution (e.g. `Object.prototype.username = '...'`),
|
|
76
|
+
* which live on Object.prototype itself and are therefore never matched.
|
|
24
77
|
*
|
|
25
78
|
* @param {*} thing The value whose chain to inspect
|
|
26
79
|
* @param {string|symbol} prop The property key to look for
|
|
@@ -31,16 +84,22 @@ const hasOwnInPrototypeChain = (thing, prop) => {
|
|
|
31
84
|
let obj = thing;
|
|
32
85
|
const seen = [];
|
|
33
86
|
|
|
34
|
-
while (obj != null
|
|
87
|
+
while (obj != null) {
|
|
35
88
|
if (seen.indexOf(obj) !== -1) {
|
|
36
89
|
return false;
|
|
37
90
|
}
|
|
38
91
|
seen.push(obj);
|
|
39
92
|
|
|
93
|
+
const prototype = getPrototypeOf(obj);
|
|
94
|
+
|
|
95
|
+
if (isPrototypeBoundary(obj, prototype, obj === thing)) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
|
|
40
99
|
if (hasOwnProperty(obj, prop)) {
|
|
41
100
|
return true;
|
|
42
101
|
}
|
|
43
|
-
obj =
|
|
102
|
+
obj = prototype;
|
|
44
103
|
}
|
|
45
104
|
return false;
|
|
46
105
|
};
|
|
@@ -59,6 +118,69 @@ const hasOwnInPrototypeChain = (thing, prop) => {
|
|
|
59
118
|
const getSafeProp = (obj, prop) =>
|
|
60
119
|
obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
|
|
61
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Flatten an object and its application-defined prototype chain into a
|
|
123
|
+
* null-prototype object. Members inherited only from the source realm's
|
|
124
|
+
* Object.prototype are deliberately excluded, while class/template members
|
|
125
|
+
* below that boundary are preserved.
|
|
126
|
+
*
|
|
127
|
+
* @param {*} thing The value to flatten
|
|
128
|
+
*
|
|
129
|
+
* @returns {*} A null-prototype copy, or the original value when it is already
|
|
130
|
+
* structurally safe or is not an object
|
|
131
|
+
*/
|
|
132
|
+
const toSafeFlatObject = (thing) => {
|
|
133
|
+
if (thing == null || (typeof thing !== 'object' && typeof thing !== 'function')) {
|
|
134
|
+
return thing;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const sourcePrototype = getPrototypeOf(thing);
|
|
138
|
+
|
|
139
|
+
if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
|
|
140
|
+
return thing;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const result = Object.create(null);
|
|
144
|
+
const merged = Object.create(null);
|
|
145
|
+
const seen = [];
|
|
146
|
+
let current = thing;
|
|
147
|
+
|
|
148
|
+
while (current != null) {
|
|
149
|
+
if (seen.indexOf(current) !== -1) {
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
seen.push(current);
|
|
154
|
+
|
|
155
|
+
const prototype = current === thing ? sourcePrototype : getPrototypeOf(current);
|
|
156
|
+
|
|
157
|
+
if (isPrototypeBoundary(current, prototype, current === thing)) {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const props = Object.getOwnPropertyNames(current);
|
|
162
|
+
|
|
163
|
+
if (Object.getOwnPropertySymbols) {
|
|
164
|
+
props.push(...Object.getOwnPropertySymbols(current));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
for (const prop of props) {
|
|
168
|
+
if (isUnsafeObjectKey(prop)) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (!hasOwnProperty(merged, prop)) {
|
|
173
|
+
result[prop] = thing[prop];
|
|
174
|
+
merged[prop] = true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
current = prototype;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return result;
|
|
182
|
+
};
|
|
183
|
+
|
|
62
184
|
const kindOf = ((cache) => (thing) => {
|
|
63
185
|
const str = toString.call(thing);
|
|
64
186
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
@@ -190,12 +312,10 @@ const isPlainObject = (val) => {
|
|
|
190
312
|
|
|
191
313
|
const prototype = getPrototypeOf(val);
|
|
192
314
|
return (
|
|
193
|
-
(prototype === null ||
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
//
|
|
197
|
-
// Symbol.iterator as evidence the value is a tagged/iterable type rather
|
|
198
|
-
// than a plain object, while ignoring keys injected onto Object.prototype.
|
|
315
|
+
(prototype === null || prototype === Object.prototype || getPrototypeOf(prototype) === null) &&
|
|
316
|
+
// Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
|
|
317
|
+
// evidence the value is tagged/iterable, while ignoring members reachable
|
|
318
|
+
// only through shared or terminal prototype boundaries.
|
|
199
319
|
!hasOwnInPrototypeChain(val, toStringTag) &&
|
|
200
320
|
!hasOwnInPrototypeChain(val, iterator)
|
|
201
321
|
);
|
|
@@ -282,6 +402,7 @@ const isBlob = kindOfTest('Blob');
|
|
|
282
402
|
* @returns {boolean} True if value is a FileList, otherwise false
|
|
283
403
|
*/
|
|
284
404
|
const isFileList = kindOfTest('FileList');
|
|
405
|
+
const isSet = kindOfTest('Set');
|
|
285
406
|
|
|
286
407
|
/**
|
|
287
408
|
* Determine if a value is a Stream
|
|
@@ -847,12 +968,23 @@ const toJSONObject = (obj) => {
|
|
|
847
968
|
if (!('toJSON' in source)) {
|
|
848
969
|
// add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
|
|
849
970
|
visited.add(source);
|
|
850
|
-
const target = isArray(source) ? [] : {};
|
|
851
971
|
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
972
|
+
let target;
|
|
973
|
+
|
|
974
|
+
if (isSet(source)) {
|
|
975
|
+
target = [];
|
|
976
|
+
for (const value of source) {
|
|
977
|
+
const reducedValue = visit(value);
|
|
978
|
+
!isUndefined(reducedValue) && target.push(reducedValue);
|
|
979
|
+
}
|
|
980
|
+
} else {
|
|
981
|
+
target = isArray(source) ? [] : {};
|
|
982
|
+
|
|
983
|
+
forEach(source, (value, key) => {
|
|
984
|
+
const reducedValue = visit(value);
|
|
985
|
+
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
986
|
+
});
|
|
987
|
+
}
|
|
856
988
|
|
|
857
989
|
visited.delete(source);
|
|
858
990
|
|
|
@@ -997,6 +1129,7 @@ export default {
|
|
|
997
1129
|
hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
|
|
998
1130
|
hasOwnInPrototypeChain,
|
|
999
1131
|
getSafeProp,
|
|
1132
|
+
toSafeFlatObject,
|
|
1000
1133
|
reduceDescriptors,
|
|
1001
1134
|
freezeMethods,
|
|
1002
1135
|
toObjectSet,
|