@eluvio/elv-client-js 4.2.30 → 4.2.32

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.
@@ -1,11 +1,7 @@
1
- var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
2
1
  var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
3
2
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4
3
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
5
4
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
6
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
7
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
8
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
9
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
7
  /**
@@ -28,12 +24,6 @@ var _require = require("../Validation"),
28
24
  ValidateWriteToken = _require.ValidateWriteToken,
29
25
  ValidatePartHash = _require.ValidatePartHash,
30
26
  ValidateParameters = _require.ValidateParameters;
31
- var JobStatus = Object.freeze({
32
- STOPPED: "STOPPED",
33
- FAILED: "FAILED",
34
- IN_PROGRESS: "IN_PROGRESS",
35
- COMPLETED: "COMPLETED"
36
- });
37
27
 
38
28
  /* Files */
39
29
 
@@ -94,7 +84,7 @@ exports.ListFiles = /*#__PURE__*/function () {
94
84
  }();
95
85
 
96
86
  /**
97
- * Upload or resume copy/reference files from S3 to a content object
87
+ * Copy/reference files from S3 to a content object.
98
88
  *
99
89
  * S3 authentication is done by either providing an access key and secret or a presigned URL. The credentials will not be stored (neither in the client nor in the Fabric)
100
90
  *
@@ -102,12 +92,12 @@ exports.ListFiles = /*#__PURE__*/function () {
102
92
  *
103
93
  * Expected format of fileInfo:
104
94
  *
105
- [
106
- {
107
- path: string,
108
- source: string // either a full path e.g. "s3://BUCKET_NAME/path..." or just the path part without "s3://BUCKET_NAME/"
109
- }
110
- ]
95
+ [
96
+ {
97
+ path: string,
98
+ source: string // either a full path e.g. "s3://BUCKET_NAME/path..." or just the path part without "s3://BUCKET_NAME/"
99
+ }
100
+ ]
111
101
  *
112
102
  * @memberof module:ElvClient/Files+Parts
113
103
  * @methodGroup Files
@@ -115,27 +105,25 @@ exports.ListFiles = /*#__PURE__*/function () {
115
105
  * @param {string} libraryId - ID of the library
116
106
  * @param {string} objectId - ID of the object
117
107
  * @param {string} writeToken - Write token of the draft
118
- * @param {string=} region - AWS region to use
119
- * @param {string=} bucket - AWS bucket to use
108
+ * @param {string} region - AWS region to use
109
+ * @param {string} bucket - AWS bucket to use
120
110
  * @param {Array<Object>} fileInfo - List of files to reference/copy
121
- * @param {string=} accessKey - AWS access key
122
- * @param {string=} secret - AWS secret
111
+ * @param {string} accessKey - AWS access key
112
+ * @param {string} secret - AWS secret
123
113
  * @param {string=} signedUrl
124
114
  * @param {string} encryption="none" - Encryption for uploaded files (copy only) - cgck | none
125
115
  * @param {boolean} copy=false - If true, will copy the data from S3 into the fabric. Otherwise, a reference to the content will be made.
126
- * @param {boolean} resume=false - If true, will resume the file jobs stopped
127
116
  * @param {function=} callback - If specified, will be periodically called with current upload status
128
117
  * - Arguments (copy): { done: boolean, uploaded: number, total: number, uploadedFiles: number, totalFiles: number, fileStatus: Object }
129
118
  * - Arguments (reference): { done: boolean, uploadedFiles: number, totalFiles: number }
130
119
  */
131
120
  exports.UploadFilesFromS3 = /*#__PURE__*/function () {
132
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref3) {
133
- var _this = this;
134
- var libraryId, objectId, writeToken, region, bucket, fileInfo, accessKey, secret, signedUrl, _ref3$encryption, encryption, _ref3$copy, copy, _ref3$resume, resume, callback, s3prefixRegex, i, fileSourcePath, s3prefixMatch, bucketName, encryption_key, conk, cloudCredentials, remoteAccess, defaults, ops, trackUploadStatus, jobIds, jobsByStatus, resumeAndTrack, _i, _arr, status, trackOnlyEntries, _yield$this$CreateFil, uploadId;
135
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
136
- while (1) switch (_context6.prev = _context6.next) {
121
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
122
+ var libraryId, objectId, writeToken, region, bucket, fileInfo, accessKey, secret, signedUrl, _ref3$encryption, encryption, _ref3$copy, copy, callback, s3prefixRegex, i, fileSourcePath, s3prefixMatch, bucketName, encryption_key, conk, cloudCredentials, defaults, ops, _yield$this$CreateFil, id, status, done, progress, _progress;
123
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
124
+ while (1) switch (_context2.prev = _context2.next) {
137
125
  case 0:
138
- libraryId = _ref3.libraryId, objectId = _ref3.objectId, writeToken = _ref3.writeToken, region = _ref3.region, bucket = _ref3.bucket, fileInfo = _ref3.fileInfo, accessKey = _ref3.accessKey, secret = _ref3.secret, signedUrl = _ref3.signedUrl, _ref3$encryption = _ref3.encryption, encryption = _ref3$encryption === void 0 ? "none" : _ref3$encryption, _ref3$copy = _ref3.copy, copy = _ref3$copy === void 0 ? false : _ref3$copy, _ref3$resume = _ref3.resume, resume = _ref3$resume === void 0 ? false : _ref3$resume, callback = _ref3.callback;
126
+ libraryId = _ref3.libraryId, objectId = _ref3.objectId, writeToken = _ref3.writeToken, region = _ref3.region, bucket = _ref3.bucket, fileInfo = _ref3.fileInfo, accessKey = _ref3.accessKey, secret = _ref3.secret, signedUrl = _ref3.signedUrl, _ref3$encryption = _ref3.encryption, encryption = _ref3$encryption === void 0 ? "none" : _ref3$encryption, _ref3$copy = _ref3.copy, copy = _ref3$copy === void 0 ? false : _ref3$copy, callback = _ref3.callback;
139
127
  ValidateParameters({
140
128
  libraryId: libraryId,
141
129
  objectId: objectId
@@ -146,65 +134,71 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
146
134
  i = 0;
147
135
  case 5:
148
136
  if (!(i < fileInfo.length)) {
149
- _context6.next = 16;
137
+ _context2.next = 18;
150
138
  break;
151
139
  }
152
140
  fileSourcePath = fileInfo[i].source;
153
141
  s3prefixMatch = s3prefixRegex.exec(fileSourcePath);
154
142
  if (!s3prefixMatch) {
155
- _context6.next = 13;
143
+ _context2.next = 15;
156
144
  break;
157
145
  }
158
146
  bucketName = s3prefixMatch[1];
159
147
  if (!(bucketName !== bucket)) {
160
- _context6.next = 12;
148
+ _context2.next = 14;
161
149
  break;
162
150
  }
163
151
  throw Error("Full S3 file path \"" + fileSourcePath + "\" specified, but does not match provided bucket name '" + bucket + "'");
164
- case 12:
152
+ case 14:
165
153
  // strip prefix
166
154
  fileInfo[i].source = fileSourcePath.replace(s3prefixRegex, "");
167
- case 13:
155
+ case 15:
168
156
  i++;
169
- _context6.next = 5;
157
+ _context2.next = 5;
170
158
  break;
171
- case 16:
172
- this.Log("".concat(resume ? "Resuming" : copy ? "Copying" : "Referencing", " files from S3: ").concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
159
+ case 18:
160
+ if (copy) {
161
+ this.Log("Copying files from S3: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
162
+ } else {
163
+ this.Log("Adding links to files in S3: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
164
+ }
173
165
  if (!(encryption === "cgck")) {
174
- _context6.next = 23;
166
+ _context2.next = 25;
175
167
  break;
176
168
  }
177
- _context6.next = 20;
169
+ _context2.next = 22;
178
170
  return this.EncryptionConk({
179
171
  libraryId: libraryId,
180
172
  objectId: objectId,
181
173
  writeToken: writeToken
182
174
  });
183
- case 20:
184
- conk = _context6.sent;
175
+ case 22:
176
+ conk = _context2.sent;
185
177
  conk = _objectSpread(_objectSpread({}, conk), {}, {
186
178
  secret_key: ""
187
179
  });
188
180
  encryption_key = "kp__".concat(this.utils.B58(Buffer.from(JSON.stringify(conk))));
189
- case 23:
190
- cloudCredentials = signedUrl ? {
191
- signed_url: signedUrl
192
- } : {
181
+ case 25:
182
+ cloudCredentials = {
193
183
  access_key_id: accessKey,
194
184
  secret_access_key: secret
195
185
  };
196
- remoteAccess = {
197
- protocol: "s3",
198
- platform: "aws",
199
- cloud_credentials: cloudCredentials
200
- };
201
- if (bucket) remoteAccess.path = bucket;
202
- if (region) remoteAccess.storage_endpoint = {
203
- region: region
204
- };
186
+ if (signedUrl) {
187
+ cloudCredentials = {
188
+ signed_url: signedUrl
189
+ };
190
+ }
205
191
  defaults = {
206
192
  encryption_key: encryption_key,
207
- access: remoteAccess
193
+ access: {
194
+ protocol: "s3",
195
+ platform: "aws",
196
+ path: bucket,
197
+ storage_endpoint: {
198
+ region: region
199
+ },
200
+ cloud_credentials: cloudCredentials
201
+ }
208
202
  };
209
203
  ops = fileInfo.map(function (info) {
210
204
  if (copy) {
@@ -229,242 +223,94 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
229
223
  }
230
224
  };
231
225
  }
226
+ }); // eslint-disable-next-line no-unused-vars
227
+ _context2.next = 31;
228
+ return this.CreateFileUploadJob({
229
+ libraryId: libraryId,
230
+ objectId: objectId,
231
+ writeToken: writeToken,
232
+ ops: ops,
233
+ defaults: defaults
232
234
  });
233
- trackUploadStatus = /*#__PURE__*/function () {
234
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref5) {
235
- var uploadId, status, done, progress, _progress;
236
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
237
- while (1) switch (_context2.prev = _context2.next) {
238
- case 0:
239
- uploadId = _ref5.uploadId;
240
- case 1:
241
- if (!true) {
242
- _context2.next = 24;
243
- break;
244
- }
245
- _context2.next = 4;
246
- return new Promise(function (resolve) {
247
- return setTimeout(resolve, 1000);
248
- });
249
- case 4:
250
- _context2.next = 6;
251
- return _this.UploadStatus({
252
- libraryId: libraryId,
253
- objectId: objectId,
254
- writeToken: writeToken,
255
- uploadId: uploadId
256
- });
257
- case 6:
258
- status = _context2.sent;
259
- if (!(status.errors && status.errors.length >= 1)) {
260
- _context2.next = 11;
261
- break;
262
- }
263
- throw new Error(status.errors.join("\n"));
264
- case 11:
265
- if (!status.error) {
266
- _context2.next = 16;
267
- break;
268
- }
269
- _this.Log("S3 file upload failed:\n".concat(JSON.stringify(status, null, 2)));
270
- throw new Error(status.error);
271
- case 16:
272
- if (!(status.status.toLowerCase() === "failed")) {
273
- _context2.next = 18;
274
- break;
275
- }
276
- throw new Error("File upload failed");
277
- case 18:
278
- done = false;
279
- if (copy) {
280
- done = status.ingest_copy.done;
281
- if (callback) {
282
- progress = status.ingest_copy.progress;
283
- callback({
284
- done: done,
285
- uploaded: progress.bytes.completed,
286
- total: progress.bytes.total,
287
- uploadedFiles: progress.files.completed,
288
- totalFiles: progress.files.total,
289
- fileStatus: progress.files.details
290
- });
291
- }
292
- } else {
293
- done = status.add_reference.done;
294
- if (callback) {
295
- _progress = status.add_reference.progress;
296
- callback({
297
- done: done,
298
- uploadedFiles: _progress.completed,
299
- totalFiles: _progress.total
300
- });
301
- }
302
- }
303
- if (!done) {
304
- _context2.next = 22;
305
- break;
306
- }
307
- return _context2.abrupt("break", 24);
308
- case 22:
309
- _context2.next = 1;
310
- break;
311
- case 24:
312
- case "end":
313
- return _context2.stop();
314
- }
315
- }, _callee2);
316
- }));
317
- return function trackUploadStatus(_x3) {
318
- return _ref6.apply(this, arguments);
319
- };
320
- }();
321
- if (!resume) {
322
- _context6.next = 50;
235
+ case 31:
236
+ _yield$this$CreateFil = _context2.sent;
237
+ id = _yield$this$CreateFil.id;
238
+ case 33:
239
+ if (!true) {
240
+ _context2.next = 56;
323
241
  break;
324
242
  }
325
- _context6.next = 33;
326
- return this.ListFilesJob({
243
+ _context2.next = 36;
244
+ return new Promise(function (resolve) {
245
+ return setTimeout(resolve, 1000);
246
+ });
247
+ case 36:
248
+ _context2.next = 38;
249
+ return this.UploadStatus({
327
250
  libraryId: libraryId,
328
251
  objectId: objectId,
329
252
  writeToken: writeToken,
330
- encryption: encryption
253
+ uploadId: id
331
254
  });
332
- case 33:
333
- jobIds = _context6.sent;
334
- jobsByStatus = jobIds.reduce(function (acc, job) {
335
- acc[job.status] = acc[job.status] || new Map();
336
- acc[job.status].set(job.id, true);
337
- return acc;
338
- }, {});
339
- resumeAndTrack = /*#__PURE__*/function () {
340
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(jobIds) {
341
- var responses;
342
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
343
- while (1) switch (_context4.prev = _context4.next) {
344
- case 0:
345
- _context4.next = 2;
346
- return _this.ResumeFileUploadJob({
347
- libraryId: libraryId,
348
- objectId: objectId,
349
- writeToken: writeToken,
350
- ops: ops,
351
- defaults: defaults,
352
- encryption: encryption,
353
- stoppedOrFailedJobIds: jobIds
354
- });
355
- case 2:
356
- responses = _context4.sent;
357
- _context4.next = 5;
358
- return _this.utils.LimitedMap(5, responses, /*#__PURE__*/function () {
359
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(res) {
360
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
361
- while (1) switch (_context3.prev = _context3.next) {
362
- case 0:
363
- _this.Log("Tracking resumed job id: ".concat(res.id));
364
- _context3.next = 3;
365
- return trackUploadStatus({
366
- uploadId: res.id
367
- });
368
- case 3:
369
- case "end":
370
- return _context3.stop();
371
- }
372
- }, _callee3);
373
- }));
374
- return function (_x5) {
375
- return _ref8.apply(this, arguments);
376
- };
377
- }());
378
- case 5:
379
- case "end":
380
- return _context4.stop();
381
- }
382
- }, _callee4);
383
- }));
384
- return function resumeAndTrack(_x4) {
385
- return _ref7.apply(this, arguments);
386
- };
387
- }();
388
- _i = 0, _arr = [JobStatus.STOPPED, JobStatus.FAILED];
389
- case 37:
390
- if (!(_i < _arr.length)) {
391
- _context6.next = 45;
255
+ case 38:
256
+ status = _context2.sent;
257
+ if (!(status.errors && status.errors.length > 1)) {
258
+ _context2.next = 43;
392
259
  break;
393
260
  }
394
- status = _arr[_i];
395
- if (!jobsByStatus[status]) {
396
- _context6.next = 42;
261
+ throw status.errors.join("\n");
262
+ case 43:
263
+ if (!status.error) {
264
+ _context2.next = 48;
397
265
  break;
398
266
  }
399
- _context6.next = 42;
400
- return resumeAndTrack(_toConsumableArray(jobsByStatus[status].keys()));
401
- case 42:
402
- _i++;
403
- _context6.next = 37;
404
- break;
405
- case 45:
406
- trackOnlyEntries = Object.entries(jobsByStatus).filter(function (_ref9) {
407
- var _ref10 = _slicedToArray(_ref9, 1),
408
- status = _ref10[0];
409
- return [JobStatus.IN_PROGRESS, JobStatus.COMPLETED].includes(status);
410
- }).flatMap(function (_ref11) {
411
- var _ref12 = _slicedToArray(_ref11, 2),
412
- status = _ref12[0],
413
- jobs = _ref12[1];
414
- return _toConsumableArray(jobs.keys()).map(function (jobId) {
415
- return {
416
- status: status,
417
- jobId: jobId
418
- };
419
- });
420
- });
421
- _context6.next = 48;
422
- return this.utils.LimitedMap(5, trackOnlyEntries, /*#__PURE__*/function () {
423
- var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref13) {
424
- var status, jobId;
425
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
426
- while (1) switch (_context5.prev = _context5.next) {
427
- case 0:
428
- status = _ref13.status, jobId = _ref13.jobId;
429
- _this.Log("Tracking ".concat(status.toLowerCase(), " job id: ").concat(jobId));
430
- _context5.next = 4;
431
- return trackUploadStatus({
432
- uploadId: jobId
433
- });
434
- case 4:
435
- case "end":
436
- return _context5.stop();
437
- }
438
- }, _callee5);
439
- }));
440
- return function (_x6) {
441
- return _ref14.apply(this, arguments);
442
- };
443
- }());
267
+ this.Log("S3 file upload failed:\n".concat(JSON.stringify(status, null, 2)));
268
+ throw status.error;
444
269
  case 48:
445
- _context6.next = 56;
446
- break;
270
+ if (!(status.status.toLowerCase() === "failed")) {
271
+ _context2.next = 50;
272
+ break;
273
+ }
274
+ throw "File upload failed";
447
275
  case 50:
