@webex/calling 3.3.1-next.13 → 3.3.1-next.15

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,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
3
+ var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
4
4
  var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
5
5
  var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
6
6
  var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
@@ -15,7 +15,6 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regene
15
15
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
16
16
  var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
17
17
  var _entries = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/entries"));
18
- var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
19
18
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
20
19
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
21
20
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
@@ -29,7 +28,9 @@ var _Logger = _interopRequireDefault(require("../Logger"));
29
28
  var _constants2 = require("./constants");
30
29
  var _types2 = require("./types");
31
30
  var _Utils = require("../common/Utils");
32
- function ownKeys(e, r) { var t = _Object$keys2(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; }
31
+ var _ExtendedError = _interopRequireDefault(require("../Errors/catalog/ExtendedError"));
32
+ var _types3 = require("../Errors/types");
33
+ 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; }
33
34
  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) { (0, _defineProperty2.default)(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; } /* eslint-disable no-await-in-loop */
34
35
  /**
35
36
  * `ContactsClient` module is designed to offer a set of APIs for retrieving and updating contacts and groups from the contacts-service.
@@ -58,6 +59,7 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
58
59
  _SDKConnector.default.setWebex(webex);
59
60
  }
60
61
  this.webex = this.sdkConnector.getWebex();
62
+ this.webex.internal.dss.register();
61
63
  this.encryptionKeyUrl = '';
62
64
  this.groups = undefined;
63
65
  this.contacts = undefined;
@@ -378,105 +380,85 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
378
380
  }, {
379
381
  key: "fetchContactFromDSS",
380
382
  value: (function () {
381
- var _fetchContactFromDSS = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(contactsDataMap) {
382
- var _this5 = this;
383
- var contactList, dssResult, _loop, i;
384
- return _regenerator.default.wrap(function _callee9$(_context10) {
385
- while (1) switch (_context10.prev = _context10.next) {
383
+ var _fetchContactFromDSS = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(contactsDataMap, id) {
384
+ var contact, contactId, displayName, emails, phoneNumbers, sipAddresses, photos, _contact$additionalIn, department, firstName, identityManager, jobTitle, lastName, manager, _contactsDataMap$cont, contactType, avatarUrlDomain, encryptionKeyUrl, ownerId, groups, avatarURL, addedPhoneNumbers, decryptedPhoneNumbers, addedSipAddresses, decryptedSipAddresses, cloudContact;
385
+ return _regenerator.default.wrap(function _callee9$(_context9) {
386
+ while (1) switch (_context9.prev = _context9.next) {
386
387
  case 0:
387
- contactList = [];
388
- _context10.next = 3;
388
+ _context9.prev = 0;
389
+ _context9.next = 3;
389
390
  return this.webex.internal.dss.lookup({
390
- ids: (0, _keys.default)(contactsDataMap)
391
+ id: id,
392
+ shouldBatch: true
391
393
  });
392
394
  case 3:
393
- dssResult = _context10.sent;
394
- _loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
395
- var contact, contactId, displayName, emails, phoneNumbers, sipAddresses, photos, _contact$additionalIn, department, firstName, identityManager, jobTitle, lastName, manager, _contactsDataMap$cont, contactType, avatarUrlDomain, encryptionKeyUrl, ownerId, groups, avatarURL, addedPhoneNumbers, decryptedPhoneNumbers, addedSipAddresses, decryptedSipAddresses, cloudContact;
396
- return _regenerator.default.wrap(function _loop$(_context9) {
397
- while (1) switch (_context9.prev = _context9.next) {
398
- case 0:
399
- contact = dssResult[i];
400
- contactId = contact.identity;
401
- displayName = contact.displayName, emails = contact.emails, phoneNumbers = contact.phoneNumbers, sipAddresses = contact.sipAddresses, photos = contact.photos;
402
- _contact$additionalIn = contact.additionalInfo, department = _contact$additionalIn.department, firstName = _contact$additionalIn.firstName, identityManager = _contact$additionalIn.identityManager, jobTitle = _contact$additionalIn.jobTitle, lastName = _contact$additionalIn.lastName;
403
- manager = identityManager && identityManager.displayName ? identityManager.displayName : undefined;
404
- _contactsDataMap$cont = contactsDataMap[contactId], contactType = _contactsDataMap$cont.contactType, avatarUrlDomain = _contactsDataMap$cont.avatarUrlDomain, encryptionKeyUrl = _contactsDataMap$cont.encryptionKeyUrl, ownerId = _contactsDataMap$cont.ownerId, groups = _contactsDataMap$cont.groups;
405
- avatarURL = '';
406
- if (photos.length) {
407
- avatarURL = photos[0].value;
408
- }
409
- addedPhoneNumbers = contactsDataMap[contactId].phoneNumbers;
410
- if (!addedPhoneNumbers) {
411
- _context9.next = 14;
412
- break;
413
- }
414
- _context9.next = 12;
415
- return _this5.decryptContactDetail(encryptionKeyUrl, addedPhoneNumbers);
416
- case 12:
417
- decryptedPhoneNumbers = _context9.sent;
418
- decryptedPhoneNumbers.forEach(function (number) {
419
- return phoneNumbers.push(number);
420
- });
421
- case 14:
422
- addedSipAddresses = contactsDataMap[contactId].sipAddresses;
423
- if (!addedSipAddresses) {
424
- _context9.next = 20;
425
- break;
426
- }
427
- _context9.next = 18;
428
- return _this5.decryptContactDetail(encryptionKeyUrl, addedSipAddresses);
429
- case 18:
430
- decryptedSipAddresses = _context9.sent;
431
- decryptedSipAddresses.forEach(function (address) {
432
- return sipAddresses.push(address);
433
- });
434
- case 20:
435
- cloudContact = {
436
- avatarUrlDomain: avatarUrlDomain,
437
- avatarURL: avatarURL,
438
- contactId: contactId,
439
- contactType: contactType,
440
- department: department,
441
- displayName: displayName,
442
- emails: emails,
443
- encryptionKeyUrl: encryptionKeyUrl,
444
- firstName: firstName,
445
- groups: groups,
446
- lastName: lastName,
447
- manager: manager,
448
- ownerId: ownerId,
449
- phoneNumbers: phoneNumbers,
450
- sipAddresses: sipAddresses,
451
- title: jobTitle
452
- };
453
- contactList.push(cloudContact);
454
- case 22:
455
- case "end":
456
- return _context9.stop();
457
- }
458
- }, _loop);
395
+ contact = _context9.sent;
396
+ contactId = contact.identity;
397
+ displayName = contact.displayName, emails = contact.emails, phoneNumbers = contact.phoneNumbers, sipAddresses = contact.sipAddresses, photos = contact.photos;
398
+ _contact$additionalIn = contact.additionalInfo, department = _contact$additionalIn.department, firstName = _contact$additionalIn.firstName, identityManager = _contact$additionalIn.identityManager, jobTitle = _contact$additionalIn.jobTitle, lastName = _contact$additionalIn.lastName;
399
+ manager = identityManager && identityManager.displayName ? identityManager.displayName : undefined;
400
+ _contactsDataMap$cont = contactsDataMap[contactId], contactType = _contactsDataMap$cont.contactType, avatarUrlDomain = _contactsDataMap$cont.avatarUrlDomain, encryptionKeyUrl = _contactsDataMap$cont.encryptionKeyUrl, ownerId = _contactsDataMap$cont.ownerId, groups = _contactsDataMap$cont.groups;
401
+ avatarURL = '';
402
+ if (photos.length) {
403
+ avatarURL = photos[0].value;
404
+ }
405
+ addedPhoneNumbers = contactsDataMap[contactId].phoneNumbers;
406
+ if (!addedPhoneNumbers) {
407
+ _context9.next = 17;
408
+ break;
409
+ }
410
+ _context9.next = 15;
411
+ return this.decryptContactDetail(encryptionKeyUrl, addedPhoneNumbers);
412
+ case 15:
413
+ decryptedPhoneNumbers = _context9.sent;
414
+ decryptedPhoneNumbers.forEach(function (number) {
415
+ return phoneNumbers.push(number);
459
416
  });
460
- i = 0;
461
- case 6:
462
- if (!(i < dssResult.length)) {
463
- _context10.next = 11;
417
+ case 17:
418
+ addedSipAddresses = contactsDataMap[contactId].sipAddresses;
419
+ if (!addedSipAddresses) {
420
+ _context9.next = 23;
464
421
  break;
465
422
  }
466
- return _context10.delegateYield(_loop(), "t0", 8);
467
- case 8:
468
- i += 1;
469
- _context10.next = 6;
470
- break;
471
- case 11:
472
- return _context10.abrupt("return", contactList);
473
- case 12:
423
+ _context9.next = 21;
424
+ return this.decryptContactDetail(encryptionKeyUrl, addedSipAddresses);
425
+ case 21:
426
+ decryptedSipAddresses = _context9.sent;
427
+ decryptedSipAddresses.forEach(function (address) {
428
+ return sipAddresses.push(address);
429
+ });
430
+ case 23:
431
+ cloudContact = {
432
+ avatarUrlDomain: avatarUrlDomain,
433
+ avatarURL: avatarURL,
434
+ contactId: contactId,
435
+ contactType: contactType,
436
+ department: department,
437
+ displayName: displayName,
438
+ emails: emails,
439
+ encryptionKeyUrl: encryptionKeyUrl,
440
+ firstName: firstName,
441
+ groups: groups,
442
+ lastName: lastName,
443
+ manager: manager,
444
+ ownerId: ownerId,
445
+ phoneNumbers: phoneNumbers,
446
+ sipAddresses: sipAddresses,
447
+ title: jobTitle
448
+ };
449
+ return _context9.abrupt("return", cloudContact);
450
+ case 27:
451
+ _context9.prev = 27;
452
+ _context9.t0 = _context9["catch"](0);
453
+ _Logger.default.error(new _ExtendedError.default(_context9.t0.message, {}, _types3.ERROR_TYPE.DEFAULT), {});
454
+ return _context9.abrupt("return", null);
455
+ case 31:
474
456
  case "end":
475
- return _context10.stop();
457
+ return _context9.stop();
476
458
  }
477
- }, _callee9, this);
459
+ }, _callee9, this, [[0, 27]]);
478
460
  }));
479
- function fetchContactFromDSS(_x11) {
461
+ function fetchContactFromDSS(_x11, _x12) {
480
462
  return _fetchContactFromDSS.apply(this, arguments);
481
463
  }
482
464
  return fetchContactFromDSS;
@@ -489,10 +471,10 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
489
471
  key: "getContacts",
490
472
  value: (function () {
491
473
  var _getContacts = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
492
- var _this6 = this;
493
- var loggerContext, contactList, contactsDataMap, response, responseBody, contacts, groups, i, contact, decryptedContact, cloudContacts, contactResponse, errorInfo, errorStatus;
494
- return _regenerator.default.wrap(function _callee11$(_context12) {
495
- while (1) switch (_context12.prev = _context12.next) {
474
+ var _this5 = this;
475
+ var loggerContext, contactList, contactsDataMap, response, responseBody, contacts, groups, i, contact, decryptedContact, contactDetails, contactResponse, errorInfo, errorStatus;
476
+ return _regenerator.default.wrap(function _callee11$(_context11) {
477
+ while (1) switch (_context11.prev = _context11.next) {
496
478
  case 0:
497
479
  loggerContext = {
498
480
  file: _constants2.CONTACTS_FILE,
@@ -500,18 +482,18 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
500
482
  };
501
483
  contactList = [];
502
484
  contactsDataMap = {};
503
- _context12.prev = 3;
504
- _context12.next = 6;
485
+ _context11.prev = 3;
486
+ _context11.next = 6;
505
487
  return this.webex.request({
506
488
  // eslint-disable-next-line no-underscore-dangle
507
489
  uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.CONTACT_FILTER),
508
490
  method: _types.HTTP_METHODS.GET
509
491
  });
510
492
  case 6:
511
- response = _context12.sent;
493
+ response = _context11.sent;
512
494
  responseBody = response.body;
513
495
  if (responseBody) {
514
- _context12.next = 10;
496
+ _context11.next = 10;
515
497
  break;
516
498
  }
517
499
  throw new Error("".concat(response));
@@ -520,57 +502,56 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
520
502
  i = 0;
521
503
  case 12:
522
504
  if (!(i < contacts.length)) {
523
- _context12.next = 25;
505
+ _context11.next = 30;
524
506
  break;
525
507
  }
526
508
  contact = contacts[i];
527
509
  if (!(contact.contactType === _types2.ContactType.CUSTOM)) {
528
- _context12.next = 21;
510
+ _context11.next = 21;
529
511
  break;
530
512
  }
531
- _context12.next = 17;
513
+ _context11.next = 17;
532
514
  return this.decryptContact(contact);
533
515
  case 17:
534
- decryptedContact = _context12.sent;
516
+ decryptedContact = _context11.sent;
535
517
  contactList.push(decryptedContact);
536
- _context12.next = 22;
518
+ _context11.next = 27;
537
519
  break;
538
520
  case 21:
539
- if (contact.contactType === _types2.ContactType.CLOUD && contact.contactId) {
540
- contactsDataMap[contact.contactId] = contact;
521
+ if (!(contact.contactType === _types2.ContactType.CLOUD && contact.contactId)) {
522
+ _context11.next = 27;
523
+ break;
541
524
  }
542
- case 22:
543
- i += 1;
544
- _context12.next = 12;
545
- break;
525
+ contactsDataMap[contact.contactId] = contact;
526
+ _context11.next = 25;
527
+ return this.fetchContactFromDSS(contactsDataMap, contact.contactId);
546
528
  case 25:
547
- if (!(0, _keys.default)(contactsDataMap).length) {
548
- _context12.next = 30;
549
- break;
529
+ contactDetails = _context11.sent;
530
+ if (contactDetails) {
531
+ contactList.push(contactDetails);
550
532
  }
551
- _context12.next = 28;
552
- return this.fetchContactFromDSS(contactsDataMap);
553
- case 28:
554
- cloudContacts = _context12.sent;
555
- contactList.push.apply(contactList, (0, _toConsumableArray2.default)(cloudContacts));
533
+ case 27:
534
+ i += 1;
535
+ _context11.next = 12;
536
+ break;
556
537
  case 30:
557
- _context12.next = 32;
538
+ _context11.next = 32;
558
539
  return _promise.default.all(groups.map( /*#__PURE__*/function () {
559
540
  var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(group, idx) {
560
- return _regenerator.default.wrap(function _callee10$(_context11) {
561
- while (1) switch (_context11.prev = _context11.next) {
541
+ return _regenerator.default.wrap(function _callee10$(_context10) {
542
+ while (1) switch (_context10.prev = _context10.next) {
562
543
  case 0:
563
- _context11.next = 2;
564
- return _this6.webex.internal.encryption.decryptText(group.encryptionKeyUrl, group.displayName);
544
+ _context10.next = 2;
545
+ return _this5.webex.internal.encryption.decryptText(group.encryptionKeyUrl, group.displayName);
565
546
  case 2:
566
- groups[idx].displayName = _context11.sent;
547
+ groups[idx].displayName = _context10.sent;
567
548
  case 3:
568
549
  case "end":
569
- return _context11.stop();
550
+ return _context10.stop();
570
551
  }
571
552
  }, _callee10);
572
553
  }));
573
- return function (_x12, _x13) {
554
+ return function (_x13, _x14) {
574
555
  return _ref13.apply(this, arguments);
575
556
  };
576
557
  }()));
@@ -585,16 +566,16 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
585
566
  },
