@webex/internal-plugin-calendar 2.48.0 → 2.50.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.
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
+ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
10
+ var _decryptTextProp = function _decryptTextProp(ctx, name, key, object) {
11
+ if (!object[name]) {
12
+ return _promise.default.resolve();
13
+ }
14
+ return ctx.webex.internal.encryption.decryptText(key.uri || key, object[name]).then(function (plaintext) {
15
+ object[name] = plaintext;
16
+ });
17
+ };
18
+ var DecryptHelper = {
19
+ /**
20
+ * Decrypt scheduler data response
21
+ * @param {object} [ctx] context
22
+ * @param {object} [data] scheduler data response
23
+ * @returns {Promise} Resolves with decrypted response
24
+ * */
25
+ decryptSchedulerDataResponse: function decryptSchedulerDataResponse(ctx, data) {
26
+ if (!data) {
27
+ return _promise.default.resolve();
28
+ }
29
+ if (!data.encryptionKeyUrl) {
30
+ return _promise.default.resolve();
31
+ }
32
+
33
+ // Decrypt participant properties if meeting object contains participants
34
+ var decryptedParticipants = data.encryptedParticipants ? data.encryptedParticipants.map(function (participant) {
35
+ return _promise.default.all([_decryptTextProp(ctx, 'encryptedEmailAddress', data.encryptionKeyUrl, participant), _decryptTextProp(ctx, 'encryptedName', data.encryptionKeyUrl, participant)]);
36
+ }) : [];
37
+
38
+ // Decrypt meetingJoinInfo properties if meeting object contains meetingJoinInfo
39
+ var decryptedMeetingJoinInfo = data.meetingJoinInfo ? _promise.default.all([_decryptTextProp(ctx, 'meetingJoinURI', data.encryptionKeyUrl, data.meetingJoinInfo), _decryptTextProp(ctx, 'meetingJoinURL', data.encryptionKeyUrl, data.meetingJoinInfo)]) : [];
40
+ var decryptedOrganizer = data.encryptedOrganizer ? _promise.default.all([_decryptTextProp(ctx, 'encryptedEmailAddress', data.encryptionKeyUrl, data.encryptedOrganizer), _decryptTextProp(ctx, 'encryptedName', data.encryptionKeyUrl, data.encryptedOrganizer)]) : [];
41
+ return _promise.default.all([_decryptTextProp(ctx, 'encryptedSubject', data.encryptionKeyUrl, data), _decryptTextProp(ctx, 'encryptedLocation', data.encryptionKeyUrl, data), _decryptTextProp(ctx, 'encryptedNotes', data.encryptionKeyUrl, data), _decryptTextProp(ctx, 'webexURI', data.encryptionKeyUrl, data), _decryptTextProp(ctx, 'webexURL', data.encryptionKeyUrl, data), _decryptTextProp(ctx, 'spaceMeetURL', data.encryptionKeyUrl, data), _decryptTextProp(ctx, 'spaceURI', data.encryptionKeyUrl, data), _decryptTextProp(ctx, 'spaceURL', data.encryptionKeyUrl, data)].concat(decryptedOrganizer, decryptedParticipants, decryptedMeetingJoinInfo));
42
+ },
43
+ /**
44
+ * Decrypt free-busy response
45
+ * @param {object} [ctx] context
46
+ * @param {object} [data] free-busy response
47
+ * @returns {Promise} Resolves with decrypted response
48
+ * */
49
+ decryptFreeBusyResponse: function decryptFreeBusyResponse(ctx, data) {
50
+ if (!data) {
51
+ return _promise.default.resolve();
52
+ }
53
+ if (!data.calendarFreeBusyScheduleResponse) {
54
+ return _promise.default.resolve();
55
+ }
56
+ if (!data.calendarFreeBusyScheduleResponse.encryptionKeyUrl) {
57
+ return _promise.default.resolve();
58
+ }
59
+ var calendarFreeBusyItems = data.calendarFreeBusyScheduleResponse.calendarFreeBusyItems ? data.calendarFreeBusyScheduleResponse.calendarFreeBusyItems.map(function (calendarFreeBusyItem) {
60
+ return _promise.default.all([_decryptTextProp(ctx, 'email', data.calendarFreeBusyScheduleResponse.encryptionKeyUrl, calendarFreeBusyItem)]);
61
+ }) : [];
62
+ return _promise.default.all([].concat(calendarFreeBusyItems));
63
+ }
64
+ };
65
+ var _default = DecryptHelper;
66
+ exports.default = _default;
67
+ //# sourceMappingURL=calendar.decrypt.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_decryptTextProp","ctx","name","key","object","_promise","default","resolve","webex","internal","encryption","decryptText","uri","then","plaintext","DecryptHelper","decryptSchedulerDataResponse","data","encryptionKeyUrl","decryptedParticipants","encryptedParticipants","map","participant","all","decryptedMeetingJoinInfo","meetingJoinInfo","decryptedOrganizer","encryptedOrganizer","concat","decryptFreeBusyResponse","calendarFreeBusyScheduleResponse","calendarFreeBusyItems","calendarFreeBusyItem","_default","exports"],"sources":["calendar.decrypt.helper.js"],"sourcesContent":["const _decryptTextProp = (ctx, name, key, object) => {\n if (!object[name]) {\n return Promise.resolve();\n }\n\n return ctx.webex.internal.encryption\n .decryptText(key.uri || key, object[name])\n .then((plaintext) => {\n object[name] = plaintext;\n });\n};\n\nconst DecryptHelper = {\n /**\n * Decrypt scheduler data response\n * @param {object} [ctx] context\n * @param {object} [data] scheduler data response\n * @returns {Promise} Resolves with decrypted response\n * */\n decryptSchedulerDataResponse: (ctx, data) => {\n if (!data) {\n return Promise.resolve();\n }\n\n if (!data.encryptionKeyUrl) {\n return Promise.resolve();\n }\n\n // Decrypt participant properties if meeting object contains participants\n const decryptedParticipants = data.encryptedParticipants\n ? data.encryptedParticipants.map((participant) =>\n Promise.all([\n _decryptTextProp(ctx, 'encryptedEmailAddress', data.encryptionKeyUrl, participant),\n _decryptTextProp(ctx, 'encryptedName', data.encryptionKeyUrl, participant),\n ])\n )\n : [];\n\n // Decrypt meetingJoinInfo properties if meeting object contains meetingJoinInfo\n const decryptedMeetingJoinInfo = data.meetingJoinInfo\n ? Promise.all([\n _decryptTextProp(ctx, 'meetingJoinURI', data.encryptionKeyUrl, data.meetingJoinInfo),\n _decryptTextProp(ctx, 'meetingJoinURL', data.encryptionKeyUrl, data.meetingJoinInfo),\n ])\n : [];\n\n const decryptedOrganizer = data.encryptedOrganizer\n ? Promise.all([\n _decryptTextProp(\n ctx,\n 'encryptedEmailAddress',\n data.encryptionKeyUrl,\n data.encryptedOrganizer\n ),\n _decryptTextProp(ctx, 'encryptedName', data.encryptionKeyUrl, data.encryptedOrganizer),\n ])\n : [];\n\n return Promise.all(\n [\n _decryptTextProp(ctx, 'encryptedSubject', data.encryptionKeyUrl, data),\n _decryptTextProp(ctx, 'encryptedLocation', data.encryptionKeyUrl, data),\n _decryptTextProp(ctx, 'encryptedNotes', data.encryptionKeyUrl, data),\n _decryptTextProp(ctx, 'webexURI', data.encryptionKeyUrl, data),\n _decryptTextProp(ctx, 'webexURL', data.encryptionKeyUrl, data),\n _decryptTextProp(ctx, 'spaceMeetURL', data.encryptionKeyUrl, data),\n _decryptTextProp(ctx, 'spaceURI', data.encryptionKeyUrl, data),\n _decryptTextProp(ctx, 'spaceURL', data.encryptionKeyUrl, data),\n ].concat(decryptedOrganizer, decryptedParticipants, decryptedMeetingJoinInfo)\n );\n },\n /**\n * Decrypt free-busy response\n * @param {object} [ctx] context\n * @param {object} [data] free-busy response\n * @returns {Promise} Resolves with decrypted response\n * */\n decryptFreeBusyResponse: (ctx, data) => {\n if (!data) {\n return Promise.resolve();\n }\n\n if (!data.calendarFreeBusyScheduleResponse) {\n return Promise.resolve();\n }\n\n if (!data.calendarFreeBusyScheduleResponse.encryptionKeyUrl) {\n return Promise.resolve();\n }\n\n const calendarFreeBusyItems = data.calendarFreeBusyScheduleResponse.calendarFreeBusyItems\n ? data.calendarFreeBusyScheduleResponse.calendarFreeBusyItems.map((calendarFreeBusyItem) =>\n Promise.all([\n _decryptTextProp(\n ctx,\n 'email',\n data.calendarFreeBusyScheduleResponse.encryptionKeyUrl,\n calendarFreeBusyItem\n ),\n ])\n )\n : [];\n\n return Promise.all([].concat(calendarFreeBusyItems));\n },\n};\n\nexport default DecryptHelper;\n"],"mappings":";;;;;;;;;AAAA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,GAAG,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAA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B,EAAED,IAAI,CAAC,CAC/D,CAACW,MAAM,CAACF,kBAAkB,EAAEP,qBAAqB,EAAEK,wBAAwB,CAAC,CAC9E;EACH,CAAC;EACD;AACF;AACA;AACA;AACA;AACA;EACEK,uBAAuB,EAAE,SAAAA,wBAAC5B,GAAG,EAAEgB,IAAI,EAAK;IACtC,IAAI,CAACA,IAAI,EAAE;MACT,OAAOZ,QAAA,CAAAC,OAAA,CAAQC,OAAO,EAAE;IAC1B;IAEA,IAAI,CAACU,IAAI,CAACa,gCAAgC,EAAE;MAC1C,OAAOzB,QAAA,CAAAC,OAAA,CAAQC,OAAO,EAAE;IAC1B;IAEA,IAAI,CAACU,IAAI,CAACa,gCAAgC,CAACZ,gBAAgB,EAAE;MAC3D,OAAOb,QAAA,CAAAC,OAAA,CAAQC,OAAO,EAAE;IAC1B;IAEA,IAAMwB,qBAAqB,GAAGd,IAAI,CAACa,gCAAgC,CAACC,qBAAqB,GACrFd,IAAI,CAACa,gCAAgC,CAACC,qBAAqB,CAACV,GAAG,CAAC,UAACW,oBAAoB;MAAA,OACnF3B,QAAA,CAAAC,OAAA,CAAQiB,GAAG,CAAC,CACVvB,gBAAgB,CACdC,GAAG,EACH,OAAO,EACPgB,IAAI,CAACa,gCAAgC,CAACZ,gBAAgB,EACtDc,oBAAoB,CACrB,CACF,CAAC;IAAA,EACH,GACD,EAAE;IAEN,OAAO3B,QAAA,CAAAC,OAAA,CAAQiB,GAAG,CAAC,EAAE,CAACK,MAAM,CAACG,qBAAqB,CAAC,CAAC;EACtD;AACF,CAAC;AAAC,IAAAE,QAAA,GAEalB,aAAa;AAAAmB,OAAA,CAAA5B,OAAA,GAAA2B,QAAA"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
+ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
10
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
11
+ var _isArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
12
+ var _isArray3 = _interopRequireDefault(require("lodash/isArray"));
13
+ var _encryptTextProp = function _encryptTextProp(ctx, name, key, object) {
14
+ if (!object[name]) {
15
+ return _promise.default.resolve();
16
+ }
17
+ return ctx.webex.internal.encryption.encryptText(key.uri || key, object[name]).then(function (ciphertext) {
18
+ object[name] = ciphertext;
19
+ });
20
+ };
21
+ var _encryptCalendarEventPayload = function _encryptCalendarEventPayload(data, ctx) {
22
+ (0, _assign.default)(data, {
23
+ encryptionKeyUrl: ctx.encryptionKeyUrl
24
+ });
25
+ var encryptedAttendees = data.attendees ? data.attendees.map(function (attendee) {
26
+ return _promise.default.all([_encryptTextProp(ctx, 'displayName', data.encryptionKeyUrl, attendee), _encryptTextProp(ctx, 'email', data.encryptionKeyUrl, attendee)]);
27
+ }) : [];
28
+ return _promise.default.all([_encryptTextProp(ctx, 'subject', data.encryptionKeyUrl, data), _encryptTextProp(ctx, 'notes', data.encryptionKeyUrl, data), _encryptTextProp(ctx, 'webexOptions', data.encryptionKeyUrl, data)].concat([encryptedAttendees]));
29
+ };
30
+ var _encryptFreeBusyPayload = function _encryptFreeBusyPayload(data, ctx) {
31
+ (0, _assign.default)(data, {
32
+ encryptionKeyUrl: ctx.encryptionKeyUrl
33
+ });
34
+ var promises = [];
35
+ if (data.emails && (0, _isArray2.default)(data.emails)) {
36
+ data.emails.map(function (item, index) {
37
+ return promises.push(ctx.webex.internal.encryption.encryptText(data.encryptionKeyUrl, item).then(function (encryptText) {
38
+ data.emails[index] = encryptText;
39
+ }));
40
+ });
41
+ }
42
+ return _promise.default.all(promises);
43
+ };
44
+ var EncryptHelper = {
45
+ /**
46
+ * Encrypt create / update calendar event request payload
47
+ * @param {object} [ctx] context
48
+ * @param {object} [data] meeting payload data
49
+ * @returns {Promise} Resolves with encrypted request payload
50
+ * */
51
+ encryptCalendarEventRequest: function encryptCalendarEventRequest(ctx, data) {
52
+ if (ctx.encryptionKeyUrl) {
53
+ return _encryptCalendarEventPayload(data, ctx);
54
+ }
55
+ return ctx.webex.internal.encryption.kms.createUnboundKeys({
56
+ count: 1
57
+ }).then(function (keys) {
58
+ var key = (0, _isArray3.default)(keys) ? keys[0] : keys;
59
+ ctx.encryptionKeyUrl = key.uri;
60
+ return _encryptCalendarEventPayload(data, ctx);
61
+ });
62
+ },
63
+ /**
64
+ * Encrypt free-busy request payload
65
+ * @param {object} [ctx] context
66
+ * @param {object} [data] free busy payload data
67
+ * @returns {Promise} Resolves with encrypted request payload
68
+ * */
69
+ encryptFreeBusyRequest: function encryptFreeBusyRequest(ctx, data) {
70
+ if (ctx.encryptionKeyUrl) {
71
+ return _encryptFreeBusyPayload(data, ctx);
72
+ }
73
+ return ctx.webex.internal.encryption.kms.createUnboundKeys({
74
+ count: 1
75
+ }).then(function (keys) {
76
+ var key = (0, _isArray3.default)(keys) ? keys[0] : keys;
77
+ ctx.encryptionKeyUrl = key.uri;
78
+ return _encryptFreeBusyPayload(data, ctx);
79
+ });
80
+ }
81
+ };
82
+ var _default = EncryptHelper;
83
+ exports.default = _default;
84
+ //# sourceMappingURL=calendar.encrypt.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_encryptTextProp","ctx","name","key","object","_promise","default","resolve","webex","internal","encryption","encryptText","uri","then","ciphertext","_encryptCalendarEventPayload","data","_assign","encryptionKeyUrl","encryptedAttendees","attendees","map","attendee","all","concat","_encryptFreeBusyPayload","promises","emails","_isArray2","item","index","push","EncryptHelper","encryptCalendarEventRequest","kms","createUnboundKeys","count","keys","_isArray3","encryptFreeBusyRequest","_default","exports"],"sources":["calendar.encrypt.helper.js"],"sourcesContent":["import {isArray} from 'lodash';\n\nconst _encryptTextProp = (ctx, name, key, object) => {\n if (!object[name]) {\n return Promise.resolve();\n }\n\n return ctx.webex.internal.encryption\n .encryptText(key.uri || key, object[name])\n .then((ciphertext) => {\n object[name] = ciphertext;\n });\n};\n\nconst _encryptCalendarEventPayload = (data, ctx) => {\n Object.assign(data, {encryptionKeyUrl: ctx.encryptionKeyUrl});\n\n const encryptedAttendees = data.attendees\n ? data.attendees.map((attendee) =>\n Promise.all([\n _encryptTextProp(ctx, 'displayName', data.encryptionKeyUrl, attendee),\n _encryptTextProp(ctx, 'email', data.encryptionKeyUrl, attendee),\n ])\n )\n : [];\n\n return Promise.all(\n [\n _encryptTextProp(ctx, 'subject', data.encryptionKeyUrl, data),\n _encryptTextProp(ctx, 'notes', data.encryptionKeyUrl, data),\n _encryptTextProp(ctx, 'webexOptions', data.encryptionKeyUrl, data),\n ].concat([encryptedAttendees])\n );\n};\n\nconst _encryptFreeBusyPayload = (data, ctx) => {\n Object.assign(data, {encryptionKeyUrl: ctx.encryptionKeyUrl});\n\n const promises = [];\n if (data.emails && Array.isArray(data.emails)) {\n data.emails.map((item, index) =>\n promises.push(\n ctx.webex.internal.encryption\n .encryptText(data.encryptionKeyUrl, item)\n .then((encryptText) => {\n data.emails[index] = encryptText;\n })\n )\n );\n }\n\n return Promise.all(promises);\n};\n\nconst EncryptHelper = {\n /**\n * Encrypt create / update calendar event request payload\n * @param {object} [ctx] context\n * @param {object} [data] meeting payload data\n * @returns {Promise} Resolves with encrypted request payload\n * */\n encryptCalendarEventRequest: (ctx, data) => {\n if (ctx.encryptionKeyUrl) {\n return _encryptCalendarEventPayload(data, ctx);\n }\n\n return ctx.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => {\n const key = isArray(keys) ? keys[0] : keys;\n ctx.encryptionKeyUrl = key.uri;\n\n return _encryptCalendarEventPayload(data, ctx);\n });\n },\n /**\n * Encrypt free-busy request payload\n * @param {object} [ctx] context\n * @param {object} [data] free busy payload data\n * @returns {Promise} Resolves with encrypted request payload\n * */\n encryptFreeBusyRequest: (ctx, data) => {\n if (ctx.encryptionKeyUrl) {\n return _encryptFreeBusyPayload(data, ctx);\n }\n\n return ctx.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => {\n const key = isArray(keys) ? keys[0] : keys;\n ctx.encryptionKeyUrl = key.uri;\n\n return _encryptFreeBusyPayload(data, ctx);\n });\n },\n};\n\nexport default EncryptHelper;\n"],"mappings":";;;;;;;;;;;;AAEA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,GAAG,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,EAAK;EACnD,IAAI,CAACA,MAAM,CAACF,IAAI,CAAC,EAAE;IACjB,OAAOG,QAAA,CAAAC,OAAA,CAAQC,OAAO,EAAE;EAC1B;EAEA,OAAON,GAAG,CAACO,KAAK,CAACC,QAAQ,CAACC,UAAU,CACjCC,WAAW,CAACR,GAAG,CAACS,GAAG,IAAIT,GAAG,EAAEC,MAAM,CAACF,IAAI,CAAC,CAAC,CACzCW,IAAI,CAAC,UAACC,UAAU,EAAK;IACpBV,MAAM,CAACF,IAAI,CAAC,GAAGY,UAAU;EAC3B,CAAC,CAAC;AACN,CAAC;AAED,IAAMC,4BAA4B,GAAG,SAA/BA,4BAA4BA,CAAIC,IAAI,EAAEf,GAAG,EAAK;EAClD,IAAAgB,OAAA,CAAAX,OAAA,EAAcU,IAAI,EAAE;IAACE,gBAAgB,EAAEjB,GAAG,CAACiB;EAAgB,CAAC,CAAC;EAE7D,IAAMC,kBAAkB,GAAGH,IAAI,CAACI,SAAS,GACrCJ,IAAI,CAACI,SAAS,CAACC,GAAG,CAAC,UAACC,QAAQ;IAAA,OAC1BjB,QAAA,CAAAC,OAAA,CAAQiB,GAAG,CAAC,CACVvB,gBAAgB,CAACC,GAAG,EAAE,aAAa,EAAEe,IAAI,CAACE,gBAAgB,EAAEI,QAAQ,CAAC,EACrEtB,gBAAgB,CAACC,GAAG,EAAE,OAAO,EAAEe,IAAI,CAACE,gBAAgB,EAAEI,QAAQ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,QAAA,GAEaR,aAAa;AAAAS,OAAA,CAAAnC,OAAA,GAAAkC,QAAA"}
package/dist/calendar.js CHANGED
@@ -7,54 +7,13 @@ _Object$defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
10
- var _btoa = _interopRequireDefault(require("btoa"));
10
+ var _isArray2 = _interopRequireDefault(require("lodash/isArray"));
11
+ var _common = require("@webex/common");
11
12
  var _webexCore = require("@webex/webex-core");
