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