@webex/calling 3.0.0-next.2 → 3.0.0-next.4
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/CHANGELOG.md +1403 -0
- package/README.md +74 -74
- package/dist/module/CallHistory/CallHistory.js +81 -81
- package/dist/module/CallHistory/callHistoryFixtures.js +307 -307
- package/dist/module/CallHistory/constants.js +9 -9
- package/dist/module/CallHistory/types.js +1 -1
- package/dist/module/CallSettings/CallSettings.js +65 -65
- package/dist/module/CallSettings/UcmBackendConnector.js +100 -100
- package/dist/module/CallSettings/WxCallBackendConnector.js +287 -287
- package/dist/module/CallSettings/constants.js +11 -11
- package/dist/module/CallSettings/testFixtures.js +62 -62
- package/dist/module/CallSettings/types.js +1 -1
- package/dist/module/CallingClient/CallingClient.js +248 -248
- package/dist/module/CallingClient/callRecordFixtures.js +93 -93
- package/dist/module/CallingClient/calling/CallerId/index.js +169 -169
- package/dist/module/CallingClient/calling/CallerId/types.js +1 -1
- package/dist/module/CallingClient/calling/call.js +1658 -1658
- package/dist/module/CallingClient/calling/callManager.js +284 -284
- package/dist/module/CallingClient/calling/index.js +2 -2
- package/dist/module/CallingClient/calling/types.js +53 -53
- package/dist/module/CallingClient/callingClientFixtures.js +38 -38
- package/dist/module/CallingClient/constants.js +122 -122
- package/dist/module/CallingClient/line/index.js +158 -158
- package/dist/module/CallingClient/line/types.js +15 -15
- package/dist/module/CallingClient/registration/index.js +1 -1
- package/dist/module/CallingClient/registration/register.js +507 -507
- package/dist/module/CallingClient/registration/registerFixtures.js +28 -28
- package/dist/module/CallingClient/registration/types.js +1 -1
- package/dist/module/CallingClient/types.js +1 -1
- package/dist/module/Contacts/ContactsClient.js +484 -484
- package/dist/module/Contacts/constants.js +20 -20
- package/dist/module/Contacts/contactFixtures.js +284 -284
- package/dist/module/Contacts/types.js +10 -10
- package/dist/module/Errors/catalog/CallError.js +26 -26
- package/dist/module/Errors/catalog/CallingDeviceError.js +18 -18
- package/dist/module/Errors/catalog/ExtendedError.js +10 -10
- package/dist/module/Errors/catalog/LineError.js +24 -24
- package/dist/module/Errors/index.js +2 -2
- package/dist/module/Errors/types.js +48 -48
- package/dist/module/Events/impl/index.js +19 -19
- package/dist/module/Events/types.js +83 -83
- package/dist/module/Logger/index.js +114 -114
- package/dist/module/Logger/types.js +25 -25
- package/dist/module/Metrics/index.js +232 -232
- package/dist/module/Metrics/types.js +37 -37
- package/dist/module/SDKConnector/index.js +39 -39
- package/dist/module/SDKConnector/types.js +1 -1
- package/dist/module/SDKConnector/utils.js +12 -12
- package/dist/module/Voicemail/BroadworksBackendConnector.js +291 -291
- package/dist/module/Voicemail/UcmBackendConnector.js +279 -279
- package/dist/module/Voicemail/Voicemail.js +110 -110
- package/dist/module/Voicemail/WxCallBackendConnector.js +279 -279
- package/dist/module/Voicemail/constants.js +29 -29
- package/dist/module/Voicemail/types.js +1 -1
- package/dist/module/Voicemail/voicemailFixture.js +510 -510
- package/dist/module/api.js +6 -6
- package/dist/module/common/Utils.js +802 -802
- package/dist/module/common/constants.js +41 -41
- package/dist/module/common/index.js +1 -1
- package/dist/module/common/testUtil.js +938 -938
- package/dist/module/common/types.js +57 -57
- package/dist/module/index.js +8 -8
- package/dist/types/CallHistory/CallHistory.d.ts +17 -17
- package/dist/types/CallHistory/callHistoryFixtures.d.ts +94 -94
- package/dist/types/CallHistory/constants.d.ts +9 -9
- package/dist/types/CallHistory/types.d.ts +18 -18
- package/dist/types/CallSettings/CallSettings.d.ts +19 -19
- package/dist/types/CallSettings/UcmBackendConnector.d.ts +19 -19
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts +21 -21
- package/dist/types/CallSettings/constants.d.ts +11 -11
- package/dist/types/CallSettings/testFixtures.d.ts +15 -15
- package/dist/types/CallSettings/types.d.ts +107 -107
- package/dist/types/CallingClient/CallingClient.d.ts +35 -35
- package/dist/types/CallingClient/callRecordFixtures.d.ts +3 -3
- package/dist/types/CallingClient/calling/CallerId/index.d.ts +17 -17
- package/dist/types/CallingClient/calling/CallerId/types.d.ts +41 -41
- package/dist/types/CallingClient/calling/call.d.ts +96 -96
- package/dist/types/CallingClient/calling/callManager.d.ts +25 -25
- package/dist/types/CallingClient/calling/index.d.ts +2 -2
- package/dist/types/CallingClient/calling/types.d.ts +206 -206
- package/dist/types/CallingClient/callingClientFixtures.d.ts +18 -18
- package/dist/types/CallingClient/constants.d.ts +122 -122
- package/dist/types/CallingClient/line/index.d.ts +43 -43
- package/dist/types/CallingClient/line/types.d.ts +55 -55
- package/dist/types/CallingClient/registration/index.d.ts +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +64 -64
- package/dist/types/CallingClient/registration/registerFixtures.d.ts +28 -28
- package/dist/types/CallingClient/registration/types.d.ts +20 -20
- package/dist/types/CallingClient/types.d.ts +29 -29
- package/dist/types/Contacts/ContactsClient.d.ts +26 -26
- package/dist/types/Contacts/constants.d.ts +19 -19
- package/dist/types/Contacts/contactFixtures.d.ts +280 -280
- package/dist/types/Contacts/types.d.ts +72 -72
- package/dist/types/Errors/catalog/CallError.d.ts +11 -11
- package/dist/types/Errors/catalog/CallingDeviceError.d.ts +10 -10
- package/dist/types/Errors/catalog/ExtendedError.d.ts +6 -6
- package/dist/types/Errors/catalog/LineError.d.ts +10 -10
- package/dist/types/Errors/index.d.ts +2 -2
- package/dist/types/Errors/types.d.ts +60 -60
- package/dist/types/Events/impl/index.d.ts +8 -8
- package/dist/types/Events/types.d.ts +288 -288
- package/dist/types/Logger/index.d.ts +12 -12
- package/dist/types/Logger/types.d.ts +25 -25
- package/dist/types/Metrics/index.d.ts +5 -5
- package/dist/types/Metrics/types.d.ts +42 -42
- package/dist/types/SDKConnector/index.d.ts +12 -12
- package/dist/types/SDKConnector/types.d.ts +128 -128
- package/dist/types/SDKConnector/utils.d.ts +5 -5
- package/dist/types/Voicemail/BroadworksBackendConnector.d.ts +27 -27
- package/dist/types/Voicemail/UcmBackendConnector.d.ts +34 -34
- package/dist/types/Voicemail/Voicemail.d.ts +27 -27
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts +23 -23
- package/dist/types/Voicemail/constants.d.ts +29 -29
- package/dist/types/Voicemail/types.d.ts +133 -133
- package/dist/types/Voicemail/voicemailFixture.d.ts +417 -417
- package/dist/types/api.d.ts +16 -16
- package/dist/types/common/Utils.d.ts +34 -34
- package/dist/types/common/constants.d.ts +41 -41
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/common/testUtil.d.ts +3611 -3611
- package/dist/types/common/types.d.ts +191 -191
- package/dist/types/index.d.ts +8 -8
- package/package.json +4 -4
- package/dist/CallHistory/CallHistory.js +0 -203
- package/dist/CallHistory/CallHistory.js.map +0 -1
- package/dist/CallHistory/CallHistory.test.js +0 -133
- package/dist/CallHistory/CallHistory.test.js.map +0 -1
- package/dist/CallHistory/callHistoryFixtures.js +0 -310
- package/dist/CallHistory/callHistoryFixtures.js.map +0 -1
- package/dist/CallHistory/constants.js +0 -26
- 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 -276
- 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 -217
- package/dist/CallSettings/UcmBackendConnector.js.map +0 -1
- package/dist/CallSettings/UcmBackendConnector.test.js +0 -227
- package/dist/CallSettings/UcmBackendConnector.test.js.map +0 -1
- package/dist/CallSettings/WxCallBackendConnector.js +0 -541
- package/dist/CallSettings/WxCallBackendConnector.js.map +0 -1
- package/dist/CallSettings/WxCallBackendConnector.test.js +0 -802
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +0 -1
- package/dist/CallSettings/constants.js +0 -30
- package/dist/CallSettings/constants.js.map +0 -1
- package/dist/CallSettings/testFixtures.js +0 -72
- 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 -572
- package/dist/CallingClient/CallingClient.js.map +0 -1
- package/dist/CallingClient/CallingClient.test.js +0 -931
- package/dist/CallingClient/CallingClient.test.js.map +0 -1
- package/dist/CallingClient/callRecordFixtures.js +0 -103
- package/dist/CallingClient/callRecordFixtures.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/index.js +0 -287
- package/dist/CallingClient/calling/CallerId/index.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/index.test.js +0 -274
- 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 -2995
- package/dist/CallingClient/calling/call.js.map +0 -1
- package/dist/CallingClient/calling/call.test.js +0 -2614
- package/dist/CallingClient/calling/call.test.js.map +0 -1
- package/dist/CallingClient/calling/callManager.js +0 -443
- package/dist/CallingClient/calling/callManager.js.map +0 -1
- package/dist/CallingClient/calling/callManager.test.js +0 -683
- 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 -71
- package/dist/CallingClient/calling/types.js.map +0 -1
- package/dist/CallingClient/callingClientFixtures.js +0 -53
- package/dist/CallingClient/callingClientFixtures.js.map +0 -1
- package/dist/CallingClient/constants.js +0 -226
- package/dist/CallingClient/constants.js.map +0 -1
- package/dist/CallingClient/line/index.js +0 -312
- package/dist/CallingClient/line/index.js.map +0 -1
- package/dist/CallingClient/line/line.test.js +0 -270
- package/dist/CallingClient/line/line.test.js.map +0 -1
- package/dist/CallingClient/line/types.js +0 -25
- 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 -1295
- package/dist/CallingClient/registration/register.js.map +0 -1
- package/dist/CallingClient/registration/register.test.js +0 -838
- package/dist/CallingClient/registration/register.test.js.map +0 -1
- package/dist/CallingClient/registration/registerFixtures.js +0 -41
- 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/types.js +0 -7
- package/dist/CallingClient/types.js.map +0 -1
- package/dist/Contacts/ContactsClient.js +0 -1139
- package/dist/Contacts/ContactsClient.js.map +0 -1
- package/dist/Contacts/ContactsClient.test.js +0 -725
- package/dist/Contacts/ContactsClient.test.js.map +0 -1
- package/dist/Contacts/constants.js +0 -36
- package/dist/Contacts/constants.js.map +0 -1
- package/dist/Contacts/contactFixtures.js +0 -340
- package/dist/Contacts/contactFixtures.js.map +0 -1
- package/dist/Contacts/types.js +0 -20
- package/dist/Contacts/types.js.map +0 -1
- package/dist/Errors/catalog/CallError.js +0 -94
- package/dist/Errors/catalog/CallError.js.map +0 -1
- package/dist/Errors/catalog/CallingDeviceError.js +0 -88
- package/dist/Errors/catalog/CallingDeviceError.js.map +0 -1
- package/dist/Errors/catalog/ExtendedError.js +0 -45
- package/dist/Errors/catalog/ExtendedError.js.map +0 -1
- package/dist/Errors/catalog/LineError.js +0 -90
- package/dist/Errors/catalog/LineError.js.map +0 -1
- package/dist/Errors/index.js +0 -21
- package/dist/Errors/index.js.map +0 -1
- package/dist/Errors/types.js +0 -62
- package/dist/Errors/types.js.map +0 -1
- package/dist/Events/impl/index.js +0 -82
- package/dist/Events/impl/index.js.map +0 -1
- package/dist/Events/types.js +0 -111
- package/dist/Events/types.js.map +0 -1
- package/dist/Logger/index.js +0 -221
- package/dist/Logger/index.js.map +0 -1
- package/dist/Logger/index.test.js +0 -62
- package/dist/Logger/index.test.js.map +0 -1
- package/dist/Logger/types.js +0 -37
- package/dist/Logger/types.js.map +0 -1
- package/dist/Metrics/index.js +0 -329
- package/dist/Metrics/index.js.map +0 -1
- package/dist/Metrics/index.test.js +0 -291
- package/dist/Metrics/index.test.js.map +0 -1
- package/dist/Metrics/types.js +0 -50
- package/dist/Metrics/types.js.map +0 -1
- package/dist/SDKConnector/index.js +0 -105
- 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 -40
- 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 -632
- package/dist/Voicemail/BroadworksBackendConnector.js.map +0 -1
- package/dist/Voicemail/BroadworksBackendConnector.test.js +0 -733
- package/dist/Voicemail/BroadworksBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/UcmBackendConnector.js +0 -566
- package/dist/Voicemail/UcmBackendConnector.js.map +0 -1
- package/dist/Voicemail/UcmBackendConnector.test.js +0 -628
- package/dist/Voicemail/UcmBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/Voicemail.js +0 -378
- package/dist/Voicemail/Voicemail.js.map +0 -1
- package/dist/Voicemail/Voicemail.test.js +0 -226
- package/dist/Voicemail/Voicemail.test.js.map +0 -1
- package/dist/Voicemail/WxCallBackendConnector.js +0 -540
- package/dist/Voicemail/WxCallBackendConnector.js.map +0 -1
- package/dist/Voicemail/WxCallBackendConnector.test.js +0 -942
- package/dist/Voicemail/WxCallBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/constants.js +0 -66
- 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 -559
- package/dist/Voicemail/voicemailFixture.js.map +0 -1
- package/dist/api.js +0 -134
- package/dist/api.js.map +0 -1
- package/dist/common/Utils.js +0 -1264
- package/dist/common/Utils.js.map +0 -1
- package/dist/common/Utils.test.js +0 -1227
- package/dist/common/Utils.test.js.map +0 -1
- package/dist/common/constants.js +0 -90
- 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 -968
- 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 -63
- package/dist/index.js.map +0 -1
|
@@ -1,1139 +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(object, enumerableOnly) { var keys = _Object$keys2(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
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
|
-
* @implements {IContacts}
|
|
45
|
-
*/
|
|
46
|
-
var ContactsClient = /*#__PURE__*/function () {
|
|
47
|
-
/**
|
|
48
|
-
* @ignore
|
|
49
|
-
*/
|
|
50
|
-
function ContactsClient(webex, logger) {
|
|
51
|
-
(0, _classCallCheck2.default)(this, ContactsClient);
|
|
52
|
-
(0, _defineProperty2.default)(this, "sdkConnector", void 0);
|
|
53
|
-
(0, _defineProperty2.default)(this, "encryptionKeyUrl", void 0);
|
|
54
|
-
(0, _defineProperty2.default)(this, "webex", void 0);
|
|
55
|
-
(0, _defineProperty2.default)(this, "groups", void 0);
|
|
56
|
-
(0, _defineProperty2.default)(this, "contacts", void 0);
|
|
57
|
-
(0, _defineProperty2.default)(this, "defaultGroupId", void 0);
|
|
58
|
-
this.sdkConnector = _SDKConnector.default;
|
|
59
|
-
if (!this.sdkConnector.getWebex()) {
|
|
60
|
-
_SDKConnector.default.setWebex(webex);
|
|
61
|
-
}
|
|
62
|
-
this.webex = this.sdkConnector.getWebex();
|
|
63
|
-
this.encryptionKeyUrl = '';
|
|
64
|
-
this.groups = undefined;
|
|
65
|
-
this.contacts = undefined;
|
|
66
|
-
this.defaultGroupId = '';
|
|
67
|
-
_Logger.default.setLogger(logger.level, _constants2.CONTACTS_FILE);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Decrypt emails, phoneNumbers, sipAddresses.
|
|
72
|
-
*/
|
|
73
|
-
(0, _createClass2.default)(ContactsClient, [{
|
|
74
|
-
key: "decryptContactDetail",
|
|
75
|
-
value: function () {
|
|
76
|
-
var _decryptContactDetail = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(encryptionKeyUrl, contactDetails) {
|
|
77
|
-
var _this = this;
|
|
78
|
-
var decryptedContactDetail, decryptedValues;
|
|
79
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
80
|
-
while (1) switch (_context.prev = _context.next) {
|
|
81
|
-
case 0:
|
|
82
|
-
decryptedContactDetail = (0, _toConsumableArray2.default)(contactDetails);
|
|
83
|
-
_context.next = 3;
|
|
84
|
-
return _promise.default.all(decryptedContactDetail.map(function (detail) {
|
|
85
|
-
return _this.webex.internal.encryption.decryptText(encryptionKeyUrl, detail.value);
|
|
86
|
-
}));
|
|
87
|
-
case 3:
|
|
88
|
-
decryptedValues = _context.sent;
|
|
89
|
-
decryptedValues.forEach(function (decryptedValue, index) {
|
|
90
|
-
decryptedContactDetail[index].value = decryptedValue;
|
|
91
|
-
});
|
|
92
|
-
return _context.abrupt("return", decryptedContactDetail);
|
|
93
|
-
case 6:
|
|
94
|
-
case "end":
|
|
95
|
-
return _context.stop();
|
|
96
|
-
}
|
|
97
|
-
}, _callee);
|
|
98
|
-
}));
|
|
99
|
-
function decryptContactDetail(_x, _x2) {
|
|
100
|
-
return _decryptContactDetail.apply(this, arguments);
|
|
101
|
-
}
|
|
102
|
-
return decryptContactDetail;
|
|
103
|
-
}()
|
|
104
|
-
/**
|
|
105
|
-
* Encrypt emails, phoneNumbers, sipAddresses.
|
|
106
|
-
*
|
|
107
|
-
*/
|
|
108
|
-
}, {
|
|
109
|
-
key: "encryptContactDetail",
|
|
110
|
-
value: function () {
|
|
111
|
-
var _encryptContactDetail = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(encryptionKeyUrl, contactDetails) {
|
|
112
|
-
var _this2 = this;
|
|
113
|
-
var encryptedContactDetail, encryptedValues;
|
|
114
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
115
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
116
|
-
case 0:
|
|
117
|
-
encryptedContactDetail = (0, _toConsumableArray2.default)(contactDetails);
|
|
118
|
-
_context2.next = 3;
|
|
119
|
-
return _promise.default.all(encryptedContactDetail.map(function (detail) {
|
|
120
|
-
return _this2.webex.internal.encryption.encryptText(encryptionKeyUrl, detail.value);
|
|
121
|
-
}));
|
|
122
|
-
case 3:
|
|
123
|
-
encryptedValues = _context2.sent;
|
|
124
|
-
encryptedValues.forEach(function (encryptedValue, index) {
|
|
125
|
-
encryptedContactDetail[index].value = encryptedValue;
|
|
126
|
-
});
|
|
127
|
-
return _context2.abrupt("return", encryptedContactDetail);
|
|
128
|
-
case 6:
|
|
129
|
-
case "end":
|
|
130
|
-
return _context2.stop();
|
|
131
|
-
}
|
|
132
|
-
}, _callee2);
|
|
133
|
-
}));
|
|
134
|
-
function encryptContactDetail(_x3, _x4) {
|
|
135
|
-
return _encryptContactDetail.apply(this, arguments);
|
|
136
|
-
}
|
|
137
|
-
return encryptContactDetail;
|
|
138
|
-
}()
|
|
139
|
-
/**
|
|
140
|
-
* Encrypts a given contact.
|
|
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
|
-
key: "decryptContact",
|
|
261
|
-
value: function () {
|
|
262
|
-
var _decryptContact = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(contact) {
|
|
263
|
-
var _this4 = this;
|
|
264
|
-
var encryptionKeyUrl, decryptedContact, decryptionPromises, decryptedFieldsList;
|
|
265
|
-
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
266
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
267
|
-
case 0:
|
|
268
|
-
encryptionKeyUrl = contact.encryptionKeyUrl;
|
|
269
|
-
decryptedContact = _objectSpread({}, contact);
|
|
270
|
-
decryptionPromises = (0, _values.default)(_constants2.encryptedFields).map( /*#__PURE__*/function () {
|
|
271
|
-
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(field) {
|
|
272
|
-
var plaintextAddressInfo, decryptedAddressInfo, decryptedAddressInfoPromises, plainTextDetails, decryptedDetails, decryptedValue;
|
|
273
|
-
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
274
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
275
|
-
case 0:
|
|
276
|
-
_context7.t0 = field;
|
|
277
|
-
_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;
|
|
278
|
-
break;
|
|
279
|
-
case 3:
|
|
280
|
-
plaintextAddressInfo = decryptedContact.addressInfo;
|
|
281
|
-
if (!plaintextAddressInfo) {
|
|
282
|
-
_context7.next = 11;
|
|
283
|
-
break;
|
|
284
|
-
}
|
|
285
|
-
decryptedAddressInfoPromises = (0, _entries.default)(plaintextAddressInfo).map( /*#__PURE__*/function () {
|
|
286
|
-
var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(_ref8) {
|
|
287
|
-
var _ref10, key, value;
|
|
288
|
-
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
289
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
290
|
-
case 0:
|
|
291
|
-
_ref10 = (0, _slicedToArray2.default)(_ref8, 2), key = _ref10[0], value = _ref10[1];
|
|
292
|
-
_context6.t0 = key;
|
|
293
|
-
_context6.next = 4;
|
|
294
|
-
return _this4.webex.internal.encryption.decryptText(encryptionKeyUrl, value);
|
|
295
|
-
case 4:
|
|
296
|
-
_context6.t1 = _context6.sent;
|
|
297
|
-
return _context6.abrupt("return", [_context6.t0, _context6.t1]);
|
|
298
|
-
case 6:
|
|
299
|
-
case "end":
|
|
300
|
-
return _context6.stop();
|
|
301
|
-
}
|
|
302
|
-
}, _callee6);
|
|
303
|
-
}));
|
|
304
|
-
return function (_x10) {
|
|
305
|
-
return _ref9.apply(this, arguments);
|
|
306
|
-
};
|
|
307
|
-
}());
|
|
308
|
-
_context7.t1 = Object;
|
|
309
|
-
_context7.next = 9;
|
|
310
|
-
return _promise.default.all(decryptedAddressInfoPromises);
|
|
311
|
-
case 9:
|
|
312
|
-
_context7.t2 = _context7.sent;
|
|
313
|
-
decryptedAddressInfo = _context7.t1.fromEntries.call(_context7.t1, _context7.t2);
|
|
314
|
-
case 11:
|
|
315
|
-
return _context7.abrupt("return", [field, decryptedAddressInfo]);
|
|
316
|
-
case 12:
|
|
317
|
-
plainTextDetails = decryptedContact[field];
|
|
318
|
-
if (!plainTextDetails) {
|
|
319
|
-
_context7.next = 17;
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
_context7.next = 16;
|
|
323
|
-
return _this4.decryptContactDetail(encryptionKeyUrl, plainTextDetails);
|
|
324
|
-
case 16:
|
|
325
|
-
decryptedDetails = _context7.sent;
|
|
326
|
-
case 17:
|
|
327
|
-
return _context7.abrupt("return", [field, decryptedDetails]);
|
|
328
|
-
case 18:
|
|
329
|
-
if (!((0, _values.default)(_constants2.encryptedFields).includes(field) && decryptedContact[field])) {
|
|
330
|
-
_context7.next = 22;
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
_context7.next = 21;
|
|
334
|
-
return _this4.webex.internal.encryption.decryptText(encryptionKeyUrl, decryptedContact[field]);
|
|
335
|
-
case 21:
|
|
336
|
-
decryptedValue = _context7.sent;
|
|
337
|
-
case 22:
|
|
338
|
-
return _context7.abrupt("return", [field, decryptedValue]);
|
|
339
|
-
case 23:
|
|
340
|
-
case "end":
|
|
341
|
-
return _context7.stop();
|
|
342
|
-
}
|
|
343
|
-
}, _callee7);
|
|
344
|
-
}));
|
|
345
|
-
return function (_x9) {
|
|
346
|
-
return _ref7.apply(this, arguments);
|
|
347
|
-
};
|
|
348
|
-
}());
|
|
349
|
-
_context8.next = 5;
|
|
350
|
-
return _promise.default.all(decryptionPromises);
|
|
351
|
-
case 5:
|
|
352
|
-
decryptedFieldsList = _context8.sent;
|
|
353
|
-
decryptedFieldsList.forEach(function (_ref11) {
|
|
354
|
-
var _ref12 = (0, _slicedToArray2.default)(_ref11, 2),
|
|
355
|
-
field = _ref12[0],
|
|
356
|
-
value = _ref12[1];
|
|
357
|
-
if (value !== undefined) {
|
|
358
|
-
decryptedContact[field] = value;
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
return _context8.abrupt("return", decryptedContact);
|
|
362
|
-
case 8:
|
|
363
|
-
case "end":
|
|
364
|
-
return _context8.stop();
|
|
365
|
-
}
|
|
366
|
-
}, _callee8);
|
|
367
|
-
}));
|
|
368
|
-
function decryptContact(_x8) {
|
|
369
|
-
return _decryptContact.apply(this, arguments);
|
|
370
|
-
}
|
|
371
|
-
return decryptContact;
|
|
372
|
-
}()
|
|
373
|
-
/**
|
|
374
|
-
* Fetches contacts from DSS.
|
|
375
|
-
*/
|
|
376
|
-
}, {
|
|
377
|
-
key: "fetchContactFromDSS",
|
|
378
|
-
value: function () {
|
|
379
|
-
var _fetchContactFromDSS = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(contactsDataMap) {
|
|
380
|
-
var _this5 = this;
|
|
381
|
-
var contactList, dssResult, _loop, i;
|
|
382
|
-
return _regenerator.default.wrap(function _callee9$(_context10) {
|
|
383
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
384
|
-
case 0:
|
|
385
|
-
contactList = [];
|
|
386
|
-
_context10.next = 3;
|
|
387
|
-
return this.webex.internal.dss.lookup({
|
|
388
|
-
ids: (0, _keys.default)(contactsDataMap)
|
|
389
|
-
});
|
|
390
|
-
case 3:
|
|
391
|
-
dssResult = _context10.sent;
|
|
392
|
-
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
393
|
-
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;
|
|
394
|
-
return _regenerator.default.wrap(function _loop$(_context9) {
|
|
395
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
396
|
-
case 0:
|
|
397
|
-
contact = dssResult[i];
|
|
398
|
-
contactId = contact.identity;
|
|
399
|
-
displayName = contact.displayName, emails = contact.emails, phoneNumbers = contact.phoneNumbers, sipAddresses = contact.sipAddresses, photos = contact.photos;
|
|
400
|
-
_contact$additionalIn = contact.additionalInfo, department = _contact$additionalIn.department, firstName = _contact$additionalIn.firstName, identityManager = _contact$additionalIn.identityManager, jobTitle = _contact$additionalIn.jobTitle, lastName = _contact$additionalIn.lastName;
|
|
401
|
-
manager = identityManager && identityManager.displayName ? identityManager.displayName : undefined;
|
|
402
|
-
_contactsDataMap$cont = contactsDataMap[contactId], contactType = _contactsDataMap$cont.contactType, avatarUrlDomain = _contactsDataMap$cont.avatarUrlDomain, encryptionKeyUrl = _contactsDataMap$cont.encryptionKeyUrl, ownerId = _contactsDataMap$cont.ownerId, groups = _contactsDataMap$cont.groups;
|
|
403
|
-
avatarURL = '';
|
|
404
|
-
if (photos.length) {
|
|
405
|
-
avatarURL = photos[0].value;
|
|
406
|
-
}
|
|
407
|
-
addedPhoneNumbers = contactsDataMap[contactId].phoneNumbers;
|
|
408
|
-
if (!addedPhoneNumbers) {
|
|
409
|
-
_context9.next = 14;
|
|
410
|
-
break;
|
|
411
|
-
}
|
|
412
|
-
_context9.next = 12;
|
|
413
|
-
return _this5.decryptContactDetail(encryptionKeyUrl, addedPhoneNumbers);
|
|
414
|
-
case 12:
|
|
415
|
-
decryptedPhoneNumbers = _context9.sent;
|
|
416
|
-
decryptedPhoneNumbers.forEach(function (number) {
|
|
417
|
-
return phoneNumbers.push(number);
|
|
418
|
-
});
|
|
419
|
-
case 14:
|
|
420
|
-
addedSipAddresses = contactsDataMap[contactId].sipAddresses;
|
|
421
|
-
if (!addedSipAddresses) {
|
|
422
|
-
_context9.next = 20;
|
|
423
|
-
break;
|
|
424
|
-
}
|
|
425
|
-
_context9.next = 18;
|
|
426
|
-
return _this5.decryptContactDetail(encryptionKeyUrl, addedSipAddresses);
|
|
427
|
-
case 18:
|
|
428
|
-
decryptedSipAddresses = _context9.sent;
|
|
429
|
-
decryptedSipAddresses.forEach(function (address) {
|
|
430
|
-
return sipAddresses.push(address);
|
|
431
|
-
});
|
|
432
|
-
case 20:
|
|
433
|
-
cloudContact = {
|
|
434
|
-
avatarUrlDomain: avatarUrlDomain,
|
|
435
|
-
avatarURL: avatarURL,
|
|
436
|
-
contactId: contactId,
|
|
437
|
-
contactType: contactType,
|
|
438
|
-
department: department,
|
|
439
|
-
displayName: displayName,
|
|
440
|
-
emails: emails,
|
|
441
|
-
encryptionKeyUrl: encryptionKeyUrl,
|
|
442
|
-
firstName: firstName,
|
|
443
|
-
groups: groups,
|
|
444
|
-
lastName: lastName,
|
|
445
|
-
manager: manager,
|
|
446
|
-
ownerId: ownerId,
|
|
447
|
-
phoneNumbers: phoneNumbers,
|
|
448
|
-
sipAddresses: sipAddresses,
|
|
449
|
-
title: jobTitle
|
|
450
|
-
};
|
|
451
|
-
contactList.push(cloudContact);
|
|
452
|
-
case 22:
|
|
453
|
-
case "end":
|
|
454
|
-
return _context9.stop();
|
|
455
|
-
}
|
|
456
|
-
}, _loop);
|
|
457
|
-
});
|
|
458
|
-
i = 0;
|
|
459
|
-
case 6:
|
|
460
|
-
if (!(i < dssResult.length)) {
|
|
461
|
-
_context10.next = 11;
|
|
462
|
-
break;
|
|
463
|
-
}
|
|
464
|
-
return _context10.delegateYield(_loop(), "t0", 8);
|
|
465
|
-
case 8:
|
|
466
|
-
i += 1;
|
|
467
|
-
_context10.next = 6;
|
|
468
|
-
break;
|
|
469
|
-
case 11:
|
|
470
|
-
return _context10.abrupt("return", contactList);
|
|
471
|
-
case 12:
|
|
472
|
-
case "end":
|
|
473
|
-
return _context10.stop();
|
|
474
|
-
}
|
|
475
|
-
}, _callee9, this);
|
|
476
|
-
}));
|
|
477
|
-
function fetchContactFromDSS(_x11) {
|
|
478
|
-
return _fetchContactFromDSS.apply(this, arguments);
|
|
479
|
-
}
|
|
480
|
-
return fetchContactFromDSS;
|
|
481
|
-
}()
|
|
482
|
-
/**
|
|
483
|
-
* Returns list of contacts.
|
|
484
|
-
*/
|
|
485
|
-
}, {
|
|
486
|
-
key: "getContacts",
|
|
487
|
-
value: function () {
|
|
488
|
-
var _getContacts = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
|
|
489
|
-
var _this6 = this;
|
|
490
|
-
var loggerContext, contactList, contactsDataMap, response, responseBody, contacts, groups, i, contact, decryptedContact, cloudContacts, contactResponse, errorInfo, errorStatus;
|
|
491
|
-
return _regenerator.default.wrap(function _callee11$(_context12) {
|
|
492
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
493
|
-
case 0:
|
|
494
|
-
loggerContext = {
|
|
495
|
-
file: _constants2.CONTACTS_FILE,
|
|
496
|
-
method: 'getContacts'
|
|
497
|
-
};
|
|
498
|
-
contactList = [];
|
|
499
|
-
contactsDataMap = {};
|
|
500
|
-
_context12.prev = 3;
|
|
501
|
-
_context12.next = 6;
|
|
502
|
-
return this.webex.request({
|
|
503
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
504
|
-
uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.CONTACT_FILTER),
|
|
505
|
-
method: _types.HTTP_METHODS.GET
|
|
506
|
-
});
|
|
507
|
-
case 6:
|
|
508
|
-
response = _context12.sent;
|
|
509
|
-
responseBody = response.body;
|
|
510
|
-
if (responseBody) {
|
|
511
|
-
_context12.next = 10;
|
|
512
|
-
break;
|
|
513
|
-
}
|
|
514
|
-
throw new Error("".concat(response));
|
|
515
|
-
case 10:
|
|
516
|
-
contacts = responseBody.contacts, groups = responseBody.groups;
|
|
517
|
-
i = 0;
|
|
518
|
-
case 12:
|
|
519
|
-
if (!(i < contacts.length)) {
|
|
520
|
-
_context12.next = 25;
|
|
521
|
-
break;
|
|
522
|
-
}
|
|
523
|
-
contact = contacts[i];
|
|
524
|
-
if (!(contact.contactType === _types2.ContactType.CUSTOM)) {
|
|
525
|
-
_context12.next = 21;
|
|
526
|
-
break;
|
|
527
|
-
}
|
|
528
|
-
_context12.next = 17;
|
|
529
|
-
return this.decryptContact(contact);
|
|
530
|
-
case 17:
|
|
531
|
-
decryptedContact = _context12.sent;
|
|
532
|
-
contactList.push(decryptedContact);
|
|
533
|
-
_context12.next = 22;
|
|
534
|
-
break;
|
|
535
|
-
case 21:
|
|
536
|
-
if (contact.contactType === _types2.ContactType.CLOUD && contact.contactId) {
|
|
537
|
-
contactsDataMap[contact.contactId] = contact;
|
|
538
|
-
}
|
|
539
|
-
case 22:
|
|
540
|
-
i += 1;
|
|
541
|
-
_context12.next = 12;
|
|
542
|
-
break;
|
|
543
|
-
case 25:
|
|
544
|
-
if (!(0, _keys.default)(contactsDataMap).length) {
|
|
545
|
-
_context12.next = 30;
|
|
546
|
-
break;
|
|
547
|
-
}
|
|
548
|
-
_context12.next = 28;
|
|
549
|
-
return this.fetchContactFromDSS(contactsDataMap);
|
|
550
|
-
case 28:
|
|
551
|
-
cloudContacts = _context12.sent;
|
|
552
|
-
contactList.push.apply(contactList, (0, _toConsumableArray2.default)(cloudContacts));
|
|
553
|
-
case 30:
|
|
554
|
-
_context12.next = 32;
|
|
555
|
-
return _promise.default.all(groups.map( /*#__PURE__*/function () {
|
|
556
|
-
var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(group, idx) {
|
|
557
|
-
return _regenerator.default.wrap(function _callee10$(_context11) {
|
|
558
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
559
|
-
case 0:
|
|
560
|
-
_context11.next = 2;
|
|
561
|
-
return _this6.webex.internal.encryption.decryptText(group.encryptionKeyUrl, group.displayName);
|
|
562
|
-
case 2:
|
|
563
|
-
groups[idx].displayName = _context11.sent;
|
|
564
|
-
case 3:
|
|
565
|
-
case "end":
|
|
566
|
-
return _context11.stop();
|
|
567
|
-
}
|
|
568
|
-
}, _callee10);
|
|
569
|
-
}));
|
|
570
|
-
return function (_x12, _x13) {
|
|
571
|
-
return _ref13.apply(this, arguments);
|
|
572
|
-
};
|
|
573
|
-
}()));
|
|
574
|
-
case 32:
|
|
575
|
-
this.groups = groups;
|
|
576
|
-
this.contacts = contactList;
|
|
577
|
-
contactResponse = {
|
|
578
|
-
statusCode: Number(response[_constants.STATUS_CODE]),
|
|
579
|
-
data: {
|
|
580
|
-
contacts: contactList,
|
|
581
|
-
groups: groups
|
|
582
|
-
},
|
|
583
|
-
message: _constants.SUCCESS_MESSAGE
|
|
584
|
-
};
|
|
585
|
-
return _context12.abrupt("return", contactResponse);
|
|
586
|
-
case 38:
|
|
587
|
-
_context12.prev = 38;
|
|
588
|
-
_context12.t0 = _context12["catch"](3);
|
|
589
|
-
errorInfo = _context12.t0;
|
|
590
|
-
errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
|
|
591
|
-
return _context12.abrupt("return", errorStatus);
|
|
592
|
-
case 43:
|
|
593
|
-
case "end":
|
|
594
|
-
return _context12.stop();
|
|
595
|
-
}
|
|
596
|
-
}, _callee11, this, [[3, 38]]);
|
|
597
|
-
}));
|
|
598
|
-
function getContacts() {
|
|
599
|
-
return _getContacts.apply(this, arguments);
|
|
600
|
-
}
|
|
601
|
-
return getContacts;
|
|
602
|
-
}()
|
|
603
|
-
/**
|
|
604
|
-
* Creates a new KMS Resource Object (KRO) and Content Key (CK) which is used for encryption.
|
|
605
|
-
*
|
|
606
|
-
* @returns EncryptionKeyUrl as a Promise.
|
|
607
|
-
*/
|
|
608
|
-
}, {
|
|
609
|
-
key: "createNewEncryptionKeyUrl",
|
|
610
|
-
value: function () {
|
|
611
|
-
var _createNewEncryptionKeyUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
|
|
612
|
-
var loggerContext, unboundedKeyUri, unboundedKeys;
|
|
613
|
-
return _regenerator.default.wrap(function _callee12$(_context13) {
|
|
614
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
615
|
-
case 0:
|
|
616
|
-
loggerContext = {
|
|
617
|
-
file: _constants2.CONTACTS_FILE,
|
|
618
|
-
method: this.createNewEncryptionKeyUrl.name
|
|
619
|
-
};
|
|
620
|
-
unboundedKeyUri = '';
|
|
621
|
-
_Logger.default.info('Requesting kms for a new KRO and key', loggerContext);
|
|
622
|
-
_context13.next = 5;
|
|
623
|
-
return this.webex.internal.encryption.kms.createUnboundKeys({
|
|
624
|
-
count: 1
|
|
625
|
-
});
|
|
626
|
-
case 5:
|
|
627
|
-
unboundedKeys = _context13.sent;
|
|
628
|
-
unboundedKeyUri = unboundedKeys[0].uri;
|
|
629
|
-
this.webex.internal.encryption.kms.createResource({
|
|
630
|
-
keyUris: [unboundedKeyUri]
|
|
631
|
-
});
|
|
632
|
-
return _context13.abrupt("return", unboundedKeyUri);
|
|
633
|
-
case 9:
|
|
634
|
-
case "end":
|
|
635
|
-
return _context13.stop();
|
|
636
|
-
}
|
|
637
|
-
}, _callee12, this);
|
|
638
|
-
}));
|
|
639
|
-
function createNewEncryptionKeyUrl() {
|
|
640
|
-
return _createNewEncryptionKeyUrl.apply(this, arguments);
|
|
641
|
-
}
|
|
642
|
-
return createNewEncryptionKeyUrl;
|
|
643
|
-
}()
|
|
644
|
-
/**
|
|
645
|
-
* Fetches the encryptionKeyUrl from one of the groups. Creates a new key and default group if there is no data.
|
|
646
|
-
*
|
|
647
|
-
* @returns EncryptionKeyUrl as a Promise.
|
|
648
|
-
*/
|
|
649
|
-
}, {
|
|
650
|
-
key: "fetchEncryptionKeyUrl",
|
|
651
|
-
value: function () {
|
|
652
|
-
var _fetchEncryptionKeyUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
|
|
653
|
-
var _response$data$group;
|
|
654
|
-
var response, _response$data$group2;
|
|
655
|
-
return _regenerator.default.wrap(function _callee13$(_context14) {
|
|
656
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
657
|
-
case 0:
|
|
658
|
-
if (!this.encryptionKeyUrl) {
|
|
659
|
-
_context14.next = 2;
|
|
660
|
-
break;
|
|
661
|
-
}
|
|
662
|
-
return _context14.abrupt("return", this.encryptionKeyUrl);
|
|
663
|
-
case 2:
|
|
664
|
-
// istanbul ignore else
|
|
665
|
-
if (this.groups === undefined) {
|
|
666
|
-
this.getContacts();
|
|
667
|
-
}
|
|
668
|
-
// istanbul ignore else
|
|
669
|
-
if (!(this.groups && this.groups.length)) {
|
|
670
|
-
_context14.next = 5;
|
|
671
|
-
break;
|
|
672
|
-
}
|
|
673
|
-
return _context14.abrupt("return", this.groups[0].encryptionKeyUrl);
|
|
674
|
-
case 5:
|
|
675
|
-
_context14.next = 7;
|
|
676
|
-
return this.createNewEncryptionKeyUrl();
|
|
677
|
-
case 7:
|
|
678
|
-
this.encryptionKeyUrl = _context14.sent;
|
|
679
|
-
_Logger.default.info("Creating a default group: ".concat(_constants2.DEFAULT_GROUP_NAME), {
|
|
680
|
-
file: _constants2.CONTACTS_FILE,
|
|
681
|
-
method: this.fetchEncryptionKeyUrl.name
|
|
682
|
-
});
|
|
683
|
-
_context14.next = 11;
|
|
684
|
-
return this.createContactGroup(_constants2.DEFAULT_GROUP_NAME, this.encryptionKeyUrl);
|
|
685
|
-
case 11:
|
|
686
|
-
response = _context14.sent;
|
|
687
|
-
if ((_response$data$group = response.data.group) !== null && _response$data$group !== void 0 && _response$data$group.groupId) {
|
|
688
|
-
this.defaultGroupId = (_response$data$group2 = response.data.group) === null || _response$data$group2 === void 0 ? void 0 : _response$data$group2.groupId;
|
|
689
|
-
}
|
|
690
|
-
return _context14.abrupt("return", this.encryptionKeyUrl);
|
|
691
|
-
case 14:
|
|
692
|
-
case "end":
|
|
693
|
-
return _context14.stop();
|
|
694
|
-
}
|
|
695
|
-
}, _callee13, this);
|
|
696
|
-
}));
|
|
697
|
-
function fetchEncryptionKeyUrl() {
|
|
698
|
-
return _fetchEncryptionKeyUrl.apply(this, arguments);
|
|
699
|
-
}
|
|
700
|
-
return fetchEncryptionKeyUrl;
|
|
701
|
-
}()
|
|
702
|
-
/**
|
|
703
|
-
* Fetches a default group.
|
|
704
|
-
*
|
|
705
|
-
* @returns GroupId of default group.
|
|
706
|
-
*/
|
|
707
|
-
}, {
|
|
708
|
-
key: "fetchDefaultGroup",
|
|
709
|
-
value: function () {
|
|
710
|
-
var _fetchDefaultGroup = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
|
|
711
|
-
var i, response, group;
|
|
712
|
-
return _regenerator.default.wrap(function _callee14$(_context15) {
|
|
713
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
714
|
-
case 0:
|
|
715
|
-
if (!this.defaultGroupId) {
|
|
716
|
-
_context15.next = 2;
|
|
717
|
-
break;
|
|
718
|
-
}
|
|
719
|
-
return _context15.abrupt("return", this.defaultGroupId);
|
|
720
|
-
case 2:
|
|
721
|
-
if (!(this.groups && this.groups.length)) {
|
|
722
|
-
_context15.next = 11;
|
|
723
|
-
break;
|
|
724
|
-
}
|
|
725
|
-
i = 0;
|
|
726
|
-
case 4:
|
|
727
|
-
if (!(i < this.groups.length)) {
|
|
728
|
-
_context15.next = 11;
|
|
729
|
-
break;
|
|
730
|
-
}
|
|
731
|
-
if (!(this.groups[i].displayName === _constants2.DEFAULT_GROUP_NAME)) {
|
|
732
|
-
_context15.next = 8;
|
|
733
|
-
break;
|
|
734
|
-
}
|
|
735
|
-
this.defaultGroupId = this.groups[i].groupId;
|
|
736
|
-
return _context15.abrupt("return", this.defaultGroupId);
|
|
737
|
-
case 8:
|
|
738
|
-
i += 1;
|
|
739
|
-
_context15.next = 4;
|
|
740
|
-
break;
|
|
741
|
-
case 11:
|
|
742
|
-
_Logger.default.info('No default group found.', {
|
|
743
|
-
file: _constants2.CONTACTS_FILE,
|
|
744
|
-
method: this.fetchDefaultGroup.name
|
|
745
|
-
});
|
|
746
|
-
_context15.next = 14;
|
|
747
|
-
return this.createContactGroup(_constants2.DEFAULT_GROUP_NAME);
|
|
748
|
-
case 14:
|
|
749
|
-
response = _context15.sent;
|
|
750
|
-
group = response.data.group;
|
|
751
|
-
if (!group) {
|
|
752
|
-
_context15.next = 18;
|
|
753
|
-
break;
|
|
754
|
-
}
|
|
755
|
-
return _context15.abrupt("return", group.groupId);
|
|
756
|
-
case 18:
|
|
757
|
-
return _context15.abrupt("return", '');
|
|
758
|
-
case 19:
|
|
759
|
-
case "end":
|
|
760
|
-
return _context15.stop();
|
|
761
|
-
}
|
|
762
|
-
}, _callee14, this);
|
|
763
|
-
}));
|
|
764
|
-
function fetchDefaultGroup() {
|
|
765
|
-
return _fetchDefaultGroup.apply(this, arguments);
|
|
766
|
-
}
|
|
767
|
-
return fetchDefaultGroup;
|
|
768
|
-
}()
|
|
769
|
-
/**
|
|
770
|
-
* Creates a personal contact group.
|
|
771
|
-
* Also creates a KRO, if there aren't any groups.
|
|
772
|
-
* @param displayName - Name of the group to create.
|
|
773
|
-
* @param encryptionKeyUrl - EncryptionKeyUrl to encrypt the displayName.
|
|
774
|
-
* @param groupType - Type of the group to create.
|
|
775
|
-
*/
|
|
776
|
-
}, {
|
|
777
|
-
key: "createContactGroup",
|
|
778
|
-
value: function () {
|
|
779
|
-
var _createContactGroup = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(displayName, encryptionKeyUrl, groupType) {
|
|
780
|
-
var loggerContext, encryptionKeyUrlFinal, isExistingGroup, encryptedDisplayName, groupInfo, _this$groups, response, group, contactResponse, errorInfo, errorStatus;
|
|
781
|
-
return _regenerator.default.wrap(function _callee15$(_context16) {
|
|
782
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
783
|
-
case 0:
|
|
784
|
-
loggerContext = {
|
|
785
|
-
file: _constants2.CONTACTS_FILE,
|
|
786
|
-
method: this.createContactGroup.name
|
|
787
|
-
};
|
|
788
|
-
_Logger.default.info("Creating contact group ".concat(displayName), loggerContext);
|
|
789
|
-
_context16.t0 = encryptionKeyUrl;
|
|
790
|
-
if (_context16.t0) {
|
|
791
|
-
_context16.next = 7;
|
|
792
|
-
break;
|
|
793
|
-
}
|
|
794
|
-
_context16.next = 6;
|
|
795
|
-
return this.fetchEncryptionKeyUrl();
|
|
796
|
-
case 6:
|
|
797
|
-
_context16.t0 = _context16.sent;
|
|
798
|
-
case 7:
|
|
799
|
-
encryptionKeyUrlFinal = _context16.t0;
|
|
800
|
-
if (!(this.groups === undefined)) {
|
|
801
|
-
_context16.next = 11;
|
|
802
|
-
break;
|
|
803
|
-
}
|
|
804
|
-
_context16.next = 11;
|
|
805
|
-
return this.getContacts();
|
|
806
|
-
case 11:
|
|
807
|
-
if (!(this.groups && this.groups.length)) {
|
|
808
|
-
_context16.next = 16;
|
|
809
|
-
break;
|
|
810
|
-
}
|
|
811
|
-
isExistingGroup = this.groups.find(function (group) {
|
|
812
|
-
return group.displayName === displayName;
|
|
813
|
-
});
|
|
814
|
-
if (!isExistingGroup) {
|
|
815
|
-
_context16.next = 16;
|
|
816
|
-
break;
|
|
817
|
-
}
|
|
818
|
-
_Logger.default.warn("Group name ".concat(displayName, " already exists."), loggerContext);
|
|
819
|
-
return _context16.abrupt("return", {
|
|
820
|
-
statusCode: 400,
|
|
821
|
-
data: {
|
|
822
|
-
error: 'Group displayName already exists'
|
|
823
|
-
},
|
|
824
|
-
message: _constants.FAILURE_MESSAGE
|
|
825
|
-
});
|
|
826
|
-
case 16:
|
|
827
|
-
_context16.next = 18;
|
|
828
|
-
return this.webex.internal.encryption.encryptText(encryptionKeyUrlFinal, displayName);
|
|
829
|
-
case 18:
|
|
830
|
-
encryptedDisplayName = _context16.sent;
|
|
831
|
-
groupInfo = {
|
|
832
|
-
schemas: _constants2.CONTACTS_SCHEMA,
|
|
833
|
-
displayName: encryptedDisplayName,
|
|
834
|
-
groupType: groupType || _types2.GroupType.NORMAL,
|
|
835
|
-
encryptionKeyUrl: encryptionKeyUrlFinal
|
|
836
|
-
};
|
|
837
|
-
_context16.prev = 20;
|
|
838
|
-
_context16.next = 23;
|
|
839
|
-
return this.webex.request({
|
|
840
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
841
|
-
uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.GROUP_FILTER),
|
|
842
|
-
method: _types.HTTP_METHODS.POST,
|
|
843
|
-
body: groupInfo
|
|
844
|
-
});
|
|
845
|
-
case 23:
|
|
846
|
-
response = _context16.sent;
|
|
847
|
-
group = response.body;
|
|
848
|
-
group.displayName = displayName;
|
|
849
|
-
contactResponse = {
|
|
850
|
-
statusCode: Number(response[_constants.STATUS_CODE]),
|
|
851
|
-
data: {
|
|
852
|
-
group: group
|
|
853
|
-
},
|
|
854
|
-
message: _constants.SUCCESS_MESSAGE
|
|
855
|
-
};
|
|
856
|
-
(_this$groups = this.groups) === null || _this$groups === void 0 ? void 0 : _this$groups.push(group);
|
|
857
|
-
return _context16.abrupt("return", contactResponse);
|
|
858
|
-
case 31:
|
|
859
|
-
_context16.prev = 31;
|
|
860
|
-
_context16.t1 = _context16["catch"](20);
|
|
861
|
-
_Logger.default.warn('Unable to create contact group.', loggerContext);
|
|
862
|
-
errorInfo = _context16.t1;
|
|
863
|
-
errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
|
|
864
|
-
return _context16.abrupt("return", errorStatus);
|
|
865
|
-
case 37:
|
|
866
|
-
case "end":
|
|
867
|
-
return _context16.stop();
|
|
868
|
-
}
|
|
869
|
-
}, _callee15, this, [[20, 31]]);
|
|
870
|
-
}));
|
|
871
|
-
function createContactGroup(_x14, _x15, _x16) {
|
|
872
|
-
return _createContactGroup.apply(this, arguments);
|
|
873
|
-
}
|
|
874
|
-
return createContactGroup;
|
|
875
|
-
}()
|
|
876
|
-
/**
|
|
877
|
-
* Deletes a contact group.
|
|
878
|
-
* @param groupId - GroupId of the group to delete.
|
|
879
|
-
*/
|
|
880
|
-
}, {
|
|
881
|
-
key: "deleteContactGroup",
|
|
882
|
-
value: function () {
|
|
883
|
-
var _deleteContactGroup = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(groupId) {
|
|
884
|
-
var loggerContext, _this$groups2, _this$groups4, response, contactResponse, groupToDelete, _this$groups3, errorInfo, errorStatus;
|
|
885
|
-
return _regenerator.default.wrap(function _callee16$(_context17) {
|
|
886
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
887
|
-
case 0:
|
|
888
|
-
loggerContext = {
|
|
889
|
-
file: _constants2.CONTACTS_FILE,
|
|
890
|
-
method: this.deleteContactGroup.name
|
|
891
|
-
};
|
|
892
|
-
_context17.prev = 1;
|
|
893
|
-
_Logger.default.info("Deleting contact group: ".concat(groupId), loggerContext);
|
|
894
|
-
_context17.next = 5;
|
|
895
|
-
return this.webex.request({
|
|
896
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
897
|
-
uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.GROUP_FILTER, "/").concat(groupId),
|
|
898
|
-
method: _types.HTTP_METHODS.DELETE
|
|
899
|
-
});
|
|
900
|
-
case 5:
|
|
901
|
-
response = _context17.sent;
|
|
902
|
-
contactResponse = {
|
|
903
|
-
statusCode: Number(response[_constants.STATUS_CODE]),
|
|
904
|
-
data: {},
|
|
905
|
-
message: _constants.SUCCESS_MESSAGE
|
|
906
|
-
};
|
|
907
|
-
groupToDelete = (_this$groups2 = this.groups) === null || _this$groups2 === void 0 ? void 0 : _this$groups2.findIndex(function (group) {
|
|
908
|
-
return group.groupId === groupId;
|
|
909
|
-
});
|
|
910
|
-
if (groupToDelete !== undefined && groupToDelete !== -1) {
|
|
911
|
-
(_this$groups3 = this.groups) === null || _this$groups3 === void 0 ? void 0 : _this$groups3.splice(groupToDelete, 1);
|
|
912
|
-
}
|
|
913
|
-
if (!((_this$groups4 = this.groups) !== null && _this$groups4 !== void 0 && _this$groups4.length)) {
|
|
914
|
-
this.defaultGroupId = '';
|
|
915
|
-
}
|
|
916
|
-
return _context17.abrupt("return", contactResponse);
|
|
917
|
-
case 13:
|
|
918
|
-
_context17.prev = 13;
|
|
919
|
-
_context17.t0 = _context17["catch"](1);
|
|
920
|
-
_Logger.default.warn("Unable to delete contact group ".concat(groupId), loggerContext);
|
|
921
|
-
errorInfo = _context17.t0;
|
|
922
|
-
errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
|
|
923
|
-
return _context17.abrupt("return", errorStatus);
|
|
924
|
-
case 19:
|
|
925
|
-
case "end":
|
|
926
|
-
return _context17.stop();
|
|
927
|
-
}
|
|
928
|
-
}, _callee16, this, [[1, 13]]);
|
|
929
|
-
}));
|
|
930
|
-
function deleteContactGroup(_x17) {
|
|
931
|
-
return _deleteContactGroup.apply(this, arguments);
|
|
932
|
-
}
|
|
933
|
-
return deleteContactGroup;
|
|
934
|
-
}()
|
|
935
|
-
/**
|
|
936
|
-
* Creates a custom contact.
|
|
937
|
-
* @param contactInfo - Contact object to create.
|
|
938
|
-
*/
|
|
939
|
-
}, {
|
|
940
|
-
key: "createContact",
|
|
941
|
-
value: function () {
|
|
942
|
-
var _createContact = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(contactInfo) {
|
|
943
|
-
var loggerContext, contact, defaultGroupId, requestBody, encryptedContact, _encryptedContact, response, newContact, contactResponse, decryptedContacts, _this$contacts, _this$contacts2, errorInfo, errorStatus;
|
|
944
|
-
return _regenerator.default.wrap(function _callee17$(_context18) {
|
|
945
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
946
|
-
case 0:
|
|
947
|
-
loggerContext = {
|
|
948
|
-
file: _constants2.CONTACTS_FILE,
|
|
949
|
-
method: this.createContact.name
|
|
950
|
-
};
|
|
951
|
-
_Logger.default.info("Request to create contact: contactType: ".concat(contactInfo.contactType), loggerContext);
|
|
952
|
-
_context18.prev = 2;
|
|
953
|
-
contact = _objectSpread({}, contactInfo);
|
|
954
|
-
if (contact.encryptionKeyUrl) {
|
|
955
|
-
_context18.next = 8;
|
|
956
|
-
break;
|
|
957
|
-
}
|
|
958
|
-
_context18.next = 7;
|
|
959
|
-
return this.fetchEncryptionKeyUrl();
|
|
960
|
-
case 7:
|
|
961
|
-
contact.encryptionKeyUrl = _context18.sent;
|
|
962
|
-
case 8:
|
|
963
|
-
if (!(!contact.groups || contact.groups.length === 0)) {
|
|
964
|
-
_context18.next = 13;
|
|
965
|
-
break;
|
|
966
|
-
}
|
|
967
|
-
_context18.next = 11;
|
|
968
|
-
return this.fetchDefaultGroup();
|
|
969
|
-
case 11:
|
|
970
|
-
defaultGroupId = _context18.sent;
|
|
971
|
-
contact.groups = [defaultGroupId];
|
|
972
|
-
case 13:
|
|
973
|
-
contact.schemas = _constants2.CONTACTS_SCHEMA;
|
|
974
|
-
requestBody = {};
|
|
975
|
-
_context18.t0 = contact.contactType;
|
|
976
|
-
_context18.next = _context18.t0 === _types2.ContactType.CUSTOM ? 18 : _context18.t0 === _types2.ContactType.CLOUD ? 23 : 30;
|
|
977
|
-
break;
|
|
978
|
-
case 18:
|
|
979
|
-
_context18.next = 20;
|
|
980
|
-
return this.encryptContact(contact);
|
|
981
|
-
case 20:
|
|
982
|
-
encryptedContact = _context18.sent;
|
|
983
|
-
requestBody = encryptedContact;
|
|
984
|
-
return _context18.abrupt("break", 31);
|
|
985
|
-
case 23:
|
|
986
|
-
if (contact.contactId) {
|
|
987
|
-
_context18.next = 25;
|
|
988
|
-
break;
|
|
989
|
-
}
|
|
990
|
-
return _context18.abrupt("return", {
|
|
991
|
-
statusCode: 400,
|
|
992
|
-
data: {
|
|
993
|
-
error: 'contactId is required for contactType:CLOUD.'
|
|
994
|
-
},
|
|
995
|
-
message: _constants.FAILURE_MESSAGE
|
|
996
|
-
});
|
|
997
|
-
case 25:
|
|
998
|
-
_context18.next = 27;
|
|
999
|
-
return this.encryptContact(contact);
|
|
1000
|
-
case 27:
|
|
1001
|
-
_encryptedContact = _context18.sent;
|
|
1002
|
-
requestBody = _encryptedContact;
|
|
1003
|
-
return _context18.abrupt("break", 31);
|
|
1004
|
-
case 30:
|
|
1005
|
-
return _context18.abrupt("return", {
|
|
1006
|
-
statusCode: 400,
|
|
1007
|
-
data: {
|
|
1008
|
-
error: 'Unknown contactType received.'
|
|
1009
|
-
},
|
|
1010
|
-
message: _constants.FAILURE_MESSAGE
|
|
1011
|
-
});
|
|
1012
|
-
case 31:
|
|
1013
|
-
_context18.next = 33;
|
|
1014
|
-
return this.webex.request({
|
|
1015
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
1016
|
-
uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.CONTACT_FILTER),
|
|
1017
|
-
method: _types.HTTP_METHODS.POST,
|
|
1018
|
-
body: requestBody
|
|
1019
|
-
});
|
|
1020
|
-
case 33:
|
|
1021
|
-
response = _context18.sent;
|
|
1022
|
-
newContact = response.body;
|
|
1023
|
-
contact.contactId = newContact.contactId;
|
|
1024
|
-
contactResponse = {
|
|
1025
|
-
statusCode: Number(response[_constants.STATUS_CODE]),
|
|
1026
|
-
data: {
|
|
1027
|
-
contact: contact
|
|
1028
|
-
},
|
|
1029
|
-
message: _constants.SUCCESS_MESSAGE
|
|
1030
|
-
};
|
|
1031
|
-
if (!(contact.contactType === _types2.ContactType.CLOUD)) {
|
|
1032
|
-
_context18.next = 44;
|
|
1033
|
-
break;
|
|
1034
|
-
}
|
|
1035
|
-
_context18.next = 40;
|
|
1036
|
-
return this.fetchContactFromDSS(Object.fromEntries([[newContact.contactId, newContact]]));
|
|
1037
|
-
case 40:
|
|
1038
|
-
decryptedContacts = _context18.sent;
|
|
1039
|
-
if (decryptedContacts.length && decryptedContacts[0]) {
|
|
1040
|
-
(_this$contacts = this.contacts) === null || _this$contacts === void 0 ? void 0 : _this$contacts.push(decryptedContacts[0]);
|
|
1041
|
-
}
|
|
1042
|
-
_context18.next = 45;
|
|
1043
|
-
break;
|
|
1044
|
-
case 44:
|
|
1045
|
-
(_this$contacts2 = this.contacts) === null || _this$contacts2 === void 0 ? void 0 : _this$contacts2.push(contact);
|
|
1046
|
-
case 45:
|
|
1047
|
-
return _context18.abrupt("return", contactResponse);
|
|
1048
|
-
case 48:
|
|
1049
|
-
_context18.prev = 48;
|
|
1050
|
-
_context18.t1 = _context18["catch"](2);
|
|
1051
|
-
_Logger.default.warn('Failed to create contact.', {
|
|
1052
|
-
file: _constants2.CONTACTS_FILE,
|
|
1053
|
-
method: this.createContact.name
|
|
1054
|
-
});
|
|
1055
|
-
errorInfo = _context18.t1;
|
|
1056
|
-
errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
|
|
1057
|
-
return _context18.abrupt("return", errorStatus);
|
|
1058
|
-
case 54:
|
|
1059
|
-
case "end":
|
|
1060
|
-
return _context18.stop();
|
|
1061
|
-
}
|
|
1062
|
-
}, _callee17, this, [[2, 48]]);
|
|
1063
|
-
}));
|
|
1064
|
-
function createContact(_x18) {
|
|
1065
|
-
return _createContact.apply(this, arguments);
|
|
1066
|
-
}
|
|
1067
|
-
return createContact;
|
|
1068
|
-
}()
|
|
1069
|
-
/**
|
|
1070
|
-
* Delete a contact.
|
|
1071
|
-
* @param contactId - ContactId of the contact to delete.
|
|
1072
|
-
*/
|
|
1073
|
-
}, {
|
|
1074
|
-
key: "deleteContact",
|
|
1075
|
-
value: function () {
|
|
1076
|
-
var _deleteContact = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(contactId) {
|
|
1077
|
-
var loggerContext, _this$contacts3, response, contactResponse, contactToDelete, _this$contacts4, errorInfo, errorStatus;
|
|
1078
|
-
return _regenerator.default.wrap(function _callee18$(_context19) {
|
|
1079
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
1080
|
-
case 0:
|
|
1081
|
-
loggerContext = {
|
|
1082
|
-
file: _constants2.CONTACTS_FILE,
|
|
1083
|
-
method: this.deleteContact.name
|
|
1084
|
-
};
|
|
1085
|
-
_context19.prev = 1;
|
|
1086
|
-
_Logger.default.info("Deleting contact : ".concat(contactId), loggerContext);
|
|
1087
|
-
_context19.next = 5;
|
|
1088
|
-
return this.webex.request({
|
|
1089
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
1090
|
-
uri: "".concat(this.webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.CONTACT_FILTER, "/").concat(contactId),
|
|
1091
|
-
method: _types.HTTP_METHODS.DELETE
|
|
1092
|
-
});
|
|
1093
|
-
case 5:
|
|
1094
|
-
response = _context19.sent;
|
|
1095
|
-
contactResponse = {
|
|
1096
|
-
statusCode: Number(response[_constants.STATUS_CODE]),
|
|
1097
|
-
data: {},
|
|
1098
|
-
message: _constants.SUCCESS_MESSAGE
|
|
1099
|
-
};
|
|
1100
|
-
contactToDelete = (_this$contacts3 = this.contacts) === null || _this$contacts3 === void 0 ? void 0 : _this$contacts3.findIndex(function (contact) {
|
|
1101
|
-
return contact.contactId === contactId;
|
|
1102
|
-
});
|
|
1103
|
-
if (contactToDelete !== undefined && contactToDelete !== -1) {
|
|
1104
|
-
(_this$contacts4 = this.contacts) === null || _this$contacts4 === void 0 ? void 0 : _this$contacts4.splice(contactToDelete, 1);
|
|
1105
|
-
}
|
|
1106
|
-
return _context19.abrupt("return", contactResponse);
|
|
1107
|
-
case 12:
|
|
1108
|
-
_context19.prev = 12;
|
|
1109
|
-
_context19.t0 = _context19["catch"](1);
|
|
1110
|
-
_Logger.default.warn("Unable to delete contact ".concat(contactId), loggerContext);
|
|
1111
|
-
errorInfo = _context19.t0;
|
|
1112
|
-
errorStatus = (0, _Utils.serviceErrorCodeHandler)(errorInfo, loggerContext);
|
|
1113
|
-
return _context19.abrupt("return", errorStatus);
|
|
1114
|
-
case 18:
|
|
1115
|
-
case "end":
|
|
1116
|
-
return _context19.stop();
|
|
1117
|
-
}
|
|
1118
|
-
}, _callee18, this, [[1, 12]]);
|
|
1119
|
-
}));
|
|
1120
|
-
function deleteContact(_x19) {
|
|
1121
|
-
return _deleteContact.apply(this, arguments);
|
|
1122
|
-
}
|
|
1123
|
-
return deleteContact;
|
|
1124
|
-
}()
|
|
1125
|
-
}]);
|
|
1126
|
-
return ContactsClient;
|
|
1127
|
-
}();
|
|
1128
|
-
/**
|
|
1129
|
-
* Creates a ContactsClient instance
|
|
1130
|
-
*
|
|
1131
|
-
* @param {WebexSDK} webex - `Webex SDK`instance.
|
|
1132
|
-
* @param {LoggerInterface} logger - An instance implementing LoggerInterface used to set the log level for the module.
|
|
1133
|
-
*/
|
|
1134
|
-
exports.ContactsClient = ContactsClient;
|
|
1135
|
-
var createContactsClient = function createContactsClient(webex, logger) {
|
|
1136
|
-
return new ContactsClient(webex, logger);
|
|
1137
|
-
};
|
|
1138
|
-
exports.createContactsClient = createContactsClient;
|
|
1139
|
-
//# sourceMappingURL=ContactsClient.js.map
|