@webex/internal-plugin-conversation 3.0.0-beta.9 → 3.0.0-bnr.2

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.
Files changed (57) hide show
  1. package/README.md +1 -3
  2. package/dist/activities.js +8 -69
  3. package/dist/activities.js.map +1 -1
  4. package/dist/activity-thread-ordering.js +19 -79
  5. package/dist/activity-thread-ordering.js.map +1 -1
  6. package/dist/config.js +1 -7
  7. package/dist/config.js.map +1 -1
  8. package/dist/constants.js +4 -5
  9. package/dist/constants.js.map +1 -1
  10. package/dist/conversation.js +790 -1199
  11. package/dist/conversation.js.map +1 -1
  12. package/dist/convo-error.js +0 -23
  13. package/dist/convo-error.js.map +1 -1
  14. package/dist/decryption-transforms.js +35 -98
  15. package/dist/decryption-transforms.js.map +1 -1
  16. package/dist/encryption-transforms.js +11 -48
  17. package/dist/encryption-transforms.js.map +1 -1
  18. package/dist/index.js +7 -50
  19. package/dist/index.js.map +1 -1
  20. package/dist/internal-plugin-conversation.d.ts +21 -0
  21. package/dist/share-activity.js +40 -106
  22. package/dist/share-activity.js.map +1 -1
  23. package/dist/to-array.js +9 -11
  24. package/dist/to-array.js.map +1 -1
  25. package/dist/tsdoc-metadata.json +11 -0
  26. package/dist/types/activities.d.ts +32 -0
  27. package/dist/types/activity-thread-ordering.d.ts +18 -0
  28. package/dist/types/config.d.ts +19 -0
  29. package/dist/types/constants.d.ts +5 -0
  30. package/dist/types/conversation.d.ts +2 -0
  31. package/dist/types/convo-error.d.ts +10 -0
  32. package/dist/types/decryption-transforms.d.ts +1 -0
  33. package/dist/types/encryption-transforms.d.ts +1 -0
  34. package/dist/types/index.d.ts +3 -0
  35. package/dist/types/share-activity.d.ts +7 -0
  36. package/dist/types/to-array.d.ts +9 -0
  37. package/package.json +15 -15
  38. package/src/activities.js +10 -7
  39. package/src/activity-thread-ordering.js +27 -30
  40. package/src/activity-threading.md +68 -49
  41. package/src/config.js +5 -5
  42. package/src/conversation.js +621 -589
  43. package/src/decryption-transforms.js +103 -62
  44. package/src/encryption-transforms.js +103 -83
  45. package/src/index.js +82 -66
  46. package/src/share-activity.js +64 -55
  47. package/src/to-array.js +2 -2
  48. package/test/integration/spec/create.js +184 -118
  49. package/test/integration/spec/encryption.js +250 -186
  50. package/test/integration/spec/get.js +761 -513
  51. package/test/integration/spec/mercury.js +37 -27
  52. package/test/integration/spec/share.js +292 -229
  53. package/test/integration/spec/verbs.js +628 -441
  54. package/test/unit/spec/conversation.js +265 -163
  55. package/test/unit/spec/decrypt-transforms.js +112 -131
  56. package/test/unit/spec/encryption-transforms.js +24 -18
  57. package/test/unit/spec/share-activity.js +37 -40