448
- _context6.next = 52;
449
- return this.CreateFileUploadJob({
450
- libraryId: libraryId,
451
- objectId: objectId,
452
- writeToken: writeToken,
453
- ops: ops,
454
- defaults: defaults
455
- });
456
- case 52:
457
- _yield$this$CreateFil = _context6.sent;
458
- uploadId = _yield$this$CreateFil.id;
459
- _context6.next = 56;
460
- return trackUploadStatus({
461
- uploadId: uploadId
462
- });
276
+ done = false;
277
+ if (copy) {
278
+ done = status.ingest_copy.done;
279
+ if (callback) {
280
+ progress = status.ingest_copy.progress;
281
+ callback({
282
+ done: done,
283
+ uploaded: progress.bytes.completed,
284
+ total: progress.bytes.total,
285
+ uploadedFiles: progress.files.completed,
286
+ totalFiles: progress.files.total,
287
+ fileStatus: progress.files.details
288
+ });
289
+ }
290
+ } else {
291
+ done = status.add_reference.done;
292
+ if (callback) {
293
+ _progress = status.add_reference.progress;
294
+ callback({
295
+ done: done,
296
+ uploadedFiles: _progress.completed,
297
+ totalFiles: _progress.total
298
+ });
299
+ }
300
+ }
301
+ if (!done) {
302
+ _context2.next = 54;
303
+ break;
304
+ }
305
+ return _context2.abrupt("break", 56);
306
+ case 54:
307
+ _context2.next = 33;
308
+ break;
463
309
  case 56:
464
310
  case "end":
465
- return _context6.stop();
311
+ return _context2.stop();
466
312
  }
467
- }, _callee6, this);
313
+ }, _callee2, this);
468
314
  }));
469
315
  return function (_x2) {
470
316
  return _ref4.apply(this, arguments);
@@ -476,14 +322,14 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
476
322
  *
477
323
  * Expected format of fileInfo:
478
324
  *
479
- [
480
- {
481
- path: string,
482
- mime_type: string,
483
- size: number,
484
- data: File | ArrayBuffer | Buffer | File Descriptor (Node)
485
- }
486
- ]
325
+ [
326
+ {
327
+ path: string,
328
+ mime_type: string,
329
+ size: number,
330
+ data: File | ArrayBuffer | Buffer | File Descriptor (Node)
331
+ }
332
+ ]
487
333
  *
488
334
  *
489
335
  * @memberof module:ElvClient/Files+Parts
@@ -493,19 +339,18 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
493
339
  * @param {string} objectId - ID of the object
494
340
  * @param {string} writeToken - Write token of the draft
495
341
  * @param {Array<object>} fileInfo - List of files to upload, including their size, type, and contents
496
- * @param {string} resume - Resume the upload jobs
497
342
  * @param {string} encryption="none" - Encryption for uploaded files - cgck | none
498
343
  * @param {function=} callback - If specified, will be called after each job segment is finished with the current upload progress
499
344
  * - Format: {"filename1": {uploaded: number, total: number}, ...}
500
345
  */
501
346
  exports.UploadFiles = /*#__PURE__*/function () {
502
- var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref15) {
503
- var _this2 = this;
504
- var libraryId, objectId, writeToken, fileInfo, _ref15$resume, resume, _ref15$encryption, encryption, callback, conk, progress, fileDataMap, originalFileInfo, i, entry, idJobMap, ids, jobsByStatus, stoppedJobIds, failedJobIds, inProgressJobIds, resumeJobIds, resumeJobs, _i2, _arr2, jobsToResume, uploadJobsResults, jobResponse, bufferSize, _iterator, _step, _loop;
505
- return _regeneratorRuntime.wrap(function _callee13$(_context15) {
506
- while (1) switch (_context15.prev = _context15.next) {
347
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref5) {
348
+ var _this = this;
349
+ var libraryId, objectId, writeToken, fileInfo, _ref5$encryption, encryption, callback, conk, progress, fileDataMap, originalFileInfo, i, entry, _yield$this$CreateFil2, id, jobs, bufferSize, jobSpecs, prepared, uploaded, PrepareJobs, UploadJob, rateTestJobs, rates, j, start, elapsed, size, averageRate, concurrentUploads;
350
+ return _regeneratorRuntime.wrap(function _callee6$(_context7) {
351
+ while (1) switch (_context7.prev = _context7.next) {
507
352
  case 0:
508
- libraryId = _ref15.libraryId, objectId = _ref15.objectId, writeToken = _ref15.writeToken, fileInfo = _ref15.fileInfo, _ref15$resume = _ref15.resume, resume = _ref15$resume === void 0 ? false : _ref15$resume, _ref15$encryption = _ref15.encryption, encryption = _ref15$encryption === void 0 ? "none" : _ref15$encryption, callback = _ref15.callback;
353
+ libraryId = _ref5.libraryId, objectId = _ref5.objectId, writeToken = _ref5.writeToken, fileInfo = _ref5.fileInfo, _ref5$encryption = _ref5.encryption, encryption = _ref5$encryption === void 0 ? "none" : _ref5$encryption, callback = _ref5.callback;
509
354
  ValidateParameters({
510
355
  libraryId: libraryId,
511
356
  objectId: objectId
@@ -514,17 +359,17 @@ exports.UploadFiles = /*#__PURE__*/function () {
514
359
  ValidatePresence("fileInfo", fileInfo);
515
360
  this.Log("Uploading files: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
516
361
  if (!(encryption === "cgck")) {
517
- _context15.next = 9;
362
+ _context7.next = 9;
518
363
  break;
519
364
  }
520
- _context15.next = 8;
365
+ _context7.next = 8;
521
366
  return this.EncryptionConk({
522
367
  libraryId: libraryId,
523
368
  objectId: objectId,
524
369
  writeToken: writeToken
525
370
  });
526
371
  case 8:
527
- conk = _context15.sent;
372
+ conk = _context7.sent;
528
373
  case 9:
529
374
  // Extract file data into easily accessible hash while removing the data from the fileinfo for upload job creation
530
375
  progress = {};
@@ -550,507 +395,294 @@ exports.UploadFiles = /*#__PURE__*/function () {
550
395
  fileInfo.push(entry);
551
396
  }
552
397
  this.Log(fileInfo);
553
-
554
- // On a fresh upload nothing has happened yet, so 0% is accurate. On resume, the real starting
555
- // point isn't known until job status is fetched below, so skip this to avoid a misleading
556
- // initial 0% line ahead of the actual (possibly much higher) baseline.
557
- if (callback && !resume) {
398
+ if (callback) {
558
399
  callback(progress);
559
400
  }
560
- idJobMap = new Map();
561
- if (!resume) {
562
- _context15.next = 45;
563
- break;
564
- }
565
- _context15.next = 20;
566
- return this.ListFilesJob({
401
+ _context7.next = 18;
402
+ return this.CreateFileUploadJob({
567
403
  libraryId: libraryId,
568
404
  objectId: objectId,
569
405
  writeToken: writeToken,
406
+ ops: fileInfo,
570
407
  encryption: encryption
571
408
  });
572
- case 20:
573
- ids = _context15.sent;
574
- jobsByStatus = ids.reduce(function (acc, job) {
575
- acc[job.status] = acc[job.status] || [];
576
- acc[job.status].push(job.id);
577
- return acc;
578
- }, {});
579
- stoppedJobIds = jobsByStatus.STOPPED || [];
580
- failedJobIds = jobsByStatus.FAILED || [];
581
- inProgressJobIds = jobsByStatus.IN_PROGRESS || [];
582
- resumeJobIds = [].concat(_toConsumableArray(stoppedJobIds), _toConsumableArray(failedJobIds), _toConsumableArray(inProgressJobIds));
583
- if (!(resumeJobIds.length === 0)) {
584
- _context15.next = 29;
585
- break;
586
- }
587
- this.Log("No job Ids to resume");
588
- return _context15.abrupt("return");
589
- case 29:
590
- resumeJobs = /*#__PURE__*/function () {
591
- var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(jobs) {
592
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
593
- while (1) switch (_context7.prev = _context7.next) {
409
+ case 18:
410
+ _yield$this$CreateFil2 = _context7.sent;
411
+ id = _yield$this$CreateFil2.id;
412
+ jobs = _yield$this$CreateFil2.jobs;
413
+ this.Log("Upload ID: ".concat(id));
414
+ this.Log(jobs);
415
+
416
+ // How far encryption can get ahead of upload
417
+ bufferSize = 500 * 1024 * 1024;
418
+ jobSpecs = [];
419
+ prepared = 0;
420
+ uploaded = 0; // Insert the data to upload into the job spec, encrypting if necessary
421
+ PrepareJobs = /*#__PURE__*/function () {
422
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
423
+ var j, jobId, job, f, _fileInfo, data;
424
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
425
+ while (1) switch (_context3.prev = _context3.next) {
594
426
  case 0:
595
- _context7.next = 2;
596
- return _this2.ResumeFileUploadJob({
427
+ j = 0;
428
+ case 1:
429
+ if (!(j < jobs.length)) {
430
+ _context3.next = 31;
431
+ break;
432
+ }
433
+ case 2:
434
+ if (!(prepared - uploaded > bufferSize)) {
435
+ _context3.next = 7;
436
+ break;
437
+ }
438
+ _context3.next = 5;
439
+ return new Promise(function (resolve) {
440
+ return setTimeout(resolve, 500);
441
+ });
442
+ case 5:
443
+ _context3.next = 2;
444
+ break;
445
+ case 7:
446
+ // Retrieve job info
447
+ jobId = jobs[j];
448
+ _context3.next = 10;
449
+ return _this.UploadJobStatus({
597
450
  libraryId: libraryId,
598
451
  objectId: objectId,
599
452
  writeToken: writeToken,
600
- ops: fileInfo,
601
- encryption: encryption,
602
- stoppedOrFailedJobIds: jobs
453
+ uploadId: id,
454
+ jobId: jobId
603
455
  });
604
- case 2:
456
+ case 10:
457
+ job = _context3.sent;
458
+ f = 0;
459
+ case 12:
460
+ if (!(f < job.files.length)) {
461
+ _context3.next = 25;
462
+ break;
463
+ }
464
+ _fileInfo = job.files[f];
465
+ data = void 0;
466
+ if (typeof fileDataMap[_fileInfo.path] === "number") {
467
+ // File descriptor - Read data from file
468
+ data = Buffer.alloc(_fileInfo.len);
469
+ fs.readSync(fileDataMap[_fileInfo.path], data, 0, _fileInfo.len, _fileInfo.off);
470
+ } else {
471
+ // Full data - Slice requested chunk
472
+ data = fileDataMap[_fileInfo.path].slice(_fileInfo.off, _fileInfo.off + _fileInfo.len);
473
+ }
474
+ if (!(encryption === "cgck")) {
475
+ _context3.next = 20;
476
+ break;
477
+ }
478
+ _context3.next = 19;
479
+ return _this.Crypto.Encrypt(conk, data);
480
+ case 19:
481
+ data = _context3.sent;
482
+ case 20:
483
+ job.files[f].data = data;
484
+ prepared += _fileInfo.len;
485
+ case 22:
486
+ f++;
487
+ _context3.next = 12;
488
+ break;
489
+ case 25:
490
+ jobSpecs[j] = job;
491
+
492
+ // Wait for a bit to let upload start
493
+ _context3.next = 28;
494
+ return new Promise(function (resolve) {
495
+ return setTimeout(resolve, 50);
496
+ });
497
+ case 28:
498
+ j++;
499
+ _context3.next = 1;
500
+ break;
501
+ case 31:
605
502
  case "end":
606
- return _context7.stop();
503
+ return _context3.stop();
607
504
  }
608
- }, _callee7);
505
+ }, _callee3);
609
506
  }));
610
- return function resumeJobs(_x8) {
611
- return _ref17.apply(this, arguments);
507
+ return function PrepareJobs() {
508
+ return _ref7.apply(this, arguments);
612
509
  };
613
- }(); // resume stopped and failed jobs
614
- _i2 = 0, _arr2 = [stoppedJobIds, failedJobIds];
615
- case 31:
616
- if (!(_i2 < _arr2.length)) {
617
- _context15.next = 39;
618
- break;
619
- }
620
- jobsToResume = _arr2[_i2];
621
- if (!(jobsToResume.length > 0)) {
622
- _context15.next = 36;
623
- break;
624
- }
625
- _context15.next = 36;
626
- return resumeJobs(jobsToResume);
627
- case 36:
628
- _i2++;
629
- _context15.next = 31;
630
- break;
631
- case 39:
632
- _context15.next = 41;
633
- return this.utils.LimitedMap(5, resumeJobIds, /*#__PURE__*/function () {
634
- var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(uploadId) {
635
- var result;
636
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
637
- while (1) switch (_context8.prev = _context8.next) {
510
+ }();
511
+ UploadJob = /*#__PURE__*/function () {
512
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(jobId, j) {
513
+ var jobSpec, files, _loop, f;
514
+ return _regeneratorRuntime.wrap(function _callee4$(_context5) {
515
+ while (1) switch (_context5.prev = _context5.next) {
638
516
  case 0:
639
- _context8.next = 2;
640
- return _this2.ListFilesUploadJobs({
641
- libraryId: libraryId,
642
- objectId: objectId,
643
- writeToken: writeToken,
644
- jobId: uploadId,
645
- encryption: encryption
517
+ if (jobSpecs[j]) {
518
+ _context5.next = 5;
519
+ break;
520
+ }
521
+ _context5.next = 3;
522
+ return new Promise(function (resolve) {
523
+ return setTimeout(resolve, 500);
646
524
  });
647
- case 2:
648
- result = _context8.sent;
649
- return _context8.abrupt("return", result.jobs);
650
- case 4:
651
- case "end":
652
- return _context8.stop();
653
- }
654
- }, _callee8);
655
- }));
656
- return function (_x9) {
657
- return _ref18.apply(this, arguments);
658
- };
659
- }());
660
- case 41:
661
- uploadJobsResults = _context15.sent;
662
- resumeJobIds.forEach(function (uploadId, i) {
663
- return idJobMap.set(uploadId, uploadJobsResults[i]);
664
- });
665
- _context15.next = 49;
666
- break;
667
- case 45:
668
- _context15.next = 47;
669
- return this.CreateFileUploadJob({
670
- libraryId: libraryId,
671
- objectId: objectId,
672
- writeToken: writeToken,
673
- ops: fileInfo,
674
- encryption: encryption
675
- });
676
- case 47:
677
- jobResponse = _context15.sent;
678
- idJobMap.set(jobResponse.id, jobResponse.jobs);
679
- case 49:
680
- // How far encryption can get ahead of upload (500 MB)
681
- bufferSize = 500 * 1024 * 1024; // Process each uploadId and its jobs
682
- _iterator = _createForOfIteratorHelper(idJobMap.entries());
683
- _context15.prev = 51;
684
- _loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
685
- var _step$value, uploadId, jobs, prepared, uploaded, jobSpecs, alreadyCreditedKeys, PrepareJobs, UploadJob, rateTestJobs, rates, j, start, elapsed, size, averageRate, concurrentUploads;
686
- return _regeneratorRuntime.wrap(function _loop$(_context14) {
687
- while (1) switch (_context14.prev = _context14.next) {
688
- case 0:
689
- _step$value = _slicedToArray(_step.value, 2), uploadId = _step$value[0], jobs = _step$value[1];
690
- _this2.Log("Upload ID: ".concat(uploadId));
691
- _this2.Log(jobs.length);
692
-
693
- // Each upload ID gets its own counters
694
- prepared = 0;
695
- uploaded = 0;
696
- jobSpecs = []; // `${jobId}:${path}` pairs already reflected in progress by the resume baseline scan below,
697
- // so the normal per-chunk completion credit further down doesn't double-count them
698
- // It stores the jobId whose remaining bytes = 0
699
- alreadyCreditedKeys = new Set();
700
- if (!(resume && callback)) {
701
- _context14.next = 11;
525
+ case 3:
526
+ _context5.next = 0;
702
527
  break;
703
- }
704
- _context14.next = 10;
705
- return _this2.utils.LimitedMap(5, jobs, /*#__PURE__*/function () {
706
- var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(jobId) {
707
- var job, _iterator2, _step2, _fileInfo, fileStatus;
708
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
709
- while (1) switch (_context9.prev = _context9.next) {
528
+ case 5:
529
+ jobSpec = jobSpecs[j];
530
+ files = jobSpec.files; // Upload each item
531
+ _loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
532
+ var fileInfo, retries, succeeded;
533
+ return _regeneratorRuntime.wrap(function _loop$(_context4) {
534
+ while (1) switch (_context4.prev = _context4.next) {
710
535
  case 0:
711
- _context9.next = 2;
712
- return _this2.UploadJobStatus({
536
+ fileInfo = files[f];
537
+ retries = 0;
538
+ succeeded = false;
539
+ case 3:
540
+ _context4.prev = 3;
541
+ _context4.next = 6;
542
+ return _this.UploadFileData({
713
543
  libraryId: libraryId,
714
544
  objectId: objectId,
715
545
  writeToken: writeToken,
716
- uploadId: uploadId,
717
- jobId: jobId
546
+ uploadId: id,
547
+ jobId: jobId,
548
+ filePath: fileInfo.path,
549
+ fileData: fileInfo.data,
550
+ encryption: encryption
718
551
  });
719
- case 2:
720
- job = _context9.sent;
721
- _iterator2 = _createForOfIteratorHelper(job.files);
722
- try {
723
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
724
- _fileInfo = _step2.value;
725
- // When encrypted, the top-level rem/skip are sentinel (-1) - the real, already-received
726
- // byte counts for this chunk are under `encrypted` (same lookup UploadFileData uses)
727
- fileStatus = encryption && encryption !== "none" ? _fileInfo.encrypted : _fileInfo;
728
- if (fileStatus.rem === 0) {
729
- alreadyCreditedKeys.add("".concat(jobId, ":").concat(_fileInfo.path));
730
- progress[_fileInfo.path] = _objectSpread(_objectSpread({}, progress[_fileInfo.path]), {}, {
731
- uploaded: progress[_fileInfo.path].uploaded + _fileInfo.len
732
- });
733
- }
734
- }
735
- } catch (err) {
736
- _iterator2.e(err);
737
- } finally {
738
- _iterator2.f();
739
- }
740
- case 5:
741
- case "end":
742
- return _context9.stop();
743
- }
744
- }, _callee9);
745
- }));
746
- return function (_x10) {
747
- return _ref19.apply(this, arguments);
748
- };
749
- }());
750
- case 10:
751
- callback(progress);
752
- case 11:
753
- // Insert the data to upload into the job spec, encrypting if necessary
754
- PrepareJobs = /*#__PURE__*/function () {
755
- var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
756
- var j, jobId, job, f, _fileInfo2, data;
757
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
758
- while (1) switch (_context10.prev = _context10.next) {
759
- case 0:
760
- j = 0;
761
- case 1:
762
- if (!(j < jobs.length)) {
763
- _context10.next = 31;
764
- break;
765
- }
766
- case 2:
767
- if (!(prepared - uploaded > bufferSize)) {
768
- _context10.next = 7;
769
- break;
770
- }
771
- _context10.next = 5;
772
- return new Promise(function (resolve) {
773
- return setTimeout(resolve, 500);
774
- });
775
- case 5:
776
- _context10.next = 2;
552
+ case 6:
553
+ succeeded = true;
554
+ _context4.next = 17;
777
555
  break;
778
- case 7:
779
- // Retrieve job info
780
- jobId = jobs[j];
781
- _context10.next = 10;
782
- return _this2.UploadJobStatus({
783
- libraryId: libraryId,
784
- objectId: objectId,
785
- writeToken: writeToken,
786
- uploadId: uploadId,
787
- jobId: jobId
788
- });
789
- case 10:
790
- job = _context10.sent;
791
- f = 0;
792
- case 12:
793
- if (!(f < job.files.length)) {
794
- _context10.next = 25;
795
- break;
796
- }
797
- _fileInfo2 = job.files[f];
798
- data = void 0;
799
- if (typeof fileDataMap[_fileInfo2.path] === "number") {
800
- // File descriptor - Read data from file
801
- data = Buffer.alloc(_fileInfo2.len);
802
- fs.readSync(fileDataMap[_fileInfo2.path], data, 0, _fileInfo2.len, _fileInfo2.off);
803
- } else {
804
- // Full data - Slice requested chunk
805
- data = fileDataMap[_fileInfo2.path].slice(_fileInfo2.off, _fileInfo2.off + _fileInfo2.len);
806
- }
807
- if (!(encryption === "cgck")) {
808
- _context10.next = 20;
556
+ case 9:
557
+ _context4.prev = 9;
558
+ _context4.t0 = _context4["catch"](3);
559
+ _this.Log(_context4.t0, true);
560
+ retries += 1;
561
+ if (!(retries >= 10)) {
562
+ _context4.next = 15;
809
563
  break;
810
564
  }
811
- _context10.next = 19;
812
- return _this2.Crypto.Encrypt(conk, data);
813
- case 19:
814
- data = _context10.sent;
815
- case 20:
816
- job.files[f].data = data;
817
- prepared += _fileInfo2.len;
818
- case 22:
819
- f++;
820
- _context10.next = 12;
821
- break;
822
- case 25:
823
- jobSpecs[j] = job;
824
-
825
- // Wait for a bit to let upload start
826
- _context10.next = 28;
565
+ throw _context4.t0;
566
+ case 15:
567
+ _context4.next = 17;
827
568
  return new Promise(function (resolve) {
828
- return setTimeout(resolve, 50);
569
+ return setTimeout(resolve, 10 * retries * 1000);
829
570
  });
830
- case 28:
831
- j++;
832
- _context10.next = 1;
833
- break;
834
- case 31:
835
- case "end":
836
- return _context10.stop();
837
- }
838
- }, _callee10);
839
- }));
840
- return function PrepareJobs() {
841
- return _ref20.apply(this, arguments);
842
- };
843
- }();
844
- UploadJob = /*#__PURE__*/function () {
845
- var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(jobId, j) {
846
- var jobSpec, files, _loop2, f;
847
- return _regeneratorRuntime.wrap(function _callee11$(_context12) {
848
- while (1) switch (_context12.prev = _context12.next) {
849
- case 0:
850
- if (jobSpecs[j]) {
851
- _context12.next = 5;
571
+ case 17:
572
+ if (!succeeded && retries < 10) {
573
+ _context4.next = 3;
852
574
  break;
853
575
  }
854
- _context12.next = 3;
855
- return new Promise(function (resolve) {
856
- return setTimeout(resolve, 500);
857
- });
858
- case 3:
859
- _context12.next = 0;
860
- break;
861
- case 5:
862
- jobSpec = jobSpecs[j];
863
- files = jobSpec.files; // Upload each item
864
- _loop2 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop2() {
865
- var fileInfo, retries, succeeded;
866
- return _regeneratorRuntime.wrap(function _loop2$(_context11) {
867
- while (1) switch (_context11.prev = _context11.next) {
868
- case 0:
869
- fileInfo = files[f];
870
- retries = 0;
871
- succeeded = false;
872
- case 3:
873
- _context11.prev = 3;
874
- _context11.next = 6;
875
- return _this2.UploadFileData({
876
- libraryId: libraryId,
877
- objectId: objectId,
878
- writeToken: writeToken,
879
- uploadId: uploadId,
880
- jobId: jobId,
881
- filePath: fileInfo.path,
882
- fileData: fileInfo.data,
883
- encryption: encryption
884
- });
885
- case 6:
886
- succeeded = true;
887
- _context11.next = 17;
888
- break;
889
- case 9:
890
- _context11.prev = 9;
891
- _context11.t0 = _context11["catch"](3);
892
- _this2.Log(_context11.t0, true);
893
- retries += 1;
894
- if (!(retries >= 10)) {
895
- _context11.next = 15;
896
- break;
897
- }
898
- throw _context11.t0;
899
- case 15:
900
- _context11.next = 17;
901
- return new Promise(function (resolve) {
902
- return setTimeout(resolve, 10 * retries * 1000);
903
- });
904
- case 17:
905
- if (!succeeded && retries < 10) {
906
- _context11.next = 3;
907
- break;
908
- }
909
- case 18:
910
- delete jobSpecs[j].files[f].data;
911
- uploaded += fileInfo.len;
912
- if (callback && !alreadyCreditedKeys.has("".concat(jobId, ":").concat(fileInfo.path))) {
913
- progress[fileInfo.path] = _objectSpread(_objectSpread({}, progress[fileInfo.path]), {}, {
914
- uploaded: progress[fileInfo.path].uploaded + fileInfo.len
915
- });
916
- callback(progress);
917
- }
918
- case 21:
919
- case "end":
920
- return _context11.stop();
921
- }
922
- }, _loop2, null, [[3, 9]]);
923
- });
924
- f = 0;
925
- case 9:
926
- if (!(f < files.length)) {
927
- _context12.next = 14;
928
- break;
576
+ case 18:
577
+ delete jobSpecs[j].files[f].data;
578
+ uploaded += fileInfo.len;
579
+ if (callback) {
580
+ progress[fileInfo.path] = _objectSpread(_objectSpread({}, progress[fileInfo.path]), {}, {
581
+ uploaded: progress[fileInfo.path].uploaded + fileInfo.len
582
+ });
583
+ callback(progress);
929
584
  }
930
- return _context12.delegateYield(_loop2(), "t0", 11);
931
- case 11:
932
- f++;
933
- _context12.next = 9;
934
- break;
935
- case 14:
585
+ case 21:
936
586
  case "end":
937
- return _context12.stop();
587
+ return _context4.stop();
938
588
  }
939
- }, _callee11);
940
- }));
941
- return function UploadJob(_x11, _x12) {
942
- return _ref21.apply(this, arguments);
943
- };
944
- }(); // Preparing jobs is done asynchronously
945
- PrepareJobs()["catch"](function (e) {
946
- throw e;
947
- });
948
-
949
- // Upload the first several chunks in sequence, to determine average upload rate
950
- rateTestJobs = Math.min(3, jobs.length);
951
- rates = [];
952
- j = 0;
953
- case 17:
954
- if (!(j < rateTestJobs)) {
955
- _context14.next = 27;
589
+ }, _loop, null, [[3, 9]]);
590
+ });
591
+ f = 0;
592
+ case 9:
593
+ if (!(f < files.length)) {
594
+ _context5.next = 14;
595
+ break;
596
+ }
597
+ return _context5.delegateYield(_loop(), "t0", 11);
598
+ case 11:
599
+ f++;
600
+ _context5.next = 9;
956
601
  break;
957
- }
958
- start = new Date().getTime();
959
- _context14.next = 21;
960
- return UploadJob(jobs[j], j);
961
- case 21:
962
- elapsed = (new Date().getTime() - start) / 1000;
963
- size = jobSpecs[j].files.map(function (file) {
964
- return file.len;
965
- }).reduce(function (length, total) {
966
- return length + total;
967
- }, 0);
968
- rates.push(size / elapsed / (1024 * 1024));
969
- case 24:
970
- j++;
971
- _context14.next = 17;
972
- break;
973
- case 27:
974
- averageRate = rates.reduce(function (mbps, total) {
975
- return mbps + total;
976
- }, 0) / rateTestJobs; // Upload remaining jobs in parallel
977
- concurrentUploads = Math.min(5, Math.ceil(averageRate / 2));
978
- _context14.next = 31;
979
- return _this2.utils.LimitedMap(concurrentUploads, jobs, /*#__PURE__*/function () {
980
- var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(jobId, j) {
981
- return _regeneratorRuntime.wrap(function _callee12$(_context13) {
982
- while (1) switch (_context13.prev = _context13.next) {
983
- case 0:
984
- if (!(j < rateTestJobs)) {
985
- _context13.next = 2;
986
- break;
987
- }
988
- return _context13.abrupt("return");
989
- case 2:
990
- _context13.prev = 2;
991
- _context13.next = 5;
992
- return UploadJob(jobId, j);
993
- case 5:
994
- _context13.next = 10;
995
- break;
996
- case 7:
997
- _context13.prev = 7;
998
- _context13.t0 = _context13["catch"](2);
999
- throw Error("Failed upload for job ".concat(jobId, ": ").concat(_context13.t0));
1000
- case 10:
1001
- case "end":
1002
- return _context13.stop();
1003
- }
1004
- }, _callee12, null, [[2, 7]]);
1005
- }));
1006
- return function (_x13, _x14) {
1007
- return _ref22.apply(this, arguments);
1008
- };
1009
- }());
1010
- case 31:
1011
- case "end":
1012
- return _context14.stop();
1013
- }
1014
- }, _loop);
1015
- });
1016
- _iterator.s();
1017
- case 54:
1018
- if ((_step = _iterator.n()).done) {
1019
- _context15.next = 58;
602
+ case 14:
603
+ case "end":
604
+ return _context5.stop();
605
+ }
606
+ }, _callee4);
607
+ }));
608
+ return function UploadJob(_x4, _x5) {
609
+ return _ref8.apply(this, arguments);
610
+ };
611
+ }(); // Preparing jobs is done asynchronously
612
+ PrepareJobs()["catch"](function (e) {
613
+ throw e;
614
+ });
615
+
616
+ // Upload the first several chunks in sequence, to determine average upload rate
617
+ rateTestJobs = Math.min(3, jobs.length);
618
+ rates = [];
619
+ j = 0;
620
+ case 33:
621
+ if (!(j < rateTestJobs)) {
622
+ _context7.next = 43;
1020
623
  break;
1021
624
  }