12
13
  var _collection = _interopRequireDefault(require("./collection"));
13
14
  var _constants = require("./constants");
14
- /*!
15
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
16
- */
17
-
18
- /**
19
- * Calendar Item Create Event
20
- * Emitted when a calendar item has been added
21
- * @event calendar:meeting:create
22
- * @instance
23
- * @memberof Calendar
24
- */
25
-
26
- /**
27
- * Calendar Item Update Event
28
- * Emitted when a calendar item has been updated
29
- * @event calendar:meeting:update
30
- * @instance
31
- * @memberof Calendar
32
- */
33
-
34
- /**
35
- * Calendar Item Update Event
36
- * Emitted when a calendar item has been deleted
37
- * @event calendar:meeting:delete
38
- * @instance
39
- * @memberof Calendar
40
- */
41
-
42
- /**
43
- * Calendar Registered Event
44
- * Emitted when the calendar instance has been registered and listening
45
- * @event calendar:registered
46
- * @instance
47
- * @memberof Calendar
48
- */
49
-
50
- /**
51
- * Calendar Registered Event
52
- * Emitted when the calendar instance has been registered and listening
53
- * @event calendar:unregistered
54
- * @instance
55
- * @memberof Calendar
56
- */
57
-
15
+ var _calendarEncrypt = _interopRequireDefault(require("./calendar.encrypt.helper"));
16
+ var _calendarDecrypt = _interopRequireDefault(require("./calendar.decrypt.helper"));
58
17
  var Calendar = _webexCore.WebexPlugin.extend({
59
18
  namespace: 'Calendar',
60
19
  /**
@@ -64,6 +23,43 @@ var Calendar = _webexCore.WebexPlugin.extend({
64
23
  * @memberof Calendar
65
24
  */
66
25
  registered: false,
26
+ /**
27
+ * Cache all rpc event request locally
28
+ * */
29
+ rpcEventRequests: [],
30
+ /**
31
+ * Cache KMS encryptionKeyUrl
32
+ * */
33
+ encryptionKeyUrl: null,
34
+ /**
35
+ * WebexPlugin initialize method. This triggers once Webex has completed its
36
+ * initialization workflow.
37
+ *
38
+ * If the plugin is meant to perform startup actions, place them in this
39
+ * `initialize()` method instead of the `constructor()` method.
40
+ * @returns {void}
41
+ */
42
+ initialize: function initialize() {
43
+ var _this = this;
44
+ // Used to perform actions after webex is fully qualified and ready for
45
+ // operation.
46
+ this.listenToOnce(this.webex, 'ready', function () {
47
+ // Pre-fetch a KMS encryption key url to improve performance
48
+ _this.webex.internal.encryption.kms.createUnboundKeys({
49
+ count: 1
50
+ }).then(function (keys) {
51
+ var key = (0, _isArray2.default)(keys) ? keys[0] : keys;
52
+ _this.encryptionKeyUrl = key ? key.uri : null;
53
+ _this.logger.info('calendar->bind a KMS encryption key url');
54
+ _this.webex.internal.encryption.getKey(_this.encryptionKeyUrl, {
55
+ onBehalfOf: null
56
+ }).then(function (retrievedKey) {
57
+ _this.encryptionKeyUrl = retrievedKey ? retrievedKey.uri : null;
58
+ _this.logger.info('calendar->retrieve the KMS encryption key url and cache it');
59
+ });
60
+ });
61
+ });
62
+ },
67
63
  /**
68
64
  * Explicitly sets up the calendar plugin by registering
69
65
  * the device, connecting to mercury, and listening for calendar events.
@@ -72,7 +68,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
72
68
  * @memberof Calendar
73
69
  */
74
70
  register: function register() {
75
- var _this = this;
71
+ var _this2 = this;
76
72
  if (!this.webex.canAuthorize) {
77
73
  this.logger.error('calendar->register#ERROR, Unable to register, SDK cannot authorize');
78
74
  return _promise.default.reject(new Error('SDK cannot authorize'));
@@ -82,13 +78,13 @@ var Calendar = _webexCore.WebexPlugin.extend({
82
78
  return _promise.default.resolve();
83
79
  }
84
80
  return this.webex.internal.device.register().then(function () {
85
- return _this.webex.internal.mercury.connect();
81
+ return _this2.webex.internal.mercury.connect();
86
82
  }).then(function () {
87
- _this.listenForEvents();
88
- _this.trigger(_constants.CALENDAR_REGISTERED);
89
- _this.registered = true;
83
+ _this2.listenForEvents();
84
+ _this2.trigger(_constants.CALENDAR_REGISTERED);
85
+ _this2.registered = true;
90
86
  }).catch(function (error) {
91
- _this.logger.error("calendar->register#ERROR, Unable to register, ".concat(error.message));
87
+ _this2.logger.error("calendar->register#ERROR, Unable to register, ".concat(error.message));
92
88
  return _promise.default.reject(error);
93
89
  });
94
90
  },
@@ -101,17 +97,17 @@ var Calendar = _webexCore.WebexPlugin.extend({
101
97
  * @memberof Calendar
102
98
  */
103
99
  unregister: function unregister() {
104
- var _this2 = this;
100
+ var _this3 = this;
105
101
  if (!this.registered) {
106
102
  this.logger.info('calendar->unregister#INFO, Calendar plugin already unregistered');
107
103
  return _promise.default.resolve();
108
104
  }
109
105
  this.stopListeningForEvents();
110
106
  return this.webex.internal.mercury.disconnect().then(function () {
111
- return _this2.webex.internal.device.unregister();
107
+ return _this3.webex.internal.device.unregister();
112
108
  }).then(function () {
113
- _this2.trigger(_constants.CALENDAR_UNREGISTERED);
114
- _this2.registered = false;
109
+ _this3.trigger(_constants.CALENDAR_UNREGISTERED);
110
+ _this3.registered = false;
115
111
  });
116
112
  },
117
113
  /**
@@ -120,22 +116,25 @@ var Calendar = _webexCore.WebexPlugin.extend({
120
116
  * @private
121
117
  */
122
118
  listenForEvents: function listenForEvents() {
123
- var _this3 = this;
119
+ var _this4 = this;
124
120
  // Calendar mercury events listener
125
121
  this.webex.internal.mercury.on('event:calendar.meeting.create', function (envelope) {
126
- _this3._handleCreate(envelope.data);
122
+ _this4._handleCreate(envelope.data);
127
123
  });
128
124
  this.webex.internal.mercury.on('event:calendar.meeting.update', function (envelope) {
129
- _this3._handleUpdate(envelope.data);
125
+ _this4._handleUpdate(envelope.data);
130
126
  });
131
127
  this.webex.internal.mercury.on('event:calendar.meeting.create.minimal', function (envelope) {
132
- _this3._handleCreate(envelope.data);
128
+ _this4._handleCreate(envelope.data);
133
129
  });
134
130
  this.webex.internal.mercury.on('event:calendar.meeting.update.minimal', function (envelope) {
135
- _this3._handleUpdate(envelope.data);
131
+ _this4._handleUpdate(envelope.data);
136
132
  });
137
133
  this.webex.internal.mercury.on('event:calendar.meeting.delete', function (envelope) {
138
- _this3._handleDelete(envelope.data);
134
+ _this4._handleDelete(envelope.data);
135
+ });
136
+ this.webex.internal.mercury.on('event:calendar.free_busy', function (envelope) {
137
+ _this4._handleFreeBusy(envelope.data);
139
138
  });
140
139
  },
141
140
  /**
@@ -149,6 +148,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
149
148
  this.webex.internal.mercury.off('event:calendar.meeting.update');
150
149
  this.webex.internal.mercury.off('event:calendar.meeting.update.minimal');
151
150
  this.webex.internal.mercury.off('event:calendar.meeting.delete');
151
+ this.webex.internal.mercury.off('event:calendar.free_busy');
152
152
  },
153
153
  /**
154
154
  * handles update events, triggers after collection updates
@@ -180,6 +180,30 @@ var Calendar = _webexCore.WebexPlugin.extend({
180
180
  var item = _collection.default.remove(data.calendarMeetingExternal.id);
181
181
  this.trigger(_constants.CALENDAR_DELETE, item);
182
182
  },
183
+ /**
184
+ * handles free_busy events
185
+ * @param {Object} data
186
+ * @returns {undefined}
187
+ * @private
188
+ */
189
+ _handleFreeBusy: function _handleFreeBusy(data) {
190
+ var _this5 = this;
191
+ _calendarDecrypt.default.decryptFreeBusyResponse(this, data).then(function () {
192
+ var response = {};
193
+ if (data && data.calendarFreeBusyScheduleResponse) {
194
+ response = data.calendarFreeBusyScheduleResponse;
195
+ }
196
+ if (response && response.requestId && response.requestId in _this5.rpcEventRequests) {
197
+ _this5.logger.log("webex.internal.calendar - receive requests, requestId: ".concat(response.requestId));
198
+ delete response.encryptionKeyUrl;
199
+ var resolve = _this5.rpcEventRequests[response.requestId].resolve;
200
+ resolve(response);
201
+ delete _this5.rpcEventRequests[response.requestId];
202
+ } else {
203
+ _this5.logger.log('webex.internal.calendar - receive other requests.');
204
+ }
205
+ });
206
+ },
183
207
  /**
184
208
  * Retrieves a collection of calendars based on the request parameters
185
209
  * Defaults to 1 day before and 7 days ahead
@@ -239,7 +263,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
239
263
  return this.request({
240
264
  method: 'GET',
241
265
  service: 'calendar',
242
- resource: "calendarEvents/".concat((0, _btoa.default)(id), "/participants")
266
+ resource: "calendarEvents/".concat(_common.base64.encode(id), "/participants")
243
267
  });
244
268
  },
245
269
  /**
@@ -251,7 +275,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
251
275
  return this.request({
252
276
  method: 'GET',
253
277
  service: 'calendar',
254
- resource: "calendarEvents/".concat((0, _btoa.default)(id), "/notes")
278
+ resource: "calendarEvents/".concat(_common.base64.encode(id), "/notes")
255
279
  });
256
280
  },
257
281
  /**
@@ -262,7 +286,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
262
286
  * @returns {Promise} Resolves with an array of meetings
263
287
  */
264
288
  list: function list(options) {
265
- var _this4 = this;
289
+ var _this6 = this;
266
290
  options = options || {};
267
291
  return this.webex.request({
268
292
  method: 'GET',
@@ -274,12 +298,12 @@ var Calendar = _webexCore.WebexPlugin.extend({
274
298
  var promises = [];
275
299
  meetingObjects.forEach(function (meeting) {
276
300
  if (!meeting.encryptedNotes) {
277
- promises.push(_this4.getNotes(meeting.id).then(function (notesResponse) {
301
+ promises.push(_this6.getNotes(meeting.id).then(function (notesResponse) {
278
302
  meeting.encryptedNotes = notesResponse.body && notesResponse.body.encryptedNotes;
279
303
  }));
280
304
  }
281
305
  if (!meeting.encryptedParticipants) {
282
- promises.push(_this4.getParticipants(meeting.id).then(function (notesResponse) {
306
+ promises.push(_this6.getParticipants(meeting.id).then(function (notesResponse) {
283
307
  meeting.encryptedParticipants = notesResponse.body.encryptedParticipants;
284
308
  }));
285
309
  }
@@ -289,7 +313,115 @@ var Calendar = _webexCore.WebexPlugin.extend({
289
313
  });
290
314
  });
291
315
  },
292
- version: "2.48.0"
316
+ /**
317
+ * Create calendar event
318
+ * @param {object} [data] meeting payload data
319
+ * @returns {Promise} Resolves with creating calendar event response
320
+ * */
321
+ createCalendarEvent: function createCalendarEvent(data) {
322
+ var _this7 = this;
323
+ return _calendarEncrypt.default.encryptCalendarEventRequest(this, data).then(function () {
324
+ return _this7.request({
325
+ method: 'POST',
326
+ service: 'calendar',
327
+ body: data,
328
+ resource: 'calendarEvents/sync'
329
+ });
330
+ });
331
+ },
332
+ /**
333
+ * Update calendar event
334
+ * @param {string} [id] calendar event id
335
+ * @param {object} [data] meeting payload data
336
+ * @param {object} [query] the query parameters for specific usage
337
+ * @returns {Promise} Resolves with updating calendar event response
338
+ * */
339
+ updateCalendarEvent: function updateCalendarEvent(id, data, query) {
340
+ var _this8 = this;
341
+ return _calendarEncrypt.default.encryptCalendarEventRequest(this, data).then(function () {
342
+ return _this8.request({
343
+ method: 'PATCH',
344
+ service: 'calendar',
345
+ body: data,
346
+ resource: "calendarEvents/".concat(_common.base64.encode(id), "/sync"),
347
+ qs: query || {}
348
+ });
349
+ });
350
+ },
351
+ /**
352
+ * Delete calendar event
353
+ * @param {string} [id] calendar event id
354
+ * @returns {Promise} Resolves with deleting calendar event response
355
+ * */
356
+ deleteCalendarEvent: function deleteCalendarEvent(id) {
357
+ return this.request({
358
+ method: 'DELETE',
359
+ service: 'calendar',
360
+ resource: "calendarEvents/".concat(_common.base64.encode(id), "/sync")
361
+ });
362
+ },
363
+ /**
364
+ * @typedef QuerySchedulerDataOptions
365
+ * @param {string} [siteName] it is site full url, must have. Example: ccctest.dmz.webex.com
366
+ * @param {string} [id] it is seriesOrOccurrenceId. If present, the series/occurrence meeting ID to fetch data for. It should be base64 encoded.
367
+ * Example: 040000008200E00074C5B7101A82E008000000004A99F11A0841D9010000000000000000100000009EE499D4A71C1A46B51494C70EC7BFE5
368
+ * @param {string} [clientMeetingId] If present, the client meeting UUID to fetch data for. It should be base64 encoded.
369
+ * Example: 7f318aa9-887c-6e94-802a-8dc8e6eb1a0a
370
+ * @param {string} [scheduleTemplateId] it template id.
371
+ * @param {string} [sessionTypeId] it session type id.
372
+ * @param {string} [organizerCIUserId] required in schedule-on-behalf case. It is the organizer's CI UUID.
373
+ * @param {boolean} [usmPreference]
374
+ * @param {string} [webexMeetingId] webex side meeting UUID
375
+ * @param {string} [eventId] event ID.
376
+ * @param {string} [icalUid] icalendar UUID.
377
+ * @param {string} [thirdPartyType] third part type, such as: Microsoft
378
+ */
379
+ /**
380
+ * Get scheduler data from calendar service
381
+ * @param {QuerySchedulerDataOptions} [query] the command parameters for fetching scheduler data.
382
+ * @returns {Promise} Resolves with a decrypted scheduler data
383
+ * */
384
+ getSchedulerData: function getSchedulerData(query) {
385
+ var _this9 = this;
386
+ return this.request({
387
+ method: 'GET',
388
+ service: 'calendar',
389
+ resource: 'schedulerData',
390
+ qs: query || {}
391
+ }).then(function (response) {
392
+ return _calendarDecrypt.default.decryptSchedulerDataResponse(_this9, response.body).then(function () {
393
+ return response;
394
+ });
395
+ });
396
+ },
397
+ /**
398
+ * Get free busy status from calendar service
399
+ * @param {Object} [data] the command parameters for fetching free busy status.
400
+ * @returns {Promise} Resolves with a decrypted response
401
+ * */
402
+ getFreeBusy: function getFreeBusy(data) {
403
+ var _this10 = this;
404
+ return new _promise.default(function (resolve, reject) {
405
+ _calendarEncrypt.default.encryptFreeBusyRequest(_this10, data).then(function () {
406
+ _this10.request({
407
+ method: 'POST',
408
+ service: 'calendar',
409
+ body: data,
410
+ resource: 'freebusy'
411
+ }).then(function () {
412
+ _this10.rpcEventRequests[data.requestId] = {
413
+ resolve: resolve,
414
+ reject: reject
415
+ };
416
+ }).catch(function (error) {
417
+ reject(error);
418
+ });
419
+ }).catch(function (error) {
420
+ reject(error);
421
+ });
422
+ });
423
+ },
424
+ version: "2.50.0"
293
425
  });
294
426
  var _default = Calendar;
295
427
  exports.default = _default;