@@ -9,196 +9,255 @@ import testUsers from '@webex/test-helper-test-users';
9
9
  describe('plugin-conversation', () => {
10
10
  let checkov, mccoy, participants, webex, spock;
11
11
 
12
- before(() => testUsers.create({count: 3})
13
- .then((users) => {
12
+ before(() =>
13
+ testUsers.create({count: 3}).then((users) => {
14
14
  participants = [spock, mccoy, checkov] = users;
15
15
 
16
16
  webex = new WebexCore({
17
17
  credentials: {
18
- authorization: spock.token
19
- }
18
+ authorization: spock.token,
19
+ },
20
20
  });
21
21
 
22
22
  return webex.internal.mercury.connect();
23
- }));
23
+ })
24
+ );
24
25
 
25
26
  after(() => webex && webex.internal.mercury.disconnect());
26
27
 
27
28
  describe('when not supplying enough encryption data', () => {
28
29
  let conversation;
29
30
 
30
- before(() => webex.internal.conversation.create({participants, comment: 'first'})
31
- .then((c) => {
31
+ before(() =>
32
+ webex.internal.conversation.create({participants, comment: 'first'}).then((c) => {
32
33
  conversation = c;
33
- }));
34
+ })
35
+ );
34
36
 
35
- it('fetches the conversation and does not alter its key', () => webex.internal.conversation.post({url: conversation.url}, {displayName: 'second'})
36
- .then(() => webex.internal.conversation.get(conversation))
37
- .then((c) => assert.equal(c.defaultActivityEncryptionKeyUrl, conversation.defaultActivityEncryptionKeyUrl)));
37
+ it('fetches the conversation and does not alter its key', () =>
38
+ webex.internal.conversation
39
+ .post({url: conversation.url}, {displayName: 'second'})
40
+ .then(() => webex.internal.conversation.get(conversation))
41
+ .then((c) =>
42
+ assert.equal(
43
+ c.defaultActivityEncryptionKeyUrl,
44
+ conversation.defaultActivityEncryptionKeyUrl
45
+ )
46
+ ));
38
47
  });
39
48
 
40
49
  describe('when interacting with a non-encrypted conversation', () => {
41
50
  before(() => {
42
51
  mccoy.webex = new WebexCore({
43
52
  credentials: {
44
- authorization: mccoy.token
45
- }
53
+ authorization: mccoy.token,
54
+ },
46
55
  });
47
56
 
48
57
  checkov.webex = new WebexCore({
49
58
  credentials: {
50
- authorization: checkov.token
51
- }
59
+ authorization: checkov.token,
60
+ },
52
61
  });
53
62
 
54
63
  return Promise.all([
55
64
  checkov.webex.internal.mercury.connect(),
56
- mccoy.webex.internal.mercury.connect()
65
+ mccoy.webex.internal.mercury.connect(),
57
66
  ]);
58
67
  });
59
68
 
60
- after(() => Promise.all([
61
- checkov && checkov.webex && checkov.webex.internal.mercury.disconnect(),
62
- mccoy && mccoy.webex && mccoy.webex.internal.mercury.disconnect()
63
- ]));
69
+ after(() =>
70
+ Promise.all([
71
+ checkov && checkov.webex && checkov.webex.internal.mercury.disconnect(),
72
+ mccoy && mccoy.webex && mccoy.webex.internal.mercury.disconnect(),
73
+ ])
74
+ );
64
75
 
65
76
  let conversation;
66
77
 
67
- beforeEach(() => webex.request({
68
- method: 'POST',
69
- service: 'conversation',
70
- resource: '/conversations',
71
- noTransform: true,
72
- body: {
73
- objectType: 'conversation',
74
- activities: {
75
- items: [
76
- {
77
- verb: 'create',
78
- actor: {
79
- id: spock.id,
80
- objectType: 'person'
81
- }
82
- },
83
- {
84
- verb: 'add',
85
- actor: {
86
- id: spock.id,
87
- objectType: 'person'
88
- },
89
- object: {
90
- id: spock.id,
91
- objectType: 'person'
92
- }
78
+ beforeEach(() =>
79
+ webex
80
+ .request({
81
+ method: 'POST',
82
+ service: 'conversation',
83
+ resource: '/conversations',
84
+ noTransform: true,
85
+ body: {
86
+ objectType: 'conversation',
87
+ activities: {
88
+ items: [
89
+ {
90
+ verb: 'create',
91
+ actor: {
92
+ id: spock.id,
93
+ objectType: 'person',
94
+ },
95
+ },
96
+ {
97
+ verb: 'add',
98
+ actor: {
99
+ id: spock.id,
100
+ objectType: 'person',
101
+ },
102
+ object: {
103
+ id: spock.id,
104
+ objectType: 'person',
105
+ },
106
+ },
107
+ {
108
+ verb: 'add',
109
+ actor: {
110
+ id: spock.id,
111
+ objectType: 'person',
112
+ },
113
+ object: {
114
+ id: checkov.id,
115
+ objectType: 'person',
116
+ },
117
+ },
118
+ ],
93
119
  },
94
- {
95
- verb: 'add',
96
- actor: {
97
- id: spock.id,
98
- objectType: 'person'
99
- },
100
- object: {
101
- id: checkov.id,
102
- objectType: 'person'
103
- }
104
- }
105
- ]
106
- }
107
- }
108
- })
109
- .then((res) => res.body)
110
- .then((c) => {
111
- conversation = c;
112
- assert.notProperty(conversation, 'defaultActivityEncryptionKeyUrl');
113
- }));
120
+ },
121
+ })
122
+ .then((res) => res.body)
123
+ .then((c) => {
124
+ conversation = c;
125
+ assert.notProperty(conversation, 'defaultActivityEncryptionKeyUrl');
126
+ })
127
+ );
114
128
 
115
129
  describe('when the conversation is a grouped conversation', () => {
116
130
  describe('#add()', () => {
117
- it('adds the specified user', () => webex.internal.conversation.add(conversation, mccoy)
118
- .then(() => mccoy.webex.internal.conversation.get(conversation))
119
- .then((c) => assert.property(c, 'defaultActivityEncryptionKeyUrl', 'The conversation was encrypted as a side effect of the add activity')));
131
+ it('adds the specified user', () =>
132
+ webex.internal.conversation
133
+ .add(conversation, mccoy)
134
+ .then(() => mccoy.webex.internal.conversation.get(conversation))
135
+ .then((c) =>
136
+ assert.property(
137
+ c,
138
+ 'defaultActivityEncryptionKeyUrl',
139
+ 'The conversation was encrypted as a side effect of the add activity'
140
+ )
141
+ ));
120
142
  });
121
143
 
122
144
  describe('#leave()', () => {
123
- it('removes the current user', () => webex.internal.conversation.leave(conversation)
124
- .then(() => assert.isRejected(webex.internal.conversation.get(conversation)))
125
- .then((reason) => assert.instanceOf(reason, WebexHttpError.NotFound))
126
- .then(() => checkov.webex.internal.conversation.get(conversation))
127
- .then((c) => assert.notProperty(c, 'defaultActivityEncryptionKeyUrl', 'The conversation was not encrypted as a side effect of the leave activity')));
145
+ it('removes the current user', () =>
146
+ webex.internal.conversation
147
+ .leave(conversation)
148
+ .then(() => assert.isRejected(webex.internal.conversation.get(conversation)))
149
+ .then((reason) => assert.instanceOf(reason, WebexHttpError.NotFound))
150
+ .then(() => checkov.webex.internal.conversation.get(conversation))
151
+ .then((c) =>
152
+ assert.notProperty(
153
+ c,
154
+ 'defaultActivityEncryptionKeyUrl',
155
+ 'The conversation was not encrypted as a side effect of the leave activity'
156
+ )
157
+ ));
128
158
 
129
- it('removes the specified user', () => webex.internal.conversation.leave(conversation, checkov)
130
- .then(() => assert.isRejected(checkov.webex.internal.conversation.get(conversation)))
131
- .then((reason) => assert.instanceOf(reason, WebexHttpError.NotFound))
132
- .then(() => webex.internal.conversation.get(conversation))
133
- .then((c) => assert.notProperty(c, 'defaultActivityEncryptionKeyUrl', 'The conversation was not encrypted as a side effect of the leave activity')));
159
+ it('removes the specified user', () =>
160
+ webex.internal.conversation
161
+ .leave(conversation, checkov)
162
+ .then(() => assert.isRejected(checkov.webex.internal.conversation.get(conversation)))
163
+ .then((reason) => assert.instanceOf(reason, WebexHttpError.NotFound))
164
+ .then(() => webex.internal.conversation.get(conversation))
165
+ .then((c) =>
166
+ assert.notProperty(
167
+ c,
168
+ 'defaultActivityEncryptionKeyUrl',
169
+ 'The conversation was not encrypted as a side effect of the leave activity'
170
+ )
171
+ ));
134
172
  });
135
173
 
136
174
  describe('#post()', () => {
137
- it('posts a message', () => webex.internal.conversation.post(conversation, {displayName: 'Ahoy'})
138
- .then(() => checkov.webex.internal.conversation.get(conversation, {activitiesLimit: 1}))
139
- .then((c) => {
140
- assert.property(c, 'defaultActivityEncryptionKeyUrl');
141
- assert.equal(c.activities.items[0].object.displayName, 'Ahoy');
142
- }));
175
+ it('posts a message', () =>
176
+ webex.internal.conversation
177
+ .post(conversation, {displayName: 'Ahoy'})
178
+ .then(() => checkov.webex.internal.conversation.get(conversation, {activitiesLimit: 1}))
179
+ .then((c) => {
180
+ assert.property(c, 'defaultActivityEncryptionKeyUrl');
181
+ assert.equal(c.activities.items[0].object.displayName, 'Ahoy');
182
+ }));
143
183
  });
144
184
 
145
185
  describe('#cardAction()', () => {
146
- it('creates a cardAction Activity', () => webex.internal.conversation.post(conversation, {displayName: 'First Message', cards: ['test']})
147
- .then(() => checkov.webex.internal.conversation.get(conversation, {activitiesLimit: 1}))
148
- .then((c) => {
149
- assert.property(c, 'defaultActivityEncryptionKeyUrl');
150
- assert.equal(c.activities.items[0].object.displayName, 'First Message');
151
- webex.internal.conversation.cardAction(conversation, {
152
- objectType: 'submit',
153
- inputs: {key: 'value'}
154
- }, c.activities.items[0])
155
- .then(() => checkov.webex.internal.conversation.get(conversation, {activitiesLimit: 1}))
156
- .then((ci) => {
157
- assert.property(c, 'defaultActivityEncryptionKeyUrl');
158
- /* eslint-disable no-unused-expressions */
159
- expect(ci.activities.items[0].object.inputs).to.not.be.null;
160
- });
161
- }));
186
+ it('creates a cardAction Activity', () =>
187
+ webex.internal.conversation
188
+ .post(conversation, {displayName: 'First Message', cards: ['test']})
189
+ .then(() => checkov.webex.internal.conversation.get(conversation, {activitiesLimit: 1}))
190
+ .then((c) => {
191
+ assert.property(c, 'defaultActivityEncryptionKeyUrl');
192
+ assert.equal(c.activities.items[0].object.displayName, 'First Message');
193
+ webex.internal.conversation
194
+ .cardAction(
195
+ conversation,
196
+ {
197
+ objectType: 'submit',
198
+ inputs: {key: 'value'},
199
+ },
200
+ c.activities.items[0]
201
+ )
202
+ .then(() =>
203
+ checkov.webex.internal.conversation.get(conversation, {activitiesLimit: 1})
204
+ )
205
+ .then((ci) => {
206
+ assert.property(c, 'defaultActivityEncryptionKeyUrl');
207
+ /* eslint-disable no-unused-expressions */
208
+ expect(ci.activities.items[0].object.inputs).to.not.be.null;
209
+ });
210
+ }));
162
211
  });
163
212
 
164
213
  describe('#update()', () => {
165
- it('sets the conversation\'s title', () => webex.internal.conversation.update(conversation, {
166
- displayName: 'New Name!',
167
- objectType: 'conversation'
168
- })
169
- .then(() => checkov.webex.internal.conversation.get(conversation))
170
- .then((c) => {
171
- assert.property(c, 'defaultActivityEncryptionKeyUrl');
172
- assert.property(c, 'encryptionKeyUrl');
173
- assert.equal(c.displayName, 'New Name!');
174
- }));
214
+ it("sets the conversation's title", () =>
215
+ webex.internal.conversation
216
+ .update(conversation, {
217
+ displayName: 'New Name!',
218
+ objectType: 'conversation',
219
+ })
220
+ .then(() => checkov.webex.internal.conversation.get(conversation))
221
+ .then((c) => {
222
+ assert.property(c, 'defaultActivityEncryptionKeyUrl');
223
+ assert.property(c, 'encryptionKeyUrl');
224
+ assert.equal(c.displayName, 'New Name!');
225
+ }));
175
226
  });
176
227
 
177
228
  describe('#updateKey()', () => {
178
- it('sets the conversation\'s defaultActivityEncryptionKeyUrl', () => webex.internal.conversation.updateKey(conversation)
179
- .then(() => webex.internal.conversation.get(conversation))
180
- .then((c) => {
181
- assert.property(c, 'defaultActivityEncryptionKeyUrl');
182
- })
183
- .then(() => checkov.webex.internal.conversation.get(conversation))
184
- .then((c) => {
185
- assert.property(c, 'defaultActivityEncryptionKeyUrl');
186
- }));
187
-
188
- it('unsets the conversations\'s defaultActivityEncryptionKeyUrl', () => webex.internal.conversation.updateKey(conversation, {uri: null})
189
- .then(() => checkov.webex.internal.conversation.get(conversation))
190
- .then((c) => {
191
- assert.isUndefined(c.defaultActivityEncryptionKeyUrl);
192
- }));
193
-
194
- describe('when the KMS key has been unset', () => {
195
- it('rotates the key and sends the post', () => webex.internal.conversation.updateKey(conversation, {uri: null})
196
- .then(() => webex.internal.conversation.post(conversation, {displayName: 'Ahoy'}))
197
- .then(() => checkov.webex.internal.conversation.get(conversation, {activitiesLimit: 1}))
229
+ it("sets the conversation's defaultActivityEncryptionKeyUrl", () =>
230
+ webex.internal.conversation
231
+ .updateKey(conversation)
232
+ .then(() => webex.internal.conversation.get(conversation))
198
233
  .then((c) => {
199
234
  assert.property(c, 'defaultActivityEncryptionKeyUrl');
200
- assert.equal(c.activities.items[0].object.displayName, 'Ahoy');
235
+ })
236
+ .then(() => checkov.webex.internal.conversation.get(conversation))
237
+ .then((c) => {
238
+ assert.property(c, 'defaultActivityEncryptionKeyUrl');
239
+ }));
240
+
241
+ it("unsets the conversations's defaultActivityEncryptionKeyUrl", () =>
242
+ webex.internal.conversation
243
+ .updateKey(conversation, {uri: null})
244
+ .then(() => checkov.webex.internal.conversation.get(conversation))
245
+ .then((c) => {
246
+ assert.isUndefined(c.defaultActivityEncryptionKeyUrl);
201
247
  }));
248
+
249
+ describe('when the KMS key has been unset', () => {
250
+ it('rotates the key and sends the post', () =>
251
+ webex.internal.conversation
252
+ .updateKey(conversation, {uri: null})
253
+ .then(() => webex.internal.conversation.post(conversation, {displayName: 'Ahoy'}))
254
+ .then(() =>
255
+ checkov.webex.internal.conversation.get(conversation, {activitiesLimit: 1})
256
+ )
257
+ .then((c) => {
258
+ assert.property(c, 'defaultActivityEncryptionKeyUrl');
259
+ assert.equal(c.activities.items[0].object.displayName, 'Ahoy');
260
+ }));
202
261
  });
203
262
  });
204
263
  });
@@ -206,63 +265,68 @@ describe('plugin-conversation', () => {
206
265
  describe('when the conversation is a 1:1 conversation', () => {
207
266
  let conversation;
208
267
 
209
- beforeEach(() => webex.request({
210
- method: 'POST',
211
- service: 'conversation',
212
- resource: '/conversations',
213
- noTransform: true,
214
- body: {
215
- objectType: 'conversation',
216
- activities: {
217
- items: [
218
- {
219
- verb: 'create',
220
- actor: {
221
- id: spock.id,
222
- objectType: 'person'
223
- }
268
+ beforeEach(() =>
269
+ webex
270
+ .request({
271
+ method: 'POST',
272
+ service: 'conversation',
273
+ resource: '/conversations',
274
+ noTransform: true,
275
+ body: {
276
+ objectType: 'conversation',
277
+ activities: {
278
+ items: [
279
+ {
280
+ verb: 'create',
281
+ actor: {
282
+ id: spock.id,
283
+ objectType: 'person',
284
+ },
285
+ },
286
+ {
287
+ verb: 'add',
288
+ actor: {
289
+ id: spock.id,
290
+ objectType: 'person',
291
+ },
292
+ object: {
293
+ id: spock.id,
294
+ objectType: 'person',
295
+ },
296
+ },
297
+ {
298
+ verb: 'add',
299
+ actor: {
300
+ id: spock.id,
301
+ objectType: 'person',
302
+ },
303
+ object: {
304
+ id: mccoy.id,
305
+ objectType: 'person',
306
+ },
307
+ },
308
+ ],
224
309
  },
225
- {
226
- verb: 'add',
227
- actor: {
228
- id: spock.id,
229
- objectType: 'person'
230
- },
231
- object: {
232
- id: spock.id,
233
- objectType: 'person'
234
- }
235
- },
236
- {
237
- verb: 'add',
238
- actor: {
239
- id: spock.id,
240
- objectType: 'person'
241
- },
242
- object: {
243
- id: mccoy.id,
244
- objectType: 'person'
245
- }
246
- }
247
- ]
248
- },
249
- tags: ['ONE_ON_ONE']
250
- }
251
- })
252
- .then((res) => res.body)
253
- .then((c) => {
254
- conversation = c;
255
- assert.notProperty(conversation, 'defaultActivityEncryptionKeyUrl');
256
- assert.include(c.tags, 'ONE_ON_ONE');
257
- }));
310
+ tags: ['ONE_ON_ONE'],
311
+ },
312
+ })
313
+ .then((res) => res.body)
314
+ .then((c) => {
315
+ conversation = c;
316
+ assert.notProperty(conversation, 'defaultActivityEncryptionKeyUrl');
317
+ assert.include(c.tags, 'ONE_ON_ONE');
318
+ })
319
+ );
258
320
 
259
321
  describe('#post()', () => {
260
- it('posts a message', () => webex.internal.conversation.post(conversation, {displayName: 'First Message'})
261
- .then(() => mccoy.webex.internal.conversation.get(conversation, {activitiesLimit: 1}))
262
- .then((c) => {
263
- assert.property(c, 'defaultActivityEncryptionKeyUrl');
264
- assert.equal(c.activities.items[0].object.displayName, 'First Message');
265
- }));
322
+ it('posts a message', () =>
323
+ webex.internal.conversation
324
+ .post(conversation, {displayName: 'First Message'})
325
+ .then(() => mccoy.webex.internal.conversation.get(conversation, {activitiesLimit: 1}))
326
+ .then((c) => {
327
+ assert.property(c, 'defaultActivityEncryptionKeyUrl');
328
+ assert.equal(c.activities.items[0].object.displayName, 'First Message');
329
+ }));
266
330
  });
267
331
  });
268
332
  });