@eluvio/elv-client-js 4.0.144 → 4.0.145

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.
Files changed (38) hide show
  1. package/dist/ElvClient-min.js +15 -14
  2. package/dist/ElvClient-node-min.js +14 -13
  3. package/dist/ElvFrameClient-min.js +10 -10
  4. package/dist/ElvPermissionsClient-min.js +9 -9
  5. package/dist/ElvWalletClient-min.js +15 -14
  6. package/dist/ElvWalletClient-node-min.js +14 -13
  7. package/dist/src/AuthorizationClient.js +9 -12
  8. package/dist/src/ContentObjectAudit.js +3 -3
  9. package/dist/src/ContentObjectVerification.js +3 -3
  10. package/dist/src/Crypto.js +2 -2
  11. package/dist/src/ElvClient.js +49 -30
  12. package/dist/src/ElvWallet.js +7 -5
  13. package/dist/src/EthClient.js +8 -9
  14. package/dist/src/FrameClient.js +8 -9
  15. package/dist/src/HttpClient.js +1 -2
  16. package/dist/src/Id.js +1 -2
  17. package/dist/src/PermissionsClient.js +31 -19
  18. package/dist/src/RemoteSigner.js +6 -8
  19. package/dist/src/UserProfileClient.js +35 -20
  20. package/dist/src/Utils.js +2 -3
  21. package/dist/src/Validation.js +10 -2
  22. package/dist/src/client/ABRPublishing.js +307 -252
  23. package/dist/src/client/AccessGroups.js +2 -2
  24. package/dist/src/client/ContentAccess.js +2 -3
  25. package/dist/src/client/ContentManagement.js +3 -3
  26. package/dist/src/client/Contracts.js +11 -12
  27. package/dist/src/client/Files.js +2 -2
  28. package/dist/src/client/LiveConf.js +3 -5
  29. package/dist/src/client/LiveStream.js +0 -2
  30. package/dist/src/client/NFT.js +2 -2
  31. package/dist/src/client/Shares.js +2 -2
  32. package/dist/src/walletClient/ClientMethods.js +2 -2
  33. package/dist/src/walletClient/Profile.js +2 -2
  34. package/dist/src/walletClient/Utils.js +2 -2
  35. package/dist/src/walletClient/index.js +17 -14
  36. package/package.json +2 -2
  37. package/src/Validation.js +9 -3
  38. package/src/client/ABRPublishing.js +176 -160
@@ -2,8 +2,8 @@ var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
2
2
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
3
3
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4
4
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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; }
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; }
7
7
  /**
8
8
  * Methods for ABR video creation and management
9
9
  *
@@ -90,7 +90,7 @@ var MezJobMainOfferingKey = function MezJobMainOfferingKey(abrMezOfferings) {
90
90
  */
