@webex/internal-plugin-conversation 2.59.1 → 2.59.3-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.
- package/.eslintrc.js +6 -6
- package/README.md +47 -47
- package/babel.config.js +3 -3
- package/dist/activities.js +4 -4
- package/dist/activities.js.map +1 -1
- package/dist/activity-thread-ordering.js +34 -34
- package/dist/activity-thread-ordering.js.map +1 -1
- package/dist/config.js +12 -12
- package/dist/config.js.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/conversation.js +474 -474
- package/dist/conversation.js.map +1 -1
- package/dist/convo-error.js +4 -4
- package/dist/convo-error.js.map +1 -1
- package/dist/decryption-transforms.js +155 -155
- package/dist/decryption-transforms.js.map +1 -1
- package/dist/encryption-transforms.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/share-activity.js +57 -57
- package/dist/share-activity.js.map +1 -1
- package/dist/to-array.js +7 -7
- package/dist/to-array.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +21 -20
- package/process +1 -1
- package/src/activities.js +157 -157
- package/src/activity-thread-ordering.js +283 -283
- package/src/activity-threading.md +282 -282
- package/src/config.js +37 -37
- package/src/constants.js +3 -3
- package/src/conversation.js +2535 -2535
- package/src/convo-error.js +15 -15
- package/src/decryption-transforms.js +541 -541
- package/src/encryption-transforms.js +345 -345
- package/src/index.js +327 -327
- package/src/share-activity.js +436 -436
- package/src/to-array.js +29 -29
- package/test/integration/spec/create.js +290 -290
- package/test/integration/spec/encryption.js +333 -333
- package/test/integration/spec/get.js +1255 -1255
- package/test/integration/spec/mercury.js +94 -94
- package/test/integration/spec/share.js +537 -537
- package/test/integration/spec/verbs.js +1041 -1041
- package/test/unit/spec/conversation.js +823 -823
- package/test/unit/spec/decrypt-transforms.js +460 -460
- package/test/unit/spec/encryption-transforms.js +93 -93
- package/test/unit/spec/share-activity.js +178 -178
package/src/index.js
CHANGED
|
@@ -1,327 +1,327 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@webex/internal-plugin-encryption';
|
|
6
|
-
import '@webex/internal-plugin-user';
|
|
7
|
-
|
|
8
|
-
import {patterns} from '@webex/common';
|
|
9
|
-
import {filter as htmlFilter, filterEscape as htmlFilterEscape} from '@webex/helper-html';
|
|
10
|
-
import {registerInternalPlugin} from '@webex/webex-core';
|
|
11
|
-
import {capitalize, get, has} from 'lodash';
|
|
12
|
-
|
|
13
|
-
import Conversation from './conversation';
|
|
14
|
-
import config from './config';
|
|
15
|
-
import {transforms as encryptionTransforms} from './encryption-transforms';
|
|
16
|
-
import {transforms as decryptionTransforms} from './decryption-transforms';
|
|
17
|
-
|
|
18
|
-
registerInternalPlugin('conversation', Conversation, {
|
|
19
|
-
payloadTransformer: {
|
|
20
|
-
predicates: [
|
|
21
|
-
{
|
|
22
|
-
name: 'transformObject',
|
|
23
|
-
test(ctx, optionsOrResponse) {
|
|
24
|
-
return Promise.resolve(has(optionsOrResponse, 'body.objectType'));
|
|
25
|
-
},
|
|
26
|
-
extract(optionsOrResponse) {
|
|
27
|
-
return Promise.resolve(optionsOrResponse.body);
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: 'transformObject',
|
|
32
|
-
direction: 'inbound',
|
|
33
|
-
test(ctx, event) {
|
|
34
|
-
return Promise.resolve(has(event, 'activity'));
|
|
35
|
-
},
|
|
36
|
-
extract(event) {
|
|
37
|
-
return Promise.resolve(event.activity);
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: 'transformObjectArray',
|
|
42
|
-
direction: 'inbound',
|
|
43
|
-
test(ctx, response) {
|
|
44
|
-
return Promise.resolve(has(response, 'body.multistatus'));
|
|
45
|
-
},
|
|
46
|
-
extract(response) {
|
|
47
|
-
return Promise.resolve(
|
|
48
|
-
response.body.multistatus.map((item) => item && item.data && item.data.activity)
|
|
49
|
-
);
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: 'normalizeConversationListAndBindDecrypters',
|
|
54
|
-
direction: 'inbound',
|
|
55
|
-
test(ctx, options) {
|
|
56
|
-
if (!has(options, 'body.items[0].objectType')) {
|
|
57
|
-
return Promise.resolve(false);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (get(options, 'options.deferDecrypt')) {
|
|
61
|
-
return Promise.resolve(true);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return Promise.resolve(false);
|
|
65
|
-
},
|
|
66
|
-
extract(options) {
|
|
67
|
-
return Promise.resolve(options.body.items);
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: 'transformObjectArray',
|
|
72
|
-
direction: 'inbound',
|
|
73
|
-
test(ctx, options) {
|
|
74
|
-
if (!has(options, 'body.items[0].objectType')) {
|
|
75
|
-
return Promise.resolve(false);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (get(options, 'options.deferDecrypt')) {
|
|
79
|
-
return Promise.resolve(false);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return Promise.resolve(true);
|
|
83
|
-
},
|
|
84
|
-
extract(options) {
|
|
85
|
-
return Promise.resolve(options.body.items);
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: 'transformThreadArray',
|
|
90
|
-
direction: 'inbound',
|
|
91
|
-
test(ctx, options) {
|
|
92
|
-
if (!has(options, 'body.items[0].childType') || !has(options, 'body.items[0].actorId')) {
|
|
93
|
-
return Promise.resolve(false);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (get(options, 'options.deferDecrypt')) {
|
|
97
|
-
return Promise.resolve(false);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return Promise.resolve(true);
|
|
101
|
-
},
|
|
102
|
-
extract(options) {
|
|
103
|
-
return Promise.resolve(options.body.items);
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
transforms: [
|
|
108
|
-
{
|
|
109
|
-
name: 'normalizeConversationListAndBindDecrypters',
|
|
110
|
-
fn(ctx, array) {
|
|
111
|
-
return Promise.all(
|
|
112
|
-
array.map((item) =>
|
|
113
|
-
ctx.transform('normalizeObject', item).then(() => {
|
|
114
|
-
item.decrypt = function decrypt() {
|
|
115
|
-
Reflect.deleteProperty(item, 'decrypt');
|
|
116
|
-
|
|
117
|
-
return ctx.transform('decryptObject', item);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
return item;
|
|
121
|
-
})
|
|
122
|
-
)
|
|
123
|
-
);
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
name: 'transformObjectArray',
|
|
128
|
-
fn(ctx, array) {
|
|
129
|
-
return Promise.all(array.map((item) => ctx.transform('transformObject', item)));
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: 'transformThreadArray',
|
|
134
|
-
fn(ctx, array) {
|
|
135
|
-
return Promise.all(array.map((item) => ctx.transform('transformThread', item)));
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: 'transformObject',
|
|
140
|
-
direction: 'outbound',
|
|
141
|
-
fn(ctx, object) {
|
|
142
|
-
if (!object) {
|
|
143
|
-
return Promise.resolve();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (!object.objectType) {
|
|
147
|
-
return Promise.resolve();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return ctx
|
|
151
|
-
.transform('normalizeObject', object)
|
|
152
|
-
.then(() => ctx.transform('encryptObject', object))
|
|
153
|
-
.then(() => ctx.transform('encryptKmsMessage', object));
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
name: 'transformObject',
|
|
158
|
-
direction: 'inbound',
|
|
159
|
-
fn(ctx, object) {
|
|
160
|
-
if (!object) {
|
|
161
|
-
return Promise.resolve();
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (!object.objectType) {
|
|
165
|
-
return Promise.resolve();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return ctx
|
|
169
|
-
.transform('decryptObject', object)
|
|
170
|
-
.then(() => ctx.transform('normalizeObject', object));
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
name: 'normalizeObject',
|
|
175
|
-
fn(ctx, object) {
|
|
176
|
-
if (!object) {
|
|
177
|
-
return Promise.resolve();
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (!object.objectType) {
|
|
181
|
-
return Promise.resolve();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return Promise.all([
|
|
185
|
-
ctx.transform(`normalize${capitalize(object.objectType)}`, object),
|
|
186
|
-
ctx.transform('normalizePropContent', object),
|
|
187
|
-
]);
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: 'transformThread',
|
|
192
|
-
direction: 'inbound',
|
|
193
|
-
fn(ctx, object) {
|
|
194
|
-
if (!object) {
|
|
195
|
-
return Promise.resolve();
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return ctx
|
|
199
|
-
.transform('decryptThread', object)
|
|
200
|
-
.then(() => ctx.transform('normalizeThread', object));
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
name: 'normalizePropContent',
|
|
205
|
-
direction: 'inbound',
|
|
206
|
-
fn(ctx, object) {
|
|
207
|
-
if (!object.content) {
|
|
208
|
-
return Promise.resolve();
|
|
209
|
-
}
|
|
210
|
-
const {inboundProcessFunc, allowedInboundTags, allowedInboundStyles} =
|
|
211
|
-
ctx.webex.config.conversation;
|
|
212
|
-
|
|
213
|
-
return htmlFilter(
|
|
214
|
-
inboundProcessFunc,
|
|
215
|
-
allowedInboundTags || {},
|
|
216
|
-
allowedInboundStyles,
|
|
217
|
-
object.content
|
|
218
|
-
).then((c) => {
|
|
219
|
-
object.content = c;
|
|
220
|
-
});
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
name: 'normalizePropContent',
|
|
225
|
-
direction: 'outbound',
|
|
226
|
-
fn(ctx, object) {
|
|
227
|
-
if (!object.content) {
|
|
228
|
-
return Promise.resolve();
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const {outboundProcessFunc, allowedOutboundTags, allowedOutboundStyles} =
|
|
232
|
-
ctx.webex.config.conversation;
|
|
233
|
-
|
|
234
|
-
return htmlFilterEscape(
|
|
235
|
-
outboundProcessFunc,
|
|
236
|
-
allowedOutboundTags || {},
|
|
237
|
-
allowedOutboundStyles,
|
|
238
|
-
object.content
|
|
239
|
-
).then((c) => {
|
|
240
|
-
object.content = c;
|
|
241
|
-
});
|
|
242
|
-
},
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
name: 'normalizeConversation',
|
|
246
|
-
fn(ctx, conversation) {
|
|
247
|
-
conversation.activities = conversation.activities || {};
|
|
248
|
-
conversation.activities.items = conversation.activities.items || [];
|
|
249
|
-
conversation.participants = conversation.participants || {};
|
|
250
|
-
conversation.participants.items = conversation.participants.items || [];
|
|
251
|
-
|
|
252
|
-
return Promise.all([
|
|
253
|
-
Promise.all(
|
|
254
|
-
conversation.activities.items.map((item) => ctx.transform('normalizeObject', item))
|
|
255
|
-
),
|
|
256
|
-
Promise.all(
|
|
257
|
-
conversation.participants.items.map((item) => ctx.transform('normalizeObject', item))
|
|
258
|
-
),
|
|
259
|
-
]);
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
name: 'normalizeActivity',
|
|
264
|
-
fn(ctx, activity) {
|
|
265
|
-
return Promise.all([
|
|
266
|
-
ctx.transform('normalizeObject', activity.actor),
|
|
267
|
-
ctx.transform('normalizeObject', activity.object),
|
|
268
|
-
ctx.transform('normalizeObject', activity.target),
|
|
269
|
-
]);
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
name: 'normalizeThread',
|
|
274
|
-
fn(ctx, threadActivity) {
|
|
275
|
-
// childActivities are of type Activity
|
|
276
|
-
return Promise.all(
|
|
277
|
-
threadActivity.childActivities.map((item) => ctx.transform('normalizeObject', item))
|
|
278
|
-
);
|
|
279
|
-
},
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
name: 'normalizePerson',
|
|
283
|
-
// eslint-disable-next-line complexity
|
|
284
|
-
fn(ctx, person) {
|
|
285
|
-
const email = person.entryEmail || person.emailAddress || person.id;
|
|
286
|
-
const id = person.entryUUID || person.id;
|
|
287
|
-
|
|
288
|
-
if (patterns.email.test(email)) {
|
|
289
|
-
person.entryEmail = person.emailAddress = email.toLowerCase();
|
|
290
|
-
} else {
|
|
291
|
-
Reflect.deleteProperty(person, 'entryEmail');
|
|
292
|
-
Reflect.deleteProperty(person, 'emailAddress');
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (person.roomProperties) {
|
|
296
|
-
person.roomProperties.isModerator = Boolean(person.roomProperties.isModerator);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (patterns.uuid.test(id)) {
|
|
300
|
-
person.entryUUID = person.id = id.toLowerCase();
|
|
301
|
-
|
|
302
|
-
return Promise.resolve(person);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (!email) {
|
|
306
|
-
return Promise.reject(
|
|
307
|
-
new Error('cannot determine id without an `emailAddress` or `entryUUID` property')
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
return ctx.webex.internal.user.asUUID(email).then((uuid) => {
|
|
312
|
-
person.entryUUID = person.id = uuid;
|
|
313
|
-
|
|
314
|
-
return person;
|
|
315
|
-
});
|
|
316
|
-
},
|
|
317
|
-
},
|
|
318
|
-
]
|
|
319
|
-
.concat(decryptionTransforms)
|
|
320
|
-
.concat(encryptionTransforms),
|
|
321
|
-
},
|
|
322
|
-
config,
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
export {default} from './conversation';
|
|
326
|
-
export {default as ShareActivity} from './share-activity';
|
|
327
|
-
export {ConversationError, InvalidUserCreation} from './convo-error';
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import '@webex/internal-plugin-encryption';
|
|
6
|
+
import '@webex/internal-plugin-user';
|
|
7
|
+
|
|
8
|
+
import {patterns} from '@webex/common';
|
|
9
|
+
import {filter as htmlFilter, filterEscape as htmlFilterEscape} from '@webex/helper-html';
|
|
10
|
+
import {registerInternalPlugin} from '@webex/webex-core';
|
|
11
|
+
import {capitalize, get, has} from 'lodash';
|
|
12
|
+
|
|
13
|
+
import Conversation from './conversation';
|
|
14
|
+
import config from './config';
|
|
15
|
+
import {transforms as encryptionTransforms} from './encryption-transforms';
|
|
16
|
+
import {transforms as decryptionTransforms} from './decryption-transforms';
|
|
17
|
+
|
|
18
|
+
registerInternalPlugin('conversation', Conversation, {
|
|
19
|
+
payloadTransformer: {
|
|
20
|
+
predicates: [
|
|
21
|
+
{
|
|
22
|
+
name: 'transformObject',
|
|
23
|
+
test(ctx, optionsOrResponse) {
|
|
24
|
+
return Promise.resolve(has(optionsOrResponse, 'body.objectType'));
|
|
25
|
+
},
|
|
26
|
+
extract(optionsOrResponse) {
|
|
27
|
+
return Promise.resolve(optionsOrResponse.body);
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'transformObject',
|
|
32
|
+
direction: 'inbound',
|
|
33
|
+
test(ctx, event) {
|
|
34
|
+
return Promise.resolve(has(event, 'activity'));
|
|
35
|
+
},
|
|
36
|
+
extract(event) {
|
|
37
|
+
return Promise.resolve(event.activity);
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'transformObjectArray',
|
|
42
|
+
direction: 'inbound',
|
|
43
|
+
test(ctx, response) {
|
|
44
|
+
return Promise.resolve(has(response, 'body.multistatus'));
|
|
45
|
+
},
|
|
46
|
+
extract(response) {
|
|
47
|
+
return Promise.resolve(
|
|
48
|
+
response.body.multistatus.map((item) => item && item.data && item.data.activity)
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'normalizeConversationListAndBindDecrypters',
|
|
54
|
+
direction: 'inbound',
|
|
55
|
+
test(ctx, options) {
|
|
56
|
+
if (!has(options, 'body.items[0].objectType')) {
|
|
57
|
+
return Promise.resolve(false);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (get(options, 'options.deferDecrypt')) {
|
|
61
|
+
return Promise.resolve(true);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return Promise.resolve(false);
|
|
65
|
+
},
|
|
66
|
+
extract(options) {
|
|
67
|
+
return Promise.resolve(options.body.items);
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'transformObjectArray',
|
|
72
|
+
direction: 'inbound',
|
|
73
|
+
test(ctx, options) {
|
|
74
|
+
if (!has(options, 'body.items[0].objectType')) {
|
|
75
|
+
return Promise.resolve(false);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (get(options, 'options.deferDecrypt')) {
|
|
79
|
+
return Promise.resolve(false);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return Promise.resolve(true);
|
|
83
|
+
},
|
|
84
|
+
extract(options) {
|
|
85
|
+
return Promise.resolve(options.body.items);
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'transformThreadArray',
|
|
90
|
+
direction: 'inbound',
|
|
91
|
+
test(ctx, options) {
|
|
92
|
+
if (!has(options, 'body.items[0].childType') || !has(options, 'body.items[0].actorId')) {
|
|
93
|
+
return Promise.resolve(false);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (get(options, 'options.deferDecrypt')) {
|
|
97
|
+
return Promise.resolve(false);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return Promise.resolve(true);
|
|
101
|
+
},
|
|
102
|
+
extract(options) {
|
|
103
|
+
return Promise.resolve(options.body.items);
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
transforms: [
|
|
108
|
+
{
|
|
109
|
+
name: 'normalizeConversationListAndBindDecrypters',
|
|
110
|
+
fn(ctx, array) {
|
|
111
|
+
return Promise.all(
|
|
112
|
+
array.map((item) =>
|
|
113
|
+
ctx.transform('normalizeObject', item).then(() => {
|
|
114
|
+
item.decrypt = function decrypt() {
|
|
115
|
+
Reflect.deleteProperty(item, 'decrypt');
|
|
116
|
+
|
|
117
|
+
return ctx.transform('decryptObject', item);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
return item;
|
|
121
|
+
})
|
|
122
|
+
)
|
|
123
|
+
);
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'transformObjectArray',
|
|
128
|
+
fn(ctx, array) {
|
|
129
|
+
return Promise.all(array.map((item) => ctx.transform('transformObject', item)));
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'transformThreadArray',
|
|
134
|
+
fn(ctx, array) {
|
|
135
|
+
return Promise.all(array.map((item) => ctx.transform('transformThread', item)));
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: 'transformObject',
|
|
140
|
+
direction: 'outbound',
|
|
141
|
+
fn(ctx, object) {
|
|
142
|
+
if (!object) {
|
|
143
|
+
return Promise.resolve();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (!object.objectType) {
|
|
147
|
+
return Promise.resolve();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return ctx
|
|
151
|
+
.transform('normalizeObject', object)
|
|
152
|
+
.then(() => ctx.transform('encryptObject', object))
|
|
153
|
+
.then(() => ctx.transform('encryptKmsMessage', object));
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: 'transformObject',
|
|
158
|
+
direction: 'inbound',
|
|
159
|
+
fn(ctx, object) {
|
|
160
|
+
if (!object) {
|
|
161
|
+
return Promise.resolve();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (!object.objectType) {
|
|
165
|
+
return Promise.resolve();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return ctx
|
|
169
|
+
.transform('decryptObject', object)
|
|
170
|
+
.then(() => ctx.transform('normalizeObject', object));
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: 'normalizeObject',
|
|
175
|
+
fn(ctx, object) {
|
|
176
|
+
if (!object) {
|
|
177
|
+
return Promise.resolve();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (!object.objectType) {
|
|
181
|
+
return Promise.resolve();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return Promise.all([
|
|
185
|
+
ctx.transform(`normalize${capitalize(object.objectType)}`, object),
|
|
186
|
+
ctx.transform('normalizePropContent', object),
|
|
187
|
+
]);
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: 'transformThread',
|
|
192
|
+
direction: 'inbound',
|
|
193
|
+
fn(ctx, object) {
|
|
194
|
+
if (!object) {
|
|
195
|
+
return Promise.resolve();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return ctx
|
|
199
|
+
.transform('decryptThread', object)
|
|
200
|
+
.then(() => ctx.transform('normalizeThread', object));
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'normalizePropContent',
|
|
205
|
+
direction: 'inbound',
|
|
206
|
+
fn(ctx, object) {
|
|
207
|
+
if (!object.content) {
|
|
208
|
+
return Promise.resolve();
|
|
209
|
+
}
|
|
210
|
+
const {inboundProcessFunc, allowedInboundTags, allowedInboundStyles} =
|
|
211
|
+
ctx.webex.config.conversation;
|
|
212
|
+
|
|
213
|
+
return htmlFilter(
|
|
214
|
+
inboundProcessFunc,
|
|
215
|
+
allowedInboundTags || {},
|
|
216
|
+
allowedInboundStyles,
|
|
217
|
+
object.content
|
|
218
|
+
).then((c) => {
|
|
219
|
+
object.content = c;
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: 'normalizePropContent',
|
|
225
|
+
direction: 'outbound',
|
|
226
|
+
fn(ctx, object) {
|
|
227
|
+
if (!object.content) {
|
|
228
|
+
return Promise.resolve();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const {outboundProcessFunc, allowedOutboundTags, allowedOutboundStyles} =
|
|
232
|
+
ctx.webex.config.conversation;
|
|
233
|
+
|
|
234
|
+
return htmlFilterEscape(
|
|
235
|
+
outboundProcessFunc,
|
|
236
|
+
allowedOutboundTags || {},
|
|
237
|
+
allowedOutboundStyles,
|
|
238
|
+
object.content
|
|
239
|
+
).then((c) => {
|
|
240
|
+
object.content = c;
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: 'normalizeConversation',
|
|
246
|
+
fn(ctx, conversation) {
|
|
247
|
+
conversation.activities = conversation.activities || {};
|
|
248
|
+
conversation.activities.items = conversation.activities.items || [];
|
|
249
|
+
conversation.participants = conversation.participants || {};
|
|
250
|
+
conversation.participants.items = conversation.participants.items || [];
|
|
251
|
+
|
|
252
|
+
return Promise.all([
|
|
253
|
+
Promise.all(
|
|
254
|
+
conversation.activities.items.map((item) => ctx.transform('normalizeObject', item))
|
|
255
|
+
),
|
|
256
|
+
Promise.all(
|
|
257
|
+
conversation.participants.items.map((item) => ctx.transform('normalizeObject', item))
|
|
258
|
+
),
|
|
259
|
+
]);
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: 'normalizeActivity',
|
|
264
|
+
fn(ctx, activity) {
|
|
265
|
+
return Promise.all([
|
|
266
|
+
ctx.transform('normalizeObject', activity.actor),
|
|
267
|
+
ctx.transform('normalizeObject', activity.object),
|
|
268
|
+
ctx.transform('normalizeObject', activity.target),
|
|
269
|
+
]);
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: 'normalizeThread',
|
|
274
|
+
fn(ctx, threadActivity) {
|
|
275
|
+
// childActivities are of type Activity
|
|
276
|
+
return Promise.all(
|
|
277
|
+
threadActivity.childActivities.map((item) => ctx.transform('normalizeObject', item))
|
|
278
|
+
);
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: 'normalizePerson',
|
|
283
|
+
// eslint-disable-next-line complexity
|
|
284
|
+
fn(ctx, person) {
|
|
285
|
+
const email = person.entryEmail || person.emailAddress || person.id;
|
|
286
|
+
const id = person.entryUUID || person.id;
|
|
287
|
+
|
|
288
|
+
if (patterns.email.test(email)) {
|
|
289
|
+
person.entryEmail = person.emailAddress = email.toLowerCase();
|
|
290
|
+
} else {
|
|
291
|
+
Reflect.deleteProperty(person, 'entryEmail');
|
|
292
|
+
Reflect.deleteProperty(person, 'emailAddress');
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (person.roomProperties) {
|
|
296
|
+
person.roomProperties.isModerator = Boolean(person.roomProperties.isModerator);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (patterns.uuid.test(id)) {
|
|
300
|
+
person.entryUUID = person.id = id.toLowerCase();
|
|
301
|
+
|
|
302
|
+
return Promise.resolve(person);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (!email) {
|
|
306
|
+
return Promise.reject(
|
|
307
|
+
new Error('cannot determine id without an `emailAddress` or `entryUUID` property')
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return ctx.webex.internal.user.asUUID(email).then((uuid) => {
|
|
312
|
+
person.entryUUID = person.id = uuid;
|
|
313
|
+
|
|
314
|
+
return person;
|
|
315
|
+
});
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
]
|
|
319
|
+
.concat(decryptionTransforms)
|
|
320
|
+
.concat(encryptionTransforms),
|
|
321
|
+
},
|
|
322
|
+
config,
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
export {default} from './conversation';
|
|
326
|
+
export {default as ShareActivity} from './share-activity';
|
|
327
|
+
export {ConversationError, InvalidUserCreation} from './convo-error';
|