openclaw-openagent 1.0.12 → 1.0.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/dist/index.js +2 -0
- package/dist/src/config/config-schema.d.ts +9 -0
- package/dist/src/config/config-schema.js +6 -0
- package/dist/src/messaging/executor.d.ts +2 -3
- package/dist/src/messaging/executor.js +4 -31
- package/dist/src/plugin-ui/assets/openagent-override.js +124 -18
- package/dist/src/proxy/auth-proxy.js +5 -0
- package/dist/src/runtime/update-checker.d.ts +18 -0
- package/dist/src/runtime/update-checker.js +216 -0
- package/index.ts +3 -0
- package/package.json +1 -3
- package/src/app/channel-tools.ts +0 -249
- package/src/app/discovery-tools.ts +0 -273
- package/src/app/download-file-tool.ts +0 -133
- package/src/app/hooks.ts +0 -144
- package/src/app/index.ts +0 -84
- package/src/app/messaging-tools.ts +0 -79
- package/src/app/ops-tools.ts +0 -155
- package/src/app/remote-agent-tool.ts +0 -762
- package/src/app/types.ts +0 -68
- package/src/app/upload-file-tool.ts +0 -411
- package/src/app/verbose-preflight.ts +0 -190
- package/src/auth/config.ts +0 -266
- package/src/auth/credential-manager.ts +0 -146
- package/src/auth/index.ts +0 -24
- package/src/auth/verify.ts +0 -99
- package/src/channel.ts +0 -566
- package/src/compat.ts +0 -94
- package/src/config/config-schema.ts +0 -39
- package/src/messaging/aggregator.ts +0 -120
- package/src/messaging/collector.ts +0 -89
- package/src/messaging/executor.ts +0 -72
- package/src/messaging/inbound.ts +0 -150
- package/src/messaging/index.ts +0 -11
- package/src/messaging/mention-protocol.ts +0 -94
- package/src/messaging/process-c2c-request.ts +0 -564
- package/src/messaging/process-message.ts +0 -373
- package/src/messaging/scheduler.ts +0 -55
- package/src/messaging/types.ts +0 -38
- package/src/plugin-ui/adapters/oc-2026-04.js +0 -103
- package/src/plugin-ui/adapters/oc-2026-05.js +0 -125
- package/src/plugin-ui/adapters/oc-2026-06.js +0 -125
- package/src/plugin-ui/adapters/oc-unknown.js +0 -48
- package/src/plugin-ui/assets/agentbook-icon.svg +0 -5
- package/src/plugin-ui/assets/bg.png +0 -0
- package/src/plugin-ui/assets/icon.png +0 -0
- package/src/plugin-ui/assets/magic.svg +0 -5
- package/src/plugin-ui/assets/openagent-override.js +0 -11156
- package/src/plugin-ui/build.cjs +0 -463
- package/src/plugin-ui/index.ts +0 -18
- package/src/plugin-ui/modules/agent-book/panel/agent-book.js +0 -570
- package/src/plugin-ui/modules/agent-book/panel/agent-card.js +0 -170
- package/src/plugin-ui/modules/agent-book/panel/agent-data.js +0 -643
- package/src/plugin-ui/modules/agent-book/panel/inject-ui.js +0 -665
- package/src/plugin-ui/modules/agent-book/panel/mention-state.js +0 -206
- package/src/plugin-ui/modules/agent-book/panel/styles.js +0 -833
- package/src/plugin-ui/modules/agent-book/panel/theme-adapter.js +0 -86
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/components-core.js +0 -295
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/thought-chain-card.js +0 -211
- package/src/plugin-ui/modules/agent-book/scanner.js +0 -131
- package/src/plugin-ui/modules/agent-book/travelcard/travel-cards.js +0 -500
- package/src/plugin-ui/modules/agent-book/travelcard/travel-engine.js +0 -652
- package/src/plugin-ui/modules/agent-book/travelcard/travel-styles.js +0 -256
- package/src/plugin-ui/modules/loader/bootstrap.js +0 -38
- package/src/plugin-ui/modules/loader/shared-state.js +0 -838
- package/src/plugin-ui/modules/loader/ws-intercept.js +0 -199
- package/src/plugin-ui/modules/remote-agent/chunk-parser.js +0 -161
- package/src/plugin-ui/modules/remote-agent/execution-card.js +0 -530
- package/src/plugin-ui/modules/remote-agent/markdown-renderer.js +0 -256
- package/src/plugin-ui/modules/remote-agent/media-links.js +0 -151
- package/src/plugin-ui/modules/remote-agent/native-style-adapter.js +0 -134
- package/src/plugin-ui/modules/remote-agent/output-card.js +0 -342
- package/src/plugin-ui/modules/remote-agent/progress-store.js +0 -363
- package/src/plugin-ui/modules/remote-agent/render-hooks.js +0 -1700
- package/src/plugin-ui/modules/remote-agent/styles.js +0 -896
- package/src/plugin-ui/modules/remote-agent/tool-card-model.js +0 -130
- package/src/plugin-ui/postinstall-deploy.cjs +0 -52
- package/src/plugin-ui/ui-extension-loader/backup.ts +0 -92
- package/src/plugin-ui/ui-extension-loader/index.ts +0 -276
- package/src/plugin-ui/ui-extension-loader/locator.ts +0 -152
- package/src/plugin-ui/ui-extension-loader/manifest.ts +0 -57
- package/src/plugin-ui/ui-extension-loader/registry-regex.ts +0 -944
- package/src/plugin-ui/ui-extension-loader/removed-extensions.ts +0 -70
- package/src/plugin-ui/ui-extension-loader/types.ts +0 -72
- package/src/proxy/auth-proxy.ts +0 -409
- package/src/runtime/account.ts +0 -549
- package/src/runtime/index.ts +0 -7
- package/src/runtime/plugin-runtime.ts +0 -94
- package/src/runtime/registry.ts +0 -71
- package/src/sdk/CLASS_MAP.md +0 -143
- package/src/sdk/index.d.ts +0 -126
- package/src/sdk/index.js +0 -23990
- package/src/sdk/modules/cloud-search-module.js +0 -1117
- package/src/sdk/modules/follow-module.js +0 -1069
- package/src/sdk/modules/group-module.js +0 -7397
- package/src/sdk/modules/relationship-module.js +0 -2269
- package/src/sdk/modules/signaling-module.js +0 -1468
- package/src/sdk/modules/tim-upload-plugin.js +0 -730
- package/src/sdk/node-env/http-request.js +0 -90
- package/src/sdk/node-env/index.js +0 -57
- package/src/sdk/node-env/storage.js +0 -114
- package/src/sdk/package.json +0 -10
- package/src/sdk/tsconfig.json +0 -16
- package/src/state/pending-invocation-store.ts +0 -43
- package/src/state/store.ts +0 -756
- package/src/tim/c2c.ts +0 -451
- package/src/tim/channels.ts +0 -364
- package/src/tim/client.ts +0 -330
- package/src/tim/index.ts +0 -18
- package/src/tim/messages.ts +0 -166
- package/src/tim/sdk-logger-init.ts +0 -50
- package/src/tools.ts +0 -10
- package/src/transport/factory.ts +0 -95
- package/src/transport/oasn/index.ts +0 -17
- package/src/transport/oasn/oasn-agent-card.ts +0 -111
- package/src/transport/oasn/oasn-discovery.ts +0 -108
- package/src/transport/oasn/oasn-files.ts +0 -210
- package/src/transport/oasn/oasn-http.ts +0 -529
- package/src/transport/oasn/oasn-invocation.ts +0 -604
- package/src/transport/oasn/oasn-normalize.ts +0 -133
- package/src/transport/oasn/oasn-register.ts +0 -33
- package/src/transport/oasn/oasn-transport.ts +0 -318
- package/src/transport/oasn/oasn-types.ts +0 -404
- package/src/transport/tim/index.ts +0 -8
- package/src/transport/tim/tim-transport.ts +0 -515
- package/src/transport/types.ts +0 -538
- package/src/types/openclaw-plugin-sdk-media-store.d.ts +0 -9
- package/src/types/openclaw.d.ts +0 -97
- package/src/types/tencentcloud-chat.d.ts +0 -15
- package/src/util/http.ts +0 -113
- package/src/util/logger.ts +0 -131
- package/src/util/url-resolver.ts +0 -77
|
@@ -1,730 +0,0 @@
|
|
|
1
|
-
// [OPENAGENT] tim-upload-plugin v1.4.3 — patched for Node.js
|
|
2
|
-
// Original: npm tim-upload-plugin@1.4.3
|
|
3
|
-
// Patch: Added NodeRequest adapter (N) using fetch() to replace XMLHttpRequest
|
|
4
|
-
// in Node.js environment. Adapter selection at L564 patched to detect Node.js.
|
|
5
|
-
// @see docs/audit/023-tim-upload-plugin-v1.md §4.1
|
|
6
|
-
!(function (e, t) {
|
|
7
|
-
'object' == typeof exports && 'undefined' != typeof module
|
|
8
|
-
? (module.exports = t())
|
|
9
|
-
: 'function' == typeof define && define.amd
|
|
10
|
-
? define(t)
|
|
11
|
-
: ((e = e || self).TIMUploadPlugin = t());
|
|
12
|
-
})(this, function () {
|
|
13
|
-
function e(e, t) {
|
|
14
|
-
if (!(e instanceof t))
|
|
15
|
-
throw new TypeError('Cannot call a class as a function');
|
|
16
|
-
}
|
|
17
|
-
function t(e, t) {
|
|
18
|
-
for (var n = 0; n < t.length; n++) {
|
|
19
|
-
var o = t[n];
|
|
20
|
-
((o.enumerable = o.enumerable || !1),
|
|
21
|
-
(o.configurable = !0),
|
|
22
|
-
'value' in o && (o.writable = !0),
|
|
23
|
-
Object.defineProperty(e, s(o.key), o));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function n(e, n, o) {
|
|
27
|
-
return (
|
|
28
|
-
n && t(e.prototype, n),
|
|
29
|
-
o && t(e, o),
|
|
30
|
-
Object.defineProperty(e, 'prototype', { writable: !1 }),
|
|
31
|
-
e
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
function o(e, t, n) {
|
|
35
|
-
return (
|
|
36
|
-
(t = s(t)) in e
|
|
37
|
-
? Object.defineProperty(e, t, {
|
|
38
|
-
value: n,
|
|
39
|
-
enumerable: !0,
|
|
40
|
-
configurable: !0,
|
|
41
|
-
writable: !0,
|
|
42
|
-
})
|
|
43
|
-
: (e[t] = n),
|
|
44
|
-
e
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
function r(e, t) {
|
|
48
|
-
var n = Object.keys(e);
|
|
49
|
-
if (Object.getOwnPropertySymbols) {
|
|
50
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
51
|
-
(t &&
|
|
52
|
-
(o = o.filter(function (t) {
|
|
53
|
-
return Object.getOwnPropertyDescriptor(e, t).enumerable;
|
|
54
|
-
})),
|
|
55
|
-
n.push.apply(n, o));
|
|
56
|
-
}
|
|
57
|
-
return n;
|
|
58
|
-
}
|
|
59
|
-
function a(e) {
|
|
60
|
-
for (var t = 1; t < arguments.length; t++) {
|
|
61
|
-
var n = null != arguments[t] ? arguments[t] : {};
|
|
62
|
-
t % 2
|
|
63
|
-
? r(Object(n), !0).forEach(function (t) {
|
|
64
|
-
o(e, t, n[t]);
|
|
65
|
-
})
|
|
66
|
-
: Object.getOwnPropertyDescriptors
|
|
67
|
-
? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n))
|
|
68
|
-
: r(Object(n)).forEach(function (t) {
|
|
69
|
-
Object.defineProperty(
|
|
70
|
-
e,
|
|
71
|
-
t,
|
|
72
|
-
Object.getOwnPropertyDescriptor(n, t),
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
return e;
|
|
77
|
-
}
|
|
78
|
-
function s(e) {
|
|
79
|
-
var t = (function (e, t) {
|
|
80
|
-
if ('object' != typeof e || !e) return e;
|
|
81
|
-
var n = e[Symbol.toPrimitive];
|
|
82
|
-
if (void 0 !== n) {
|
|
83
|
-
var o = n.call(e, t || 'default');
|
|
84
|
-
if ('object' != typeof o) return o;
|
|
85
|
-
throw new TypeError('@@toPrimitive must return a primitive value.');
|
|
86
|
-
}
|
|
87
|
-
return ('string' === t ? String : Number)(e);
|
|
88
|
-
})(e, 'string');
|
|
89
|
-
return 'symbol' == typeof t ? t : t + '';
|
|
90
|
-
}
|
|
91
|
-
function i(e) {
|
|
92
|
-
return (i =
|
|
93
|
-
'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator
|
|
94
|
-
? function (e) {
|
|
95
|
-
return typeof e;
|
|
96
|
-
}
|
|
97
|
-
: function (e) {
|
|
98
|
-
return e &&
|
|
99
|
-
'function' == typeof Symbol &&
|
|
100
|
-
e.constructor === Symbol &&
|
|
101
|
-
e !== Symbol.prototype
|
|
102
|
-
? 'symbol'
|
|
103
|
-
: typeof e;
|
|
104
|
-
})(e);
|
|
105
|
-
}
|
|
106
|
-
var u =
|
|
107
|
-
'undefined' != typeof global
|
|
108
|
-
? global
|
|
109
|
-
: 'undefined' != typeof self
|
|
110
|
-
? self
|
|
111
|
-
: 'undefined' != typeof window
|
|
112
|
-
? window
|
|
113
|
-
: {},
|
|
114
|
-
l =
|
|
115
|
-
'undefined' != typeof wx &&
|
|
116
|
-
'function' == typeof wx.getSystemInfoSync &&
|
|
117
|
-
('mac' === wx.getSystemInfoSync().platform ||
|
|
118
|
-
'windows' === wx.getSystemInfoSync().platform),
|
|
119
|
-
f =
|
|
120
|
-
('undefined' != typeof wx &&
|
|
121
|
-
'function' == typeof wx.getSystemInfoSync &&
|
|
122
|
-
Boolean(wx.getSystemInfoSync().fontSizeSetting)) ||
|
|
123
|
-
l,
|
|
124
|
-
c =
|
|
125
|
-
'undefined' != typeof qq &&
|
|
126
|
-
'function' == typeof qq.getSystemInfoSync &&
|
|
127
|
-
Boolean(qq.getSystemInfoSync().fontSizeSetting),
|
|
128
|
-
d =
|
|
129
|
-
'undefined' != typeof tt &&
|
|
130
|
-
'function' == typeof tt.getSystemInfoSync &&
|
|
131
|
-
Boolean(tt.getSystemInfoSync().fontSizeSetting),
|
|
132
|
-
p =
|
|
133
|
-
'undefined' != typeof swan &&
|
|
134
|
-
'function' == typeof swan.getSystemInfoSync &&
|
|
135
|
-
Boolean(swan.getSystemInfoSync().fontSizeSetting),
|
|
136
|
-
y =
|
|
137
|
-
'undefined' != typeof my &&
|
|
138
|
-
'function' == typeof my.getSystemInfoSync &&
|
|
139
|
-
Boolean(my.getSystemInfoSync().fontSizeSetting),
|
|
140
|
-
m =
|
|
141
|
-
'undefined' != typeof uni &&
|
|
142
|
-
'undefined' == typeof window &&
|
|
143
|
-
'function' == typeof uni.requireNativePlugin,
|
|
144
|
-
g = m && 'ios' === uni.getDeviceInfo().platform.toLocaleLowerCase(),
|
|
145
|
-
h =
|
|
146
|
-
(m && uni.getDeviceInfo().platform.toLocaleLowerCase(),
|
|
147
|
-
f || c || d || p || y || m),
|
|
148
|
-
v =
|
|
149
|
-
void 0 !== u &&
|
|
150
|
-
(void 0 !== u.nativeModuleProxy || void 0 !== u.ReactNative),
|
|
151
|
-
b = c ? qq : d ? tt : p ? swan : y ? my : f ? wx : m ? uni : {},
|
|
152
|
-
w = function (e) {
|
|
153
|
-
if ('object' !== i(e) || null === e) return !1;
|
|
154
|
-
var t = Object.getPrototypeOf(e);
|
|
155
|
-
if (null === t) return !0;
|
|
156
|
-
for (var n = t; null !== Object.getPrototypeOf(n); )
|
|
157
|
-
n = Object.getPrototypeOf(n);
|
|
158
|
-
return t === n;
|
|
159
|
-
};
|
|
160
|
-
function S(e) {
|
|
161
|
-
if (null == e) return !0;
|
|
162
|
-
if ('boolean' == typeof e) return !1;
|
|
163
|
-
if ('number' == typeof e) return 0 === e;
|
|
164
|
-
if ('string' == typeof e) return 0 === e.length;
|
|
165
|
-
if ('function' == typeof e) return 0 === e.length;
|
|
166
|
-
if (Array.isArray(e)) return 0 === e.length;
|
|
167
|
-
if (e instanceof Error) return '' === e.message;
|
|
168
|
-
if (w(e)) {
|
|
169
|
-
for (var t in e)
|
|
170
|
-
if (Object.prototype.hasOwnProperty.call(e, t)) return !1;
|
|
171
|
-
return !0;
|
|
172
|
-
}
|
|
173
|
-
return !1;
|
|
174
|
-
}
|
|
175
|
-
// [OPENAGENT] Node.js environment detection
|
|
176
|
-
var _isNode = typeof process !== 'undefined' && !!process.versions && !!process.versions.node;
|
|
177
|
-
// [OPENAGENT] NodeRequest adapter — replaces WebRequest (O) in Node.js
|
|
178
|
-
// Implements the same interface as O but uses fetch() instead of XMLHttpRequest.
|
|
179
|
-
// Only handles PUT uploads (pre-signed URL protocol used by COS).
|
|
180
|
-
// @see docs/audit/023-tim-upload-plugin-v1.md §4.1
|
|
181
|
-
var N = (function () {
|
|
182
|
-
return n(
|
|
183
|
-
function t() {
|
|
184
|
-
(e(this, t), (this._n = 'NodeRequest'));
|
|
185
|
-
},
|
|
186
|
-
[
|
|
187
|
-
{
|
|
188
|
-
key: 'request',
|
|
189
|
-
value: function (e, t) {
|
|
190
|
-
var n = this,
|
|
191
|
-
o = ''.concat(this._n, '.request'),
|
|
192
|
-
r = e.downloadUrl || '',
|
|
193
|
-
s = (e.method || 'PUT').toUpperCase(),
|
|
194
|
-
i = e.url;
|
|
195
|
-
console.log('[OPENAGENT] ' + o + ' URL:' + i);
|
|
196
|
-
// Build query string (same logic as WebRequest)
|
|
197
|
-
if (e.qs) {
|
|
198
|
-
var u = (function (e) {
|
|
199
|
-
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : '&',
|
|
200
|
-
n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : '=';
|
|
201
|
-
return S(e)
|
|
202
|
-
? ''
|
|
203
|
-
: w(e)
|
|
204
|
-
? Object.keys(e)
|
|
205
|
-
.map(function (o) {
|
|
206
|
-
var r = encodeURIComponent(o) + n;
|
|
207
|
-
return Array.isArray(e[o])
|
|
208
|
-
? e[o].map(function (e) { return r + encodeURIComponent(e); }).join(t)
|
|
209
|
-
: r + encodeURIComponent(e[o]);
|
|
210
|
-
})
|
|
211
|
-
.filter(Boolean)
|
|
212
|
-
.join(t)
|
|
213
|
-
: void 0;
|
|
214
|
-
})(e.qs);
|
|
215
|
-
u && (i += ''.concat(-1 === i.indexOf('?') ? '?' : '&').concat(u));
|
|
216
|
-
}
|
|
217
|
-
// Build headers — filter out forbidden headers same as WebRequest
|
|
218
|
-
var f = e.headers || {};
|
|
219
|
-
if (e.uploadByIP && e.uploadIP) {
|
|
220
|
-
f = a(a({}, f), {}, { host: e.uploadIP });
|
|
221
|
-
}
|
|
222
|
-
var headers = {};
|
|
223
|
-
if (!S(f)) {
|
|
224
|
-
for (var c in f) {
|
|
225
|
-
if (f.hasOwnProperty(c)) {
|
|
226
|
-
var lc = c.toLowerCase();
|
|
227
|
-
// Skip headers that fetch/Node.js manages or rejects
|
|
228
|
-
if (lc !== 'content-length' && lc !== 'user-agent' && lc !== 'origin' && lc !== 'host') {
|
|
229
|
-
headers[c] = f[c];
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
// Execute fetch — PUT binary body (same as xhr.send(e.resources))
|
|
235
|
-
fetch(i, {
|
|
236
|
-
method: s,
|
|
237
|
-
headers: headers,
|
|
238
|
-
body: e.resources,
|
|
239
|
-
})
|
|
240
|
-
.then(function (resp) {
|
|
241
|
-
// Parse response headers into plain object (matching _xhrRes format)
|
|
242
|
-
var respHeaders = {};
|
|
243
|
-
resp.headers.forEach(function (val, key) {
|
|
244
|
-
respHeaders[key.toLowerCase()] = val;
|
|
245
|
-
});
|
|
246
|
-
var statusCode = resp.status;
|
|
247
|
-
var result = {
|
|
248
|
-
statusCode: statusCode,
|
|
249
|
-
statusMessage: resp.statusText,
|
|
250
|
-
headers: respHeaders,
|
|
251
|
-
data: statusCode === 200 && r
|
|
252
|
-
? { location: r, uploadIP: e.uploadByIP && e.uploadIP }
|
|
253
|
-
: { response: '', uploadIP: e.uploadByIP && e.uploadIP },
|
|
254
|
-
};
|
|
255
|
-
if (statusCode === 200) {
|
|
256
|
-
console.log('[OPENAGENT] ' + o + ' upload OK: ' + statusCode);
|
|
257
|
-
t(null, result);
|
|
258
|
-
} else if (e.uploadIP && -1 === e.url.indexOf(e.uploadIP)) {
|
|
259
|
-
// Retry with uploadIP (same logic as WebRequest fallback)
|
|
260
|
-
console.log('[OPENAGENT] ' + o + ' retry with uploadIP: ' + e.uploadIP);
|
|
261
|
-
e.url = e.url.replace(/^http(s)?:\/\/(.*?)\//, 'https://' + e.uploadIP + '/');
|
|
262
|
-
e.uploadByIP = true;
|
|
263
|
-
n.request(e, t);
|
|
264
|
-
} else {
|
|
265
|
-
console.log('[OPENAGENT] ' + o + ' upload failed: ' + statusCode);
|
|
266
|
-
t({ code: statusCode, message: 'HTTP ' + statusCode }, result);
|
|
267
|
-
}
|
|
268
|
-
})
|
|
269
|
-
.catch(function (err) {
|
|
270
|
-
console.error('[OPENAGENT] ' + o + ' fetch error:', err.message);
|
|
271
|
-
t(
|
|
272
|
-
{ code: 0, message: err.message || 'Network error' },
|
|
273
|
-
{ statusCode: 0, statusMessage: '', headers: {}, data: void 0 },
|
|
274
|
-
);
|
|
275
|
-
});
|
|
276
|
-
// Note: no upload progress support in Node.js fetch (P2)
|
|
277
|
-
return null; // WebRequest returns xhr, we return null (not used by caller)
|
|
278
|
-
},
|
|
279
|
-
},
|
|
280
|
-
],
|
|
281
|
-
);
|
|
282
|
-
})();
|
|
283
|
-
var O = (function () {
|
|
284
|
-
return n(
|
|
285
|
-
function t() {
|
|
286
|
-
(e(this, t), (this._n = 'WebRequest'));
|
|
287
|
-
},
|
|
288
|
-
[
|
|
289
|
-
{
|
|
290
|
-
key: 'request',
|
|
291
|
-
value: function (e, t) {
|
|
292
|
-
var n = this,
|
|
293
|
-
o = ''.concat(this._n, '.request'),
|
|
294
|
-
r = e.downloadUrl || '',
|
|
295
|
-
s = (e.method || 'PUT').toUpperCase(),
|
|
296
|
-
i = e.url;
|
|
297
|
-
if (
|
|
298
|
-
(console.log(
|
|
299
|
-
'%c tim-upload-plugin %c',
|
|
300
|
-
'background:#0abf5b; padding:1px; border-radius:3px; color: #fff',
|
|
301
|
-
'background:transparent',
|
|
302
|
-
''.concat(o, ' URL:').concat(i),
|
|
303
|
-
),
|
|
304
|
-
e.qs)
|
|
305
|
-
) {
|
|
306
|
-
var u = (function (e) {
|
|
307
|
-
var t =
|
|
308
|
-
arguments.length > 1 && void 0 !== arguments[1]
|
|
309
|
-
? arguments[1]
|
|
310
|
-
: '&',
|
|
311
|
-
n =
|
|
312
|
-
arguments.length > 2 && void 0 !== arguments[2]
|
|
313
|
-
? arguments[2]
|
|
314
|
-
: '=';
|
|
315
|
-
return S(e)
|
|
316
|
-
? ''
|
|
317
|
-
: w(e)
|
|
318
|
-
? Object.keys(e)
|
|
319
|
-
.map(function (o) {
|
|
320
|
-
var r = encodeURIComponent(o) + n;
|
|
321
|
-
return Array.isArray(e[o])
|
|
322
|
-
? e[o]
|
|
323
|
-
.map(function (e) {
|
|
324
|
-
return r + encodeURIComponent(e);
|
|
325
|
-
})
|
|
326
|
-
.join(t)
|
|
327
|
-
: r + encodeURIComponent(e[o]);
|
|
328
|
-
})
|
|
329
|
-
.filter(Boolean)
|
|
330
|
-
.join(t)
|
|
331
|
-
: void 0;
|
|
332
|
-
})(e.qs);
|
|
333
|
-
u &&
|
|
334
|
-
(i += ''.concat(-1 === i.indexOf('?') ? '?' : '&').concat(u));
|
|
335
|
-
}
|
|
336
|
-
var l = new XMLHttpRequest();
|
|
337
|
-
(l.open(s, i, !0), (l.responseType = e.dataType || 'text'));
|
|
338
|
-
var f = e.headers || {};
|
|
339
|
-
if (
|
|
340
|
-
(e.uploadByIP && (f = a(a({}, f), {}, { host: e.uploadIP })),
|
|
341
|
-
!S(f))
|
|
342
|
-
)
|
|
343
|
-
for (var c in f)
|
|
344
|
-
f.hasOwnProperty(c) &&
|
|
345
|
-
'content-length' !== c.toLowerCase() &&
|
|
346
|
-
'user-agent' !== c.toLowerCase() &&
|
|
347
|
-
'origin' !== c.toLowerCase() &&
|
|
348
|
-
'host' !== c.toLowerCase() &&
|
|
349
|
-
l.setRequestHeader(c, f[c]);
|
|
350
|
-
return (
|
|
351
|
-
(l.onload = function () {
|
|
352
|
-
if (200 === l.status)
|
|
353
|
-
t(
|
|
354
|
-
null,
|
|
355
|
-
n._xhrRes(
|
|
356
|
-
l,
|
|
357
|
-
n._xhrBody(l, r, e.uploadByIP && e.uploadIP),
|
|
358
|
-
f,
|
|
359
|
-
),
|
|
360
|
-
);
|
|
361
|
-
else {
|
|
362
|
-
if (e.uploadIP && -1 === e.url.indexOf(e.uploadIP))
|
|
363
|
-
return (
|
|
364
|
-
(e.url = (function (e, t) {
|
|
365
|
-
return e.replace(
|
|
366
|
-
/^http(s)?:\/\/(.*?)\//,
|
|
367
|
-
'https://'.concat(t, '/'),
|
|
368
|
-
);
|
|
369
|
-
})(e.url, e.uploadIP)),
|
|
370
|
-
(e.uploadByIP = !0),
|
|
371
|
-
n.request(e, t)
|
|
372
|
-
);
|
|
373
|
-
var o = {
|
|
374
|
-
code: l.status,
|
|
375
|
-
message: JSON.stringify(l.responseText),
|
|
376
|
-
};
|
|
377
|
-
t(
|
|
378
|
-
o,
|
|
379
|
-
n._xhrRes(
|
|
380
|
-
l,
|
|
381
|
-
n._xhrBody(l, r, e.uploadByIP && e.uploadIP),
|
|
382
|
-
f,
|
|
383
|
-
),
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
}),
|
|
387
|
-
(l.onerror = function (o) {
|
|
388
|
-
var a = n._xhrBody(l, r, e.uploadByIP && e.uploadIP),
|
|
389
|
-
s = {
|
|
390
|
-
code: l.status,
|
|
391
|
-
message: JSON.stringify(l.responseText),
|
|
392
|
-
};
|
|
393
|
-
(a ||
|
|
394
|
-
l.statusText ||
|
|
395
|
-
0 !== l.status ||
|
|
396
|
-
(o.message = 'CORS blocked or network error'),
|
|
397
|
-
t(s, n._xhrRes(l, a)),
|
|
398
|
-
(s = null));
|
|
399
|
-
}),
|
|
400
|
-
e.onProgress &&
|
|
401
|
-
l.upload &&
|
|
402
|
-
(l.upload.onprogress = function (t) {
|
|
403
|
-
var n = t.total,
|
|
404
|
-
o = t.loaded,
|
|
405
|
-
r = Math.floor((100 * o) / n);
|
|
406
|
-
e.onProgress({
|
|
407
|
-
total: n,
|
|
408
|
-
loaded: o,
|
|
409
|
-
percent: (r >= 100 ? 100 : r) / 100,
|
|
410
|
-
});
|
|
411
|
-
}),
|
|
412
|
-
l.send(e.resources),
|
|
413
|
-
l
|
|
414
|
-
);
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
key: '_xhrRes',
|
|
419
|
-
value: function (e, t) {
|
|
420
|
-
var n = {};
|
|
421
|
-
return (
|
|
422
|
-
e
|
|
423
|
-
.getAllResponseHeaders()
|
|
424
|
-
.trim()
|
|
425
|
-
.split('\n')
|
|
426
|
-
.forEach(function (e) {
|
|
427
|
-
if (e) {
|
|
428
|
-
var t = e.indexOf(':'),
|
|
429
|
-
o = e.substr(0, t).trim().toLowerCase(),
|
|
430
|
-
r = e.substr(t + 1).trim();
|
|
431
|
-
n[o] = r;
|
|
432
|
-
}
|
|
433
|
-
}),
|
|
434
|
-
{
|
|
435
|
-
statusCode: e.status,
|
|
436
|
-
statusMessage: e.statusText,
|
|
437
|
-
headers: n,
|
|
438
|
-
data: t,
|
|
439
|
-
}
|
|
440
|
-
);
|
|
441
|
-
},
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
key: '_xhrBody',
|
|
445
|
-
value: function (e, t, n) {
|
|
446
|
-
return 200 === e.status && t
|
|
447
|
-
? { location: t, uploadIP: n }
|
|
448
|
-
: { response: e.responseText, uploadIP: n };
|
|
449
|
-
},
|
|
450
|
-
},
|
|
451
|
-
],
|
|
452
|
-
);
|
|
453
|
-
})(),
|
|
454
|
-
P = ['unknown', 'image', 'video', 'audio', 'log'],
|
|
455
|
-
I = ['name'],
|
|
456
|
-
C = (function () {
|
|
457
|
-
return n(
|
|
458
|
-
function t() {
|
|
459
|
-
e(this, t);
|
|
460
|
-
},
|
|
461
|
-
[
|
|
462
|
-
{
|
|
463
|
-
key: 'request',
|
|
464
|
-
value: function (e, t) {
|
|
465
|
-
var n = this,
|
|
466
|
-
o = e.resources,
|
|
467
|
-
r = void 0 === o ? '' : o,
|
|
468
|
-
s = e.headers,
|
|
469
|
-
i = void 0 === s ? {} : s,
|
|
470
|
-
u = e.url,
|
|
471
|
-
l = e.downloadUrl,
|
|
472
|
-
f = void 0 === l ? '' : l,
|
|
473
|
-
c = u,
|
|
474
|
-
d = null,
|
|
475
|
-
p = f.match(/^(https?:\/\/[^/]+\/)([^/]*\/?)(.*)$/),
|
|
476
|
-
m = decodeURIComponent(p[3]),
|
|
477
|
-
h = m.indexOf('?') > -1 ? m.split('?')[0] : m,
|
|
478
|
-
v = {
|
|
479
|
-
key: e.fileKey ? e.fileKey : h,
|
|
480
|
-
success_action_status: 200,
|
|
481
|
-
'Content-Type': '',
|
|
482
|
-
},
|
|
483
|
-
w = {};
|
|
484
|
-
if (g) {
|
|
485
|
-
var S = u.split('?sign=');
|
|
486
|
-
if (S.length > 1) {
|
|
487
|
-
var O = S[1];
|
|
488
|
-
((c = ''
|
|
489
|
-
.concat(S[0], '?sign=')
|
|
490
|
-
.concat(encodeURIComponent(''.concat(O)))),
|
|
491
|
-
(w.sign = decodeURIComponent(O)),
|
|
492
|
-
(w.signature = decodeURIComponent(O)));
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
var C = {
|
|
496
|
-
url: c,
|
|
497
|
-
header: i,
|
|
498
|
-
name: 'file',
|
|
499
|
-
filePath: r,
|
|
500
|
-
formData: a(a({}, v), w),
|
|
501
|
-
timeout: e.timeout || 3e5,
|
|
502
|
-
};
|
|
503
|
-
if (y) {
|
|
504
|
-
var x = C;
|
|
505
|
-
x.name;
|
|
506
|
-
C = a(
|
|
507
|
-
a(
|
|
508
|
-
{},
|
|
509
|
-
(function (e, t) {
|
|
510
|
-
if (null == e) return {};
|
|
511
|
-
var n,
|
|
512
|
-
o,
|
|
513
|
-
r = (function (e, t) {
|
|
514
|
-
if (null == e) return {};
|
|
515
|
-
var n = {};
|
|
516
|
-
for (var o in e)
|
|
517
|
-
if ({}.hasOwnProperty.call(e, o)) {
|
|
518
|
-
if (t.includes(o)) continue;
|
|
519
|
-
n[o] = e[o];
|
|
520
|
-
}
|
|
521
|
-
return n;
|
|
522
|
-
})(e, t);
|
|
523
|
-
if (Object.getOwnPropertySymbols) {
|
|
524
|
-
var a = Object.getOwnPropertySymbols(e);
|
|
525
|
-
for (o = 0; o < a.length; o++)
|
|
526
|
-
((n = a[o]),
|
|
527
|
-
t.includes(n) ||
|
|
528
|
-
({}.propertyIsEnumerable.call(e, n) &&
|
|
529
|
-
(r[n] = e[n])));
|
|
530
|
-
}
|
|
531
|
-
return r;
|
|
532
|
-
})(x, I),
|
|
533
|
-
),
|
|
534
|
-
{},
|
|
535
|
-
{ fileName: 'file', fileType: P[e.fileType] },
|
|
536
|
-
);
|
|
537
|
-
}
|
|
538
|
-
return (
|
|
539
|
-
(d = b.uploadFile(
|
|
540
|
-
a(
|
|
541
|
-
a({}, C),
|
|
542
|
-
{},
|
|
543
|
-
{
|
|
544
|
-
success: function (e) {
|
|
545
|
-
n._handleResponse({
|
|
546
|
-
response: e,
|
|
547
|
-
downloadUrl: f,
|
|
548
|
-
callback: t,
|
|
549
|
-
});
|
|
550
|
-
},
|
|
551
|
-
fail: function (e) {
|
|
552
|
-
n._handleResponse({
|
|
553
|
-
response: e,
|
|
554
|
-
downloadUrl: f,
|
|
555
|
-
callback: t,
|
|
556
|
-
});
|
|
557
|
-
},
|
|
558
|
-
},
|
|
559
|
-
),
|
|
560
|
-
)).onProgressUpdate &&
|
|
561
|
-
d.onProgressUpdate(function (t) {
|
|
562
|
-
e.onProgress &&
|
|
563
|
-
e.onProgress({
|
|
564
|
-
total: t.totalBytesExpectedToSend,
|
|
565
|
-
loaded: t.totalBytesSent,
|
|
566
|
-
percent: Math.floor(t.progress) / 100,
|
|
567
|
-
});
|
|
568
|
-
}),
|
|
569
|
-
d
|
|
570
|
-
);
|
|
571
|
-
},
|
|
572
|
-
},
|
|
573
|
-
{
|
|
574
|
-
key: '_handleResponse',
|
|
575
|
-
value: function (e) {
|
|
576
|
-
var t = e.downloadUrl,
|
|
577
|
-
n = e.response,
|
|
578
|
-
o = e.callback,
|
|
579
|
-
r = n.header,
|
|
580
|
-
s = {};
|
|
581
|
-
if (r)
|
|
582
|
-
for (var i in r)
|
|
583
|
-
r.hasOwnProperty(i) && (s[i.toLowerCase()] = r[i]);
|
|
584
|
-
var u = +n.statusCode;
|
|
585
|
-
200 === u
|
|
586
|
-
? o(null, {
|
|
587
|
-
statusCode: u,
|
|
588
|
-
headers: s,
|
|
589
|
-
data: a(a({}, n.data), {}, { location: t }),
|
|
590
|
-
})
|
|
591
|
-
: o(
|
|
592
|
-
{ code: u, message: JSON.stringify(n.data) },
|
|
593
|
-
{ statusCode: u, headers: s, data: void 0 },
|
|
594
|
-
);
|
|
595
|
-
},
|
|
596
|
-
},
|
|
597
|
-
],
|
|
598
|
-
);
|
|
599
|
-
})(),
|
|
600
|
-
x = (function () {
|
|
601
|
-
return n(
|
|
602
|
-
function t() {
|
|
603
|
-
e(this, t);
|
|
604
|
-
},
|
|
605
|
-
[
|
|
606
|
-
{
|
|
607
|
-
key: 'request',
|
|
608
|
-
value: function (e, t) {
|
|
609
|
-
var n = this,
|
|
610
|
-
o = e.resources,
|
|
611
|
-
r = void 0 === o ? '' : o,
|
|
612
|
-
a = e.fileKey,
|
|
613
|
-
s = void 0 === a ? '' : a,
|
|
614
|
-
i = e.url,
|
|
615
|
-
u = e.downloadUrl,
|
|
616
|
-
l = void 0 === u ? '' : u,
|
|
617
|
-
f = new FormData();
|
|
618
|
-
(f.append('key', s),
|
|
619
|
-
f.append('success_action_status', 200),
|
|
620
|
-
f.append('file', {
|
|
621
|
-
uri: r,
|
|
622
|
-
type: 'application/octet-stream',
|
|
623
|
-
name: 'uploaded_file',
|
|
624
|
-
}),
|
|
625
|
-
fetch(i, {
|
|
626
|
-
method: 'POST',
|
|
627
|
-
headers: { 'Content-Type': 'multipart/form-data' },
|
|
628
|
-
body: f,
|
|
629
|
-
})
|
|
630
|
-
.then(function (e) {
|
|
631
|
-
n._handleResponse({
|
|
632
|
-
response: e,
|
|
633
|
-
downloadUrl: l,
|
|
634
|
-
callback: t,
|
|
635
|
-
});
|
|
636
|
-
})
|
|
637
|
-
.catch(function (e) {
|
|
638
|
-
n._handleResponse({
|
|
639
|
-
response: e,
|
|
640
|
-
downloadUrl: l,
|
|
641
|
-
callback: t,
|
|
642
|
-
});
|
|
643
|
-
}));
|
|
644
|
-
},
|
|
645
|
-
},
|
|
646
|
-
{
|
|
647
|
-
key: '_handleResponse',
|
|
648
|
-
value: function (e) {
|
|
649
|
-
var t = e.downloadUrl,
|
|
650
|
-
n = e.response,
|
|
651
|
-
o = e.callback,
|
|
652
|
-
r = n.headers,
|
|
653
|
-
a = n.status,
|
|
654
|
-
s = (r && r.map) || {};
|
|
655
|
-
200 === a
|
|
656
|
-
? o(null, {
|
|
657
|
-
statusCode: 200,
|
|
658
|
-
headers: s,
|
|
659
|
-
data: { location: t },
|
|
660
|
-
})
|
|
661
|
-
: o(
|
|
662
|
-
{ code: a, message: JSON.stringify(n) },
|
|
663
|
-
{ statusCode: a, headers: s, data: void 0 },
|
|
664
|
-
);
|
|
665
|
-
},
|
|
666
|
-
},
|
|
667
|
-
],
|
|
668
|
-
);
|
|
669
|
-
})();
|
|
670
|
-
return (function () {
|
|
671
|
-
return n(
|
|
672
|
-
function t() {
|
|
673
|
-
(e(this, t),
|
|
674
|
-
(this.retry = 1),
|
|
675
|
-
(this.tryCount = 0),
|
|
676
|
-
(this.systemClockOffset = 0),
|
|
677
|
-
// [OPENAGENT] Patched: added _isNode branch for NodeRequest adapter
|
|
678
|
-
(this.httpRequest = h ? new C() : v ? new x() : _isNode ? new N() : new O()),
|
|
679
|
-
console.log('TIMUploadPlugin.VERSION: '.concat('1.4.3-openagent')));
|
|
680
|
-
},
|
|
681
|
-
[
|
|
682
|
-
{
|
|
683
|
-
key: 'uploadFile',
|
|
684
|
-
value: function (e, t) {
|
|
685
|
-
var n = this;
|
|
686
|
-
return this.httpRequest.request(e, function (o, r) {
|
|
687
|
-
o && n.tryCount < n.retry && n.allowRetry(o)
|
|
688
|
-
? (n.tryCount++, n.uploadFile(e, t))
|
|
689
|
-
: ((n.tryCount = 0), t(o, r));
|
|
690
|
-
});
|
|
691
|
-
},
|
|
692
|
-
},
|
|
693
|
-
{
|
|
694
|
-
key: 'allowRetry',
|
|
695
|
-
value: function (e) {
|
|
696
|
-
var t = !1,
|
|
697
|
-
n = !1;
|
|
698
|
-
if (e) {
|
|
699
|
-
var o =
|
|
700
|
-
(e.headers && (e.headers.date || e.headers.Date)) ||
|
|
701
|
-
(e.error && e.error.ServerTime);
|
|
702
|
-
try {
|
|
703
|
-
var r = e.error && e.error.Code,
|
|
704
|
-
a = e.error && e.error.Message;
|
|
705
|
-
('RequestTimeTooSkewed' === r ||
|
|
706
|
-
('AccessDenied' === r && 'Request has expired' === a)) &&
|
|
707
|
-
(n = !0);
|
|
708
|
-
} catch (u) {}
|
|
709
|
-
if (n && o) {
|
|
710
|
-
var s = Date.now(),
|
|
711
|
-
i = Date.parse(o);
|
|
712
|
-
Math.abs(s + this.systemClockOffset - i) >= 3e4 &&
|
|
713
|
-
((this.systemClockOffset = i - s), (t = !0));
|
|
714
|
-
} else 5 === Math.floor(e.statusCode / 100) && (t = !0);
|
|
715
|
-
}
|
|
716
|
-
return t;
|
|
717
|
-
},
|
|
718
|
-
},
|
|
719
|
-
],
|
|
720
|
-
[
|
|
721
|
-
{
|
|
722
|
-
key: 'getVersion',
|
|
723
|
-
value: function () {
|
|
724
|
-
return '1.4.3';
|
|
725
|
-
},
|
|
726
|
-
},
|
|
727
|
-
],
|
|
728
|
-
);
|
|
729
|
-
})();
|
|
730
|
-
});
|