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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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;