@webex/internal-plugin-calendar 3.0.0-beta.42 → 3.0.0-beta.420
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/calendar.decrypt.helper.js +73 -0
- package/dist/calendar.decrypt.helper.js.map +1 -0
- package/dist/calendar.encrypt.helper.js +88 -0
- package/dist/calendar.encrypt.helper.js.map +1 -0
- package/dist/calendar.js +235 -75
- package/dist/calendar.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +9 -11
- package/src/calendar.decrypt.helper.js +121 -0
- package/src/calendar.encrypt.helper.js +98 -0
- package/src/calendar.js +223 -17
- package/src/index.js +27 -3
- package/test/unit/spec/calendar.decrypt.helper.js +145 -0
- package/test/unit/spec/calendar.encrypt.helper.js +52 -0
- package/test/unit/spec/calendar.js +210 -47
|
@@ -0,0 +1,73 @@
|
|
|
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 _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
|
|
11
|
+
var _decryptTextProp = function _decryptTextProp(ctx, name, key, object) {
|
|
12
|
+
if (!object[name]) {
|
|
13
|
+
return _promise.default.resolve();
|
|
14
|
+
}
|
|
15
|
+
return ctx.webex.internal.encryption.decryptText(key.uri || key, object[name]).then(function (plaintext) {
|
|
16
|
+
object[name] = plaintext;
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
var DecryptHelper = {
|
|
20
|
+
/**
|
|
21
|
+
* Decrypt scheduler data response
|
|
22
|
+
* @param {object} [ctx] context
|
|
23
|
+
* @param {object} [data] scheduler data response
|
|
24
|
+
* @returns {Promise} Resolves with decrypted response
|
|
25
|
+
* */
|
|
26
|
+
decryptSchedulerDataResponse: function decryptSchedulerDataResponse(ctx, data) {
|
|
27
|
+
if (!data) {
|
|
28
|
+
return _promise.default.resolve();
|
|
29
|
+
}
|
|
30
|
+
if (!data.encryptionKeyUrl) {
|
|
31
|
+
return _promise.default.resolve();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Decrypt participant properties if meeting object contains participants
|
|
35
|
+
var decryptedParticipants = data.encryptedParticipants ? data.encryptedParticipants.map(function (participant) {
|
|
36
|
+
return _promise.default.all([_decryptTextProp(ctx, 'encryptedEmailAddress', data.encryptionKeyUrl, participant), _decryptTextProp(ctx, 'encryptedName', data.encryptionKeyUrl, participant)]);
|
|
37
|
+
}) : [];
|
|
38
|
+
|
|
39
|
+
// Decrypt encryptedScheduleFor properties if meeting object contains SOB
|
|
40
|
+
var decryptedScheduleFor = _promise.default.all((0, _values.default)(data.encryptedScheduleFor || {}).flatMap(function (item) {
|
|
41
|
+
return [_decryptTextProp(ctx, 'encryptedEmail', data.encryptionKeyUrl, item), _decryptTextProp(ctx, 'encryptedDisplayName', data.encryptionKeyUrl, item)];
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
// Decrypt meetingJoinInfo properties if meeting object contains meetingJoinInfo
|
|
45
|
+
var decryptedMeetingJoinInfo = data.meetingJoinInfo ? _promise.default.all([_decryptTextProp(ctx, 'meetingJoinURI', data.encryptionKeyUrl, data.meetingJoinInfo), _decryptTextProp(ctx, 'meetingJoinURL', data.encryptionKeyUrl, data.meetingJoinInfo)]) : [];
|
|
46
|
+
var decryptedOrganizer = data.encryptedOrganizer ? _promise.default.all([_decryptTextProp(ctx, 'encryptedEmailAddress', data.encryptionKeyUrl, data.encryptedOrganizer), _decryptTextProp(ctx, 'encryptedName', data.encryptionKeyUrl, data.encryptedOrganizer)]) : [];
|
|
47
|
+
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, decryptedScheduleFor, decryptedMeetingJoinInfo));
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* Decrypt free-busy response
|
|
51
|
+
* @param {object} [ctx] context
|
|
52
|
+
* @param {object} [data] free-busy response
|
|
53
|
+
* @returns {Promise} Resolves with decrypted response
|
|
54
|
+
* */
|
|
55
|
+
decryptFreeBusyResponse: function decryptFreeBusyResponse(ctx, data) {
|
|
56
|
+
if (!data) {
|
|
57
|
+
return _promise.default.resolve();
|
|
58
|
+
}
|
|
59
|
+
if (!data.calendarFreeBusyScheduleResponse) {
|
|
60
|
+
return _promise.default.resolve();
|
|
61
|
+
}
|
|
62
|
+
if (!data.calendarFreeBusyScheduleResponse.encryptionKeyUrl) {
|
|
63
|
+
return _promise.default.resolve();
|
|
64
|
+
}
|
|
65
|
+
var calendarFreeBusyItems = data.calendarFreeBusyScheduleResponse.calendarFreeBusyItems ? data.calendarFreeBusyScheduleResponse.calendarFreeBusyItems.map(function (calendarFreeBusyItem) {
|
|
66
|
+
return _promise.default.all([_decryptTextProp(ctx, 'email', data.calendarFreeBusyScheduleResponse.encryptionKeyUrl, calendarFreeBusyItem)]);
|
|
67
|
+
}) : [];
|
|
68
|
+
return _promise.default.all([].concat(calendarFreeBusyItems));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var _default = DecryptHelper;
|
|
72
|
+
exports.default = _default;
|
|
73
|
+
//# sourceMappingURL=calendar.decrypt.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_decryptTextProp","ctx","name","key","object","resolve","webex","internal","encryption","decryptText","uri","then","plaintext","DecryptHelper","decryptSchedulerDataResponse","data","encryptionKeyUrl","decryptedParticipants","encryptedParticipants","map","participant","all","decryptedScheduleFor","encryptedScheduleFor","flatMap","item","decryptedMeetingJoinInfo","meetingJoinInfo","decryptedOrganizer","encryptedOrganizer","concat","decryptFreeBusyResponse","calendarFreeBusyScheduleResponse","calendarFreeBusyItems","calendarFreeBusyItem"],"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 encryptedScheduleFor properties if meeting object contains SOB\n const decryptedScheduleFor = Promise.all(\n Object.values(data.encryptedScheduleFor || {}).flatMap((item) => [\n _decryptTextProp(ctx, 'encryptedEmail', data.encryptionKeyUrl, item),\n _decryptTextProp(ctx, 'encryptedDisplayName', data.encryptionKeyUrl, item),\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(\n decryptedOrganizer,\n decryptedParticipants,\n decryptedScheduleFor,\n decryptedMeetingJoinInfo\n )\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,gBAAgB,CAAIC,GAAG,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,EAAK;EACnD,IAAI,CAACA,MAAM,CAACF,IAAI,CAAC,EAAE;IACjB,OAAO,iBAAQG,OAAO,EAAE;EAC1B;EAEA,OAAOJ,GAAG,CAACK,KAAK,CAACC,QAAQ,CAACC,UAAU,CACjCC,WAAW,CAACN,GAAG,CAACO,GAAG,IAAIP,GAAG,EAAEC,MAAM,CAACF,IAAI,CAAC,CAAC,CACzCS,IAAI,CAAC,UAACC,SAAS,EAAK;IACnBR,MAAM,CAACF,IAAI,CAAC,GAAGU,SAAS;EAC1B,CAAC,CAAC;AACN,CAAC;AAED,IAAMC,aAAa,GAAG;EACpB;AACF;AACA;AACA;AACA;AACA;EACEC,4BAA4B,EAAE,sCAACb,GAAG,EAAEc,IAAI,EAAK;IAC3C,IAAI,CAACA,IAAI,EAAE;MACT,OAAO,iBAAQV,OAAO,EAAE;IAC1B;IAEA,IAAI,CAACU,IAAI,CAACC,gBAAgB,EAAE;MAC1B,OAAO,iBAAQX,OAAO,EAAE;IAC1B;;IAEA;IACA,IAAMY,qBAAqB,GAAGF,IAAI,CAACG,qBAAqB,GACpDH,IAAI,CAACG,qBAAqB,CAACC,GAAG,CAAC,UAACC,WAAW;MAAA,OACzC,iBAAQC,GAAG,CAAC,CACVrB,gBAAgB,CAACC,GAAG,EAAE,uBAAuB,EAAEc,IAAI,CAACC,gBAAgB,EAAEI,WAAW,CAAC,EAClFpB,gBAAgB,CAACC,GAAG,EAAE,eAAe,EAAEc,IAAI,CAACC,gBAAgB,EAAEI,WAAW,CAAC,CAC3E,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EAAE;IAEN,OAAO,iBAAQb,GAAG,CAAC,EAAE,CAACS,MAAM,CAACG,qBAAqB,CAAC,CAAC;EACtD;AACF,CAAC;AAAC,eAEapB,aAAa;AAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
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, if request payload only includes the sensitive data, like email, need to encrypt these reqeust parameters, and playload includes encrypt url.
|
|
65
|
+
* Otherwise, don't encrypt playload and without encrypt url,Due to calendar serivce will vaild both encrypt url and sensitive that are both present. if not, will return 400 bad reqeust to caller.
|
|
66
|
+
* @param {object} [ctx] context
|
|
67
|
+
* @param {object} [data] free busy payload data
|
|
68
|
+
* @returns {Promise} Resolves with encrypted request payload
|
|
69
|
+
* */
|
|
70
|
+
encryptFreeBusyRequest: function encryptFreeBusyRequest(ctx, data) {
|
|
71
|
+
if (!data.emails || !(0, _isArray2.default)(data.emails)) {
|
|
72
|
+
return _promise.default.resolve();
|
|
73
|
+
}
|
|
74
|
+
if (ctx.encryptionKeyUrl) {
|
|
75
|
+
return _encryptFreeBusyPayload(data, ctx);
|
|
76
|
+
}
|
|
77
|
+
return ctx.webex.internal.encryption.kms.createUnboundKeys({
|
|
78
|
+
count: 1
|
|
79
|
+
}).then(function (keys) {
|
|
80
|
+
var key = (0, _isArray3.default)(keys) ? keys[0] : keys;
|
|
81
|
+
ctx.encryptionKeyUrl = key.uri;
|
|
82
|
+
return _encryptFreeBusyPayload(data, ctx);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var _default = EncryptHelper;
|
|
87
|
+
exports.default = _default;
|
|
88
|
+
//# sourceMappingURL=calendar.encrypt.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_encryptTextProp","ctx","name","key","object","resolve","webex","internal","encryption","encryptText","uri","then","ciphertext","_encryptCalendarEventPayload","data","encryptionKeyUrl","encryptedAttendees","attendees","map","attendee","all","concat","_encryptFreeBusyPayload","promises","emails","item","index","push","EncryptHelper","encryptCalendarEventRequest","kms","createUnboundKeys","count","keys","encryptFreeBusyRequest"],"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, if request payload only includes the sensitive data, like email, need to encrypt these reqeust parameters, and playload includes encrypt url.\n * Otherwise, don't encrypt playload and without encrypt url,Due to calendar serivce will vaild both encrypt url and sensitive that are both present. if not, will return 400 bad reqeust to caller.\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 (!data.emails || !Array.isArray(data.emails)) {\n return Promise.resolve();\n }\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,gBAAgB,CAAIC,GAAG,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,EAAK;EACnD,IAAI,CAACA,MAAM,CAACF,IAAI,CAAC,EAAE;IACjB,OAAO,iBAAQG,OAAO,EAAE;EAC1B;EAEA,OAAOJ,GAAG,CAACK,KAAK,CAACC,QAAQ,CAACC,UAAU,CACjCC,WAAW,CAACN,GAAG,CAACO,GAAG,IAAIP,GAAG,EAAEC,MAAM,CAACF,IAAI,CAAC,CAAC,CACzCS,IAAI,CAAC,UAACC,UAAU,EAAK;IACpBR,MAAM,CAACF,IAAI,CAAC,GAAGU,UAAU;EAC3B,CAAC,CAAC;AACN,CAAC;AAED,IAAMC,4BAA4B,GAAG,SAA/BA,4BAA4B,CAAIC,IAAI,EAAEb,GAAG,EAAK;EAClD,qBAAca,IAAI,EAAE;IAACC,gBAAgB,EAAEd,GAAG,CAACc;EAAgB,CAAC,CAAC;EAE7D,IAAMC,kBAAkB,GAAGF,IAAI,CAACG,SAAS,GACrCH,IAAI,CAACG,SAAS,CAACC,GAAG,CAAC,UAACC,QAAQ;IAAA,OAC1B,iBAAQC,GAAG,CAAC,CACVpB,gBAAgB,CAACC,GAAG,EAAE,aAAa,EAAEa,IAAI,CAACC,gBAAgB,EAAEI,QAAQ,CAAC,EACrEnB,gBAAgB,CAACC,GAAG,EAAE,OAAO,EAAEa,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AA"}
|
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
|
|
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
|
-
|
|
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,62 @@ 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
|
+
* Pre-fetch a KMS encryption key url to improve performance.
|
|
36
|
+
* Waits for the user to be authorized and skips if an unverified guest.
|
|
37
|
+
* @private
|
|
38
|
+
* @returns {void}
|
|
39
|
+
*/
|
|
40
|
+
prefetchEncryptionKey: function prefetchEncryptionKey() {
|
|
41
|
+
var _this = this;
|
|
42
|
+
if (!this.webex.canAuthorize) {
|
|
43
|
+
this.listenToOnce(this.webex, 'change:canAuthorize', function () {
|
|
44
|
+
_this.prefetchEncryptionKey();
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (this.webex.credentials.isUnverifiedGuest) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.webex.internal.encryption.kms.createUnboundKeys({
|
|
52
|
+
count: 1
|
|
53
|
+
}).then(function (keys) {
|
|
54
|
+
var key = (0, _isArray2.default)(keys) ? keys[0] : keys;
|
|
55
|
+
_this.encryptionKeyUrl = key ? key.uri : null;
|
|
56
|
+
_this.logger.info('calendar->bind a KMS encryption key url');
|
|
57
|
+
_this.webex.internal.encryption.getKey(_this.encryptionKeyUrl, {
|
|
58
|
+
onBehalfOf: null
|
|
59
|
+
}).then(function (retrievedKey) {
|
|
60
|
+
_this.encryptionKeyUrl = retrievedKey ? retrievedKey.uri : null;
|
|
61
|
+
_this.logger.info('calendar->retrieve the KMS encryption key url and cache it');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* WebexPlugin initialize method. This triggers once Webex has completed its
|
|
67
|
+
* initialization workflow.
|
|
68
|
+
*
|
|
69
|
+
* If the plugin is meant to perform startup actions, place them in this
|
|
70
|
+
* `initialize()` method instead of the `constructor()` method.
|
|
71
|
+
* @private
|
|
72
|
+
* @returns {void}
|
|
73
|
+
*/
|
|
74
|
+
initialize: function initialize() {
|
|
75
|
+
var _this2 = this;
|
|
76
|
+
// Used to perform actions after webex is fully qualified and ready for
|
|
77
|
+
// operation.
|
|
78
|
+
this.listenToOnce(this.webex, 'ready', function () {
|
|
79
|
+
_this2.prefetchEncryptionKey();
|
|
80
|
+
});
|
|
81
|
+
},
|
|
67
82
|
/**
|
|
68
83
|
* Explicitly sets up the calendar plugin by registering
|
|
69
84
|
* the device, connecting to mercury, and listening for calendar events.
|
|
@@ -72,7 +87,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
72
87
|
* @memberof Calendar
|
|
73
88
|
*/
|
|
74
89
|
register: function register() {
|
|
75
|
-
var
|
|
90
|
+
var _this3 = this;
|
|
76
91
|
if (!this.webex.canAuthorize) {
|
|
77
92
|
this.logger.error('calendar->register#ERROR, Unable to register, SDK cannot authorize');
|
|
78
93
|
return _promise.default.reject(new Error('SDK cannot authorize'));
|
|
@@ -82,13 +97,13 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
82
97
|
return _promise.default.resolve();
|
|
83
98
|
}
|
|
84
99
|
return this.webex.internal.device.register().then(function () {
|
|
85
|
-
return
|
|
100
|
+
return _this3.webex.internal.mercury.connect();
|
|
86
101
|
}).then(function () {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
_this3.listenForEvents();
|
|
103
|
+
_this3.trigger(_constants.CALENDAR_REGISTERED);
|
|
104
|
+
_this3.registered = true;
|
|
90
105
|
}).catch(function (error) {
|
|
91
|
-
|
|
106
|
+
_this3.logger.error("calendar->register#ERROR, Unable to register, ".concat(error.message));
|
|
92
107
|
return _promise.default.reject(error);
|
|
93
108
|
});
|
|
94
109
|
},
|
|
@@ -101,17 +116,17 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
101
116
|
* @memberof Calendar
|
|
102
117
|
*/
|
|
103
118
|
unregister: function unregister() {
|
|
104
|
-
var
|
|
119
|
+
var _this4 = this;
|
|
105
120
|
if (!this.registered) {
|
|
106
121
|
this.logger.info('calendar->unregister#INFO, Calendar plugin already unregistered');
|
|
107
122
|
return _promise.default.resolve();
|
|
108
123
|
}
|
|
109
124
|
this.stopListeningForEvents();
|
|
110
125
|
return this.webex.internal.mercury.disconnect().then(function () {
|
|
111
|
-
return
|
|
126
|
+
return _this4.webex.internal.device.unregister();
|
|
112
127
|
}).then(function () {
|
|
113
|
-
|
|
114
|
-
|
|
128
|
+
_this4.trigger(_constants.CALENDAR_UNREGISTERED);
|
|
129
|
+
_this4.registered = false;
|
|
115
130
|
});
|
|
116
131
|
},
|
|
117
132
|
/**
|
|
@@ -120,22 +135,25 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
120
135
|
* @private
|
|
121
136
|
*/
|
|
122
137
|
listenForEvents: function listenForEvents() {
|
|
123
|
-
var
|
|
138
|
+
var _this5 = this;
|
|
124
139
|
// Calendar mercury events listener
|
|
125
140
|
this.webex.internal.mercury.on('event:calendar.meeting.create', function (envelope) {
|
|
126
|
-
|
|
141
|
+
_this5._handleCreate(envelope.data);
|
|
127
142
|
});
|
|
128
143
|
this.webex.internal.mercury.on('event:calendar.meeting.update', function (envelope) {
|
|
129
|
-
|
|
144
|
+
_this5._handleUpdate(envelope.data);
|
|
130
145
|
});
|
|
131
146
|
this.webex.internal.mercury.on('event:calendar.meeting.create.minimal', function (envelope) {
|
|
132
|
-
|
|
147
|
+
_this5._handleCreate(envelope.data);
|
|
133
148
|
});
|
|
134
149
|
this.webex.internal.mercury.on('event:calendar.meeting.update.minimal', function (envelope) {
|
|
135
|
-
|
|
150
|
+
_this5._handleUpdate(envelope.data);
|
|
136
151
|
});
|
|
137
152
|
this.webex.internal.mercury.on('event:calendar.meeting.delete', function (envelope) {
|
|
138
|
-
|
|
153
|
+
_this5._handleDelete(envelope.data);
|
|
154
|
+
});
|
|
155
|
+
this.webex.internal.mercury.on('event:calendar.free_busy', function (envelope) {
|
|
156
|
+
_this5._handleFreeBusy(envelope.data);
|
|
139
157
|
});
|
|
140
158
|
},
|
|
141
159
|
/**
|
|
@@ -149,6 +167,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
149
167
|
this.webex.internal.mercury.off('event:calendar.meeting.update');
|
|
150
168
|
this.webex.internal.mercury.off('event:calendar.meeting.update.minimal');
|
|
151
169
|
this.webex.internal.mercury.off('event:calendar.meeting.delete');
|
|
170
|
+
this.webex.internal.mercury.off('event:calendar.free_busy');
|
|
152
171
|
},
|
|
153
172
|
/**
|
|
154
173
|
* handles update events, triggers after collection updates
|
|
@@ -180,6 +199,30 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
180
199
|
var item = _collection.default.remove(data.calendarMeetingExternal.id);
|
|
181
200
|
this.trigger(_constants.CALENDAR_DELETE, item);
|
|
182
201
|
},
|
|
202
|
+
/**
|
|
203
|
+
* handles free_busy events
|
|
204
|
+
* @param {Object} data
|
|
205
|
+
* @returns {undefined}
|
|
206
|
+
* @private
|
|
207
|
+
*/
|
|
208
|
+
_handleFreeBusy: function _handleFreeBusy(data) {
|
|
209
|
+
var _this6 = this;
|
|
210
|
+
_calendarDecrypt.default.decryptFreeBusyResponse(this, data).then(function () {
|
|
211
|
+
var response = {};
|
|
212
|
+
if (data && data.calendarFreeBusyScheduleResponse) {
|
|
213
|
+
response = data.calendarFreeBusyScheduleResponse;
|
|
214
|
+
}
|
|
215
|
+
if (response && response.requestId && response.requestId in _this6.rpcEventRequests) {
|
|
216
|
+
_this6.logger.log("webex.internal.calendar - receive requests, requestId: ".concat(response.requestId));
|
|
217
|
+
delete response.encryptionKeyUrl;
|
|
218
|
+
var resolve = _this6.rpcEventRequests[response.requestId].resolve;
|
|
219
|
+
resolve(response);
|
|
220
|
+
delete _this6.rpcEventRequests[response.requestId];
|
|
221
|
+
} else {
|
|
222
|
+
_this6.logger.log('webex.internal.calendar - receive other requests.');
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
},
|
|
183
226
|
/**
|
|
184
227
|
* Retrieves a collection of calendars based on the request parameters
|
|
185
228
|
* Defaults to 1 day before and 7 days ahead
|
|
@@ -231,15 +274,25 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
231
274
|
});
|
|
232
275
|
},
|
|
233
276
|
/**
|
|
234
|
-
* Retrieves an array of meeting participants for the meeting
|
|
235
|
-
* @param {String}
|
|
277
|
+
* Retrieves an array of meeting participants for the meeting participantsUrl
|
|
278
|
+
* @param {String} participantsUrl
|
|
236
279
|
* @returns {Promise} Resolves with an object of meeting participants
|
|
237
280
|
*/
|
|
238
|
-
getParticipants: function getParticipants(
|
|
281
|
+
getParticipants: function getParticipants(participantsUrl) {
|
|
239
282
|
return this.request({
|
|
240
283
|
method: 'GET',
|
|
241
|
-
|
|
242
|
-
|
|
284
|
+
uri: participantsUrl
|
|
285
|
+
});
|
|
286
|
+
},
|
|
287
|
+
/**
|
|
288
|
+
* get meeting notes using notesUrl from meeting object.
|
|
289
|
+
* @param {String} notesUrl
|
|
290
|
+
* @returns {Promise} Resolves with an object of meeting notes
|
|
291
|
+
*/
|
|
292
|
+
getNotesByUrl: function getNotesByUrl(notesUrl) {
|
|
293
|
+
return this.request({
|
|
294
|
+
method: 'GET',
|
|
295
|
+
uri: notesUrl
|
|
243
296
|
});
|
|
244
297
|
},
|
|
245
298
|
/**
|
|
@@ -251,7 +304,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
251
304
|
return this.request({
|
|
252
305
|
method: 'GET',
|
|
253
306
|
service: 'calendar',
|
|
254
|
-
resource: "calendarEvents/".concat(
|
|
307
|
+
resource: "calendarEvents/".concat(_common.base64.encode(id), "/notes")
|
|
255
308
|
});
|
|
256
309
|
},
|
|
257
310
|
/**
|
|
@@ -262,7 +315,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
262
315
|
* @returns {Promise} Resolves with an array of meetings
|
|
263
316
|
*/
|
|
264
317
|
list: function list(options) {
|
|
265
|
-
var
|
|
318
|
+
var _this7 = this;
|
|
266
319
|
options = options || {};
|
|
267
320
|
return this.webex.request({
|
|
268
321
|
method: 'GET',
|
|
@@ -273,13 +326,8 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
273
326
|
var meetingObjects = res.body.items;
|
|
274
327
|
var promises = [];
|
|
275
328
|
meetingObjects.forEach(function (meeting) {
|
|
276
|
-
if (!meeting.encryptedNotes) {
|
|
277
|
-
promises.push(_this4.getNotes(meeting.id).then(function (notesResponse) {
|
|
278
|
-
meeting.encryptedNotes = notesResponse.body && notesResponse.body.encryptedNotes;
|
|
279
|
-
}));
|
|
280
|
-
}
|
|
281
329
|
if (!meeting.encryptedParticipants) {
|
|
282
|
-
promises.push(
|
|
330
|
+
promises.push(_this7.getParticipants(meeting.participantsUrl).then(function (notesResponse) {
|
|
283
331
|
meeting.encryptedParticipants = notesResponse.body.encryptedParticipants;
|
|
284
332
|
}));
|
|
285
333
|
}
|
|
@@ -289,7 +337,119 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
289
337
|
});
|
|
290
338
|
});
|
|
291
339
|
},
|
|
292
|
-
|
|
340
|
+
/**
|
|
341
|
+
* Create calendar event
|
|
342
|
+
* @param {object} [data] meeting payload data
|
|
343
|
+
* @param {object} [query] the query parameters for specific usage
|
|
344
|
+
* @returns {Promise} Resolves with creating calendar event response
|
|
345
|
+
* */
|
|
346
|
+
createCalendarEvent: function createCalendarEvent(data, query) {
|
|
347
|
+
var _this8 = this;
|
|
348
|
+
return _calendarEncrypt.default.encryptCalendarEventRequest(this, data).then(function () {
|
|
349
|
+
return _this8.request({
|
|
350
|
+
method: 'POST',
|
|
351
|
+
service: 'calendar',
|
|
352
|
+
body: data,
|
|
353
|
+
resource: 'calendarEvents/sync',
|
|
354
|
+
qs: query || {}
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
},
|
|
358
|
+
/**
|
|
359
|
+
* Update calendar event
|
|
360
|
+
* @param {string} [id] calendar event id
|
|
361
|
+
* @param {object} [data] meeting payload data
|
|
362
|
+
* @param {object} [query] the query parameters for specific usage
|
|
363
|
+
* @returns {Promise} Resolves with updating calendar event response
|
|
364
|
+
* */
|
|
365
|
+
updateCalendarEvent: function updateCalendarEvent(id, data, query) {
|
|
366
|
+
var _this9 = this;
|
|
367
|
+
return _calendarEncrypt.default.encryptCalendarEventRequest(this, data).then(function () {
|
|
368
|
+
return _this9.request({
|
|
369
|
+
method: 'PATCH',
|
|
370
|
+
service: 'calendar',
|
|
371
|
+
body: data,
|
|
372
|
+
resource: "calendarEvents/".concat(_common.base64.encode(id), "/sync"),
|
|
373
|
+
qs: query || {}
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
},
|
|
377
|
+
/**
|
|
378
|
+
* Delete calendar event
|
|
379
|
+
* @param {string} [id] calendar event id
|
|
380
|
+
* @param {object} [query] the query parameters for specific usage
|
|
381
|
+
* @returns {Promise} Resolves with deleting calendar event response
|
|
382
|
+
* */
|
|
383
|
+
deleteCalendarEvent: function deleteCalendarEvent(id, query) {
|
|
384
|
+
return this.request({
|
|
385
|
+
method: 'DELETE',
|
|
386
|
+
service: 'calendar',
|
|
387
|
+
resource: "calendarEvents/".concat(_common.base64.encode(id), "/sync"),
|
|
388
|
+
qs: query || {}
|
|
389
|
+
});
|
|
390
|
+
},
|
|
391
|
+
/**
|
|
392
|
+
* @typedef QuerySchedulerDataOptions
|
|
393
|
+
* @param {string} [siteName] it is site full url, must have. Example: ccctest.dmz.webex.com
|
|
394
|
+
* @param {string} [id] it is seriesOrOccurrenceId. If present, the series/occurrence meeting ID to fetch data for.
|
|
395
|
+
* Example: 040000008200E00074C5B7101A82E008000000004A99F11A0841D9010000000000000000100000009EE499D4A71C1A46B51494C70EC7BFE5
|
|
396
|
+
* @param {string} [clientMeetingId] If present, the client meeting UUID to fetch data for.
|
|
397
|
+
* Example: 7f318aa9-887c-6e94-802a-8dc8e6eb1a0a
|
|
398
|
+
* @param {string} [scheduleTemplateId] it template id.
|
|
399
|
+
* @param {string} [sessionTypeId] it session type id.
|
|
400
|
+
* @param {string} [organizerCIUserId] required in schedule-on-behalf case. It is the organizer's CI UUID.
|
|
401
|
+
* @param {boolean} [usmPreference]
|
|
402
|
+
* @param {string} [webexMeetingId] webex side meeting UUID
|
|
403
|
+
* @param {string} [eventId] event ID.
|
|
404
|
+
* @param {string} [icalUid] icalendar UUID.
|
|
405
|
+
* @param {string} [thirdPartyType] third part type, such as: Microsoft
|
|
406
|
+
*/
|
|
407
|
+
/**
|
|
408
|
+
* Get scheduler data from calendar service
|
|
409
|
+
* @param {QuerySchedulerDataOptions} [query] the command parameters for fetching scheduler data.
|
|
410
|
+
* @returns {Promise} Resolves with a decrypted scheduler data
|
|
411
|
+
* */
|
|
412
|
+
getSchedulerData: function getSchedulerData(query) {
|
|
413
|
+
var _this10 = this;
|
|
414
|
+
return this.request({
|
|
415
|
+
method: 'GET',
|
|
416
|
+
service: 'calendar',
|
|
417
|
+
resource: 'schedulerData',
|
|
418
|
+
qs: query || {}
|
|
419
|
+
}).then(function (response) {
|
|
420
|
+
return _calendarDecrypt.default.decryptSchedulerDataResponse(_this10, response.body).then(function () {
|
|
421
|
+
return response;
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
},
|
|
425
|
+
/**
|
|
426
|
+
* Get free busy status from calendar service
|
|
427
|
+
* @param {Object} [data] the command parameters for fetching free busy status.
|
|
428
|
+
* @param {object} [query] the query parameters for specific usage
|
|
429
|
+
* @returns {Promise} Resolves with a decrypted response
|
|
430
|
+
* */
|
|
431
|
+
getFreeBusy: function getFreeBusy(data, query) {
|
|
432
|
+
var _this11 = this;
|
|
433
|
+
return _calendarEncrypt.default.encryptFreeBusyRequest(this, data).then(function () {
|
|
434
|
+
return _this11.request({
|
|
435
|
+
method: 'POST',
|
|
436
|
+
service: 'calendar',
|
|
437
|
+
body: data,
|
|
438
|
+
resource: 'freebusy',
|
|
439
|
+
qs: query || {}
|
|
440
|
+
});
|
|
441
|
+
}).then(function () {
|
|
442
|
+
return new _promise.default(function (resolve, reject) {
|
|
443
|
+
_this11.rpcEventRequests[data.requestId] = {
|
|
444
|
+
resolve: resolve,
|
|
445
|
+
reject: reject
|
|
446
|
+
};
|
|
447
|
+
});
|
|
448
|
+
}).catch(function (error) {
|
|
449
|
+
throw error;
|
|
450
|
+
});
|
|
451
|
+
},
|
|
452
|
+
version: "3.0.0-beta.420"
|
|
293
453
|
});
|
|
294
454
|
var _default = Calendar;
|
|
295
455
|
exports.default = _default;
|