tiny-oss 0.5.1 → 1.0.0
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/README.md +459 -52
- package/UPGRADING.md +151 -0
- package/dist/aws.d.ts +208 -0
- package/dist/azure.d.ts +204 -0
- package/dist/cos.d.ts +208 -0
- package/dist/index.d.ts +209 -0
- package/dist/obs.d.ts +208 -0
- package/dist/protocol.d.ts +271 -0
- package/dist/tiny-oss.aws.es.js +1052 -0
- package/dist/tiny-oss.aws.es.js.map +1 -0
- package/dist/tiny-oss.azure.es.js +882 -0
- package/dist/tiny-oss.azure.es.js.map +1 -0
- package/dist/tiny-oss.cos.es.js +984 -0
- package/dist/tiny-oss.cos.es.js.map +1 -0
- package/dist/tiny-oss.es.js +965 -0
- package/dist/tiny-oss.es.js.map +1 -0
- package/dist/tiny-oss.obs.es.js +1048 -0
- package/dist/tiny-oss.obs.es.js.map +1 -0
- package/dist/tiny-oss.protocol.es.js +588 -0
- package/dist/tiny-oss.protocol.es.js.map +1 -0
- package/package.json +78 -64
- package/dist/tiny-oss.js +0 -1642
- package/dist/tiny-oss.js.map +0 -1
- package/dist/tiny-oss.min.js +0 -35
- package/dist/tiny-oss.min.js.map +0 -1
- package/es/TinyOSS.js +0 -209
- package/es/index.js +0 -1
- package/es/utils/ajax.js +0 -61
- package/es/utils/index.js +0 -188
- package/lib/TinyOSS.js +0 -218
- package/lib/index.js +0 -3
- package/lib/utils/ajax.js +0 -66
- package/lib/utils/index.js +0 -203
- package/types/index.d.ts +0 -89
- package/vendor/digest.js +0 -390
|
@@ -0,0 +1,984 @@
|
|
|
1
|
+
var me = Object.defineProperty;
|
|
2
|
+
var N = Object.getOwnPropertySymbols;
|
|
3
|
+
var xe = Object.prototype.hasOwnProperty, we = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var G = (r, e, t) => e in r ? me(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, b = (r, e) => {
|
|
5
|
+
for (var t in e || (e = {}))
|
|
6
|
+
xe.call(e, t) && G(r, t, e[t]);
|
|
7
|
+
if (N)
|
|
8
|
+
for (var t of N(e))
|
|
9
|
+
we.call(e, t) && G(r, t, e[t]);
|
|
10
|
+
return r;
|
|
11
|
+
};
|
|
12
|
+
var P = (r, e, t) => new Promise((o, c) => {
|
|
13
|
+
var u = (p) => {
|
|
14
|
+
try {
|
|
15
|
+
s(t.next(p));
|
|
16
|
+
} catch (n) {
|
|
17
|
+
c(n);
|
|
18
|
+
}
|
|
19
|
+
}, d = (p) => {
|
|
20
|
+
try {
|
|
21
|
+
s(t.throw(p));
|
|
22
|
+
} catch (n) {
|
|
23
|
+
c(n);
|
|
24
|
+
}
|
|
25
|
+
}, s = (p) => p.done ? o(p.value) : Promise.resolve(p.value).then(u, d);
|
|
26
|
+
s((t = t.apply(r, e)).next());
|
|
27
|
+
});
|
|
28
|
+
function ve(r, e) {
|
|
29
|
+
return new Promise((t, o) => {
|
|
30
|
+
const {
|
|
31
|
+
method: c = "get",
|
|
32
|
+
data: u = null,
|
|
33
|
+
headers: d = {},
|
|
34
|
+
timeout: s = 0,
|
|
35
|
+
onprogress: p
|
|
36
|
+
} = e, n = new XMLHttpRequest();
|
|
37
|
+
let a;
|
|
38
|
+
s && (a = setTimeout(() => {
|
|
39
|
+
o(new Error(`the request timeout ${s}ms`));
|
|
40
|
+
}, s)), n.onerror = () => {
|
|
41
|
+
o(new Error("unknown error"));
|
|
42
|
+
}, n.upload && p && (n.upload.onprogress = (l) => {
|
|
43
|
+
p({ loaded: l.loaded, total: l.total, lengthComputable: l.lengthComputable });
|
|
44
|
+
}), n.onreadystatechange = () => {
|
|
45
|
+
if (n.readyState === 4)
|
|
46
|
+
if (s && clearTimeout(a), n.status >= 200 && n.status < 300) {
|
|
47
|
+
const l = {}, f = n.getAllResponseHeaders();
|
|
48
|
+
f && f.trim().split(/[\r\n]+/).forEach((h) => {
|
|
49
|
+
const g = h.split(": "), y = g.shift(), m = g.join(": ");
|
|
50
|
+
y && (l[y.toLowerCase()] = m);
|
|
51
|
+
}), t({
|
|
52
|
+
data: n.responseText,
|
|
53
|
+
headers: l,
|
|
54
|
+
status: n.status,
|
|
55
|
+
statusText: n.statusText
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
const l = new Error(`the request is error: ${n.status} ${n.statusText} ${n.responseText || ""}`);
|
|
59
|
+
o(l);
|
|
60
|
+
}
|
|
61
|
+
}, n.open(c, r, !0), Object.keys(d).forEach((l) => {
|
|
62
|
+
n.setRequestHeader(l, d[l]);
|
|
63
|
+
});
|
|
64
|
+
try {
|
|
65
|
+
n.send(u);
|
|
66
|
+
} catch (l) {
|
|
67
|
+
o(l);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
let se = ve;
|
|
72
|
+
function nt(r) {
|
|
73
|
+
se = r;
|
|
74
|
+
}
|
|
75
|
+
function Ae() {
|
|
76
|
+
return se;
|
|
77
|
+
}
|
|
78
|
+
function ae(r) {
|
|
79
|
+
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
80
|
+
}
|
|
81
|
+
var q = { exports: {} }, H = { exports: {} }, V;
|
|
82
|
+
function Te() {
|
|
83
|
+
return V || (V = 1, (function() {
|
|
84
|
+
var r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", e = {
|
|
85
|
+
// Bit-wise rotation left
|
|
86
|
+
rotl: function(t, o) {
|
|
87
|
+
return t << o | t >>> 32 - o;
|
|
88
|
+
},
|
|
89
|
+
// Bit-wise rotation right
|
|
90
|
+
rotr: function(t, o) {
|
|
91
|
+
return t << 32 - o | t >>> o;
|
|
92
|
+
},
|
|
93
|
+
// Swap big-endian to little-endian and vice versa
|
|
94
|
+
endian: function(t) {
|
|
95
|
+
if (t.constructor == Number)
|
|
96
|
+
return e.rotl(t, 8) & 16711935 | e.rotl(t, 24) & 4278255360;
|
|
97
|
+
for (var o = 0; o < t.length; o++)
|
|
98
|
+
t[o] = e.endian(t[o]);
|
|
99
|
+
return t;
|
|
100
|
+
},
|
|
101
|
+
// Generate an array of any length of random bytes
|
|
102
|
+
randomBytes: function(t) {
|
|
103
|
+
for (var o = []; t > 0; t--)
|
|
104
|
+
o.push(Math.floor(Math.random() * 256));
|
|
105
|
+
return o;
|
|
106
|
+
},
|
|
107
|
+
// Convert a byte array to big-endian 32-bit words
|
|
108
|
+
bytesToWords: function(t) {
|
|
109
|
+
for (var o = [], c = 0, u = 0; c < t.length; c++, u += 8)
|
|
110
|
+
o[u >>> 5] |= t[c] << 24 - u % 32;
|
|
111
|
+
return o;
|
|
112
|
+
},
|
|
113
|
+
// Convert big-endian 32-bit words to a byte array
|
|
114
|
+
wordsToBytes: function(t) {
|
|
115
|
+
for (var o = [], c = 0; c < t.length * 32; c += 8)
|
|
116
|
+
o.push(t[c >>> 5] >>> 24 - c % 32 & 255);
|
|
117
|
+
return o;
|
|
118
|
+
},
|
|
119
|
+
// Convert a byte array to a hex string
|
|
120
|
+
bytesToHex: function(t) {
|
|
121
|
+
for (var o = [], c = 0; c < t.length; c++)
|
|
122
|
+
o.push((t[c] >>> 4).toString(16)), o.push((t[c] & 15).toString(16));
|
|
123
|
+
return o.join("");
|
|
124
|
+
},
|
|
125
|
+
// Convert a hex string to a byte array
|
|
126
|
+
hexToBytes: function(t) {
|
|
127
|
+
for (var o = [], c = 0; c < t.length; c += 2)
|
|
128
|
+
o.push(parseInt(t.substr(c, 2), 16));
|
|
129
|
+
return o;
|
|
130
|
+
},
|
|
131
|
+
// Convert a byte array to a base-64 string
|
|
132
|
+
bytesToBase64: function(t) {
|
|
133
|
+
for (var o = [], c = 0; c < t.length; c += 3)
|
|
134
|
+
for (var u = t[c] << 16 | t[c + 1] << 8 | t[c + 2], d = 0; d < 4; d++)
|
|
135
|
+
c * 8 + d * 6 <= t.length * 8 ? o.push(r.charAt(u >>> 6 * (3 - d) & 63)) : o.push("=");
|
|
136
|
+
return o.join("");
|
|
137
|
+
},
|
|
138
|
+
// Convert a base-64 string to a byte array
|
|
139
|
+
base64ToBytes: function(t) {
|
|
140
|
+
t = t.replace(/[^A-Z0-9+\/]/ig, "");
|
|
141
|
+
for (var o = [], c = 0, u = 0; c < t.length; u = ++c % 4)
|
|
142
|
+
u != 0 && o.push((r.indexOf(t.charAt(c - 1)) & Math.pow(2, -2 * u + 8) - 1) << u * 2 | r.indexOf(t.charAt(c)) >>> 6 - u * 2);
|
|
143
|
+
return o;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
H.exports = e;
|
|
147
|
+
})()), H.exports;
|
|
148
|
+
}
|
|
149
|
+
var z, W;
|
|
150
|
+
function J() {
|
|
151
|
+
if (W) return z;
|
|
152
|
+
W = 1;
|
|
153
|
+
var r = {
|
|
154
|
+
// UTF-8 encoding
|
|
155
|
+
utf8: {
|
|
156
|
+
// Convert a string to a byte array
|
|
157
|
+
stringToBytes: function(e) {
|
|
158
|
+
return r.bin.stringToBytes(unescape(encodeURIComponent(e)));
|
|
159
|
+
},
|
|
160
|
+
// Convert a byte array to a string
|
|
161
|
+
bytesToString: function(e) {
|
|
162
|
+
return decodeURIComponent(escape(r.bin.bytesToString(e)));
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
// Binary encoding
|
|
166
|
+
bin: {
|
|
167
|
+
// Convert a string to a byte array
|
|
168
|
+
stringToBytes: function(e) {
|
|
169
|
+
for (var t = [], o = 0; o < e.length; o++)
|
|
170
|
+
t.push(e.charCodeAt(o) & 255);
|
|
171
|
+
return t;
|
|
172
|
+
},
|
|
173
|
+
// Convert a byte array to a string
|
|
174
|
+
bytesToString: function(e) {
|
|
175
|
+
for (var t = [], o = 0; o < e.length; o++)
|
|
176
|
+
t.push(String.fromCharCode(e[o]));
|
|
177
|
+
return t.join("");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
return z = r, z;
|
|
182
|
+
}
|
|
183
|
+
var K, Z;
|
|
184
|
+
function Ue() {
|
|
185
|
+
if (Z) return K;
|
|
186
|
+
Z = 1, K = function(t) {
|
|
187
|
+
return t != null && (r(t) || e(t) || !!t._isBuffer);
|
|
188
|
+
};
|
|
189
|
+
function r(t) {
|
|
190
|
+
return !!t.constructor && typeof t.constructor.isBuffer == "function" && t.constructor.isBuffer(t);
|
|
191
|
+
}
|
|
192
|
+
function e(t) {
|
|
193
|
+
return typeof t.readFloatLE == "function" && typeof t.slice == "function" && r(t.slice(0, 0));
|
|
194
|
+
}
|
|
195
|
+
return K;
|
|
196
|
+
}
|
|
197
|
+
var Q;
|
|
198
|
+
function be() {
|
|
199
|
+
return Q || (Q = 1, (function() {
|
|
200
|
+
var r = Te(), e = J().utf8, t = Ue(), o = J().bin, c = function(u, d) {
|
|
201
|
+
u.constructor == String ? d && d.encoding === "binary" ? u = o.stringToBytes(u) : u = e.stringToBytes(u) : t(u) ? u = Array.prototype.slice.call(u, 0) : !Array.isArray(u) && u.constructor !== Uint8Array && (u = u.toString());
|
|
202
|
+
for (var s = r.bytesToWords(u), p = u.length * 8, n = 1732584193, a = -271733879, l = -1732584194, f = 271733878, i = 0; i < s.length; i++)
|
|
203
|
+
s[i] = (s[i] << 8 | s[i] >>> 24) & 16711935 | (s[i] << 24 | s[i] >>> 8) & 4278255360;
|
|
204
|
+
s[p >>> 5] |= 128 << p % 32, s[(p + 64 >>> 9 << 4) + 14] = p;
|
|
205
|
+
for (var h = c._ff, g = c._gg, y = c._hh, m = c._ii, i = 0; i < s.length; i += 16) {
|
|
206
|
+
var w = n, x = a, v = l, T = f;
|
|
207
|
+
n = h(n, a, l, f, s[i + 0], 7, -680876936), f = h(f, n, a, l, s[i + 1], 12, -389564586), l = h(l, f, n, a, s[i + 2], 17, 606105819), a = h(a, l, f, n, s[i + 3], 22, -1044525330), n = h(n, a, l, f, s[i + 4], 7, -176418897), f = h(f, n, a, l, s[i + 5], 12, 1200080426), l = h(l, f, n, a, s[i + 6], 17, -1473231341), a = h(a, l, f, n, s[i + 7], 22, -45705983), n = h(n, a, l, f, s[i + 8], 7, 1770035416), f = h(f, n, a, l, s[i + 9], 12, -1958414417), l = h(l, f, n, a, s[i + 10], 17, -42063), a = h(a, l, f, n, s[i + 11], 22, -1990404162), n = h(n, a, l, f, s[i + 12], 7, 1804603682), f = h(f, n, a, l, s[i + 13], 12, -40341101), l = h(l, f, n, a, s[i + 14], 17, -1502002290), a = h(a, l, f, n, s[i + 15], 22, 1236535329), n = g(n, a, l, f, s[i + 1], 5, -165796510), f = g(f, n, a, l, s[i + 6], 9, -1069501632), l = g(l, f, n, a, s[i + 11], 14, 643717713), a = g(a, l, f, n, s[i + 0], 20, -373897302), n = g(n, a, l, f, s[i + 5], 5, -701558691), f = g(f, n, a, l, s[i + 10], 9, 38016083), l = g(l, f, n, a, s[i + 15], 14, -660478335), a = g(a, l, f, n, s[i + 4], 20, -405537848), n = g(n, a, l, f, s[i + 9], 5, 568446438), f = g(f, n, a, l, s[i + 14], 9, -1019803690), l = g(l, f, n, a, s[i + 3], 14, -187363961), a = g(a, l, f, n, s[i + 8], 20, 1163531501), n = g(n, a, l, f, s[i + 13], 5, -1444681467), f = g(f, n, a, l, s[i + 2], 9, -51403784), l = g(l, f, n, a, s[i + 7], 14, 1735328473), a = g(a, l, f, n, s[i + 12], 20, -1926607734), n = y(n, a, l, f, s[i + 5], 4, -378558), f = y(f, n, a, l, s[i + 8], 11, -2022574463), l = y(l, f, n, a, s[i + 11], 16, 1839030562), a = y(a, l, f, n, s[i + 14], 23, -35309556), n = y(n, a, l, f, s[i + 1], 4, -1530992060), f = y(f, n, a, l, s[i + 4], 11, 1272893353), l = y(l, f, n, a, s[i + 7], 16, -155497632), a = y(a, l, f, n, s[i + 10], 23, -1094730640), n = y(n, a, l, f, s[i + 13], 4, 681279174), f = y(f, n, a, l, s[i + 0], 11, -358537222), l = y(l, f, n, a, s[i + 3], 16, -722521979), a = y(a, l, f, n, s[i + 6], 23, 76029189), n = y(n, a, l, f, s[i + 9], 4, -640364487), f = y(f, n, a, l, s[i + 12], 11, -421815835), l = y(l, f, n, a, s[i + 15], 16, 530742520), a = y(a, l, f, n, s[i + 2], 23, -995338651), n = m(n, a, l, f, s[i + 0], 6, -198630844), f = m(f, n, a, l, s[i + 7], 10, 1126891415), l = m(l, f, n, a, s[i + 14], 15, -1416354905), a = m(a, l, f, n, s[i + 5], 21, -57434055), n = m(n, a, l, f, s[i + 12], 6, 1700485571), f = m(f, n, a, l, s[i + 3], 10, -1894986606), l = m(l, f, n, a, s[i + 10], 15, -1051523), a = m(a, l, f, n, s[i + 1], 21, -2054922799), n = m(n, a, l, f, s[i + 8], 6, 1873313359), f = m(f, n, a, l, s[i + 15], 10, -30611744), l = m(l, f, n, a, s[i + 6], 15, -1560198380), a = m(a, l, f, n, s[i + 13], 21, 1309151649), n = m(n, a, l, f, s[i + 4], 6, -145523070), f = m(f, n, a, l, s[i + 11], 10, -1120210379), l = m(l, f, n, a, s[i + 2], 15, 718787259), a = m(a, l, f, n, s[i + 9], 21, -343485551), n = n + w >>> 0, a = a + x >>> 0, l = l + v >>> 0, f = f + T >>> 0;
|
|
208
|
+
}
|
|
209
|
+
return r.endian([n, a, l, f]);
|
|
210
|
+
};
|
|
211
|
+
c._ff = function(u, d, s, p, n, a, l) {
|
|
212
|
+
var f = u + (d & s | ~d & p) + (n >>> 0) + l;
|
|
213
|
+
return (f << a | f >>> 32 - a) + d;
|
|
214
|
+
}, c._gg = function(u, d, s, p, n, a, l) {
|
|
215
|
+
var f = u + (d & p | s & ~p) + (n >>> 0) + l;
|
|
216
|
+
return (f << a | f >>> 32 - a) + d;
|
|
217
|
+
}, c._hh = function(u, d, s, p, n, a, l) {
|
|
218
|
+
var f = u + (d ^ s ^ p) + (n >>> 0) + l;
|
|
219
|
+
return (f << a | f >>> 32 - a) + d;
|
|
220
|
+
}, c._ii = function(u, d, s, p, n, a, l) {
|
|
221
|
+
var f = u + (s ^ (d | ~p)) + (n >>> 0) + l;
|
|
222
|
+
return (f << a | f >>> 32 - a) + d;
|
|
223
|
+
}, c._blocksize = 16, c._digestsize = 16, q.exports = function(u, d) {
|
|
224
|
+
if (u == null)
|
|
225
|
+
throw new Error("Illegal argument " + u);
|
|
226
|
+
var s = r.wordsToBytes(c(u, d));
|
|
227
|
+
return d && d.asBytes ? s : d && d.asString ? o.bytesToString(s) : r.bytesToHex(s);
|
|
228
|
+
};
|
|
229
|
+
})()), q.exports;
|
|
230
|
+
}
|
|
231
|
+
var Ce = be();
|
|
232
|
+
const Se = /* @__PURE__ */ ae(Ce);
|
|
233
|
+
var $ = {}, Y;
|
|
234
|
+
function Be() {
|
|
235
|
+
if (Y) return $;
|
|
236
|
+
Y = 1, $.byteLength = s, $.toByteArray = n, $.fromByteArray = f;
|
|
237
|
+
for (var r = [], e = [], t = typeof Uint8Array != "undefined" ? Uint8Array : Array, o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", c = 0, u = o.length; c < u; ++c)
|
|
238
|
+
r[c] = o[c], e[o.charCodeAt(c)] = c;
|
|
239
|
+
e[45] = 62, e[95] = 63;
|
|
240
|
+
function d(i) {
|
|
241
|
+
var h = i.length;
|
|
242
|
+
if (h % 4 > 0)
|
|
243
|
+
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
244
|
+
var g = i.indexOf("=");
|
|
245
|
+
g === -1 && (g = h);
|
|
246
|
+
var y = g === h ? 0 : 4 - g % 4;
|
|
247
|
+
return [g, y];
|
|
248
|
+
}
|
|
249
|
+
function s(i) {
|
|
250
|
+
var h = d(i), g = h[0], y = h[1];
|
|
251
|
+
return (g + y) * 3 / 4 - y;
|
|
252
|
+
}
|
|
253
|
+
function p(i, h, g) {
|
|
254
|
+
return (h + g) * 3 / 4 - g;
|
|
255
|
+
}
|
|
256
|
+
function n(i) {
|
|
257
|
+
var h, g = d(i), y = g[0], m = g[1], w = new t(p(i, y, m)), x = 0, v = m > 0 ? y - 4 : y, T;
|
|
258
|
+
for (T = 0; T < v; T += 4)
|
|
259
|
+
h = e[i.charCodeAt(T)] << 18 | e[i.charCodeAt(T + 1)] << 12 | e[i.charCodeAt(T + 2)] << 6 | e[i.charCodeAt(T + 3)], w[x++] = h >> 16 & 255, w[x++] = h >> 8 & 255, w[x++] = h & 255;
|
|
260
|
+
return m === 2 && (h = e[i.charCodeAt(T)] << 2 | e[i.charCodeAt(T + 1)] >> 4, w[x++] = h & 255), m === 1 && (h = e[i.charCodeAt(T)] << 10 | e[i.charCodeAt(T + 1)] << 4 | e[i.charCodeAt(T + 2)] >> 2, w[x++] = h >> 8 & 255, w[x++] = h & 255), w;
|
|
261
|
+
}
|
|
262
|
+
function a(i) {
|
|
263
|
+
return r[i >> 18 & 63] + r[i >> 12 & 63] + r[i >> 6 & 63] + r[i & 63];
|
|
264
|
+
}
|
|
265
|
+
function l(i, h, g) {
|
|
266
|
+
for (var y, m = [], w = h; w < g; w += 3)
|
|
267
|
+
y = (i[w] << 16 & 16711680) + (i[w + 1] << 8 & 65280) + (i[w + 2] & 255), m.push(a(y));
|
|
268
|
+
return m.join("");
|
|
269
|
+
}
|
|
270
|
+
function f(i) {
|
|
271
|
+
for (var h, g = i.length, y = g % 3, m = [], w = 16383, x = 0, v = g - y; x < v; x += w)
|
|
272
|
+
m.push(l(i, x, x + w > v ? v : x + w));
|
|
273
|
+
return y === 1 ? (h = i[g - 1], m.push(
|
|
274
|
+
r[h >> 2] + r[h << 4 & 63] + "=="
|
|
275
|
+
)) : y === 2 && (h = (i[g - 2] << 8) + i[g - 1], m.push(
|
|
276
|
+
r[h >> 10] + r[h >> 4 & 63] + r[h << 2 & 63] + "="
|
|
277
|
+
)), m.join("");
|
|
278
|
+
}
|
|
279
|
+
return $;
|
|
280
|
+
}
|
|
281
|
+
var Le = Be();
|
|
282
|
+
const ke = /* @__PURE__ */ ae(Le);
|
|
283
|
+
ArrayBuffer.prototype.slice || (ArrayBuffer.prototype.slice = function(r, e) {
|
|
284
|
+
const t = new Uint8Array(this), o = e === void 0 ? t.length : e, c = new ArrayBuffer(o - r), u = new Uint8Array(c);
|
|
285
|
+
for (let d = 0; d < u.length; d++)
|
|
286
|
+
u[d] = t[d + r];
|
|
287
|
+
return c;
|
|
288
|
+
});
|
|
289
|
+
class X {
|
|
290
|
+
constructor() {
|
|
291
|
+
this.current = new Uint32Array(new ArrayBuffer(20)), this.currentLen = 0, this.inLen = 0, this.inbuf = new Uint8Array(new ArrayBuffer(64)), this.blockLen = 64, this.digestLen = 20, this.reset();
|
|
292
|
+
}
|
|
293
|
+
processBlock(e) {
|
|
294
|
+
let t = this.current[0], o = this.current[1], c = this.current[2], u = this.current[3], d = this.current[4];
|
|
295
|
+
const s = [
|
|
296
|
+
e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3],
|
|
297
|
+
e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7],
|
|
298
|
+
e[8] << 24 | e[9] << 16 | e[10] << 8 | e[11],
|
|
299
|
+
e[12] << 24 | e[13] << 16 | e[14] << 8 | e[15],
|
|
300
|
+
e[16] << 24 | e[17] << 16 | e[18] << 8 | e[19],
|
|
301
|
+
e[20] << 24 | e[21] << 16 | e[22] << 8 | e[23],
|
|
302
|
+
e[24] << 24 | e[25] << 16 | e[26] << 8 | e[27],
|
|
303
|
+
e[28] << 24 | e[29] << 16 | e[30] << 8 | e[31],
|
|
304
|
+
e[32] << 24 | e[33] << 16 | e[34] << 8 | e[35],
|
|
305
|
+
e[36] << 24 | e[37] << 16 | e[38] << 8 | e[39],
|
|
306
|
+
e[40] << 24 | e[41] << 16 | e[42] << 8 | e[43],
|
|
307
|
+
e[44] << 24 | e[45] << 16 | e[46] << 8 | e[47],
|
|
308
|
+
e[48] << 24 | e[49] << 16 | e[50] << 8 | e[51],
|
|
309
|
+
e[52] << 24 | e[53] << 16 | e[54] << 8 | e[55],
|
|
310
|
+
e[56] << 24 | e[57] << 16 | e[58] << 8 | e[59],
|
|
311
|
+
e[60] << 24 | e[61] << 16 | e[62] << 8 | e[63]
|
|
312
|
+
];
|
|
313
|
+
let p;
|
|
314
|
+
for (let n = 16; n < 80; n++)
|
|
315
|
+
s.push((s[n - 3] ^ s[n - 8] ^ s[n - 14] ^ s[n - 16]) << 1 | (s[n - 3] ^ s[n - 8] ^ s[n - 14] ^ s[n - 16]) >>> 31);
|
|
316
|
+
for (let n = 0; n < 80; n++)
|
|
317
|
+
p = (t << 5 | t >>> 27) + d + s[n], n < 20 ? p += (o & c | ~o & u) + 1518500249 | 0 : n < 40 ? p += (o ^ c ^ u) + 1859775393 | 0 : n < 60 ? p += (o & c | o & u | c & u) + 2400959708 | 0 : p += (o ^ c ^ u) + 3395469782 | 0, d = u, u = c, c = o << 30 | o >>> 2, o = t, t = p;
|
|
318
|
+
this.current[0] += t, this.current[1] += o, this.current[2] += c, this.current[3] += u, this.current[4] += d, this.currentLen += 64;
|
|
319
|
+
}
|
|
320
|
+
doPadding() {
|
|
321
|
+
const e = (this.inLen + this.currentLen) * 8, t = 0, o = e & 4294967295, c = this.inLen <= 55 ? 55 - this.inLen : 119 - this.inLen, u = new Uint8Array(new ArrayBuffer(c + 1 + 8));
|
|
322
|
+
return u[0] = 128, u[u.length - 1] = o & 255, u[u.length - 2] = o >>> 8 & 255, u[u.length - 3] = o >>> 16 & 255, u[u.length - 4] = o >>> 24 & 255, u[u.length - 5] = t & 255, u[u.length - 6] = t >>> 8 & 255, u[u.length - 7] = t >>> 16 & 255, u[u.length - 8] = t >>> 24 & 255, u;
|
|
323
|
+
}
|
|
324
|
+
getDigest() {
|
|
325
|
+
const e = new Uint8Array(new ArrayBuffer(20));
|
|
326
|
+
return e[3] = this.current[0] & 255, e[2] = this.current[0] >>> 8 & 255, e[1] = this.current[0] >>> 16 & 255, e[0] = this.current[0] >>> 24 & 255, e[7] = this.current[1] & 255, e[6] = this.current[1] >>> 8 & 255, e[5] = this.current[1] >>> 16 & 255, e[4] = this.current[1] >>> 24 & 255, e[11] = this.current[2] & 255, e[10] = this.current[2] >>> 8 & 255, e[9] = this.current[2] >>> 16 & 255, e[8] = this.current[2] >>> 24 & 255, e[15] = this.current[3] & 255, e[14] = this.current[3] >>> 8 & 255, e[13] = this.current[3] >>> 16 & 255, e[12] = this.current[3] >>> 24 & 255, e[19] = this.current[4] & 255, e[18] = this.current[4] >>> 8 & 255, e[17] = this.current[4] >>> 16 & 255, e[16] = this.current[4] >>> 24 & 255, e.buffer;
|
|
327
|
+
}
|
|
328
|
+
reset() {
|
|
329
|
+
this.currentLen = 0, this.inLen = 0, this.current[0] = 1732584193, this.current[1] = 4023233417, this.current[2] = 2562383102, this.current[3] = 271733878, this.current[4] = 3285377520;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function Ee(r) {
|
|
333
|
+
const e = new ArrayBuffer(r.length), t = new Uint8Array(e);
|
|
334
|
+
for (let o = 0; o < r.length; o++)
|
|
335
|
+
t[o] = r.charCodeAt(o);
|
|
336
|
+
return t;
|
|
337
|
+
}
|
|
338
|
+
function Pe(r) {
|
|
339
|
+
const e = new ArrayBuffer(1), t = new Uint8Array(e);
|
|
340
|
+
return t[0] = r, t;
|
|
341
|
+
}
|
|
342
|
+
function R(r) {
|
|
343
|
+
if (r instanceof Uint8Array)
|
|
344
|
+
return r;
|
|
345
|
+
if (r instanceof ArrayBuffer)
|
|
346
|
+
return new Uint8Array(r);
|
|
347
|
+
if (typeof r == "string")
|
|
348
|
+
return Ee(r);
|
|
349
|
+
if (typeof r == "number") {
|
|
350
|
+
if (r > 255)
|
|
351
|
+
throw new Error("For more than one byte, use an array buffer");
|
|
352
|
+
if (r < 0)
|
|
353
|
+
throw new Error("Input value must be positive");
|
|
354
|
+
return Pe(r);
|
|
355
|
+
} else
|
|
356
|
+
throw new Error("Unsupported type");
|
|
357
|
+
}
|
|
358
|
+
function ee(r) {
|
|
359
|
+
const e = function(c) {
|
|
360
|
+
let u = c.length, d = 0;
|
|
361
|
+
for (; u > 0; ) {
|
|
362
|
+
let s = this.blockLen - this.inLen;
|
|
363
|
+
s > u && (s = u);
|
|
364
|
+
const p = c.subarray(d, d + s);
|
|
365
|
+
this.inbuf.set(p, this.inLen), d += s, u -= s, this.inLen += s, this.inLen === this.blockLen && (this.processBlock(this.inbuf), this.inLen = 0);
|
|
366
|
+
}
|
|
367
|
+
}, t = function() {
|
|
368
|
+
const c = this.doPadding();
|
|
369
|
+
this.update(c);
|
|
370
|
+
const u = this.getDigest();
|
|
371
|
+
return this.reset(), u;
|
|
372
|
+
}, o = new r();
|
|
373
|
+
return o.inbuf = new Uint8Array(new ArrayBuffer(o.blockLen)), o.reset(), o.update = e, o.finalize = t, {
|
|
374
|
+
update(c) {
|
|
375
|
+
o.update(R(c));
|
|
376
|
+
},
|
|
377
|
+
finalize() {
|
|
378
|
+
return o.finalize();
|
|
379
|
+
},
|
|
380
|
+
digest(c) {
|
|
381
|
+
return o.update(R(c)), o.finalize();
|
|
382
|
+
},
|
|
383
|
+
reset() {
|
|
384
|
+
o.reset();
|
|
385
|
+
},
|
|
386
|
+
digestLength() {
|
|
387
|
+
return o.digestLen;
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
function Fe(r) {
|
|
392
|
+
let e = !1, t, o, c;
|
|
393
|
+
const u = function() {
|
|
394
|
+
if (e)
|
|
395
|
+
return;
|
|
396
|
+
if (t === void 0)
|
|
397
|
+
throw new Error("MAC key is not defined");
|
|
398
|
+
let n;
|
|
399
|
+
t.byteLength > 64 ? n = new Uint8Array(r.digest(t)) : n = new Uint8Array(t), o = new Uint8Array(new ArrayBuffer(64));
|
|
400
|
+
for (let a = 0; a < n.length; a++)
|
|
401
|
+
o[a] = 54 ^ n[a];
|
|
402
|
+
for (let a = n.length; a < 64; a++)
|
|
403
|
+
o[a] = 54;
|
|
404
|
+
c = new Uint8Array(new ArrayBuffer(64));
|
|
405
|
+
for (let a = 0; a < n.length; a++)
|
|
406
|
+
c[a] = 92 ^ n[a];
|
|
407
|
+
for (let a = n.length; a < 64; a++)
|
|
408
|
+
c[a] = 92;
|
|
409
|
+
e = !0, r.update(o.buffer);
|
|
410
|
+
}, d = function() {
|
|
411
|
+
e = !1, t = void 0, o = void 0, c = void 0, r.reset();
|
|
412
|
+
}, s = function() {
|
|
413
|
+
const n = r.finalize();
|
|
414
|
+
r.reset(), r.update(c.buffer), r.update(new Uint8Array(n));
|
|
415
|
+
const a = r.finalize();
|
|
416
|
+
return d(), a;
|
|
417
|
+
}, p = function(n) {
|
|
418
|
+
t = n;
|
|
419
|
+
};
|
|
420
|
+
return {
|
|
421
|
+
setKey(n) {
|
|
422
|
+
p(R(n)), u();
|
|
423
|
+
},
|
|
424
|
+
update(n) {
|
|
425
|
+
r.update(R(n));
|
|
426
|
+
},
|
|
427
|
+
finalize() {
|
|
428
|
+
return s();
|
|
429
|
+
},
|
|
430
|
+
mac(n) {
|
|
431
|
+
return this.update(n), this.finalize();
|
|
432
|
+
},
|
|
433
|
+
reset() {
|
|
434
|
+
d();
|
|
435
|
+
},
|
|
436
|
+
hmacLength() {
|
|
437
|
+
return r.digestLength();
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
const ce = {
|
|
442
|
+
SHA1: function() {
|
|
443
|
+
return ee(X);
|
|
444
|
+
},
|
|
445
|
+
HMAC_SHA1: function() {
|
|
446
|
+
return Fe(ee(X));
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
function Ie(r) {
|
|
450
|
+
const e = new Uint8Array(r.length * 4);
|
|
451
|
+
let t = 0;
|
|
452
|
+
for (let o = 0; o < r.length; o++) {
|
|
453
|
+
let c = r.charCodeAt(o);
|
|
454
|
+
if (c >= 55296 && c <= 56319 && o + 1 < r.length) {
|
|
455
|
+
const u = r.charCodeAt(o + 1);
|
|
456
|
+
u >= 56320 && u <= 57343 && (c = (c - 55296) * 1024 + (u - 56320) + 65536, o += 1);
|
|
457
|
+
}
|
|
458
|
+
c < 128 ? e[t++] = c : c < 2048 ? (e[t++] = 192 | c >> 6, e[t++] = 128 | c & 63) : c < 65536 ? (e[t++] = 224 | c >> 12, e[t++] = 128 | c >> 6 & 63, e[t++] = 128 | c & 63) : (e[t++] = 240 | c >> 18, e[t++] = 128 | c >> 12 & 63, e[t++] = 128 | c >> 6 & 63, e[t++] = 128 | c & 63);
|
|
459
|
+
}
|
|
460
|
+
return e.subarray(0, t);
|
|
461
|
+
}
|
|
462
|
+
const te = typeof TextEncoder != "undefined" ? new TextEncoder() : null;
|
|
463
|
+
function F(r) {
|
|
464
|
+
return te ? te.encode(r) : Ie(r);
|
|
465
|
+
}
|
|
466
|
+
function ie(r) {
|
|
467
|
+
return typeof r == "string" ? Promise.resolve(F(r)) : r instanceof ArrayBuffer ? Promise.resolve(new Uint8Array(r)) : ArrayBuffer.isView(r) ? Promise.resolve(new Uint8Array(r.buffer, r.byteOffset, r.byteLength)) : r.arrayBuffer().then((e) => new Uint8Array(e));
|
|
468
|
+
}
|
|
469
|
+
function Me(r) {
|
|
470
|
+
const { accessKeyId: e, accessKeySecret: t, bucket: o, endpoint: c } = r;
|
|
471
|
+
if (!e) throw new Error("need accessKeyId");
|
|
472
|
+
if (!t) throw new Error("need accessKeySecret");
|
|
473
|
+
if (!o && !c) throw new Error("need bucket or endpoint");
|
|
474
|
+
}
|
|
475
|
+
function $e(r) {
|
|
476
|
+
const e = [];
|
|
477
|
+
for (let t = 0; t < r.length; t += 2)
|
|
478
|
+
e.push(parseInt(r[t] + r[t + 1], 16));
|
|
479
|
+
return Uint8Array.from(e);
|
|
480
|
+
}
|
|
481
|
+
function D(r) {
|
|
482
|
+
const e = Array.prototype.slice.call(r, 0), t = $e(Se(e));
|
|
483
|
+
return ke.fromByteArray(t);
|
|
484
|
+
}
|
|
485
|
+
const Re = {
|
|
486
|
+
region: "oss-cn-hangzhou",
|
|
487
|
+
internal: !1,
|
|
488
|
+
cname: !1,
|
|
489
|
+
secure: !1,
|
|
490
|
+
timeout: 6e4
|
|
491
|
+
};
|
|
492
|
+
function ue(r = {}, e = Re) {
|
|
493
|
+
return Me(r), Object.assign({}, e, r);
|
|
494
|
+
}
|
|
495
|
+
function qe(r, e) {
|
|
496
|
+
const t = e || r.timeout;
|
|
497
|
+
return typeof t == "string" ? parseInt(t, 10) : t;
|
|
498
|
+
}
|
|
499
|
+
function He(r) {
|
|
500
|
+
if (r != null) {
|
|
501
|
+
if (typeof r == "string") return F(r).length;
|
|
502
|
+
if (r instanceof Blob) return r.size;
|
|
503
|
+
if (r instanceof ArrayBuffer || ArrayBuffer.isView(r)) return r.byteLength;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function O(r) {
|
|
507
|
+
return encodeURIComponent(r).replace(/!/g, "%21").replace(/'/g, "%27").replace(/\(/g, "%28").replace(/\)/g, "%29").replace(/\*/g, "%2A");
|
|
508
|
+
}
|
|
509
|
+
function fe(r) {
|
|
510
|
+
let e = "";
|
|
511
|
+
for (let t = 0; t < r.length; t++)
|
|
512
|
+
e += r[t].toString(16).padStart(2, "0");
|
|
513
|
+
return e;
|
|
514
|
+
}
|
|
515
|
+
function ze(r) {
|
|
516
|
+
return fe(new Uint8Array(ce.SHA1().digest(F(r))));
|
|
517
|
+
}
|
|
518
|
+
function re(r, e) {
|
|
519
|
+
const t = ce.HMAC_SHA1();
|
|
520
|
+
return t.setKey(F(r)), t.update(F(e)), fe(new Uint8Array(t.finalize()));
|
|
521
|
+
}
|
|
522
|
+
function _(r, e) {
|
|
523
|
+
return Object.keys(r).map((o) => e ? O(o).toLowerCase() : o).sort();
|
|
524
|
+
}
|
|
525
|
+
function ne(r, e) {
|
|
526
|
+
return _(r).map((t) => {
|
|
527
|
+
const o = r[t] === void 0 || r[t] === null ? "" : String(r[t]), c = O(t).toLowerCase(), u = O(o) || "";
|
|
528
|
+
return `${c}=${u}`;
|
|
529
|
+
}).join("&");
|
|
530
|
+
}
|
|
531
|
+
const Ke = [
|
|
532
|
+
"cache-control",
|
|
533
|
+
"content-disposition",
|
|
534
|
+
"content-encoding",
|
|
535
|
+
"content-length",
|
|
536
|
+
"content-md5",
|
|
537
|
+
"expect",
|
|
538
|
+
"expires",
|
|
539
|
+
"host",
|
|
540
|
+
"if-match",
|
|
541
|
+
"if-modified-since",
|
|
542
|
+
"if-none-match",
|
|
543
|
+
"if-unmodified-since",
|
|
544
|
+
"origin",
|
|
545
|
+
"range",
|
|
546
|
+
"transfer-encoding",
|
|
547
|
+
"pic-operations"
|
|
548
|
+
];
|
|
549
|
+
function Oe(r) {
|
|
550
|
+
const e = {};
|
|
551
|
+
return Object.keys(r).forEach((t) => {
|
|
552
|
+
const o = t.toLowerCase();
|
|
553
|
+
(o.indexOf("x-cos-") === 0 || o.indexOf("x-ci-") === 0 || Ke.indexOf(o) > -1) && (e[t] = String(r[t]));
|
|
554
|
+
}), e;
|
|
555
|
+
}
|
|
556
|
+
function le(r) {
|
|
557
|
+
const { method: e, pathname: t, secretId: o, secretKey: c } = r;
|
|
558
|
+
if (!o) throw new Error("need accessKeyId (SecretId)");
|
|
559
|
+
if (!c) throw new Error("need accessKeySecret (SecretKey)");
|
|
560
|
+
const u = Oe(b({}, r.headers));
|
|
561
|
+
r.host && !u.Host && !u.host && (u.Host = r.host);
|
|
562
|
+
const d = {};
|
|
563
|
+
r.query && Object.keys(r.query).forEach((y) => {
|
|
564
|
+
const m = r.query[y];
|
|
565
|
+
m !== void 0 && (d[y] = String(m));
|
|
566
|
+
});
|
|
567
|
+
const s = Math.floor(Date.now() / 1e3) - 1, p = s + (r.expires === void 0 ? 900 : r.expires || 0), n = r.keyTime || `${s};${p}`, a = re(c, n), l = [
|
|
568
|
+
e.toLowerCase(),
|
|
569
|
+
t,
|
|
570
|
+
ne(d),
|
|
571
|
+
ne(u),
|
|
572
|
+
""
|
|
573
|
+
].join(`
|
|
574
|
+
`), f = ["sha1", n, ze(l), ""].join(`
|
|
575
|
+
`), i = re(a, f), h = _(u, !0).join(";"), g = _(d, !0).join(";");
|
|
576
|
+
return [
|
|
577
|
+
"q-sign-algorithm=sha1",
|
|
578
|
+
`q-ak=${o}`,
|
|
579
|
+
`q-sign-time=${n}`,
|
|
580
|
+
`q-key-time=${n}`,
|
|
581
|
+
`q-header-list=${h}`,
|
|
582
|
+
`q-url-param-list=${g}`,
|
|
583
|
+
`q-signature=${i}`
|
|
584
|
+
].join("&");
|
|
585
|
+
}
|
|
586
|
+
function de(r) {
|
|
587
|
+
const { bucket: e, region: t, endpoint: o } = r;
|
|
588
|
+
return o || `${e}.cos.${t}.myqcloud.com`;
|
|
589
|
+
}
|
|
590
|
+
function _e(r, e) {
|
|
591
|
+
const t = ue(r), { accessKeyId: o, accessKeySecret: c, stsToken: u, secure: d } = t, s = de(t), p = b({
|
|
592
|
+
Host: s,
|
|
593
|
+
Date: (/* @__PURE__ */ new Date()).toUTCString()
|
|
594
|
+
}, e.headers);
|
|
595
|
+
u && (p["x-cos-security-token"] = u);
|
|
596
|
+
const n = e.objectName === "" ? "/" : `/${e.objectName}`, a = le({
|
|
597
|
+
method: e.verb,
|
|
598
|
+
pathname: n,
|
|
599
|
+
query: e.subResource,
|
|
600
|
+
headers: p,
|
|
601
|
+
secretId: o,
|
|
602
|
+
secretKey: c,
|
|
603
|
+
host: s
|
|
604
|
+
});
|
|
605
|
+
p.Authorization = a;
|
|
606
|
+
let f = `${d ? "https" : "http"}://${s}${n}`;
|
|
607
|
+
if (e.subResource) {
|
|
608
|
+
const i = Object.keys(e.subResource).map((h) => {
|
|
609
|
+
const g = e.subResource[h];
|
|
610
|
+
return g === "" || g == null ? h : `${h}=${encodeURIComponent(g)}`;
|
|
611
|
+
}).join("&");
|
|
612
|
+
i && (f += `?${i}`);
|
|
613
|
+
}
|
|
614
|
+
return Ae()(f, {
|
|
615
|
+
method: e.verb,
|
|
616
|
+
headers: p,
|
|
617
|
+
data: e.data,
|
|
618
|
+
timeout: e.timeout == null ? qe(t) : e.timeout,
|
|
619
|
+
onprogress: e.onprogress,
|
|
620
|
+
total: He(e.data)
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
function De(r, e, t = {}) {
|
|
624
|
+
const { expires: o = 1800, method: c, process: u, response: d } = t, s = ue(r), { accessKeyId: p, accessKeySecret: n, stsToken: a, secure: l } = s, f = de(s), i = {};
|
|
625
|
+
u && (i["pic-operations"] = u), d && Object.keys(d).forEach((x) => {
|
|
626
|
+
i[`response-${x.toLowerCase()}`] = String(d[x]);
|
|
627
|
+
}), Object.keys(t).forEach((x) => {
|
|
628
|
+
const v = x.toLowerCase();
|
|
629
|
+
(v.indexOf("x-cos-") === 0 || v !== "expires" && v !== "response" && v !== "process" && v !== "method" && v !== "security-token") && (i[v] = String(t[x]));
|
|
630
|
+
});
|
|
631
|
+
const h = t["security-token"] || a, g = e === "" ? "/" : `/${e}`, y = le({
|
|
632
|
+
method: c || "GET",
|
|
633
|
+
pathname: g,
|
|
634
|
+
query: i,
|
|
635
|
+
headers: { Host: f },
|
|
636
|
+
secretId: p,
|
|
637
|
+
secretKey: n,
|
|
638
|
+
expires: o,
|
|
639
|
+
host: f
|
|
640
|
+
});
|
|
641
|
+
let w = `${l ? "https" : "http"}://${f}${g}?`;
|
|
642
|
+
return w += y.split("&").map((x) => {
|
|
643
|
+
const v = x.indexOf("=");
|
|
644
|
+
return `${x.slice(0, v)}=${encodeURIComponent(x.slice(v + 1))}`;
|
|
645
|
+
}).join("&"), h && (w += `&x-cos-security-token=${encodeURIComponent(h)}`), Object.keys(i).forEach((x) => {
|
|
646
|
+
w += `&${x}=${encodeURIComponent(i[x])}`;
|
|
647
|
+
}), w;
|
|
648
|
+
}
|
|
649
|
+
function je(r) {
|
|
650
|
+
return function(t, o, c, u = {}) {
|
|
651
|
+
return ie(c).then((d) => {
|
|
652
|
+
const s = D(d), p = typeof c == "string" ? "text/plain; charset=utf-8" : c instanceof Blob ? c.type : "application/octet-stream", n = {
|
|
653
|
+
"Content-Md5": s,
|
|
654
|
+
"Content-Type": p
|
|
655
|
+
};
|
|
656
|
+
return r.request(t, {
|
|
657
|
+
verb: "PUT",
|
|
658
|
+
objectName: o,
|
|
659
|
+
contentMd5: s,
|
|
660
|
+
headers: n,
|
|
661
|
+
// Strings are already encoded to bytes for the MD5; send those
|
|
662
|
+
// bytes to avoid encoding twice and to give the transport a size.
|
|
663
|
+
data: typeof c == "string" ? d : c,
|
|
664
|
+
onprogress: u.onprogress
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
function U(r, e) {
|
|
670
|
+
const t = new RegExp(`<${e}>([\\s\\S]*?)</${e}>`).exec(r);
|
|
671
|
+
return t ? t[1] : "";
|
|
672
|
+
}
|
|
673
|
+
function he(r, e) {
|
|
674
|
+
const t = new RegExp(`<${e}>[\\s\\S]*?</${e}>`, "g"), o = [];
|
|
675
|
+
let c;
|
|
676
|
+
for (; (c = t.exec(r)) !== null; )
|
|
677
|
+
o.push(c[0]);
|
|
678
|
+
return o;
|
|
679
|
+
}
|
|
680
|
+
function Ne(r) {
|
|
681
|
+
return function(t, o, c = {}) {
|
|
682
|
+
const u = b({}, c.headers);
|
|
683
|
+
return r.request(t, {
|
|
684
|
+
verb: "POST",
|
|
685
|
+
objectName: o,
|
|
686
|
+
headers: u,
|
|
687
|
+
subResource: { uploads: "" },
|
|
688
|
+
timeout: c.timeout
|
|
689
|
+
}).then((d) => {
|
|
690
|
+
const s = U(d.data, "UploadId");
|
|
691
|
+
return {
|
|
692
|
+
name: o,
|
|
693
|
+
uploadId: s,
|
|
694
|
+
res: d.data
|
|
695
|
+
};
|
|
696
|
+
});
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
function Ge(r) {
|
|
700
|
+
return function(a, l, f, i, h, g, y) {
|
|
701
|
+
return P(this, arguments, function* (t, o, c, u, d, s, p, n = {}) {
|
|
702
|
+
const m = ArrayBuffer.isView(d) && !(d instanceof DataView) ? d.subarray(s, p) : d.slice(s, p), w = yield ie(m), x = D(w), v = m instanceof Blob && m.type || "application/octet-stream", T = b({
|
|
703
|
+
"Content-Md5": x,
|
|
704
|
+
"Content-Type": v
|
|
705
|
+
}, n.headers);
|
|
706
|
+
return r.request(t, {
|
|
707
|
+
verb: "PUT",
|
|
708
|
+
objectName: o,
|
|
709
|
+
contentMd5: x,
|
|
710
|
+
headers: T,
|
|
711
|
+
subResource: { uploadId: c, partNumber: u.toString() },
|
|
712
|
+
data: m,
|
|
713
|
+
timeout: n.timeout
|
|
714
|
+
}).then((B) => ({
|
|
715
|
+
name: o,
|
|
716
|
+
etag: B.headers.etag || "",
|
|
717
|
+
res: B.data
|
|
718
|
+
}));
|
|
719
|
+
});
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
function Ve(r) {
|
|
723
|
+
return function(s, p, n, a) {
|
|
724
|
+
return P(this, arguments, function* (t, o, c, u, d = {}) {
|
|
725
|
+
const f = `<?xml version="1.0" encoding="UTF-8"?>
|
|
726
|
+
<CompleteMultipartUpload>
|
|
727
|
+
${u.sort((y, m) => y.number - m.number).map((y) => ` <Part><PartNumber>${y.number}</PartNumber><ETag>${y.etag}</ETag></Part>`).join(`
|
|
728
|
+
`)}
|
|
729
|
+
</CompleteMultipartUpload>`, i = F(f), h = D(i), g = b({
|
|
730
|
+
"Content-Md5": h,
|
|
731
|
+
"Content-Type": "application/xml"
|
|
732
|
+
}, d.headers);
|
|
733
|
+
return r.request(t, {
|
|
734
|
+
verb: "POST",
|
|
735
|
+
objectName: o,
|
|
736
|
+
contentMd5: h,
|
|
737
|
+
headers: g,
|
|
738
|
+
subResource: { uploadId: c },
|
|
739
|
+
data: i,
|
|
740
|
+
timeout: d.timeout
|
|
741
|
+
}).then((y) => {
|
|
742
|
+
const m = U(y.data, "ETag");
|
|
743
|
+
return {
|
|
744
|
+
name: o,
|
|
745
|
+
etag: m,
|
|
746
|
+
bucket: t.bucket,
|
|
747
|
+
res: y.data
|
|
748
|
+
};
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
function We(r) {
|
|
754
|
+
return function(t, o, c, u = {}) {
|
|
755
|
+
return r.request(t, {
|
|
756
|
+
verb: "DELETE",
|
|
757
|
+
objectName: o,
|
|
758
|
+
headers: b({}, u.headers),
|
|
759
|
+
subResource: { uploadId: c },
|
|
760
|
+
timeout: u.timeout
|
|
761
|
+
}).then(() => {
|
|
762
|
+
});
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
function Je(r) {
|
|
766
|
+
return function(t, o, c, u = {}, d = {}) {
|
|
767
|
+
const s = { uploadId: c };
|
|
768
|
+
return u["max-parts"] && (s["max-parts"] = u["max-parts"].toString()), u["part-number-marker"] && (s["part-number-marker"] = u["part-number-marker"].toString()), r.request(t, {
|
|
769
|
+
verb: "GET",
|
|
770
|
+
objectName: o,
|
|
771
|
+
headers: b({}, d.headers),
|
|
772
|
+
subResource: s,
|
|
773
|
+
timeout: d.timeout
|
|
774
|
+
}).then((p) => {
|
|
775
|
+
const n = p.data, a = U(n, "IsTruncated") === "true", l = parseInt(U(n, "NextPartNumberMarker") || "0", 10), f = he(n, "Part").map((i) => ({
|
|
776
|
+
PartNumber: parseInt(U(i, "PartNumber") || "0", 10),
|
|
777
|
+
LastModified: U(i, "LastModified"),
|
|
778
|
+
ETag: U(i, "ETag"),
|
|
779
|
+
Size: parseInt(U(i, "Size") || "0", 10)
|
|
780
|
+
}));
|
|
781
|
+
return {
|
|
782
|
+
isTruncated: a,
|
|
783
|
+
nextPartNumberMarker: l,
|
|
784
|
+
parts: f,
|
|
785
|
+
res: p.data
|
|
786
|
+
};
|
|
787
|
+
});
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
function Ze(r) {
|
|
791
|
+
return function(t, o = {}, c = {}) {
|
|
792
|
+
const u = { uploads: "" };
|
|
793
|
+
return o.prefix && (u.prefix = o.prefix), o.marker && (u[r.listUploadsMarkerKey] = o.marker), o["max-uploads"] && (u["max-uploads"] = o["max-uploads"].toString()), o["upload-id-marker"] && (u["upload-id-marker"] = o["upload-id-marker"]), r.request(t, {
|
|
794
|
+
verb: "GET",
|
|
795
|
+
objectName: "",
|
|
796
|
+
headers: b({}, c.headers),
|
|
797
|
+
subResource: u,
|
|
798
|
+
timeout: c.timeout
|
|
799
|
+
}).then((d) => {
|
|
800
|
+
const s = d.data, p = U(s, "IsTruncated") === "true", n = U(s, "NextKeyMarker") || void 0, a = U(s, "NextUploadIdMarker") || void 0;
|
|
801
|
+
return {
|
|
802
|
+
uploads: he(s, "Upload").map((f) => ({
|
|
803
|
+
uploadId: U(f, "UploadId"),
|
|
804
|
+
name: U(f, "Key"),
|
|
805
|
+
initiated: U(f, "Initiated")
|
|
806
|
+
})),
|
|
807
|
+
isTruncated: p,
|
|
808
|
+
nextKeyMarker: n,
|
|
809
|
+
nextUploadIdMarker: a,
|
|
810
|
+
res: d.data
|
|
811
|
+
};
|
|
812
|
+
});
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
function Qe(r) {
|
|
816
|
+
return function(t, o, c, u, d, s, p = {}) {
|
|
817
|
+
const n = t.bucket, l = `/${s.sourceBucket || n}/${encodeURIComponent(s.sourceKey)}`, f = b({
|
|
818
|
+
[r.copySourceHeader]: l,
|
|
819
|
+
[r.copySourceRangeHeader]: d
|
|
820
|
+
}, p.headers);
|
|
821
|
+
return r.request(t, {
|
|
822
|
+
verb: "PUT",
|
|
823
|
+
objectName: o,
|
|
824
|
+
headers: f,
|
|
825
|
+
subResource: { uploadId: c, partNumber: u.toString() },
|
|
826
|
+
timeout: p.timeout
|
|
827
|
+
}).then((i) => {
|
|
828
|
+
const h = U(i.data, "ETag"), g = U(i.data, "LastModified");
|
|
829
|
+
return {
|
|
830
|
+
etag: h,
|
|
831
|
+
lastModified: g,
|
|
832
|
+
res: i.data
|
|
833
|
+
};
|
|
834
|
+
});
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
function oe(r) {
|
|
838
|
+
return typeof r == "string" ? F(r).length : r instanceof Blob ? r.size : r.byteLength;
|
|
839
|
+
}
|
|
840
|
+
function Ye(r, e) {
|
|
841
|
+
return function(s, p, n) {
|
|
842
|
+
return P(this, arguments, function* (o, c, u, d = {}) {
|
|
843
|
+
const {
|
|
844
|
+
parallel: a = 5,
|
|
845
|
+
partSize: l = 1024 * 1024,
|
|
846
|
+
// default 1MB
|
|
847
|
+
checkpoint: f,
|
|
848
|
+
progress: i,
|
|
849
|
+
meta: h,
|
|
850
|
+
mime: g,
|
|
851
|
+
headers: y = {}
|
|
852
|
+
} = d;
|
|
853
|
+
let m, w = [], x = Math.max(l, 100 * 1024);
|
|
854
|
+
const v = oe(u);
|
|
855
|
+
if (v === 0)
|
|
856
|
+
throw new Error("multipart upload requires a non-empty file");
|
|
857
|
+
if (f && f.uploadId && oe(f.file) === v)
|
|
858
|
+
m = f.uploadId, w = f.doneParts || [], f.partSize && (x = f.partSize);
|
|
859
|
+
else {
|
|
860
|
+
const A = b({}, y);
|
|
861
|
+
g && (A["Content-Type"] = g), h && Object.keys(h).forEach((C) => {
|
|
862
|
+
A[`${r.metaPrefix}${C}`] = h[C];
|
|
863
|
+
}), m = (yield e.initMultipartUpload(o, c, { headers: A })).uploadId;
|
|
864
|
+
}
|
|
865
|
+
const T = Math.ceil(v / x), B = {
|
|
866
|
+
file: u,
|
|
867
|
+
name: c,
|
|
868
|
+
uploadId: m,
|
|
869
|
+
partSize: x,
|
|
870
|
+
parts: [],
|
|
871
|
+
doneParts: [...w]
|
|
872
|
+
};
|
|
873
|
+
for (let A = 1; A <= T; A++)
|
|
874
|
+
w.some((C) => C.number === A) || B.parts.push({ number: A, etag: "" });
|
|
875
|
+
const pe = (A, L, C) => P(null, null, function* () {
|
|
876
|
+
const k = () => P(null, null, function* () {
|
|
877
|
+
const M = yield e.uploadPart(o, c, m, A, u, L, C);
|
|
878
|
+
if (!M.etag)
|
|
879
|
+
throw new Error("cannot read the ETag of the uploaded part; make sure the bucket CORS rule exposes the ETag response header");
|
|
880
|
+
return M;
|
|
881
|
+
});
|
|
882
|
+
let E;
|
|
883
|
+
try {
|
|
884
|
+
E = yield k();
|
|
885
|
+
} catch (M) {
|
|
886
|
+
E = yield k();
|
|
887
|
+
}
|
|
888
|
+
if (B.doneParts.push({ number: A, etag: E.etag }), i) {
|
|
889
|
+
const M = B.doneParts.length / T;
|
|
890
|
+
i(M, B, E);
|
|
891
|
+
}
|
|
892
|
+
return { number: A, etag: E.etag };
|
|
893
|
+
}), ge = B.parts.filter((A) => !w.some((L) => L.number === A.number)), j = [], I = [];
|
|
894
|
+
for (const A of ge) {
|
|
895
|
+
const L = (A.number - 1) * x, C = Math.min(A.number * x, v), k = pe(A.number, L, C);
|
|
896
|
+
j.push(k), I.push(k), k.finally(() => {
|
|
897
|
+
const E = I.indexOf(k);
|
|
898
|
+
E > -1 && I.splice(E, 1);
|
|
899
|
+
}), I.length >= a && (yield Promise.race(I));
|
|
900
|
+
}
|
|
901
|
+
yield Promise.all(j);
|
|
902
|
+
const ye = [...w, ...B.doneParts].filter((A, L, C) => C.findIndex((k) => k.number === A.number) === L);
|
|
903
|
+
return e.completeMultipartUpload(o, c, m, ye);
|
|
904
|
+
});
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
function ot(r, e) {
|
|
908
|
+
const { method: t, headers: o, data: c, timeout: u, onprogress: d, total: s } = e, p = new AbortController();
|
|
909
|
+
let n;
|
|
910
|
+
return u && (n = setTimeout(() => p.abort(), u)), d && s && d({ loaded: 0, total: s, lengthComputable: !1 }), fetch(r, {
|
|
911
|
+
method: t,
|
|
912
|
+
headers: o,
|
|
913
|
+
body: c,
|
|
914
|
+
signal: p.signal
|
|
915
|
+
}).then((a) => P(null, null, function* () {
|
|
916
|
+
const l = yield a.text();
|
|
917
|
+
if (a.status < 200 || a.status >= 300)
|
|
918
|
+
throw new Error(`the request is error: ${a.status} ${a.statusText} ${l}`);
|
|
919
|
+
d && s && d({ loaded: s, total: s, lengthComputable: !1 });
|
|
920
|
+
const f = {};
|
|
921
|
+
return a.headers.forEach((i, h) => {
|
|
922
|
+
f[h] = i;
|
|
923
|
+
}), {
|
|
924
|
+
data: l,
|
|
925
|
+
headers: f,
|
|
926
|
+
status: a.status,
|
|
927
|
+
statusText: a.statusText
|
|
928
|
+
};
|
|
929
|
+
})).finally(() => {
|
|
930
|
+
n && clearTimeout(n);
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
function st(r, e) {
|
|
934
|
+
const { method: t, headers: o, data: c, timeout: u, onprogress: d, total: s } = e;
|
|
935
|
+
return typeof wx == "undefined" ? Promise.reject(new Error("wxRequestTransport requires the WeChat mini program runtime")) : (d && s && d({ loaded: 0, total: s, lengthComputable: !1 }), new Promise((p, n) => {
|
|
936
|
+
wx.request({
|
|
937
|
+
url: r,
|
|
938
|
+
method: t,
|
|
939
|
+
header: o,
|
|
940
|
+
data: c instanceof Uint8Array ? c.buffer : c,
|
|
941
|
+
timeout: u,
|
|
942
|
+
success: (a) => {
|
|
943
|
+
d && s && d({ loaded: s, total: s, lengthComputable: !1 }), p({ data: a.data, headers: a.header, status: a.statusCode, statusText: "" });
|
|
944
|
+
},
|
|
945
|
+
fail: (a) => {
|
|
946
|
+
n(a instanceof Error ? a : new Error(String(a)));
|
|
947
|
+
}
|
|
948
|
+
});
|
|
949
|
+
}));
|
|
950
|
+
}
|
|
951
|
+
function at(r, e) {
|
|
952
|
+
return (...t) => r(e, ...t);
|
|
953
|
+
}
|
|
954
|
+
const S = {
|
|
955
|
+
request: _e,
|
|
956
|
+
metaPrefix: "x-cos-meta-",
|
|
957
|
+
copySourceHeader: "x-cos-copy-source",
|
|
958
|
+
copySourceRangeHeader: "x-cos-copy-source-range",
|
|
959
|
+
listUploadsMarkerKey: "key-marker",
|
|
960
|
+
supportsSymlink: !1,
|
|
961
|
+
signUrl: De
|
|
962
|
+
}, ct = je(S), Xe = Ne(S), et = Ge(S), tt = Ve(S), it = Ye(S, {
|
|
963
|
+
initMultipartUpload: Xe,
|
|
964
|
+
uploadPart: et,
|
|
965
|
+
completeMultipartUpload: tt
|
|
966
|
+
}), ut = We(S), ft = Je(S), lt = Ze(S), dt = Qe(S), ht = S.signUrl;
|
|
967
|
+
export {
|
|
968
|
+
ut as abortMultipartUpload,
|
|
969
|
+
at as bindOptions,
|
|
970
|
+
tt as completeMultipartUpload,
|
|
971
|
+
ot as fetchTransport,
|
|
972
|
+
Ae as getTransport,
|
|
973
|
+
Xe as initMultipartUpload,
|
|
974
|
+
ft as listParts,
|
|
975
|
+
lt as listUploads,
|
|
976
|
+
it as multipartUpload,
|
|
977
|
+
ct as put,
|
|
978
|
+
nt as setTransport,
|
|
979
|
+
ht as signatureUrl,
|
|
980
|
+
et as uploadPart,
|
|
981
|
+
dt as uploadPartCopy,
|
|
982
|
+
st as wxRequestTransport
|
|
983
|
+
};
|
|
984
|
+
//# sourceMappingURL=tiny-oss.cos.es.js.map
|