tiny-oss 0.5.0 → 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.
@@ -0,0 +1,882 @@
1
+ var dt = Object.defineProperty;
2
+ var J = Object.getOwnPropertySymbols;
3
+ var pt = Object.prototype.hasOwnProperty, yt = Object.prototype.propertyIsEnumerable;
4
+ var G = (e, n, t) => n in e ? dt(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, E = (e, n) => {
5
+ for (var t in n || (n = {}))
6
+ pt.call(n, t) && G(e, t, n[t]);
7
+ if (J)
8
+ for (var t of J(n))
9
+ yt.call(n, t) && G(e, t, n[t]);
10
+ return e;
11
+ };
12
+ var z = (e, n, t) => new Promise((u, i) => {
13
+ var l = (p) => {
14
+ try {
15
+ s(t.next(p));
16
+ } catch (r) {
17
+ i(r);
18
+ }
19
+ }, h = (p) => {
20
+ try {
21
+ s(t.throw(p));
22
+ } catch (r) {
23
+ i(r);
24
+ }
25
+ }, s = (p) => p.done ? u(p.value) : Promise.resolve(p.value).then(l, h);
26
+ s((t = t.apply(e, n)).next());
27
+ });
28
+ function gt(e, n) {
29
+ return new Promise((t, u) => {
30
+ const {
31
+ method: i = "get",
32
+ data: l = null,
33
+ headers: h = {},
34
+ timeout: s = 0,
35
+ onprogress: p
36
+ } = n, r = new XMLHttpRequest();
37
+ let o;
38
+ s && (o = setTimeout(() => {
39
+ u(new Error(`the request timeout ${s}ms`));
40
+ }, s)), r.onerror = () => {
41
+ u(new Error("unknown error"));
42
+ }, r.upload && p && (r.upload.onprogress = (c) => {
43
+ p({ loaded: c.loaded, total: c.total, lengthComputable: c.lengthComputable });
44
+ }), r.onreadystatechange = () => {
45
+ if (r.readyState === 4)
46
+ if (s && clearTimeout(o), r.status >= 200 && r.status < 300) {
47
+ const c = {}, a = r.getAllResponseHeaders();
48
+ a && a.trim().split(/[\r\n]+/).forEach((d) => {
49
+ const y = d.split(": "), g = y.shift(), m = y.join(": ");
50
+ g && (c[g.toLowerCase()] = m);
51
+ }), t({
52
+ data: r.responseText,
53
+ headers: c,
54
+ status: r.status,
55
+ statusText: r.statusText
56
+ });
57
+ } else {
58
+ const c = new Error(`the request is error: ${r.status} ${r.statusText} ${r.responseText || ""}`);
59
+ u(c);
60
+ }
61
+ }, r.open(i, e, !0), Object.keys(h).forEach((c) => {
62
+ r.setRequestHeader(c, h[c]);
63
+ });
64
+ try {
65
+ r.send(l);
66
+ } catch (c) {
67
+ u(c);
68
+ }
69
+ });
70
+ }
71
+ let st = gt;
72
+ function Nt(e) {
73
+ st = e;
74
+ }
75
+ function mt() {
76
+ return st;
77
+ }
78
+ function it(e) {
79
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
80
+ }
81
+ var _ = { exports: {} }, H = { exports: {} }, Q;
82
+ function At() {
83
+ return Q || (Q = 1, (function() {
84
+ var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", n = {
85
+ // Bit-wise rotation left
86
+ rotl: function(t, u) {
87
+ return t << u | t >>> 32 - u;
88
+ },
89
+ // Bit-wise rotation right
90
+ rotr: function(t, u) {
91
+ return t << 32 - u | t >>> u;
92
+ },
93
+ // Swap big-endian to little-endian and vice versa
94
+ endian: function(t) {
95
+ if (t.constructor == Number)
96
+ return n.rotl(t, 8) & 16711935 | n.rotl(t, 24) & 4278255360;
97
+ for (var u = 0; u < t.length; u++)
98
+ t[u] = n.endian(t[u]);
99
+ return t;
100
+ },
101
+ // Generate an array of any length of random bytes
102
+ randomBytes: function(t) {
103
+ for (var u = []; t > 0; t--)
104
+ u.push(Math.floor(Math.random() * 256));
105
+ return u;
106
+ },
107
+ // Convert a byte array to big-endian 32-bit words
108
+ bytesToWords: function(t) {
109
+ for (var u = [], i = 0, l = 0; i < t.length; i++, l += 8)
110
+ u[l >>> 5] |= t[i] << 24 - l % 32;
111
+ return u;
112
+ },
113
+ // Convert big-endian 32-bit words to a byte array
114
+ wordsToBytes: function(t) {
115
+ for (var u = [], i = 0; i < t.length * 32; i += 8)
116
+ u.push(t[i >>> 5] >>> 24 - i % 32 & 255);
117
+ return u;
118
+ },
119
+ // Convert a byte array to a hex string
120
+ bytesToHex: function(t) {
121
+ for (var u = [], i = 0; i < t.length; i++)
122
+ u.push((t[i] >>> 4).toString(16)), u.push((t[i] & 15).toString(16));
123
+ return u.join("");
124
+ },
125
+ // Convert a hex string to a byte array
126
+ hexToBytes: function(t) {
127
+ for (var u = [], i = 0; i < t.length; i += 2)
128
+ u.push(parseInt(t.substr(i, 2), 16));
129
+ return u;
130
+ },
131
+ // Convert a byte array to a base-64 string
132
+ bytesToBase64: function(t) {
133
+ for (var u = [], i = 0; i < t.length; i += 3)
134
+ for (var l = t[i] << 16 | t[i + 1] << 8 | t[i + 2], h = 0; h < 4; h++)
135
+ i * 8 + h * 6 <= t.length * 8 ? u.push(e.charAt(l >>> 6 * (3 - h) & 63)) : u.push("=");
136
+ return u.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 u = [], i = 0, l = 0; i < t.length; l = ++i % 4)
142
+ l != 0 && u.push((e.indexOf(t.charAt(i - 1)) & Math.pow(2, -2 * l + 8) - 1) << l * 2 | e.indexOf(t.charAt(i)) >>> 6 - l * 2);
143
+ return u;
144
+ }
145
+ };
146
+ H.exports = n;
147
+ })()), H.exports;
148
+ }
149
+ var K, X;
150
+ function Y() {
151
+ if (X) return K;
152
+ X = 1;
153
+ var e = {
154
+ // UTF-8 encoding
155
+ utf8: {
156
+ // Convert a string to a byte array
157
+ stringToBytes: function(n) {
158
+ return e.bin.stringToBytes(unescape(encodeURIComponent(n)));
159
+ },
160
+ // Convert a byte array to a string
161
+ bytesToString: function(n) {
162
+ return decodeURIComponent(escape(e.bin.bytesToString(n)));
163
+ }
164
+ },
165
+ // Binary encoding
166
+ bin: {
167
+ // Convert a string to a byte array
168
+ stringToBytes: function(n) {
169
+ for (var t = [], u = 0; u < n.length; u++)
170
+ t.push(n.charCodeAt(u) & 255);
171
+ return t;
172
+ },
173
+ // Convert a byte array to a string
174
+ bytesToString: function(n) {
175
+ for (var t = [], u = 0; u < n.length; u++)
176
+ t.push(String.fromCharCode(n[u]));
177
+ return t.join("");
178
+ }
179
+ }
180
+ };
181
+ return K = e, K;
182
+ }
183
+ var D, N;
184
+ function wt() {
185
+ if (N) return D;
186
+ N = 1, D = function(t) {
187
+ return t != null && (e(t) || n(t) || !!t._isBuffer);
188
+ };
189
+ function e(t) {
190
+ return !!t.constructor && typeof t.constructor.isBuffer == "function" && t.constructor.isBuffer(t);
191
+ }
192
+ function n(t) {
193
+ return typeof t.readFloatLE == "function" && typeof t.slice == "function" && e(t.slice(0, 0));
194
+ }
195
+ return D;
196
+ }
197
+ var tt;
198
+ function vt() {
199
+ return tt || (tt = 1, (function() {
200
+ var e = At(), n = Y().utf8, t = wt(), u = Y().bin, i = function(l, h) {
201
+ l.constructor == String ? h && h.encoding === "binary" ? l = u.stringToBytes(l) : l = n.stringToBytes(l) : t(l) ? l = Array.prototype.slice.call(l, 0) : !Array.isArray(l) && l.constructor !== Uint8Array && (l = l.toString());
202
+ for (var s = e.bytesToWords(l), p = l.length * 8, r = 1732584193, o = -271733879, c = -1732584194, a = 271733878, f = 0; f < s.length; f++)
203
+ s[f] = (s[f] << 8 | s[f] >>> 24) & 16711935 | (s[f] << 24 | s[f] >>> 8) & 4278255360;
204
+ s[p >>> 5] |= 128 << p % 32, s[(p + 64 >>> 9 << 4) + 14] = p;
205
+ for (var d = i._ff, y = i._gg, g = i._hh, m = i._ii, f = 0; f < s.length; f += 16) {
206
+ var A = r, w = o, B = c, x = a;
207
+ r = d(r, o, c, a, s[f + 0], 7, -680876936), a = d(a, r, o, c, s[f + 1], 12, -389564586), c = d(c, a, r, o, s[f + 2], 17, 606105819), o = d(o, c, a, r, s[f + 3], 22, -1044525330), r = d(r, o, c, a, s[f + 4], 7, -176418897), a = d(a, r, o, c, s[f + 5], 12, 1200080426), c = d(c, a, r, o, s[f + 6], 17, -1473231341), o = d(o, c, a, r, s[f + 7], 22, -45705983), r = d(r, o, c, a, s[f + 8], 7, 1770035416), a = d(a, r, o, c, s[f + 9], 12, -1958414417), c = d(c, a, r, o, s[f + 10], 17, -42063), o = d(o, c, a, r, s[f + 11], 22, -1990404162), r = d(r, o, c, a, s[f + 12], 7, 1804603682), a = d(a, r, o, c, s[f + 13], 12, -40341101), c = d(c, a, r, o, s[f + 14], 17, -1502002290), o = d(o, c, a, r, s[f + 15], 22, 1236535329), r = y(r, o, c, a, s[f + 1], 5, -165796510), a = y(a, r, o, c, s[f + 6], 9, -1069501632), c = y(c, a, r, o, s[f + 11], 14, 643717713), o = y(o, c, a, r, s[f + 0], 20, -373897302), r = y(r, o, c, a, s[f + 5], 5, -701558691), a = y(a, r, o, c, s[f + 10], 9, 38016083), c = y(c, a, r, o, s[f + 15], 14, -660478335), o = y(o, c, a, r, s[f + 4], 20, -405537848), r = y(r, o, c, a, s[f + 9], 5, 568446438), a = y(a, r, o, c, s[f + 14], 9, -1019803690), c = y(c, a, r, o, s[f + 3], 14, -187363961), o = y(o, c, a, r, s[f + 8], 20, 1163531501), r = y(r, o, c, a, s[f + 13], 5, -1444681467), a = y(a, r, o, c, s[f + 2], 9, -51403784), c = y(c, a, r, o, s[f + 7], 14, 1735328473), o = y(o, c, a, r, s[f + 12], 20, -1926607734), r = g(r, o, c, a, s[f + 5], 4, -378558), a = g(a, r, o, c, s[f + 8], 11, -2022574463), c = g(c, a, r, o, s[f + 11], 16, 1839030562), o = g(o, c, a, r, s[f + 14], 23, -35309556), r = g(r, o, c, a, s[f + 1], 4, -1530992060), a = g(a, r, o, c, s[f + 4], 11, 1272893353), c = g(c, a, r, o, s[f + 7], 16, -155497632), o = g(o, c, a, r, s[f + 10], 23, -1094730640), r = g(r, o, c, a, s[f + 13], 4, 681279174), a = g(a, r, o, c, s[f + 0], 11, -358537222), c = g(c, a, r, o, s[f + 3], 16, -722521979), o = g(o, c, a, r, s[f + 6], 23, 76029189), r = g(r, o, c, a, s[f + 9], 4, -640364487), a = g(a, r, o, c, s[f + 12], 11, -421815835), c = g(c, a, r, o, s[f + 15], 16, 530742520), o = g(o, c, a, r, s[f + 2], 23, -995338651), r = m(r, o, c, a, s[f + 0], 6, -198630844), a = m(a, r, o, c, s[f + 7], 10, 1126891415), c = m(c, a, r, o, s[f + 14], 15, -1416354905), o = m(o, c, a, r, s[f + 5], 21, -57434055), r = m(r, o, c, a, s[f + 12], 6, 1700485571), a = m(a, r, o, c, s[f + 3], 10, -1894986606), c = m(c, a, r, o, s[f + 10], 15, -1051523), o = m(o, c, a, r, s[f + 1], 21, -2054922799), r = m(r, o, c, a, s[f + 8], 6, 1873313359), a = m(a, r, o, c, s[f + 15], 10, -30611744), c = m(c, a, r, o, s[f + 6], 15, -1560198380), o = m(o, c, a, r, s[f + 13], 21, 1309151649), r = m(r, o, c, a, s[f + 4], 6, -145523070), a = m(a, r, o, c, s[f + 11], 10, -1120210379), c = m(c, a, r, o, s[f + 2], 15, 718787259), o = m(o, c, a, r, s[f + 9], 21, -343485551), r = r + A >>> 0, o = o + w >>> 0, c = c + B >>> 0, a = a + x >>> 0;
208
+ }
209
+ return e.endian([r, o, c, a]);
210
+ };
211
+ i._ff = function(l, h, s, p, r, o, c) {
212
+ var a = l + (h & s | ~h & p) + (r >>> 0) + c;
213
+ return (a << o | a >>> 32 - o) + h;
214
+ }, i._gg = function(l, h, s, p, r, o, c) {
215
+ var a = l + (h & p | s & ~p) + (r >>> 0) + c;
216
+ return (a << o | a >>> 32 - o) + h;
217
+ }, i._hh = function(l, h, s, p, r, o, c) {
218
+ var a = l + (h ^ s ^ p) + (r >>> 0) + c;
219
+ return (a << o | a >>> 32 - o) + h;
220
+ }, i._ii = function(l, h, s, p, r, o, c) {
221
+ var a = l + (s ^ (h | ~p)) + (r >>> 0) + c;
222
+ return (a << o | a >>> 32 - o) + h;
223
+ }, i._blocksize = 16, i._digestsize = 16, _.exports = function(l, h) {
224
+ if (l == null)
225
+ throw new Error("Illegal argument " + l);
226
+ var s = e.wordsToBytes(i(l, h));
227
+ return h && h.asBytes ? s : h && h.asString ? u.bytesToString(s) : e.bytesToHex(s);
228
+ };
229
+ })()), _.exports;
230
+ }
231
+ var xt = vt();
232
+ const Bt = /* @__PURE__ */ it(xt);
233
+ var k = {}, et;
234
+ function Tt() {
235
+ if (et) return k;
236
+ et = 1, k.byteLength = s, k.toByteArray = r, k.fromByteArray = a;
237
+ for (var e = [], n = [], t = typeof Uint8Array != "undefined" ? Uint8Array : Array, u = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i = 0, l = u.length; i < l; ++i)
238
+ e[i] = u[i], n[u.charCodeAt(i)] = i;
239
+ n[45] = 62, n[95] = 63;
240
+ function h(f) {
241
+ var d = f.length;
242
+ if (d % 4 > 0)
243
+ throw new Error("Invalid string. Length must be a multiple of 4");
244
+ var y = f.indexOf("=");
245
+ y === -1 && (y = d);
246
+ var g = y === d ? 0 : 4 - y % 4;
247
+ return [y, g];
248
+ }
249
+ function s(f) {
250
+ var d = h(f), y = d[0], g = d[1];
251
+ return (y + g) * 3 / 4 - g;
252
+ }
253
+ function p(f, d, y) {
254
+ return (d + y) * 3 / 4 - y;
255
+ }
256
+ function r(f) {
257
+ var d, y = h(f), g = y[0], m = y[1], A = new t(p(f, g, m)), w = 0, B = m > 0 ? g - 4 : g, x;
258
+ for (x = 0; x < B; x += 4)
259
+ d = n[f.charCodeAt(x)] << 18 | n[f.charCodeAt(x + 1)] << 12 | n[f.charCodeAt(x + 2)] << 6 | n[f.charCodeAt(x + 3)], A[w++] = d >> 16 & 255, A[w++] = d >> 8 & 255, A[w++] = d & 255;
260
+ return m === 2 && (d = n[f.charCodeAt(x)] << 2 | n[f.charCodeAt(x + 1)] >> 4, A[w++] = d & 255), m === 1 && (d = n[f.charCodeAt(x)] << 10 | n[f.charCodeAt(x + 1)] << 4 | n[f.charCodeAt(x + 2)] >> 2, A[w++] = d >> 8 & 255, A[w++] = d & 255), A;
261
+ }
262
+ function o(f) {
263
+ return e[f >> 18 & 63] + e[f >> 12 & 63] + e[f >> 6 & 63] + e[f & 63];
264
+ }
265
+ function c(f, d, y) {
266
+ for (var g, m = [], A = d; A < y; A += 3)
267
+ g = (f[A] << 16 & 16711680) + (f[A + 1] << 8 & 65280) + (f[A + 2] & 255), m.push(o(g));
268
+ return m.join("");
269
+ }
270
+ function a(f) {
271
+ for (var d, y = f.length, g = y % 3, m = [], A = 16383, w = 0, B = y - g; w < B; w += A)
272
+ m.push(c(f, w, w + A > B ? B : w + A));
273
+ return g === 1 ? (d = f[y - 1], m.push(
274
+ e[d >> 2] + e[d << 4 & 63] + "=="
275
+ )) : g === 2 && (d = (f[y - 2] << 8) + f[y - 1], m.push(
276
+ e[d >> 10] + e[d >> 4 & 63] + e[d << 2 & 63] + "="
277
+ )), m.join("");
278
+ }
279
+ return k;
280
+ }
281
+ var Ut = Tt();
282
+ const $ = /* @__PURE__ */ it(Ut);
283
+ ArrayBuffer.prototype.slice || (ArrayBuffer.prototype.slice = function(e, n) {
284
+ const t = new Uint8Array(this), u = n === void 0 ? t.length : n, i = new ArrayBuffer(u - e), l = new Uint8Array(i);
285
+ for (let h = 0; h < l.length; h++)
286
+ l[h] = t[h + e];
287
+ return i;
288
+ });
289
+ function bt(e) {
290
+ const n = new ArrayBuffer(e.length), t = new Uint8Array(n);
291
+ for (let u = 0; u < e.length; u++)
292
+ t[u] = e.charCodeAt(u);
293
+ return t;
294
+ }
295
+ function Ct(e) {
296
+ const n = new ArrayBuffer(1), t = new Uint8Array(n);
297
+ return t[0] = e, t;
298
+ }
299
+ function M(e) {
300
+ if (e instanceof Uint8Array)
301
+ return e;
302
+ if (e instanceof ArrayBuffer)
303
+ return new Uint8Array(e);
304
+ if (typeof e == "string")
305
+ return bt(e);
306
+ if (typeof e == "number") {
307
+ if (e > 255)
308
+ throw new Error("For more than one byte, use an array buffer");
309
+ if (e < 0)
310
+ throw new Error("Input value must be positive");
311
+ return Ct(e);
312
+ } else
313
+ throw new Error("Unsupported type");
314
+ }
315
+ function Lt(e) {
316
+ const n = function(i) {
317
+ let l = i.length, h = 0;
318
+ for (; l > 0; ) {
319
+ let s = this.blockLen - this.inLen;
320
+ s > l && (s = l);
321
+ const p = i.subarray(h, h + s);
322
+ this.inbuf.set(p, this.inLen), h += s, l -= s, this.inLen += s, this.inLen === this.blockLen && (this.processBlock(this.inbuf), this.inLen = 0);
323
+ }
324
+ }, t = function() {
325
+ const i = this.doPadding();
326
+ this.update(i);
327
+ const l = this.getDigest();
328
+ return this.reset(), l;
329
+ }, u = new e();
330
+ return u.inbuf = new Uint8Array(new ArrayBuffer(u.blockLen)), u.reset(), u.update = n, u.finalize = t, {
331
+ update(i) {
332
+ u.update(M(i));
333
+ },
334
+ finalize() {
335
+ return u.finalize();
336
+ },
337
+ digest(i) {
338
+ return u.update(M(i)), u.finalize();
339
+ },
340
+ reset() {
341
+ u.reset();
342
+ },
343
+ digestLength() {
344
+ return u.digestLen;
345
+ }
346
+ };
347
+ }
348
+ function Ft(e) {
349
+ let n = !1, t, u, i;
350
+ const l = function() {
351
+ if (n)
352
+ return;
353
+ if (t === void 0)
354
+ throw new Error("MAC key is not defined");
355
+ let r;
356
+ t.byteLength > 64 ? r = new Uint8Array(e.digest(t)) : r = new Uint8Array(t), u = new Uint8Array(new ArrayBuffer(64));
357
+ for (let o = 0; o < r.length; o++)
358
+ u[o] = 54 ^ r[o];
359
+ for (let o = r.length; o < 64; o++)
360
+ u[o] = 54;
361
+ i = new Uint8Array(new ArrayBuffer(64));
362
+ for (let o = 0; o < r.length; o++)
363
+ i[o] = 92 ^ r[o];
364
+ for (let o = r.length; o < 64; o++)
365
+ i[o] = 92;
366
+ n = !0, e.update(u.buffer);
367
+ }, h = function() {
368
+ n = !1, t = void 0, u = void 0, i = void 0, e.reset();
369
+ }, s = function() {
370
+ const r = e.finalize();
371
+ e.reset(), e.update(i.buffer), e.update(new Uint8Array(r));
372
+ const o = e.finalize();
373
+ return h(), o;
374
+ }, p = function(r) {
375
+ t = r;
376
+ };
377
+ return {
378
+ setKey(r) {
379
+ p(M(r)), l();
380
+ },
381
+ update(r) {
382
+ e.update(M(r));
383
+ },
384
+ finalize() {
385
+ return s();
386
+ },
387
+ mac(r) {
388
+ return this.update(r), this.finalize();
389
+ },
390
+ reset() {
391
+ h();
392
+ },
393
+ hmacLength() {
394
+ return e.digestLength();
395
+ }
396
+ };
397
+ }
398
+ function St(e) {
399
+ const n = new Uint8Array(e.length * 4);
400
+ let t = 0;
401
+ for (let u = 0; u < e.length; u++) {
402
+ let i = e.charCodeAt(u);
403
+ if (i >= 55296 && i <= 56319 && u + 1 < e.length) {
404
+ const l = e.charCodeAt(u + 1);
405
+ l >= 56320 && l <= 57343 && (i = (i - 55296) * 1024 + (l - 56320) + 65536, u += 1);
406
+ }
407
+ i < 128 ? n[t++] = i : i < 2048 ? (n[t++] = 192 | i >> 6, n[t++] = 128 | i & 63) : i < 65536 ? (n[t++] = 224 | i >> 12, n[t++] = 128 | i >> 6 & 63, n[t++] = 128 | i & 63) : (n[t++] = 240 | i >> 18, n[t++] = 128 | i >> 12 & 63, n[t++] = 128 | i >> 6 & 63, n[t++] = 128 | i & 63);
408
+ }
409
+ return n.subarray(0, t);
410
+ }
411
+ const rt = typeof TextEncoder != "undefined" ? new TextEncoder() : null;
412
+ function I(e) {
413
+ return rt ? rt.encode(e) : St(e);
414
+ }
415
+ function ct(e) {
416
+ return typeof e == "string" ? Promise.resolve(I(e)) : e instanceof ArrayBuffer ? Promise.resolve(new Uint8Array(e)) : ArrayBuffer.isView(e) ? Promise.resolve(new Uint8Array(e.buffer, e.byteOffset, e.byteLength)) : e.arrayBuffer().then((n) => new Uint8Array(n));
417
+ }
418
+ function Et(e) {
419
+ const { accessKeyId: n, accessKeySecret: t, bucket: u, endpoint: i } = e;
420
+ if (!n) throw new Error("need accessKeyId");
421
+ if (!t) throw new Error("need accessKeySecret");
422
+ if (!u && !i) throw new Error("need bucket or endpoint");
423
+ }
424
+ function $t(e) {
425
+ const n = [];
426
+ for (let t = 0; t < e.length; t += 2)
427
+ n.push(parseInt(e[t] + e[t + 1], 16));
428
+ return Uint8Array.from(n);
429
+ }
430
+ function ut(e) {
431
+ const n = Array.prototype.slice.call(e, 0), t = $t(Bt(n));
432
+ return $.fromByteArray(t);
433
+ }
434
+ const It = {
435
+ region: "oss-cn-hangzhou",
436
+ internal: !1,
437
+ cname: !1,
438
+ secure: !1,
439
+ timeout: 6e4
440
+ };
441
+ function at(e = {}, n = It) {
442
+ return Et(e), Object.assign({}, n, e);
443
+ }
444
+ function Pt(e, n) {
445
+ const t = n || e.timeout;
446
+ return typeof t == "string" ? parseInt(t, 10) : t;
447
+ }
448
+ function nt(e) {
449
+ if (e != null) {
450
+ if (typeof e == "string") return I(e).length;
451
+ if (e instanceof Blob) return e.size;
452
+ if (e instanceof ArrayBuffer || ArrayBuffer.isView(e)) return e.byteLength;
453
+ }
454
+ }
455
+ class zt {
456
+ constructor() {
457
+ this.current = new Uint32Array(new ArrayBuffer(32)), this.currentLen = 0, this.inLen = 0, this.inbuf = new Uint8Array(new ArrayBuffer(64)), this.blockLen = 64, this.digestLen = 32, this.reset();
458
+ }
459
+ processBlock(n) {
460
+ let t = this.current[0], u = this.current[1], i = this.current[2], l = this.current[3], h = this.current[4], s = this.current[5], p = this.current[6], r = this.current[7];
461
+ const o = new Array(64);
462
+ for (let c = 0; c < 16; c++) {
463
+ const a = c * 4;
464
+ o[c] = n[a] << 24 | n[a + 1] << 16 | n[a + 2] << 8 | n[a + 3];
465
+ }
466
+ for (let c = 16; c < 64; c++) {
467
+ const a = o[c - 15], f = o[c - 2], d = (a >>> 7 | a << 25) ^ (a >>> 18 | a << 14) ^ a >>> 3, y = (f >>> 17 | f << 15) ^ (f >>> 19 | f << 13) ^ f >>> 10;
468
+ o[c] = y + o[c - 7] + d + o[c - 16] | 0;
469
+ }
470
+ for (let c = 0; c < 64; c++) {
471
+ const a = (h >>> 6 | h << 26) ^ (h >>> 11 | h << 21) ^ (h >>> 25 | h << 7), f = h & s ^ ~h & p, d = r + a + f + kt[c] + o[c] | 0, y = (t >>> 2 | t << 30) ^ (t >>> 13 | t << 19) ^ (t >>> 22 | t << 10), g = t & u ^ t & i ^ u & i, m = y + g | 0;
472
+ r = p, p = s, s = h, h = l + d | 0, l = i, i = u, u = t, t = d + m | 0;
473
+ }
474
+ this.current[0] = this.current[0] + t | 0, this.current[1] = this.current[1] + u | 0, this.current[2] = this.current[2] + i | 0, this.current[3] = this.current[3] + l | 0, this.current[4] = this.current[4] + h | 0, this.current[5] = this.current[5] + s | 0, this.current[6] = this.current[6] + p | 0, this.current[7] = this.current[7] + r | 0, this.currentLen += 64;
475
+ }
476
+ doPadding() {
477
+ const n = (this.inLen + this.currentLen) * 8, t = 0, u = n & 4294967295, i = this.inLen <= 55 ? 55 - this.inLen : 119 - this.inLen, l = new Uint8Array(new ArrayBuffer(i + 1 + 8));
478
+ return l[0] = 128, l[l.length - 1] = u & 255, l[l.length - 2] = u >>> 8 & 255, l[l.length - 3] = u >>> 16 & 255, l[l.length - 4] = u >>> 24 & 255, l[l.length - 5] = t & 255, l[l.length - 6] = t >>> 8 & 255, l[l.length - 7] = t >>> 16 & 255, l[l.length - 8] = t >>> 24 & 255, l;
479
+ }
480
+ getDigest() {
481
+ const n = new Uint8Array(new ArrayBuffer(32));
482
+ for (let t = 0; t < 8; t++) {
483
+ const u = this.current[t], i = t * 4;
484
+ n[i] = u >>> 24 & 255, n[i + 1] = u >>> 16 & 255, n[i + 2] = u >>> 8 & 255, n[i + 3] = u & 255;
485
+ }
486
+ return n.buffer;
487
+ }
488
+ reset() {
489
+ this.currentLen = 0, this.inLen = 0, this.current[0] = 1779033703, this.current[1] = 3144134277, this.current[2] = 1013904242, this.current[3] = 2773480762, this.current[4] = 1359893119, this.current[5] = 2600822924, this.current[6] = 528734635, this.current[7] = 1541459225;
490
+ }
491
+ }
492
+ const kt = new Uint32Array([
493
+ 1116352408,
494
+ 1899447441,
495
+ 3049323471,
496
+ 3921009573,
497
+ 961987163,
498
+ 1508970993,
499
+ 2453635748,
500
+ 2870763221,
501
+ 3624381080,
502
+ 310598401,
503
+ 607225278,
504
+ 1426881987,
505
+ 1925078388,
506
+ 2162078206,
507
+ 2614888103,
508
+ 3248222580,
509
+ 3835390401,
510
+ 4022224774,
511
+ 264347078,
512
+ 604807628,
513
+ 770255983,
514
+ 1249150122,
515
+ 1555081692,
516
+ 1996064986,
517
+ 2554220882,
518
+ 2821834349,
519
+ 2952996808,
520
+ 3210313671,
521
+ 3336571891,
522
+ 3584528711,
523
+ 113926993,
524
+ 338241895,
525
+ 666307205,
526
+ 773529912,
527
+ 1294757372,
528
+ 1396182291,
529
+ 1695183700,
530
+ 1986661051,
531
+ 2177026350,
532
+ 2456956037,
533
+ 2730485921,
534
+ 2820302411,
535
+ 3259730800,
536
+ 3345764771,
537
+ 3516065817,
538
+ 3600352804,
539
+ 4094571909,
540
+ 275423344,
541
+ 430227734,
542
+ 506948616,
543
+ 659060556,
544
+ 883997877,
545
+ 958139571,
546
+ 1322822218,
547
+ 1537002063,
548
+ 1747873779,
549
+ 1955562222,
550
+ 2024104815,
551
+ 2227730452,
552
+ 2361852424,
553
+ 2428436474,
554
+ 2756734187,
555
+ 3204031479,
556
+ 3329325298
557
+ ]);
558
+ function ft() {
559
+ return Ft(Lt(zt));
560
+ }
561
+ function Rt(e) {
562
+ try {
563
+ return decodeURIComponent(e);
564
+ } catch (n) {
565
+ return e;
566
+ }
567
+ }
568
+ function Mt(e) {
569
+ const n = Object.keys(e).map((u) => u.toLowerCase()).filter((u) => u.indexOf("x-ms-") === 0).sort();
570
+ let t = "";
571
+ return n.forEach((u) => {
572
+ const i = Object.keys(e).find((h) => h.toLowerCase() === u), l = String(e[i]).trim();
573
+ t += `${u}:${l}
574
+ `;
575
+ }), t;
576
+ }
577
+ function qt(e, n) {
578
+ return e[0] !== n[0] ? e[0] < n[0] ? -1 : 1 : e[1] !== n[1] ? e[1] < n[1] ? -1 : 1 : 0;
579
+ }
580
+ function Ot(e, n, t) {
581
+ let u = `/${e}${n}`;
582
+ if (t) {
583
+ const i = [];
584
+ Object.keys(t).forEach((l) => {
585
+ const h = l.toLowerCase(), s = t[l];
586
+ if (s == null || s === "") return;
587
+ const r = (Array.isArray(s) ? s : [s]).map((o) => Rt(o == null ? "" : String(o))).sort();
588
+ i.push([h, r.join(",")]);
589
+ }), i.sort(qt), i.forEach(([l, h]) => {
590
+ u += `
591
+ ${l}:${h}`;
592
+ });
593
+ }
594
+ return u;
595
+ }
596
+ function _t(e) {
597
+ const { verb: n, headers: t, pathname: u, query: i, account: l, accountKey: h } = e, s = e.contentMd5 || "", p = e.contentType || "", r = e.contentLength ? String(e.contentLength) : "", c = [n, "", "", r, s, p, "", "", "", "", "", ""].join(`
598
+ `) + `
599
+ ` + Mt(t) + Ot(l, u, i), a = ft();
600
+ a.setKey($.toByteArray(h)), a.update(I(c));
601
+ const f = $.fromByteArray(new Uint8Array(a.finalize()));
602
+ return `SharedKey ${l}:${f}`;
603
+ }
604
+ function lt(e) {
605
+ const { accessKeyId: n, endpoint: t } = e;
606
+ return t || `${n}.blob.core.windows.net`;
607
+ }
608
+ function ht(e) {
609
+ return e.split("/").map(encodeURIComponent).join("/");
610
+ }
611
+ const Ht = {
612
+ secure: !0,
613
+ timeout: 6e4
614
+ }, V = "2020-12-06";
615
+ function Z(e, n) {
616
+ const t = at(e, Ht), { accessKeyId: u, accessKeySecret: i, bucket: l, secure: h } = t, s = E({
617
+ "x-ms-date": (/* @__PURE__ */ new Date()).toUTCString(),
618
+ "x-ms-version": V
619
+ }, n.headers);
620
+ n.verb === "PUT" && !n.subResource && (s["x-ms-blob-type"] = "BlockBlob");
621
+ const p = `/${l}/${ht(n.objectName)}`, r = _t({
622
+ verb: n.verb,
623
+ headers: s,
624
+ pathname: p,
625
+ query: n.subResource,
626
+ account: u,
627
+ accountKey: i,
628
+ contentMd5: n.contentMd5,
629
+ contentType: n.headers ? n.headers["Content-Type"] : void 0,
630
+ contentLength: nt(n.data)
631
+ });
632
+ s.Authorization = r;
633
+ let c = `${h ? "https" : "http"}://${lt(t)}${p}`;
634
+ if (n.subResource) {
635
+ const a = Object.keys(n.subResource).map((f) => {
636
+ const d = n.subResource[f];
637
+ return d === "" || d == null ? f : `${f}=${encodeURIComponent(d)}`;
638
+ }).join("&");
639
+ a && (c += `?${a}`);
640
+ }
641
+ return mt()(c, {
642
+ method: n.verb,
643
+ headers: s,
644
+ data: n.data,
645
+ timeout: n.timeout == null ? Pt(t) : n.timeout,
646
+ onprogress: n.onprogress,
647
+ total: nt(n.data)
648
+ });
649
+ }
650
+ const Kt = {
651
+ secure: !0,
652
+ timeout: 6e4
653
+ };
654
+ function Dt(e) {
655
+ const n = e.toISOString();
656
+ return n.substring(0, n.length - 5) + "Z";
657
+ }
658
+ function Vt(e, n, t = {}) {
659
+ const { expires: u = 1800, method: i, response: l } = t, h = at(e, Kt), { accessKeyId: s, accessKeySecret: p, bucket: r, secure: o } = h, c = s, a = i === "PUT" ? "w" : "r", f = Dt(new Date(Date.now() + u * 1e3)), d = "b", y = `/blob/${c}/${r}${n ? `/${n}` : ""}`, g = l && l["cache-control"] || "", m = l && l["content-disposition"] || "", A = l && l["content-encoding"] || "", w = l && l["content-language"] || "", B = l && l["content-type"] || "", x = [a, "", f, y, "", "", "", V, d, "", "", g, m, A, w, B].join(`
660
+ `), C = ft();
661
+ C.setKey($.toByteArray(p)), C.update(I(x));
662
+ const q = $.fromByteArray(new Uint8Array(C.finalize())), R = [], U = (b, T) => {
663
+ T && R.push([b, T]);
664
+ };
665
+ U("sv", V), U("se", f), U("sr", d), U("sp", a), U("rscc", g), U("rscd", m), U("rsce", A), U("rscl", w), U("rsct", B), U("sig", q);
666
+ const S = R.map(([b, T]) => `${b}=${encodeURIComponent(T)}`).join("&"), O = o ? "https" : "http", v = `/${r}/${ht(n)}`;
667
+ return `${O}://${lt(h)}${v}?${S}`;
668
+ }
669
+ function jt(e) {
670
+ return function(t, u, i, l = {}) {
671
+ return ct(i).then((h) => {
672
+ const s = ut(h), p = typeof i == "string" ? "text/plain; charset=utf-8" : i instanceof Blob ? i.type : "application/octet-stream", r = {
673
+ "Content-Md5": s,
674
+ "Content-Type": p
675
+ };
676
+ return e.request(t, {
677
+ verb: "PUT",
678
+ objectName: u,
679
+ contentMd5: s,
680
+ headers: r,
681
+ // Strings are already encoded to bytes for the MD5; send those
682
+ // bytes to avoid encoding twice and to give the transport a size.
683
+ data: typeof i == "string" ? h : i,
684
+ onprogress: l.onprogress
685
+ });
686
+ });
687
+ };
688
+ }
689
+ function ot(e) {
690
+ return typeof e == "string" ? I(e).length : e instanceof Blob ? e.size : e.byteLength;
691
+ }
692
+ function Zt(e, n) {
693
+ return function(s, p, r) {
694
+ return z(this, arguments, function* (u, i, l, h = {}) {
695
+ const {
696
+ parallel: o = 5,
697
+ partSize: c = 1024 * 1024,
698
+ // default 1MB
699
+ checkpoint: a,
700
+ progress: f,
701
+ meta: d,
702
+ mime: y,
703
+ headers: g = {}
704
+ } = h;
705
+ let m, A = [], w = Math.max(c, 100 * 1024);
706
+ const B = ot(l);
707
+ if (B === 0)
708
+ throw new Error("multipart upload requires a non-empty file");
709
+ if (a && a.uploadId && ot(a.file) === B)
710
+ m = a.uploadId, A = a.doneParts || [], a.partSize && (w = a.partSize);
711
+ else {
712
+ const v = E({}, g);
713
+ y && (v["Content-Type"] = y), d && Object.keys(d).forEach((T) => {
714
+ v[`${e.metaPrefix}${T}`] = d[T];
715
+ }), m = (yield n.initMultipartUpload(u, i, { headers: v })).uploadId;
716
+ }
717
+ const x = Math.ceil(B / w), C = {
718
+ file: l,
719
+ name: i,
720
+ uploadId: m,
721
+ partSize: w,
722
+ parts: [],
723
+ doneParts: [...A]
724
+ };
725
+ for (let v = 1; v <= x; v++)
726
+ A.some((T) => T.number === v) || C.parts.push({ number: v, etag: "" });
727
+ const q = (v, b, T) => z(null, null, function* () {
728
+ const L = () => z(null, null, function* () {
729
+ const P = yield n.uploadPart(u, i, m, v, l, b, T);
730
+ if (!P.etag)
731
+ throw new Error("cannot read the ETag of the uploaded part; make sure the bucket CORS rule exposes the ETag response header");
732
+ return P;
733
+ });
734
+ let F;
735
+ try {
736
+ F = yield L();
737
+ } catch (P) {
738
+ F = yield L();
739
+ }
740
+ if (C.doneParts.push({ number: v, etag: F.etag }), f) {
741
+ const P = C.doneParts.length / x;
742
+ f(P, C, F);
743
+ }
744
+ return { number: v, etag: F.etag };
745
+ }), R = C.parts.filter((v) => !A.some((b) => b.number === v.number)), U = [], S = [];
746
+ for (const v of R) {
747
+ const b = (v.number - 1) * w, T = Math.min(v.number * w, B), L = q(v.number, b, T);
748
+ U.push(L), S.push(L), L.finally(() => {
749
+ const F = S.indexOf(L);
750
+ F > -1 && S.splice(F, 1);
751
+ }), S.length >= o && (yield Promise.race(S));
752
+ }
753
+ yield Promise.all(U);
754
+ const O = [...A, ...C.doneParts].filter((v, b, T) => T.findIndex((L) => L.number === v.number) === b);
755
+ return n.completeMultipartUpload(u, i, m, O);
756
+ });
757
+ };
758
+ }
759
+ function Wt(e) {
760
+ const n = String(e).padStart(5, "0");
761
+ return $.fromByteArray(I(n));
762
+ }
763
+ function Jt() {
764
+ return `az-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
765
+ }
766
+ const j = /* @__PURE__ */ new Map();
767
+ function Gt(e, n, t = {}) {
768
+ const u = Jt();
769
+ return t.headers && j.set(u, t.headers), Promise.resolve({ name: n, uploadId: u });
770
+ }
771
+ function Qt(e, n, t, u, i, l, h, s = {}) {
772
+ const p = ArrayBuffer.isView(i) && !(i instanceof DataView) ? i.subarray(l, h) : i.slice(l, h);
773
+ return ct(p).then((r) => {
774
+ const o = Wt(u), c = E({
775
+ "Content-Md5": ut(r)
776
+ }, s.headers);
777
+ return Z(e, {
778
+ verb: "PUT",
779
+ objectName: n,
780
+ contentMd5: c["Content-Md5"],
781
+ headers: c,
782
+ subResource: { comp: "block", blockid: o },
783
+ data: p,
784
+ timeout: s.timeout
785
+ }).then(() => ({
786
+ name: n,
787
+ etag: o,
788
+ res: void 0
789
+ }));
790
+ });
791
+ }
792
+ function Xt(e, n, t, u, i = {}) {
793
+ const l = j.get(t);
794
+ j.delete(t);
795
+ const s = '<?xml version="1.0" encoding="utf-8"?><BlockList>' + [...u].sort((p, r) => p.number - r.number).map((p) => `<Latest>${p.etag}</Latest>`).join("") + "</BlockList>";
796
+ return Z(e, {
797
+ verb: "PUT",
798
+ objectName: n,
799
+ headers: E(E({}, l), i.headers),
800
+ subResource: { comp: "blocklist" },
801
+ data: s,
802
+ timeout: i.timeout
803
+ }).then((p) => ({
804
+ name: n,
805
+ etag: p && p.headers && p.headers.etag || "",
806
+ res: p ? p.data : void 0
807
+ }));
808
+ }
809
+ function te(e, n) {
810
+ const { method: t, headers: u, data: i, timeout: l, onprogress: h, total: s } = n, p = new AbortController();
811
+ let r;
812
+ return l && (r = setTimeout(() => p.abort(), l)), h && s && h({ loaded: 0, total: s, lengthComputable: !1 }), fetch(e, {
813
+ method: t,
814
+ headers: u,
815
+ body: i,
816
+ signal: p.signal
817
+ }).then((o) => z(null, null, function* () {
818
+ const c = yield o.text();
819
+ if (o.status < 200 || o.status >= 300)
820
+ throw new Error(`the request is error: ${o.status} ${o.statusText} ${c}`);
821
+ h && s && h({ loaded: s, total: s, lengthComputable: !1 });
822
+ const a = {};
823
+ return o.headers.forEach((f, d) => {
824
+ a[d] = f;
825
+ }), {
826
+ data: c,
827
+ headers: a,
828
+ status: o.status,
829
+ statusText: o.statusText
830
+ };
831
+ })).finally(() => {
832
+ r && clearTimeout(r);
833
+ });
834
+ }
835
+ function ee(e, n) {
836
+ const { method: t, headers: u, data: i, timeout: l, onprogress: h, total: s } = n;
837
+ return typeof wx == "undefined" ? Promise.reject(new Error("wxRequestTransport requires the WeChat mini program runtime")) : (h && s && h({ loaded: 0, total: s, lengthComputable: !1 }), new Promise((p, r) => {
838
+ wx.request({
839
+ url: e,
840
+ method: t,
841
+ header: u,
842
+ data: i instanceof Uint8Array ? i.buffer : i,
843
+ timeout: l,
844
+ success: (o) => {
845
+ h && s && h({ loaded: s, total: s, lengthComputable: !1 }), p({ data: o.data, headers: o.header, status: o.statusCode, statusText: "" });
846
+ },
847
+ fail: (o) => {
848
+ r(o instanceof Error ? o : new Error(String(o)));
849
+ }
850
+ });
851
+ }));
852
+ }
853
+ function re(e, n) {
854
+ return (...t) => e(n, ...t);
855
+ }
856
+ const W = {
857
+ request: Z,
858
+ metaPrefix: "x-ms-meta-",
859
+ copySourceHeader: "x-ms-copy-source",
860
+ copySourceRangeHeader: "x-ms-copy-source-range",
861
+ listUploadsMarkerKey: "marker",
862
+ supportsSymlink: !1,
863
+ signUrl: Vt
864
+ }, ne = jt(W), oe = Zt(W, {
865
+ initMultipartUpload: Gt,
866
+ uploadPart: Qt,
867
+ completeMultipartUpload: Xt
868
+ }), se = W.signUrl;
869
+ export {
870
+ re as bindOptions,
871
+ Xt as completeMultipartUpload,
872
+ te as fetchTransport,
873
+ mt as getTransport,
874
+ Gt as initMultipartUpload,
875
+ oe as multipartUpload,
876
+ ne as put,
877
+ Nt as setTransport,
878
+ se as signatureUrl,
879
+ Qt as uploadPart,
880
+ ee as wxRequestTransport
881
+ };
882
+ //# sourceMappingURL=tiny-oss.azure.es.js.map