1022
- return _context15.delegateYield(_loop(), "t0", 56);
1023
- case 56:
1024
- _context15.next = 54;
1025
- break;
1026
- case 58:
1027
- _context15.next = 63;
625
+ start = new Date().getTime();
626
+ _context7.next = 37;
627
+ return UploadJob(jobs[j], j);
628
+ case 37:
629
+ elapsed = (new Date().getTime() - start) / 1000;
630
+ size = jobSpecs[j].files.map(function (file) {
631
+ return file.len;
632
+ }).reduce(function (length, total) {
633
+ return length + total;
634
+ }, 0);
635
+ rates.push(size / elapsed / (1024 * 1024));
636
+ case 40:
637
+ j++;
638
+ _context7.next = 33;
1028
639
  break;
1029
- case 60:
1030
- _context15.prev = 60;
1031
- _context15.t1 = _context15["catch"](51);
1032
- _iterator.e(_context15.t1);
1033
- case 63:
1034
- _context15.prev = 63;
1035
- _iterator.f();
1036
- return _context15.finish(63);
1037
- case 66:
640
+ case 43:
641
+ averageRate = rates.reduce(function (mbps, total) {
642
+ return mbps + total;
643
+ }, 0) / rateTestJobs; // Upload remaining jobs in parallel
644
+ concurrentUploads = Math.min(5, Math.ceil(averageRate / 2));
645
+ _context7.next = 47;
646
+ return this.utils.LimitedMap(concurrentUploads, jobs, /*#__PURE__*/function () {
647
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(jobId, j) {
648
+ return _regeneratorRuntime.wrap(function _callee5$(_context6) {
649
+ while (1) switch (_context6.prev = _context6.next) {
650
+ case 0:
651
+ if (!(j < rateTestJobs)) {
652
+ _context6.next = 2;
653
+ break;
654
+ }
655
+ return _context6.abrupt("return");
656
+ case 2:
657
+ _context6.next = 4;
658
+ return UploadJob(jobId, j);
659
+ case 4:
660
+ case "end":
661
+ return _context6.stop();
662
+ }
663
+ }, _callee5);
664
+ }));
665
+ return function (_x6, _x7) {
666
+ return _ref9.apply(this, arguments);
667
+ };
668
+ }());
669
+ case 47:
1038
670
  case "end":
1039
- return _context15.stop();
671
+ return _context7.stop();
1040
672
  }
1041
- }, _callee13, this, [[51, 60, 63, 66]]);
673
+ }, _callee6, this);
1042
674
  }));
1043
- return function (_x7) {
1044
- return _ref16.apply(this, arguments);
675
+ return function (_x3) {
676
+ return _ref6.apply(this, arguments);
1045
677
  };
1046
678
  }();
