maka-agent 0.2.0-dev.64.20260929 → 0.2.0-dev.68.20261003
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/acp-executor-plugin/dist/acp-catalog.js +132 -0
- package/node_modules/@maka/acp-executor-plugin/dist/index.js +251 -113
- package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +431 -108
- package/node_modules/@maka/core/dist/executor-catalog.js +25 -3
- 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/admission-limiter.js +3 -2
- 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/plugin-data-services.js +7 -0
- package/node_modules/@maka/runtime/dist/plugin-executor-service.js +19 -3
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +17 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +26 -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/package.json +1 -0
- package/node_modules/@maka/runtime-host/dist/antigravity-program.js +49 -0
- 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 +16 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +8 -2
- 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/acp/antigravity.js +5 -19
- 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 +41 -9
- package/node_modules/@maka/runtime-host/dist/server/external-agent-setup-coordinator.js +3 -0
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-data-runtime.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-scratch-directory.js +55 -0
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +46 -6
- 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/runtime-host/package.json +1 -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
|
@@ -6,6 +6,7 @@ import InterceptorManager from './InterceptorManager.js';
|
|
|
6
6
|
import dispatchRequest from './dispatchRequest.js';
|
|
7
7
|
import mergeConfig from './mergeConfig.js';
|
|
8
8
|
import buildFullPath from './buildFullPath.js';
|
|
9
|
+
import methodList from './methodList.js';
|
|
9
10
|
import validator from '../helpers/validator.js';
|
|
10
11
|
import AxiosHeaders from './AxiosHeaders.js';
|
|
11
12
|
import transitionalDefaults from '../defaults/transitional.js';
|
|
@@ -41,21 +42,21 @@ class Axios {
|
|
|
41
42
|
return await this._request(configOrUrl, config);
|
|
42
43
|
} catch (err) {
|
|
43
44
|
if (err instanceof Error) {
|
|
44
|
-
|
|
45
|
+
try {
|
|
46
|
+
let dummy = {};
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (!dummy.stack) {
|
|
51
|
-
return '';
|
|
52
|
-
}
|
|
50
|
+
const dummyStack = dummy.stack;
|
|
51
|
+
let stack = '';
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
// slice off the Error: ... line
|
|
54
|
+
if (typeof dummyStack === 'string') {
|
|
55
|
+
const firstNewlineIndex = dummyStack.indexOf('\n');
|
|
56
|
+
|
|
57
|
+
stack = firstNewlineIndex === -1 ? '' : dummyStack.slice(firstNewlineIndex + 1);
|
|
58
|
+
}
|
|
55
59
|
|
|
56
|
-
return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
|
|
57
|
-
})();
|
|
58
|
-
try {
|
|
59
60
|
if (!err.stack) {
|
|
60
61
|
err.stack = stack;
|
|
61
62
|
// match without the 2 top stack lines
|
|
@@ -71,7 +72,7 @@ class Axios {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
} catch (e) {
|
|
74
|
-
//
|
|
75
|
+
// Ignore failures from custom stack hooks or un-writable stack properties.
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
|
|
@@ -144,13 +145,17 @@ class Axios {
|
|
|
144
145
|
);
|
|
145
146
|
|
|
146
147
|
// Set config.method
|
|
147
|
-
config.method = (
|
|
148
|
+
config.method = (
|
|
149
|
+
utils.getSafeProp(config, 'method') ||
|
|
150
|
+
utils.getSafeProp(this.defaults, 'method') ||
|
|
151
|
+
'get'
|
|
152
|
+
).toLowerCase();
|
|
148
153
|
|
|
149
154
|
// Flatten headers
|
|
150
155
|
let contextHeaders = headers && utils.merge(headers.common, headers[config.method]);
|
|
151
156
|
|
|
152
157
|
headers &&
|
|
153
|
-
utils.forEach(
|
|
158
|
+
utils.forEach(methodList.concat('common'), (method) => {
|
|
154
159
|
delete headers[method];
|
|
155
160
|
});
|
|
156
161
|
|
|
@@ -209,17 +214,35 @@ class Axios {
|
|
|
209
214
|
const onFulfilled = requestInterceptorChain[i++];
|
|
210
215
|
const onRejected = requestInterceptorChain[i++];
|
|
211
216
|
try {
|
|
212
|
-
newConfig = onFulfilled(newConfig);
|
|
217
|
+
newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
|
|
213
218
|
} catch (error) {
|
|
214
|
-
onRejected
|
|
219
|
+
if (!onRejected) {
|
|
220
|
+
promise = Promise.reject(error);
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
try {
|
|
225
|
+
const rejectedResult = onRejected.call(this, error);
|
|
226
|
+
|
|
227
|
+
if (utils.isThenable(rejectedResult)) {
|
|
228
|
+
promise = Promise.resolve(rejectedResult).then(() =>
|
|
229
|
+
dispatchRequest.call(this, newConfig)
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
} catch (rejectedError) {
|
|
233
|
+
promise = Promise.reject(rejectedError);
|
|
234
|
+
}
|
|
235
|
+
|
|
215
236
|
break;
|
|
216
237
|
}
|
|
217
238
|
}
|
|
218
239
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
240
|
+
if (!promise) {
|
|
241
|
+
try {
|
|
242
|
+
promise = dispatchRequest.call(this, newConfig);
|
|
243
|
+
} catch (error) {
|
|
244
|
+
promise = Promise.reject(error);
|
|
245
|
+
}
|
|
223
246
|
}
|
|
224
247
|
|
|
225
248
|
i = 0;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import utils from '../utils.js';
|
|
4
4
|
import AxiosHeaders from './AxiosHeaders.js';
|
|
5
5
|
|
|
6
|
-
const REDACTED = '[REDACTED ****]';
|
|
6
|
+
export const REDACTED = '[REDACTED ****]';
|
|
7
7
|
|
|
8
8
|
function hasOwnOrPrototypeToJSON(source) {
|
|
9
9
|
if (utils.hasOwnProp(source, 'toJSON')) {
|
|
@@ -72,9 +72,40 @@ function redactConfig(config, redactKeys) {
|
|
|
72
72
|
return visit(config);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
function stringifySafely(value) {
|
|
76
|
+
try {
|
|
77
|
+
return String(value);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
return '';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function aggregateErrorMessage(error) {
|
|
84
|
+
const message = error.errors
|
|
85
|
+
.map((entry) => {
|
|
86
|
+
try {
|
|
87
|
+
return entry && entry.message ? stringifySafely(entry.message) : stringifySafely(entry);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
return '';
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
.filter(Boolean)
|
|
93
|
+
.join('; ');
|
|
94
|
+
|
|
95
|
+
return message || error.name || 'AggregateError';
|
|
96
|
+
}
|
|
97
|
+
|
|
75
98
|
class AxiosError extends Error {
|
|
76
99
|
static from(error, code, config, request, response, customProps) {
|
|
77
|
-
|
|
100
|
+
// `AggregateError` (thrown by Node on dual-stack/Happy-Eyeballs connection
|
|
101
|
+
// failures) has an empty `message`; its detail lives in `errors[]`. Without
|
|
102
|
+
// this, the wrapped error surfaces with a blank message (see #6721).
|
|
103
|
+
let message = error.message;
|
|
104
|
+
if (!message && utils.isArray(error.errors) && error.errors.length) {
|
|
105
|
+
message = aggregateErrorMessage(error);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const axiosError = new AxiosError(message, code || error.code, config, request, response);
|
|
78
109
|
// Match native `Error` `cause` semantics: non-enumerable. The wrapped
|
|
79
110
|
// error often carries circular internals (sockets, requests, agents), so
|
|
80
111
|
// an enumerable `cause` makes structured loggers (pino/winston) and any
|
|
@@ -30,6 +30,124 @@ function parseTokens(str) {
|
|
|
30
30
|
return tokens;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
const parameterNameRE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
34
|
+
|
|
35
|
+
function trimOWS(value) {
|
|
36
|
+
let start = 0;
|
|
37
|
+
let end = value.length;
|
|
38
|
+
|
|
39
|
+
while (start < end) {
|
|
40
|
+
const code = value.charCodeAt(start);
|
|
41
|
+
|
|
42
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
start += 1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
while (end > start) {
|
|
50
|
+
const code = value.charCodeAt(end - 1);
|
|
51
|
+
|
|
52
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
end -= 1;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return start === 0 && end === value.length ? value : value.slice(start, end);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function decodeQuotedString(value) {
|
|
63
|
+
const last = value.length - 1;
|
|
64
|
+
|
|
65
|
+
if (last < 1 || value.charCodeAt(0) !== 0x22 || value.charCodeAt(last) !== 0x22) {
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let decoded = '';
|
|
70
|
+
|
|
71
|
+
for (let i = 1; i < last; i++) {
|
|
72
|
+
const code = value.charCodeAt(i);
|
|
73
|
+
|
|
74
|
+
if (code === 0x22) {
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (code === 0x5c) {
|
|
79
|
+
i += 1;
|
|
80
|
+
|
|
81
|
+
if (i >= last) {
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
decoded += value[i];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return decoded;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function parseParameters(value) {
|
|
93
|
+
const parameters = Object.create(null);
|
|
94
|
+
const str = String(value);
|
|
95
|
+
let start = 0;
|
|
96
|
+
let quoted = false;
|
|
97
|
+
let escaped = false;
|
|
98
|
+
|
|
99
|
+
function parseParameter(end) {
|
|
100
|
+
const part = trimOWS(str.slice(start, end));
|
|
101
|
+
const equals = part.indexOf('=');
|
|
102
|
+
|
|
103
|
+
if (equals < 1) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const name = trimOWS(part.slice(0, equals));
|
|
108
|
+
|
|
109
|
+
if (!parameterNameRE.test(name)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const normalizedName = name.toLowerCase();
|
|
114
|
+
|
|
115
|
+
if (
|
|
116
|
+
normalizedName === '__proto__' ||
|
|
117
|
+
normalizedName === 'constructor' ||
|
|
118
|
+
normalizedName === 'prototype'
|
|
119
|
+
) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const parameterValue = trimOWS(part.slice(equals + 1));
|
|
124
|
+
parameters[normalizedName] = decodeQuotedString(parameterValue);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
for (let i = 0; i < str.length; i++) {
|
|
128
|
+
const code = str.charCodeAt(i);
|
|
129
|
+
|
|
130
|
+
if (quoted) {
|
|
131
|
+
if (escaped) {
|
|
132
|
+
escaped = false;
|
|
133
|
+
} else if (code === 0x5c) {
|
|
134
|
+
escaped = true;
|
|
135
|
+
} else if (code === 0x22) {
|
|
136
|
+
quoted = false;
|
|
137
|
+
}
|
|
138
|
+
} else if (code === 0x22) {
|
|
139
|
+
quoted = true;
|
|
140
|
+
} else if (code === 0x2c || code === 0x3b) {
|
|
141
|
+
parseParameter(i);
|
|
142
|
+
start = i + 1;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
parseParameter(str.length);
|
|
147
|
+
|
|
148
|
+
return parameters;
|
|
149
|
+
}
|
|
150
|
+
|
|
33
151
|
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
34
152
|
|
|
35
153
|
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
@@ -281,7 +399,8 @@ class AxiosHeaders {
|
|
|
281
399
|
}
|
|
282
400
|
|
|
283
401
|
getSetCookie() {
|
|
284
|
-
|
|
402
|
+
const value = this.get('set-cookie');
|
|
403
|
+
return utils.isArray(value) ? value : value == null || value === false ? [] : [value];
|
|
285
404
|
}
|
|
286
405
|
|
|
287
406
|
get [Symbol.toStringTag]() {
|
|
@@ -292,6 +411,10 @@ class AxiosHeaders {
|
|
|
292
411
|
return thing instanceof this ? thing : new this(thing);
|
|
293
412
|
}
|
|
294
413
|
|
|
414
|
+
static parseParameters(value) {
|
|
415
|
+
return parseParameters(value);
|
|
416
|
+
}
|
|
417
|
+
|
|
295
418
|
static concat(first, ...targets) {
|
|
296
419
|
const computed = new this(first);
|
|
297
420
|
|
|
@@ -2,9 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
import utils from '../utils.js';
|
|
4
4
|
|
|
5
|
+
const $internals = Symbol('internals');
|
|
6
|
+
|
|
7
|
+
// `handlers` is public and may be replaced with a nullish value by user code;
|
|
8
|
+
// `clear()` has always tolerated that. Treat it as an empty stack rather than
|
|
9
|
+
// dereferencing it.
|
|
10
|
+
function countHandlers(handlers) {
|
|
11
|
+
return handlers ? handlers.length : 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function trimHandlers(handlers) {
|
|
15
|
+
if (!handlers) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
while (handlers.length && handlers[handlers.length - 1] === null) {
|
|
20
|
+
handlers.pop();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function syncHandlerEntries(manager, internals) {
|
|
25
|
+
const handlers = manager.handlers;
|
|
26
|
+
const length = countHandlers(handlers);
|
|
27
|
+
|
|
28
|
+
if (handlers !== internals.handlersRef) {
|
|
29
|
+
internals.handlersRef = handlers;
|
|
30
|
+
internals.handlerEntries.clear();
|
|
31
|
+
} else if (length !== internals.handlersLength) {
|
|
32
|
+
if (!length) {
|
|
33
|
+
internals.handlerEntries.clear();
|
|
34
|
+
} else {
|
|
35
|
+
internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
|
|
36
|
+
if (handlers[entry.index] !== entry.handler) {
|
|
37
|
+
internals.handlerEntries.delete(id);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
internals.handlersLength = length;
|
|
44
|
+
}
|
|
45
|
+
|
|
5
46
|
class InterceptorManager {
|
|
6
47
|
constructor() {
|
|
7
48
|
this.handlers = [];
|
|
49
|
+
this[$internals] = {
|
|
50
|
+
handlersRef: this.handlers,
|
|
51
|
+
handlersLength: this.handlers.length,
|
|
52
|
+
handlerEntries: new Map(),
|
|
53
|
+
iterationDepth: 0,
|
|
54
|
+
nextId: 0,
|
|
55
|
+
};
|
|
8
56
|
}
|
|
9
57
|
|
|
10
58
|
/**
|
|
@@ -17,13 +65,30 @@ class InterceptorManager {
|
|
|
17
65
|
* @return {Number} An ID used to remove interceptor later
|
|
18
66
|
*/
|
|
19
67
|
use(fulfilled, rejected, options) {
|
|
20
|
-
|
|
68
|
+
const handler = {
|
|
21
69
|
fulfilled,
|
|
22
70
|
rejected,
|
|
23
71
|
synchronous: options ? options.synchronous : false,
|
|
24
72
|
runWhen: options ? options.runWhen : null,
|
|
73
|
+
};
|
|
74
|
+
const internals = this[$internals];
|
|
75
|
+
|
|
76
|
+
if (this.handlers == null) {
|
|
77
|
+
this.handlers = [];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
syncHandlerEntries(this, internals);
|
|
81
|
+
|
|
82
|
+
const id = internals.nextId++;
|
|
83
|
+
|
|
84
|
+
this.handlers.push(handler);
|
|
85
|
+
internals.handlerEntries.set(id, {
|
|
86
|
+
handler,
|
|
87
|
+
index: this.handlers.length - 1,
|
|
25
88
|
});
|
|
26
|
-
|
|
89
|
+
internals.handlersLength = this.handlers.length;
|
|
90
|
+
|
|
91
|
+
return id;
|
|
27
92
|
}
|
|
28
93
|
|
|
29
94
|
/**
|
|
@@ -34,8 +99,27 @@ class InterceptorManager {
|
|
|
34
99
|
* @returns {void}
|
|
35
100
|
*/
|
|
36
101
|
eject(id) {
|
|
37
|
-
|
|
38
|
-
|
|
102
|
+
const internals = this[$internals];
|
|
103
|
+
|
|
104
|
+
syncHandlerEntries(this, internals);
|
|
105
|
+
|
|
106
|
+
const entry = internals.handlerEntries.get(id);
|
|
107
|
+
|
|
108
|
+
if (entry) {
|
|
109
|
+
internals.handlerEntries.delete(id);
|
|
110
|
+
|
|
111
|
+
// Ignore IDs invalidated by clear or direct replacement of handlers.
|
|
112
|
+
if (this.handlers[entry.index] !== entry.handler) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.handlers[entry.index] = null;
|
|
117
|
+
|
|
118
|
+
// Do not reuse an index while forEach is walking its length snapshot.
|
|
119
|
+
if (!internals.iterationDepth) {
|
|
120
|
+
trimHandlers(this.handlers);
|
|
121
|
+
internals.handlersLength = this.handlers.length;
|
|
122
|
+
}
|
|
39
123
|
}
|
|
40
124
|
}
|
|
41
125
|
|
|
@@ -47,6 +131,7 @@ class InterceptorManager {
|
|
|
47
131
|
clear() {
|
|
48
132
|
if (this.handlers) {
|
|
49
133
|
this.handlers = [];
|
|
134
|
+
syncHandlerEntries(this, this[$internals]);
|
|
50
135
|
}
|
|
51
136
|
}
|
|
52
137
|
|
|
@@ -61,11 +146,25 @@ class InterceptorManager {
|
|
|
61
146
|
* @returns {void}
|
|
62
147
|
*/
|
|
63
148
|
forEach(fn) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
149
|
+
const internals = this[$internals];
|
|
150
|
+
|
|
151
|
+
syncHandlerEntries(this, internals);
|
|
152
|
+
|
|
153
|
+
internals.iterationDepth++;
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
utils.forEach(this.handlers, function forEachHandler(h) {
|
|
157
|
+
if (h !== null) {
|
|
158
|
+
fn(h);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
} finally {
|
|
162
|
+
if (!--internals.iterationDepth) {
|
|
163
|
+
syncHandlerEntries(this, internals);
|
|
164
|
+
trimHandlers(this.handlers);
|
|
165
|
+
internals.handlersLength = countHandlers(this.handlers);
|
|
67
166
|
}
|
|
68
|
-
}
|
|
167
|
+
}
|
|
69
168
|
}
|
|
70
169
|
}
|
|
71
170
|
|
|
@@ -1,31 +1,57 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import AxiosError from './AxiosError.js';
|
|
3
|
+
import AxiosError, { REDACTED } from './AxiosError.js';
|
|
4
4
|
import isAbsoluteURL from '../helpers/isAbsoluteURL.js';
|
|
5
5
|
import combineURLs from '../helpers/combineURLs.js';
|
|
6
|
+
import normalizeURLForProtocolCheck from '../helpers/normalizeURLForProtocolCheck.js';
|
|
6
7
|
|
|
7
8
|
const malformedHttpProtocol = /^https?:(?!\/\/)/i;
|
|
8
|
-
const httpProtocolControlCharacters = /[\t\n\r]/g;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
// Redact the parts of a URL that can carry secrets before it is embedded in an
|
|
11
|
+
// error message. AxiosError.toJSON() serializes `message` verbatim and errors
|
|
12
|
+
// are commonly logged, while the opt-in `config.redact` model only cleans
|
|
13
|
+
// config keys — it cannot reach the message. Redact only the genuinely
|
|
14
|
+
// sensitive substrings — userinfo (credentials), query parameter values and
|
|
15
|
+
// fragment contents — with the same REDACTED marker the config redaction uses,
|
|
16
|
+
// while keeping the scheme, host, path and parameter names so the offending
|
|
17
|
+
// request stays accurately identifiable.
|
|
18
|
+
function redactFragment(fragment) {
|
|
19
|
+
if (!fragment) {
|
|
20
|
+
return fragment;
|
|
14
21
|
}
|
|
15
|
-
|
|
22
|
+
|
|
23
|
+
return fragment.replace(/(^|&)([^=&]*=)?[^&]+/g, (match, separator, parameterName = '') => {
|
|
24
|
+
return `${separator}${parameterName}${REDACTED}`;
|
|
25
|
+
});
|
|
16
26
|
}
|
|
17
27
|
|
|
18
|
-
function
|
|
19
|
-
|
|
28
|
+
function redactSensitiveURLParts(url) {
|
|
29
|
+
const redactedURL = url.replace(/^(https?:\/{0,2})[^/?#]*@/i, `$1${REDACTED}@`);
|
|
30
|
+
const fragmentIndex = redactedURL.indexOf('#');
|
|
31
|
+
const urlWithoutFragment =
|
|
32
|
+
fragmentIndex === -1 ? redactedURL : redactedURL.slice(0, fragmentIndex);
|
|
33
|
+
const redactedURLWithoutFragment = urlWithoutFragment.replace(
|
|
34
|
+
/([?&][^=&#]*=)[^&#]*/g,
|
|
35
|
+
`$1${REDACTED}`
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
if (fragmentIndex === -1) {
|
|
39
|
+
return redactedURLWithoutFragment;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return `${redactedURLWithoutFragment}#${redactFragment(redactedURL.slice(fragmentIndex + 1))}`;
|
|
20
43
|
}
|
|
21
44
|
|
|
22
45
|
function assertValidHttpProtocolURL(url, config) {
|
|
23
|
-
if (typeof url === 'string'
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
AxiosError
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
if (typeof url === 'string') {
|
|
47
|
+
const normalizedURL = normalizeURLForProtocolCheck(url);
|
|
48
|
+
if (malformedHttpProtocol.test(normalizedURL)) {
|
|
49
|
+
throw new AxiosError(
|
|
50
|
+
`Invalid URL ${JSON.stringify(redactSensitiveURLParts(normalizedURL))}: missing "//" after protocol`,
|
|
51
|
+
AxiosError.ERR_INVALID_URL,
|
|
52
|
+
config
|
|
53
|
+
);
|
|
54
|
+
}
|
|
29
55
|
}
|
|
30
56
|
}
|
|
31
57
|
|
|
@@ -6,6 +6,7 @@ import defaults from '../defaults/index.js';
|
|
|
6
6
|
import CanceledError from '../cancel/CanceledError.js';
|
|
7
7
|
import AxiosHeaders from '../core/AxiosHeaders.js';
|
|
8
8
|
import adapters from '../adapters/adapters.js';
|
|
9
|
+
import utils from '../utils.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Throws a `CanceledError` if cancellation has been requested.
|
|
@@ -31,10 +32,15 @@ function throwIfCancellationRequested(config) {
|
|
|
31
32
|
*
|
|
32
33
|
* @returns {Promise} The Promise to be fulfilled
|
|
33
34
|
*/
|
|
34
|
-
export default function dispatchRequest(
|
|
35
|
+
export default function dispatchRequest(_config) {
|
|
36
|
+
// Interceptors may replace the merged config with an ordinary object. Flatten
|
|
37
|
+
// it at the dispatch boundary so shared prototype members cannot become
|
|
38
|
+
// request behavior, while preserving intentional template/class members.
|
|
39
|
+
const config = utils.toSafeFlatObject(_config);
|
|
40
|
+
|
|
35
41
|
throwIfCancellationRequested(config);
|
|
36
42
|
|
|
37
|
-
config.headers = AxiosHeaders.from(config
|
|
43
|
+
config.headers = AxiosHeaders.from(utils.getSafeProp(config, 'headers'));
|
|
38
44
|
|
|
39
45
|
// Transform request data
|
|
40
46
|
config.data = transformData.call(config, config.transformRequest);
|
|
@@ -5,6 +5,17 @@ import AxiosHeaders from './AxiosHeaders.js';
|
|
|
5
5
|
|
|
6
6
|
const headersToObject = (thing) => (thing instanceof AxiosHeaders ? { ...thing } : thing);
|
|
7
7
|
|
|
8
|
+
const ownEnumerableKeys = (thing) => {
|
|
9
|
+
if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
|
|
10
|
+
return Object.keys(thing).concat(
|
|
11
|
+
Object.getOwnPropertySymbols(thing).filter(
|
|
12
|
+
(symbol) => Object.getOwnPropertyDescriptor(thing, symbol).enumerable
|
|
13
|
+
)
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return Object.keys(thing);
|
|
17
|
+
};
|
|
18
|
+
|
|
8
19
|
/**
|
|
9
20
|
* Config-specific merge-function which creates a new config-object
|
|
10
21
|
* by merging two configuration objects together.
|
|
@@ -70,7 +81,9 @@ export default function mergeConfig(config1, config2) {
|
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
function getMergedTransitionalOption(prop) {
|
|
73
|
-
const transitional2 = utils.hasOwnProp(config2, 'transitional')
|
|
84
|
+
const transitional2 = utils.hasOwnProp(config2, 'transitional')
|
|
85
|
+
? config2.transitional
|
|
86
|
+
: undefined;
|
|
74
87
|
|
|
75
88
|
if (!utils.isUndefined(transitional2)) {
|
|
76
89
|
if (utils.isPlainObject(transitional2)) {
|
|
@@ -82,7 +95,9 @@ export default function mergeConfig(config1, config2) {
|
|
|
82
95
|
}
|
|
83
96
|
}
|
|
84
97
|
|
|
85
|
-
const transitional1 = utils.hasOwnProp(config1, 'transitional')
|
|
98
|
+
const transitional1 = utils.hasOwnProp(config1, 'transitional')
|
|
99
|
+
? config1.transitional
|
|
100
|
+
: undefined;
|
|
86
101
|
|
|
87
102
|
if (utils.isPlainObject(transitional1) && utils.hasOwnProp(transitional1, prop)) {
|
|
88
103
|
return transitional1[prop];
|
|
@@ -109,7 +124,7 @@ export default function mergeConfig(config1, config2) {
|
|
|
109
124
|
transformResponse: defaultToConfig2,
|
|
110
125
|
paramsSerializer: defaultToConfig2,
|
|
111
126
|
timeout: defaultToConfig2,
|
|
112
|
-
|
|
127
|
+
timeoutErrorMessage: defaultToConfig2,
|
|
113
128
|
withCredentials: defaultToConfig2,
|
|
114
129
|
withXSRFToken: defaultToConfig2,
|
|
115
130
|
adapter: defaultToConfig2,
|
|
@@ -134,7 +149,7 @@ export default function mergeConfig(config1, config2) {
|
|
|
134
149
|
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
135
150
|
};
|
|
136
151
|
|
|
137
|
-
utils.forEach(
|
|
152
|
+
utils.forEach(ownEnumerableKeys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
138
153
|
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
139
154
|
const merge = utils.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
140
155
|
const a = utils.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Apply the headers generated by a FormData implementation to the request headers,
|
|
7
|
+
* honoring the `formDataHeaderPolicy` option: with 'content-only', copy only the
|
|
8
|
+
* content-* headers; otherwise merge all of them.
|
|
9
|
+
*
|
|
10
|
+
* @param {AxiosHeaders} headers - the request headers to mutate
|
|
11
|
+
* @param {Object | null | undefined} formHeaders - headers produced by the FormData implementation
|
|
12
|
+
* @param {String} [policy] - the resolved `formDataHeaderPolicy` config value
|
|
13
|
+
*
|
|
14
|
+
* @returns {void}
|
|
15
|
+
*/
|
|
16
|
+
export default function setFormDataHeaders(headers, formHeaders, policy) {
|
|
17
|
+
if (policy !== 'content-only') {
|
|
18
|
+
headers.set(formHeaders);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Object.entries(formHeaders || {}).forEach(([key, val]) => {
|
|
23
|
+
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
24
|
+
headers.set(key, val);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -7,6 +7,7 @@ import toFormData from '../helpers/toFormData.js';
|
|
|
7
7
|
import toURLEncodedForm from '../helpers/toURLEncodedForm.js';
|
|
8
8
|
import platform from '../platform/index.js';
|
|
9
9
|
import formDataToJSON from '../helpers/formDataToJSON.js';
|
|
10
|
+
import methodList from '../core/methodList.js';
|
|
10
11
|
|
|
11
12
|
const own = (obj, key) => (obj != null && utils.hasOwnProp(obj, key) ? obj[key] : undefined);
|
|
12
13
|
|
|
@@ -170,7 +171,7 @@ const defaults = {
|
|
|
170
171
|
},
|
|
171
172
|
};
|
|
172
173
|
|
|
173
|
-
utils.forEach(
|
|
174
|
+
utils.forEach(methodList, (method) => {
|
|
174
175
|
defaults.headers[method] = {};
|
|
175
176
|
});
|
|
176
177
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.
|
|
1
|
+
export const VERSION = "1.20.0";
|