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/dist/tiny-oss.js DELETED
@@ -1,1642 +0,0 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory();
4
- else if(typeof define === 'function' && define.amd)
5
- define([], factory);
6
- else if(typeof exports === 'object')
7
- exports["TinyOSS"] = factory();
8
- else
9
- root["TinyOSS"] = factory();
10
- })(window, function() {
11
- return /******/ (function(modules) { // webpackBootstrap
12
- /******/ // The module cache
13
- /******/ var installedModules = {};
14
- /******/
15
- /******/ // The require function
16
- /******/ function __webpack_require__(moduleId) {
17
- /******/
18
- /******/ // Check if module is in cache
19
- /******/ if(installedModules[moduleId]) {
20
- /******/ return installedModules[moduleId].exports;
21
- /******/ }
22
- /******/ // Create a new module (and put it into the cache)
23
- /******/ var module = installedModules[moduleId] = {
24
- /******/ i: moduleId,
25
- /******/ l: false,
26
- /******/ exports: {}
27
- /******/ };
28
- /******/
29
- /******/ // Execute the module function
30
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
- /******/
32
- /******/ // Flag the module as loaded
33
- /******/ module.l = true;
34
- /******/
35
- /******/ // Return the exports of the module
36
- /******/ return module.exports;
37
- /******/ }
38
- /******/
39
- /******/
40
- /******/ // expose the modules object (__webpack_modules__)
41
- /******/ __webpack_require__.m = modules;
42
- /******/
43
- /******/ // expose the module cache
44
- /******/ __webpack_require__.c = installedModules;
45
- /******/
46
- /******/ // define getter function for harmony exports
47
- /******/ __webpack_require__.d = function(exports, name, getter) {
48
- /******/ if(!__webpack_require__.o(exports, name)) {
49
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50
- /******/ }
51
- /******/ };
52
- /******/
53
- /******/ // define __esModule on exports
54
- /******/ __webpack_require__.r = function(exports) {
55
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57
- /******/ }
58
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
59
- /******/ };
60
- /******/
61
- /******/ // create a fake namespace object
62
- /******/ // mode & 1: value is a module id, require it
63
- /******/ // mode & 2: merge all properties of value into the ns
64
- /******/ // mode & 4: return value when already ns object
65
- /******/ // mode & 8|1: behave like require
66
- /******/ __webpack_require__.t = function(value, mode) {
67
- /******/ if(mode & 1) value = __webpack_require__(value);
68
- /******/ if(mode & 8) return value;
69
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70
- /******/ var ns = Object.create(null);
71
- /******/ __webpack_require__.r(ns);
72
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74
- /******/ return ns;
75
- /******/ };
76
- /******/
77
- /******/ // getDefaultExport function for compatibility with non-harmony modules
78
- /******/ __webpack_require__.n = function(module) {
79
- /******/ var getter = module && module.__esModule ?
80
- /******/ function getDefault() { return module['default']; } :
81
- /******/ function getModuleExports() { return module; };
82
- /******/ __webpack_require__.d(getter, 'a', getter);
83
- /******/ return getter;
84
- /******/ };
85
- /******/
86
- /******/ // Object.prototype.hasOwnProperty.call
87
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88
- /******/
89
- /******/ // __webpack_public_path__
90
- /******/ __webpack_require__.p = "";
91
- /******/
92
- /******/
93
- /******/ // Load entry module and return exports
94
- /******/ return __webpack_require__(__webpack_require__.s = "./src/index.js");
95
- /******/ })
96
- /************************************************************************/
97
- /******/ ({
98
-
99
- /***/ "./node_modules/base64-js/index.js":
100
- /*!*****************************************!*\
101
- !*** ./node_modules/base64-js/index.js ***!
102
- \*****************************************/
103
- /*! no static exports found */
104
- /***/ (function(module, exports, __webpack_require__) {
105
-
106
- "use strict";
107
-
108
-
109
- exports.byteLength = byteLength
110
- exports.toByteArray = toByteArray
111
- exports.fromByteArray = fromByteArray
112
-
113
- var lookup = []
114
- var revLookup = []
115
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
116
-
117
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
118
- for (var i = 0, len = code.length; i < len; ++i) {
119
- lookup[i] = code[i]
120
- revLookup[code.charCodeAt(i)] = i
121
- }
122
-
123
- // Support decoding URL-safe base64 strings, as Node.js does.
124
- // See: https://en.wikipedia.org/wiki/Base64#URL_applications
125
- revLookup['-'.charCodeAt(0)] = 62
126
- revLookup['_'.charCodeAt(0)] = 63
127
-
128
- function getLens (b64) {
129
- var len = b64.length
130
-
131
- if (len % 4 > 0) {
132
- throw new Error('Invalid string. Length must be a multiple of 4')
133
- }
134
-
135
- // Trim off extra bytes after placeholder bytes are found
136
- // See: https://github.com/beatgammit/base64-js/issues/42
137
- var validLen = b64.indexOf('=')
138
- if (validLen === -1) validLen = len
139
-
140
- var placeHoldersLen = validLen === len
141
- ? 0
142
- : 4 - (validLen % 4)
143
-
144
- return [validLen, placeHoldersLen]
145
- }
146
-
147
- // base64 is 4/3 + up to two characters of the original data
148
- function byteLength (b64) {
149
- var lens = getLens(b64)
150
- var validLen = lens[0]
151
- var placeHoldersLen = lens[1]
152
- return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
153
- }
154
-
155
- function _byteLength (b64, validLen, placeHoldersLen) {
156
- return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
157
- }
158
-
159
- function toByteArray (b64) {
160
- var tmp
161
- var lens = getLens(b64)
162
- var validLen = lens[0]
163
- var placeHoldersLen = lens[1]
164
-
165
- var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
166
-
167
- var curByte = 0
168
-
169
- // if there are placeholders, only get up to the last complete 4 chars
170
- var len = placeHoldersLen > 0
171
- ? validLen - 4
172
- : validLen
173
-
174
- for (var i = 0; i < len; i += 4) {
175
- tmp =
176
- (revLookup[b64.charCodeAt(i)] << 18) |
177
- (revLookup[b64.charCodeAt(i + 1)] << 12) |
178
- (revLookup[b64.charCodeAt(i + 2)] << 6) |
179
- revLookup[b64.charCodeAt(i + 3)]
180
- arr[curByte++] = (tmp >> 16) & 0xFF
181
- arr[curByte++] = (tmp >> 8) & 0xFF
182
- arr[curByte++] = tmp & 0xFF
183
- }
184
-
185
- if (placeHoldersLen === 2) {
186
- tmp =
187
- (revLookup[b64.charCodeAt(i)] << 2) |
188
- (revLookup[b64.charCodeAt(i + 1)] >> 4)
189
- arr[curByte++] = tmp & 0xFF
190
- }
191
-
192
- if (placeHoldersLen === 1) {
193
- tmp =
194
- (revLookup[b64.charCodeAt(i)] << 10) |
195
- (revLookup[b64.charCodeAt(i + 1)] << 4) |
196
- (revLookup[b64.charCodeAt(i + 2)] >> 2)
197
- arr[curByte++] = (tmp >> 8) & 0xFF
198
- arr[curByte++] = tmp & 0xFF
199
- }
200
-
201
- return arr
202
- }
203
-
204
- function tripletToBase64 (num) {
205
- return lookup[num >> 18 & 0x3F] +
206
- lookup[num >> 12 & 0x3F] +
207
- lookup[num >> 6 & 0x3F] +
208
- lookup[num & 0x3F]
209
- }
210
-
211
- function encodeChunk (uint8, start, end) {
212
- var tmp
213
- var output = []
214
- for (var i = start; i < end; i += 3) {
215
- tmp =
216
- ((uint8[i] << 16) & 0xFF0000) +
217
- ((uint8[i + 1] << 8) & 0xFF00) +
218
- (uint8[i + 2] & 0xFF)
219
- output.push(tripletToBase64(tmp))
220
- }
221
- return output.join('')
222
- }
223
-
224
- function fromByteArray (uint8) {
225
- var tmp
226
- var len = uint8.length
227
- var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
228
- var parts = []
229
- var maxChunkLength = 16383 // must be multiple of 3
230
-
231
- // go through the array every three bytes, we'll deal with trailing stuff later
232
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
233
- parts.push(encodeChunk(
234
- uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
235
- ))
236
- }
237
-
238
- // pad the end with zeros, but make sure to not forget the extra bytes
239
- if (extraBytes === 1) {
240
- tmp = uint8[len - 1]
241
- parts.push(
242
- lookup[tmp >> 2] +
243
- lookup[(tmp << 4) & 0x3F] +
244
- '=='
245
- )
246
- } else if (extraBytes === 2) {
247
- tmp = (uint8[len - 2] << 8) + uint8[len - 1]
248
- parts.push(
249
- lookup[tmp >> 10] +
250
- lookup[(tmp >> 4) & 0x3F] +
251
- lookup[(tmp << 2) & 0x3F] +
252
- '='
253
- )
254
- }
255
-
256
- return parts.join('')
257
- }
258
-
259
-
260
- /***/ }),
261
-
262
- /***/ "./node_modules/charenc/charenc.js":
263
- /*!*****************************************!*\
264
- !*** ./node_modules/charenc/charenc.js ***!
265
- \*****************************************/
266
- /*! no static exports found */
267
- /***/ (function(module, exports) {
268
-
269
- var charenc = {
270
- // UTF-8 encoding
271
- utf8: {
272
- // Convert a string to a byte array
273
- stringToBytes: function(str) {
274
- return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
275
- },
276
-
277
- // Convert a byte array to a string
278
- bytesToString: function(bytes) {
279
- return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
280
- }
281
- },
282
-
283
- // Binary encoding
284
- bin: {
285
- // Convert a string to a byte array
286
- stringToBytes: function(str) {
287
- for (var bytes = [], i = 0; i < str.length; i++)
288
- bytes.push(str.charCodeAt(i) & 0xFF);
289
- return bytes;
290
- },
291
-
292
- // Convert a byte array to a string
293
- bytesToString: function(bytes) {
294
- for (var str = [], i = 0; i < bytes.length; i++)
295
- str.push(String.fromCharCode(bytes[i]));
296
- return str.join('');
297
- }
298
- }
299
- };
300
-
301
- module.exports = charenc;
302
-
303
-
304
- /***/ }),
305
-
306
- /***/ "./node_modules/crypt/crypt.js":
307
- /*!*************************************!*\
308
- !*** ./node_modules/crypt/crypt.js ***!
309
- \*************************************/
310
- /*! no static exports found */
311
- /***/ (function(module, exports) {
312
-
313
- (function() {
314
- var base64map
315
- = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
316
-
317
- crypt = {
318
- // Bit-wise rotation left
319
- rotl: function(n, b) {
320
- return (n << b) | (n >>> (32 - b));
321
- },
322
-
323
- // Bit-wise rotation right
324
- rotr: function(n, b) {
325
- return (n << (32 - b)) | (n >>> b);
326
- },
327
-
328
- // Swap big-endian to little-endian and vice versa
329
- endian: function(n) {
330
- // If number given, swap endian
331
- if (n.constructor == Number) {
332
- return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00;
333
- }
334
-
335
- // Else, assume array and swap all items
336
- for (var i = 0; i < n.length; i++)
337
- n[i] = crypt.endian(n[i]);
338
- return n;
339
- },
340
-
341
- // Generate an array of any length of random bytes
342
- randomBytes: function(n) {
343
- for (var bytes = []; n > 0; n--)
344
- bytes.push(Math.floor(Math.random() * 256));
345
- return bytes;
346
- },
347
-
348
- // Convert a byte array to big-endian 32-bit words
349
- bytesToWords: function(bytes) {
350
- for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)
351
- words[b >>> 5] |= bytes[i] << (24 - b % 32);
352
- return words;
353
- },
354
-
355
- // Convert big-endian 32-bit words to a byte array
356
- wordsToBytes: function(words) {
357
- for (var bytes = [], b = 0; b < words.length * 32; b += 8)
358
- bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
359
- return bytes;
360
- },
361
-
362
- // Convert a byte array to a hex string
363
- bytesToHex: function(bytes) {
364
- for (var hex = [], i = 0; i < bytes.length; i++) {
365
- hex.push((bytes[i] >>> 4).toString(16));
366
- hex.push((bytes[i] & 0xF).toString(16));
367
- }
368
- return hex.join('');
369
- },
370
-
371
- // Convert a hex string to a byte array
372
- hexToBytes: function(hex) {
373
- for (var bytes = [], c = 0; c < hex.length; c += 2)
374
- bytes.push(parseInt(hex.substr(c, 2), 16));
375
- return bytes;
376
- },
377
-
378
- // Convert a byte array to a base-64 string
379
- bytesToBase64: function(bytes) {
380
- for (var base64 = [], i = 0; i < bytes.length; i += 3) {
381
- var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
382
- for (var j = 0; j < 4; j++)
383
- if (i * 8 + j * 6 <= bytes.length * 8)
384
- base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));
385
- else
386
- base64.push('=');
387
- }
388
- return base64.join('');
389
- },
390
-
391
- // Convert a base-64 string to a byte array
392
- base64ToBytes: function(base64) {
393
- // Remove non-base-64 characters
394
- base64 = base64.replace(/[^A-Z0-9+\/]/ig, '');
395
-
396
- for (var bytes = [], i = 0, imod4 = 0; i < base64.length;
397
- imod4 = ++i % 4) {
398
- if (imod4 == 0) continue;
399
- bytes.push(((base64map.indexOf(base64.charAt(i - 1))
400
- & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2))
401
- | (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));
402
- }
403
- return bytes;
404
- }
405
- };
406
-
407
- module.exports = crypt;
408
- })();
409
-
410
-
411
- /***/ }),
412
-
413
- /***/ "./node_modules/is-buffer/index.js":
414
- /*!*****************************************!*\
415
- !*** ./node_modules/is-buffer/index.js ***!
416
- \*****************************************/
417
- /*! no static exports found */
418
- /***/ (function(module, exports) {
419
-
420
- /*!
421
- * Determine if an object is a Buffer
422
- *
423
- * @author Feross Aboukhadijeh <https://feross.org>
424
- * @license MIT
425
- */
426
-
427
- // The _isBuffer check is for Safari 5-7 support, because it's missing
428
- // Object.prototype.constructor. Remove this eventually
429
- module.exports = function (obj) {
430
- return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
431
- }
432
-
433
- function isBuffer (obj) {
434
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
435
- }
436
-
437
- // For Node v0.10 support. Remove this eventually.
438
- function isSlowBuffer (obj) {
439
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
440
- }
441
-
442
-
443
- /***/ }),
444
-
445
- /***/ "./node_modules/md5/md5.js":
446
- /*!*********************************!*\
447
- !*** ./node_modules/md5/md5.js ***!
448
- \*********************************/
449
- /*! no static exports found */
450
- /***/ (function(module, exports, __webpack_require__) {
451
-
452
- (function(){
453
- var crypt = __webpack_require__(/*! crypt */ "./node_modules/crypt/crypt.js"),
454
- utf8 = __webpack_require__(/*! charenc */ "./node_modules/charenc/charenc.js").utf8,
455
- isBuffer = __webpack_require__(/*! is-buffer */ "./node_modules/is-buffer/index.js"),
456
- bin = __webpack_require__(/*! charenc */ "./node_modules/charenc/charenc.js").bin,
457
-
458
- // The core
459
- md5 = function (message, options) {
460
- // Convert to byte array
461
- if (message.constructor == String)
462
- if (options && options.encoding === 'binary')
463
- message = bin.stringToBytes(message);
464
- else
465
- message = utf8.stringToBytes(message);
466
- else if (isBuffer(message))
467
- message = Array.prototype.slice.call(message, 0);
468
- else if (!Array.isArray(message))
469
- message = message.toString();
470
- // else, assume byte array already
471
-
472
- var m = crypt.bytesToWords(message),
473
- l = message.length * 8,
474
- a = 1732584193,
475
- b = -271733879,
476
- c = -1732584194,
477
- d = 271733878;
478
-
479
- // Swap endian
480
- for (var i = 0; i < m.length; i++) {
481
- m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF |
482
- ((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00;
483
- }
484
-
485
- // Padding
486
- m[l >>> 5] |= 0x80 << (l % 32);
487
- m[(((l + 64) >>> 9) << 4) + 14] = l;
488
-
489
- // Method shortcuts
490
- var FF = md5._ff,
491
- GG = md5._gg,
492
- HH = md5._hh,
493
- II = md5._ii;
494
-
495
- for (var i = 0; i < m.length; i += 16) {
496
-
497
- var aa = a,
498
- bb = b,
499
- cc = c,
500
- dd = d;
501
-
502
- a = FF(a, b, c, d, m[i+ 0], 7, -680876936);
503
- d = FF(d, a, b, c, m[i+ 1], 12, -389564586);
504
- c = FF(c, d, a, b, m[i+ 2], 17, 606105819);
505
- b = FF(b, c, d, a, m[i+ 3], 22, -1044525330);
506
- a = FF(a, b, c, d, m[i+ 4], 7, -176418897);
507
- d = FF(d, a, b, c, m[i+ 5], 12, 1200080426);
508
- c = FF(c, d, a, b, m[i+ 6], 17, -1473231341);
509
- b = FF(b, c, d, a, m[i+ 7], 22, -45705983);
510
- a = FF(a, b, c, d, m[i+ 8], 7, 1770035416);
511
- d = FF(d, a, b, c, m[i+ 9], 12, -1958414417);
512
- c = FF(c, d, a, b, m[i+10], 17, -42063);
513
- b = FF(b, c, d, a, m[i+11], 22, -1990404162);
514
- a = FF(a, b, c, d, m[i+12], 7, 1804603682);
515
- d = FF(d, a, b, c, m[i+13], 12, -40341101);
516
- c = FF(c, d, a, b, m[i+14], 17, -1502002290);
517
- b = FF(b, c, d, a, m[i+15], 22, 1236535329);
518
-
519
- a = GG(a, b, c, d, m[i+ 1], 5, -165796510);
520
- d = GG(d, a, b, c, m[i+ 6], 9, -1069501632);
521
- c = GG(c, d, a, b, m[i+11], 14, 643717713);
522
- b = GG(b, c, d, a, m[i+ 0], 20, -373897302);
523
- a = GG(a, b, c, d, m[i+ 5], 5, -701558691);
524
- d = GG(d, a, b, c, m[i+10], 9, 38016083);
525
- c = GG(c, d, a, b, m[i+15], 14, -660478335);
526
- b = GG(b, c, d, a, m[i+ 4], 20, -405537848);
527
- a = GG(a, b, c, d, m[i+ 9], 5, 568446438);
528
- d = GG(d, a, b, c, m[i+14], 9, -1019803690);
529
- c = GG(c, d, a, b, m[i+ 3], 14, -187363961);
530
- b = GG(b, c, d, a, m[i+ 8], 20, 1163531501);
531
- a = GG(a, b, c, d, m[i+13], 5, -1444681467);
532
- d = GG(d, a, b, c, m[i+ 2], 9, -51403784);
533
- c = GG(c, d, a, b, m[i+ 7], 14, 1735328473);
534
- b = GG(b, c, d, a, m[i+12], 20, -1926607734);
535
-
536
- a = HH(a, b, c, d, m[i+ 5], 4, -378558);
537
- d = HH(d, a, b, c, m[i+ 8], 11, -2022574463);
538
- c = HH(c, d, a, b, m[i+11], 16, 1839030562);
539
- b = HH(b, c, d, a, m[i+14], 23, -35309556);
540
- a = HH(a, b, c, d, m[i+ 1], 4, -1530992060);
541
- d = HH(d, a, b, c, m[i+ 4], 11, 1272893353);
542
- c = HH(c, d, a, b, m[i+ 7], 16, -155497632);
543
- b = HH(b, c, d, a, m[i+10], 23, -1094730640);
544
- a = HH(a, b, c, d, m[i+13], 4, 681279174);
545
- d = HH(d, a, b, c, m[i+ 0], 11, -358537222);
546
- c = HH(c, d, a, b, m[i+ 3], 16, -722521979);
547
- b = HH(b, c, d, a, m[i+ 6], 23, 76029189);
548
- a = HH(a, b, c, d, m[i+ 9], 4, -640364487);
549
- d = HH(d, a, b, c, m[i+12], 11, -421815835);
550
- c = HH(c, d, a, b, m[i+15], 16, 530742520);
551
- b = HH(b, c, d, a, m[i+ 2], 23, -995338651);
552
-
553
- a = II(a, b, c, d, m[i+ 0], 6, -198630844);
554
- d = II(d, a, b, c, m[i+ 7], 10, 1126891415);
555
- c = II(c, d, a, b, m[i+14], 15, -1416354905);
556
- b = II(b, c, d, a, m[i+ 5], 21, -57434055);
557
- a = II(a, b, c, d, m[i+12], 6, 1700485571);
558
- d = II(d, a, b, c, m[i+ 3], 10, -1894986606);
559
- c = II(c, d, a, b, m[i+10], 15, -1051523);
560
- b = II(b, c, d, a, m[i+ 1], 21, -2054922799);
561
- a = II(a, b, c, d, m[i+ 8], 6, 1873313359);
562
- d = II(d, a, b, c, m[i+15], 10, -30611744);
563
- c = II(c, d, a, b, m[i+ 6], 15, -1560198380);
564
- b = II(b, c, d, a, m[i+13], 21, 1309151649);
565
- a = II(a, b, c, d, m[i+ 4], 6, -145523070);
566
- d = II(d, a, b, c, m[i+11], 10, -1120210379);
567
- c = II(c, d, a, b, m[i+ 2], 15, 718787259);
568
- b = II(b, c, d, a, m[i+ 9], 21, -343485551);
569
-
570
- a = (a + aa) >>> 0;
571
- b = (b + bb) >>> 0;
572
- c = (c + cc) >>> 0;
573
- d = (d + dd) >>> 0;
574
- }
575
-
576
- return crypt.endian([a, b, c, d]);
577
- };
578
-
579
- // Auxiliary functions
580
- md5._ff = function (a, b, c, d, x, s, t) {
581
- var n = a + (b & c | ~b & d) + (x >>> 0) + t;
582
- return ((n << s) | (n >>> (32 - s))) + b;
583
- };
584
- md5._gg = function (a, b, c, d, x, s, t) {
585
- var n = a + (b & d | c & ~d) + (x >>> 0) + t;
586
- return ((n << s) | (n >>> (32 - s))) + b;
587
- };
588
- md5._hh = function (a, b, c, d, x, s, t) {
589
- var n = a + (b ^ c ^ d) + (x >>> 0) + t;
590
- return ((n << s) | (n >>> (32 - s))) + b;
591
- };
592
- md5._ii = function (a, b, c, d, x, s, t) {
593
- var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
594
- return ((n << s) | (n >>> (32 - s))) + b;
595
- };
596
-
597
- // Package private blocksize
598
- md5._blocksize = 16;
599
- md5._digestsize = 16;
600
-
601
- module.exports = function (message, options) {
602
- if (message === undefined || message === null)
603
- throw new Error('Illegal argument ' + message);
604
-
605
- var digestbytes = crypt.wordsToBytes(md5(message, options));
606
- return options && options.asBytes ? digestbytes :
607
- options && options.asString ? bin.bytesToString(digestbytes) :
608
- crypt.bytesToHex(digestbytes);
609
- };
610
-
611
- })();
612
-
613
-
614
- /***/ }),
615
-
616
- /***/ "./node_modules/object-assign/index.js":
617
- /*!*********************************************!*\
618
- !*** ./node_modules/object-assign/index.js ***!
619
- \*********************************************/
620
- /*! no static exports found */
621
- /***/ (function(module, exports, __webpack_require__) {
622
-
623
- "use strict";
624
- /*
625
- object-assign
626
- (c) Sindre Sorhus
627
- @license MIT
628
- */
629
-
630
-
631
- /* eslint-disable no-unused-vars */
632
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
633
- var hasOwnProperty = Object.prototype.hasOwnProperty;
634
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
635
-
636
- function toObject(val) {
637
- if (val === null || val === undefined) {
638
- throw new TypeError('Object.assign cannot be called with null or undefined');
639
- }
640
-
641
- return Object(val);
642
- }
643
-
644
- function shouldUseNative() {
645
- try {
646
- if (!Object.assign) {
647
- return false;
648
- }
649
-
650
- // Detect buggy property enumeration order in older V8 versions.
651
-
652
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
653
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
654
- test1[5] = 'de';
655
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
656
- return false;
657
- }
658
-
659
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
660
- var test2 = {};
661
- for (var i = 0; i < 10; i++) {
662
- test2['_' + String.fromCharCode(i)] = i;
663
- }
664
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
665
- return test2[n];
666
- });
667
- if (order2.join('') !== '0123456789') {
668
- return false;
669
- }
670
-
671
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
672
- var test3 = {};
673
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
674
- test3[letter] = letter;
675
- });
676
- if (Object.keys(Object.assign({}, test3)).join('') !==
677
- 'abcdefghijklmnopqrst') {
678
- return false;
679
- }
680
-
681
- return true;
682
- } catch (err) {
683
- // We don't expect any of the above to throw, but better to be safe.
684
- return false;
685
- }
686
- }
687
-
688
- module.exports = shouldUseNative() ? Object.assign : function (target, source) {
689
- var from;
690
- var to = toObject(target);
691
- var symbols;
692
-
693
- for (var s = 1; s < arguments.length; s++) {
694
- from = Object(arguments[s]);
695
-
696
- for (var key in from) {
697
- if (hasOwnProperty.call(from, key)) {
698
- to[key] = from[key];
699
- }
700
- }
701
-
702
- if (getOwnPropertySymbols) {
703
- symbols = getOwnPropertySymbols(from);
704
- for (var i = 0; i < symbols.length; i++) {
705
- if (propIsEnumerable.call(from, symbols[i])) {
706
- to[symbols[i]] = from[symbols[i]];
707
- }
708
- }
709
- }
710
- }
711
-
712
- return to;
713
- };
714
-
715
-
716
- /***/ }),
717
-
718
- /***/ "./src/TinyOSS.js":
719
- /*!************************!*\
720
- !*** ./src/TinyOSS.js ***!
721
- \************************/
722
- /*! exports provided: default */
723
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
724
-
725
- "use strict";
726
- __webpack_require__.r(__webpack_exports__);
727
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return TinyOSS; });
728
- /* harmony import */ var object_assign__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js");
729
- /* harmony import */ var object_assign__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(object_assign__WEBPACK_IMPORTED_MODULE_0__);
730
- /* harmony import */ var _utils_ajax__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils/ajax */ "./src/utils/ajax.js");
731
- /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/utils/index.js");
732
-
733
-
734
-
735
-
736
- var TinyOSS =
737
- /*#__PURE__*/
738
- function () {
739
- function TinyOSS(options) {
740
- if (options === void 0) {
741
- options = {};
742
- }
743
-
744
- Object(_utils__WEBPACK_IMPORTED_MODULE_2__["assertOptions"])(options);
745
- this.opts = object_assign__WEBPACK_IMPORTED_MODULE_0___default()({
746
- region: 'oss-cn-hangzhou',
747
- internal: false,
748
- cname: false,
749
- secure: false,
750
- timeout: 60000
751
- }, options);
752
- var _this$opts = this.opts,
753
- bucket = _this$opts.bucket,
754
- region = _this$opts.region,
755
- endpoint = _this$opts.endpoint,
756
- internal = _this$opts.internal;
757
- this.host = '';
758
-
759
- if (endpoint) {
760
- this.host = endpoint;
761
- } else {
762
- var host = bucket;
763
-
764
- if (internal) {
765
- host += '-internal';
766
- }
767
-
768
- host += "." + region + ".aliyuncs.com";
769
- this.host = host;
770
- }
771
- }
772
-
773
- var _proto = TinyOSS.prototype;
774
-
775
- _proto.put = function put(objectName, blob, options) {
776
- var _this = this;
777
-
778
- if (options === void 0) {
779
- options = {};
780
- }
781
-
782
- return new Promise(function (resolve, reject) {
783
- Object(_utils__WEBPACK_IMPORTED_MODULE_2__["blobToBuffer"])(blob).then(function (buf) {
784
- var _this$opts2 = _this.opts,
785
- accessKeyId = _this$opts2.accessKeyId,
786
- accessKeySecret = _this$opts2.accessKeySecret,
787
- stsToken = _this$opts2.stsToken,
788
- bucket = _this$opts2.bucket;
789
- var verb = 'PUT';
790
- var contentMd5 = Object(_utils__WEBPACK_IMPORTED_MODULE_2__["getContentMd5"])(buf);
791
- var contentType = blob.type;
792
- var headers = {
793
- 'Content-Md5': contentMd5,
794
- 'Content-Type': contentType,
795
- 'x-oss-date': new Date().toGMTString()
796
- };
797
-
798
- if (stsToken) {
799
- headers['x-oss-security-token'] = stsToken;
800
- }
801
-
802
- var signature = Object(_utils__WEBPACK_IMPORTED_MODULE_2__["getSignature"])({
803
- verb: verb,
804
- contentMd5: contentMd5,
805
- headers: headers,
806
- bucket: bucket,
807
- objectName: objectName,
808
- accessKeyId: accessKeyId,
809
- accessKeySecret: accessKeySecret
810
- });
811
- headers.Authorization = "OSS " + accessKeyId + ":" + signature;
812
- var protocol = _this.opts.secure ? 'https' : 'http';
813
- var url = protocol + "://" + _this.host + "/" + objectName;
814
- return Object(_utils_ajax__WEBPACK_IMPORTED_MODULE_1__["default"])(url, {
815
- method: verb,
816
- headers: headers,
817
- data: blob,
818
- timeout: _this.opts.timeout,
819
- onprogress: options.onprogress
820
- });
821
- }).then(resolve)["catch"](reject);
822
- });
823
- } // https://help.aliyun.com/document_detail/45126.html
824
- ;
825
-
826
- _proto.putSymlink = function putSymlink(objectName, targetObjectName) {
827
- var _this$opts3 = this.opts,
828
- accessKeyId = _this$opts3.accessKeyId,
829
- accessKeySecret = _this$opts3.accessKeySecret,
830
- stsToken = _this$opts3.stsToken,
831
- bucket = _this$opts3.bucket;
832
- var verb = 'PUT';
833
- var headers = {
834
- 'x-oss-date': new Date().toGMTString(),
835
- 'x-oss-symlink-target': encodeURI(targetObjectName)
836
- };
837
-
838
- if (stsToken) {
839
- headers['x-oss-security-token'] = stsToken;
840
- }
841
-
842
- var signature = Object(_utils__WEBPACK_IMPORTED_MODULE_2__["getSignature"])({
843
- verb: verb,
844
- headers: headers,
845
- bucket: bucket,
846
- objectName: objectName,
847
- accessKeyId: accessKeyId,
848
- accessKeySecret: accessKeySecret,
849
- subResource: {
850
- symlink: ''
851
- }
852
- });
853
- headers.Authorization = "OSS " + accessKeyId + ":" + signature;
854
- var protocol = this.opts.secure ? 'https' : 'http';
855
- var url = protocol + "://" + this.host + "/" + objectName + "?symlink";
856
- return Object(_utils_ajax__WEBPACK_IMPORTED_MODULE_1__["default"])(url, {
857
- method: verb,
858
- headers: headers,
859
- timeout: this.opts.timeout
860
- });
861
- };
862
-
863
- _proto.signatureUrl = function signatureUrl(objectName, options) {
864
- if (options === void 0) {
865
- options = {};
866
- }
867
-
868
- var _options = options,
869
- _options$expires = _options.expires,
870
- expires = _options$expires === void 0 ? 1800 : _options$expires,
871
- method = _options.method,
872
- process = _options.process,
873
- response = _options.response;
874
- var _this$opts4 = this.opts,
875
- accessKeyId = _this$opts4.accessKeyId,
876
- accessKeySecret = _this$opts4.accessKeySecret,
877
- stsToken = _this$opts4.stsToken,
878
- bucket = _this$opts4.bucket;
879
- var headers = {};
880
- var subResource = {};
881
-
882
- if (process) {
883
- var processKeyword = 'x-oss-process';
884
- subResource[processKeyword] = process;
885
- }
886
-
887
- if (response) {
888
- Object.keys(response).forEach(function (k) {
889
- var key = "response-" + k.toLowerCase();
890
- subResource[key] = response[k];
891
- });
892
- }
893
-
894
- Object.keys(options).forEach(function (key) {
895
- var lowerKey = key.toLowerCase();
896
- var value = options[key];
897
-
898
- if (lowerKey.indexOf('x-oss-') === 0) {
899
- headers[lowerKey] = value;
900
- } else if (lowerKey.indexOf('content-md5') === 0) {
901
- headers[key] = value;
902
- } else if (lowerKey.indexOf('content-type') === 0) {
903
- headers[key] = value;
904
- } else if (lowerKey !== 'expires' && lowerKey !== 'response' && lowerKey !== 'process' && lowerKey !== 'method') {
905
- subResource[lowerKey] = value;
906
- }
907
- });
908
- var securityToken = options['security-token'] || stsToken;
909
-
910
- if (securityToken) {
911
- subResource['security-token'] = securityToken;
912
- }
913
-
914
- var expireUnix = Object(_utils__WEBPACK_IMPORTED_MODULE_2__["unix"])() + expires;
915
- var signature = Object(_utils__WEBPACK_IMPORTED_MODULE_2__["getSignature"])({
916
- type: 'url',
917
- verb: method || 'GET',
918
- accessKeyId: accessKeyId,
919
- accessKeySecret: accessKeySecret,
920
- bucket: bucket,
921
- objectName: objectName,
922
- headers: headers,
923
- subResource: subResource,
924
- expires: expireUnix
925
- });
926
- var protocol = this.opts.secure ? 'https' : 'http';
927
- var url = protocol + "://" + this.host + "/" + objectName;
928
- url += "?OSSAccessKeyId=" + accessKeyId;
929
- url += "&Expires=" + expireUnix;
930
- url += "&Signature=" + encodeURIComponent(signature);
931
- Object.keys(subResource).forEach(function (k) {
932
- url += "&" + k + "=" + encodeURIComponent(subResource[k]);
933
- });
934
- return url;
935
- };
936
-
937
- return TinyOSS;
938
- }();
939
-
940
-
941
-
942
- /***/ }),
943
-
944
- /***/ "./src/index.js":
945
- /*!**********************!*\
946
- !*** ./src/index.js ***!
947
- \**********************/
948
- /*! no static exports found */
949
- /***/ (function(module, exports, __webpack_require__) {
950
-
951
- module.exports = __webpack_require__(/*! ./TinyOSS */ "./src/TinyOSS.js")["default"];
952
-
953
- /***/ }),
954
-
955
- /***/ "./src/utils/ajax.js":
956
- /*!***************************!*\
957
- !*** ./src/utils/ajax.js ***!
958
- \***************************/
959
- /*! exports provided: default */
960
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
961
-
962
- "use strict";
963
- __webpack_require__.r(__webpack_exports__);
964
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ajax; });
965
- function ajax(url, options) {
966
- if (options === void 0) {
967
- options = {};
968
- }
969
-
970
- return new Promise(function (resolve, reject) {
971
- var _options = options,
972
- _options$async = _options.async,
973
- async = _options$async === void 0 ? true : _options$async,
974
- _options$data = _options.data,
975
- data = _options$data === void 0 ? null : _options$data,
976
- _options$headers = _options.headers,
977
- headers = _options$headers === void 0 ? {} : _options$headers,
978
- _options$method = _options.method,
979
- method = _options$method === void 0 ? 'get' : _options$method,
980
- _options$timeout = _options.timeout,
981
- timeout = _options$timeout === void 0 ? 0 : _options$timeout,
982
- onprogress = _options.onprogress;
983
- var xhr = new XMLHttpRequest();
984
- var timerId;
985
-
986
- if (timeout) {
987
- timerId = setTimeout(function () {
988
- reject(new Error("the request timeout " + timeout + "ms"));
989
- }, timeout);
990
- }
991
-
992
- xhr.onerror = function () {
993
- reject(new Error('unknown error'));
994
- };
995
-
996
- if (xhr.upload) {
997
- // Note: the progress event must be located before the xhr.open method
998
- xhr.upload.onprogress = onprogress;
999
- }
1000
-
1001
- xhr.onreadystatechange = function () {
1002
- if (xhr.readyState === 4) {
1003
- if (timeout) clearTimeout(timerId);
1004
-
1005
- if (xhr.status >= 200 && xhr.status < 300) {
1006
- resolve(xhr.response, xhr);
1007
- } else {
1008
- var err = new Error('the request is error');
1009
- reject(err);
1010
- }
1011
- }
1012
- };
1013
-
1014
- xhr.open(method, url, async);
1015
- Object.keys(headers).forEach(function (key) {
1016
- xhr.setRequestHeader(key, headers[key]);
1017
- });
1018
-
1019
- try {
1020
- xhr.send(data);
1021
- } catch (err) {
1022
- reject(err);
1023
- }
1024
- });
1025
- }
1026
-
1027
- /***/ }),
1028
-
1029
- /***/ "./src/utils/index.js":
1030
- /*!****************************!*\
1031
- !*** ./src/utils/index.js ***!
1032
- \****************************/
1033
- /*! exports provided: unix, blobToBuffer, assertOptions, getContentMd5, getCanonicalizedOSSHeaders, getCanonicalizedResource, getSignature */
1034
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1035
-
1036
- "use strict";
1037
- __webpack_require__.r(__webpack_exports__);
1038
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "unix", function() { return unix; });
1039
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blobToBuffer", function() { return blobToBuffer; });
1040
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "assertOptions", function() { return assertOptions; });
1041
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getContentMd5", function() { return getContentMd5; });
1042
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCanonicalizedOSSHeaders", function() { return getCanonicalizedOSSHeaders; });
1043
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCanonicalizedResource", function() { return getCanonicalizedResource; });
1044
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getSignature", function() { return getSignature; });
1045
- /* harmony import */ var md5__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! md5 */ "./node_modules/md5/md5.js");
1046
- /* harmony import */ var md5__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(md5__WEBPACK_IMPORTED_MODULE_0__);
1047
- /* harmony import */ var base64_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js");
1048
- /* harmony import */ var base64_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(base64_js__WEBPACK_IMPORTED_MODULE_1__);
1049
- /* harmony import */ var _vendor_digest__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../vendor/digest */ "./vendor/digest.js");
1050
- /* harmony import */ var _vendor_digest__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_vendor_digest__WEBPACK_IMPORTED_MODULE_2__);
1051
-
1052
-
1053
-
1054
-
1055
- function isDate(obj) {
1056
- return obj && Object.prototype.toString.call(obj) === '[object Date]' && obj.toString !== 'Invalid Date';
1057
- }
1058
-
1059
- function unix(date) {
1060
- var d;
1061
-
1062
- if (date) {
1063
- d = new Date(date);
1064
- }
1065
-
1066
- if (!isDate(d)) {
1067
- d = new Date();
1068
- }
1069
-
1070
- return Math.round(d.getTime() / 1000);
1071
- }
1072
-
1073
- function blobToBuffer(blob) {
1074
- return new Promise(function (resolve, reject) {
1075
- var fr = new FileReader();
1076
-
1077
- fr.onload = function () {
1078
- var result = new Uint8Array(fr.result);
1079
- resolve(result);
1080
- };
1081
-
1082
- fr.onerror = function () {
1083
- reject(fr.error);
1084
- };
1085
-
1086
- fr.readAsArrayBuffer(blob);
1087
- });
1088
- }
1089
-
1090
- function assertOptions(options) {
1091
- var accessKeyId = options.accessKeyId,
1092
- accessKeySecret = options.accessKeySecret,
1093
- bucket = options.bucket,
1094
- endpoint = options.endpoint;
1095
-
1096
- if (!accessKeyId) {
1097
- throw new Error('need accessKeyId');
1098
- }
1099
-
1100
- if (!accessKeySecret) {
1101
- throw new Error('need accessKeySecret');
1102
- }
1103
-
1104
- if (!bucket && !endpoint) {
1105
- throw new Error('need bucket or endpoint');
1106
- }
1107
- }
1108
-
1109
- function hexToBuffer(hex) {
1110
- var arr = [];
1111
-
1112
- for (var i = 0; i < hex.length; i += 2) {
1113
- arr.push(parseInt(hex[i] + hex[i + 1], 16));
1114
- }
1115
-
1116
- return Uint8Array.from(arr);
1117
- }
1118
-
1119
- function getContentMd5(buf) {
1120
- // md5 doesn't work for Uint8Array
1121
- var bytes = Array.prototype.slice.call(buf, 0);
1122
- var md5Buf = hexToBuffer(md5__WEBPACK_IMPORTED_MODULE_0___default()(bytes));
1123
- return base64_js__WEBPACK_IMPORTED_MODULE_1___default.a.fromByteArray(md5Buf);
1124
- }
1125
-
1126
- function getCanonicalizedOSSHeaders(headers) {
1127
- var result = '';
1128
- var headerNames = Object.keys(headers);
1129
- headerNames = headerNames.map(function (name) {
1130
- return name.toLowerCase();
1131
- });
1132
- headerNames.sort();
1133
- headerNames.forEach(function (name) {
1134
- if (name.indexOf('x-oss-') === 0) {
1135
- result += name + ":" + headers[name] + "\n";
1136
- }
1137
- });
1138
- return result;
1139
- }
1140
-
1141
- function getCanonicalizedResource(bucket, objectName, parameters) {
1142
- if (bucket === void 0) {
1143
- bucket = '';
1144
- }
1145
-
1146
- if (objectName === void 0) {
1147
- objectName = '';
1148
- }
1149
-
1150
- var resourcePath = '';
1151
-
1152
- if (bucket) {
1153
- resourcePath += "/" + bucket;
1154
- }
1155
-
1156
- if (objectName) {
1157
- if (objectName.charAt(0) !== '/') {
1158
- resourcePath += '/';
1159
- }
1160
-
1161
- resourcePath += objectName;
1162
- }
1163
-
1164
- var canonicalizedResource = "" + resourcePath;
1165
- var separatorString = '?';
1166
-
1167
- if (parameters) {
1168
- var compareFunc = function compareFunc(entry1, entry2) {
1169
- if (entry1[0] > entry2[0]) {
1170
- return 1;
1171
- }
1172
-
1173
- if (entry1[0] < entry2[0]) {
1174
- return -1;
1175
- }
1176
-
1177
- return 0;
1178
- };
1179
-
1180
- var processFunc = function processFunc(key) {
1181
- canonicalizedResource += separatorString + key;
1182
-
1183
- if (parameters[key]) {
1184
- canonicalizedResource += "=" + parameters[key];
1185
- }
1186
-
1187
- separatorString = '&';
1188
- };
1189
-
1190
- Object.keys(parameters).sort(compareFunc).forEach(processFunc);
1191
- }
1192
-
1193
- return canonicalizedResource;
1194
- }
1195
-
1196
- function getSignature(options) {
1197
- if (options === void 0) {
1198
- options = {};
1199
- }
1200
-
1201
- var _options = options,
1202
- _options$type = _options.type,
1203
- type = _options$type === void 0 ? 'header' : _options$type,
1204
- _options$verb = _options.verb,
1205
- verb = _options$verb === void 0 ? '' : _options$verb,
1206
- _options$contentMd = _options.contentMd5,
1207
- contentMd5 = _options$contentMd === void 0 ? '' : _options$contentMd,
1208
- _options$expires = _options.expires,
1209
- expires = _options$expires === void 0 ? unix() + 3600 : _options$expires,
1210
- bucket = _options.bucket,
1211
- objectName = _options.objectName,
1212
- accessKeySecret = _options.accessKeySecret,
1213
- _options$headers = _options.headers,
1214
- headers = _options$headers === void 0 ? {} : _options$headers,
1215
- subResource = _options.subResource;
1216
- var date = headers['x-oss-date'] || '';
1217
- var contentType = headers['Content-Type'] || '';
1218
- var data = [verb, contentMd5, contentType];
1219
-
1220
- if (type === 'header') {
1221
- data.push(date);
1222
- } else {
1223
- data.push(expires);
1224
- }
1225
-
1226
- var canonicalizedOSSHeaders = getCanonicalizedOSSHeaders(headers);
1227
- var canonicalizedResource = getCanonicalizedResource(bucket, objectName, subResource);
1228
- data.push("" + canonicalizedOSSHeaders + canonicalizedResource);
1229
- var text = data.join('\n');
1230
- var hmac = new _vendor_digest__WEBPACK_IMPORTED_MODULE_2___default.a.HMAC_SHA1();
1231
- hmac.setKey(accessKeySecret);
1232
- hmac.update(text);
1233
- var hashBuf = new Uint8Array(hmac.finalize());
1234
- var signature = base64_js__WEBPACK_IMPORTED_MODULE_1___default.a.fromByteArray(hashBuf);
1235
- return signature;
1236
- }
1237
-
1238
-
1239
-
1240
- /***/ }),
1241
-
1242
- /***/ "./vendor/digest.js":
1243
- /*!**************************!*\
1244
- !*** ./vendor/digest.js ***!
1245
- \**************************/
1246
- /*! no static exports found */
1247
- /***/ (function(module, exports, __webpack_require__) {
1248
-
1249
- /*! ***** BEGIN LICENSE BLOCK *****
1250
- *!
1251
- *! Copyright 2011-2012, 2014 Jean-Christophe Sirot <sirot@chelonix.com>
1252
- *!
1253
- *! This file is part of digest.js
1254
- *!
1255
- *! digest.js is free software: you can redistribute it and/or modify it under
1256
- *! the terms of the GNU General Public License as published by the Free Software
1257
- *! Foundation, either version 3 of the License, or (at your option) any later
1258
- *! version.
1259
- *!
1260
- *! digest.js is distributed in the hope that it will be useful, but
1261
- *! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1262
- *! or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
1263
- *! more details.
1264
- *!
1265
- *! You should have received a copy of the GNU General Public License along with
1266
- *! digest.js. If not, see http://www.gnu.org/licenses/.
1267
- *!
1268
- *! ***** END LICENSE BLOCK ***** */
1269
-
1270
- /*global ArrayBuffer: true, Uint8Array: true, Uint32Array:true */
1271
-
1272
- /*jslint browser: true, bitwise: true, plusplus: true, vars: true, indent: 4, maxerr: 50 */
1273
- (function () {
1274
- "use strict";
1275
-
1276
- if (!ArrayBuffer.prototype.slice) {
1277
- ArrayBuffer.prototype.slice = function (start, end) {
1278
- var i;
1279
- var that = new Uint8Array(this);
1280
-
1281
- if (end === undefined) {
1282
- end = that.length;
1283
- }
1284
-
1285
- var result = new ArrayBuffer(end - start);
1286
- var resultArray = new Uint8Array(result);
1287
-
1288
- for (i = 0; i < resultArray.length; i++) {
1289
- resultArray[i] = that[i + start];
1290
- }
1291
-
1292
- return result;
1293
- };
1294
- }
1295
- })();
1296
-
1297
- ;
1298
-
1299
- (function (global) {
1300
- "use strict";
1301
- /* SHA-1 */
1302
-
1303
- function sha1Engine() {}
1304
-
1305
- sha1Engine.prototype.processBlock = function (input) {
1306
- var A = this.current[0];
1307
- var B = this.current[1];
1308
- var C = this.current[2];
1309
- var D = this.current[3];
1310
- var E = this.current[4];
1311
- var W = [input[0] << 24 | input[1] << 16 | input[2] << 8 | input[3], input[4] << 24 | input[5] << 16 | input[6] << 8 | input[7], input[8] << 24 | input[9] << 16 | input[10] << 8 | input[11], input[12] << 24 | input[13] << 16 | input[14] << 8 | input[15], input[16] << 24 | input[17] << 16 | input[18] << 8 | input[19], input[20] << 24 | input[21] << 16 | input[22] << 8 | input[23], input[24] << 24 | input[25] << 16 | input[26] << 8 | input[27], input[28] << 24 | input[29] << 16 | input[30] << 8 | input[31], input[32] << 24 | input[33] << 16 | input[34] << 8 | input[35], input[36] << 24 | input[37] << 16 | input[38] << 8 | input[39], input[40] << 24 | input[41] << 16 | input[42] << 8 | input[43], input[44] << 24 | input[45] << 16 | input[46] << 8 | input[47], input[48] << 24 | input[49] << 16 | input[50] << 8 | input[51], input[52] << 24 | input[53] << 16 | input[54] << 8 | input[55], input[56] << 24 | input[57] << 16 | input[58] << 8 | input[59], input[60] << 24 | input[61] << 16 | input[62] << 8 | input[63]];
1312
- var T;
1313
- var i;
1314
-
1315
- for (i = 16; i < 80; i++) {
1316
- W.push((W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]) << 1 | (W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]) >>> 31);
1317
- }
1318
-
1319
- for (i = 0; i < 80; i++) {
1320
- T = (A << 5 | A >>> 27) + E + W[i];
1321
-
1322
- if (i < 20) {
1323
- T += (B & C | ~B & D) + 0x5A827999 | 0;
1324
- } else if (i < 40) {
1325
- T += (B ^ C ^ D) + 0x6ED9EBA1 | 0;
1326
- } else if (i < 60) {
1327
- T += (B & C | B & D | C & D) + 0x8F1BBCDC | 0;
1328
- } else {
1329
- T += (B ^ C ^ D) + 0xCA62C1D6 | 0;
1330
- }
1331
-
1332
- E = D;
1333
- D = C;
1334
- C = B << 30 | B >>> 2;
1335
- B = A;
1336
- A = T;
1337
- }
1338
-
1339
- this.current[0] += A;
1340
- this.current[1] += B;
1341
- this.current[2] += C;
1342
- this.current[3] += D;
1343
- this.current[4] += E;
1344
- this.currentLen += 64;
1345
- };
1346
-
1347
- sha1Engine.prototype.doPadding = function () {
1348
- var datalen = (this.inLen + this.currentLen) * 8;
1349
- var msw = 0; // FIXME
1350
-
1351
- var lsw = datalen & 0xFFFFFFFF;
1352
- var zeros = this.inLen <= 55 ? 55 - this.inLen : 119 - this.inLen;
1353
- var pad = new Uint8Array(new ArrayBuffer(zeros + 1 + 8));
1354
- pad[0] = 0x80;
1355
- pad[pad.length - 1] = lsw & 0xFF;
1356
- pad[pad.length - 2] = lsw >>> 8 & 0xFF;
1357
- pad[pad.length - 3] = lsw >>> 16 & 0xFF;
1358
- pad[pad.length - 4] = lsw >>> 24 & 0xFF;
1359
- pad[pad.length - 5] = msw & 0xFF;
1360
- pad[pad.length - 6] = msw >>> 8 & 0xFF;
1361
- pad[pad.length - 7] = msw >>> 16 & 0xFF;
1362
- pad[pad.length - 8] = msw >>> 24 & 0xFF;
1363
- return pad;
1364
- };
1365
-
1366
- sha1Engine.prototype.getDigest = function () {
1367
- var rv = new Uint8Array(new ArrayBuffer(20));
1368
- rv[3] = this.current[0] & 0xFF;
1369
- rv[2] = this.current[0] >>> 8 & 0xFF;
1370
- rv[1] = this.current[0] >>> 16 & 0xFF;
1371
- rv[0] = this.current[0] >>> 24 & 0xFF;
1372
- rv[7] = this.current[1] & 0xFF;
1373
- rv[6] = this.current[1] >>> 8 & 0xFF;
1374
- rv[5] = this.current[1] >>> 16 & 0xFF;
1375
- rv[4] = this.current[1] >>> 24 & 0xFF;
1376
- rv[11] = this.current[2] & 0xFF;
1377
- rv[10] = this.current[2] >>> 8 & 0xFF;
1378
- rv[9] = this.current[2] >>> 16 & 0xFF;
1379
- rv[8] = this.current[2] >>> 24 & 0xFF;
1380
- rv[15] = this.current[3] & 0xFF;
1381
- rv[14] = this.current[3] >>> 8 & 0xFF;
1382
- rv[13] = this.current[3] >>> 16 & 0xFF;
1383
- rv[12] = this.current[3] >>> 24 & 0xFF;
1384
- rv[19] = this.current[4] & 0xFF;
1385
- rv[18] = this.current[4] >>> 8 & 0xFF;
1386
- rv[17] = this.current[4] >>> 16 & 0xFF;
1387
- rv[16] = this.current[4] >>> 24 & 0xFF;
1388
- return rv.buffer;
1389
- };
1390
-
1391
- sha1Engine.prototype.reset = function () {
1392
- this.currentLen = 0;
1393
- this.inLen = 0;
1394
- this.current = new Uint32Array(new ArrayBuffer(20));
1395
- this.current[0] = 0x67452301;
1396
- this.current[1] = 0xEFCDAB89;
1397
- this.current[2] = 0x98BADCFE;
1398
- this.current[3] = 0x10325476;
1399
- this.current[4] = 0xC3D2E1F0;
1400
- };
1401
-
1402
- sha1Engine.prototype.blockLen = 64;
1403
- sha1Engine.prototype.digestLen = 20;
1404
- /* Input utility functions */
1405
-
1406
- var fromASCII = function fromASCII(s) {
1407
- var buffer = new ArrayBuffer(s.length);
1408
- var b = new Uint8Array(buffer);
1409
- var i;
1410
-
1411
- for (i = 0; i < s.length; i++) {
1412
- b[i] = s.charCodeAt(i);
1413
- }
1414
-
1415
- return b;
1416
- };
1417
-
1418
- var fromInteger = function fromInteger(v) {
1419
- var buffer = new ArrayBuffer(1);
1420
- var b = new Uint8Array(buffer);
1421
- b[0] = v;
1422
- return b;
1423
- };
1424
-
1425
- var convertToUint8Array = function convertToUint8Array(input) {
1426
- if (input.constructor === Uint8Array) {
1427
- return input;
1428
- } else if (input.constructor === ArrayBuffer) {
1429
- return new Uint8Array(input);
1430
- } else if (input.constructor === String) {
1431
- return fromASCII(input);
1432
- } else if (input.constructor === Number) {
1433
- if (input > 0xFF) {
1434
- throw "For more than one byte, use an array buffer";
1435
- } else if (input < 0) {
1436
- throw "Input value must be positive";
1437
- }
1438
-
1439
- return fromInteger(input);
1440
- } else {
1441
- throw "Unsupported type";
1442
- }
1443
- };
1444
-
1445
- var convertToUInt32 = function convertToUInt32(i) {
1446
- var tmp = new Uint8Array(new ArrayBuffer(4));
1447
- tmp[0] = (i & 0xFF000000) >> 24;
1448
- tmp[1] = (i & 0x00FF0000) >> 16;
1449
- tmp[2] = (i & 0x0000FF00) >> 8;
1450
- tmp[3] = i & 0x000000FF;
1451
- return tmp;
1452
- };
1453
- /* Digest implementation */
1454
-
1455
-
1456
- var dg = function dg(Constructor) {
1457
- var update = function update(input) {
1458
- var len = input.length;
1459
- var offset = 0;
1460
-
1461
- while (len > 0) {
1462
- var copyLen = this.blockLen - this.inLen;
1463
-
1464
- if (copyLen > len) {
1465
- copyLen = len;
1466
- }
1467
-
1468
- var tmpInput = input.subarray(offset, offset + copyLen);
1469
- this.inbuf.set(tmpInput, this.inLen);
1470
- offset += copyLen;
1471
- len -= copyLen;
1472
- this.inLen += copyLen;
1473
-
1474
- if (this.inLen === this.blockLen) {
1475
- //var t0 = performance.now();
1476
- this.processBlock(this.inbuf); //var t1 = performance.now();
1477
- //console.log(t1 - t0);
1478
-
1479
- this.inLen = 0;
1480
- }
1481
- }
1482
- };
1483
-
1484
- var finalize = function finalize() {
1485
- var padding = this.doPadding();
1486
- this.update(padding);
1487
- var result = this.getDigest();
1488
- this.reset();
1489
- return result;
1490
- };
1491
-
1492
- var engine = function () {
1493
- if (!Constructor) {
1494
- throw "Unsupported algorithm: " + Constructor.toString();
1495
- }
1496
-
1497
- Constructor.prototype.update = update;
1498
- Constructor.prototype.finalize = finalize;
1499
- var engine = new Constructor();
1500
- engine.inbuf = new Uint8Array(new ArrayBuffer(engine.blockLen));
1501
- engine.reset();
1502
- return engine;
1503
- }();
1504
-
1505
- return {
1506
- update: function update(input) {
1507
- engine.update(convertToUint8Array(input));
1508
- },
1509
- finalize: function finalize() {
1510
- return engine.finalize();
1511
- },
1512
- digest: function digest(input) {
1513
- engine.update(convertToUint8Array(input));
1514
- return engine.finalize();
1515
- },
1516
- reset: function reset() {
1517
- engine.reset();
1518
- },
1519
- digestLength: function digestLength() {
1520
- return engine.digestLen;
1521
- }
1522
- };
1523
- };
1524
- /* HMAC implementation */
1525
-
1526
-
1527
- var hmac = function hmac(digest) {
1528
- var initialized = false;
1529
- var key, ipad, opad;
1530
-
1531
- var init = function init() {
1532
- var i, kbuf;
1533
-
1534
- if (initialized) {
1535
- return;
1536
- }
1537
-
1538
- if (key === undefined) {
1539
- throw "MAC key is not defined";
1540
- }
1541
-
1542
- if (key.byteLength > 64) {
1543
- /* B = 64 */
1544
- kbuf = new Uint8Array(digest.digest(key));
1545
- } else {
1546
- kbuf = new Uint8Array(key);
1547
- }
1548
-
1549
- ipad = new Uint8Array(new ArrayBuffer(64));
1550
-
1551
- for (i = 0; i < kbuf.length; i++) {
1552
- ipad[i] = 0x36 ^ kbuf[i];
1553
- }
1554
-
1555
- for (i = kbuf.length; i < 64; i++) {
1556
- ipad[i] = 0x36;
1557
- }
1558
-
1559
- opad = new Uint8Array(new ArrayBuffer(64));
1560
-
1561
- for (i = 0; i < kbuf.length; i++) {
1562
- opad[i] = 0x5c ^ kbuf[i];
1563
- }
1564
-
1565
- for (i = kbuf.length; i < 64; i++) {
1566
- opad[i] = 0x5c;
1567
- }
1568
-
1569
- initialized = true;
1570
- digest.update(ipad.buffer);
1571
- };
1572
-
1573
- var resetMac = function resetMac() {
1574
- initialized = false;
1575
- key = undefined;
1576
- ipad = undefined;
1577
- opad = undefined;
1578
- digest.reset();
1579
- };
1580
-
1581
- var finalizeMac = function finalizeMac() {
1582
- var result = digest.finalize();
1583
- digest.reset();
1584
- digest.update(opad.buffer);
1585
- digest.update(result);
1586
- result = digest.finalize();
1587
- resetMac();
1588
- return result;
1589
- };
1590
-
1591
- var setKeyMac = function setKeyMac(k) {
1592
- key = k;
1593
- };
1594
-
1595
- return {
1596
- setKey: function setKey(key) {
1597
- setKeyMac(convertToUint8Array(key));
1598
- init();
1599
- },
1600
- update: function update(input) {
1601
- digest.update(input);
1602
- },
1603
- finalize: function finalize() {
1604
- return finalizeMac();
1605
- },
1606
- mac: function mac(input) {
1607
- this.update(input);
1608
- return this.finalize();
1609
- },
1610
- reset: function reset() {
1611
- resetMac();
1612
- },
1613
- hmacLength: function hmacLength() {
1614
- return digest.digestLength();
1615
- }
1616
- };
1617
- };
1618
-
1619
- var Digest = {
1620
- SHA1: function SHA1() {
1621
- return dg(sha1Engine);
1622
- },
1623
- HMAC_SHA1: function HMAC_SHA1() {
1624
- return hmac(dg(sha1Engine));
1625
- }
1626
- };
1627
-
1628
- if (true) {
1629
- /* Node Support */
1630
- if ( true && module.exports) {
1631
- module.exports = exports = Digest;
1632
- } else {
1633
- exports = Digest;
1634
- }
1635
- } else {}
1636
- })(this);
1637
-
1638
- /***/ })
1639
-
1640
- /******/ });
1641
- });
1642
- //# sourceMappingURL=tiny-oss.js.map