1047
679
  exports.CreateFileUploadJob = /*#__PURE__*/function () {
1048
- var _ref24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref23) {
1049
- var libraryId, objectId, writeToken, ops, _ref23$defaults, defaults, _ref23$encryption, encryption, body, path;
1050
- return _regeneratorRuntime.wrap(function _callee14$(_context16) {
1051
- while (1) switch (_context16.prev = _context16.next) {
680
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref10) {
681
+ var libraryId, objectId, writeToken, ops, _ref10$defaults, defaults, _ref10$encryption, encryption, body, path;
682
+ return _regeneratorRuntime.wrap(function _callee7$(_context8) {
683
+ while (1) switch (_context8.prev = _context8.next) {
1052
684
  case 0:
1053
- libraryId = _ref23.libraryId, objectId = _ref23.objectId, writeToken = _ref23.writeToken, ops = _ref23.ops, _ref23$defaults = _ref23.defaults, defaults = _ref23$defaults === void 0 ? {} : _ref23$defaults, _ref23$encryption = _ref23.encryption, encryption = _ref23$encryption === void 0 ? "none" : _ref23$encryption;
685
+ libraryId = _ref10.libraryId, objectId = _ref10.objectId, writeToken = _ref10.writeToken, ops = _ref10.ops, _ref10$defaults = _ref10.defaults, defaults = _ref10$defaults === void 0 ? {} : _ref10$defaults, _ref10$encryption = _ref10.encryption, encryption = _ref10$encryption === void 0 ? "none" : _ref10$encryption;
1054
686
  ValidateParameters({
1055
687
  libraryId: libraryId,
1056
688
  objectId: objectId
@@ -1070,8 +702,8 @@ exports.CreateFileUploadJob = /*#__PURE__*/function () {
1070
702
  ops: ops
1071
703
  };
1072
704
  path = UrlJoin("q", writeToken, "file_jobs");
1073
- _context16.t0 = this.HttpClient;
1074
- _context16.next = 11;
705
+ _context8.t0 = this.HttpClient;
706
+ _context8.next = 11;
1075
707
  return this.authClient.AuthorizationHeader({
1076
708
  libraryId: libraryId,
1077
709
  objectId: objectId,
@@ -1079,350 +711,169 @@ exports.CreateFileUploadJob = /*#__PURE__*/function () {
1079
711
  encryption: encryption
1080
712
  });
1081
713
  case 11:
1082
- _context16.t1 = _context16.sent;
1083
- _context16.t2 = path;
1084
- _context16.t3 = body;
1085
- _context16.t4 = {
1086
- headers: _context16.t1,
714
+ _context8.t1 = _context8.sent;
715
+ _context8.t2 = path;
716
+ _context8.t3 = body;
717
+ _context8.t4 = {
718
+ headers: _context8.t1,
1087
719
  method: "POST",
1088
- path: _context16.t2,
1089
- body: _context16.t3,
720
+ path: _context8.t2,
721
+ body: _context8.t3,
1090
722
  allowFailover: false
1091
723
  };
1092
- return _context16.abrupt("return", _context16.t0.RequestJsonBody.call(_context16.t0, _context16.t4));
724
+ return _context8.abrupt("return", _context8.t0.RequestJsonBody.call(_context8.t0, _context8.t4));
1093
725
  case 16:
1094
726
  case "end":
1095
- return _context16.stop();
1096
- }
1097
- }, _callee14, this);
1098
- }));
1099
- return function (_x15) {
1100
- return _ref24.apply(this, arguments);
1101
- };
1102
- }();
1103
- exports.ListFilesJob = /*#__PURE__*/function () {
1104
- var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref25) {
1105
- var libraryId, objectId, writeToken, _ref25$encryption, encryption, path;
1106
- return _regeneratorRuntime.wrap(function _callee15$(_context17) {
1107
- while (1) switch (_context17.prev = _context17.next) {
1108
- case 0:
1109
- libraryId = _ref25.libraryId, objectId = _ref25.objectId, writeToken = _ref25.writeToken, _ref25$encryption = _ref25.encryption, encryption = _ref25$encryption === void 0 ? "none" : _ref25$encryption;
1110
- ValidateParameters({
1111
- libraryId: libraryId,
1112
- objectId: objectId
1113
- });
1114
- ValidateWriteToken(writeToken);
1115
- this.Log("List file jobs: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
1116
- path = UrlJoin("q", writeToken, "file_jobs");
1117
- _context17.t0 = this.HttpClient;
1118
- _context17.next = 8;
1119
- return this.authClient.AuthorizationHeader({
1120
- libraryId: libraryId,
1121
- objectId: objectId,
1122
- update: true,
1123
- encryption: encryption
1124
- });
1125
- case 8:
1126
- _context17.t1 = _context17.sent;
1127
- _context17.t2 = path;
1128
- _context17.t3 = {
1129
- headers: _context17.t1,
1130
- method: "GET",
1131
- path: _context17.t2,
1132
- allowFailover: false
1133
- };
1134
- return _context17.abrupt("return", _context17.t0.RequestJsonBody.call(_context17.t0, _context17.t3));
1135
- case 12:
1136
- case "end":
1137
- return _context17.stop();
1138
- }
1139
- }, _callee15, this);
1140
- }));
1141
- return function (_x16) {
1142
- return _ref26.apply(this, arguments);
1143
- };
1144
- }();
1145
- exports.ListFilesUploadJobs = /*#__PURE__*/function () {
1146
- var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref27) {
1147
- var libraryId, objectId, writeToken, jobId, _ref27$encryption, encryption, path;
1148
- return _regeneratorRuntime.wrap(function _callee16$(_context18) {
1149
- while (1) switch (_context18.prev = _context18.next) {
1150
- case 0:
1151
- libraryId = _ref27.libraryId, objectId = _ref27.objectId, writeToken = _ref27.writeToken, jobId = _ref27.jobId, _ref27$encryption = _ref27.encryption, encryption = _ref27$encryption === void 0 ? "none" : _ref27$encryption;
1152
- ValidateParameters({
1153
- libraryId: libraryId,
1154
- objectId: objectId
1155
- });
1156
- ValidateWriteToken(writeToken);
1157
- this.Log("List file upload jobs: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
1158
- path = UrlJoin("qlibs", libraryId, "q", writeToken, "file_jobs", jobId, "uploads");
1159
- _context18.t0 = this.HttpClient;
1160
- _context18.next = 8;
1161
- return this.authClient.AuthorizationHeader({
1162
- libraryId: libraryId,
1163
- objectId: objectId,
1164
- update: true,
1165
- encryption: encryption
1166
- });
1167
- case 8:
1168
- _context18.t1 = _context18.sent;
1169
- _context18.t2 = path;
1170
- _context18.t3 = {
1171
- headers: _context18.t1,
1172
- method: "GET",
1173
- path: _context18.t2,
1174
- allowFailover: false
1175
- };
1176
- return _context18.abrupt("return", _context18.t0.RequestJsonBody.call(_context18.t0, _context18.t3));
1177
- case 12:
1178
- case "end":
1179
- return _context18.stop();
1180
- }
1181
- }, _callee16, this);
1182
- }));
1183
- return function (_x17) {
1184
- return _ref28.apply(this, arguments);
1185
- };
1186
- }();
1187
- exports.ResumeFileUploadJob = /*#__PURE__*/function () {
1188
- var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref29) {
1189
- var libraryId, objectId, writeToken, ops, _ref29$defaults, defaults, _ref29$encryption, encryption, _ref29$stoppedOrFaile, stoppedOrFailedJobIds, body, responses, _iterator3, _step3, jobId, path, res;
1190
- return _regeneratorRuntime.wrap(function _callee17$(_context19) {
1191
- while (1) switch (_context19.prev = _context19.next) {
1192
- case 0:
1193
- libraryId = _ref29.libraryId, objectId = _ref29.objectId, writeToken = _ref29.writeToken, ops = _ref29.ops, _ref29$defaults = _ref29.defaults, defaults = _ref29$defaults === void 0 ? {} : _ref29$defaults, _ref29$encryption = _ref29.encryption, encryption = _ref29$encryption === void 0 ? "none" : _ref29$encryption, _ref29$stoppedOrFaile = _ref29.stoppedOrFailedJobIds, stoppedOrFailedJobIds = _ref29$stoppedOrFaile === void 0 ? [] : _ref29$stoppedOrFaile;
1194
- ValidateParameters({
1195
- libraryId: libraryId,
1196
- objectId: objectId
1197
- });
1198
- ValidateWriteToken(writeToken);
1199
- if (!(stoppedOrFailedJobIds.length === 0)) {
1200
- _context19.next = 6;
1201
- break;
1202
- }
1203
- this.Log("No stopped/failed jobs found");
1204
- throw new Error("No STOPPED/FAILED jobs found");
1205
- case 6:
1206
- this.Log("Resuming file upload job: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
1207
- if (encryption === "cgck") {
1208
- defaults.encryption = {
1209
- scheme: "cgck"
1210
- };
1211
- }
1212
- body = {
1213
- seq: 0,
1214
- seq_complete: true,
1215
- clear_resolve: true,
1216
- defaults: defaults,
1217
- ops: ops
1218
- }; // resume and change jobId status from 'STOPPED' to 'IN_PROGRESS'
1219
- responses = [];
1220
- this.Log("Stopped or Failed job IDs: ".concat(stoppedOrFailedJobIds.join(",")));
1221
- _iterator3 = _createForOfIteratorHelper(stoppedOrFailedJobIds);
1222
- _context19.prev = 12;
1223
- _iterator3.s();
1224
- case 14:
1225
- if ((_step3 = _iterator3.n()).done) {
1226
- _context19.next = 30;
1227
- break;
1228
- }
1229
- jobId = _step3.value;
1230
- path = UrlJoin("q", writeToken, "file_jobs", jobId, "resume");
1231
- _context19.t0 = this.HttpClient;
1232
- _context19.next = 20;
1233
- return this.authClient.AuthorizationHeader({
1234
- libraryId: libraryId,
1235
- objectId: objectId,
1236
- update: true,
1237
- encryption: encryption
1238
- });
1239
- case 20:
1240
- _context19.t1 = _context19.sent;
1241
- _context19.t2 = path;
1242
- _context19.t3 = body;
1243
- _context19.t4 = {
1244
- headers: _context19.t1,
1245
- method: "PUT",
1246
- path: _context19.t2,
1247
- body: _context19.t3,
1248
- allowFailover: false
1249
- };
1250
- _context19.next = 26;
1251
- return _context19.t0.RequestJsonBody.call(_context19.t0, _context19.t4);
1252
- case 26:
1253
- res = _context19.sent;
1254
- responses.push({
1255
- message: res,
1256
- id: jobId
1257
- });
1258
- case 28:
1259
- _context19.next = 14;
1260
- break;
1261
- case 30:
1262
- _context19.next = 35;
1263
- break;
1264
- case 32:
1265
- _context19.prev = 32;
1266
- _context19.t5 = _context19["catch"](12);
1267
- _iterator3.e(_context19.t5);
1268
- case 35:
1269
- _context19.prev = 35;
1270
- _iterator3.f();
1271
- return _context19.finish(35);
1272
- case 38:
1273
- return _context19.abrupt("return", responses);
1274
- case 39:
1275
- case "end":
1276
- return _context19.stop();
727
+ return _context8.stop();
1277
728
  }
1278
- }, _callee17, this, [[12, 32, 35, 38]]);
729
+ }, _callee7, this);
1279
730
  }));
1280
- return function (_x18) {
1281
- return _ref30.apply(this, arguments);
731
+ return function (_x8) {
732
+ return _ref11.apply(this, arguments);
1282
733
  };
1283
734
  }();
1284
735
  exports.UploadStatus = /*#__PURE__*/function () {
1285
- var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref31) {
736
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
1286
737
  var libraryId, objectId, writeToken, uploadId, path;
1287
- return _regeneratorRuntime.wrap(function _callee18$(_context20) {
1288
- while (1) switch (_context20.prev = _context20.next) {
738
+ return _regeneratorRuntime.wrap(function _callee8$(_context9) {
739
+ while (1) switch (_context9.prev = _context9.next) {
1289
740
  case 0:
1290
- libraryId = _ref31.libraryId, objectId = _ref31.objectId, writeToken = _ref31.writeToken, uploadId = _ref31.uploadId;
741
+ libraryId = _ref12.libraryId, objectId = _ref12.objectId, writeToken = _ref12.writeToken, uploadId = _ref12.uploadId;
1291
742
  ValidateParameters({
1292
743
  libraryId: libraryId,
1293
744
  objectId: objectId
1294
745
  });
1295
746
  ValidateWriteToken(writeToken);
1296
747
  path = UrlJoin("q", writeToken, "file_jobs", uploadId);
1297
- _context20.t0 = this.utils;
1298
- _context20.t1 = this.HttpClient;
1299
- _context20.next = 8;
748
+ _context9.t0 = this.utils;
749
+ _context9.t1 = this.HttpClient;
750
+ _context9.next = 8;
1300
751
  return this.authClient.AuthorizationHeader({
1301
752
  libraryId: libraryId,
1302
753
  objectId: objectId,
1303
754
  update: true
1304
755
  });
1305
756
  case 8:
1306
- _context20.t2 = _context20.sent;
1307
- _context20.t3 = path;
1308
- _context20.t4 = {
1309
- headers: _context20.t2,
757
+ _context9.t2 = _context9.sent;
758
+ _context9.t3 = path;
759
+ _context9.t4 = {
760
+ headers: _context9.t2,
1310
761
  method: "GET",
1311
- path: _context20.t3,
762
+ path: _context9.t3,
1312
763
  allowFailover: false
1313
764
  };
1314
- _context20.t5 = _context20.t1.Request.call(_context20.t1, _context20.t4);
1315
- return _context20.abrupt("return", _context20.t0.ResponseToJson.call(_context20.t0, _context20.t5));
765
+ _context9.t5 = _context9.t1.Request.call(_context9.t1, _context9.t4);
766
+ return _context9.abrupt("return", _context9.t0.ResponseToJson.call(_context9.t0, _context9.t5));
1316
767
  case 13:
1317
768
  case "end":
1318
- return _context20.stop();
769
+ return _context9.stop();
1319
770
  }
1320
- }, _callee18, this);
771
+ }, _callee8, this);
1321
772
  }));
1322
- return function (_x19) {
1323
- return _ref32.apply(this, arguments);
773
+ return function (_x9) {
774
+ return _ref13.apply(this, arguments);
1324
775
  };
1325
776
  }();
