@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/src/index.js CHANGED
@@ -1,241 +1,241 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import '@webex/internal-plugin-device';
6
- import '@webex/internal-plugin-encryption';
7
- import '@webex/internal-plugin-conversation';
8
-
9
- import {registerInternalPlugin} from '@webex/webex-core';
10
- import {has} from 'lodash';
11
-
12
- import Calendar from './calendar';
13
- import config from './config';
14
-
15
- registerInternalPlugin('calendar', Calendar, {
16
- config,
17
- payloadTransformer: {
18
- predicates: [
19
- {
20
- name: 'transformMeetingNotes',
21
- direction: 'inbound',
22
- test(ctx, response) {
23
- return Promise.resolve(
24
- has(response, 'body.encryptedNotes') &&
25
- !(
26
- response.options &&
27
- response.options.service === 'calendar' &&
28
- response.options.method === 'GET' &&
29
- response.options.resource === 'schedulerData'
30
- )
31
- );
32
- },
33
- extract(response) {
34
- return Promise.resolve(response.body);
35
- },
36
- },
37
- {
38
- name: 'transformMeetingParticipants',
39
- direction: 'inbound',
40
- test(ctx, response) {
41
- return Promise.resolve(
42
- has(response, 'body.encryptedParticipants') &&
43
- !(
44
- response.options &&
45
- response.options.service === 'calendar' &&
46
- response.options.method === 'GET' &&
47
- response.options.resource === 'schedulerData'
48
- )
49
- );
50
- },
51
- extract(response) {
52
- return Promise.resolve(response.body);
53
- },
54
- },
55
- {
56
- name: 'transformMeetingArray',
57
- direction: 'inbound',
58
- test(ctx, response) {
59
- return Promise.resolve(has(response, 'body.items[0].seriesId'));
60
- },
61
- extract(response) {
62
- return Promise.resolve(response.body.items);
63
- },
64
- },
65
- {
66
- name: 'transformMeeting',
67
- direction: 'inbound',
68
- test(ctx, response) {
69
- return Promise.resolve(
70
- has(response, 'body.seriesId') &&
71
- !(
72
- response.options &&
73
- response.options.service === 'calendar' &&
74
- response.options.method === 'GET' &&
75
- response.options.resource === 'schedulerData'
76
- )
77
- );
78
- },
79
- extract(response) {
80
- return Promise.resolve(response.body);
81
- },
82
- },
83
- {
84
- name: 'transformMeeting',
85
- direction: 'inbound',
86
- test(ctx, response) {
87
- return Promise.resolve(has(response, 'calendarMeetingExternal'));
88
- },
89
- extract(response) {
90
- return Promise.resolve(response.calendarMeetingExternal);
91
- },
92
- },
93
- ],
94
- transforms: [
95
- {
96
- name: 'transformMeetingArray',
97
- fn(ctx, array) {
98
- return Promise.all(array.map((item) => ctx.transform('transformMeeting', item)));
99
- },
100
- },
101
- {
102
- name: 'transformMeeting',
103
- direction: 'inbound',
104
- fn(ctx, object) {
105
- if (!object) {
106
- return Promise.resolve();
107
- }
108
-
109
- if (!object.encryptionKeyUrl) {
110
- return Promise.resolve();
111
- }
112
-
113
- // Decrypt participant properties if meeting object contains participants
114
- const decryptedParticipants = object.encryptedParticipants
115
- ? object.encryptedParticipants.map((participant) =>
116
- Promise.all([
117
- ctx.transform(
118
- 'decryptTextProp',
119
- 'encryptedEmailAddress',
120
- object.encryptionKeyUrl,
121
- participant
122
- ),
123
- ctx.transform(
124
- 'decryptTextProp',
125
- 'encryptedName',
126
- object.encryptionKeyUrl,
127
- participant
128
- ),
129
- ])
130
- )
131
- : [];
132
-
133
- // Decrypt meetingJoinInfo properties if meeting object contains meetingJoinInfo
134
- const decryptedMeetingJoinInfo = object.meetingJoinInfo
135
- ? Promise.all([
136
- ctx.transform(
137
- 'decryptTextProp',
138
- 'meetingJoinURI',
139
- object.encryptionKeyUrl,
140
- object.meetingJoinInfo
141
- ),
142
- ctx.transform(
143
- 'decryptTextProp',
144
- 'meetingJoinURL',
145
- object.encryptionKeyUrl,
146
- object.meetingJoinInfo
147
- ),
148
- ])
149
- : [];
150
-
151
- const decryptedOrganizer = object.encryptedOrganizer
152
- ? Promise.all([
153
- ctx.transform(
154
- 'decryptTextProp',
155
- 'encryptedEmailAddress',
156
- object.encryptionKeyUrl,
157
- object.encryptedOrganizer
158
- ),
159
- ctx.transform(
160
- 'decryptTextProp',
161
- 'encryptedName',
162
- object.encryptionKeyUrl,
163
- object.encryptedOrganizer
164
- ),
165
- ])
166
- : [];
167
-
168
- return Promise.all(
169
- [
170
- ctx.transform('decryptTextProp', 'encryptedSubject', object.encryptionKeyUrl, object),
171
- ctx.transform(
172
- 'decryptTextProp',
173
- 'encryptedLocation',
174
- object.encryptionKeyUrl,
175
- object
176
- ),
177
- ctx.transform('decryptTextProp', 'encryptedNotes', object.encryptionKeyUrl, object),
178
- ctx.transform('decryptTextProp', 'webexURI', object.encryptionKeyUrl, object),
179
- ctx.transform('decryptTextProp', 'webexURL', object.encryptionKeyUrl, object),
180
- ctx.transform('decryptTextProp', 'spaceMeetURL', object.encryptionKeyUrl, object),
181
- ctx.transform('decryptTextProp', 'spaceURI', object.encryptionKeyUrl, object),
182
- ctx.transform('decryptTextProp', 'spaceURL', object.encryptionKeyUrl, object),
183
- ].concat(decryptedOrganizer, decryptedParticipants, decryptedMeetingJoinInfo)
184
- );
185
- },
186
- },
187
- {
188
- name: 'transformMeetingNotes',
189
- direction: 'inbound',
190
- fn(ctx, object) {
191
- if (!object) {
192
- return Promise.resolve();
193
- }
194
-
195
- if (!object.encryptionKeyUrl) {
196
- return Promise.resolve();
197
- }
198
-
199
- return Promise.all([
200
- ctx.transform('decryptTextProp', 'encryptedNotes', object.encryptionKeyUrl, object),
201
- ]);
202
- },
203
- },
204
- {
205
- name: 'transformMeetingParticipants',
206
- direction: 'inbound',
207
- fn(ctx, object) {
208
- if (!object) {
209
- return Promise.resolve();
210
- }
211
-
212
- if (!object.encryptionKeyUrl || !object.encryptedParticipants) {
213
- return Promise.resolve();
214
- }
215
-
216
- // Decrypt participant properties
217
- const decryptedParticipants = object.encryptedParticipants.map((participant) =>
218
- Promise.all([
219
- ctx.transform(
220
- 'decryptTextProp',
221
- 'encryptedEmailAddress',
222
- object.encryptionKeyUrl,
223
- participant
224
- ),
225
- ctx.transform(
226
- 'decryptTextProp',
227
- 'encryptedName',
228
- object.encryptionKeyUrl,
229
- participant
230
- ),
231
- ])
232
- );
233
-
234
- return Promise.all(decryptedParticipants);
235
- },
236
- },
237
- ],
238
- },
239
- });
240
-
241
- export {default} from './calendar';
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import '@webex/internal-plugin-device';
6
+ import '@webex/internal-plugin-encryption';
7
+ import '@webex/internal-plugin-conversation';
8
+
9
+ import {registerInternalPlugin} from '@webex/webex-core';
10
+ import {has} from 'lodash';
11
+
12
+ import Calendar from './calendar';
13
+ import config from './config';
14
+
15
+ registerInternalPlugin('calendar', Calendar, {
16
+ config,
17
+ payloadTransformer: {
18
+ predicates: [
19
+ {
20
+ name: 'transformMeetingNotes',
21
+ direction: 'inbound',
22
+ test(ctx, response) {
23
+ return Promise.resolve(
24
+ has(response, 'body.encryptedNotes') &&
25
+ !(
26
+ response.options &&
27
+ response.options.service === 'calendar' &&
28
+ response.options.method === 'GET' &&
29
+ response.options.resource === 'schedulerData'
30
+ )
31
+ );
32
+ },
33
+ extract(response) {
34
+ return Promise.resolve(response.body);
35
+ },
36
+ },
37
+ {
38
+ name: 'transformMeetingParticipants',
39
+ direction: 'inbound',
40
+ test(ctx, response) {
41
+ return Promise.resolve(
42
+ has(response, 'body.encryptedParticipants') &&
43
+ !(
44
+ response.options &&
45
+ response.options.service === 'calendar' &&
46
+ response.options.method === 'GET' &&
47
+ response.options.resource === 'schedulerData'
48
+ )
49
+ );
50
+ },
51
+ extract(response) {
52
+ return Promise.resolve(response.body);
53
+ },
54
+ },
55
+ {
56
+ name: 'transformMeetingArray',
57
+ direction: 'inbound',
58
+ test(ctx, response) {
59
+ return Promise.resolve(has(response, 'body.items[0].seriesId'));
60
+ },
61
+ extract(response) {
62
+ return Promise.resolve(response.body.items);
63
+ },
64
+ },
65
+ {
66
+ name: 'transformMeeting',
67
+ direction: 'inbound',
68
+ test(ctx, response) {
69
+ return Promise.resolve(
70
+ has(response, 'body.seriesId') &&
71
+ !(
72
+ response.options &&
73
+ response.options.service === 'calendar' &&
74
+ response.options.method === 'GET' &&
75
+ response.options.resource === 'schedulerData'
76
+ )
77
+ );
78
+ },
79
+ extract(response) {
80
+ return Promise.resolve(response.body);
81
+ },
82
+ },
83
+ {
84
+ name: 'transformMeeting',
85
+ direction: 'inbound',
86
+ test(ctx, response) {
87
+ return Promise.resolve(has(response, 'calendarMeetingExternal'));
88
+ },
89
+ extract(response) {
90
+ return Promise.resolve(response.calendarMeetingExternal);
91
+ },
92
+ },
93
+ ],
94
+ transforms: [
95
+ {
96
+ name: 'transformMeetingArray',
97
+ fn(ctx, array) {
98
+ return Promise.all(array.map((item) => ctx.transform('transformMeeting', item)));
99
+ },
100
+ },
101
+ {
102
+ name: 'transformMeeting',
103
+ direction: 'inbound',
104
+ fn(ctx, object) {
105
+ if (!object) {
106
+ return Promise.resolve();
107
+ }
108
+
109
+ if (!object.encryptionKeyUrl) {
110
+ return Promise.resolve();
111
+ }
112
+
113
+ // Decrypt participant properties if meeting object contains participants
114
+ const decryptedParticipants = object.encryptedParticipants
115
+ ? object.encryptedParticipants.map((participant) =>
116
+ Promise.all([
117
+ ctx.transform(
118
+ 'decryptTextProp',
119
+ 'encryptedEmailAddress',
120
+ object.encryptionKeyUrl,
121
+ participant
122
+ ),
123
+ ctx.transform(
124
+ 'decryptTextProp',
125
+ 'encryptedName',
126
+ object.encryptionKeyUrl,
127
+ participant
128
+ ),
129
+ ])
130
+ )
131
+ : [];
132
+
133
+ // Decrypt meetingJoinInfo properties if meeting object contains meetingJoinInfo
134
+ const decryptedMeetingJoinInfo = object.meetingJoinInfo
135
+ ? Promise.all([
136
+ ctx.transform(
137
+ 'decryptTextProp',
138
+ 'meetingJoinURI',
139
+ object.encryptionKeyUrl,
140
+ object.meetingJoinInfo
141
+ ),
142
+ ctx.transform(
143
+ 'decryptTextProp',
144
+ 'meetingJoinURL',
145
+ object.encryptionKeyUrl,
146
+ object.meetingJoinInfo
147
+ ),
148
+ ])
149
+ : [];
150
+
151
+ const decryptedOrganizer = object.encryptedOrganizer
152
+ ? Promise.all([
153
+ ctx.transform(
154
+ 'decryptTextProp',
155
+ 'encryptedEmailAddress',
156
+ object.encryptionKeyUrl,
157
+ object.encryptedOrganizer
158
+ ),
159
+ ctx.transform(
160
+ 'decryptTextProp',
161
+ 'encryptedName',
162
+ object.encryptionKeyUrl,
163
+ object.encryptedOrganizer
164
+ ),
165
+ ])
166
+ : [];
167
+
168
+ return Promise.all(
169
+ [
170
+ ctx.transform('decryptTextProp', 'encryptedSubject', object.encryptionKeyUrl, object),
171
+ ctx.transform(
172
+ 'decryptTextProp',
173
+ 'encryptedLocation',
174
+ object.encryptionKeyUrl,
175
+ object
176
+ ),
177
+ ctx.transform('decryptTextProp', 'encryptedNotes', object.encryptionKeyUrl, object),
178
+ ctx.transform('decryptTextProp', 'webexURI', object.encryptionKeyUrl, object),
179
+ ctx.transform('decryptTextProp', 'webexURL', object.encryptionKeyUrl, object),
180
+ ctx.transform('decryptTextProp', 'spaceMeetURL', object.encryptionKeyUrl, object),
181
+ ctx.transform('decryptTextProp', 'spaceURI', object.encryptionKeyUrl, object),
182
+ ctx.transform('decryptTextProp', 'spaceURL', object.encryptionKeyUrl, object),
183
+ ].concat(decryptedOrganizer, decryptedParticipants, decryptedMeetingJoinInfo)
184
+ );
185
+ },
186
+ },
187
+ {
188
+ name: 'transformMeetingNotes',
189
+ direction: 'inbound',
190
+ fn(ctx, object) {
191
+ if (!object) {
192
+ return Promise.resolve();
193
+ }
194
+
195
+ if (!object.encryptionKeyUrl) {
196
+ return Promise.resolve();
197
+ }
198
+
199
+ return Promise.all([
200
+ ctx.transform('decryptTextProp', 'encryptedNotes', object.encryptionKeyUrl, object),
201
+ ]);
202
+ },
203
+ },
204
+ {
205
+ name: 'transformMeetingParticipants',
206
+ direction: 'inbound',
207
+ fn(ctx, object) {
208
+ if (!object) {
209
+ return Promise.resolve();
210
+ }
211
+
212
+ if (!object.encryptionKeyUrl || !object.encryptedParticipants) {
213
+ return Promise.resolve();
214
+ }
215
+
216
+ // Decrypt participant properties
217
+ const decryptedParticipants = object.encryptedParticipants.map((participant) =>
218
+ Promise.all([
219
+ ctx.transform(
220
+ 'decryptTextProp',
221
+ 'encryptedEmailAddress',
222
+ object.encryptionKeyUrl,
223
+ participant
224
+ ),
225
+ ctx.transform(
226
+ 'decryptTextProp',
227
+ 'encryptedName',
228
+ object.encryptionKeyUrl,
229
+ participant
230
+ ),
231
+ ])
232
+ );
233
+
234
+ return Promise.all(decryptedParticipants);
235
+ },
236
+ },
237
+ ],
238
+ },
239
+ });
240
+
241
+ export {default} from './calendar';
package/src/util.js CHANGED
@@ -1,22 +1,22 @@
1
- const CalendarUtil = {
2
- // calculate the end time for the meeting based on the duration so it's stored on
3
- // the scheduled meeting item, that way client can display start and end without
4
- // calculation on their side
5
- // gets the start time from server, and the duration, and reformats
6
- /**
7
- * calculates the end time for meeting
8
- * @param {Object} item the locus.host property
9
- * @param {Object} item.start start time of the meeting
10
- * @param {Object} item.duration duration of the meeting
11
- * @returns {Object} end time of the meeting
12
- * @memberof CalendarUtil
13
- */
14
- calculateEndTime(item) {
15
- return {
16
- ...item,
17
- endTime: new Date(new Date(item.start).getTime() + item.durationMinutes * 60000),
18
- };
19
- },
20
- };
21
-
22
- export default CalendarUtil;
1
+ const CalendarUtil = {
2
+ // calculate the end time for the meeting based on the duration so it's stored on
3
+ // the scheduled meeting item, that way client can display start and end without
4
+ // calculation on their side
5
+ // gets the start time from server, and the duration, and reformats
6
+ /**
7
+ * calculates the end time for meeting
8
+ * @param {Object} item the locus.host property
9
+ * @param {Object} item.start start time of the meeting
10
+ * @param {Object} item.duration duration of the meeting
11
+ * @returns {Object} end time of the meeting
12
+ * @memberof CalendarUtil
13
+ */
14
+ calculateEndTime(item) {
15
+ return {
16
+ ...item,
17
+ endTime: new Date(new Date(item.start).getTime() + item.durationMinutes * 60000),
18
+ };
19
+ },
20
+ };
21
+
22
+ export default CalendarUtil;