586
567
  message: _constants.SUCCESS_MESSAGE
587
568
  };
588
- return _context12.abrupt("return", contactResponse);
569
+ return _context11.abrupt("return", contactResponse);
589
570
  case 38:
590
- _context12.prev = 38;
591
- _context12.t0 = _context12["catch"](3);
592
- errorInfo = _context12.t0;
571
+ _context11.prev = 38;
572
+ _context11.t0 = _context11["catch"](3);
573
+ errorInfo = _context11.t0;
593
574
  errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
594
- return _context12.abrupt("return", errorStatus);
575
+ return _context11.abrupt("return", errorStatus);
595
576
  case 43:
596
577
  case "end":
597
- return _context12.stop();
578
+ return _context11.stop();
598
579
  }
599
580
  }, _callee11, this, [[3, 38]]);
600
581
  }));
@@ -614,8 +595,8 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
614
595
  value: (function () {
615
596
  var _createNewEncryptionKeyUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
616
597
  var loggerContext, unboundedKeyUri, unboundedKeys;
617
- return _regenerator.default.wrap(function _callee12$(_context13) {
618
- while (1) switch (_context13.prev = _context13.next) {
598
+ return _regenerator.default.wrap(function _callee12$(_context12) {
599
+ while (1) switch (_context12.prev = _context12.next) {
619
600
  case 0:
620
601
  loggerContext = {
621
602
  file: _constants2.CONTACTS_FILE,
@@ -623,20 +604,20 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
623
604
  };
624
605
  unboundedKeyUri = '';
625
606
  _Logger.default.info('Requesting kms for a new KRO and key', loggerContext);
626
- _context13.next = 5;
607
+ _context12.next = 5;
627
608
  return this.webex.internal.encryption.kms.createUnboundKeys({
628
609
  count: 1
629
610
  });
630
611
  case 5:
631
- unboundedKeys = _context13.sent;
612
+ unboundedKeys = _context12.sent;
632
613
  unboundedKeyUri = unboundedKeys[0].uri;
633
614
  this.webex.internal.encryption.kms.createResource({
634
615
  keyUris: [unboundedKeyUri]
635
616
  });
636
- return _context13.abrupt("return", unboundedKeyUri);
617
+ return _context12.abrupt("return", unboundedKeyUri);
637
618
  case 9:
638
619
  case "end":
639
- return _context13.stop();
620
+ return _context12.stop();
640
621
  }
641
622
  }, _callee12, this);
642
623
  }));
@@ -657,14 +638,14 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
657
638
  var _fetchEncryptionKeyUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
658
639
  var _response$data$group;
659
640
  var response, _response$data$group2;
660
- return _regenerator.default.wrap(function _callee13$(_context14) {
661
- while (1) switch (_context14.prev = _context14.next) {
641
+ return _regenerator.default.wrap(function _callee13$(_context13) {
642
+ while (1) switch (_context13.prev = _context13.next) {
662
643
  case 0:
663
644
  if (!this.encryptionKeyUrl) {
664
- _context14.next = 2;
645
+ _context13.next = 2;
665
646
  break;
666
647
  }
667
- return _context14.abrupt("return", this.encryptionKeyUrl);
648
+ return _context13.abrupt("return", this.encryptionKeyUrl);
668
649
  case 2:
669
650
  // istanbul ignore else
670
651
  if (this.groups === undefined) {
@@ -672,30 +653,30 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
672
653
  }
673
654
  // istanbul ignore else
674
655
  if (!(this.groups && this.groups.length)) {
675
- _context14.next = 5;
656
+ _context13.next = 5;
676
657
  break;
677
658
  }
678
- return _context14.abrupt("return", this.groups[0].encryptionKeyUrl);
659
+ return _context13.abrupt("return", this.groups[0].encryptionKeyUrl);
679
660
  case 5:
680
- _context14.next = 7;
661
+ _context13.next = 7;
681
662
  return this.createNewEncryptionKeyUrl();
682
663
  case 7:
683
- this.encryptionKeyUrl = _context14.sent;
664
+ this.encryptionKeyUrl = _context13.sent;
684
665
  _Logger.default.info("Creating a default group: ".concat(_constants2.DEFAULT_GROUP_NAME), {
685
666
  file: _constants2.CONTACTS_FILE,
686
667
  method: this.fetchEncryptionKeyUrl.name
687
668
  });
688
- _context14.next = 11;
669
+ _context13.next = 11;
689
670
  return this.createContactGroup(_constants2.DEFAULT_GROUP_NAME, this.encryptionKeyUrl);
690
671
  case 11:
691
- response = _context14.sent;
672
+ response = _context13.sent;
692
673
  if ((_response$data$group = response.data.group) !== null && _response$data$group !== void 0 && _response$data$group.groupId) {
693
674
  this.defaultGroupId = (_response$data$group2 = response.data.group) === null || _response$data$group2 === void 0 ? void 0 : _response$data$group2.groupId;
694
675
  }
695
- return _context14.abrupt("return", this.encryptionKeyUrl);
676
+ return _context13.abrupt("return", this.encryptionKeyUrl);
696
677
  case 14:
697
678
  case "end":
698
- return _context14.stop();
679
+ return _context13.stop();
699
680
  }
700
681
  }, _callee13, this);
701
682
  }));
@@ -715,55 +696,55 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
715
696
  value: (function () {
716
697
  var _fetchDefaultGroup = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
717
698
  var i, response, group;
718
- return _regenerator.default.wrap(function _callee14$(_context15) {
719
- while (1) switch (_context15.prev = _context15.next) {
699
+ return _regenerator.default.wrap(function _callee14$(_context14) {
700
+ while (1) switch (_context14.prev = _context14.next) {
720
701
  case 0:
721
702
  if (!this.defaultGroupId) {
722
- _context15.next = 2;
703
+ _context14.next = 2;
723
704
  break;
724
705
  }
725
- return _context15.abrupt("return", this.defaultGroupId);
706
+ return _context14.abrupt("return", this.defaultGroupId);
726
707
  case 2:
727
708
  if (!(this.groups && this.groups.length)) {
728
- _context15.next = 11;
709
+ _context14.next = 11;
729
710
  break;
730
711
  }
731
712
  i = 0;
732
713
  case 4:
733
714
  if (!(i < this.groups.length)) {
734
- _context15.next = 11;
715
+ _context14.next = 11;
735
716
  break;
736
717
  }
737
718
  if (!(this.groups[i].displayName === _constants2.DEFAULT_GROUP_NAME)) {
738
- _context15.next = 8;
719
+ _context14.next = 8;
739
720
  break;
740
721
  }
741
722
  this.defaultGroupId = this.groups[i].groupId;
742
- return _context15.abrupt("return", this.defaultGroupId);
723
+ return _context14.abrupt("return", this.defaultGroupId);
743
724
  case 8:
744
725
  i += 1;
745
- _context15.next = 4;
726
+ _context14.next = 4;
746
727
  break;
747
728
  case 11:
748
729
  _Logger.default.info('No default group found.', {
749
730
  file: _constants2.CONTACTS_FILE,
750
731
  method: this.fetchDefaultGroup.name
751
732
  });
752
- _context15.next = 14;
733
+ _context14.next = 14;
753
734
  return this.createContactGroup(_constants2.DEFAULT_GROUP_NAME);
754
735
  case 14:
755
- response = _context15.sent;
736
+ response = _context14.sent;
756
737
  group = response.data.group;
757
738
  if (!group) {
758
- _context15.next = 18;
739
+ _context14.next = 18;
759
740
  break;
760
741
  }
761
- return _context15.abrupt("return", group.groupId);
742
+ return _context14.abrupt("return", group.groupId);
762
743
  case 18:
763
- return _context15.abrupt("return", '');
744
+ return _context14.abrupt("return", '');
764
745
  case 19:
765
746
  case "end":
766
- return _context15.stop();
747
+ return _context14.stop();
767
748
  }
768
749
  }, _callee14, this);
769
750
  }));
@@ -785,45 +766,45 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
785
766
  value: (function () {
786
767
  var _createContactGroup = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(displayName, encryptionKeyUrl, groupType) {
787
768
  var loggerContext, encryptionKeyUrlFinal, isExistingGroup, encryptedDisplayName, groupInfo, _this$groups, response, group, contactResponse, errorInfo, errorStatus;
788
- return _regenerator.default.wrap(function _callee15$(_context16) {
789
- while (1) switch (_context16.prev = _context16.next) {
769
+ return _regenerator.default.wrap(function _callee15$(_context15) {
770
+ while (1) switch (_context15.prev = _context15.next) {
790
771
  case 0:
791
772
  loggerContext = {
792
773
  file: _constants2.CONTACTS_FILE,
793
774
  method: this.createContactGroup.name
794
775
  };
795
776
  _Logger.default.info("Creating contact group ".concat(displayName), loggerContext);
796
- _context16.t0 = encryptionKeyUrl;
797
- if (_context16.t0) {
798
- _context16.next = 7;
777
+ _context15.t0 = encryptionKeyUrl;
778
+ if (_context15.t0) {
779
+ _context15.next = 7;
799
780
  break;
800
781
  }
801
- _context16.next = 6;
782
+ _context15.next = 6;
802
783
  return this.fetchEncryptionKeyUrl();
803
784
  case 6:
804
- _context16.t0 = _context16.sent;
785
+ _context15.t0 = _context15.sent;
805
786
  case 7:
806
- encryptionKeyUrlFinal = _context16.t0;
787
+ encryptionKeyUrlFinal = _context15.t0;
807
788
  if (!(this.groups === undefined)) {
808
- _context16.next = 11;
789
+ _context15.next = 11;
809
790
  break;
810
791
  }
811
- _context16.next = 11;
792
+ _context15.next = 11;
812
793
  return this.getContacts();
813
794
  case 11:
814
795
  if (!(this.groups && this.groups.length)) {
815
- _context16.next = 16;
796
+ _context15.next = 16;
816
797
  break;
817
798
  }
818
799
  isExistingGroup = this.groups.find(function (group) {
819
800
  return group.displayName === displayName;
820
801
  });
821
802
  if (!isExistingGroup) {
822
- _context16.next = 16;
803
+ _context15.next = 16;
823
804
  break;
824
805
  }
825
806
  _Logger.default.warn("Group name ".concat(displayName, " already exists."), loggerContext);
826
- return _context16.abrupt("return", {
807
+ return _context15.abrupt("return", {
827
808
  statusCode: 400,
828
809
  data: {
829
810
  error: 'Group displayName already exists'
@@ -831,18 +812,18 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
831
812
  message: _constants.FAILURE_MESSAGE
832
813
  });
833
814
  case 16:
834
- _context16.next = 18;
815
+ _context15.next = 18;
835
816
  return this.webex.internal.encryption.encryptText(encryptionKeyUrlFinal, displayName);
836
817
  case 18:
837
- encryptedDisplayName = _context16.sent;
818
+ encryptedDisplayName = _context15.sent;
838
819
  groupInfo = {
839
820
  schemas: _constants2.CONTACTS_SCHEMA,
840
821
  displayName: encryptedDisplayName,
841
822
  groupType: groupType || _types2.GroupType.NORMAL,
842
823
  encryptionKeyUrl: encryptionKeyUrlFinal
843
824
  };
844
- _context16.prev = 20;
845
- _context16.next = 23;
825
+ _context15.prev = 20;
826
+ _context15.next = 23;
846
827
  return this.webex.request({
847
828
  // eslint-disable-next-line no-underscore-dangle
848
829
  uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.GROUP_FILTER),
@@ -850,7 +831,7 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
850
831
  body: groupInfo
851
832
  });
852
833
  case 23:
853
- response = _context16.sent;
834
+ response = _context15.sent;
854
835
  group = response.body;
855
836
  group.displayName = displayName;
856
837
  contactResponse = {
@@ -861,21 +842,21 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
861
842
  message: _constants.SUCCESS_MESSAGE
862
843
  };
863
844
  (_this$groups = this.groups) === null || _this$groups === void 0 ? void 0 : _this$groups.push(group);
864
- return _context16.abrupt("return", contactResponse);
845
+ return _context15.abrupt("return", contactResponse);
865
846
  case 31:
866
- _context16.prev = 31;
867
- _context16.t1 = _context16["catch"](20);
847
+ _context15.prev = 31;
848
+ _context15.t1 = _context15["catch"](20);
868
849
  _Logger.default.warn('Unable to create contact group.', loggerContext);
869
- errorInfo = _context16.t1;
850
+ errorInfo = _context15.t1;
870
851
  errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
871
- return _context16.abrupt("return", errorStatus);
852
+ return _context15.abrupt("return", errorStatus);
872
853
  case 37:
873
854
  case "end":
874
- return _context16.stop();
855
+ return _context15.stop();
875
856
  }
876
857
  }, _callee15, this, [[20, 31]]);
877
858
  }));
878
- function createContactGroup(_x14, _x15, _x16) {
859
+ function createContactGroup(_x15, _x16, _x17) {
879
860
  return _createContactGroup.apply(this, arguments);
880
861
  }
881
862
  return createContactGroup;
@@ -890,23 +871,23 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
890
871
  value: (function () {
891
872
  var _deleteContactGroup = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(groupId) {
892
873
  var loggerContext, _this$groups2, _this$groups4, response, contactResponse, groupToDelete, _this$groups3, errorInfo, errorStatus;
893
- return _regenerator.default.wrap(function _callee16$(_context17) {
894
- while (1) switch (_context17.prev = _context17.next) {
874
+ return _regenerator.default.wrap(function _callee16$(_context16) {
875
+ while (1) switch (_context16.prev = _context16.next) {
895
876
  case 0:
896
877
  loggerContext = {
897
878
  file: _constants2.CONTACTS_FILE,
898
879
  method: this.deleteContactGroup.name
899
880
  };
900
- _context17.prev = 1;
881
+ _context16.prev = 1;
901
882
  _Logger.default.info("Deleting contact group: ".concat(groupId), loggerContext);
902
- _context17.next = 5;
883
+ _context16.next = 5;
903
884
  return this.webex.request({
904
885
  // eslint-disable-next-line no-underscore-dangle
905
886
  uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.GROUP_FILTER, "/").concat(groupId),
906
887
  method: _types.HTTP_METHODS.DELETE
907
888
  });
908
889
  case 5:
909
- response = _context17.sent;
890
+ response = _context16.sent;
910
891
  contactResponse = {
911
892
  statusCode: Number(response[_constants.STATUS_CODE]),
912
893
  data: {},
@@ -921,21 +902,21 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
921
902
  if (!((_this$groups4 = this.groups) !== null && _this$groups4 !== void 0 && _this$groups4.length)) {
922
903
  this.defaultGroupId = '';
923
904
  }
924
- return _context17.abrupt("return", contactResponse);
905
+ return _context16.abrupt("return", contactResponse);
925
906
  case 13:
926
- _context17.prev = 13;
927
- _context17.t0 = _context17["catch"](1);
907
+ _context16.prev = 13;
908
+ _context16.t0 = _context16["catch"](1);
928
909
  _Logger.default.warn("Unable to delete contact group ".concat(groupId), loggerContext);
929
- errorInfo = _context17.t0;
910
+ errorInfo = _context16.t0;
930
911
  errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
931
- return _context17.abrupt("return", errorStatus);
912
+ return _context16.abrupt("return", errorStatus);
932
913
  case 19:
933
914
  case "end":
934
- return _context17.stop();
915
+ return _context16.stop();
935
916
  }
936
917
  }, _callee16, this, [[1, 13]]);
937
918
  }));
938
- function deleteContactGroup(_x17) {
919
+ function deleteContactGroup(_x18) {
939
920
  return _deleteContactGroup.apply(this, arguments);
940
921
  }
941
922
  return deleteContactGroup;
@@ -949,54 +930,54 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
949
930
  key: "createContact",
950
931
  value: (function () {
951
932
  var _createContact = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(contactInfo) {
952
- var loggerContext, contact, defaultGroupId, requestBody, encryptedContact, _encryptedContact, response, newContact, contactResponse, decryptedContacts, _this$contacts, _this$contacts2, errorInfo, errorStatus;
953
- return _regenerator.default.wrap(function _callee17$(_context18) {
954
- while (1) switch (_context18.prev = _context18.next) {
933
+ var loggerContext, contact, defaultGroupId, requestBody, encryptedContact, _encryptedContact, response, newContact, contactResponse, decryptedContact, _this$contacts, _this$contacts2, errorInfo, errorStatus;
934
+ return _regenerator.default.wrap(function _callee17$(_context17) {
935
+ while (1) switch (_context17.prev = _context17.next) {
955
936
  case 0:
956
937
  loggerContext = {
957
938
  file: _constants2.CONTACTS_FILE,
958
939
  method: this.createContact.name
959
940
  };
960
941
  _Logger.default.info("Request to create contact: contactType: ".concat(contactInfo.contactType), loggerContext);
961
- _context18.prev = 2;
942
+ _context17.prev = 2;
962
943
  contact = _objectSpread({}, contactInfo);
963
944
  if (contact.encryptionKeyUrl) {
964
- _context18.next = 8;
945
+ _context17.next = 8;
965
946
  break;
966
947
  }
967
- _context18.next = 7;
948
+ _context17.next = 7;
968
949
  return this.fetchEncryptionKeyUrl();
969
950
  case 7:
970
- contact.encryptionKeyUrl = _context18.sent;
951
+ contact.encryptionKeyUrl = _context17.sent;
971
952
  case 8:
972
953
  if (!(!contact.groups || contact.groups.length === 0)) {
973
- _context18.next = 13;
954
+ _context17.next = 13;
974
955
  break;
975
956
  }
976
- _context18.next = 11;
957
+ _context17.next = 11;
977
958
  return this.fetchDefaultGroup();
978
959
  case 11:
979
- defaultGroupId = _context18.sent;
960
+ defaultGroupId = _context17.sent;
980
961
  contact.groups = [defaultGroupId];
981
962
  case 13:
982
963
  contact.schemas = _constants2.CONTACTS_SCHEMA;
983
964
  requestBody = {};
984
- _context18.t0 = contact.contactType;
985
- _context18.next = _context18.t0 === _types2.ContactType.CUSTOM ? 18 : _context18.t0 === _types2.ContactType.CLOUD ? 23 : 30;
965
+ _context17.t0 = contact.contactType;
966
+ _context17.next = _context17.t0 === _types2.ContactType.CUSTOM ? 18 : _context17.t0 === _types2.ContactType.CLOUD ? 23 : 30;
986
967
  break;
987
968
  case 18:
988
- _context18.next = 20;
969
+ _context17.next = 20;
989
970
  return this.encryptContact(contact);
990
971
  case 20:
991
- encryptedContact = _context18.sent;
972
+ encryptedContact = _context17.sent;
992
973
  requestBody = encryptedContact;
993
- return _context18.abrupt("break", 31);
974
+ return _context17.abrupt("break", 31);
994
975
  case 23:
995
976
  if (contact.contactId) {
996
- _context18.next = 25;
977
+ _context17.next = 25;
997
978
  break;
998
979
  }
999
- return _context18.abrupt("return", {
980
+ return _context17.abrupt("return", {
1000
981
  statusCode: 400,
1001
982
  data: {
1002
983
  error: 'contactId is required for contactType:CLOUD.'
@@ -1004,14 +985,14 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
1004
985
  message: _constants.FAILURE_MESSAGE
1005
986
  });
1006
987
  case 25:
1007
- _context18.next = 27;
988
+ _context17.next = 27;
1008
989
  return this.encryptContact(contact);
1009
990
  case 27:
1010
- _encryptedContact = _context18.sent;
991
+ _encryptedContact = _context17.sent;
1011
992
  requestBody = _encryptedContact;
1012
- return _context18.abrupt("break", 31);
993
+ return _context17.abrupt("break", 31);
1013
994
  case 30:
1014
- return _context18.abrupt("return", {
995
+ return _context17.abrupt("return", {
1015
996
  statusCode: 400,
1016
997
  data: {
1017
998
  error: 'Unknown contactType received.'
@@ -1019,7 +1000,7 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
1019
1000
  message: _constants.FAILURE_MESSAGE
1020
1001
  });
1021
1002
  case 31:
1022
- _context18.next = 33;
1003
+ _context17.next = 33;
1023
1004
  return this.webex.request({
1024
1005
  // eslint-disable-next-line no-underscore-dangle
1025
1006
  uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.CONTACT_FILTER),
@@ -1027,7 +1008,7 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
1027
1008
  body: requestBody
1028
1009
  });
1029
1010
  case 33:
1030
- response = _context18.sent;
1011
+ response = _context17.sent;
1031
1012
  newContact = response.body;
1032
1013
  contact.contactId = newContact.contactId;
1033
1014
  contactResponse = {
@@ -1037,40 +1018,40 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
1037
1018
  },
1038
1019
  message: _constants.SUCCESS_MESSAGE
1039
1020
  };
1040
- if (!(contact.contactType === _types2.ContactType.CLOUD)) {
1041
- _context18.next = 44;
1021
+ if (!(contact.contactType === _types2.ContactType.CLOUD && newContact.contactId)) {
1022
+ _context17.next = 44;
1042
1023
  break;
1043
1024
  }
1044
- _context18.next = 40;
1045
- return this.fetchContactFromDSS(Object.fromEntries([[newContact.contactId, newContact]]));
1025
+ _context17.next = 40;
1026
+ return this.fetchContactFromDSS(Object.fromEntries([[newContact.contactId, newContact]]), newContact.contactId);
1046
1027
  case 40:
1047
- decryptedContacts = _context18.sent;
1048
- if (decryptedContacts.length && decryptedContacts[0]) {
1049
- (_this$contacts = this.contacts) === null || _this$contacts === void 0 ? void 0 : _this$contacts.push(decryptedContacts[0]);
1028
+ decryptedContact = _context17.sent;
1029
+ if (decryptedContact) {
1030
+ (_this$contacts = this.contacts) === null || _this$contacts === void 0 ? void 0 : _this$contacts.push(decryptedContact);
1050
1031
  }
1051
- _context18.next = 45;
1032
+ _context17.next = 45;
1052
1033
  break;
1053
1034
  case 44:
1054
1035
  (_this$contacts2 = this.contacts) === null || _this$contacts2 === void 0 ? void 0 : _this$contacts2.push(contact);
1055
1036
  case 45:
1056
- return _context18.abrupt("return", contactResponse);
1037
+ return _context17.abrupt("return", contactResponse);
1057
1038
  case 48:
1058
- _context18.prev = 48;
1059
- _context18.t1 = _context18["catch"](2);
1039
+ _context17.prev = 48;
1040
+ _context17.t1 = _context17["catch"](2);
1060
1041
  _Logger.default.warn('Failed to create contact.', {
1061
1042
  file: _constants2.CONTACTS_FILE,
1062
1043
  method: this.createContact.name
1063
1044
  });
1064
- errorInfo = _context18.t1;
1045
+ errorInfo = _context17.t1;
1065
1046
  errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
1066
- return _context18.abrupt("return", errorStatus);
1047
+ return _context17.abrupt("return", errorStatus);
1067
1048
  case 54:
1068
1049
  case "end":
1069
- return _context18.stop();
1050
+ return _context17.stop();
1070
1051
  }
1071
1052
  }, _callee17, this, [[2, 48]]);
1072
1053
  }));
1073
- function createContact(_x18) {
1054
+ function createContact(_x19) {
1074
1055
  return _createContact.apply(this, arguments);
1075
1056
  }
1076
1057
  return createContact;
@@ -1085,23 +1066,23 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
1085
1066
  value: (function () {
1086
1067
  var _deleteContact = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(contactId) {
1087
1068
  var loggerContext, _this$contacts3, response, contactResponse, contactToDelete, _this$contacts4, errorInfo, errorStatus;
1088
- return _regenerator.default.wrap(function _callee18$(_context19) {
1089
- while (1) switch (_context19.prev = _context19.next) {
1069
+ return _regenerator.default.wrap(function _callee18$(_context18) {
1070
+ while (1) switch (_context18.prev = _context18.next) {
1090
1071
  case 0:
1091
1072
  loggerContext = {
1092
1073
  file: _constants2.CONTACTS_FILE,
1093
1074
  method: this.deleteContact.name
1094
1075
  };
1095
- _context19.prev = 1;
1076
+ _context18.prev = 1;
1096
1077
  _Logger.default.info("Deleting contact : ".concat(contactId), loggerContext);
1097
- _context19.next = 5;
1078
+ _context18.next = 5;
1098
1079
  return this.webex.request({
1099
1080
  // eslint-disable-next-line no-underscore-dangle
1100
1081
  uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.CONTACT_FILTER, "/").concat(contactId),
1101
1082
  method: _types.HTTP_METHODS.DELETE
1102
1083
  });
1103
1084
  case 5:
1104
- response = _context19.sent;
1085
+ response = _context18.sent;
1105
1086
  contactResponse = {
1106
1087
  statusCode: Number(response[_constants.STATUS_CODE]),
1107
1088
  data: {},
@@ -1113,21 +1094,21 @@ var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
1113
1094
  if (contactToDelete !== undefined && contactToDelete !== -1) {
1114
1095
  (_this$contacts4 = this.contacts) === null || _this$contacts4 === void 0 ? void 0 : _this$contacts4.splice(contactToDelete, 1);
1115
1096
  }
1116
- return _context19.abrupt("return", contactResponse);
1097
+ return _context18.abrupt("return", contactResponse);
1117
1098
  case 12:
1118
- _context19.prev = 12;
1119
- _context19.t0 = _context19["catch"](1);
1099
+ _context18.prev = 12;
1100
+ _context18.t0 = _context18["catch"](1);
1120
1101
  _Logger.default.warn("Unable to delete contact ".concat(contactId), loggerContext);
1121
- errorInfo = _context19.t0;
1102
+ errorInfo = _context18.t0;
1122
1103
  errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
1123
- return _context19.abrupt("return", errorStatus);
1104
+ return _context18.abrupt("return", errorStatus);
1124
1105
  case 18:
1125
1106
  case "end":
1126
- return _context19.stop();
1107
+ return _context18.stop();
1127
1108
  }
1128
1109
  }, _callee18, this, [[1, 12]]);
1129
1110
  }));
1130
- function deleteContact(_x19) {
1111
+ function deleteContact(_x20) {
1131
1112
  return _deleteContact.apply(this, arguments);
1132
1113
  }
1133
1114
  return deleteContact;