@webex/calling 3.10.0 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module/CallHistory/CallHistory.js +20 -11
- package/dist/module/CallSettings/UcmBackendConnector.js +21 -8
- package/dist/module/CallSettings/WxCallBackendConnector.js +10 -15
- package/dist/module/CallingClient/CallingClient.js +83 -123
- package/dist/module/CallingClient/calling/call.js +73 -58
- package/dist/module/CallingClient/calling/callManager.js +7 -0
- package/dist/module/CallingClient/constants.js +3 -0
- package/dist/module/CallingClient/registration/register.js +85 -5
- package/dist/module/CallingClient/registration/webWorker.js +2 -2
- package/dist/module/CallingClient/registration/webWorkerStr.js +2 -2
- package/dist/module/Contacts/ContactsClient.js +19 -25
- package/dist/module/Events/impl/index.js +1 -1
- package/dist/module/Logger/index.js +2 -2
- package/dist/module/Voicemail/BroadworksBackendConnector.js +10 -18
- package/dist/module/Voicemail/UcmBackendConnector.js +7 -11
- package/dist/module/Voicemail/Voicemail.js +42 -68
- package/dist/module/Voicemail/WxCallBackendConnector.js +14 -28
- package/dist/module/common/Utils.js +31 -5
- package/dist/module/common/constants.js +2 -0
- package/dist/module/common/testUtil.js +1 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
- package/dist/types/CallSettings/UcmBackendConnector.d.ts +1 -0
- package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts +4 -0
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +3 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +4 -0
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +6 -0
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
- package/dist/types/Contacts/ContactsClient.d.ts +1 -0
- package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
- package/dist/types/Logger/index.d.ts +1 -2
- package/dist/types/Logger/index.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +16 -0
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +1 -1
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/constants.d.ts +2 -0
- package/dist/types/common/constants.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +1 -0
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/CallHistory/CallHistory.js +0 -584
- package/dist/CallHistory/CallHistory.js.map +0 -1
- package/dist/CallHistory/CallHistory.test.js +0 -813
- package/dist/CallHistory/CallHistory.test.js.map +0 -1
- package/dist/CallHistory/callHistoryFixtures.js +0 -650
- package/dist/CallHistory/callHistoryFixtures.js.map +0 -1
- package/dist/CallHistory/constants.js +0 -38
- package/dist/CallHistory/constants.js.map +0 -1
- package/dist/CallHistory/types.js +0 -7
- package/dist/CallHistory/types.js.map +0 -1
- package/dist/CallSettings/CallSettings.js +0 -312
- package/dist/CallSettings/CallSettings.js.map +0 -1
- package/dist/CallSettings/CallSettings.test.js +0 -122
- package/dist/CallSettings/CallSettings.test.js.map +0 -1
- package/dist/CallSettings/UcmBackendConnector.js +0 -261
- package/dist/CallSettings/UcmBackendConnector.js.map +0 -1
- package/dist/CallSettings/UcmBackendConnector.test.js +0 -321
- package/dist/CallSettings/UcmBackendConnector.test.js.map +0 -1
- package/dist/CallSettings/WxCallBackendConnector.js +0 -604
- package/dist/CallSettings/WxCallBackendConnector.js.map +0 -1
- package/dist/CallSettings/WxCallBackendConnector.test.js +0 -905
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +0 -1
- package/dist/CallSettings/constants.js +0 -31
- package/dist/CallSettings/constants.js.map +0 -1
- package/dist/CallSettings/testFixtures.js +0 -68
- package/dist/CallSettings/testFixtures.js.map +0 -1
- package/dist/CallSettings/types.js +0 -7
- package/dist/CallSettings/types.js.map +0 -1
- package/dist/CallingClient/CallingClient.js +0 -1071
- package/dist/CallingClient/CallingClient.js.map +0 -1
- package/dist/CallingClient/CallingClient.test.js +0 -1289
- package/dist/CallingClient/CallingClient.test.js.map +0 -1
- package/dist/CallingClient/callRecordFixtures.js +0 -101
- package/dist/CallingClient/callRecordFixtures.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/index.js +0 -276
- package/dist/CallingClient/calling/CallerId/index.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/index.test.js +0 -275
- package/dist/CallingClient/calling/CallerId/index.test.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/types.js +0 -7
- package/dist/CallingClient/calling/CallerId/types.js.map +0 -1
- package/dist/CallingClient/calling/call.js +0 -3444
- package/dist/CallingClient/calling/call.js.map +0 -1
- package/dist/CallingClient/calling/call.test.js +0 -3260
- package/dist/CallingClient/calling/call.test.js.map +0 -1
- package/dist/CallingClient/calling/callManager.js +0 -456
- package/dist/CallingClient/calling/callManager.js.map +0 -1
- package/dist/CallingClient/calling/callManager.test.js +0 -741
- package/dist/CallingClient/calling/callManager.test.js.map +0 -1
- package/dist/CallingClient/calling/index.js +0 -30
- package/dist/CallingClient/calling/index.js.map +0 -1
- package/dist/CallingClient/calling/types.js +0 -74
- package/dist/CallingClient/calling/types.js.map +0 -1
- package/dist/CallingClient/callingClientFixtures.js +0 -143
- package/dist/CallingClient/callingClientFixtures.js.map +0 -1
- package/dist/CallingClient/constants.js +0 -237
- package/dist/CallingClient/constants.js.map +0 -1
- package/dist/CallingClient/line/index.js +0 -349
- package/dist/CallingClient/line/index.js.map +0 -1
- package/dist/CallingClient/line/line.test.js +0 -327
- package/dist/CallingClient/line/line.test.js.map +0 -1
- package/dist/CallingClient/line/types.js +0 -21
- package/dist/CallingClient/line/types.js.map +0 -1
- package/dist/CallingClient/registration/index.js +0 -19
- package/dist/CallingClient/registration/index.js.map +0 -1
- package/dist/CallingClient/registration/register.js +0 -1538
- package/dist/CallingClient/registration/register.js.map +0 -1
- package/dist/CallingClient/registration/register.test.js +0 -1537
- package/dist/CallingClient/registration/register.test.js.map +0 -1
- package/dist/CallingClient/registration/registerFixtures.js +0 -36
- package/dist/CallingClient/registration/registerFixtures.js.map +0 -1
- package/dist/CallingClient/registration/types.js +0 -7
- package/dist/CallingClient/registration/types.js.map +0 -1
- package/dist/CallingClient/registration/webWorker.js +0 -130
- package/dist/CallingClient/registration/webWorker.js.map +0 -1
- package/dist/CallingClient/registration/webWorker.test.js +0 -303
- package/dist/CallingClient/registration/webWorker.test.js.map +0 -1
- package/dist/CallingClient/registration/webWorkerStr.js +0 -15
- package/dist/CallingClient/registration/webWorkerStr.js.map +0 -1
- package/dist/CallingClient/types.js +0 -7
- package/dist/CallingClient/types.js.map +0 -1
- package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +0 -142
- package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +0 -1
- package/dist/Contacts/ContactsClient.js +0 -1215
- package/dist/Contacts/ContactsClient.js.map +0 -1
- package/dist/Contacts/ContactsClient.test.js +0 -1003
- package/dist/Contacts/ContactsClient.test.js.map +0 -1
- package/dist/Contacts/constants.js +0 -40
- package/dist/Contacts/constants.js.map +0 -1
- package/dist/Contacts/contactFixtures.js +0 -430
- package/dist/Contacts/contactFixtures.js.map +0 -1
- package/dist/Contacts/types.js +0 -43
- package/dist/Contacts/types.js.map +0 -1
- package/dist/Errors/catalog/CallError.js +0 -92
- package/dist/Errors/catalog/CallError.js.map +0 -1
- package/dist/Errors/catalog/CallingDeviceError.js +0 -86
- package/dist/Errors/catalog/CallingDeviceError.js.map +0 -1
- package/dist/Errors/catalog/ExtendedError.js +0 -44
- package/dist/Errors/catalog/ExtendedError.js.map +0 -1
- package/dist/Errors/catalog/LineError.js +0 -88
- package/dist/Errors/catalog/LineError.js.map +0 -1
- package/dist/Errors/index.js +0 -28
- package/dist/Errors/index.js.map +0 -1
- package/dist/Errors/types.js +0 -59
- package/dist/Errors/types.js.map +0 -1
- package/dist/Events/impl/index.js +0 -81
- package/dist/Events/impl/index.js.map +0 -1
- package/dist/Events/types.js +0 -107
- package/dist/Events/types.js.map +0 -1
- package/dist/Logger/index.js +0 -228
- package/dist/Logger/index.js.map +0 -1
- package/dist/Logger/index.test.js +0 -87
- package/dist/Logger/index.test.js.map +0 -1
- package/dist/Logger/types.js +0 -34
- package/dist/Logger/types.js.map +0 -1
- package/dist/Metrics/index.js +0 -535
- package/dist/Metrics/index.js.map +0 -1
- package/dist/Metrics/index.test.js +0 -463
- package/dist/Metrics/index.test.js.map +0 -1
- package/dist/Metrics/types.js +0 -64
- package/dist/Metrics/types.js.map +0 -1
- package/dist/SDKConnector/index.js +0 -103
- package/dist/SDKConnector/index.js.map +0 -1
- package/dist/SDKConnector/index.test.js +0 -9
- package/dist/SDKConnector/index.test.js.map +0 -1
- package/dist/SDKConnector/types.js +0 -7
- package/dist/SDKConnector/types.js.map +0 -1
- package/dist/SDKConnector/utils.js +0 -39
- package/dist/SDKConnector/utils.js.map +0 -1
- package/dist/SDKConnector/utils.test.js +0 -9
- package/dist/SDKConnector/utils.test.js.map +0 -1
- package/dist/Voicemail/BroadworksBackendConnector.js +0 -707
- package/dist/Voicemail/BroadworksBackendConnector.js.map +0 -1
- package/dist/Voicemail/BroadworksBackendConnector.test.js +0 -812
- package/dist/Voicemail/BroadworksBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/UcmBackendConnector.js +0 -632
- package/dist/Voicemail/UcmBackendConnector.js.map +0 -1
- package/dist/Voicemail/UcmBackendConnector.test.js +0 -738
- package/dist/Voicemail/UcmBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/Voicemail.js +0 -500
- package/dist/Voicemail/Voicemail.js.map +0 -1
- package/dist/Voicemail/Voicemail.test.js +0 -391
- package/dist/Voicemail/Voicemail.test.js.map +0 -1
- package/dist/Voicemail/WxCallBackendConnector.js +0 -671
- package/dist/Voicemail/WxCallBackendConnector.js.map +0 -1
- package/dist/Voicemail/WxCallBackendConnector.test.js +0 -1199
- package/dist/Voicemail/WxCallBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/constants.js +0 -61
- package/dist/Voicemail/constants.js.map +0 -1
- package/dist/Voicemail/types.js +0 -7
- package/dist/Voicemail/types.js.map +0 -1
- package/dist/Voicemail/voicemailFixture.js +0 -524
- package/dist/Voicemail/voicemailFixture.js.map +0 -1
- package/dist/api.js +0 -157
- package/dist/api.js.map +0 -1
- package/dist/common/Utils.js +0 -1451
- package/dist/common/Utils.js.map +0 -1
- package/dist/common/Utils.test.js +0 -1744
- package/dist/common/Utils.test.js.map +0 -1
- package/dist/common/constants.js +0 -60
- package/dist/common/constants.js.map +0 -1
- package/dist/common/index.js +0 -19
- package/dist/common/index.js.map +0 -1
- package/dist/common/testUtil.js +0 -982
- package/dist/common/testUtil.js.map +0 -1
- package/dist/common/types.js +0 -75
- package/dist/common/types.js.map +0 -1
- package/dist/index.js +0 -321
- package/dist/index.js.map +0 -1
|
@@ -1,1215 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
4
|
-
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
5
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
6
|
-
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
7
|
-
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
8
|
-
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
9
|
-
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
10
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
11
|
-
value: true
|
|
12
|
-
});
|
|
13
|
-
exports.createContactsClient = exports.ContactsClient = void 0;
|
|
14
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
15
|
-
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
16
|
-
var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
|
|
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
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
20
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
21
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
22
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
23
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
24
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
25
|
-
var _constants = require("../common/constants");
|
|
26
|
-
var _types = require("../common/types");
|
|
27
|
-
var _SDKConnector = _interopRequireDefault(require("../SDKConnector"));
|
|
28
|
-
var _Logger = _interopRequireDefault(require("../Logger"));
|
|
29
|
-
var _constants2 = require("./constants");
|
|
30
|
-
var _types2 = require("./types");
|
|
31
|
-
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; }
|
|
33
|
-
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
|
-
* `ContactsClient` module is designed to offer a set of APIs for retrieving and updating contacts and groups from the contacts-service.
|
|
36
|
-
*
|
|
37
|
-
* This code snippet demonstrates how to create an instance of `ContactClient` using webex and logger.
|
|
38
|
-
*
|
|
39
|
-
* Example
|
|
40
|
-
* ```javascript
|
|
41
|
-
* const contactClient = createContactsClient(webex, logger);
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
|
|
45
|
-
/**
|
|
46
|
-
* @ignore
|
|
47
|
-
*/
|
|
48
|
-
function ContactsClient(webex, logger) {
|
|
49
|
-
(0, _classCallCheck2.default)(this, ContactsClient);
|
|
50
|
-
(0, _defineProperty2.default)(this, "sdkConnector", void 0);
|
|
51
|
-
(0, _defineProperty2.default)(this, "encryptionKeyUrl", void 0);
|
|
52
|
-
(0, _defineProperty2.default)(this, "webex", void 0);
|
|
53
|
-
(0, _defineProperty2.default)(this, "groups", void 0);
|
|
54
|
-
(0, _defineProperty2.default)(this, "contacts", void 0);
|
|
55
|
-
(0, _defineProperty2.default)(this, "defaultGroupId", void 0);
|
|
56
|
-
this.sdkConnector = _SDKConnector.default;
|
|
57
|
-
if (!this.sdkConnector.getWebex()) {
|
|
58
|
-
_SDKConnector.default.setWebex(webex);
|
|
59
|
-
}
|
|
60
|
-
this.webex = this.sdkConnector.getWebex();
|
|
61
|
-
this.encryptionKeyUrl = '';
|
|
62
|
-
this.groups = undefined;
|
|
63
|
-
this.contacts = undefined;
|
|
64
|
-
this.defaultGroupId = '';
|
|
65
|
-
_Logger.default.setLogger(logger.level, _constants2.CONTACTS_CLIENT);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Decrypt emails, phoneNumbers, sipAddresses.
|
|
70
|
-
*/
|
|
71
|
-
(0, _createClass2.default)(ContactsClient, [{
|
|
72
|
-
key: "decryptContactDetail",
|
|
73
|
-
value: (function () {
|
|
74
|
-
var _decryptContactDetail = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(encryptionKeyUrl, contactDetails) {
|
|
75
|
-
var _this = this;
|
|
76
|
-
var decryptedContactDetail, decryptedValues;
|
|
77
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
78
|
-
while (1) switch (_context.prev = _context.next) {
|
|
79
|
-
case 0:
|
|
80
|
-
decryptedContactDetail = (0, _toConsumableArray2.default)(contactDetails);
|
|
81
|
-
_context.next = 3;
|
|
82
|
-
return _promise.default.all(decryptedContactDetail.map(function (detail) {
|
|
83
|
-
return _this.webex.internal.encryption.decryptText(encryptionKeyUrl, detail.value);
|
|
84
|
-
}));
|
|
85
|
-
case 3:
|
|
86
|
-
decryptedValues = _context.sent;
|
|
87
|
-
decryptedValues.forEach(function (decryptedValue, index) {
|
|
88
|
-
decryptedContactDetail[index].value = decryptedValue;
|
|
89
|
-
});
|
|
90
|
-
return _context.abrupt("return", decryptedContactDetail);
|
|
91
|
-
case 6:
|
|
92
|
-
case "end":
|
|
93
|
-
return _context.stop();
|
|
94
|
-
}
|
|
95
|
-
}, _callee);
|
|
96
|
-
}));
|
|
97
|
-
function decryptContactDetail(_x, _x2) {
|
|
98
|
-
return _decryptContactDetail.apply(this, arguments);
|
|
99
|
-
}
|
|
100
|
-
return decryptContactDetail;
|
|
101
|
-
}()
|
|
102
|
-
/**
|
|
103
|
-
* Encrypt emails, phoneNumbers, sipAddresses.
|
|
104
|
-
*
|
|
105
|
-
*/
|
|
106
|
-
)
|
|
107
|
-
}, {
|
|
108
|
-
key: "encryptContactDetail",
|
|
109
|
-
value: (function () {
|
|
110
|
-
var _encryptContactDetail = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(encryptionKeyUrl, contactDetails) {
|
|
111
|
-
var _this2 = this;
|
|
112
|
-
var encryptedContactDetail, encryptedValues;
|
|
113
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
114
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
115
|
-
case 0:
|
|
116
|
-
encryptedContactDetail = (0, _toConsumableArray2.default)(contactDetails);
|
|
117
|
-
_context2.next = 3;
|
|
118
|
-
return _promise.default.all(encryptedContactDetail.map(function (detail) {
|
|
119
|
-
return _this2.webex.internal.encryption.encryptText(encryptionKeyUrl, detail.value);
|
|
120
|
-
}));
|
|
121
|
-
case 3:
|
|
122
|
-
encryptedValues = _context2.sent;
|
|
123
|
-
encryptedValues.forEach(function (encryptedValue, index) {
|
|
124
|
-
encryptedContactDetail[index].value = encryptedValue;
|
|
125
|
-
});
|
|
126
|
-
return _context2.abrupt("return", encryptedContactDetail);
|
|
127
|
-
case 6:
|
|
128
|
-
case "end":
|
|
129
|
-
return _context2.stop();
|
|
130
|
-
}
|
|
131
|
-
}, _callee2);
|
|
132
|
-
}));
|
|
133
|
-
function encryptContactDetail(_x3, _x4) {
|
|
134
|
-
return _encryptContactDetail.apply(this, arguments);
|
|
135
|
-
}
|
|
136
|
-
return encryptContactDetail;
|
|
137
|
-
}()
|
|
138
|
-
/**
|
|
139
|
-
* Encrypts a given contact.
|
|
140
|
-
*/
|
|
141
|
-
)
|
|
142
|
-
}, {
|
|
143
|
-
key: "encryptContact",
|
|
144
|
-
value: (function () {
|
|
145
|
-
var _encryptContact = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5(contact) {
|
|
146
|
-
var _this3 = this;
|
|
147
|
-
var encryptionKeyUrl, encryptedContact, encryptionPromises, encryptedFieldsList;
|
|
148
|
-
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
149
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
150
|
-
case 0:
|
|
151
|
-
encryptionKeyUrl = contact.encryptionKeyUrl;
|
|
152
|
-
encryptedContact = _objectSpread({}, contact);
|
|
153
|
-
encryptionPromises = (0, _values.default)(_constants2.encryptedFields).map(/*#__PURE__*/function () {
|
|
154
|
-
var _ref = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4(field) {
|
|
155
|
-
var plaintextAddressInfo, encryptedAddressInfo, encryptedAddressInfoPromises, plainTextDetails, encryptedDetails, encryptedValue;
|
|
156
|
-
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
157
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
158
|
-
case 0:
|
|
159
|
-
_context4.t0 = field;
|
|
160
|
-
_context4.next = _context4.t0 === _constants2.encryptedFields.ADDRESS_INFO ? 3 : _context4.t0 === _constants2.encryptedFields.EMAILS ? 12 : _context4.t0 === _constants2.encryptedFields.PHONE_NUMBERS ? 12 : _context4.t0 === _constants2.encryptedFields.SIP_ADDRESSES ? 12 : 18;
|
|
161
|
-
break;
|
|
162
|
-
case 3:
|
|
163
|
-
plaintextAddressInfo = encryptedContact.addressInfo;
|
|
164
|
-
if (!plaintextAddressInfo) {
|
|
165
|
-
_context4.next = 11;
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
encryptedAddressInfoPromises = (0, _entries.default)(plaintextAddressInfo).map(/*#__PURE__*/function () {
|
|
169
|
-
var _ref3 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3(_ref2) {
|
|
170
|
-
var _ref4, key, value;
|
|
171
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
172
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
173
|
-
case 0:
|
|
174
|
-
_ref4 = (0, _slicedToArray2.default)(_ref2, 2), key = _ref4[0], value = _ref4[1];
|
|
175
|
-
_context3.t0 = key;
|
|
176
|
-
_context3.next = 4;
|
|
177
|
-
return _this3.webex.internal.encryption.encryptText(encryptionKeyUrl, value);
|
|
178
|
-
case 4:
|
|
179
|
-
_context3.t1 = _context3.sent;
|
|
180
|
-
return _context3.abrupt("return", [_context3.t0, _context3.t1]);
|
|
181
|
-
case 6:
|
|
182
|
-
case "end":
|
|
183
|
-
return _context3.stop();
|
|
184
|
-
}
|
|
185
|
-
}, _callee3);
|
|
186
|
-
}));
|
|
187
|
-
return function (_x7) {
|
|
188
|
-
return _ref3.apply(this, arguments);
|
|
189
|
-
};
|
|
190
|
-
}());
|
|
191
|
-
_context4.t1 = Object;
|
|
192
|
-
_context4.next = 9;
|
|
193
|
-
return _promise.default.all(encryptedAddressInfoPromises);
|
|
194
|
-
case 9:
|
|
195
|
-
_context4.t2 = _context4.sent;
|
|
196
|
-
encryptedAddressInfo = _context4.t1.fromEntries.call(_context4.t1, _context4.t2);
|
|
197
|
-
case 11:
|
|
198
|
-
return _context4.abrupt("return", [field, encryptedAddressInfo]);
|
|
199
|
-
case 12:
|
|
200
|
-
plainTextDetails = encryptedContact[field];
|
|
201
|
-
if (!plainTextDetails) {
|
|
202
|
-
_context4.next = 17;
|
|
203
|
-
break;
|
|
204
|
-
}
|
|
205
|
-
_context4.next = 16;
|
|
206
|
-
return _this3.encryptContactDetail(encryptionKeyUrl, plainTextDetails);
|
|
207
|
-
case 16:
|
|
208
|
-
encryptedDetails = _context4.sent;
|
|
209
|
-
case 17:
|
|
210
|
-
return _context4.abrupt("return", [field, encryptedDetails]);
|
|
211
|
-
case 18:
|
|
212
|
-
if (!((0, _values.default)(_constants2.encryptedFields).includes(field) && encryptedContact[field])) {
|
|
213
|
-
_context4.next = 22;
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
_context4.next = 21;
|
|
217
|
-
return _this3.webex.internal.encryption.encryptText(encryptionKeyUrl, encryptedContact[field]);
|
|
218
|
-
case 21:
|
|
219
|
-
encryptedValue = _context4.sent;
|
|
220
|
-
case 22:
|
|
221
|
-
return _context4.abrupt("return", [field, encryptedValue]);
|
|
222
|
-
case 23:
|
|
223
|
-
case "end":
|
|
224
|
-
return _context4.stop();
|
|
225
|
-
}
|
|
226
|
-
}, _callee4);
|
|
227
|
-
}));
|
|
228
|
-
return function (_x6) {
|
|
229
|
-
return _ref.apply(this, arguments);
|
|
230
|
-
};
|
|
231
|
-
}());
|
|
232
|
-
_context5.next = 5;
|
|
233
|
-
return _promise.default.all(encryptionPromises);
|
|
234
|
-
case 5:
|
|
235
|
-
encryptedFieldsList = _context5.sent;
|
|
236
|
-
encryptedFieldsList.forEach(function (_ref5) {
|
|
237
|
-
var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
|
|
238
|
-
field = _ref6[0],
|
|
239
|
-
value = _ref6[1];
|
|
240
|
-
if (value !== undefined) {
|
|
241
|
-
encryptedContact[field] = value;
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
return _context5.abrupt("return", encryptedContact);
|
|
245
|
-
case 8:
|
|
246
|
-
case "end":
|
|
247
|
-
return _context5.stop();
|
|
248
|
-
}
|
|
249
|
-
}, _callee5);
|
|
250
|
-
}));
|
|
251
|
-
function encryptContact(_x5) {
|
|
252
|
-
return _encryptContact.apply(this, arguments);
|
|
253
|
-
}
|
|
254
|
-
return encryptContact;
|
|
255
|
-
}()
|
|
256
|
-
/**
|
|
257
|
-
* Decrypts a given contact.
|
|
258
|
-
*/
|
|
259
|
-
)
|
|
260
|
-
}, {
|
|
261
|
-
key: "decryptContact",
|
|
262
|
-
value: (function () {
|
|
263
|
-
var _decryptContact = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8(contact) {
|
|
264
|
-
var _this4 = this;
|
|
265
|
-
var encryptionKeyUrl, decryptedContact, decryptionPromises, decryptedFieldsList;
|
|
266
|
-
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
267
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
268
|
-
case 0:
|
|
269
|
-
encryptionKeyUrl = contact.encryptionKeyUrl;
|
|
270
|
-
decryptedContact = _objectSpread({}, contact);
|
|
271
|
-
decryptionPromises = (0, _values.default)(_constants2.encryptedFields).map(/*#__PURE__*/function () {
|
|
272
|
-
var _ref7 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7(field) {
|
|
273
|
-
var plaintextAddressInfo, decryptedAddressInfo, decryptedAddressInfoPromises, plainTextDetails, decryptedDetails, decryptedValue;
|
|
274
|
-
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
275
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
276
|
-
case 0:
|
|
277
|
-
_context7.t0 = field;
|
|
278
|
-
_context7.next = _context7.t0 === _constants2.encryptedFields.ADDRESS_INFO ? 3 : _context7.t0 === _constants2.encryptedFields.EMAILS ? 12 : _context7.t0 === _constants2.encryptedFields.PHONE_NUMBERS ? 12 : _context7.t0 === _constants2.encryptedFields.SIP_ADDRESSES ? 12 : 18;
|
|
279
|
-
break;
|
|
280
|
-
case 3:
|
|
281
|
-
plaintextAddressInfo = decryptedContact.addressInfo;
|
|
282
|
-
if (!plaintextAddressInfo) {
|
|
283
|
-
_context7.next = 11;
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
decryptedAddressInfoPromises = (0, _entries.default)(plaintextAddressInfo).map(/*#__PURE__*/function () {
|
|
287
|
-
var _ref9 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6(_ref8) {
|
|
288
|
-
var _ref0, key, value;
|
|
289
|
-
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
290
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
291
|
-
case 0:
|
|
292
|
-
_ref0 = (0, _slicedToArray2.default)(_ref8, 2), key = _ref0[0], value = _ref0[1];
|
|
293
|
-
_context6.t0 = key;
|
|
294
|
-
_context6.next = 4;
|
|
295
|
-
return _this4.webex.internal.encryption.decryptText(encryptionKeyUrl, value);
|
|
296
|
-
case 4:
|
|
297
|
-
_context6.t1 = _context6.sent;
|
|
298
|
-
return _context6.abrupt("return", [_context6.t0, _context6.t1]);
|
|
299
|
-
case 6:
|
|
300
|
-
case "end":
|
|
301
|
-
return _context6.stop();
|
|
302
|
-
}
|
|
303
|
-
}, _callee6);
|
|
304
|
-
}));
|
|
305
|
-
return function (_x0) {
|
|
306
|
-
return _ref9.apply(this, arguments);
|
|
307
|
-
};
|
|
308
|
-
}());
|
|
309
|
-
_context7.t1 = Object;
|
|
310
|
-
_context7.next = 9;
|
|
311
|
-
return _promise.default.all(decryptedAddressInfoPromises);
|
|
312
|
-
case 9:
|
|
313
|
-
_context7.t2 = _context7.sent;
|
|
314
|
-
decryptedAddressInfo = _context7.t1.fromEntries.call(_context7.t1, _context7.t2);
|
|
315
|
-
case 11:
|
|
316
|
-
return _context7.abrupt("return", [field, decryptedAddressInfo]);
|
|
317
|
-
case 12:
|
|
318
|
-
plainTextDetails = decryptedContact[field];
|
|
319
|
-
if (!plainTextDetails) {
|
|
320
|
-
_context7.next = 17;
|
|
321
|
-
break;
|
|
322
|
-
}
|
|
323
|
-
_context7.next = 16;
|
|
324
|
-
return _this4.decryptContactDetail(encryptionKeyUrl, plainTextDetails);
|
|
325
|
-
case 16:
|
|
326
|
-
decryptedDetails = _context7.sent;
|
|
327
|
-
case 17:
|
|
328
|
-
return _context7.abrupt("return", [field, decryptedDetails]);
|
|
329
|
-
case 18:
|
|
330
|
-
if (!((0, _values.default)(_constants2.encryptedFields).includes(field) && decryptedContact[field])) {
|
|
331
|
-
_context7.next = 22;
|
|
332
|
-
break;
|
|
333
|
-
}
|
|
334
|
-
_context7.next = 21;
|
|
335
|
-
return _this4.webex.internal.encryption.decryptText(encryptionKeyUrl, decryptedContact[field]);
|
|
336
|
-
case 21:
|
|
337
|
-
decryptedValue = _context7.sent;
|
|
338
|
-
case 22:
|
|
339
|
-
return _context7.abrupt("return", [field, decryptedValue]);
|
|
340
|
-
case 23:
|
|
341
|
-
case "end":
|
|
342
|
-
return _context7.stop();
|
|
343
|
-
}
|
|
344
|
-
}, _callee7);
|
|
345
|
-
}));
|
|
346
|
-
return function (_x9) {
|
|
347
|
-
return _ref7.apply(this, arguments);
|
|
348
|
-
};
|
|
349
|
-
}());
|
|
350
|
-
_context8.next = 5;
|
|
351
|
-
return _promise.default.all(decryptionPromises);
|
|
352
|
-
case 5:
|
|
353
|
-
decryptedFieldsList = _context8.sent;
|
|
354
|
-
decryptedFieldsList.forEach(function (_ref1) {
|
|
355
|
-
var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
|
|
356
|
-
field = _ref10[0],
|
|
357
|
-
value = _ref10[1];
|
|
358
|
-
if (value !== undefined) {
|
|
359
|
-
decryptedContact[field] = value;
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
return _context8.abrupt("return", decryptedContact);
|
|
363
|
-
case 8:
|
|
364
|
-
case "end":
|
|
365
|
-
return _context8.stop();
|
|
366
|
-
}
|
|
367
|
-
}, _callee8);
|
|
368
|
-
}));
|
|
369
|
-
function decryptContact(_x8) {
|
|
370
|
-
return _decryptContact.apply(this, arguments);
|
|
371
|
-
}
|
|
372
|
-
return decryptContact;
|
|
373
|
-
}())
|
|
374
|
-
}, {
|
|
375
|
-
key: "resolveCloudContacts",
|
|
376
|
-
value: function resolveCloudContacts(contactsDataMap, inputList) {
|
|
377
|
-
var loggerContext = {
|
|
378
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
379
|
-
method: 'resolveCloudContacts'
|
|
380
|
-
};
|
|
381
|
-
var finalContactList = [];
|
|
382
|
-
var resolvedList = [];
|
|
383
|
-
try {
|
|
384
|
-
inputList.Resources.forEach(function (item) {
|
|
385
|
-
resolvedList.push(item.id);
|
|
386
|
-
});
|
|
387
|
-
(0, _values.default)(contactsDataMap).forEach(function (item) {
|
|
388
|
-
var isResolved = resolvedList.some(function (listItem) {
|
|
389
|
-
return listItem === item.contactId;
|
|
390
|
-
});
|
|
391
|
-
if (!isResolved) {
|
|
392
|
-
finalContactList.push(_objectSpread(_objectSpread({}, item), {}, {
|
|
393
|
-
resolved: false
|
|
394
|
-
}));
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
for (var n = 0; n < inputList.Resources.length; n += 1) {
|
|
398
|
-
var _filteredContact$name, _filteredContact$name2, _filteredContact$SCIM, _filteredContact$SCIM2, _filteredContact$SCIM3;
|
|
399
|
-
var filteredContact = inputList.Resources[n];
|
|
400
|
-
var displayName = filteredContact.displayName,
|
|
401
|
-
emails = filteredContact.emails,
|
|
402
|
-
phoneNumbers = filteredContact.phoneNumbers,
|
|
403
|
-
photos = filteredContact.photos;
|
|
404
|
-
var sipAddresses = void 0;
|
|
405
|
-
if (filteredContact[_constants.SCIM_WEBEXIDENTITY_USER]) {
|
|
406
|
-
sipAddresses = filteredContact[_constants.SCIM_WEBEXIDENTITY_USER].sipAddresses;
|
|
407
|
-
}
|
|
408
|
-
var firstName = (_filteredContact$name = filteredContact.name) === null || _filteredContact$name === void 0 ? void 0 : _filteredContact$name.givenName;
|
|
409
|
-
var lastName = (_filteredContact$name2 = filteredContact.name) === null || _filteredContact$name2 === void 0 ? void 0 : _filteredContact$name2.familyName;
|
|
410
|
-
var manager = (_filteredContact$SCIM = filteredContact[_constants.SCIM_ENTERPRISE_USER]) === null || _filteredContact$SCIM === void 0 ? void 0 : (_filteredContact$SCIM2 = _filteredContact$SCIM.manager) === null || _filteredContact$SCIM2 === void 0 ? void 0 : _filteredContact$SCIM2.displayName;
|
|
411
|
-
var department = (_filteredContact$SCIM3 = filteredContact[_constants.SCIM_ENTERPRISE_USER]) === null || _filteredContact$SCIM3 === void 0 ? void 0 : _filteredContact$SCIM3.department;
|
|
412
|
-
var avatarURL = photos !== null && photos !== void 0 && photos.length ? photos[0].value : '';
|
|
413
|
-
var _contactsDataMap$inpu = contactsDataMap[inputList.Resources[n].id],
|
|
414
|
-
contactType = _contactsDataMap$inpu.contactType,
|
|
415
|
-
avatarUrlDomain = _contactsDataMap$inpu.avatarUrlDomain,
|
|
416
|
-
encryptionKeyUrl = _contactsDataMap$inpu.encryptionKeyUrl,
|
|
417
|
-
ownerId = _contactsDataMap$inpu.ownerId,
|
|
418
|
-
groups = _contactsDataMap$inpu.groups;
|
|
419
|
-
var cloudContact = {
|
|
420
|
-
avatarUrlDomain: avatarUrlDomain,
|
|
421
|
-
avatarURL: avatarURL,
|
|
422
|
-
contactId: inputList.Resources[n].id,
|
|
423
|
-
contactType: contactType,
|
|
424
|
-
department: department,
|
|
425
|
-
displayName: displayName,
|
|
426
|
-
emails: emails,
|
|
427
|
-
encryptionKeyUrl: encryptionKeyUrl,
|
|
428
|
-
firstName: firstName,
|
|
429
|
-
groups: groups,
|
|
430
|
-
lastName: lastName,
|
|
431
|
-
manager: manager,
|
|
432
|
-
ownerId: ownerId,
|
|
433
|
-
phoneNumbers: phoneNumbers,
|
|
434
|
-
sipAddresses: sipAddresses,
|
|
435
|
-
resolved: true
|
|
436
|
-
};
|
|
437
|
-
finalContactList.push(cloudContact);
|
|
438
|
-
}
|
|
439
|
-
} catch (error) {
|
|
440
|
-
_Logger.default.warn('Error occurred while parsing resolved contacts', loggerContext);
|
|
441
|
-
return null;
|
|
442
|
-
}
|
|
443
|
-
return finalContactList;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Returns list of contacts.
|
|
448
|
-
*/
|
|
449
|
-
}, {
|
|
450
|
-
key: "getContacts",
|
|
451
|
-
value: (function () {
|
|
452
|
-
var _getContacts = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
|
|
453
|
-
var _this5 = this;
|
|
454
|
-
var loggerContext, contactList, cloudContactsMap, _response$headers, response, responseBody, contacts, groups, contactIdList, totalContacts, MAX_CONTACTS_PER_QUERY, i, contactIdListChunk, query, result, slicedCloudContactsMap, resolvedContacts, contactResponse, errorInfo, extendedError, errorStatus;
|
|
455
|
-
return _regenerator.default.wrap(function _callee1$(_context1) {
|
|
456
|
-
while (1) switch (_context1.prev = _context1.next) {
|
|
457
|
-
case 0:
|
|
458
|
-
loggerContext = {
|
|
459
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
460
|
-
method: _constants2.METHODS.GET_CONTACTS
|
|
461
|
-
};
|
|
462
|
-
_Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
|
|
463
|
-
contactList = [];
|
|
464
|
-
cloudContactsMap = {};
|
|
465
|
-
_context1.prev = 4;
|
|
466
|
-
_context1.next = 7;
|
|
467
|
-
return this.webex.request({
|
|
468
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
469
|
-
uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.CONTACT_FILTER),
|
|
470
|
-
method: _types.HTTP_METHODS.GET
|
|
471
|
-
});
|
|
472
|
-
case 7:
|
|
473
|
-
response = _context1.sent;
|
|
474
|
-
_Logger.default.log("Response code: ".concat(response.statusCode, " and Response trackingId: ").concat(response === null || response === void 0 ? void 0 : (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.trackingid), loggerContext);
|
|
475
|
-
responseBody = response.body;
|
|
476
|
-
if (responseBody) {
|
|
477
|
-
_context1.next = 12;
|
|
478
|
-
break;
|
|
479
|
-
}
|
|
480
|
-
throw new Error("".concat(response));
|
|
481
|
-
case 12:
|
|
482
|
-
contacts = responseBody.contacts, groups = responseBody.groups;
|
|
483
|
-
_context1.next = 15;
|
|
484
|
-
return _promise.default.all(contacts.map(/*#__PURE__*/function () {
|
|
485
|
-
var _ref11 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9(contact) {
|
|
486
|
-
var decryptedContact;
|
|
487
|
-
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
488
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
489
|
-
case 0:
|
|
490
|
-
if (!(contact.contactType === _types2.ContactType.CUSTOM)) {
|
|
491
|
-
_context9.next = 7;
|
|
492
|
-
break;
|
|
493
|
-
}
|
|
494
|
-
_context9.next = 3;
|
|
495
|
-
return _this5.decryptContact(contact);
|
|
496
|
-
case 3:
|
|
497
|
-
decryptedContact = _context9.sent;
|
|
498
|
-
contactList.push(decryptedContact);
|
|
499
|
-
_context9.next = 8;
|
|
500
|
-
break;
|
|
501
|
-
case 7:
|
|
502
|
-
if (contact.contactType === _types2.ContactType.CLOUD && contact.contactId) {
|
|
503
|
-
cloudContactsMap[contact.contactId] = contact;
|
|
504
|
-
}
|
|
505
|
-
case 8:
|
|
506
|
-
case "end":
|
|
507
|
-
return _context9.stop();
|
|
508
|
-
}
|
|
509
|
-
}, _callee9);
|
|
510
|
-
}));
|
|
511
|
-
return function (_x1) {
|
|
512
|
-
return _ref11.apply(this, arguments);
|
|
513
|
-
};
|
|
514
|
-
}()));
|
|
515
|
-
case 15:
|
|
516
|
-
if (!(0, _keys.default)(cloudContactsMap).length) {
|
|
517
|
-
_context1.next = 38;
|
|
518
|
-
break;
|
|
519
|
-
}
|
|
520
|
-
contactIdList = (0, _keys.default)(cloudContactsMap);
|
|
521
|
-
totalContacts = contactIdList.length;
|
|
522
|
-
MAX_CONTACTS_PER_QUERY = 50;
|
|
523
|
-
i = 0;
|
|
524
|
-
case 20:
|
|
525
|
-
if (!(i < totalContacts)) {
|
|
526
|
-
_context1.next = 38;
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
_context1.prev = 21;
|
|
530
|
-
contactIdListChunk = contactIdList.slice(i, i + MAX_CONTACTS_PER_QUERY);
|
|
531
|
-
query = contactIdListChunk.map(function (item) {
|
|
532
|
-
return "".concat(_constants2.SCIM_ID_FILTER, " \"").concat(item, "\"");
|
|
533
|
-
}).join(_constants2.OR);
|
|
534
|
-
_context1.next = 26;
|
|
535
|
-
return (0, _Utils.scimQuery)(query);
|
|
536
|
-
case 26:
|
|
537
|
-
result = _context1.sent;
|
|
538
|
-
slicedCloudContactsMap = Object.fromEntries((0, _entries.default)(cloudContactsMap).slice(i, i + MAX_CONTACTS_PER_QUERY));
|
|
539
|
-
resolvedContacts = this.resolveCloudContacts(slicedCloudContactsMap, result.body);
|
|
540
|
-
if (resolvedContacts) {
|
|
541
|
-
resolvedContacts.forEach(function (item) {
|
|
542
|
-
return contactList.push(item);
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
_context1.next = 35;
|
|
546
|
-
break;
|
|
547
|
-
case 32:
|
|
548
|
-
_context1.prev = 32;
|
|
549
|
-
_context1.t0 = _context1["catch"](21);
|
|
550
|
-
_Logger.default.warn("Error processing contact chunk ".concat(i, "-").concat(i + MAX_CONTACTS_PER_QUERY), loggerContext);
|
|
551
|
-
case 35:
|
|
552
|
-
i += MAX_CONTACTS_PER_QUERY;
|
|
553
|
-
_context1.next = 20;
|
|
554
|
-
break;
|
|
555
|
-
case 38:
|
|
556
|
-
_context1.next = 40;
|
|
557
|
-
return _promise.default.all(groups.map(/*#__PURE__*/function () {
|
|
558
|
-
var _ref12 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0(group, idx) {
|
|
559
|
-
return _regenerator.default.wrap(function _callee0$(_context0) {
|
|
560
|
-
while (1) switch (_context0.prev = _context0.next) {
|
|
561
|
-
case 0:
|
|
562
|
-
_context0.next = 2;
|
|
563
|
-
return _this5.webex.internal.encryption.decryptText(group.encryptionKeyUrl, group.displayName);
|
|
564
|
-
case 2:
|
|
565
|
-
groups[idx].displayName = _context0.sent;
|
|
566
|
-
case 3:
|
|
567
|
-
case "end":
|
|
568
|
-
return _context0.stop();
|
|
569
|
-
}
|
|
570
|
-
}, _callee0);
|
|
571
|
-
}));
|
|
572
|
-
return function (_x10, _x11) {
|
|
573
|
-
return _ref12.apply(this, arguments);
|
|
574
|
-
};
|
|
575
|
-
}()));
|
|
576
|
-
case 40:
|
|
577
|
-
this.groups = groups;
|
|
578
|
-
this.contacts = contactList;
|
|
579
|
-
contactResponse = {
|
|
580
|
-
statusCode: Number(response[_constants.STATUS_CODE]),
|
|
581
|
-
data: {
|
|
582
|
-
contacts: contactList,
|
|
583
|
-
groups: groups
|
|
584
|
-
},
|
|
585
|
-
message: _constants.SUCCESS_MESSAGE
|
|
586
|
-
};
|
|
587
|
-
_Logger.default.log('Successfully fetched contacts and groups', loggerContext);
|
|
588
|
-
return _context1.abrupt("return", contactResponse);
|
|
589
|
-
case 47:
|
|
590
|
-
_context1.prev = 47;
|
|
591
|
-
_context1.t1 = _context1["catch"](4);
|
|
592
|
-
errorInfo = _context1.t1;
|
|
593
|
-
extendedError = new Error("Error fetching contacts: ".concat(_context1.t1));
|
|
594
|
-
_Logger.default.error(extendedError, loggerContext);
|
|
595
|
-
errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
|
|
596
|
-
_context1.next = 55;
|
|
597
|
-
return (0, _Utils.uploadLogs)();
|
|
598
|
-
case 55:
|
|
599
|
-
return _context1.abrupt("return", errorStatus);
|
|
600
|
-
case 56:
|
|
601
|
-
case "end":
|
|
602
|
-
return _context1.stop();
|
|
603
|
-
}
|
|
604
|
-
}, _callee1, this, [[4, 47], [21, 32]]);
|
|
605
|
-
}));
|
|
606
|
-
function getContacts() {
|
|
607
|
-
return _getContacts.apply(this, arguments);
|
|
608
|
-
}
|
|
609
|
-
return getContacts;
|
|
610
|
-
}()
|
|
611
|
-
/**
|
|
612
|
-
* Creates a new KMS Resource Object (KRO) and Content Key (CK) which is used for encryption.
|
|
613
|
-
*
|
|
614
|
-
* @returns EncryptionKeyUrl as a Promise.
|
|
615
|
-
*/
|
|
616
|
-
)
|
|
617
|
-
}, {
|
|
618
|
-
key: "createNewEncryptionKeyUrl",
|
|
619
|
-
value: (function () {
|
|
620
|
-
var _createNewEncryptionKeyUrl = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
|
|
621
|
-
var loggerContext, unboundedKeyUri, unboundedKeys;
|
|
622
|
-
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
623
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
624
|
-
case 0:
|
|
625
|
-
loggerContext = {
|
|
626
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
627
|
-
method: _constants2.METHODS.CREATE_NEW_ENCRYPTION_KEY_URL
|
|
628
|
-
};
|
|
629
|
-
_Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
|
|
630
|
-
unboundedKeyUri = '';
|
|
631
|
-
_Logger.default.info('Requesting kms for a new KRO and key', loggerContext);
|
|
632
|
-
_context10.next = 6;
|
|
633
|
-
return this.webex.internal.encryption.kms.createUnboundKeys({
|
|
634
|
-
count: 1
|
|
635
|
-
});
|
|
636
|
-
case 6:
|
|
637
|
-
unboundedKeys = _context10.sent;
|
|
638
|
-
unboundedKeyUri = unboundedKeys[0].uri;
|
|
639
|
-
this.webex.internal.encryption.kms.createResource({
|
|
640
|
-
keyUris: [unboundedKeyUri]
|
|
641
|
-
});
|
|
642
|
-
return _context10.abrupt("return", unboundedKeyUri);
|
|
643
|
-
case 10:
|
|
644
|
-
case "end":
|
|
645
|
-
return _context10.stop();
|
|
646
|
-
}
|
|
647
|
-
}, _callee10, this);
|
|
648
|
-
}));
|
|
649
|
-
function createNewEncryptionKeyUrl() {
|
|
650
|
-
return _createNewEncryptionKeyUrl.apply(this, arguments);
|
|
651
|
-
}
|
|
652
|
-
return createNewEncryptionKeyUrl;
|
|
653
|
-
}()
|
|
654
|
-
/**
|
|
655
|
-
* Fetches the encryptionKeyUrl from one of the groups. Creates a new key and default group if there is no data.
|
|
656
|
-
*
|
|
657
|
-
* @returns EncryptionKeyUrl as a Promise.
|
|
658
|
-
*/
|
|
659
|
-
)
|
|
660
|
-
}, {
|
|
661
|
-
key: "fetchEncryptionKeyUrl",
|
|
662
|
-
value: (function () {
|
|
663
|
-
var _fetchEncryptionKeyUrl = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
|
|
664
|
-
var _response$data$group;
|
|
665
|
-
var loggerContext, response, _response$data$group2;
|
|
666
|
-
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
667
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
668
|
-
case 0:
|
|
669
|
-
loggerContext = {
|
|
670
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
671
|
-
method: _constants2.METHODS.FETCH_ENCRYPTION_KEY_URL
|
|
672
|
-
};
|
|
673
|
-
_Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
|
|
674
|
-
if (!this.encryptionKeyUrl) {
|
|
675
|
-
_context11.next = 4;
|
|
676
|
-
break;
|
|
677
|
-
}
|
|
678
|
-
return _context11.abrupt("return", this.encryptionKeyUrl);
|
|
679
|
-
case 4:
|
|
680
|
-
// istanbul ignore else
|
|
681
|
-
if (this.groups === undefined) {
|
|
682
|
-
this.getContacts();
|
|
683
|
-
}
|
|
684
|
-
// istanbul ignore else
|
|
685
|
-
if (!(this.groups && this.groups.length)) {
|
|
686
|
-
_context11.next = 7;
|
|
687
|
-
break;
|
|
688
|
-
}
|
|
689
|
-
return _context11.abrupt("return", this.groups[0].encryptionKeyUrl);
|
|
690
|
-
case 7:
|
|
691
|
-
_context11.next = 9;
|
|
692
|
-
return this.createNewEncryptionKeyUrl();
|
|
693
|
-
case 9:
|
|
694
|
-
this.encryptionKeyUrl = _context11.sent;
|
|
695
|
-
_Logger.default.log("Creating a default group: ".concat(_constants2.DEFAULT_GROUP_NAME), {
|
|
696
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
697
|
-
method: this.fetchEncryptionKeyUrl.name
|
|
698
|
-
});
|
|
699
|
-
_context11.next = 13;
|
|
700
|
-
return this.createContactGroup(_constants2.DEFAULT_GROUP_NAME, this.encryptionKeyUrl);
|
|
701
|
-
case 13:
|
|
702
|
-
response = _context11.sent;
|
|
703
|
-
if ((_response$data$group = response.data.group) !== null && _response$data$group !== void 0 && _response$data$group.groupId) {
|
|
704
|
-
this.defaultGroupId = (_response$data$group2 = response.data.group) === null || _response$data$group2 === void 0 ? void 0 : _response$data$group2.groupId;
|
|
705
|
-
_Logger.default.log("Successfully created default group with ID: ".concat(this.defaultGroupId), {
|
|
706
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
707
|
-
method: this.fetchEncryptionKeyUrl.name
|
|
708
|
-
});
|
|
709
|
-
}
|
|
710
|
-
return _context11.abrupt("return", this.encryptionKeyUrl);
|
|
711
|
-
case 16:
|
|
712
|
-
case "end":
|
|
713
|
-
return _context11.stop();
|
|
714
|
-
}
|
|
715
|
-
}, _callee11, this);
|
|
716
|
-
}));
|
|
717
|
-
function fetchEncryptionKeyUrl() {
|
|
718
|
-
return _fetchEncryptionKeyUrl.apply(this, arguments);
|
|
719
|
-
}
|
|
720
|
-
return fetchEncryptionKeyUrl;
|
|
721
|
-
}()
|
|
722
|
-
/**
|
|
723
|
-
* Fetches a default group.
|
|
724
|
-
*
|
|
725
|
-
* @returns GroupId of default group.
|
|
726
|
-
*/
|
|
727
|
-
)
|
|
728
|
-
}, {
|
|
729
|
-
key: "fetchDefaultGroup",
|
|
730
|
-
value: (function () {
|
|
731
|
-
var _fetchDefaultGroup = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
|
|
732
|
-
var loggerContext, i, response, group, groupId;
|
|
733
|
-
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
734
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
735
|
-
case 0:
|
|
736
|
-
loggerContext = {
|
|
737
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
738
|
-
method: _constants2.METHODS.FETCH_DEFAULT_GROUP
|
|
739
|
-
};
|
|
740
|
-
_Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
|
|
741
|
-
if (!this.defaultGroupId) {
|
|
742
|
-
_context12.next = 5;
|
|
743
|
-
break;
|
|
744
|
-
}
|
|
745
|
-
_Logger.default.log("Using existing default group with ID: ".concat(this.defaultGroupId), {
|
|
746
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
747
|
-
method: this.fetchDefaultGroup.name
|
|
748
|
-
});
|
|
749
|
-
return _context12.abrupt("return", this.defaultGroupId);
|
|
750
|
-
case 5:
|
|
751
|
-
if (!(this.groups && this.groups.length)) {
|
|
752
|
-
_context12.next = 15;
|
|
753
|
-
break;
|
|
754
|
-
}
|
|
755
|
-
i = 0;
|
|
756
|
-
case 7:
|
|
757
|
-
if (!(i < this.groups.length)) {
|
|
758
|
-
_context12.next = 15;
|
|
759
|
-
break;
|
|
760
|
-
}
|
|
761
|
-
if (!(this.groups[i].displayName === _constants2.DEFAULT_GROUP_NAME)) {
|
|
762
|
-
_context12.next = 12;
|
|
763
|
-
break;
|
|
764
|
-
}
|
|
765
|
-
this.defaultGroupId = this.groups[i].groupId;
|
|
766
|
-
_Logger.default.log("Found default group with ID: ".concat(this.defaultGroupId), {
|
|
767
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
768
|
-
method: this.fetchDefaultGroup.name
|
|
769
|
-
});
|
|
770
|
-
return _context12.abrupt("return", this.defaultGroupId);
|
|
771
|
-
case 12:
|
|
772
|
-
i += 1;
|
|
773
|
-
_context12.next = 7;
|
|
774
|
-
break;
|
|
775
|
-
case 15:
|
|
776
|
-
_Logger.default.log('No default group found.', {
|
|
777
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
778
|
-
method: this.fetchDefaultGroup.name
|
|
779
|
-
});
|
|
780
|
-
_context12.next = 18;
|
|
781
|
-
return this.createContactGroup(_constants2.DEFAULT_GROUP_NAME);
|
|
782
|
-
case 18:
|
|
783
|
-
response = _context12.sent;
|
|
784
|
-
group = response.data.group;
|
|
785
|
-
if (!group) {
|
|
786
|
-
_context12.next = 24;
|
|
787
|
-
break;
|
|
788
|
-
}
|
|
789
|
-
groupId = group.groupId;
|
|
790
|
-
_Logger.default.log("Successfully created new default group with ID: ".concat(groupId), {
|
|
791
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
792
|
-
method: this.fetchDefaultGroup.name
|
|
793
|
-
});
|
|
794
|
-
return _context12.abrupt("return", groupId);
|
|
795
|
-
case 24:
|
|
796
|
-
return _context12.abrupt("return", '');
|
|
797
|
-
case 25:
|
|
798
|
-
case "end":
|
|
799
|
-
return _context12.stop();
|
|
800
|
-
}
|
|
801
|
-
}, _callee12, this);
|
|
802
|
-
}));
|
|
803
|
-
function fetchDefaultGroup() {
|
|
804
|
-
return _fetchDefaultGroup.apply(this, arguments);
|
|
805
|
-
}
|
|
806
|
-
return fetchDefaultGroup;
|
|
807
|
-
}()
|
|
808
|
-
/**
|
|
809
|
-
* Creates a personal contact group.
|
|
810
|
-
* Also creates a KRO, if there aren't any groups.
|
|
811
|
-
* @param displayName - Name of the group to create.
|
|
812
|
-
* @param encryptionKeyUrl - EncryptionKeyUrl to encrypt the displayName.
|
|
813
|
-
* @param groupType - Type of the group to create.
|
|
814
|
-
*/
|
|
815
|
-
)
|
|
816
|
-
}, {
|
|
817
|
-
key: "createContactGroup",
|
|
818
|
-
value: (function () {
|
|
819
|
-
var _createContactGroup = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13(displayName, encryptionKeyUrl, groupType) {
|
|
820
|
-
var loggerContext, encryptionKeyUrlFinal, isExistingGroup, encryptedDisplayName, groupInfo, _response$headers2, _this$groups, response, group, contactResponse, errorInfo, extendedError, errorStatus;
|
|
821
|
-
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
822
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
823
|
-
case 0:
|
|
824
|
-
loggerContext = {
|
|
825
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
826
|
-
method: _constants2.METHODS.CREATE_CONTACT_GROUP
|
|
827
|
-
};
|
|
828
|
-
_Logger.default.info("".concat(_constants.METHOD_START_MESSAGE, " with displayName: ").concat(displayName), loggerContext);
|
|
829
|
-
_context13.t0 = encryptionKeyUrl;
|
|
830
|
-
if (_context13.t0) {
|
|
831
|
-
_context13.next = 7;
|
|
832
|
-
break;
|
|
833
|
-
}
|
|
834
|
-
_context13.next = 6;
|
|
835
|
-
return this.fetchEncryptionKeyUrl();
|
|
836
|
-
case 6:
|
|
837
|
-
_context13.t0 = _context13.sent;
|
|
838
|
-
case 7:
|
|
839
|
-
encryptionKeyUrlFinal = _context13.t0;
|
|
840
|
-
if (!(this.groups === undefined)) {
|
|
841
|
-
_context13.next = 11;
|
|
842
|
-
break;
|
|
843
|
-
}
|
|
844
|
-
_context13.next = 11;
|
|
845
|
-
return this.getContacts();
|
|
846
|
-
case 11:
|
|
847
|
-
if (!(this.groups && this.groups.length)) {
|
|
848
|
-
_context13.next = 16;
|
|
849
|
-
break;
|
|
850
|
-
}
|
|
851
|
-
isExistingGroup = this.groups.find(function (group) {
|
|
852
|
-
return group.displayName === displayName;
|
|
853
|
-
});
|
|
854
|
-
if (!isExistingGroup) {
|
|
855
|
-
_context13.next = 16;
|
|
856
|
-
break;
|
|
857
|
-
}
|
|
858
|
-
_Logger.default.warn("Group name ".concat(displayName, " already exists."), loggerContext);
|
|
859
|
-
return _context13.abrupt("return", {
|
|
860
|
-
statusCode: 400,
|
|
861
|
-
data: {
|
|
862
|
-
error: 'Group displayName already exists'
|
|
863
|
-
},
|
|
864
|
-
message: _constants.FAILURE_MESSAGE
|
|
865
|
-
});
|
|
866
|
-
case 16:
|
|
867
|
-
_context13.next = 18;
|
|
868
|
-
return this.webex.internal.encryption.encryptText(encryptionKeyUrlFinal, displayName);
|
|
869
|
-
case 18:
|
|
870
|
-
encryptedDisplayName = _context13.sent;
|
|
871
|
-
groupInfo = {
|
|
872
|
-
schemas: _constants2.CONTACTS_SCHEMA,
|
|
873
|
-
displayName: encryptedDisplayName,
|
|
874
|
-
groupType: groupType || _types2.GroupType.NORMAL,
|
|
875
|
-
encryptionKeyUrl: encryptionKeyUrlFinal
|
|
876
|
-
};
|
|
877
|
-
_context13.prev = 20;
|
|
878
|
-
_context13.next = 23;
|
|
879
|
-
return this.webex.request({
|
|
880
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
881
|
-
uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.GROUP_FILTER),
|
|
882
|
-
method: _types.HTTP_METHODS.POST,
|
|
883
|
-
body: groupInfo
|
|
884
|
-
});
|
|
885
|
-
case 23:
|
|
886
|
-
response = _context13.sent;
|
|
887
|
-
_Logger.default.log("Response code: ".concat(response.statusCode), loggerContext);
|
|
888
|
-
_Logger.default.log("Response trackingId: ".concat(response === null || response === void 0 ? void 0 : (_response$headers2 = response.headers) === null || _response$headers2 === void 0 ? void 0 : _response$headers2.trackingid), loggerContext);
|
|
889
|
-
group = response.body;
|
|
890
|
-
group.displayName = displayName;
|
|
891
|
-
contactResponse = {
|
|
892
|
-
statusCode: Number(response[_constants.STATUS_CODE]),
|
|
893
|
-
data: {
|
|
894
|
-
group: group
|
|
895
|
-
},
|
|
896
|
-
message: _constants.SUCCESS_MESSAGE
|
|
897
|
-
};
|
|
898
|
-
(_this$groups = this.groups) === null || _this$groups === void 0 ? void 0 : _this$groups.push(group);
|
|
899
|
-
_Logger.default.log("Contact group ".concat(displayName, " successfully created"), loggerContext);
|
|
900
|
-
return _context13.abrupt("return", contactResponse);
|
|
901
|
-
case 34:
|
|
902
|
-
_context13.prev = 34;
|
|
903
|
-
_context13.t1 = _context13["catch"](20);
|
|
904
|
-
errorInfo = _context13.t1;
|
|
905
|
-
extendedError = new Error("Unable to create contact group: ".concat(_context13.t1));
|
|
906
|
-
_Logger.default.error(extendedError, loggerContext);
|
|
907
|
-
errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
|
|
908
|
-
_context13.next = 42;
|
|
909
|
-
return (0, _Utils.uploadLogs)();
|
|
910
|
-
case 42:
|
|
911
|
-
return _context13.abrupt("return", errorStatus);
|
|
912
|
-
case 43:
|
|
913
|
-
case "end":
|
|
914
|
-
return _context13.stop();
|
|
915
|
-
}
|
|
916
|
-
}, _callee13, this, [[20, 34]]);
|
|
917
|
-
}));
|
|
918
|
-
function createContactGroup(_x12, _x13, _x14) {
|
|
919
|
-
return _createContactGroup.apply(this, arguments);
|
|
920
|
-
}
|
|
921
|
-
return createContactGroup;
|
|
922
|
-
}()
|
|
923
|
-
/**
|
|
924
|
-
* Deletes a contact group.
|
|
925
|
-
* @param groupId - GroupId of the group to delete.
|
|
926
|
-
*/
|
|
927
|
-
)
|
|
928
|
-
}, {
|
|
929
|
-
key: "deleteContactGroup",
|
|
930
|
-
value: (function () {
|
|
931
|
-
var _deleteContactGroup = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14(groupId) {
|
|
932
|
-
var loggerContext, _response$headers3, _this$groups2, _this$groups4, response, contactResponse, groupToDelete, _this$groups3, errorInfo, extendedError, errorStatus;
|
|
933
|
-
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
934
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
935
|
-
case 0:
|
|
936
|
-
loggerContext = {
|
|
937
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
938
|
-
method: _constants2.METHODS.DELETE_CONTACT_GROUP
|
|
939
|
-
};
|
|
940
|
-
_Logger.default.info("".concat(_constants.METHOD_START_MESSAGE, " with groupId: ").concat(groupId), loggerContext);
|
|
941
|
-
_context14.prev = 2;
|
|
942
|
-
_Logger.default.info("Deleting contact group: ".concat(groupId), loggerContext);
|
|
943
|
-
_context14.next = 6;
|
|
944
|
-
return this.webex.request({
|
|
945
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
946
|
-
uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.GROUP_FILTER, "/").concat(groupId),
|
|
947
|
-
method: _types.HTTP_METHODS.DELETE
|
|
948
|
-
});
|
|
949
|
-
case 6:
|
|
950
|
-
response = _context14.sent;
|
|
951
|
-
_Logger.default.log("Response trackingId: ".concat(response === null || response === void 0 ? void 0 : (_response$headers3 = response.headers) === null || _response$headers3 === void 0 ? void 0 : _response$headers3.trackingid), loggerContext);
|
|
952
|
-
contactResponse = {
|
|
953
|
-
statusCode: Number(response[_constants.STATUS_CODE]),
|
|
954
|
-
data: {},
|
|
955
|
-
message: _constants.SUCCESS_MESSAGE
|
|
956
|
-
};
|
|
957
|
-
groupToDelete = (_this$groups2 = this.groups) === null || _this$groups2 === void 0 ? void 0 : _this$groups2.findIndex(function (group) {
|
|
958
|
-
return group.groupId === groupId;
|
|
959
|
-
});
|
|
960
|
-
if (groupToDelete !== undefined && groupToDelete !== -1) {
|
|
961
|
-
(_this$groups3 = this.groups) === null || _this$groups3 === void 0 ? void 0 : _this$groups3.splice(groupToDelete, 1);
|
|
962
|
-
}
|
|
963
|
-
if (!((_this$groups4 = this.groups) !== null && _this$groups4 !== void 0 && _this$groups4.length)) {
|
|
964
|
-
this.defaultGroupId = '';
|
|
965
|
-
}
|
|
966
|
-
_Logger.default.log("Contact group ".concat(groupId, " successfully deleted"), loggerContext);
|
|
967
|
-
return _context14.abrupt("return", contactResponse);
|
|
968
|
-
case 16:
|
|
969
|
-
_context14.prev = 16;
|
|
970
|
-
_context14.t0 = _context14["catch"](2);
|
|
971
|
-
errorInfo = _context14.t0;
|
|
972
|
-
extendedError = new Error("Unable to delete contact group ".concat(groupId, ": ").concat(_context14.t0));
|
|
973
|
-
_Logger.default.error(extendedError, loggerContext);
|
|
974
|
-
errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
|
|
975
|
-
_context14.next = 24;
|
|
976
|
-
return (0, _Utils.uploadLogs)();
|
|
977
|
-
case 24:
|
|
978
|
-
return _context14.abrupt("return", errorStatus);
|
|
979
|
-
case 25:
|
|
980
|
-
case "end":
|
|
981
|
-
return _context14.stop();
|
|
982
|
-
}
|
|
983
|
-
}, _callee14, this, [[2, 16]]);
|
|
984
|
-
}));
|
|
985
|
-
function deleteContactGroup(_x15) {
|
|
986
|
-
return _deleteContactGroup.apply(this, arguments);
|
|
987
|
-
}
|
|
988
|
-
return deleteContactGroup;
|
|
989
|
-
}()
|
|
990
|
-
/**
|
|
991
|
-
* Creates a custom contact.
|
|
992
|
-
* @param contactInfo - Contact object to create.
|
|
993
|
-
*/
|
|
994
|
-
)
|
|
995
|
-
}, {
|
|
996
|
-
key: "createContact",
|
|
997
|
-
value: (function () {
|
|
998
|
-
var _createContact = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15(contactInfo) {
|
|
999
|
-
var loggerContext, _response$headers4, contact, defaultGroupId, requestBody, encryptedContact, _encryptedContact, response, newContact, contactResponse, query, res, resolvedContact, _this$contacts, _this$contacts2, errorInfo, extendedError, errorStatus;
|
|
1000
|
-
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
1001
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
1002
|
-
case 0:
|
|
1003
|
-
loggerContext = {
|
|
1004
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
1005
|
-
method: _constants2.METHODS.CREATE_CONTACT
|
|
1006
|
-
};
|
|
1007
|
-
_Logger.default.info("".concat(_constants.METHOD_START_MESSAGE, " with contactType: ").concat(contactInfo.contactType), loggerContext);
|
|
1008
|
-
_context15.prev = 2;
|
|
1009
|
-
contact = _objectSpread({}, contactInfo);
|
|
1010
|
-
if (contact.encryptionKeyUrl) {
|
|
1011
|
-
_context15.next = 8;
|
|
1012
|
-
break;
|
|
1013
|
-
}
|
|
1014
|
-
_context15.next = 7;
|
|
1015
|
-
return this.fetchEncryptionKeyUrl();
|
|
1016
|
-
case 7:
|
|
1017
|
-
contact.encryptionKeyUrl = _context15.sent;
|
|
1018
|
-
case 8:
|
|
1019
|
-
if (!(!contact.groups || contact.groups.length === 0)) {
|
|
1020
|
-
_context15.next = 13;
|
|
1021
|
-
break;
|
|
1022
|
-
}
|
|
1023
|
-
_context15.next = 11;
|
|
1024
|
-
return this.fetchDefaultGroup();
|
|
1025
|
-
case 11:
|
|
1026
|
-
defaultGroupId = _context15.sent;
|
|
1027
|
-
contact.groups = [defaultGroupId];
|
|
1028
|
-
case 13:
|
|
1029
|
-
contact.schemas = _constants2.CONTACTS_SCHEMA;
|
|
1030
|
-
requestBody = {};
|
|
1031
|
-
_context15.t0 = contact.contactType;
|
|
1032
|
-
_context15.next = _context15.t0 === _types2.ContactType.CUSTOM ? 18 : _context15.t0 === _types2.ContactType.CLOUD ? 23 : 30;
|
|
1033
|
-
break;
|
|
1034
|
-
case 18:
|
|
1035
|
-
_context15.next = 20;
|
|
1036
|
-
return this.encryptContact(contact);
|
|
1037
|
-
case 20:
|
|
1038
|
-
encryptedContact = _context15.sent;
|
|
1039
|
-
requestBody = encryptedContact;
|
|
1040
|
-
return _context15.abrupt("break", 31);
|
|
1041
|
-
case 23:
|
|
1042
|
-
if (contact.contactId) {
|
|
1043
|
-
_context15.next = 25;
|
|
1044
|
-
break;
|
|
1045
|
-
}
|
|
1046
|
-
return _context15.abrupt("return", {
|
|
1047
|
-
statusCode: 400,
|
|
1048
|
-
data: {
|
|
1049
|
-
error: 'contactId is required for contactType:CLOUD.'
|
|
1050
|
-
},
|
|
1051
|
-
message: _constants.FAILURE_MESSAGE
|
|
1052
|
-
});
|
|
1053
|
-
case 25:
|
|
1054
|
-
_context15.next = 27;
|
|
1055
|
-
return this.encryptContact(contact);
|
|
1056
|
-
case 27:
|
|
1057
|
-
_encryptedContact = _context15.sent;
|
|
1058
|
-
requestBody = _encryptedContact;
|
|
1059
|
-
return _context15.abrupt("break", 31);
|
|
1060
|
-
case 30:
|
|
1061
|
-
return _context15.abrupt("return", {
|
|
1062
|
-
statusCode: 400,
|
|
1063
|
-
data: {
|
|
1064
|
-
error: 'Unknown contactType received.'
|
|
1065
|
-
},
|
|
1066
|
-
message: _constants.FAILURE_MESSAGE
|
|
1067
|
-
});
|
|
1068
|
-
case 31:
|
|
1069
|
-
_context15.next = 33;
|
|
1070
|
-
return this.webex.request({
|
|
1071
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
1072
|
-
uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.CONTACT_FILTER),
|
|
1073
|
-
method: _types.HTTP_METHODS.POST,
|
|
1074
|
-
body: requestBody
|
|
1075
|
-
});
|
|
1076
|
-
case 33:
|
|
1077
|
-
response = _context15.sent;
|
|
1078
|
-
_Logger.default.log("Response code: ".concat(response.statusCode), loggerContext);
|
|
1079
|
-
_Logger.default.log("Response trackingId: ".concat(response === null || response === void 0 ? void 0 : (_response$headers4 = response.headers) === null || _response$headers4 === void 0 ? void 0 : _response$headers4.trackingid), loggerContext);
|
|
1080
|
-
newContact = response.body;
|
|
1081
|
-
contact.contactId = newContact.contactId;
|
|
1082
|
-
contactResponse = {
|
|
1083
|
-
statusCode: Number(response[_constants.STATUS_CODE]),
|
|
1084
|
-
data: {
|
|
1085
|
-
contact: contact
|
|
1086
|
-
},
|
|
1087
|
-
message: _constants.SUCCESS_MESSAGE
|
|
1088
|
-
};
|
|
1089
|
-
if (!(contact.contactType === _types2.ContactType.CLOUD && newContact.contactId)) {
|
|
1090
|
-
_context15.next = 48;
|
|
1091
|
-
break;
|
|
1092
|
-
}
|
|
1093
|
-
query = "".concat(_constants2.SCIM_ID_FILTER, " \"").concat(newContact.contactId, "\"");
|
|
1094
|
-
_context15.next = 43;
|
|
1095
|
-
return (0, _Utils.scimQuery)(query);
|
|
1096
|
-
case 43:
|
|
1097
|
-
res = _context15.sent;
|
|
1098
|
-
resolvedContact = this.resolveCloudContacts(Object.fromEntries([[newContact.contactId, newContact]]), res.body);
|
|
1099
|
-
if (resolvedContact) {
|
|
1100
|
-
(_this$contacts = this.contacts) === null || _this$contacts === void 0 ? void 0 : _this$contacts.push(resolvedContact[0]);
|
|
1101
|
-
}
|
|
1102
|
-
_context15.next = 49;
|
|
1103
|
-
break;
|
|
1104
|
-
case 48:
|
|
1105
|
-
(_this$contacts2 = this.contacts) === null || _this$contacts2 === void 0 ? void 0 : _this$contacts2.push(contact);
|
|
1106
|
-
case 49:
|
|
1107
|
-
_Logger.default.log("Contact successfully created", loggerContext);
|
|
1108
|
-
return _context15.abrupt("return", contactResponse);
|
|
1109
|
-
case 53:
|
|
1110
|
-
_context15.prev = 53;
|
|
1111
|
-
_context15.t1 = _context15["catch"](2);
|
|
1112
|
-
errorInfo = _context15.t1;
|
|
1113
|
-
extendedError = new Error("Failed to create contact: ".concat(_context15.t1));
|
|
1114
|
-
_Logger.default.error(extendedError, loggerContext);
|
|
1115
|
-
errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
|
|
1116
|
-
_context15.next = 61;
|
|
1117
|
-
return (0, _Utils.uploadLogs)();
|
|
1118
|
-
case 61:
|
|
1119
|
-
return _context15.abrupt("return", errorStatus);
|
|
1120
|
-
case 62:
|
|
1121
|
-
case "end":
|
|
1122
|
-
return _context15.stop();
|
|
1123
|
-
}
|
|
1124
|
-
}, _callee15, this, [[2, 53]]);
|
|
1125
|
-
}));
|
|
1126
|
-
function createContact(_x16) {
|
|
1127
|
-
return _createContact.apply(this, arguments);
|
|
1128
|
-
}
|
|
1129
|
-
return createContact;
|
|
1130
|
-
}()
|
|
1131
|
-
/**
|
|
1132
|
-
* Delete a contact.
|
|
1133
|
-
* @param contactId - ContactId of the contact to delete.
|
|
1134
|
-
*/
|
|
1135
|
-
)
|
|
1136
|
-
}, {
|
|
1137
|
-
key: "deleteContact",
|
|
1138
|
-
value: (function () {
|
|
1139
|
-
var _deleteContact = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16(contactId) {
|
|
1140
|
-
var loggerContext, _this$contacts3, response, contactResponse, contactToDelete, _this$contacts4, errorInfo, extendedError, errorStatus;
|
|
1141
|
-
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
1142
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
1143
|
-
case 0:
|
|
1144
|
-
loggerContext = {
|
|
1145
|
-
file: _constants2.CONTACTS_CLIENT,
|
|
1146
|
-
method: _constants2.METHODS.DELETE_CONTACT
|
|
1147
|
-
};
|
|
1148
|
-
_Logger.default.info("".concat(_constants.METHOD_START_MESSAGE, " with contactId: ").concat(contactId), loggerContext);
|
|
1149
|
-
_context16.prev = 2;
|
|
1150
|
-
_Logger.default.info("Deleting contact : ".concat(contactId), loggerContext);
|
|
1151
|
-
_context16.next = 6;
|
|
1152
|
-
return this.webex.request({
|
|
1153
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
1154
|
-
uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.CONTACT_FILTER, "/").concat(contactId),
|
|
1155
|
-
method: _types.HTTP_METHODS.DELETE
|
|
1156
|
-
});
|
|
1157
|
-
case 6:
|
|
1158
|
-
response = _context16.sent;
|
|
1159
|
-
contactResponse = {
|
|
1160
|
-
statusCode: Number(response[_constants.STATUS_CODE]),
|
|
1161
|
-
data: {},
|
|
1162
|
-
message: _constants.SUCCESS_MESSAGE
|
|
1163
|
-
};
|
|
1164
|
-
contactToDelete = (_this$contacts3 = this.contacts) === null || _this$contacts3 === void 0 ? void 0 : _this$contacts3.findIndex(function (contact) {
|
|
1165
|
-
return contact.contactId === contactId;
|
|
1166
|
-
});
|
|
1167
|
-
if (contactToDelete !== undefined && contactToDelete !== -1) {
|
|
1168
|
-
(_this$contacts4 = this.contacts) === null || _this$contacts4 === void 0 ? void 0 : _this$contacts4.splice(contactToDelete, 1);
|
|
1169
|
-
}
|
|
1170
|
-
_Logger.default.log("Contact ".concat(contactId, " successfully deleted"), loggerContext);
|
|
1171
|
-
return _context16.abrupt("return", contactResponse);
|
|
1172
|
-
case 14:
|
|
1173
|
-
_context16.prev = 14;
|
|
1174
|
-
_context16.t0 = _context16["catch"](2);
|
|
1175
|
-
errorInfo = _context16.t0;
|
|
1176
|
-
extendedError = new Error("Unable to delete contact ".concat(contactId, ": ").concat(_context16.t0));
|
|
1177
|
-
_Logger.default.error(extendedError, loggerContext);
|
|
1178
|
-
errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
|
|
1179
|
-
_context16.next = 22;
|
|
1180
|
-
return (0, _Utils.uploadLogs)();
|
|
1181
|
-
case 22:
|
|
1182
|
-
return _context16.abrupt("return", errorStatus);
|
|
1183
|
-
case 23:
|
|
1184
|
-
case "end":
|
|
1185
|
-
return _context16.stop();
|
|
1186
|
-
}
|
|
1187
|
-
}, _callee16, this, [[2, 14]]);
|
|
1188
|
-
}));
|
|
1189
|
-
function deleteContact(_x17) {
|
|
1190
|
-
return _deleteContact.apply(this, arguments);
|
|
1191
|
-
}
|
|
1192
|
-
return deleteContact;
|
|
1193
|
-
}()
|
|
1194
|
-
/**
|
|
1195
|
-
* @ignore
|
|
1196
|
-
*/
|
|
1197
|
-
)
|
|
1198
|
-
}, {
|
|
1199
|
-
key: "getSDKConnector",
|
|
1200
|
-
value: function getSDKConnector() {
|
|
1201
|
-
return this.sdkConnector;
|
|
1202
|
-
}
|
|
1203
|
-
}]);
|
|
1204
|
-
return ContactsClient;
|
|
1205
|
-
}();
|
|
1206
|
-
/**
|
|
1207
|
-
* Creates a ContactsClient instance
|
|
1208
|
-
*
|
|
1209
|
-
* @param {WebexSDK} webex - `Webex SDK`instance.
|
|
1210
|
-
* @param {LoggerInterface} logger - An instance implementing LoggerInterface used to set the log level for the module.
|
|
1211
|
-
*/
|
|
1212
|
-
var createContactsClient = exports.createContactsClient = function createContactsClient(webex, logger) {
|
|
1213
|
-
return new ContactsClient(webex, logger);
|
|
1214
|
-
};
|
|
1215
|
-
//# sourceMappingURL=ContactsClient.js.map
|