@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.
- package/.eslintrc.js +6 -6
- package/README.md +42 -42
- package/babel.config.js +3 -3
- package/dist/calendar.decrypt.helper.js +10 -10
- package/dist/calendar.decrypt.helper.js.map +1 -1
- package/dist/calendar.encrypt.helper.js +11 -11
- package/dist/calendar.encrypt.helper.js.map +1 -1
- package/dist/calendar.js +131 -131
- package/dist/calendar.js.map +1 -1
- package/dist/collection.js +40 -40
- package/dist/collection.js.map +1 -1
- package/dist/config.js +2 -2
- package/dist/config.js.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/util.js +7 -7
- package/dist/util.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +16 -17
- package/process +1 -1
- package/src/calendar.decrypt.helper.js +121 -121
- package/src/calendar.encrypt.helper.js +98 -98
- package/src/calendar.js +490 -490
- package/src/collection.js +100 -100
- package/src/config.js +10 -10
- package/src/constants.js +6 -6
- package/src/index.js +241 -241
- package/src/util.js +22 -22
- package/test/integration/spec/calendar.js +624 -624
- package/test/unit/spec/calendar.decrypt.helper.js +145 -145
- package/test/unit/spec/calendar.encrypt.helper.js +52 -52
- package/test/unit/spec/calendar.js +446 -446
- package/test/unit/spec/utils.js +16 -16
|
@@ -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;
|