91
91
  exports.CreateProductionMaster = /*#__PURE__*/function () {
92
92
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
93
- var libraryId, type, writeToken, name, description, _ref$metadata, metadata, fileInfo, _ref$encrypt, encrypt, _ref$access, access, _ref$copy, copy, callback, _ref$respLogLevel, respLogLevel, _ref$structLogLevel, structLogLevel, id, finalize, _yield$this$CreateCon, s3prefixRegex, i, oneFileInfo, matched, j, credentialSet, credentialSetBucket, matchers, k, matcher, fileSourcePath, s3prefixMatch, bucketName, _i, _credentialSet, region, bucket, accessKey, secret, _yield$this$CallBitco, logs, errors, warnings, finalizeResponse;
93
+ var libraryId, type, writeToken, name, description, _ref$metadata, metadata, fileInfo, _ref$encrypt, encrypt, _ref$access, access, _ref$copy, copy, callback, _ref$respLogLevel, respLogLevel, _ref$structLogLevel, structLogLevel, objectId, finalize, _yield$this$CreateCon, s3prefixRegex, i, oneFileInfo, matched, j, credentialSet, credentialSetBucket, matchers, k, matcher, fileSourcePath, s3prefixMatch, bucketName, _i, _credentialSet, region, bucket, accessKey, secret, _yield$this$CallBitco, logs, errors, warnings, additionalReturnVals;
94
94
  return _regeneratorRuntime.wrap(function _callee$(_context) {
95
95
  while (1) switch (_context.prev = _context.next) {
96
96
  case 0:
@@ -101,7 +101,8 @@ exports.CreateProductionMaster = /*#__PURE__*/function () {
101
101
  _context.next = 7;
102
102
  break;
103
103
  }
104
- id = this.utils.DecodeWriteToken(writeToken).objectId;
104
+ // if write token passed in, don't create a new object
105
+ objectId = this.utils.DecodeWriteToken(writeToken).objectId;
105
106
  _context.next = 12;
106
107
  break;
107
108
  case 7:
@@ -114,7 +115,7 @@ exports.CreateProductionMaster = /*#__PURE__*/function () {
114
115
  });
115
116
  case 9:
116
117
  _yield$this$CreateCon = _context.sent;
117
- id = _yield$this$CreateCon.id;
118
+ objectId = _yield$this$CreateCon.objectId;
118
119
  writeToken = _yield$this$CreateCon.writeToken;
119
120
  case 12:
120
121
  if (!fileInfo) {
@@ -215,7 +216,7 @@ exports.CreateProductionMaster = /*#__PURE__*/function () {
215
216
  _context.next = 57;
216
217
  return this.UploadFilesFromS3({
217
218
  libraryId: libraryId,
218
- objectId: id,
219
+ objectId: objectId,
219
220
  writeToken: writeToken,
220
221
  fileInfo: _credentialSet.matched,
221
222
  region: region,
@@ -237,7 +238,7 @@ exports.CreateProductionMaster = /*#__PURE__*/function () {
237
238
  _context.next = 64;
238
239
  return this.UploadFiles({
239
240
  libraryId: libraryId,
240
- objectId: id,
241
+ objectId: objectId,
241
242
  writeToken: writeToken,
242
243
  fileInfo: fileInfo,
243
244
  callback: callback,
@@ -247,7 +248,7 @@ exports.CreateProductionMaster = /*#__PURE__*/function () {
247
248
  _context.next = 66;
248
249
  return this.CreateEncryptionConk({
249
250
  libraryId: libraryId,
250
- objectId: id,
251
+ objectId: objectId,
251
252
  writeToken: writeToken,
252
253
  createKMSConk: true
253
254
  });
@@ -255,7 +256,7 @@ exports.CreateProductionMaster = /*#__PURE__*/function () {
255
256
  _context.next = 68;
256
257
  return this.CallBitcodeMethod({
257
258
  libraryId: libraryId,
258
- objectId: id,
259
+ objectId: objectId,
259
260
  writeToken: writeToken,
260
261
  method: UrlJoin("media", "production_master", "init"),
261
262
  queryParams: {
@@ -275,7 +276,7 @@ exports.CreateProductionMaster = /*#__PURE__*/function () {
275
276
  _context.next = 74;
276
277
  return this.MergeMetadata({
277
278
  libraryId: libraryId,
278
- objectId: id,
279
+ objectId: objectId,
279
280
  writeToken: writeToken,
280
281
  metadata: _objectSpread(_objectSpread({}, metadata || {}), {}, {
281
282
  name: name,
@@ -296,28 +297,28 @@ exports.CreateProductionMaster = /*#__PURE__*/function () {
296
297
  _context.next = 77;
297
298
  return this.FinalizeContentObject({
298
299
  libraryId: libraryId,
299
- objectId: id,
300
+ objectId: objectId,
300
301
  writeToken: writeToken,
301
302
  commitMessage: "Create master",
302
303
  awaitCommitConfirmation: false
303
304
  });
304
305
  case 77:
305
- finalizeResponse = _context.sent;
306
+ additionalReturnVals = _context.sent;
306
307
  _context.next = 81;
307
308
  break;
308
309
  case 80:
309
- finalizeResponse = {
310
+ additionalReturnVals = {
310
311
  write_token: writeToken,
311
312
  type: type,
312
313
  qlib_id: libraryId,
313
- id: id
314
+ id: objectId
314
315
  };
315
316
  case 81:
316
317
  return _context.abrupt("return", _objectSpread({
317
318
  errors: errors || [],
318
319
  logs: logs || [],
319
320
  warnings: warnings || []
320
- }, finalizeResponse));
321
+ }, additionalReturnVals));
321
322
  case 82:
322
323
  case "end":
323
324
  return _context.stop();
@@ -340,8 +341,8 @@ exports.CreateProductionMaster = /*#__PURE__*/function () {
340
341
  * @param {boolean=} keepOtherStreams=false - If objectId is specified, whether to preserve existing streams with keys other than the ones specified in production master
341
342
  * @param {string} libraryId - ID of the mezzanine library
342
343
  * @param {string} masterVersionHash - The version hash of the production master content object
343
- * @param {string=} masterWriteToken - The write token of the production master content object draft. If provided, the object will not be finalized
344
- * @param {string=} writeToken - The write token of the mezzanine object draft. If specified, the object will not be finalized
344
+ * @param {string=} masterWriteToken - The write token of the production master content object draft.
345
+ * @param {string=} writeToken - The write token of the mezzanine object draft. If specified, the object will not be finalized, and no extra version of the object will be created to hold "bread crumb" metadata entry /lro_draft
345
346
  * @param {Object=} metadata - Additional metadata for mezzanine content object
346
347
  * @param {string} name - Name for mezzanine content object
347
348
  * @param {string=} objectId - ID of existing object (if not specified, new object will be created)
@@ -356,135 +357,156 @@ exports.CreateProductionMaster = /*#__PURE__*/function () {
356
357
  */
357
358
  exports.CreateABRMezzanine = /*#__PURE__*/function () {
358
359
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
359
- var libraryId, objectId, type, name, description, metadata, masterVersionHash, masterWriteToken, writeToken, abrProfile, addlOfferingSpecs, _ref3$variant, variant, _ref3$offeringKey, offeringKey, _ref3$keepOtherStream, keepOtherStreams, _ref3$respLogLevel, respLogLevel, _ref3$structLogLevel, structLogLevel, streamKeys, masterObjectId, existingMez, options, id, finalize, _yield$this$EditConte, createResponse, nameMetaPayload, masterName, authorizationTokens, headers, body, storeClear, _yield$this$CallBitco2, logs, errors, warnings, masterId, existingMetadata, finalizeResponse;
360
+ var libraryId, objectId, type, name, description, metadata, masterVersionHash, masterWriteToken, writeToken, abrProfile, addlOfferingSpecs, _ref3$variant, variant, _ref3$offeringKey, offeringKey, _ref3$keepOtherStream, keepOtherStreams, _ref3$respLogLevel, respLogLevel, _ref3$structLogLevel, structLogLevel, streamKeys, masterObjectId, masterLibId, useExistingMez, options, finalize, _yield$this$EditConte, _yield$this$CreateCon2, masterMetaSource, masterName, authorizationTokens, headers, body, storeClear, _yield$this$CallBitco2, logs, errors, warnings, masterId, existingMetadata, additionalReturnVals;
360
361
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
361
362
  while (1) switch (_context2.prev = _context2.next) {
362
363
  case 0:
363
364
  libraryId = _ref3.libraryId, objectId = _ref3.objectId, type = _ref3.type, name = _ref3.name, description = _ref3.description, metadata = _ref3.metadata, masterVersionHash = _ref3.masterVersionHash, masterWriteToken = _ref3.masterWriteToken, writeToken = _ref3.writeToken, abrProfile = _ref3.abrProfile, addlOfferingSpecs = _ref3.addlOfferingSpecs, _ref3$variant = _ref3.variant, variant = _ref3$variant === void 0 ? "default" : _ref3$variant, _ref3$offeringKey = _ref3.offeringKey, offeringKey = _ref3$offeringKey === void 0 ? "default" : _ref3$offeringKey, _ref3$keepOtherStream = _ref3.keepOtherStreams, keepOtherStreams = _ref3$keepOtherStream === void 0 ? false : _ref3$keepOtherStream, _ref3$respLogLevel = _ref3.respLogLevel, respLogLevel = _ref3$respLogLevel === void 0 ? "warn" : _ref3$respLogLevel, _ref3$structLogLevel = _ref3.structLogLevel, structLogLevel = _ref3$structLogLevel === void 0 ? "none" : _ref3$structLogLevel, streamKeys = _ref3.streamKeys;
364
- ValidateLibrary(libraryId);
365
- if (masterVersionHash) {
366
- ValidateVersion(masterVersionHash);
367
- } else if (masterWriteToken) {
368
- ValidateWriteToken(masterWriteToken);
369
- masterObjectId = this.utils.DecodeWriteToken(masterWriteToken).objectId;
365
+ if (!(!masterVersionHash && !masterWriteToken)) {
366
+ _context2.next = 3;
367
+ break;
370
368
  }
371
- if (writeToken) {
372
- ValidateWriteToken(writeToken);
373
- if (!objectId) {
374
- objectId = this.utils.DecodeWriteToken(writeToken).objectId;
375
- }
369
+ throw Error("Neither master version hash nor master write token specified. One must be provided");
370
+ case 3:
371
+ if (!(masterVersionHash && masterWriteToken)) {
372
+ _context2.next = 5;
373
+ break;
376
374
  }
377
- if (!(!masterVersionHash && !masterWriteToken)) {
378
- _context2.next = 6;
375
+ throw Error("Both master version hash and master write token specified. Only one can be provided");
376
+ case 5:
377
+ // double-check library id for mez
378
+ ValidateLibrary(libraryId);
379
+
380
+ // The following 2 vars are used only if masterWriteToken is passed in (to retrieve master name)
381
+ if (!masterVersionHash) {
382
+ _context2.next = 10;
379
383
  break;
380
384
  }
381
- throw Error("Master version hash and master write token not specified. One must be provided");
382
- case 6:
385
+ // NOTE: masterObjectId is left undefined if masterWriteToken not passed in
386
+ ValidateVersion(masterVersionHash);
387
+ _context2.next = 16;
388
+ break;
389
+ case 10:
390
+ if (!masterWriteToken) {
391
+ _context2.next = 16;
392
+ break;
393
+ }
394
+ // determine master object id if a master write token was passed in
395
+ ValidateWriteToken(masterWriteToken);
396
+ masterObjectId = this.utils.DecodeWriteToken(masterWriteToken).objectId;
397
+ _context2.next = 15;
398
+ return client.ContentObjectLibraryId({
399
+ masterObjectId: masterObjectId
400
+ });
401
+ case 15:
402
+ masterLibId = _context2.sent;
403
+ case 16:
404
+ // if pre-existing mez object id passed in, validate
405
+ if (objectId) ValidateObject(objectId);
406
+
407
+ // if mez write token supplied, validate it
408
+ if (writeToken) {
409
+ ValidateWriteToken(writeToken, objectId);
410
+
411
+ // if pre-existing mez object id not passed in, decode it from write token
412
+ objectId = objectId || this.utils.DecodeWriteToken(writeToken).objectId;
413
+ }
414
+ // After above, if objectId is undefined then no mez writeToken was passed in, no mez objectId was passed in,
415
+ // meaning we must create a new object
416
+ useExistingMez = !!objectId; // type coerce string or undefined to boolean: "" -> false, undefined -> false, all else -> true
383
417
  if (!(!objectId && keepOtherStreams)) {
384
- _context2.next = 8;
418
+ _context2.next = 21;
385
419
  break;
386
420
  }
387
421
  throw Error("Existing mezzanine object ID required in order to use 'keepOtherStreams'");
388
- case 8:
422
+ case 21:
389
423
  if (!(addlOfferingSpecs && !abrProfile)) {
390
- _context2.next = 10;
424
+ _context2.next = 23;
391
425
  break;
392
426
  }
393
427
  throw Error("abrProfile required when using addlOfferingSpecs");
394
- case 10:
395
- existingMez = !!objectId;
428
+ case 23:
396
429
  options = type ? {
397
430
  type: type
398
431
  } : {};
399
- finalize = !writeToken;
400
- if (!existingMez) {
401
- _context2.next = 25;
402
- break;
403
- }
404
- if (!writeToken) {
405
- _context2.next = 18;
432
+ finalize = !writeToken; // are we ingesting to an existing mez (and did NOT supply a write token?)
433
+ if (!(useExistingMez && !writeToken)) {
434
+ _context2.next = 30;
406
435
  break;
407
436
  }
408
- id = objectId;
409
- _context2.next = 23;
410
- break;
411
- case 18:
412
- _context2.next = 20;
437
+ _context2.next = 28;
413
438
  return this.EditContentObject({
414
439
  libraryId: libraryId,
415
440
  objectId: objectId,
416
441
  options: options
417
442
  });
418
- case 20:
443
+ case 28:
419
444
  _yield$this$EditConte = _context2.sent;
420
445
  writeToken = _yield$this$EditConte.writeToken;
421
- id = _yield$this$EditConte.id;
422
- case 23:
423
- _context2.next = 30;
424
- break;
425
- case 25:
426
- _context2.next = 27;
446
+ case 30:
447
+ if (useExistingMez) {
448
+ _context2.next = 36;
449
+ break;
450
+ }
451
+ _context2.next = 33;
427
452
  return this.CreateContentObject({
428
453
  libraryId: libraryId,
429
454
  options: options
430
455
  });
431
- case 27:
432
- createResponse = _context2.sent;
433
- id = createResponse.id;
434
- writeToken = createResponse.write_token;
435
- case 30:
436
- _context2.next = 32;
456
+ case 33:
457
+ _yield$this$CreateCon2 = _context2.sent;
458
+ objectId = _yield$this$CreateCon2.objectId;
459
+ writeToken = _yield$this$CreateCon2.writeToken;
460
+ case 36:
461
+ _context2.next = 38;
437
462
  return this.CreateEncryptionConk({
438
463
  libraryId: libraryId,
439
- objectId: id,
464
+ objectId: objectId,
440
465
  writeToken: writeToken,
441
466
  createKMSConk: true
442
467
  });
443
- case 32:
444
- if (masterWriteToken) {
445
- nameMetaPayload = {
446
- libraryId: libraryId,
447
- objectId: masterObjectId,
448
- writeToken: masterWriteToken
449
- };
450
- } else if (masterVersionHash) {
451
- nameMetaPayload = {
452
- versionHash: masterVersionHash
453
- };
454
- }
455
- _context2.next = 35;
456
- return this.ContentObjectMetadata(_objectSpread(_objectSpread({}, nameMetaPayload), {}, {
468
+ case 38:
469
+ // figure out where to read master metadata from
470
+ masterMetaSource = masterWriteToken ? {
471
+ libraryId: masterLibId,
472
+ objectId: masterObjectId,
473
+ writeToken: masterWriteToken
474
+ } : {
475
+ versionHash: masterVersionHash
476
+ };
477
+ _context2.next = 41;
478
+ return this.ContentObjectMetadata(_objectSpread(_objectSpread({}, masterMetaSource), {}, {
457
479
  metadataSubtree: "public/name"
458
480
  }));
459
- case 35:
481
+ case 41:
460
482
  masterName = _context2.sent;
461
483
  // Include authorization for library, master, and mezzanine
462
484
  authorizationTokens = [];
463
485
  _context2.t0 = authorizationTokens;
464
- _context2.next = 40;
486
+ _context2.next = 46;
465
487
  return this.authClient.AuthorizationToken({
466
488
  libraryId: libraryId,
467
- objectId: id,
489
+ objectId: objectId,
468
490
  update: true
469
491
  });
470
- case 40:
492
+ case 46:
471
493
  _context2.t1 = _context2.sent;
472
494
  _context2.t0.push.call(_context2.t0, _context2.t1);
473
495
  _context2.t2 = authorizationTokens;
474
- _context2.next = 45;
496
+ _context2.next = 51;
475
497
  return this.authClient.AuthorizationToken({
476
498
  libraryId: libraryId
477
499
  });
478
- case 45:
500
+ case 51:
479
501
  _context2.t3 = _context2.sent;
480
502
  _context2.t2.push.call(_context2.t2, _context2.t3);
481
503
  _context2.t4 = authorizationTokens;
482
- _context2.next = 50;
504
+ _context2.next = 56;
483
505
  return this.authClient.AuthorizationToken({
484
506
  versionHash: masterVersionHash,
485
507
  objectId: masterObjectId
486
508
  });
487
- case 50:
509
+ case 56:
488
510
  _context2.t5 = _context2.sent;
489
511
  _context2.t4.push.call(_context2.t4, _context2.t5);
490
512
  headers = {
@@ -500,40 +522,39 @@ exports.CreateABRMezzanine = /*#__PURE__*/function () {
500
522
  stream_keys: streamKeys,
501
523
  variant_key: variant
502
524
  };
503
- storeClear = false;
504
525
  if (!abrProfile) {
505
- _context2.next = 60;
526
+ _context2.next = 65;
506
527
  break;
507
528
  }
508
529
  body.abr_profile = abrProfile;
509
530
  storeClear = abrProfile.store_clear;
510
- _context2.next = 63;
531
+ _context2.next = 68;
511
532
  break;
512
- case 60:
513
- _context2.next = 62;
533
+ case 65:
534
+ _context2.next = 67;
514
535
  return this.ContentObjectMetadata({
515
536
  libraryId: libraryId,
516
537
  objectId: this.utils.AddressToObjectId(this.utils.HashToAddress(libraryId)),
517
538
  metadataSubtree: "abr_profile/store_clear"
518
539
  });
519
- case 62:
540
+ case 67:
520
541
  storeClear = _context2.sent;
521
- case 63:
542
+ case 68:
522
543
  if (storeClear) {
523
- _context2.next = 66;
544
+ _context2.next = 71;
524
545
  break;
525
546
  }
526
- _context2.next = 66;
547
+ _context2.next = 71;
527
548
  return this.EncryptionConk({
528
549
  libraryId: libraryId,
529
- objectId: id,
550
+ objectId: objectId,
530
551
  writeToken: writeToken
531
552
  });
532
- case 66:
533
- _context2.next = 68;
553
+ case 71:
554
+ _context2.next = 73;
534
555
  return this.CallBitcodeMethod({
535
556
  libraryId: libraryId,
536
- objectId: id,
557
+ objectId: objectId,
537
558
  writeToken: writeToken,
538
559
  method: UrlJoin("media", "abr_mezzanine", "init"),
539
560
  queryParams: {
@@ -544,7 +565,7 @@ exports.CreateABRMezzanine = /*#__PURE__*/function () {
544
565
  body: body,
545
566
  constant: false
546
567
  });
547
- case 68:
568
+ case 73:
548
569
  _yield$this$CallBitco2 = _context2.sent;
549
570
  logs = _yield$this$CallBitco2.logs;
550
571
  errors = _yield$this$CallBitco2.errors;
@@ -575,70 +596,70 @@ exports.CreateABRMezzanine = /*#__PURE__*/function () {
575
596
  "/": "./rep/playout/".concat(offeringKey, "/options.json")
576
597
  })
577
598
  }, metadata["public"].asset_metadata);
578
- if (name || !existingMez) {
599
+ if (name || !useExistingMez) {
579
600
  metadata.name = name || "".concat(masterName, " Mezzanine");
580
601
  metadata["public"].name = name || "".concat(masterName, " Mezzanine");
581
602
  }
582
- if (description || !existingMez) {
603
+ if (description || !useExistingMez) {
583
604
  metadata.description = description || "";
584
605
  metadata["public"].description = description || "";
585
606
  }
586
607
 
587
608
  // retrieve existing metadata to merge with updated metadata
588
- _context2.next = 83;
609
+ _context2.next = 88;
589
610
  return this.ContentObjectMetadata({
590
611
  libraryId: libraryId,
591
- objectId: id,
612
+ objectId: objectId,
592
613
  writeToken: writeToken
593
614
  });
594
- case 83:
615
+ case 88:
595
616
  existingMetadata = _context2.sent;
596
617
  // newer metadata values replace existing metadata, unless both new and old values are objects,
597
618
  // in which case their keys are merged recursively
598
619
  metadata = R.mergeDeepRight(existingMetadata, metadata);
599
- if (!existingMez) {
620
+ if (!useExistingMez) {
600
621
  // set creation date
601
622
  metadata.elv_created_at = new Date().getTime();
602
623
  }
603
624
 
604
625
  // write metadata to mezzanine object
605
- _context2.next = 88;
626
+ _context2.next = 93;
606
627
  return this.ReplaceMetadata({
607
628
  libraryId: libraryId,
608
- objectId: id,
629
+ objectId: objectId,
609
630
  writeToken: writeToken,
610
631
  metadata: metadata
611
632
  });
612
- case 88:
633
+ case 93:
613
634
  if (!finalize) {
614
- _context2.next = 94;
635
+ _context2.next = 99;
615
636
  break;
616
637
  }
617
- _context2.next = 91;
638
+ _context2.next = 96;
618
639
  return this.FinalizeContentObject({
619
640
  libraryId: libraryId,
620
- objectId: id,
641
+ objectId: objectId,
621
642
  writeToken: writeToken,
622
643
  commitMessage: "Create ABR mezzanine"
623
644
  });
624
- case 91:
625
- finalizeResponse = _context2.sent;
626
- _context2.next = 95;
645
+ case 96:
646
+ additionalReturnVals = _context2.sent;
647
+ _context2.next = 100;
627
648
  break;
628
- case 94:
629
- finalizeResponse = {
649
+ case 99:
650
+ additionalReturnVals = {
630
651
  write_token: writeToken,
631
652
  type: type,
632
653
  qlib_id: libraryId,
633
- id: id
654
+ id: objectId
634
655
  };
635
- case 95:
656
+ case 100:
636
657
  return _context2.abrupt("return", _objectSpread({
637
658
  logs: logs || [],
638
659
  warnings: warnings || [],
639
660
  errors: errors || []
640
- }, finalizeResponse));
641
- case 96:
661
+ }, additionalReturnVals));
662
+ case 101:
642
663
  case "end":
643
664
  return _context2.stop();
644
665
  }
@@ -656,7 +677,7 @@ exports.CreateABRMezzanine = /*#__PURE__*/function () {
656
677
  * @namedParams
657
678
  * @param {string} libraryId - ID of the mezzanine library
658
679
  * @param {string} objectId - ID of the mezzanine object
659
- * @param {string=} writeToken - Write token of the mezzanine object draft. If provided, the object will not be finalized
680
+ * @param {string=} writeToken - Write token of the mezzanine object draft. If provided, no "bread crumb" metadata /lro_draft will be created, nor saved as an extra finalized version
660
681
  * @param {Array<Object>=} access - Array of S3 credentials, along with path matching regexes - Required if any files in the masters are S3 references (See CreateProductionMaster method)
661
682
  * - Format: {region, bucket, accessKey, secret}
662
683
  * @param {number[]} jobIndexes - Array of LRO job indexes to start. LROs are listed in a map under metadata key /abr_mezzanine/offerings/(offeringKey)/mez_prep_specs/, and job indexes start with 0, corresponding to map keys in alphabetical order
@@ -666,7 +687,7 @@ exports.CreateABRMezzanine = /*#__PURE__*/function () {
666
687
  exports.StartABRMezzanineJobs = /*#__PURE__*/function () {
667
688
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
668
689
  var _this = this;
669
- var libraryId, objectId, writeToken, _ref5$access, access, _ref5$jobIndexes, jobIndexes, lastJobOfferingsInfo, offeringKey, prepSpecs, masterVersionHashes, authorizationTokens, headers, processingDraft, nodeUrl, lroInfo, finalizeResponse, statusDraft, _yield$this$CallBitco3, data, errors, warnings, logs;
690
+ var libraryId, objectId, writeToken, _ref5$access, access, _ref5$jobIndexes, jobIndexes, writeTokenSupplied, lastJobOfferingsInfo, offeringKey, prepSpecs, masterVersionHashes, authorizationTokens, headers, breadCrumb, breadCrumbHash, lroWorkingDraft, breadCrumbDraft, finalizeResponse, nodeUrl, _yield$this$CallBitco3, data, errors, warnings, logs;
670
691
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
671
692
  while (1) switch (_context4.prev = _context4.next) {
672
693
  case 0:
@@ -675,29 +696,28 @@ exports.StartABRMezzanineJobs = /*#__PURE__*/function () {
675
696
  libraryId: libraryId,
676
697
  objectId: objectId
677
698
  });
678
- if (writeToken) {
679
- ValidateWriteToken(writeToken);
680
- if (!objectId) {
681
- objectId = this.utils.DecodeWriteToken(writeToken).objectId;
682
- }
699
+ writeTokenSupplied = !!writeToken;
700
+ if (writeTokenSupplied) {
701
+ ValidateWriteToken(writeToken, objectId);
702
+ objectId = objectId || this.utils.DecodeWriteToken(writeToken).objectId;
683
703
  }
684
- _context4.next = 5;
704
+ _context4.next = 6;
685
705
  return this.ContentObjectMetadata({
686
706
  libraryId: libraryId,
687
707
  objectId: objectId,
688
708
  writeToken: writeToken,
689
709
  metadataSubtree: UrlJoin("abr_mezzanine", "offerings")
690
710
  });
691
- case 5:
711
+ case 6:
692
712
  lastJobOfferingsInfo = _context4.sent;
693
713
  offeringKey = MezJobMainOfferingKey(lastJobOfferingsInfo);
694
714
  prepSpecs = lastJobOfferingsInfo[offeringKey].mez_prep_specs;
695
715
  if (prepSpecs) {
696
- _context4.next = 10;
716
+ _context4.next = 11;
697
717
  break;
698
718
  }
699
719
  throw Error("No stream preparation specs found");
700
- case 10:
720
+ case 11:
701
721
  // Retrieve all masters associated with this offering
702
722
  masterVersionHashes = Object.keys(prepSpecs).map(function (spec) {
703
723
  return (prepSpecs[spec].source_streams || []).map(function (stream) {
@@ -711,7 +731,7 @@ exports.StartABRMezzanineJobs = /*#__PURE__*/function () {
711
731
  });
712
732
 
713
733
  // Retrieve authorization tokens for all masters and the mezzanine
714
- _context4.next = 14;
734
+ _context4.next = 15;
715
735
  return Promise.all(masterVersionHashes.map( /*#__PURE__*/function () {
716
736
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(versionHash) {
717
737
  var payload;
@@ -738,15 +758,15 @@ exports.StartABRMezzanineJobs = /*#__PURE__*/function () {
738
758
  return _ref7.apply(this, arguments);
739
759
  };
740
760
  }()));
741
- case 14:
761
+ case 15:
742
762
  authorizationTokens = _context4.sent;
743
- _context4.next = 17;
763
+ _context4.next = 18;
744
764
  return this.authClient.AuthorizationToken({
745
765
  libraryId: libraryId,
746
766
  objectId: objectId,
747
767
  update: true
748
768
  });
749
- case 17:
769
+ case 18:
750
770
  _context4.t0 = _context4.sent;
751
771
  authorizationTokens = [_context4.t0].concat(_toConsumableArray(authorizationTokens));
752
772
  headers = {
@@ -754,83 +774,71 @@ exports.StartABRMezzanineJobs = /*#__PURE__*/function () {
754
774
  return "Bearer ".concat(token);
755
775
  }).join(",")
756
776
  };
757
- if (!writeToken) {
758
- _context4.next = 27;
777
+ if (writeTokenSupplied) {
778
+ _context4.next = 36;
759
779
  break;
760
780
  }
761
- _context4.next = 23;
762
- return this.WriteTokenNodeUrlNetwork({
763
- writeToken: writeToken
764
- });
765
- case 23:
766
- nodeUrl = _context4.sent;
767
- processingDraft = {
768
- write_token: writeToken,
769
- nodeUrl: nodeUrl
770
- };
771
- _context4.next = 30;
772
- break;
773
- case 27:
774
- _context4.next = 29;
781
+ _context4.next = 24;
775
782
  return this.EditContentObject({
776
783
  libraryId: libraryId,
777
784
  objectId: objectId
778
785
  });
779
- case 29:
780
- processingDraft = _context4.sent;
781
- case 30:
782
- lroInfo = {
783
- write_token: processingDraft.write_token,
784
- node: processingDraft.nodeUrl,
785
- offering: offeringKey
786
- }; // Update metadata with LRO version write token
787
- if (!writeToken) {
788
- _context4.next = 36;
789
- break;
790
- }
791
- _context4.next = 34;
792
- return this.ReplaceMetadata({
793
- libraryId: libraryId,
794
- objectId: objectId,
795
- writeToken: writeToken,
796
- metadataSubtree: "lro_draft",
797
- metadata: lroInfo
798
- });
799
- case 34:
800
- _context4.next = 44;
801
- break;
802
- case 36:
803
- _context4.next = 38;
786
+ case 24:
787
+ lroWorkingDraft = _context4.sent;
788
+ writeToken = lroWorkingDraft.writeToken;
789
+
790
+ // Save this write token (and node url, and offering key) to ANOTHER, NEW write token in order to
791
+ // record "bread crumb" metadata at /lro_draft, and save (finalize) this second write token
792
+ _context4.next = 28;
804
793
  return this.EditContentObject({
805
794
  libraryId: libraryId,
806
795
  objectId: objectId
807
796
  });
808
- case 38:
809
- statusDraft = _context4.sent;
810
- _context4.next = 41;
797
+ case 28:
798
+ breadCrumbDraft = _context4.sent;
799
+ breadCrumb = {
800
+ write_token: lroWorkingDraft.writeToken,
801
+ node: lroWorkingDraft.nodeUrl,
802
+ offering: offeringKey
803
+ };
804
+ _context4.next = 32;
811
805
  return this.ReplaceMetadata({
812
806
  libraryId: libraryId,
813
807
  objectId: objectId,
814
- writeToken: statusDraft.write_token,
808
+ writeToken: breadCrumbDraft.writeToken,
815
809
  metadataSubtree: "lro_draft",
816
- metadata: lroInfo
810
+ metadata: breadCrumb
817
811
  });
818
- case 41:
819
- _context4.next = 43;
812
+ case 32:
813
+ _context4.next = 34;
820
814
  return this.FinalizeContentObject({
821
815
  libraryId: libraryId,
822
816
  objectId: objectId,
823
- writeToken: statusDraft.write_token,
824
- commitMessage: "Mezzanine LRO status"
817
+ writeToken: breadCrumbDraft.write_token,
818
+ commitMessage: "Save mez LRO write token to /lro_draft"
825
819
  });
826
- case 43:
820
+ case 34:
827
821
  finalizeResponse = _context4.sent;
828
- case 44:
829
- _context4.next = 46;
822
+ breadCrumbHash = finalizeResponse.hash;
823
+ case 36:
824
+ _context4.next = 38;
825
+ return this.WriteTokenNodeUrlNetwork({
826
+ writeToken: writeToken
827
+ });
828
+ case 38:
829
+ nodeUrl = _context4.sent;
830
+ // tell http client what node to contact for this write token
831
+ this.RecordWriteToken({
832
+ writeToken: writeToken,
833
+ fabricNodeUrl: nodeUrl
834
+ });
835
+
836
+ // Make the API call that actually starts the LROs
837
+ _context4.next = 42;
830
838
  return this.CallBitcodeMethod({
831
839
  libraryId: libraryId,
832
840
  objectId: objectId,
833
- writeToken: processingDraft.write_token,
841
+ writeToken: writeToken,
834
842
  headers: headers,
835
843
  method: UrlJoin("media", "abr_mezzanine", "prep_start"),
836
844
  constant: false,
@@ -840,23 +848,23 @@ exports.StartABRMezzanineJobs = /*#__PURE__*/function () {
840
848
  job_indexes: jobIndexes
841
849
  }
842
850
  });
843
- case 46:
851
+ case 42:
844
852
  _yield$this$CallBitco3 = _context4.sent;
845
853
  data = _yield$this$CallBitco3.data;
846
854
  errors = _yield$this$CallBitco3.errors;
847
855
  warnings = _yield$this$CallBitco3.warnings;
848
856
  logs = _yield$this$CallBitco3.logs;
849
857
  return _context4.abrupt("return", {
850
- hash: finalizeResponse ? finalizeResponse.hash : "",
851
- lro_draft: lroInfo,
852
- writeToken: processingDraft.write_token,
853
- nodeUrl: processingDraft.nodeUrl,
858
+ hash: breadCrumbHash,
859
+ lro_draft: breadCrumb,
860
+ writeToken: writeToken,
861
+ nodeUrl: nodeUrl,
854
862
  data: data,
855
863
  logs: logs || [],
856
864
  warnings: warnings || [],
857
865
  errors: errors || []
858
866
  });
859
- case 52:
867
+ case 48:
860
868
  case "end":
861
869
  return _context4.stop();
862
870
  }
@@ -871,6 +879,10 @@ exports.StartABRMezzanineJobs = /*#__PURE__*/function () {
871
879
  * Retrieve node and write token for a mezzanine's current offering preparation job (if any).
872
880
  * Also returns the offering key.
873
881
  *
882
+ * This information is contained in metadata at /lro_draft, in an extra version of the object
883
+ * that gets created and finalized as part of creating a mezzanine. This serves as a "bread crumb trail" to
884
+ * allow users to find the active draft/write token that the ingest LROs are writing to.
885
+ *
874
886
  * @methodGroup ABR Publishing
875
887
  * @namedParams
876
888
  * @param {string} libraryId - ID of the library
@@ -880,16 +892,15 @@ exports.StartABRMezzanineJobs = /*#__PURE__*/function () {
880
892
  */
881
893
  exports.LRODraftInfo = /*#__PURE__*/function () {
882
894
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
883
- var libraryId, objectId, writeToken, standardPathContents, lastJobOfferingsInfo, mainOfferingKey, ready, oldPathContents;
895
+ var libraryId, objectId, standardPathContents, lastJobOfferingsInfo, mainOfferingKey, ready, oldPathContents;
884
896
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
885
897
  while (1) switch (_context5.prev = _context5.next) {
886
898
  case 0:
887
- libraryId = _ref8.libraryId, objectId = _ref8.objectId, writeToken = _ref8.writeToken;
899
+ libraryId = _ref8.libraryId, objectId = _ref8.objectId;
888
900
  _context5.next = 3;
889
901
  return this.ContentObjectMetadata({
890
902
  libraryId: libraryId,
891
903
  objectId: objectId,
892
- writeToken: writeToken,
893
904
  metadataSubtree: "lro_draft"
894
905
  });
895
906
  case 3:
@@ -959,47 +970,67 @@ exports.LRODraftInfo = /*#__PURE__*/function () {
959
970
 
960
971
  /**
961
972
  * Retrieve status information for mezzanine transcoding jobs, aka long running operations (LROs) on the given object.
973
+ * If a write token is passed in, its draft will be checked directly by lookiing at /lro_status.
974
+ * If a write token is not passed in, then the latest version of objectId will be checked for "bread crumb" entry
975
+ * at /lro_draft, to determine the write token that current ingest LRO(s) are writing to.
962
976
  *
963
977
  * @methodGroup ABR Publishing
964
978
  * @namedParams
965
979
  * @param {string} libraryId - ID of the library
966
980
  * @param {string} objectId - ID of the object
981
+ * @param {string=} writeToken - Write token of the active draft (that the transcode LROs are writing to)
967
982
  *
968
983
  * @return {Promise<Object>} - LRO status
969
984
  */
970
985
  exports.LROStatus = /*#__PURE__*/function () {
971
986
  var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref10) {
972
- var libraryId, objectId, writeToken, lroDraft;
987
+ var libraryId, objectId, _ref10$writeToken, writeToken, activeWriteToken, lroDraft, fabricNodeUrl;
973
988
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
974
989
  while (1) switch (_context6.prev = _context6.next) {
975
990
  case 0:
976
- libraryId = _ref10.libraryId, objectId = _ref10.objectId, writeToken = _ref10.writeToken;
991
+ libraryId = _ref10.libraryId, objectId = _ref10.objectId, _ref10$writeToken = _ref10.writeToken, writeToken = _ref10$writeToken === void 0 ? "" : _ref10$writeToken;
977
992
  ValidateParameters({
978
993
  libraryId: libraryId,
979
994
  objectId: objectId
980
995
  });
981
- _context6.next = 4;
996
+ if (!writeToken) {
997
+ _context6.next = 7;
998
+ break;
999
+ }
1000
+ ValidateWriteToken(writeToken, objectId);
1001
+ activeWriteToken = writeToken;
1002
+ _context6.next = 15;
1003
+ break;
1004
+ case 7:
1005
+ _context6.next = 9;
982
1006
  return this.LRODraftInfo({
983
1007
  libraryId: libraryId,
984
- objectId: objectId,
985
- writeToken: writeToken
1008
+ objectId: objectId
986
1009
  });
987
- case 4:
1010
+ case 9:
988
1011
  lroDraft = _context6.sent;
1012
+ activeWriteToken = lroDraft.write_token;
1013
+ _context6.next = 13;
1014
+ return this.WriteTokenNodeUrlNetwork({
1015
+ writeToken: activeWriteToken
1016
+ });
1017
+ case 13:
1018
+ fabricNodeUrl = _context6.sent;
989
1019
  this.RecordWriteToken({
990
1020
  writeToken: lroDraft.write_token,
991
- fabricNodeUrl: lroDraft.node
1021
+ fabricNodeUrl: fabricNodeUrl
992
1022
  });
993
- _context6.next = 8;
1023
+ case 15:
1024
+ _context6.next = 17;
994
1025
  return this.ContentObjectMetadata({
995
1026
  libraryId: libraryId,
996
1027
  objectId: objectId,
997
- writeToken: writeToken,
1028
+ writeToken: activeWriteToken,
998
1029
  metadataSubtree: "lro_status"
999
1030
  });
1000
- case 8:
1031
+ case 17:
1001
1032
  return _context6.abrupt("return", _context6.sent);
1002
- case 9:
1033
+ case 18:
1003
1034
  case "end":
1004
1035
  return _context6.stop();
1005
1036
  }
@@ -1011,13 +1042,17 @@ exports.LROStatus = /*#__PURE__*/function () {
1011
1042
  }();
1012
1043
 
1013
1044
  /**
1014
- * Finalize a mezzanine object after all jobs have finished
1045
+ * Process completed mezzanine transcoding LRO(s), creating the final offering(s) from the transcode(s)
1046
+ * Unless a writeToken is passed in, finalize the mez object working draft as well.
1047
+ *
1048
+ * If a writeToken is not passed in, then it will be retrieved from /lro_draft of most recent version of object.
1049
+ * This is a "bread crumb" entry that gets created by StartABRMezzanineJobs() - unless a writeToken was passed in to StartABRMezzanineJobs() also.
1015
1050
  *
1016
1051
  * @methodGroup ABR Publishing
1017
1052
  * @namedParams
1018
1053
  * @param {string} libraryId - ID of the mezzanine library
1019
1054
  * @param {string} objectId - ID of the mezzanine object
1020
- * @param {string} writeToken - Write token for the mezzanine object. If specified, the object will not be finalized.
1055
+ * @param {string=} writeToken - Write token for the mezzanine object. If specified, the object will not be finalized.
1021
1056
  * @param {function=} preFinalizeFn - A function to call before finalizing changes, to allow further modifications to offering. The function will be invoked with {elvClient, nodeUrl, writeToken} to allow access to the draft and MUST NOT finalize the draft.
1022
1057
  * @param {boolean=} preFinalizeThrow - If set to `true` then any error thrown by preFinalizeFn will not be caught. Otherwise, any exception will be appended to the `warnings` array returned after finalization.
1023
1058
  *
@@ -1025,59 +1060,75 @@ exports.LROStatus = /*#__PURE__*/function () {
1025
1060
  */
1026
1061
  exports.FinalizeABRMezzanine = /*#__PURE__*/function () {
1027
1062
  var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref12) {
1028
- var libraryId, objectId, preFinalizeFn, preFinalizeThrow, writeToken, nodeUrl, lastJobOfferingsInfo, offeringKey, masterHash, authPayload, authorizationTokens, headers, _yield$this$CallBitco4, data, errors, warnings, logs, preFinalizeWarnings, params, finalizeResponse;
1063
+ var libraryId, objectId, preFinalizeFn, preFinalizeThrow, _ref12$writeToken, writeToken, writeTokenSupplied, lroDraft, fabricNodeUrl, lastJobOfferingsInfo, offeringKey, masterHash, masterIdentifier, authorizationTokens, headers, _yield$this$CallBitco4, data, errors, warnings, logs, preFinalizeWarnings, params, finalizeResponse;
1029
1064
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
1030
1065
  while (1) switch (_context7.prev = _context7.next) {
1031
1066
  case 0:
1032
- libraryId = _ref12.libraryId, objectId = _ref12.objectId, preFinalizeFn = _ref12.preFinalizeFn, preFinalizeThrow = _ref12.preFinalizeThrow, writeToken = _ref12.writeToken;
1067
+ libraryId = _ref12.libraryId, objectId = _ref12.objectId, preFinalizeFn = _ref12.preFinalizeFn, preFinalizeThrow = _ref12.preFinalizeThrow, _ref12$writeToken = _ref12.writeToken, writeToken = _ref12$writeToken === void 0 ? "" : _ref12$writeToken;
1033
1068
  ValidateParameters({
1034
1069
  libraryId: libraryId,
1035
1070
  objectId: objectId
1036
1071
  });
1037
- if (writeToken) {
1038
- ValidateWriteToken(writeToken);
1072
+ writeTokenSupplied = !!writeToken;
1073
+ if (!writeTokenSupplied) {
1074
+ _context7.next = 8;
1075
+ break;
1039
1076
  }
1040
- _context7.next = 5;
1077
+ ValidateWriteToken(writeToken, objectId);
1078
+ objectId = objectId || this.utils.DecodeWriteToken(writeToken).objectId;
1079
+ _context7.next = 12;
1080
+ break;
1081
+ case 8:
1082
+ _context7.next = 10;
1083
+ return this.LRODraftInfo({
1084
+ libraryId: libraryId,
1085
+ objectId: objectId
1086
+ });
1087
+ case 10:
1088
+ lroDraft = _context7.sent;
1089
+ writeToken = lroDraft.write_token;
1090
+ case 12:
1091
+ _context7.next = 14;
1041
1092
  return this.WriteTokenNodeUrlNetwork({
1042
1093
  writeToken: writeToken
1043
1094
  });
1044
- case 5:
1045
- nodeUrl = _context7.sent;
1095
+ case 14:
1096
+ fabricNodeUrl = _context7.sent;
1046
1097
  // tell http client what node to contact for this write token
1047
1098
  this.RecordWriteToken({
1048
1099
  writeToken: writeToken,
1049
- fabricNodeUrl: nodeUrl
1100
+ fabricNodeUrl: fabricNodeUrl
1050
1101
  });
1051
- _context7.next = 9;
1102
+ _context7.next = 18;
1052
1103
  return this.ContentObjectMetadata({
1053
1104
  libraryId: libraryId,
1054
1105
  objectId: objectId,
1055
1106
  writeToken: writeToken,
1056
1107
  metadataSubtree: UrlJoin("abr_mezzanine", "offerings")
1057
1108
  });
1058
- case 9:
1109
+ case 18:
1059
1110
  lastJobOfferingsInfo = _context7.sent;
1060
1111
  offeringKey = MezJobMainOfferingKey(lastJobOfferingsInfo);
1061
1112
  masterHash = lastJobOfferingsInfo[offeringKey].prod_master_hash;
1062
- authPayload = {};
1113
+ masterIdentifier = {};
1063
1114
  if (masterHash.startsWith("tqw__")) {
1064
- authPayload["objectId"] = this.utils.DecodeWriteToken(masterHash).objectId;
1115
+ masterIdentifier["objectId"] = this.utils.DecodeWriteToken(masterHash).objectId;
1065
1116
  } else {
1066
- authPayload["versionHash"] = masterHash;
1117
+ masterIdentifier["versionHash"] = masterHash;
1067
1118
  }
1068
1119
 
1069
1120
  // Authorization token for mezzanine and master
1070
- _context7.next = 16;
1121
+ _context7.next = 25;
1071
1122
  return this.authClient.AuthorizationToken({
1072
1123
  libraryId: libraryId,
1073
1124
  objectId: objectId,
1074
1125
  update: true
1075
1126
  });
1076
- case 16:
1127
+ case 25:
1077
1128
  _context7.t0 = _context7.sent;
1078
- _context7.next = 19;
1079
- return this.authClient.AuthorizationToken(_objectSpread({}, authPayload));
1080
- case 19:
1129
+ _context7.next = 28;
1130
+ return this.authClient.AuthorizationToken(_objectSpread({}, masterIdentifier));
1131
+ case 28:
1081
1132
  _context7.t1 = _context7.sent;
1082
1133
  authorizationTokens = [_context7.t0, _context7.t1];
1083
1134
  headers = {
@@ -1085,7 +1136,7 @@ exports.FinalizeABRMezzanine = /*#__PURE__*/function () {
1085
1136
  return "Bearer ".concat(token);
1086
1137
  }).join(",")
1087
1138
  };
1088
- _context7.next = 24;
1139
+ _context7.next = 33;
1089
1140
  return this.CallBitcodeMethod({
1090
1141
  objectId: objectId,
1091
1142
  libraryId: libraryId,
@@ -1094,7 +1145,7 @@ exports.FinalizeABRMezzanine = /*#__PURE__*/function () {
1094
1145
  headers: headers,
1095
1146
  constant: false
1096
1147
  });
1097
- case 24:
1148
+ case 33:
1098
1149
  _yield$this$CallBitco4 = _context7.sent;
1099
1150
  data = _yield$this$CallBitco4.data;
1100
1151
  errors = _yield$this$CallBitco4.errors;
@@ -1102,7 +1153,7 @@ exports.FinalizeABRMezzanine = /*#__PURE__*/function () {
1102
1153
  logs = _yield$this$CallBitco4.logs;
1103
1154
  preFinalizeWarnings = [];
1104
1155
  if (!preFinalizeFn) {
1105
- _context7.next = 44;
1156
+ _context7.next = 53;
1106
1157
  break;
1107
1158
  }
1108
1159
  params = {
@@ -1110,31 +1161,34 @@ exports.FinalizeABRMezzanine = /*#__PURE__*/function () {
1110
1161
  offeringKey: offeringKey,
1111
1162
  writeToken: writeToken
1112
1163
  };
1113
- _context7.prev = 32;
1114
- _context7.next = 35;
1115
- return preFinalizeFn(params);
1116
- case 35:
1164
+ _context7.prev = 41;
1117
1165
  _context7.next = 44;
1166
+ return preFinalizeFn(params);
1167
+ case 44:
1168
+ _context7.next = 53;
1118
1169
  break;
1119
- case 37:
1120
- _context7.prev = 37;
1121
- _context7.t2 = _context7["catch"](32);
1170
+ case 46:
1171
+ _context7.prev = 46;
1172
+ _context7.t2 = _context7["catch"](41);
1122
1173
  if (!preFinalizeThrow) {
1123
- _context7.next = 43;
1174
+ _context7.next = 52;
1124
1175
  break;
1125
1176
  }
1126
1177
  throw new Error("Error running preFinalize function", {
1127
1178
  cause: _context7.t2
1128
1179
  });
1129
- case 43:
1180
+ case 52:
1130
1181
  preFinalizeWarnings = "Error running preFinalize function: ".concat(_context7.t2);
1131
- case 44:
1132
- finalizeResponse = {};
1133
- if (writeToken) {
1134
- _context7.next = 49;
1182
+ case 53:
1183
+ if (!writeTokenSupplied) {
1184
+ _context7.next = 57;
1135
1185
  break;
1136
1186
  }
1137
- _context7.next = 48;
1187
+ _context7.t3 = {};
1188
+ _context7.next = 60;
1189
+ break;
1190
+ case 57:
1191
+ _context7.next = 59;
1138
1192
  return this.FinalizeContentObject({
1139
1193
  libraryId: libraryId,
1140
1194
  objectId: objectId,
@@ -1142,20 +1196,21 @@ exports.FinalizeABRMezzanine = /*#__PURE__*/function () {
1142
1196
  commitMessage: "Finalize ABR mezzanine",
1143
1197
  awaitCommitConfirmation: false
1144
1198
  });
1145
- case 48:
1146
- finalizeResponse = _context7.sent;
1147
- case 49:
1199
+ case 59:
1200
+ _context7.t3 = _context7.sent;
1201
+ case 60:
1202
+ finalizeResponse = _context7.t3;
1148
1203
  return _context7.abrupt("return", _objectSpread({
1149
1204
  data: data,
1150
1205
  logs: logs || [],
1151
1206
  warnings: (warnings || []).concat(preFinalizeWarnings),
1152
1207
  errors: errors || []
1153
1208
  }, finalizeResponse));
1154
- case 50:
1209
+ case 62:
1155
1210
  case "end":
1156
1211
  return _context7.stop();
1157
1212
  }
1158
- }, _callee7, this, [[32, 37]]);
1213
+ }, _callee7, this, [[41, 46]]);
1159
1214
  }));
1160
1215
  return function (_x7) {
1161
1216
  return _ref13.apply(this, arguments);