openclaw-openagent 1.0.1 → 1.0.2
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.d.ts +25 -0
- package/dist/index.js +105 -0
- package/dist/src/app/channel-tools.d.ts +28 -0
- package/dist/src/app/channel-tools.js +251 -0
- package/dist/src/app/discovery-tools.d.ts +35 -0
- package/dist/src/app/discovery-tools.js +243 -0
- package/dist/src/app/download-file-tool.d.ts +10 -0
- package/dist/src/app/download-file-tool.js +104 -0
- package/dist/src/app/hooks.d.ts +14 -0
- package/dist/src/app/hooks.js +118 -0
- package/dist/src/app/index.d.ts +13 -0
- package/dist/src/app/index.js +44 -0
- package/dist/src/app/messaging-tools.d.ts +11 -0
- package/dist/src/app/messaging-tools.js +79 -0
- package/dist/src/app/ops-tools.d.ts +21 -0
- package/dist/src/app/ops-tools.js +158 -0
- package/dist/src/app/remote-agent-tool.d.ts +27 -0
- package/dist/src/app/remote-agent-tool.js +461 -0
- package/dist/src/app/types.d.ts +61 -0
- package/dist/src/app/types.js +11 -0
- package/dist/src/app/upload-file-tool.d.ts +16 -0
- package/dist/src/app/upload-file-tool.js +353 -0
- package/dist/src/app/verbose-preflight.d.ts +2 -0
- package/dist/src/app/verbose-preflight.js +145 -0
- package/dist/src/auth/config.d.ts +79 -0
- package/dist/src/auth/config.js +133 -0
- package/dist/src/auth/credential-manager.d.ts +65 -0
- package/dist/src/auth/credential-manager.js +122 -0
- package/dist/src/auth/index.d.ts +6 -0
- package/dist/src/auth/index.js +6 -0
- package/dist/src/auth/verify.d.ts +42 -0
- package/dist/src/auth/verify.js +60 -0
- package/dist/src/channel.d.ts +269 -0
- package/dist/src/channel.js +488 -0
- package/dist/src/compat.d.ts +37 -0
- package/dist/src/compat.js +70 -0
- package/dist/src/config/config-schema.d.ts +56 -0
- package/dist/src/config/config-schema.js +34 -0
- package/dist/src/messaging/aggregator.d.ts +25 -0
- package/dist/src/messaging/aggregator.js +90 -0
- package/dist/src/messaging/collector.d.ts +27 -0
- package/dist/src/messaging/collector.js +76 -0
- package/dist/src/messaging/executor.d.ts +14 -0
- package/dist/src/messaging/executor.js +59 -0
- package/dist/src/messaging/inbound.d.ts +97 -0
- package/dist/src/messaging/inbound.js +63 -0
- package/dist/src/messaging/index.d.ts +10 -0
- package/dist/src/messaging/index.js +9 -0
- package/dist/src/messaging/mention-protocol.d.ts +42 -0
- package/dist/src/messaging/mention-protocol.js +74 -0
- package/dist/src/messaging/process-c2c-request.d.ts +55 -0
- package/dist/src/messaging/process-c2c-request.js +445 -0
- package/dist/src/messaging/process-message.d.ts +62 -0
- package/dist/src/messaging/process-message.js +282 -0
- package/dist/src/messaging/scheduler.d.ts +17 -0
- package/dist/src/messaging/scheduler.js +47 -0
- package/dist/src/messaging/types.d.ts +34 -0
- package/dist/src/messaging/types.js +4 -0
- package/dist/src/plugin-ui/assets/openagent-override.js +9267 -0
- package/dist/src/plugin-ui/index.d.ts +13 -0
- package/dist/src/plugin-ui/index.js +16 -0
- package/dist/src/plugin-ui/ui-extension-loader/backup.d.ts +23 -0
- package/dist/src/plugin-ui/ui-extension-loader/backup.js +82 -0
- package/dist/src/plugin-ui/ui-extension-loader/index.d.ts +28 -0
- package/dist/src/plugin-ui/ui-extension-loader/index.js +240 -0
- package/dist/src/plugin-ui/ui-extension-loader/locator.d.ts +35 -0
- package/dist/src/plugin-ui/ui-extension-loader/locator.js +129 -0
- package/dist/src/plugin-ui/ui-extension-loader/manifest.d.ts +26 -0
- package/dist/src/plugin-ui/ui-extension-loader/manifest.js +45 -0
- package/dist/src/plugin-ui/ui-extension-loader/registry-regex.d.ts +9 -0
- package/dist/src/plugin-ui/ui-extension-loader/registry-regex.js +701 -0
- package/dist/src/plugin-ui/ui-extension-loader/removed-extensions.d.ts +8 -0
- package/dist/src/plugin-ui/ui-extension-loader/removed-extensions.js +58 -0
- package/dist/src/plugin-ui/ui-extension-loader/types.d.ts +55 -0
- package/dist/src/plugin-ui/ui-extension-loader/types.js +23 -0
- package/dist/src/proxy/auth-proxy.d.ts +20 -0
- package/dist/src/proxy/auth-proxy.js +337 -0
- package/dist/src/runtime/account.d.ts +156 -0
- package/dist/src/runtime/account.js +491 -0
- package/dist/src/runtime/index.d.ts +5 -0
- package/dist/src/runtime/index.js +6 -0
- package/dist/src/runtime/plugin-runtime.d.ts +40 -0
- package/dist/src/runtime/plugin-runtime.js +72 -0
- package/dist/src/runtime/registry.d.ts +41 -0
- package/dist/src/runtime/registry.js +60 -0
- package/dist/src/sdk/CLASS_MAP.md +143 -0
- package/dist/src/sdk/index.d.ts +126 -0
- package/dist/src/sdk/index.js +23990 -0
- package/dist/src/sdk/modules/cloud-search-module.js +1117 -0
- package/dist/src/sdk/modules/follow-module.js +1069 -0
- package/dist/src/sdk/modules/group-module.js +7397 -0
- package/dist/src/sdk/modules/relationship-module.js +2269 -0
- package/dist/src/sdk/modules/signaling-module.js +1468 -0
- package/dist/src/sdk/modules/tim-upload-plugin.js +730 -0
- package/dist/src/sdk/node-env/http-request.js +90 -0
- package/dist/src/sdk/node-env/index.js +57 -0
- package/dist/src/sdk/node-env/storage.js +114 -0
- package/dist/src/sdk/package.json +10 -0
- package/dist/src/sdk/sdk/CLASS_MAP.md +143 -0
- package/dist/src/sdk/sdk/index.d.ts +126 -0
- package/dist/src/sdk/sdk/index.js +23990 -0
- package/dist/src/sdk/sdk/modules/cloud-search-module.js +1117 -0
- package/dist/src/sdk/sdk/modules/follow-module.js +1069 -0
- package/dist/src/sdk/sdk/modules/group-module.js +7397 -0
- package/dist/src/sdk/sdk/modules/relationship-module.js +2269 -0
- package/dist/src/sdk/sdk/modules/signaling-module.js +1468 -0
- package/dist/src/sdk/sdk/modules/tim-upload-plugin.js +730 -0
- package/dist/src/sdk/sdk/node-env/http-request.js +90 -0
- package/dist/src/sdk/sdk/node-env/index.js +57 -0
- package/dist/src/sdk/sdk/node-env/storage.js +114 -0
- package/dist/src/sdk/sdk/package.json +10 -0
- package/dist/src/sdk/sdk/tsconfig.json +16 -0
- package/dist/src/sdk/tsconfig.json +16 -0
- package/dist/src/state/pending-invocation-store.d.ts +26 -0
- package/dist/src/state/pending-invocation-store.js +39 -0
- package/dist/src/state/store.d.ts +165 -0
- package/dist/src/state/store.js +535 -0
- package/dist/src/tim/c2c.d.ts +83 -0
- package/dist/src/tim/c2c.js +318 -0
- package/dist/src/tim/channels.d.ts +95 -0
- package/dist/src/tim/channels.js +279 -0
- package/dist/src/tim/client.d.ts +54 -0
- package/dist/src/tim/client.js +268 -0
- package/dist/src/tim/index.d.ts +6 -0
- package/dist/src/tim/index.js +6 -0
- package/dist/src/tim/messages.d.ts +50 -0
- package/dist/src/tim/messages.js +104 -0
- package/dist/src/tim/sdk-logger-init.d.ts +13 -0
- package/dist/src/tim/sdk-logger-init.js +46 -0
- package/dist/src/tools.d.ts +9 -0
- package/dist/src/tools.js +8 -0
- package/dist/src/transport/factory.d.ts +63 -0
- package/dist/src/transport/factory.js +54 -0
- package/dist/src/transport/oasn/index.d.ts +12 -0
- package/dist/src/transport/oasn/index.js +9 -0
- package/dist/src/transport/oasn/oasn-agent-card.d.ts +38 -0
- package/dist/src/transport/oasn/oasn-agent-card.js +102 -0
- package/dist/src/transport/oasn/oasn-discovery.d.ts +33 -0
- package/dist/src/transport/oasn/oasn-discovery.js +97 -0
- package/dist/src/transport/oasn/oasn-files.d.ts +64 -0
- package/dist/src/transport/oasn/oasn-files.js +174 -0
- package/dist/src/transport/oasn/oasn-http.d.ts +98 -0
- package/dist/src/transport/oasn/oasn-http.js +362 -0
- package/dist/src/transport/oasn/oasn-invocation.d.ts +154 -0
- package/dist/src/transport/oasn/oasn-invocation.js +432 -0
- package/dist/src/transport/oasn/oasn-normalize.d.ts +6 -0
- package/dist/src/transport/oasn/oasn-normalize.js +112 -0
- package/dist/src/transport/oasn/oasn-register.d.ts +19 -0
- package/dist/src/transport/oasn/oasn-register.js +24 -0
- package/dist/src/transport/oasn/oasn-transport.d.ts +114 -0
- package/dist/src/transport/oasn/oasn-transport.js +230 -0
- package/dist/src/transport/oasn/oasn-types.d.ts +331 -0
- package/dist/src/transport/oasn/oasn-types.js +44 -0
- package/dist/src/transport/tim/index.d.ts +7 -0
- package/dist/src/transport/tim/index.js +6 -0
- package/dist/src/transport/tim/tim-transport.d.ts +122 -0
- package/dist/src/transport/tim/tim-transport.js +402 -0
- package/dist/src/transport/types.d.ts +450 -0
- package/dist/src/transport/types.js +38 -0
- package/dist/src/util/http.d.ts +21 -0
- package/dist/src/util/http.js +93 -0
- package/dist/src/util/logger.d.ts +20 -0
- package/dist/src/util/logger.js +100 -0
- package/dist/src/util/url-resolver.d.ts +7 -0
- package/dist/src/util/url-resolver.js +20 -0
- package/index.ts +11 -0
- package/openclaw.plugin.json +9 -0
- package/package.json +7 -4
- package/src/app/download-file-tool.ts +133 -0
- package/src/app/hooks.ts +89 -5
- package/src/app/index.ts +6 -0
- package/src/app/remote-agent-tool.ts +46 -0
- package/src/app/types.ts +1 -0
- package/src/app/upload-file-tool.ts +411 -0
- package/src/plugin-ui/assets/openagent-override.js +1 -63
- package/src/plugin-ui/modules/agent-book/panel/agent-book.js +0 -61
- package/src/plugin-ui/modules/agent-book/panel/agent-data.js +0 -1
- package/src/plugin-ui/ui-extension-loader/registry-regex.ts +30 -13
- package/src/runtime/account.ts +0 -23
- package/src/transport/oasn/oasn-files.ts +5 -5
- package/src/transport/oasn/oasn-invocation.ts +44 -2
- package/src/transport/oasn/oasn-normalize.ts +0 -26
- package/src/transport/oasn/oasn-register.ts +8 -81
- package/src/transport/oasn/oasn-transport.ts +9 -32
- package/src/transport/oasn/oasn-types.ts +53 -6
- package/src/transport/types.ts +33 -36
- package/src/util/url-resolver.ts +17 -0
|
@@ -0,0 +1,730 @@
|
|
|
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
|
+
});
|