@webex/internal-plugin-calendar 3.0.0-beta.30 → 3.0.0-beta.301
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 +216 -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 +201 -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 +161 -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,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
|
|
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
|
|
81
|
+
return _this2.webex.internal.mercury.connect();
|
|
86
82
|
}).then(function () {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
_this2.listenForEvents();
|
|
84
|
+
_this2.trigger(_constants.CALENDAR_REGISTERED);
|
|
85
|
+
_this2.registered = true;
|
|
90
86
|
}).catch(function (error) {
|
|
91
|
-
|
|
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
|
|
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
|
|
107
|
+
return _this3.webex.internal.device.unregister();
|
|
112
108
|
}).then(function () {
|
|
113
|
-
|
|
114
|
-
|
|
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
|
|
119
|
+
var _this4 = this;
|
|
124
120
|
// Calendar mercury events listener
|
|
125
121
|
this.webex.internal.mercury.on('event:calendar.meeting.create', function (envelope) {
|
|
126
|
-
|
|
122
|
+
_this4._handleCreate(envelope.data);
|
|
127
123
|
});
|
|
128
124
|
this.webex.internal.mercury.on('event:calendar.meeting.update', function (envelope) {
|
|
129
|
-
|
|
125
|
+
_this4._handleUpdate(envelope.data);
|
|
130
126
|
});
|
|
131
127
|
this.webex.internal.mercury.on('event:calendar.meeting.create.minimal', function (envelope) {
|
|
132
|
-
|
|
128
|
+
_this4._handleCreate(envelope.data);
|
|
133
129
|
});
|
|
134
130
|
this.webex.internal.mercury.on('event:calendar.meeting.update.minimal', function (envelope) {
|
|
135
|
-
|
|
131
|
+
_this4._handleUpdate(envelope.data);
|
|
136
132
|
});
|
|
137
133
|
this.webex.internal.mercury.on('event:calendar.meeting.delete', function (envelope) {
|
|
138
|
-
|
|
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
|
|
@@ -231,15 +255,25 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
231
255
|
});
|
|
232
256
|
},
|
|
233
257
|
/**
|
|
234
|
-
* Retrieves an array of meeting participants for the meeting
|
|
235
|
-
* @param {String}
|
|
258
|
+
* Retrieves an array of meeting participants for the meeting participantsUrl
|
|
259
|
+
* @param {String} participantsUrl
|
|
236
260
|
* @returns {Promise} Resolves with an object of meeting participants
|
|
237
261
|
*/
|
|
238
|
-
getParticipants: function getParticipants(
|
|
262
|
+
getParticipants: function getParticipants(participantsUrl) {
|
|
239
263
|
return this.request({
|
|
240
264
|
method: 'GET',
|
|
241
|
-
|
|
242
|
-
|
|
265
|
+
uri: participantsUrl
|
|
266
|
+
});
|
|
267
|
+
},
|
|
268
|
+
/**
|
|
269
|
+
* get meeting notes using notesUrl from meeting object.
|
|
270
|
+
* @param {String} notesUrl
|
|
271
|
+
* @returns {Promise} Resolves with an object of meeting notes
|
|
272
|
+
*/
|
|
273
|
+
getNotesByUrl: function getNotesByUrl(notesUrl) {
|
|
274
|
+
return this.request({
|
|
275
|
+
method: 'GET',
|
|
276
|
+
uri: notesUrl
|
|
243
277
|
});
|
|
244
278
|
},
|
|
245
279
|
/**
|
|
@@ -251,7 +285,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
251
285
|
return this.request({
|
|
252
286
|
method: 'GET',
|
|
253
287
|
service: 'calendar',
|
|
254
|
-
resource: "calendarEvents/".concat(
|
|
288
|
+
resource: "calendarEvents/".concat(_common.base64.encode(id), "/notes")
|
|
255
289
|
});
|
|
256
290
|
},
|
|
257
291
|
/**
|
|
@@ -262,7 +296,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
262
296
|
* @returns {Promise} Resolves with an array of meetings
|
|
263
297
|
*/
|
|
264
298
|
list: function list(options) {
|
|
265
|
-
var
|
|
299
|
+
var _this6 = this;
|
|
266
300
|
options = options || {};
|
|
267
301
|
return this.webex.request({
|
|
268
302
|
method: 'GET',
|
|
@@ -273,13 +307,8 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
273
307
|
var meetingObjects = res.body.items;
|
|
274
308
|
var promises = [];
|
|
275
309
|
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
310
|
if (!meeting.encryptedParticipants) {
|
|
282
|
-
promises.push(
|
|
311
|
+
promises.push(_this6.getParticipants(meeting.participantsUrl).then(function (notesResponse) {
|
|
283
312
|
meeting.encryptedParticipants = notesResponse.body.encryptedParticipants;
|
|
284
313
|
}));
|
|
285
314
|
}
|
|
@@ -289,7 +318,119 @@ var Calendar = _webexCore.WebexPlugin.extend({
|
|
|
289
318
|
});
|
|
290
319
|
});
|
|
291
320
|
},
|
|
292
|
-
|
|
321
|
+
/**
|
|
322
|
+
* Create calendar event
|
|
323
|
+
* @param {object} [data] meeting payload data
|
|
324
|
+
* @param {object} [query] the query parameters for specific usage
|
|
325
|
+
* @returns {Promise} Resolves with creating calendar event response
|
|
326
|
+
* */
|
|
327
|
+
createCalendarEvent: function createCalendarEvent(data, query) {
|
|
328
|
+
var _this7 = this;
|
|
329
|
+
return _calendarEncrypt.default.encryptCalendarEventRequest(this, data).then(function () {
|
|
330
|
+
return _this7.request({
|
|
331
|
+
method: 'POST',
|
|
332
|
+
service: 'calendar',
|
|
333
|
+
body: data,
|
|
334
|
+
resource: 'calendarEvents/sync',
|
|
335
|
+
qs: query || {}
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
},
|
|
339
|
+
/**
|
|
340
|
+
* Update calendar event
|
|
341
|
+
* @param {string} [id] calendar event id
|
|
342
|
+
* @param {object} [data] meeting payload data
|
|
343
|
+
* @param {object} [query] the query parameters for specific usage
|
|
344
|
+
* @returns {Promise} Resolves with updating calendar event response
|
|
345
|
+
* */
|
|
346
|
+
updateCalendarEvent: function updateCalendarEvent(id, data, query) {
|
|
347
|
+
var _this8 = this;
|
|
348
|
+
return _calendarEncrypt.default.encryptCalendarEventRequest(this, data).then(function () {
|
|
349
|
+
return _this8.request({
|
|
350
|
+
method: 'PATCH',
|
|
351
|
+
service: 'calendar',
|
|
352
|
+
body: data,
|
|
353
|
+
resource: "calendarEvents/".concat(_common.base64.encode(id), "/sync"),
|
|
354
|
+
qs: query || {}
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
},
|
|
358
|
+
/**
|
|
359
|
+
* Delete calendar event
|
|
360
|
+
* @param {string} [id] calendar event id
|
|
361
|
+
* @param {object} [query] the query parameters for specific usage
|
|
362
|
+
* @returns {Promise} Resolves with deleting calendar event response
|
|
363
|
+
* */
|
|
364
|
+
deleteCalendarEvent: function deleteCalendarEvent(id, query) {
|
|
365
|
+
return this.request({
|
|
366
|
+
method: 'DELETE',
|
|
367
|
+
service: 'calendar',
|
|
368
|
+
resource: "calendarEvents/".concat(_common.base64.encode(id), "/sync"),
|
|
369
|
+
qs: query || {}
|
|
370
|
+
});
|
|
371
|
+
},
|
|
372
|
+
/**
|
|
373
|
+
* @typedef QuerySchedulerDataOptions
|
|
374
|
+
* @param {string} [siteName] it is site full url, must have. Example: ccctest.dmz.webex.com
|
|
375
|
+
* @param {string} [id] it is seriesOrOccurrenceId. If present, the series/occurrence meeting ID to fetch data for.
|
|
376
|
+
* Example: 040000008200E00074C5B7101A82E008000000004A99F11A0841D9010000000000000000100000009EE499D4A71C1A46B51494C70EC7BFE5
|
|
377
|
+
* @param {string} [clientMeetingId] If present, the client meeting UUID to fetch data for.
|
|
378
|
+
* Example: 7f318aa9-887c-6e94-802a-8dc8e6eb1a0a
|
|
379
|
+
* @param {string} [scheduleTemplateId] it template id.
|
|
380
|
+
* @param {string} [sessionTypeId] it session type id.
|
|
381
|
+
* @param {string} [organizerCIUserId] required in schedule-on-behalf case. It is the organizer's CI UUID.
|
|
382
|
+
* @param {boolean} [usmPreference]
|
|
383
|
+
* @param {string} [webexMeetingId] webex side meeting UUID
|
|
384
|
+
* @param {string} [eventId] event ID.
|
|
385
|
+
* @param {string} [icalUid] icalendar UUID.
|
|
386
|
+
* @param {string} [thirdPartyType] third part type, such as: Microsoft
|
|
387
|
+
*/
|
|
388
|
+
/**
|
|
389
|
+
* Get scheduler data from calendar service
|
|
390
|
+
* @param {QuerySchedulerDataOptions} [query] the command parameters for fetching scheduler data.
|
|
391
|
+
* @returns {Promise} Resolves with a decrypted scheduler data
|
|
392
|
+
* */
|
|
393
|
+
getSchedulerData: function getSchedulerData(query) {
|
|
394
|
+
var _this9 = this;
|
|
395
|
+
return this.request({
|
|
396
|
+
method: 'GET',
|
|
397
|
+
service: 'calendar',
|
|
398
|
+
resource: 'schedulerData',
|
|
399
|
+
qs: query || {}
|
|
400
|
+
}).then(function (response) {
|
|
401
|
+
return _calendarDecrypt.default.decryptSchedulerDataResponse(_this9, response.body).then(function () {
|
|
402
|
+
return response;
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
},
|
|
406
|
+
/**
|
|
407
|
+
* Get free busy status from calendar service
|
|
408
|
+
* @param {Object} [data] the command parameters for fetching free busy status.
|
|
409
|
+
* @param {object} [query] the query parameters for specific usage
|
|
410
|
+
* @returns {Promise} Resolves with a decrypted response
|
|
411
|
+
* */
|
|
412
|
+
getFreeBusy: function getFreeBusy(data, query) {
|
|
413
|
+
var _this10 = this;
|
|
414
|
+
return _calendarEncrypt.default.encryptFreeBusyRequest(this, data).then(function () {
|
|
415
|
+
return _this10.request({
|
|
416
|
+
method: 'POST',
|
|
417
|
+
service: 'calendar',
|
|
418
|
+
body: data,
|
|
419
|
+
resource: 'freebusy',
|
|
420
|
+
qs: query || {}
|
|
421
|
+
});
|
|
422
|
+
}).then(function () {
|
|
423
|
+
return new _promise.default(function (resolve, reject) {
|
|
424
|
+
_this10.rpcEventRequests[data.requestId] = {
|
|
425
|
+
resolve: resolve,
|
|
426
|
+
reject: reject
|
|
427
|
+
};
|
|
428
|
+
});
|
|
429
|
+
}).catch(function (error) {
|
|
430
|
+
throw error;
|
|
431
|
+
});
|
|
432
|
+
},
|
|
433
|
+
version: "3.0.0-beta.301"
|
|
293
434
|
});
|
|
294
435
|
var _default = Calendar;
|
|
295
436
|
exports.default = _default;
|