1326
777
  exports.UploadJobStatus = /*#__PURE__*/function () {
1327
- var _ref34 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref33) {
778
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref14) {
1328
779
  var libraryId, objectId, writeToken, uploadId, jobId, path, response, newResponse;
1329
- return _regeneratorRuntime.wrap(function _callee19$(_context21) {
1330
- while (1) switch (_context21.prev = _context21.next) {
780
+ return _regeneratorRuntime.wrap(function _callee9$(_context10) {
781
+ while (1) switch (_context10.prev = _context10.next) {
1331
782
  case 0:
1332
- libraryId = _ref33.libraryId, objectId = _ref33.objectId, writeToken = _ref33.writeToken, uploadId = _ref33.uploadId, jobId = _ref33.jobId;
783
+ libraryId = _ref14.libraryId, objectId = _ref14.objectId, writeToken = _ref14.writeToken, uploadId = _ref14.uploadId, jobId = _ref14.jobId;
1333
784
  ValidateParameters({
1334
785
  libraryId: libraryId,
1335
786
  objectId: objectId
1336
787
  });
1337
788
  ValidateWriteToken(writeToken);
1338
789
  path = UrlJoin("q", writeToken, "file_jobs", uploadId, "uploads", jobId);
1339
- _context21.t0 = this.utils;
1340
- _context21.t1 = this.HttpClient;
1341
- _context21.next = 8;
790
+ _context10.t0 = this.utils;
791
+ _context10.t1 = this.HttpClient;
792
+ _context10.next = 8;
1342
793
  return this.authClient.AuthorizationHeader({
1343
794
  libraryId: libraryId,
1344
795
  objectId: objectId,
1345
796
  update: true
1346
797
  });
1347
798
  case 8:
1348
- _context21.t2 = _context21.sent;
1349
- _context21.t3 = path;
1350
- _context21.t4 = {
799
+ _context10.t2 = _context10.sent;
800
+ _context10.t3 = path;
801
+ _context10.t4 = {
1351
802
  start: 0,
1352
803
  limit: 10000
1353
804
  };
1354
- _context21.t5 = {
1355
- headers: _context21.t2,
805
+ _context10.t5 = {
806
+ headers: _context10.t2,
1356
807
  method: "GET",
1357
- path: _context21.t3,
808
+ path: _context10.t3,
1358
809
  allowFailover: false,
1359
- queryParams: _context21.t4
810
+ queryParams: _context10.t4
1360
811
  };
1361
- _context21.t6 = _context21.t1.Request.call(_context21.t1, _context21.t5);
1362
- _context21.next = 15;
1363
- return _context21.t0.ResponseToJson.call(_context21.t0, _context21.t6);
812
+ _context10.t6 = _context10.t1.Request.call(_context10.t1, _context10.t5);
813
+ _context10.next = 15;
814
+ return _context10.t0.ResponseToJson.call(_context10.t0, _context10.t6);
1364
815
  case 15:
1365
- response = _context21.sent;
816
+ response = _context10.sent;
1366
817
  case 16:
1367
818
  if (!(response.next !== response.total && response.next >= 0)) {
1368
- _context21.next = 33;
819
+ _context10.next = 33;
1369
820
  break;
1370
821
  }
1371
- _context21.t7 = this.utils;
1372
- _context21.t8 = this.HttpClient;
1373
- _context21.next = 21;
822
+ _context10.t7 = this.utils;
823
+ _context10.t8 = this.HttpClient;
824
+ _context10.next = 21;
1374
825
  return this.authClient.AuthorizationHeader({
1375
826
  libraryId: libraryId,
1376
827
  objectId: objectId,
1377
828
  update: true
1378
829
  });
1379
830
  case 21:
1380
- _context21.t9 = _context21.sent;
1381
- _context21.t10 = path;
1382
- _context21.t11 = {
831
+ _context10.t9 = _context10.sent;
832
+ _context10.t10 = path;
833
+ _context10.t11 = {
1383
834
  start: response.next
1384
835
  };
1385
- _context21.t12 = {
1386
- headers: _context21.t9,
836
+ _context10.t12 = {
837
+ headers: _context10.t9,
1387
838
  method: "GET",
1388
- path: _context21.t10,
839
+ path: _context10.t10,
1389
840
  allowFailover: false,
1390
- queryParams: _context21.t11
841
+ queryParams: _context10.t11
1391
842
  };
1392
- _context21.t13 = _context21.t8.Request.call(_context21.t8, _context21.t12);
1393
- _context21.next = 28;
1394
- return _context21.t7.ResponseToJson.call(_context21.t7, _context21.t13);
843
+ _context10.t13 = _context10.t8.Request.call(_context10.t8, _context10.t12);
844
+ _context10.next = 28;
845
+ return _context10.t7.ResponseToJson.call(_context10.t7, _context10.t13);
1395
846
  case 28:
1396
- newResponse = _context21.sent;
847
+ newResponse = _context10.sent;
1397
848
  response.files = [].concat(_toConsumableArray(response.files), _toConsumableArray(newResponse.files));
1398
849
  response.next = newResponse.next;
1399
- _context21.next = 16;
850
+ _context10.next = 16;
1400
851
  break;
1401
852
  case 33:
1402
- return _context21.abrupt("return", response);
853
+ return _context10.abrupt("return", response);
1403
854
  case 34:
1404
855
  case "end":
1405
- return _context21.stop();
856
+ return _context10.stop();
1406
857
  }
1407
- }, _callee19, this);
858
+ }, _callee9, this);
1408
859
  }));
1409
- return function (_x20) {
1410
- return _ref34.apply(this, arguments);
860
+ return function (_x10) {
861
+ return _ref15.apply(this, arguments);
1411
862
  };
1412
863
  }();
1413
864
  exports.UploadFileData = /*#__PURE__*/function () {
1414
- var _ref36 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref35) {
1415
- var libraryId, objectId, writeToken, encryption, uploadId, jobId, filePath, fileData, jobStatus, fileStatus, path, response;
1416
- return _regeneratorRuntime.wrap(function _callee20$(_context22) {
1417
- while (1) switch (_context22.prev = _context22.next) {
865
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref16) {
866
+ var libraryId, objectId, writeToken, encryption, uploadId, jobId, filePath, fileData, jobStatus, fileStatus, path;
867
+ return _regeneratorRuntime.wrap(function _callee10$(_context11) {
868
+ while (1) switch (_context11.prev = _context11.next) {
1418
869
  case 0:
1419
- libraryId = _ref35.libraryId, objectId = _ref35.objectId, writeToken = _ref35.writeToken, encryption = _ref35.encryption, uploadId = _ref35.uploadId, jobId = _ref35.jobId, filePath = _ref35.filePath, fileData = _ref35.fileData;
870
+ libraryId = _ref16.libraryId, objectId = _ref16.objectId, writeToken = _ref16.writeToken, encryption = _ref16.encryption, uploadId = _ref16.uploadId, jobId = _ref16.jobId, filePath = _ref16.filePath, fileData = _ref16.fileData;
1420
871
  ValidateParameters({
1421
872
  libraryId: libraryId,
1422
873
  objectId: objectId
1423
874
  });
1424
875
  ValidateWriteToken(writeToken);
1425
- _context22.next = 5;
876
+ _context11.next = 5;
1426
877
  return this.UploadJobStatus({
1427
878
  libraryId: libraryId,
1428
879
  objectId: objectId,
@@ -1431,7 +882,7 @@ exports.UploadFileData = /*#__PURE__*/function () {
1431
882
  jobId: jobId
1432
883
  });
1433
884
  case 5:
1434
- jobStatus = _context22.sent;
885
+ jobStatus = _context11.sent;
1435
886
  // Find the status of this file
1436
887
  fileStatus = jobStatus.files.find(function (item) {
1437
888
  return item.path === filePath;
@@ -1440,71 +891,64 @@ exports.UploadFileData = /*#__PURE__*/function () {
1440
891
  fileStatus = fileStatus.encrypted;
1441
892
  }
1442
893
  if (!(fileStatus.rem === 0)) {
1443
- _context22.next = 12;
894
+ _context11.next = 12;
1444
895
  break;
1445
896
  }
1446
- return _context22.abrupt("return");
897
+ return _context11.abrupt("return");
1447
898
  case 12:
1448
899
  if (fileStatus.skip) {
1449
900
  fileData = fileData.slice(fileStatus.skip);
1450
901
  }
1451
902
  case 13:
1452
903
  path = UrlJoin("q", writeToken, "file_jobs", uploadId, jobId);
1453
- _context22.t0 = this.utils;
1454
- _context22.t1 = this.HttpClient;
1455
- _context22.t2 = path;
1456
- _context22.t3 = fileData;
1457
- _context22.t4 = _objectSpread;
1458
- _context22.t5 = {
904
+ _context11.t0 = this.utils;
905
+ _context11.t1 = this.HttpClient;
906
+ _context11.t2 = path;
907
+ _context11.t3 = fileData;
908
+ _context11.t4 = _objectSpread;
909
+ _context11.t5 = {
1459
910
  "Content-type": "application/octet-stream"
1460
911
  };
1461
- _context22.next = 22;
912
+ _context11.next = 22;
1462
913
  return this.authClient.AuthorizationHeader({
1463
914
  libraryId: libraryId,
1464
915
  objectId: objectId,
1465
916
  update: true
1466
917
  });
1467
918
  case 22:
1468
- _context22.t6 = _context22.sent;
1469
- _context22.t7 = (0, _context22.t4)(_context22.t5, _context22.t6);
1470
- _context22.t8 = {
919
+ _context11.t6 = _context11.sent;
920
+ _context11.t7 = (0, _context11.t4)(_context11.t5, _context11.t6);
921
+ _context11.t8 = {
1471
922
  method: "POST",
1472
- path: _context22.t2,
1473
- body: _context22.t3,
923
+ path: _context11.t2,
924
+ body: _context11.t3,
1474
925
  bodyType: "BINARY",
1475
- headers: _context22.t7,
926
+ headers: _context11.t7,
1476
927
  allowFailover: false,
1477
928
  allowRetry: false
1478
929
  };
1479
- _context22.t9 = _context22.t1.Request.call(_context22.t1, _context22.t8);
1480
- _context22.next = 28;
1481
- return _context22.t0.ResponseToJson.call(_context22.t0, _context22.t9);
930
+ _context11.t9 = _context11.t1.Request.call(_context11.t1, _context11.t8);
931
+ _context11.next = 28;
932
+ return _context11.t0.ResponseToJson.call(_context11.t0, _context11.t9);
1482
933
  case 28:
1483
- response = _context22.sent;
1484
- if (!(response && response.part && !response.part.hash)) {
1485
- _context22.next = 31;
1486
- break;
1487
- }
1488
- throw new Error("Upload did not finalize part for ".concat(filePath, " (job ").concat(jobId, ")"));
1489
- case 31:
1490
- return _context22.abrupt("return", response);
1491
- case 32:
934
+ return _context11.abrupt("return", _context11.sent);
935
+ case 29:
1492
936
  case "end":
1493
- return _context22.stop();
937
+ return _context11.stop();
1494
938
  }
1495
- }, _callee20, this);
939
+ }, _callee10, this);
1496
940
  }));
1497
- return function (_x21) {
1498
- return _ref36.apply(this, arguments);
941
+ return function (_x11) {
942
+ return _ref17.apply(this, arguments);
1499
943
  };
1500
944
  }();
1501
945
  exports.FinalizeUploadJob = /*#__PURE__*/function () {
1502
- var _ref38 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref37) {
946
+ var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref18) {
1503
947
  var libraryId, objectId, writeToken, path;
1504
- return _regeneratorRuntime.wrap(function _callee21$(_context23) {
1505
- while (1) switch (_context23.prev = _context23.next) {
948
+ return _regeneratorRuntime.wrap(function _callee11$(_context12) {
949
+ while (1) switch (_context12.prev = _context12.next) {
1506
950
  case 0:
1507
- libraryId = _ref37.libraryId, objectId = _ref37.objectId, writeToken = _ref37.writeToken;
951
+ libraryId = _ref18.libraryId, objectId = _ref18.objectId, writeToken = _ref18.writeToken;
1508
952
  ValidateParameters({
1509
953
  libraryId: libraryId,
1510
954
  objectId: objectId
@@ -1512,33 +956,33 @@ exports.FinalizeUploadJob = /*#__PURE__*/function () {
1512
956
  ValidateWriteToken(writeToken);
1513
957
  this.Log("Finalizing upload job: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
1514
958
  path = UrlJoin("q", writeToken, "files");
1515
- _context23.t0 = this.HttpClient;
1516
- _context23.t1 = path;
1517
- _context23.next = 9;
959
+ _context12.t0 = this.HttpClient;
960
+ _context12.t1 = path;
961
+ _context12.next = 9;
1518
962
  return this.authClient.AuthorizationHeader({
1519
963
  libraryId: libraryId,
1520
964
  objectId: objectId,
1521
965
  update: true
1522
966
  });
1523
967
  case 9:
1524
- _context23.t2 = _context23.sent;
1525
- _context23.t3 = {
968
+ _context12.t2 = _context12.sent;
969
+ _context12.t3 = {
1526
970
  method: "POST",
1527
- path: _context23.t1,
971
+ path: _context12.t1,
1528
972
  bodyType: "BINARY",
1529
- headers: _context23.t2,
973
+ headers: _context12.t2,
1530
974
  allowFailover: false
1531
975
  };
1532
- _context23.next = 13;
1533
- return _context23.t0.Request.call(_context23.t0, _context23.t3);
976
+ _context12.next = 13;
977
+ return _context12.t0.Request.call(_context12.t0, _context12.t3);
1534
978
  case 13:
1535
979
  case "end":
1536
- return _context23.stop();
980
+ return _context12.stop();
1537
981
  }
1538
- }, _callee21, this);
982
+ }, _callee11, this);
1539
983
  }));
1540
- return function (_x22) {
1541
- return _ref38.apply(this, arguments);
984
+ return function (_x12) {
985
+ return _ref19.apply(this, arguments);
1542
986
  };
1543
987
  }();
1544
988
 
@@ -1554,12 +998,12 @@ exports.FinalizeUploadJob = /*#__PURE__*/function () {
1554
998
  * @param {Array<string>} filePaths - List of file paths to create
1555
999
  */
1556
1000
  exports.CreateFileDirectories = /*#__PURE__*/function () {
1557
- var _ref40 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref39) {
1001
+ var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref20) {
1558
1002
  var libraryId, objectId, writeToken, filePaths, ops;
1559
- return _regeneratorRuntime.wrap(function _callee22$(_context24) {
1560
- while (1) switch (_context24.prev = _context24.next) {
1003
+ return _regeneratorRuntime.wrap(function _callee12$(_context13) {
1004
+ while (1) switch (_context13.prev = _context13.next) {
1561
1005
  case 0:
1562
- libraryId = _ref39.libraryId, objectId = _ref39.objectId, writeToken = _ref39.writeToken, filePaths = _ref39.filePaths;
1006
+ libraryId = _ref20.libraryId, objectId = _ref20.objectId, writeToken = _ref20.writeToken, filePaths = _ref20.filePaths;
1563
1007
  ValidateParameters({
1564
1008
  libraryId: libraryId,
1565
1009
  objectId: objectId
@@ -1574,7 +1018,7 @@ exports.CreateFileDirectories = /*#__PURE__*/function () {
1574
1018
  path: path
1575
1019
  };
1576
1020
  });
1577
- _context24.next = 8;
1021
+ _context13.next = 8;
1578
1022
  return this.CreateFileUploadJob({
1579
1023
  libraryId: libraryId,
1580
1024
  objectId: objectId,
@@ -1583,12 +1027,12 @@ exports.CreateFileDirectories = /*#__PURE__*/function () {
1583
1027
  });
1584
1028
  case 8:
1585
1029
  case "end":
1586
- return _context24.stop();
1030
+ return _context13.stop();
1587
1031
  }
1588
- }, _callee22, this);
1032
+ }, _callee12, this);
1589
1033
  }));
1590
- return function (_x23) {
1591
- return _ref40.apply(this, arguments);
1034
+ return function (_x13) {
1035
+ return _ref21.apply(this, arguments);
1592
1036
  };
1593
1037
  }();
1594
1038
 
@@ -1604,12 +1048,12 @@ exports.CreateFileDirectories = /*#__PURE__*/function () {
1604
1048
  * @param {Array<string>} filePaths - List of file paths to move. Format: ```[ { "path": "original/path", to: "new/path" } ]```
1605
1049
  */
1606
1050
  exports.MoveFiles = /*#__PURE__*/function () {
1607
- var _ref42 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref41) {
1051
+ var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref22) {
1608
1052
  var libraryId, objectId, writeToken, filePaths, ops;
1609
- return _regeneratorRuntime.wrap(function _callee23$(_context25) {
1610
- while (1) switch (_context25.prev = _context25.next) {
1053
+ return _regeneratorRuntime.wrap(function _callee13$(_context14) {
1054
+ while (1) switch (_context14.prev = _context14.next) {
1611
1055
  case 0:
1612
- libraryId = _ref41.libraryId, objectId = _ref41.objectId, writeToken = _ref41.writeToken, filePaths = _ref41.filePaths;
1056
+ libraryId = _ref22.libraryId, objectId = _ref22.objectId, writeToken = _ref22.writeToken, filePaths = _ref22.filePaths;
1613
1057
  ValidateParameters({
1614
1058
  libraryId: libraryId,
1615
1059
  objectId: objectId
@@ -1617,16 +1061,16 @@ exports.MoveFiles = /*#__PURE__*/function () {
1617
1061
  ValidateWriteToken(writeToken);
1618
1062
  this.Log("Moving Files: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
1619
1063
  this.Log(filePaths);
1620
- ops = filePaths.map(function (_ref43) {
1621
- var path = _ref43.path,
1622
- to = _ref43.to;
1064
+ ops = filePaths.map(function (_ref24) {
1065
+ var path = _ref24.path,
1066
+ to = _ref24.to;
1623
1067
  return {
1624
1068
  op: "move",
1625
1069
  copy_move_source_path: path,
1626
1070
  path: to
1627
1071
  };
1628
1072
  });
1629
- _context25.next = 8;
1073
+ _context14.next = 8;
1630
1074
  return this.CreateFileUploadJob({
1631
1075
  libraryId: libraryId,
1632
1076
  objectId: objectId,
@@ -1635,12 +1079,12 @@ exports.MoveFiles = /*#__PURE__*/function () {
1635
1079
  });
1636
1080
  case 8:
1637
1081
  case "end":
1638
- return _context25.stop();
1082
+ return _context14.stop();
1639
1083
  }
1640
- }, _callee23, this);
1084
+ }, _callee13, this);
1641
1085
  }));
1642
- return function (_x24) {
1643
- return _ref42.apply(this, arguments);
1086
+ return function (_x14) {
1087
+ return _ref23.apply(this, arguments);
1644
1088
  };
1645
1089
  }();
1646
1090
 
@@ -1656,12 +1100,12 @@ exports.MoveFiles = /*#__PURE__*/function () {
1656
1100
  * @param {Array<string>} filePaths - List of file paths to delete
1657
1101
  */
1658
1102
  exports.DeleteFiles = /*#__PURE__*/function () {
1659
- var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref44) {
1103
+ var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref25) {
1660
1104
  var libraryId, objectId, writeToken, filePaths, ops;
1661
- return _regeneratorRuntime.wrap(function _callee24$(_context26) {
1662
- while (1) switch (_context26.prev = _context26.next) {
1105
+ return _regeneratorRuntime.wrap(function _callee14$(_context15) {
1106
+ while (1) switch (_context15.prev = _context15.next) {
1663
1107
  case 0:
1664
- libraryId = _ref44.libraryId, objectId = _ref44.objectId, writeToken = _ref44.writeToken, filePaths = _ref44.filePaths;
1108
+ libraryId = _ref25.libraryId, objectId = _ref25.objectId, writeToken = _ref25.writeToken, filePaths = _ref25.filePaths;
1665
1109
  ValidateParameters({
1666
1110
  libraryId: libraryId,
1667
1111
  objectId: objectId
@@ -1675,7 +1119,7 @@ exports.DeleteFiles = /*#__PURE__*/function () {
1675
1119
  path: path
1676
1120
  };
1677
1121
  });
1678
- _context26.next = 8;
1122
+ _context15.next = 8;
1679
1123
  return this.CreateFileUploadJob({
1680
1124
  libraryId: libraryId,
1681
1125
  objectId: objectId,
@@ -1684,12 +1128,12 @@ exports.DeleteFiles = /*#__PURE__*/function () {
1684
1128
  });
1685
1129
  case 8:
1686
1130
  case "end":
1687
- return _context26.stop();
1131
+ return _context15.stop();
1688
1132
  }
1689
- }, _callee24, this);
1133
+ }, _callee14, this);
1690
1134
  }));
1691
- return function (_x25) {
1692
- return _ref45.apply(this, arguments);
1135
+ return function (_x15) {
1136
+ return _ref26.apply(this, arguments);
1693
1137
  };
1694
1138
  }();
1695
1139
 
@@ -1718,18 +1162,18 @@ exports.DeleteFiles = /*#__PURE__*/function () {
1718
1162
  * @returns {Promise<ArrayBuffer> | undefined} - No return if chunked is specified, file data in the requested format otherwise
1719
1163
  */
1720
1164
  exports.DownloadFile = /*#__PURE__*/function () {
1721
- var _ref47 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref46) {
1165
+ var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref27) {
1722
1166
  var libraryId,
1723
1167
  objectId,
1724
1168
  versionHash,
1725
1169
  writeToken,
1726
1170
  filePath,
1727
- _ref46$format,
1171
+ _ref27$format,
1728
1172
  format,
1729
- _ref46$chunked,
1173
+ _ref27$chunked,
1730
1174
  chunked,
1731
1175
  chunkSize,
1732
- _ref46$clientSideDecr,
1176
+ _ref27$clientSideDecr,
1733
1177
  clientSideDecryption,
1734
1178
  callback,
1735
1179
  fileInfo,
@@ -1740,11 +1184,11 @@ exports.DownloadFile = /*#__PURE__*/function () {
1740
1184
  ownerCapKey,
1741
1185
  ownerCap,
1742
1186
  bytesTotal,
1743
- _args27 = arguments;
1744
- return _regeneratorRuntime.wrap(function _callee25$(_context27) {
1745
- while (1) switch (_context27.prev = _context27.next) {
1187
+ _args16 = arguments;
1188
+ return _regeneratorRuntime.wrap(function _callee15$(_context16) {
1189
+ while (1) switch (_context16.prev = _context16.next) {
1746
1190
  case 0:
1747
- libraryId = _ref46.libraryId, objectId = _ref46.objectId, versionHash = _ref46.versionHash, writeToken = _ref46.writeToken, filePath = _ref46.filePath, _ref46$format = _ref46.format, format = _ref46$format === void 0 ? "arrayBuffer" : _ref46$format, _ref46$chunked = _ref46.chunked, chunked = _ref46$chunked === void 0 ? false : _ref46$chunked, chunkSize = _ref46.chunkSize, _ref46$clientSideDecr = _ref46.clientSideDecryption, clientSideDecryption = _ref46$clientSideDecr === void 0 ? false : _ref46$clientSideDecr, callback = _ref46.callback;
1191
+ libraryId = _ref27.libraryId, objectId = _ref27.objectId, versionHash = _ref27.versionHash, writeToken = _ref27.writeToken, filePath = _ref27.filePath, _ref27$format = _ref27.format, format = _ref27$format === void 0 ? "arrayBuffer" : _ref27$format, _ref27$chunked = _ref27.chunked, chunked = _ref27$chunked === void 0 ? false : _ref27$chunked, chunkSize = _ref27.chunkSize, _ref27$clientSideDecr = _ref27.clientSideDecryption, clientSideDecryption = _ref27$clientSideDecr === void 0 ? false : _ref27$clientSideDecr, callback = _ref27.callback;
1748
1192
  ValidateParameters({
1749
1193
  libraryId: libraryId,
1750
1194
  objectId: objectId,
@@ -1754,7 +1198,7 @@ exports.DownloadFile = /*#__PURE__*/function () {
1754
1198
  if (versionHash) {
1755
1199
  objectId = this.utils.DecodeVersionHash(versionHash).objectId;
1756
1200
  }
1757
- _context27.next = 6;
1201
+ _context16.next = 6;
1758
1202
  return this.ContentObjectMetadata({
1759
1203
  libraryId: libraryId,
1760
1204
  objectId: objectId,
@@ -1763,11 +1207,11 @@ exports.DownloadFile = /*#__PURE__*/function () {
1763
1207
  metadataSubtree: UrlJoin("files", filePath)
1764
1208
  });
1765
1209
  case 6:
1766
- fileInfo = _context27.sent;
1210
+ fileInfo = _context16.sent;
1767
1211
  encrypted = fileInfo && fileInfo["."].encryption && fileInfo["."].encryption.scheme === "cgck";
1768
1212
  encryption = encrypted ? "cgck" : undefined;
1769
1213
  path = encrypted && !clientSideDecryption ? UrlJoin("q", writeToken || versionHash || objectId, "rep", "files_download", filePath) : UrlJoin("q", writeToken || versionHash || objectId, "files", filePath);
1770
- _context27.next = 12;
1214
+ _context16.next = 12;
1771
1215
  return this.authClient.AuthorizationHeader({
1772
1216
  libraryId: libraryId,
1773
1217
  objectId: objectId,
@@ -1776,12 +1220,12 @@ exports.DownloadFile = /*#__PURE__*/function () {
1776
1220
  makeAccessRequest: encryption === "cgck"
1777
1221
  });
1778
1222
  case 12:
1779
- headers = _context27.sent;
1223
+ headers = _context16.sent;
1780
1224
  headers.Accept = "*/*";
1781
1225
 
1782
1226
  // If not owner, indicate re-encryption
1783
1227
  ownerCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
1784
- _context27.next = 17;
1228
+ _context16.next = 17;
1785
1229
  return this.ContentObjectMetadata({
1786
1230
  libraryId: libraryId,
1787
1231
  objectId: objectId,
@@ -1789,31 +1233,31 @@ exports.DownloadFile = /*#__PURE__*/function () {
1789
1233
  metadataSubtree: ownerCapKey
1790
1234
  });
1791
1235
  case 17:
1792
- ownerCap = _context27.sent;
1793
- _context27.t1 = encrypted;
1794
- if (!_context27.t1) {
1795
- _context27.next = 26;
1236
+ ownerCap = _context16.sent;
1237
+ _context16.t1 = encrypted;
1238
+ if (!_context16.t1) {
1239
+ _context16.next = 26;
1796
1240
  break;
1797
1241
  }
1798
- _context27.t2 = this.utils;
1799
- _context27.t3 = this.signer.address;
1800
- _context27.next = 24;
1242
+ _context16.t2 = this.utils;
1243
+ _context16.t3 = this.signer.address;
1244
+ _context16.next = 24;
1801
1245
  return this.ContentObjectOwner({
1802
1246
  objectId: objectId
1803
1247
  });
1804
1248
  case 24:
1805
- _context27.t4 = _context27.sent;
1806
- _context27.t1 = !_context27.t2.EqualAddress.call(_context27.t2, _context27.t3, _context27.t4);
1249
+ _context16.t4 = _context16.sent;
1250
+ _context16.t1 = !_context16.t2.EqualAddress.call(_context16.t2, _context16.t3, _context16.t4);
1807
1251
  case 26:
1808
- _context27.t0 = _context27.t1;
1809
- if (!_context27.t0) {
1810
- _context27.next = 29;
1252
+ _context16.t0 = _context16.t1;
1253
+ if (!_context16.t0) {
1254
+ _context16.next = 29;
1811
1255
  break;
1812
1256
  }
1813
- _context27.t0 = !ownerCap;
1257
+ _context16.t0 = !ownerCap;
1814
1258
  case 29:
1815
- if (!_context27.t0) {
1816
- _context27.next = 31;
1259
+ if (!_context16.t0) {
1260
+ _context16.next = 31;
1817
1261
  break;
1818
1262
  }
1819
1263
  headers["X-Content-Fabric-Decryption-Mode"] = "reencrypt";
@@ -1826,11 +1270,11 @@ exports.DownloadFile = /*#__PURE__*/function () {
1826
1270
  }
1827
1271
  bytesTotal = fileInfo["."].size;
1828
1272
  if (!(encrypted && clientSideDecryption)) {
1829
- _context27.next = 51;
1273
+ _context16.next = 51;
1830
1274
  break;
1831
1275
  }
1832
- _context27.t5 = this;
1833
- _context27.next = 37;
1276
+ _context16.t5 = this;
1277
+ _context16.next = 37;
1834
1278
  return this.EncryptionConk({
1835
1279
  libraryId: libraryId,
1836
1280
  objectId: objectId,
@@ -1838,34 +1282,34 @@ exports.DownloadFile = /*#__PURE__*/function () {
1838
1282
  download: true
1839
1283
  });
1840
1284
  case 37:
1841
- _context27.t6 = _context27.sent;
1842
- _context27.t7 = path;
1843
- _context27.t8 = bytesTotal;
1844
- _context27.t9 = headers;
1845
- _context27.t10 = callback;
1846
- _context27.t11 = format;
1847
- _context27.t12 = clientSideDecryption;
1848
- _context27.t13 = chunked;
1849
- _context27.t14 = {
1850
- conk: _context27.t6,
1851
- downloadPath: _context27.t7,
1852
- bytesTotal: _context27.t8,
1853
- headers: _context27.t9,
1854
- callback: _context27.t10,
1855
- format: _context27.t11,
1856
- clientSideDecryption: _context27.t12,
1857
- chunked: _context27.t13
1285
+ _context16.t6 = _context16.sent;
1286
+ _context16.t7 = path;
1287
+ _context16.t8 = bytesTotal;
1288
+ _context16.t9 = headers;
1289
+ _context16.t10 = callback;
1290
+ _context16.t11 = format;
1291
+ _context16.t12 = clientSideDecryption;
1292
+ _context16.t13 = chunked;
1293
+ _context16.t14 = {
1294
+ conk: _context16.t6,
1295
+ downloadPath: _context16.t7,
1296
+ bytesTotal: _context16.t8,
1297
+ headers: _context16.t9,
1298
+ callback: _context16.t10,
1299
+ format: _context16.t11,
1300
+ clientSideDecryption: _context16.t12,
1301
+ chunked: _context16.t13
1858
1302
  };
1859
- _context27.next = 48;
1860
- return _context27.t5.DownloadEncrypted.call(_context27.t5, _context27.t14);
1303
+ _context16.next = 48;
1304
+ return _context16.t5.DownloadEncrypted.call(_context16.t5, _context16.t14);
1861
1305
  case 48:
1862
- return _context27.abrupt("return", _context27.sent);
1306
+ return _context16.abrupt("return", _context16.sent);
1863
1307
  case 51:
1864
1308
  if (!chunkSize) {
1865
1309
  chunkSize = 10000000;
1866
1310
  }
1867
- _context27.prev = 52;
1868
- _context27.next = 55;
1311
+ _context16.prev = 52;
1312
+ _context16.next = 55;
1869
1313
  return this.Download({
1870
1314
  downloadPath: path,
1871
1315
  bytesTotal: bytesTotal,
@@ -1876,27 +1320,27 @@ exports.DownloadFile = /*#__PURE__*/function () {
1876
1320
  chunkSize: chunkSize
1877
1321
  });
1878
1322
  case 55:
1879
- return _context27.abrupt("return", _context27.sent);
1323
+ return _context16.abrupt("return", _context16.sent);
1880
1324
  case 58:
1881
- _context27.prev = 58;
1882
- _context27.t15 = _context27["catch"](52);
1325
+ _context16.prev = 58;
1326
+ _context16.t15 = _context16["catch"](52);
1883
1327
  if (!(encrypted && !clientSideDecryption)) {
1884
- _context27.next = 62;
1328
+ _context16.next = 62;
1885
1329
  break;
1886
1330
  }
1887
- return _context27.abrupt("return", this.DownloadFile(_objectSpread(_objectSpread({}, _args27[0]), {}, {
1331
+ return _context16.abrupt("return", this.DownloadFile(_objectSpread(_objectSpread({}, _args16[0]), {}, {
1888
1332
  clientSideDecryption: true
1889
1333
  })));
1890
1334
  case 62:
1891
- throw _context27.t15;
1335
+ throw _context16.t15;
1892
1336
  case 63:
1893
1337
  case "end":
1894
- return _context27.stop();
1338
+ return _context16.stop();
1895
1339
  }
1896
- }, _callee25, this, [[52, 58]]);
1340
+ }, _callee15, this, [[52, 58]]);
1897
1341
  }));
1898
- return function (_x26) {
1899
- return _ref47.apply(this, arguments);
1342
+ return function (_x16) {
1343
+ return _ref28.apply(this, arguments);
1900
1344
  };
1901
1345
  }();
1902
1346
 
@@ -1915,12 +1359,12 @@ exports.DownloadFile = /*#__PURE__*/function () {
1915
1359
  * @returns {Promise<Object>} - Response containing list of parts of the object
1916
1360
  */
1917
1361
  exports.ContentParts = /*#__PURE__*/function () {
1918
- var _ref49 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref48) {
1362
+ var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref29) {
1919
1363
  var libraryId, objectId, versionHash, path, response;
1920
- return _regeneratorRuntime.wrap(function _callee26$(_context28) {
1921
- while (1) switch (_context28.prev = _context28.next) {
1364
+ return _regeneratorRuntime.wrap(function _callee16$(_context17) {
1365
+ while (1) switch (_context17.prev = _context17.next) {
1922
1366
  case 0:
1923
- libraryId = _ref48.libraryId, objectId = _ref48.objectId, versionHash = _ref48.versionHash;
1367
+ libraryId = _ref29.libraryId, objectId = _ref29.objectId, versionHash = _ref29.versionHash;
1924
1368
  ValidateParameters({
1925
1369
  libraryId: libraryId,
1926
1370
  objectId: objectId,
@@ -1931,34 +1375,34 @@ exports.ContentParts = /*#__PURE__*/function () {
1931
1375
  objectId = this.utils.DecodeVersionHash(versionHash).objectId;
1932
1376
  }
1933
1377
  path = UrlJoin("q", versionHash || objectId, "parts");
1934
- _context28.t0 = this.HttpClient;
1935
- _context28.next = 8;
1378
+ _context17.t0 = this.HttpClient;
1379
+ _context17.next = 8;
1936
1380
  return this.authClient.AuthorizationHeader({
1937
1381
  libraryId: libraryId,
1938
1382
  objectId: objectId,
1939
1383
  versionHash: versionHash
1940
1384
  });
1941
1385
  case 8:
1942
- _context28.t1 = _context28.sent;
1943
- _context28.t2 = path;
1944
- _context28.t3 = {
1945
- headers: _context28.t1,
1386
+ _context17.t1 = _context17.sent;
1387
+ _context17.t2 = path;
1388
+ _context17.t3 = {
1389
+ headers: _context17.t1,
1946
1390
  method: "GET",
1947
- path: _context28.t2
1391
+ path: _context17.t2
1948
1392
  };
1949
- _context28.next = 13;
1950
- return _context28.t0.RequestJsonBody.call(_context28.t0, _context28.t3);
1393
+ _context17.next = 13;
1394
+ return _context17.t0.RequestJsonBody.call(_context17.t0, _context17.t3);
1951
1395
  case 13:
1952
- response = _context28.sent;
1953
- return _context28.abrupt("return", response.parts);
1396
+ response = _context17.sent;
1397
+ return _context17.abrupt("return", response.parts);
1954
1398
  case 15:
1955
1399
  case "end":
1956
- return _context28.stop();
1400
+ return _context17.stop();
1957
1401
  }
1958
- }, _callee26, this);
1402
+ }, _callee16, this);
1959
1403
  }));
1960
- return function (_x27) {
1961
- return _ref49.apply(this, arguments);
1404
+ return function (_x17) {
1405
+ return _ref30.apply(this, arguments);
1962
1406
  };
1963
1407
  }();
1964
1408
 
@@ -1976,12 +1420,12 @@ exports.ContentParts = /*#__PURE__*/function () {
1976
1420
  * @returns {Promise<Object>} - Response containing information about the specified part
1977
1421
  */
1978
1422
  exports.ContentPart = /*#__PURE__*/function () {
1979
- var _ref51 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(_ref50) {
1423
+ var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref31) {
1980
1424
  var libraryId, objectId, versionHash, partHash, path;
1981
- return _regeneratorRuntime.wrap(function _callee27$(_context29) {
1982
- while (1) switch (_context29.prev = _context29.next) {
1425
+ return _regeneratorRuntime.wrap(function _callee17$(_context18) {
1426
+ while (1) switch (_context18.prev = _context18.next) {
1983
1427
  case 0:
1984
- libraryId = _ref50.libraryId, objectId = _ref50.objectId, versionHash = _ref50.versionHash, partHash = _ref50.partHash;
1428
+ libraryId = _ref31.libraryId, objectId = _ref31.objectId, versionHash = _ref31.versionHash, partHash = _ref31.partHash;
1985
1429
  ValidateParameters({
1986
1430
  libraryId: libraryId,
1987
1431
  objectId: objectId,
@@ -1993,33 +1437,33 @@ exports.ContentPart = /*#__PURE__*/function () {
1993
1437
  objectId = this.utils.DecodeVersionHash(versionHash).objectId;
1994
1438
  }
1995
1439
  path = UrlJoin("q", versionHash || objectId, "parts", partHash);
1996
- _context29.t0 = this.HttpClient;
1997
- _context29.next = 9;
1440
+ _context18.t0 = this.HttpClient;
1441
+ _context18.next = 9;
1998
1442
  return this.authClient.AuthorizationHeader({
1999
1443
  libraryId: libraryId,
2000
1444
  objectId: objectId,
2001
1445
  versionHash: versionHash
2002
1446
  });
2003
1447
  case 9:
2004
- _context29.t1 = _context29.sent;
2005
- _context29.t2 = path;
2006
- _context29.t3 = {
2007
- headers: _context29.t1,
1448
+ _context18.t1 = _context18.sent;
1449
+ _context18.t2 = path;
1450
+ _context18.t3 = {
1451
+ headers: _context18.t1,
2008
1452
  method: "GET",
2009
- path: _context29.t2
1453
+ path: _context18.t2
2010
1454
  };
2011
- _context29.next = 14;
2012
- return _context29.t0.RequestJsonBody.call(_context29.t0, _context29.t3);
1455
+ _context18.next = 14;
1456
+ return _context18.t0.RequestJsonBody.call(_context18.t0, _context18.t3);
2013
1457
  case 14:
2014
- return _context29.abrupt("return", _context29.sent);
1458
+ return _context18.abrupt("return", _context18.sent);
2015
1459
  case 15:
2016
1460
  case "end":
2017
- return _context29.stop();
1461
+ return _context18.stop();
2018
1462
  }
2019
- }, _callee27, this);
1463
+ }, _callee17, this);
2020
1464
  }));
2021
- return function (_x28) {
2022
- return _ref51.apply(this, arguments);
1465
+ return function (_x18) {
1466
+ return _ref32.apply(this, arguments);
2023
1467
  };
2024
1468
  }();
2025
1469
 
@@ -2048,12 +1492,12 @@ exports.ContentPart = /*#__PURE__*/function () {
2048
1492
  * @returns {Promise<ArrayBuffer> | undefined} - No return if chunked is specified, part data in the requested format otherwise
2049
1493
  */
2050
1494
  exports.DownloadPart = /*#__PURE__*/function () {
2051
- var _ref53 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(_ref52) {
2052
- var libraryId, objectId, versionHash, writeToken, partHash, _ref52$format, format, _ref52$chunked, chunked, _ref52$chunkSize, chunkSize, callback, encrypted, encryption, path, headers, bytesTotal;
2053
- return _regeneratorRuntime.wrap(function _callee28$(_context30) {
2054
- while (1) switch (_context30.prev = _context30.next) {
1495
+ var _ref34 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref33) {
1496
+ var libraryId, objectId, versionHash, writeToken, partHash, _ref33$format, format, _ref33$chunked, chunked, _ref33$chunkSize, chunkSize, callback, encrypted, encryption, path, headers, bytesTotal;
1497
+ return _regeneratorRuntime.wrap(function _callee18$(_context19) {
1498
+ while (1) switch (_context19.prev = _context19.next) {
2055
1499
  case 0:
2056
- libraryId = _ref52.libraryId, objectId = _ref52.objectId, versionHash = _ref52.versionHash, writeToken = _ref52.writeToken, partHash = _ref52.partHash, _ref52$format = _ref52.format, format = _ref52$format === void 0 ? "arrayBuffer" : _ref52$format, _ref52$chunked = _ref52.chunked, chunked = _ref52$chunked === void 0 ? false : _ref52$chunked, _ref52$chunkSize = _ref52.chunkSize, chunkSize = _ref52$chunkSize === void 0 ? 10000000 : _ref52$chunkSize, callback = _ref52.callback;
1500
+ libraryId = _ref33.libraryId, objectId = _ref33.objectId, versionHash = _ref33.versionHash, writeToken = _ref33.writeToken, partHash = _ref33.partHash, _ref33$format = _ref33.format, format = _ref33$format === void 0 ? "arrayBuffer" : _ref33$format, _ref33$chunked = _ref33.chunked, chunked = _ref33$chunked === void 0 ? false : _ref33$chunked, _ref33$chunkSize = _ref33.chunkSize, chunkSize = _ref33$chunkSize === void 0 ? 10000000 : _ref33$chunkSize, callback = _ref33.callback;
2057
1501
  ValidateParameters({
2058
1502
  libraryId: libraryId,
2059
1503
  objectId: objectId,
@@ -2066,7 +1510,7 @@ exports.DownloadPart = /*#__PURE__*/function () {
2066
1510
  encrypted = partHash.startsWith("hqpe");
2067
1511
  encryption = encrypted ? "cgck" : undefined;
2068
1512
  path = UrlJoin("q", writeToken || versionHash || objectId, "data", partHash);
2069
- _context30.next = 9;
1513
+ _context19.next = 9;
2070
1514
  return this.authClient.AuthorizationHeader({
2071
1515
  libraryId: libraryId,
2072
1516
  objectId: objectId,
@@ -2075,8 +1519,8 @@ exports.DownloadPart = /*#__PURE__*/function () {
2075
1519
  makeAccessRequest: true
2076
1520
  });
2077
1521
  case 9:
2078
- headers = _context30.sent;
2079
- _context30.next = 12;
1522
+ headers = _context19.sent;
1523
+ _context19.next = 12;
2080
1524
  return this.ContentPart({
2081
1525
  libraryId: libraryId,
2082
1526
  objectId: objectId,
@@ -2084,55 +1528,55 @@ exports.DownloadPart = /*#__PURE__*/function () {
2084
1528
  partHash: partHash
2085
1529
  });
2086
1530
  case 12:
2087
- bytesTotal = _context30.sent.part.size;
1531
+ bytesTotal = _context19.sent.part.size;
2088
1532
  if (!encrypted) {
2089
- _context30.next = 37;
1533
+ _context19.next = 37;
2090
1534
  break;
2091
1535
  }
2092
- _context30.t0 = this.utils;
2093
- _context30.t1 = this.signer.address;
2094
- _context30.next = 18;
1536
+ _context19.t0 = this.utils;
1537
+ _context19.t1 = this.signer.address;
1538
+ _context19.next = 18;
2095
1539
  return this.ContentObjectOwner({
2096
1540
  objectId: objectId
2097
1541
  });
2098
1542
  case 18:
2099
- _context30.t2 = _context30.sent;
2100
- if (_context30.t0.EqualAddress.call(_context30.t0, _context30.t1, _context30.t2)) {
2101
- _context30.next = 21;
1543
+ _context19.t2 = _context19.sent;
1544
+ if (_context19.t0.EqualAddress.call(_context19.t0, _context19.t1, _context19.t2)) {
1545
+ _context19.next = 21;
2102
1546
  break;
2103
1547
  }
2104
1548
  headers["X-Content-Fabric-Decryption-Mode"] = "reencrypt";
2105
1549
  case 21:
2106
- _context30.t3 = this;
2107
- _context30.next = 24;
1550
+ _context19.t3 = this;
1551
+ _context19.next = 24;
2108
1552
  return this.EncryptionConk({
2109
1553
  libraryId: libraryId,
2110
1554
  objectId: objectId,
2111
1555
  download: true
2112
1556
  });
2113
1557
  case 24:
2114
- _context30.t4 = _context30.sent;
2115
- _context30.t5 = path;
2116
- _context30.t6 = bytesTotal;
2117
- _context30.t7 = headers;
2118
- _context30.t8 = callback;
2119
- _context30.t9 = format;
2120
- _context30.t10 = chunked;
2121
- _context30.t11 = {
2122
- conk: _context30.t4,
2123
- downloadPath: _context30.t5,
2124
- bytesTotal: _context30.t6,
2125
- headers: _context30.t7,
2126
- callback: _context30.t8,
2127
- format: _context30.t9,
2128
- chunked: _context30.t10
1558
+ _context19.t4 = _context19.sent;
1559
+ _context19.t5 = path;
1560
+ _context19.t6 = bytesTotal;
1561
+ _context19.t7 = headers;
1562
+ _context19.t8 = callback;
1563
+ _context19.t9 = format;
1564
+ _context19.t10 = chunked;
1565
+ _context19.t11 = {
1566
+ conk: _context19.t4,
1567
+ downloadPath: _context19.t5,
1568
+ bytesTotal: _context19.t6,
1569
+ headers: _context19.t7,
1570
+ callback: _context19.t8,
1571
+ format: _context19.t9,
1572
+ chunked: _context19.t10
2129
1573
  };
2130
- _context30.next = 34;
2131
- return _context30.t3.DownloadEncrypted.call(_context30.t3, _context30.t11);
1574
+ _context19.next = 34;
1575
+ return _context19.t3.DownloadEncrypted.call(_context19.t3, _context19.t11);
2132
1576
  case 34:
2133
- return _context30.abrupt("return", _context30.sent);
1577
+ return _context19.abrupt("return", _context19.sent);
2134
1578
  case 37:
2135
- _context30.next = 39;
1579
+ _context19.next = 39;
2136
1580
  return this.Download({
2137
1581
  downloadPath: path,
2138
1582
  bytesTotal: bytesTotal,
@@ -2143,26 +1587,26 @@ exports.DownloadPart = /*#__PURE__*/function () {
2143
1587
  chunkSize: chunkSize
2144
1588
  });
2145
1589
  case 39:
2146
- return _context30.abrupt("return", _context30.sent);
1590
+ return _context19.abrupt("return", _context19.sent);
2147
1591
  case 40:
2148
1592
  case "end":
2149
- return _context30.stop();
1593
+ return _context19.stop();
2150
1594
  }
2151
- }, _callee28, this);
1595
+ }, _callee18, this);
2152
1596
  }));
2153
- return function (_x29) {
2154
- return _ref53.apply(this, arguments);
1597
+ return function (_x19) {
1598
+ return _ref34.apply(this, arguments);
2155
1599
  };
2156
1600
  }();
2157
1601
  exports.Download = /*#__PURE__*/function () {
2158
- var _ref55 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(_ref54) {
2159
- var downloadPath, headers, bytesTotal, _ref54$chunked, chunked, _ref54$chunkSize, chunkSize, callback, _ref54$format, format, outputChunks, bytesFinished, totalChunks, i, response;
2160
- return _regeneratorRuntime.wrap(function _callee29$(_context31) {
2161
- while (1) switch (_context31.prev = _context31.next) {
1602
+ var _ref36 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref35) {
1603
+ var downloadPath, headers, bytesTotal, _ref35$chunked, chunked, _ref35$chunkSize, chunkSize, callback, _ref35$format, format, outputChunks, bytesFinished, totalChunks, i, response;
1604
+ return _regeneratorRuntime.wrap(function _callee19$(_context20) {
1605
+ while (1) switch (_context20.prev = _context20.next) {
2162
1606
  case 0:
2163
- downloadPath = _ref54.downloadPath, headers = _ref54.headers, bytesTotal = _ref54.bytesTotal, _ref54$chunked = _ref54.chunked, chunked = _ref54$chunked === void 0 ? false : _ref54$chunked, _ref54$chunkSize = _ref54.chunkSize, chunkSize = _ref54$chunkSize === void 0 ? 2000000 : _ref54$chunkSize, callback = _ref54.callback, _ref54$format = _ref54.format, format = _ref54$format === void 0 ? "arrayBuffer" : _ref54$format;
1607
+ downloadPath = _ref35.downloadPath, headers = _ref35.headers, bytesTotal = _ref35.bytesTotal, _ref35$chunked = _ref35.chunked, chunked = _ref35$chunked === void 0 ? false : _ref35$chunked, _ref35$chunkSize = _ref35.chunkSize, chunkSize = _ref35$chunkSize === void 0 ? 2000000 : _ref35$chunkSize, callback = _ref35.callback, _ref35$format = _ref35.format, format = _ref35$format === void 0 ? "arrayBuffer" : _ref35$format;
2164
1608
  if (!(chunked && !callback)) {
2165
- _context31.next = 3;
1609
+ _context20.next = 3;
2166
1610
  break;
2167
1611
  }
2168
1612
  throw Error("No callback specified for chunked download");
@@ -2177,47 +1621,47 @@ exports.Download = /*#__PURE__*/function () {
2177
1621
  i = 0;
2178
1622
  case 7:
2179
1623
  if (!(i < totalChunks)) {
2180
- _context31.next = 35;
1624
+ _context20.next = 35;
2181
1625
  break;
2182
1626
  }
2183
1627
  headers["Range"] = "bytes=".concat(bytesFinished, "-").concat(bytesFinished + chunkSize - 1);
2184
- _context31.next = 11;
1628
+ _context20.next = 11;
2185
1629
  return this.HttpClient.Request({
2186
1630
  path: downloadPath,
2187
1631
  headers: headers,
2188
1632
  method: "GET"
2189
1633
  });
2190
1634
  case 11:
2191
- response = _context31.sent;
1635
+ response = _context20.sent;
2192
1636
  bytesFinished = Math.min(bytesFinished + chunkSize, bytesTotal);
2193
1637
  if (!chunked) {
2194
- _context31.next = 24;
1638
+ _context20.next = 24;
2195
1639
  break;
2196
1640
  }
2197
- _context31.t0 = callback;
2198
- _context31.t1 = bytesFinished;
2199
- _context31.t2 = bytesTotal;
2200
- _context31.next = 19;
1641
+ _context20.t0 = callback;
1642
+ _context20.t1 = bytesFinished;
1643
+ _context20.t2 = bytesTotal;
1644
+ _context20.next = 19;
2201
1645
  return this.utils.ResponseToFormat(format, response);
2202
1646
  case 19:
2203
- _context31.t3 = _context31.sent;
2204
- _context31.t4 = {
2205
- bytesFinished: _context31.t1,
2206
- bytesTotal: _context31.t2,
2207
- chunk: _context31.t3
1647
+ _context20.t3 = _context20.sent;
1648
+ _context20.t4 = {
1649
+ bytesFinished: _context20.t1,
1650
+ bytesTotal: _context20.t2,
1651
+ chunk: _context20.t3
2208
1652
  };
2209
- (0, _context31.t0)(_context31.t4);
2210
- _context31.next = 32;
1653
+ (0, _context20.t0)(_context20.t4);
1654
+ _context20.next = 32;
2211
1655
  break;
2212
1656
  case 24:
2213
- _context31.t5 = outputChunks;
2214
- _context31.t6 = Buffer;
2215
- _context31.next = 28;
1657
+ _context20.t5 = outputChunks;
1658
+ _context20.t6 = Buffer;
1659
+ _context20.next = 28;
2216
1660
  return response.arrayBuffer();
2217
1661
  case 28:
2218
- _context31.t7 = _context31.sent;
2219
- _context31.t8 = _context31.t6.from.call(_context31.t6, _context31.t7);
2220
- _context31.t5.push.call(_context31.t5, _context31.t8);
1662
+ _context20.t7 = _context20.sent;
1663
+ _context20.t8 = _context20.t6.from.call(_context20.t6, _context20.t7);
1664
+ _context20.t5.push.call(_context20.t5, _context20.t8);
2221
1665
  if (callback) {
2222
1666
  callback({
2223
1667
  bytesFinished: bytesFinished,
@@ -2226,37 +1670,37 @@ exports.Download = /*#__PURE__*/function () {
2226
1670
  }
2227
1671
  case 32:
2228
1672
  i++;
2229
- _context31.next = 7;
1673
+ _context20.next = 7;
2230
1674
  break;
2231
1675
  case 35:
2232
1676
  if (chunked) {
2233
- _context31.next = 39;
1677
+ _context20.next = 39;
2234
1678
  break;
2235
1679
  }
2236
- _context31.next = 38;
1680
+ _context20.next = 38;
2237
1681
  return this.utils.ResponseToFormat(format, new Response(Buffer.concat(outputChunks)));
2238
1682
  case 38:
2239
- return _context31.abrupt("return", _context31.sent);
1683
+ return _context20.abrupt("return", _context20.sent);
2240
1684
  case 39:
2241
1685
  case "end":
2242
- return _context31.stop();
1686
+ return _context20.stop();
2243
1687
  }
2244
- }, _callee29, this);
1688
+ }, _callee19, this);
2245
1689
  }));
2246
- return function (_x30) {
2247
- return _ref55.apply(this, arguments);
1690
+ return function (_x20) {
1691
+ return _ref36.apply(this, arguments);
2248
1692
  };
2249
1693
  }();
2250
1694
  exports.DownloadEncrypted = /*#__PURE__*/function () {
2251
- var _ref57 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31(_ref56) {
2252
- var _this3 = this;
2253
- var conk, downloadPath, bytesTotal, headers, callback, _ref56$format, format, _ref56$chunked, chunked, isReencryption, chunkSize, bytesFinished, outputChunks, stream, totalChunks, i, response;
2254
- return _regeneratorRuntime.wrap(function _callee31$(_context33) {
2255
- while (1) switch (_context33.prev = _context33.next) {
1695
+ var _ref38 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref37) {
1696
+ var _this2 = this;
1697
+ var conk, downloadPath, bytesTotal, headers, callback, _ref37$format, format, _ref37$chunked, chunked, isReencryption, chunkSize, bytesFinished, outputChunks, stream, totalChunks, i, response;
1698
+ return _regeneratorRuntime.wrap(function _callee21$(_context22) {
1699
+ while (1) switch (_context22.prev = _context22.next) {
2256
1700
  case 0:
2257
- conk = _ref56.conk, downloadPath = _ref56.downloadPath, bytesTotal = _ref56.bytesTotal, headers = _ref56.headers, callback = _ref56.callback, _ref56$format = _ref56.format, format = _ref56$format === void 0 ? "arrayBuffer" : _ref56$format, _ref56$chunked = _ref56.chunked, chunked = _ref56$chunked === void 0 ? false : _ref56$chunked;
1701
+ conk = _ref37.conk, downloadPath = _ref37.downloadPath, bytesTotal = _ref37.bytesTotal, headers = _ref37.headers, callback = _ref37.callback, _ref37$format = _ref37.format, format = _ref37$format === void 0 ? "arrayBuffer" : _ref37$format, _ref37$chunked = _ref37.chunked, chunked = _ref37$chunked === void 0 ? false : _ref37$chunked;
2258
1702
  if (!(chunked && !callback)) {
2259
- _context33.next = 3;
1703
+ _context22.next = 3;
2260
1704
  break;
2261
1705
  }
2262
1706
  throw Error("No callback specified for chunked download");
@@ -2267,44 +1711,44 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
2267
1711
  bytesFinished = 0;
2268
1712
  format = format.toLowerCase();
2269
1713
  outputChunks = []; // Set up decryption stream
2270
- _context33.next = 10;
1714
+ _context22.next = 10;
2271
1715
  return this.Crypto.OpenDecryptionStream(conk);
2272
1716
  case 10:
2273
- stream = _context33.sent;
1717
+ stream = _context22.sent;
2274
1718
  stream.on("data", /*#__PURE__*/function () {
2275
- var _ref58 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(chunk) {
1719
+ var _ref39 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(chunk) {
2276
1720
  var arrayBuffer;
2277
- return _regeneratorRuntime.wrap(function _callee30$(_context32) {
2278
- while (1) switch (_context32.prev = _context32.next) {
1721
+ return _regeneratorRuntime.wrap(function _callee20$(_context21) {
1722
+ while (1) switch (_context21.prev = _context21.next) {
2279
1723
  case 0:
2280
1724
  if (!chunked) {
2281
- _context32.next = 13;
1725
+ _context21.next = 13;
2282
1726
  break;
2283
1727
  }
2284
1728
  if (!(format !== "buffer")) {
2285
- _context32.next = 10;
1729
+ _context21.next = 10;
2286
1730
  break;
2287
1731
  }
2288
1732
  arrayBuffer = chunk.buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.byteLength);
2289
1733
  if (!(format === "arraybuffer")) {
2290
- _context32.next = 7;
1734
+ _context21.next = 7;
2291
1735
  break;
2292
1736
  }
2293
1737
  chunk = arrayBuffer;
2294
- _context32.next = 10;
1738
+ _context21.next = 10;
2295
1739
  break;
2296
1740
  case 7:
2297
- _context32.next = 9;
2298
- return _this3.utils.ResponseToFormat(format, new Response(arrayBuffer));
1741
+ _context21.next = 9;
1742
+ return _this2.utils.ResponseToFormat(format, new Response(arrayBuffer));
2299
1743
  case 9:
2300
- chunk = _context32.sent;
1744
+ chunk = _context21.sent;
2301
1745
  case 10:
2302
1746
  callback({
2303
1747
  bytesFinished: bytesFinished,
2304
1748
  bytesTotal: bytesTotal,
2305
1749
  chunk: chunk
2306
1750
  });
2307
- _context32.next = 15;
1751
+ _context21.next = 15;
2308
1752
  break;
2309
1753
  case 13:
2310
1754
  if (callback) {
@@ -2316,47 +1760,47 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
2316
1760
  outputChunks.push(chunk);
2317
1761
  case 15:
2318
1762
  case "end":
2319
- return _context32.stop();
1763
+ return _context21.stop();
2320
1764
  }
2321
- }, _callee30);
1765
+ }, _callee20);
2322
1766
  }));
2323
- return function (_x32) {
2324
- return _ref58.apply(this, arguments);
1767
+ return function (_x22) {
1768
+ return _ref39.apply(this, arguments);
2325
1769
  };
2326
1770
  }());
2327
1771
  totalChunks = Math.ceil(bytesTotal / chunkSize);
2328
1772
  i = 0;
2329
1773
  case 14:
2330
1774
  if (!(i < totalChunks)) {
2331
- _context33.next = 30;
1775
+ _context22.next = 30;
2332
1776
  break;
2333
1777
  }
2334
1778
  headers["Range"] = "bytes=".concat(bytesFinished, "-").concat(bytesFinished + chunkSize - 1);
2335
- _context33.next = 18;
1779
+ _context22.next = 18;
2336
1780
  return this.HttpClient.Request({
2337
1781
  headers: headers,
2338
1782
  method: "GET",
2339
1783
  path: downloadPath
2340
1784
  });
2341
1785
  case 18:
2342
- response = _context33.sent;
1786
+ response = _context22.sent;
2343
1787
  bytesFinished = Math.min(bytesFinished + chunkSize, bytesTotal);
2344
- _context33.t0 = stream;
2345
- _context33.t1 = Uint8Array;
2346
- _context33.next = 24;
1788
+ _context22.t0 = stream;
1789
+ _context22.t1 = Uint8Array;
1790
+ _context22.next = 24;
2347
1791
  return response.arrayBuffer();
2348
1792
  case 24:
2349
- _context33.t2 = _context33.sent;
2350
- _context33.t3 = new _context33.t1(_context33.t2);
2351
- _context33.t0.write.call(_context33.t0, _context33.t3);
1793
+ _context22.t2 = _context22.sent;
1794
+ _context22.t3 = new _context22.t1(_context22.t2);
1795
+ _context22.t0.write.call(_context22.t0, _context22.t3);
2352
1796
  case 27:
2353
1797
  i++;
2354
- _context33.next = 14;
1798
+ _context22.next = 14;
2355
1799
  break;
2356
1800
  case 30:
2357
1801
  // Wait for decryption to complete
2358
1802
  stream.end();
2359
- _context33.next = 33;
1803
+ _context22.next = 33;
2360
1804
  return new Promise(function (resolve) {
2361
1805
  return stream.on("finish", function () {
2362
1806
  resolve();
@@ -2364,21 +1808,21 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
2364
1808
  });
2365
1809
  case 33:
2366
1810
  if (chunked) {
2367
- _context33.next = 37;
1811
+ _context22.next = 37;
2368
1812
  break;
2369
1813
  }
2370
- _context33.next = 36;
1814
+ _context22.next = 36;
2371
1815
  return this.utils.ResponseToFormat(format, new Response(Buffer.concat(outputChunks)));
2372
1816
  case 36:
2373
- return _context33.abrupt("return", _context33.sent);
1817
+ return _context22.abrupt("return", _context22.sent);
2374
1818
  case 37:
2375
1819
  case "end":
2376
- return _context33.stop();
1820
+ return _context22.stop();
2377
1821
  }
2378
- }, _callee31, this);
1822
+ }, _callee21, this);
2379
1823
  }));
2380
- return function (_x31) {
2381
- return _ref57.apply(this, arguments);
1824
+ return function (_x21) {
1825
+ return _ref38.apply(this, arguments);
2382
1826
  };
2383
1827
  }();
2384
1828
 
@@ -2396,20 +1840,20 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
2396
1840
  * @returns {Promise<string>} - The part write token for the part draft
2397
1841
  */
2398
1842
  exports.CreatePart = /*#__PURE__*/function () {
2399
- var _ref60 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32(_ref59) {
1843
+ var _ref41 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref40) {
2400
1844
  var libraryId, objectId, writeToken, encryption, path, openResponse;
2401
- return _regeneratorRuntime.wrap(function _callee32$(_context34) {
2402
- while (1) switch (_context34.prev = _context34.next) {
1845
+ return _regeneratorRuntime.wrap(function _callee22$(_context23) {
1846
+ while (1) switch (_context23.prev = _context23.next) {
2403
1847
  case 0:
2404
- libraryId = _ref59.libraryId, objectId = _ref59.objectId, writeToken = _ref59.writeToken, encryption = _ref59.encryption;
1848
+ libraryId = _ref40.libraryId, objectId = _ref40.objectId, writeToken = _ref40.writeToken, encryption = _ref40.encryption;
2405
1849
  ValidateParameters({
2406
1850
  libraryId: libraryId,
2407
1851
  objectId: objectId
2408
1852
  });
2409
1853
  ValidateWriteToken(writeToken);
2410
1854
  path = UrlJoin("q", writeToken, "parts");
2411
- _context34.t0 = this.HttpClient;
2412
- _context34.next = 7;
1855
+ _context23.t0 = this.HttpClient;
1856
+ _context23.next = 7;
2413
1857
  return this.authClient.AuthorizationHeader({
2414
1858
  libraryId: libraryId,
2415
1859
  objectId: objectId,
@@ -2417,29 +1861,29 @@ exports.CreatePart = /*#__PURE__*/function () {
2417
1861
  encryption: encryption
2418
1862
  });
2419
1863
  case 7:
2420
- _context34.t1 = _context34.sent;
2421
- _context34.t2 = path;
2422
- _context34.t3 = {
2423
- headers: _context34.t1,
1864
+ _context23.t1 = _context23.sent;
1865
+ _context23.t2 = path;
1866
+ _context23.t3 = {
1867
+ headers: _context23.t1,
2424
1868
  method: "POST",
2425
- path: _context34.t2,
1869
+ path: _context23.t2,
2426
1870
  bodyType: "BINARY",
2427
1871
  body: "",
2428
1872
  allowFailover: false
2429
1873
  };
2430
- _context34.next = 12;
2431
- return _context34.t0.RequestJsonBody.call(_context34.t0, _context34.t3);
1874
+ _context23.next = 12;
1875
+ return _context23.t0.RequestJsonBody.call(_context23.t0, _context23.t3);
2432
1876
  case 12:
2433
- openResponse = _context34.sent;
2434
- return _context34.abrupt("return", openResponse.part.write_token);
1877
+ openResponse = _context23.sent;
1878
+ return _context23.abrupt("return", openResponse.part.write_token);
2435
1879
  case 14:
2436
1880
  case "end":
2437
- return _context34.stop();
1881
+ return _context23.stop();
2438
1882
  }
2439
- }, _callee32, this);
1883
+ }, _callee22, this);
2440
1884
  }));
2441
- return function (_x33) {
2442
- return _ref60.apply(this, arguments);
1885
+ return function (_x23) {
1886
+ return _ref41.apply(this, arguments);
2443
1887
  };
2444
1888
  }();
2445
1889
 
@@ -2459,38 +1903,38 @@ exports.CreatePart = /*#__PURE__*/function () {
2459
1903
  * @returns {Promise<string>} - The part write token for the part draft
2460
1904
  */
2461
1905
  exports.UploadPartChunk = /*#__PURE__*/function () {
2462
- var _ref62 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33(_ref61) {
1906
+ var _ref43 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref42) {
2463
1907
  var libraryId, objectId, writeToken, partWriteToken, chunk, encryption, conk, path;
2464
- return _regeneratorRuntime.wrap(function _callee33$(_context35) {
2465
- while (1) switch (_context35.prev = _context35.next) {
1908
+ return _regeneratorRuntime.wrap(function _callee23$(_context24) {
1909
+ while (1) switch (_context24.prev = _context24.next) {
2466
1910
  case 0:
2467
- libraryId = _ref61.libraryId, objectId = _ref61.objectId, writeToken = _ref61.writeToken, partWriteToken = _ref61.partWriteToken, chunk = _ref61.chunk, encryption = _ref61.encryption;
1911
+ libraryId = _ref42.libraryId, objectId = _ref42.objectId, writeToken = _ref42.writeToken, partWriteToken = _ref42.partWriteToken, chunk = _ref42.chunk, encryption = _ref42.encryption;
2468
1912
  ValidateParameters({
2469
1913
  libraryId: libraryId,
2470
1914
  objectId: objectId
2471
1915
  });
2472
1916
  ValidateWriteToken(writeToken);
2473
1917
  if (!(encryption && encryption !== "none")) {
2474
- _context35.next = 10;
1918
+ _context24.next = 10;
2475
1919
  break;
2476
1920
  }
2477
- _context35.next = 6;
1921
+ _context24.next = 6;
2478
1922
  return this.EncryptionConk({
2479
1923
  libraryId: libraryId,
2480
1924
  objectId: objectId,
2481
1925
  writeToken: writeToken
2482
1926
  });
2483
1927
  case 6:
2484
- conk = _context35.sent;
2485
- _context35.next = 9;
1928
+ conk = _context24.sent;
1929
+ _context24.next = 9;
2486
1930
  return this.Crypto.Encrypt(conk, chunk);
2487
1931
  case 9:
2488
- chunk = _context35.sent;
1932
+ chunk = _context24.sent;
2489
1933
  case 10:
2490
1934
  path = UrlJoin("q", writeToken, "parts");
2491
- _context35.t0 = this.utils;
2492
- _context35.t1 = this.HttpClient;
2493
- _context35.next = 15;
1935
+ _context24.t0 = this.utils;
1936
+ _context24.t1 = this.HttpClient;
1937
+ _context24.next = 15;
2494
1938
  return this.authClient.AuthorizationHeader({
2495
1939
  libraryId: libraryId,
2496
1940
  objectId: objectId,
@@ -2498,28 +1942,28 @@ exports.UploadPartChunk = /*#__PURE__*/function () {
2498
1942
  encryption: encryption
2499
1943
  });
2500
1944
  case 15:
2501
- _context35.t2 = _context35.sent;
2502
- _context35.t3 = UrlJoin(path, partWriteToken);
2503
- _context35.t4 = chunk;
2504
- _context35.t5 = {
2505
- headers: _context35.t2,
1945
+ _context24.t2 = _context24.sent;
1946
+ _context24.t3 = UrlJoin(path, partWriteToken);
1947
+ _context24.t4 = chunk;
1948
+ _context24.t5 = {
1949
+ headers: _context24.t2,
2506
1950
  method: "POST",
2507
- path: _context35.t3,
2508
- body: _context35.t4,
1951
+ path: _context24.t3,
1952
+ body: _context24.t4,
2509
1953
  bodyType: "BINARY",
2510
1954
  allowFailover: false
2511
1955
  };
2512
- _context35.t6 = _context35.t1.Request.call(_context35.t1, _context35.t5);
2513
- _context35.next = 22;
2514
- return _context35.t0.ResponseToJson.call(_context35.t0, _context35.t6);
1956
+ _context24.t6 = _context24.t1.Request.call(_context24.t1, _context24.t5);
1957
+ _context24.next = 22;
1958
+ return _context24.t0.ResponseToJson.call(_context24.t0, _context24.t6);
2515
1959
  case 22:
2516
1960
  case "end":
2517
- return _context35.stop();
1961
+ return _context24.stop();
2518
1962
  }
2519
- }, _callee33, this);
1963
+ }, _callee23, this);
2520
1964
  }));
2521
- return function (_x34) {
2522
- return _ref62.apply(this, arguments);
1965
+ return function (_x24) {
1966
+ return _ref43.apply(this, arguments);
2523
1967
  };
2524
1968
  }();
2525
1969
 
@@ -2538,20 +1982,20 @@ exports.UploadPartChunk = /*#__PURE__*/function () {
2538
1982
  * @returns {Promise<object>} - The finalize response for the new part
2539
1983
  */
2540
1984
  exports.FinalizePart = /*#__PURE__*/function () {
2541
- var _ref64 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34(_ref63) {
1985
+ var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref44) {
2542
1986
  var libraryId, objectId, writeToken, partWriteToken, encryption, path;
2543
- return _regeneratorRuntime.wrap(function _callee34$(_context36) {
2544
- while (1) switch (_context36.prev = _context36.next) {
1987
+ return _regeneratorRuntime.wrap(function _callee24$(_context25) {
1988
+ while (1) switch (_context25.prev = _context25.next) {
2545
1989
  case 0:
2546
- libraryId = _ref63.libraryId, objectId = _ref63.objectId, writeToken = _ref63.writeToken, partWriteToken = _ref63.partWriteToken, encryption = _ref63.encryption;
1990
+ libraryId = _ref44.libraryId, objectId = _ref44.objectId, writeToken = _ref44.writeToken, partWriteToken = _ref44.partWriteToken, encryption = _ref44.encryption;
2547
1991
  ValidateParameters({
2548
1992
  libraryId: libraryId,
2549
1993
  objectId: objectId
2550
1994
  });
2551
1995
  ValidateWriteToken(writeToken);
2552
1996
  path = UrlJoin("q", writeToken, "parts");
2553
- _context36.t0 = this.HttpClient;
2554
- _context36.next = 7;
1997
+ _context25.t0 = this.HttpClient;
1998
+ _context25.next = 7;
2555
1999
  return this.authClient.AuthorizationHeader({
2556
2000
  libraryId: libraryId,
2557
2001
  objectId: objectId,
@@ -2559,28 +2003,28 @@ exports.FinalizePart = /*#__PURE__*/function () {
2559
2003
  encryption: encryption
2560
2004
  });
2561
2005
  case 7:
2562
- _context36.t1 = _context36.sent;
2563
- _context36.t2 = UrlJoin(path, partWriteToken);
2564
- _context36.t3 = {
2565
- headers: _context36.t1,
2006
+ _context25.t1 = _context25.sent;
2007
+ _context25.t2 = UrlJoin(path, partWriteToken);
2008
+ _context25.t3 = {
2009
+ headers: _context25.t1,
2566
2010
  method: "POST",
2567
- path: _context36.t2,
2011
+ path: _context25.t2,
2568
2012
  bodyType: "BINARY",
2569
2013
  body: "",
2570
2014
  allowFailover: false
2571
2015
  };
2572
- _context36.next = 12;
2573
- return _context36.t0.RequestJsonBody.call(_context36.t0, _context36.t3);
2016
+ _context25.next = 12;
2017
+ return _context25.t0.RequestJsonBody.call(_context25.t0, _context25.t3);
2574
2018
  case 12:
2575
- return _context36.abrupt("return", _context36.sent);
2019
+ return _context25.abrupt("return", _context25.sent);
2576
2020
  case 13:
2577
2021
  case "end":
2578
- return _context36.stop();
2022
+ return _context25.stop();
2579
2023
  }
2580
- }, _callee34, this);
2024
+ }, _callee24, this);
2581
2025
  }));
2582
- return function (_x35) {
2583
- return _ref64.apply(this, arguments);
2026
+ return function (_x25) {
2027
+ return _ref45.apply(this, arguments);
2584
2028
  };
2585
2029
  }();
2586
2030
 
@@ -2606,18 +2050,18 @@ exports.FinalizePart = /*#__PURE__*/function () {
2606
2050
  * @returns {Promise<Object>} - Response containing information about the uploaded part
2607
2051
  */
2608
2052
  exports.UploadPart = /*#__PURE__*/function () {
2609
- var _ref66 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee35(_ref65) {
2610
- var libraryId, objectId, writeToken, data, _ref65$encryption, encryption, _ref65$chunkSize, chunkSize, callback, partWriteToken, size, i, chunk;
2611
- return _regeneratorRuntime.wrap(function _callee35$(_context37) {
2612
- while (1) switch (_context37.prev = _context37.next) {
2053
+ var _ref47 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref46) {
2054
+ var libraryId, objectId, writeToken, data, _ref46$encryption, encryption, _ref46$chunkSize, chunkSize, callback, partWriteToken, size, i, chunk;
2055
+ return _regeneratorRuntime.wrap(function _callee25$(_context26) {
2056
+ while (1) switch (_context26.prev = _context26.next) {
2613
2057
  case 0:
2614
- libraryId = _ref65.libraryId, objectId = _ref65.objectId, writeToken = _ref65.writeToken, data = _ref65.data, _ref65$encryption = _ref65.encryption, encryption = _ref65$encryption === void 0 ? "none" : _ref65$encryption, _ref65$chunkSize = _ref65.chunkSize, chunkSize = _ref65$chunkSize === void 0 ? 10000000 : _ref65$chunkSize, callback = _ref65.callback;
2058
+ libraryId = _ref46.libraryId, objectId = _ref46.objectId, writeToken = _ref46.writeToken, data = _ref46.data, _ref46$encryption = _ref46.encryption, encryption = _ref46$encryption === void 0 ? "none" : _ref46$encryption, _ref46$chunkSize = _ref46.chunkSize, chunkSize = _ref46$chunkSize === void 0 ? 10000000 : _ref46$chunkSize, callback = _ref46.callback;
2615
2059
  ValidateParameters({
2616
2060
  libraryId: libraryId,
2617
2061
  objectId: objectId
2618
2062
  });
2619
2063
  ValidateWriteToken(writeToken);
2620
- _context37.next = 5;
2064
+ _context26.next = 5;
2621
2065
  return this.CreatePart({
2622
2066
  libraryId: libraryId,
2623
2067
  objectId: objectId,
@@ -2625,7 +2069,7 @@ exports.UploadPart = /*#__PURE__*/function () {
2625
2069
  encryption: encryption
2626
2070
  });
2627
2071
  case 5:
2628
- partWriteToken = _context37.sent;
2072
+ partWriteToken = _context26.sent;
2629
2073
  size = data.length || data.byteLength || data.size;
2630
2074
  if (callback) {
2631
2075
  callback({
@@ -2636,11 +2080,11 @@ exports.UploadPart = /*#__PURE__*/function () {
2636
2080
  i = 0;
2637
2081
  case 9:
2638
2082
  if (!(i < size)) {
2639
- _context37.next = 17;
2083
+ _context26.next = 17;
2640
2084
  break;
2641
2085
  }
2642
2086
  chunk = data.slice(i, i + chunkSize);
2643
- _context37.next = 13;
2087
+ _context26.next = 13;
2644
2088
  return this.UploadPartChunk({
2645
2089
  libraryId: libraryId,
2646
2090
  objectId: objectId,
@@ -2658,10 +2102,10 @@ exports.UploadPart = /*#__PURE__*/function () {
2658
2102
  }
2659
2103
  case 14:
2660
2104
  i += chunkSize;
2661
- _context37.next = 9;
2105
+ _context26.next = 9;
2662
2106
  break;
2663
2107
  case 17:
2664
- _context37.next = 19;
2108
+ _context26.next = 19;
2665
2109
  return this.FinalizePart({
2666
2110
  libraryId: libraryId,
2667
2111
  objectId: objectId,
@@ -2670,15 +2114,15 @@ exports.UploadPart = /*#__PURE__*/function () {
2670
2114
  encryption: encryption
2671
2115
  });
2672
2116
  case 19:
2673
- return _context37.abrupt("return", _context37.sent);
2117
+ return _context26.abrupt("return", _context26.sent);
2674
2118
  case 20:
2675
2119
  case "end":
2676
- return _context37.stop();
2120
+ return _context26.stop();
2677
2121
  }
2678
- }, _callee35, this);
2122
+ }, _callee25, this);
2679
2123
  }));
2680
- return function (_x36) {
2681
- return _ref66.apply(this, arguments);
2124
+ return function (_x26) {
2125
+ return _ref47.apply(this, arguments);
2682
2126
  };
2683
2127
  }();
2684
2128
 
@@ -2694,12 +2138,12 @@ exports.UploadPart = /*#__PURE__*/function () {
2694
2138
  * @param {string} partHash - Hash of the part to delete
2695
2139
  */
2696
2140
  exports.DeletePart = /*#__PURE__*/function () {
2697
- var _ref68 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee36(_ref67) {
2141
+ var _ref49 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref48) {
2698
2142
  var libraryId, objectId, writeToken, partHash, path;
2699
- return _regeneratorRuntime.wrap(function _callee36$(_context38) {
2700
- while (1) switch (_context38.prev = _context38.next) {
2143
+ return _regeneratorRuntime.wrap(function _callee26$(_context27) {
2144
+ while (1) switch (_context27.prev = _context27.next) {
2701
2145
  case 0:
2702
- libraryId = _ref67.libraryId, objectId = _ref67.objectId, writeToken = _ref67.writeToken, partHash = _ref67.partHash;
2146
+ libraryId = _ref48.libraryId, objectId = _ref48.objectId, writeToken = _ref48.writeToken, partHash = _ref48.partHash;
2703
2147
  ValidateParameters({
2704
2148
  libraryId: libraryId,
2705
2149
  objectId: objectId
@@ -2707,31 +2151,31 @@ exports.DeletePart = /*#__PURE__*/function () {
2707
2151
  ValidateWriteToken(writeToken);
2708
2152
  ValidatePartHash(partHash);
2709
2153
  path = UrlJoin("q", writeToken, "parts", partHash);
2710
- _context38.t0 = this.HttpClient;
2711
- _context38.next = 8;
2154
+ _context27.t0 = this.HttpClient;
2155
+ _context27.next = 8;
2712
2156
  return this.authClient.AuthorizationHeader({
2713
2157
  libraryId: libraryId,
2714
2158
  objectId: objectId,
2715
2159
  update: true
2716
2160
  });
2717
2161
  case 8:
2718
- _context38.t1 = _context38.sent;
2719
- _context38.t2 = path;
2720
- _context38.t3 = {
2721
- headers: _context38.t1,
2162
+ _context27.t1 = _context27.sent;
2163
+ _context27.t2 = path;
2164
+ _context27.t3 = {
2165
+ headers: _context27.t1,
2722
2166
  method: "DELETE",
2723
- path: _context38.t2,
2167
+ path: _context27.t2,
2724
2168
  allowFailover: false
2725
2169
  };
2726
- _context38.next = 13;
2727
- return _context38.t0.Request.call(_context38.t0, _context38.t3);
2170
+ _context27.next = 13;
2171
+ return _context27.t0.Request.call(_context27.t0, _context27.t3);
2728
2172
  case 13:
2729
2173
  case "end":
2730
- return _context38.stop();
2174
+ return _context27.stop();
2731
2175
  }
2732
- }, _callee36, this);
2176
+ }, _callee26, this);
2733
2177
  }));
2734
- return function (_x37) {
2735
- return _ref68.apply(this, arguments);
2178
+ return function (_x27) {
2179
+ return _ref49.apply(this, arguments);
2736
2180
  };
2737
2181
  }();