@webex/internal-plugin-calendar 2.59.3-next.1 → 2.59.4-next.1

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.
@@ -1,121 +1,121 @@
1
- const _decryptTextProp = (ctx, name, key, object) => {
2
- if (!object[name]) {
3
- return Promise.resolve();
4
- }
5
-
6
- return ctx.webex.internal.encryption
7
- .decryptText(key.uri || key, object[name])
8
- .then((plaintext) => {
9
- object[name] = plaintext;
10
- });
11
- };
12
-
13
- const DecryptHelper = {
14
- /**
15
- * Decrypt scheduler data response
16
- * @param {object} [ctx] context
17
- * @param {object} [data] scheduler data response
18
- * @returns {Promise} Resolves with decrypted response
19
- * */
20
- decryptSchedulerDataResponse: (ctx, data) => {
21
- if (!data) {
22
- return Promise.resolve();
23
- }
24
-
25
- if (!data.encryptionKeyUrl) {
26
- return Promise.resolve();
27
- }
28
-
29
- // Decrypt participant properties if meeting object contains participants
30
- const decryptedParticipants = data.encryptedParticipants
31
- ? data.encryptedParticipants.map((participant) =>
32
- Promise.all([
33
- _decryptTextProp(ctx, 'encryptedEmailAddress', data.encryptionKeyUrl, participant),
34
- _decryptTextProp(ctx, 'encryptedName', data.encryptionKeyUrl, participant),
35
- ])
36
- )
37
- : [];
38
-
39
- // Decrypt encryptedScheduleFor properties if meeting object contains SOB
40
- const decryptedScheduleFor = Promise.all(
41
- Object.values(data.encryptedScheduleFor || {}).flatMap((item) => [
42
- _decryptTextProp(ctx, 'encryptedEmail', data.encryptionKeyUrl, item),
43
- _decryptTextProp(ctx, 'encryptedDisplayName', data.encryptionKeyUrl, item),
44
- ])
45
- );
46
-
47
- // Decrypt meetingJoinInfo properties if meeting object contains meetingJoinInfo
48
- const decryptedMeetingJoinInfo = data.meetingJoinInfo
49
- ? Promise.all([
50
- _decryptTextProp(ctx, 'meetingJoinURI', data.encryptionKeyUrl, data.meetingJoinInfo),
51
- _decryptTextProp(ctx, 'meetingJoinURL', data.encryptionKeyUrl, data.meetingJoinInfo),
52
- ])
53
- : [];
54
-
55
- const decryptedOrganizer = data.encryptedOrganizer
56
- ? Promise.all([
57
- _decryptTextProp(
58
- ctx,
59
- 'encryptedEmailAddress',
60
- data.encryptionKeyUrl,
61
- data.encryptedOrganizer
62
- ),
63
- _decryptTextProp(ctx, 'encryptedName', data.encryptionKeyUrl, data.encryptedOrganizer),
64
- ])
65
- : [];
66
-
67
- return Promise.all(
68
- [
69
- _decryptTextProp(ctx, 'encryptedSubject', data.encryptionKeyUrl, data),
70
- _decryptTextProp(ctx, 'encryptedLocation', data.encryptionKeyUrl, data),
71
- _decryptTextProp(ctx, 'encryptedNotes', data.encryptionKeyUrl, data),
72
- _decryptTextProp(ctx, 'webexURI', data.encryptionKeyUrl, data),
73
- _decryptTextProp(ctx, 'webexURL', data.encryptionKeyUrl, data),
74
- _decryptTextProp(ctx, 'spaceMeetURL', data.encryptionKeyUrl, data),
75
- _decryptTextProp(ctx, 'spaceURI', data.encryptionKeyUrl, data),
76
- _decryptTextProp(ctx, 'spaceURL', data.encryptionKeyUrl, data),
77
- ].concat(
78
- decryptedOrganizer,
79
- decryptedParticipants,
80
- decryptedScheduleFor,
81
- decryptedMeetingJoinInfo
82
- )
83
- );
84
- },
85
- /**
86
- * Decrypt free-busy response
87
- * @param {object} [ctx] context
88
- * @param {object} [data] free-busy response
89
- * @returns {Promise} Resolves with decrypted response
90
- * */
91
- decryptFreeBusyResponse: (ctx, data) => {
92
- if (!data) {
93
- return Promise.resolve();
94
- }
95
-
96
- if (!data.calendarFreeBusyScheduleResponse) {
97
- return Promise.resolve();
98
- }
99
-
100
- if (!data.calendarFreeBusyScheduleResponse.encryptionKeyUrl) {
101
- return Promise.resolve();
102
- }
103
-
104
- const calendarFreeBusyItems = data.calendarFreeBusyScheduleResponse.calendarFreeBusyItems
105
- ? data.calendarFreeBusyScheduleResponse.calendarFreeBusyItems.map((calendarFreeBusyItem) =>
106
- Promise.all([
107
- _decryptTextProp(
108
- ctx,
109
- 'email',
110
- data.calendarFreeBusyScheduleResponse.encryptionKeyUrl,
111
- calendarFreeBusyItem
112
- ),
113
- ])
114
- )
115
- : [];
116
-
117
- return Promise.all([].concat(calendarFreeBusyItems));
118
- },
119
- };
120
-
121
- export default DecryptHelper;
1
+ const _decryptTextProp = (ctx, name, key, object) => {
2
+ if (!object[name]) {
3
+ return Promise.resolve();
4
+ }
5
+
6
+ return ctx.webex.internal.encryption
7
+ .decryptText(key.uri || key, object[name])
8
+ .then((plaintext) => {
9
+ object[name] = plaintext;
10
+ });
11
+ };
12
+
13
+ const DecryptHelper = {
14
+ /**
15
+ * Decrypt scheduler data response
16
+ * @param {object} [ctx] context
17
+ * @param {object} [data] scheduler data response
18
+ * @returns {Promise} Resolves with decrypted response
19
+ * */
20
+ decryptSchedulerDataResponse: (ctx, data) => {
21
+ if (!data) {
22
+ return Promise.resolve();
23
+ }
24
+
25
+ if (!data.encryptionKeyUrl) {
26
+ return Promise.resolve();
27
+ }
28
+
29
+ // Decrypt participant properties if meeting object contains participants
30
+ const decryptedParticipants = data.encryptedParticipants
31
+ ? data.encryptedParticipants.map((participant) =>
32
+ Promise.all([
33
+ _decryptTextProp(ctx, 'encryptedEmailAddress', data.encryptionKeyUrl, participant),
34
+ _decryptTextProp(ctx, 'encryptedName', data.encryptionKeyUrl, participant),
35
+ ])
36
+ )
37
+ : [];
38
+
39
+ // Decrypt encryptedScheduleFor properties if meeting object contains SOB
40
+ const decryptedScheduleFor = Promise.all(
41
+ Object.values(data.encryptedScheduleFor || {}).flatMap((item) => [
42
+ _decryptTextProp(ctx, 'encryptedEmail', data.encryptionKeyUrl, item),
43
+ _decryptTextProp(ctx, 'encryptedDisplayName', data.encryptionKeyUrl, item),
44
+ ])
45
+ );
46
+
47
+ // Decrypt meetingJoinInfo properties if meeting object contains meetingJoinInfo
48
+ const decryptedMeetingJoinInfo = data.meetingJoinInfo
49
+ ? Promise.all([
50
+ _decryptTextProp(ctx, 'meetingJoinURI', data.encryptionKeyUrl, data.meetingJoinInfo),
51
+ _decryptTextProp(ctx, 'meetingJoinURL', data.encryptionKeyUrl, data.meetingJoinInfo),
52
+ ])
53
+ : [];
54
+
55
+ const decryptedOrganizer = data.encryptedOrganizer
56
+ ? Promise.all([
57
+ _decryptTextProp(
58
+ ctx,
59
+ 'encryptedEmailAddress',
60
+ data.encryptionKeyUrl,
61
+ data.encryptedOrganizer
62
+ ),
63
+ _decryptTextProp(ctx, 'encryptedName', data.encryptionKeyUrl, data.encryptedOrganizer),
64
+ ])
65
+ : [];
66
+
67
+ return Promise.all(
68
+ [
69
+ _decryptTextProp(ctx, 'encryptedSubject', data.encryptionKeyUrl, data),
70
+ _decryptTextProp(ctx, 'encryptedLocation', data.encryptionKeyUrl, data),
71
+ _decryptTextProp(ctx, 'encryptedNotes', data.encryptionKeyUrl, data),
72
+ _decryptTextProp(ctx, 'webexURI', data.encryptionKeyUrl, data),
73
+ _decryptTextProp(ctx, 'webexURL', data.encryptionKeyUrl, data),
74
+ _decryptTextProp(ctx, 'spaceMeetURL', data.encryptionKeyUrl, data),
75
+ _decryptTextProp(ctx, 'spaceURI', data.encryptionKeyUrl, data),
76
+ _decryptTextProp(ctx, 'spaceURL', data.encryptionKeyUrl, data),
77
+ ].concat(
78
+ decryptedOrganizer,
79
+ decryptedParticipants,
80
+ decryptedScheduleFor,
81
+ decryptedMeetingJoinInfo
82
+ )
83
+ );
84
+ },
85
+ /**
86
+ * Decrypt free-busy response
87
+ * @param {object} [ctx] context
88
+ * @param {object} [data] free-busy response
89
+ * @returns {Promise} Resolves with decrypted response
90
+ * */
91
+ decryptFreeBusyResponse: (ctx, data) => {
92
+ if (!data) {
93
+ return Promise.resolve();
94
+ }
95
+
96
+ if (!data.calendarFreeBusyScheduleResponse) {
97
+ return Promise.resolve();
98
+ }
99
+
100
+ if (!data.calendarFreeBusyScheduleResponse.encryptionKeyUrl) {
101
+ return Promise.resolve();
102
+ }
103
+
104
+ const calendarFreeBusyItems = data.calendarFreeBusyScheduleResponse.calendarFreeBusyItems
105
+ ? data.calendarFreeBusyScheduleResponse.calendarFreeBusyItems.map((calendarFreeBusyItem) =>
106
+ Promise.all([
107
+ _decryptTextProp(
108
+ ctx,
109
+ 'email',
110
+ data.calendarFreeBusyScheduleResponse.encryptionKeyUrl,
111
+ calendarFreeBusyItem
112
+ ),
113
+ ])
114
+ )
115
+ : [];
116
+
117
+ return Promise.all([].concat(calendarFreeBusyItems));
118
+ },
119
+ };
120
+
121
+ export default DecryptHelper;
@@ -1,98 +1,98 @@
1
- import {isArray} from 'lodash';
2
-
3
- const _encryptTextProp = (ctx, name, key, object) => {
4
- if (!object[name]) {
5
- return Promise.resolve();
6
- }
7
-
8
- return ctx.webex.internal.encryption
9
- .encryptText(key.uri || key, object[name])
10
- .then((ciphertext) => {
11
- object[name] = ciphertext;
12
- });
13
- };
14
-
15
- const _encryptCalendarEventPayload = (data, ctx) => {
16
- Object.assign(data, {encryptionKeyUrl: ctx.encryptionKeyUrl});
17
-
18
- const encryptedAttendees = data.attendees
19
- ? data.attendees.map((attendee) =>
20
- Promise.all([
21
- _encryptTextProp(ctx, 'displayName', data.encryptionKeyUrl, attendee),
22
- _encryptTextProp(ctx, 'email', data.encryptionKeyUrl, attendee),
23
- ])
24
- )
25
- : [];
26
-
27
- return Promise.all(
28
- [
29
- _encryptTextProp(ctx, 'subject', data.encryptionKeyUrl, data),
30
- _encryptTextProp(ctx, 'notes', data.encryptionKeyUrl, data),
31
- _encryptTextProp(ctx, 'webexOptions', data.encryptionKeyUrl, data),
32
- ].concat([encryptedAttendees])
33
- );
34
- };
35
-
36
- const _encryptFreeBusyPayload = (data, ctx) => {
37
- Object.assign(data, {encryptionKeyUrl: ctx.encryptionKeyUrl});
38
-
39
- const promises = [];
40
- if (data.emails && Array.isArray(data.emails)) {
41
- data.emails.map((item, index) =>
42
- promises.push(
43
- ctx.webex.internal.encryption
44
- .encryptText(data.encryptionKeyUrl, item)
45
- .then((encryptText) => {
46
- data.emails[index] = encryptText;
47
- })
48
- )
49
- );
50
- }
51
-
52
- return Promise.all(promises);
53
- };
54
-
55
- const EncryptHelper = {
56
- /**
57
- * Encrypt create / update calendar event request payload
58
- * @param {object} [ctx] context
59
- * @param {object} [data] meeting payload data
60
- * @returns {Promise} Resolves with encrypted request payload
61
- * */
62
- encryptCalendarEventRequest: (ctx, data) => {
63
- if (ctx.encryptionKeyUrl) {
64
- return _encryptCalendarEventPayload(data, ctx);
65
- }
66
-
67
- return ctx.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => {
68
- const key = isArray(keys) ? keys[0] : keys;
69
- ctx.encryptionKeyUrl = key.uri;
70
-
71
- return _encryptCalendarEventPayload(data, ctx);
72
- });
73
- },
74
- /**
75
- * 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.
76
- * 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.
77
- * @param {object} [ctx] context
78
- * @param {object} [data] free busy payload data
79
- * @returns {Promise} Resolves with encrypted request payload
80
- * */
81
- encryptFreeBusyRequest: (ctx, data) => {
82
- if (!data.emails || !Array.isArray(data.emails)) {
83
- return Promise.resolve();
84
- }
85
- if (ctx.encryptionKeyUrl) {
86
- return _encryptFreeBusyPayload(data, ctx);
87
- }
88
-
89
- return ctx.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => {
90
- const key = isArray(keys) ? keys[0] : keys;
91
- ctx.encryptionKeyUrl = key.uri;
92
-
93
- return _encryptFreeBusyPayload(data, ctx);
94
- });
95
- },
96
- };
97
-
98
- export default EncryptHelper;
1
+ import {isArray} from 'lodash';
2
+
3
+ const _encryptTextProp = (ctx, name, key, object) => {
4
+ if (!object[name]) {
5
+ return Promise.resolve();
6
+ }
7
+
8
+ return ctx.webex.internal.encryption
9
+ .encryptText(key.uri || key, object[name])
10
+ .then((ciphertext) => {
11
+ object[name] = ciphertext;
12
+ });
13
+ };
14
+
15
+ const _encryptCalendarEventPayload = (data, ctx) => {
16
+ Object.assign(data, {encryptionKeyUrl: ctx.encryptionKeyUrl});
17
+
18
+ const encryptedAttendees = data.attendees
19
+ ? data.attendees.map((attendee) =>
20
+ Promise.all([
21
+ _encryptTextProp(ctx, 'displayName', data.encryptionKeyUrl, attendee),
22
+ _encryptTextProp(ctx, 'email', data.encryptionKeyUrl, attendee),
23
+ ])
24
+ )
25
+ : [];
26
+
27
+ return Promise.all(
28
+ [
29
+ _encryptTextProp(ctx, 'subject', data.encryptionKeyUrl, data),
30
+ _encryptTextProp(ctx, 'notes', data.encryptionKeyUrl, data),
31
+ _encryptTextProp(ctx, 'webexOptions', data.encryptionKeyUrl, data),
32
+ ].concat([encryptedAttendees])
33
+ );
34
+ };
35
+
36
+ const _encryptFreeBusyPayload = (data, ctx) => {
37
+ Object.assign(data, {encryptionKeyUrl: ctx.encryptionKeyUrl});
38
+
39
+ const promises = [];
40
+ if (data.emails && Array.isArray(data.emails)) {
41
+ data.emails.map((item, index) =>
42
+ promises.push(
43
+ ctx.webex.internal.encryption
44
+ .encryptText(data.encryptionKeyUrl, item)
45
+ .then((encryptText) => {
46
+ data.emails[index] = encryptText;
47
+ })
48
+ )
49
+ );
50
+ }
51
+
52
+ return Promise.all(promises);
53
+ };
54
+
55
+ const EncryptHelper = {
56
+ /**
57
+ * Encrypt create / update calendar event request payload
58
+ * @param {object} [ctx] context
59
+ * @param {object} [data] meeting payload data
60
+ * @returns {Promise} Resolves with encrypted request payload
61
+ * */
62
+ encryptCalendarEventRequest: (ctx, data) => {
63
+ if (ctx.encryptionKeyUrl) {
64
+ return _encryptCalendarEventPayload(data, ctx);
65
+ }
66
+
67
+ return ctx.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => {
68
+ const key = isArray(keys) ? keys[0] : keys;
69
+ ctx.encryptionKeyUrl = key.uri;
70
+
71
+ return _encryptCalendarEventPayload(data, ctx);
72
+ });
73
+ },
74
+ /**
75
+ * 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.
76
+ * 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.
77
+ * @param {object} [ctx] context
78
+ * @param {object} [data] free busy payload data
79
+ * @returns {Promise} Resolves with encrypted request payload
80
+ * */
81
+ encryptFreeBusyRequest: (ctx, data) => {
82
+ if (!data.emails || !Array.isArray(data.emails)) {
83
+ return Promise.resolve();
84
+ }
85
+ if (ctx.encryptionKeyUrl) {
86
+ return _encryptFreeBusyPayload(data, ctx);
87
+ }
88
+
89
+ return ctx.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => {
90
+ const key = isArray(keys) ? keys[0] : keys;
91
+ ctx.encryptionKeyUrl = key.uri;
92
+
93
+ return _encryptFreeBusyPayload(data, ctx);
94
+ });
95
+ },
96
+ };
97
+
98
+ export default EncryptHelper;