@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.
Files changed (48) hide show
  1. package/.eslintrc.js +6 -6
  2. package/README.md +47 -47
  3. package/babel.config.js +3 -3
  4. package/dist/activities.js +4 -4
  5. package/dist/activities.js.map +1 -1
  6. package/dist/activity-thread-ordering.js +34 -34
  7. package/dist/activity-thread-ordering.js.map +1 -1
  8. package/dist/config.js +12 -12
  9. package/dist/config.js.map +1 -1
  10. package/dist/constants.js.map +1 -1
  11. package/dist/conversation.js +474 -474
  12. package/dist/conversation.js.map +1 -1
  13. package/dist/convo-error.js +4 -4
  14. package/dist/convo-error.js.map +1 -1
  15. package/dist/decryption-transforms.js +155 -155
  16. package/dist/decryption-transforms.js.map +1 -1
  17. package/dist/encryption-transforms.js.map +1 -1
  18. package/dist/index.js +2 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/share-activity.js +57 -57
  21. package/dist/share-activity.js.map +1 -1
  22. package/dist/to-array.js +7 -7
  23. package/dist/to-array.js.map +1 -1
  24. package/jest.config.js +3 -3
  25. package/package.json +21 -20
  26. package/process +1 -1
  27. package/src/activities.js +157 -157
  28. package/src/activity-thread-ordering.js +283 -283
  29. package/src/activity-threading.md +282 -282
  30. package/src/config.js +37 -37
  31. package/src/constants.js +3 -3
  32. package/src/conversation.js +2535 -2535
  33. package/src/convo-error.js +15 -15
  34. package/src/decryption-transforms.js +541 -541
  35. package/src/encryption-transforms.js +345 -345
  36. package/src/index.js +327 -327
  37. package/src/share-activity.js +436 -436
  38. package/src/to-array.js +29 -29
  39. package/test/integration/spec/create.js +290 -290
  40. package/test/integration/spec/encryption.js +333 -333
  41. package/test/integration/spec/get.js +1255 -1255
  42. package/test/integration/spec/mercury.js +94 -94
  43. package/test/integration/spec/share.js +537 -537
  44. package/test/integration/spec/verbs.js +1041 -1041
  45. package/test/unit/spec/conversation.js +823 -823
  46. package/test/unit/spec/decrypt-transforms.js +460 -460
  47. package/test/unit/spec/encryption-transforms.js +93 -93
  48. package/test/unit/spec/share-activity.js +178 -178
@@ -1,93 +1,93 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import sinon from 'sinon';
6
- import {assert} from '@webex/test-helper-chai';
7
-
8
- import {transforms} from '@webex/internal-plugin-conversation/src/encryption-transforms';
9
-
10
- describe('plugin-conversation', () => {
11
- describe('encryption transforms', () => {
12
- describe('encryptActivity()', () => {
13
- it('does not call transfom when created is True', () => {
14
- const transform = transforms.find((t) => t.name === 'encryptActivity');
15
-
16
- const ctx = {
17
- transform,
18
- };
19
- const key = null;
20
- const activity = {
21
- object: {
22
- created: 'True',
23
- },
24
- objectType: 'activity',
25
- verb: 'update',
26
- };
27
-
28
- // should just resolve immediately and return nothing
29
- transform
30
- .fn(ctx, key, activity)
31
- .then((result) => {
32
- assert.equal(undefined, result, 'should just return nothing');
33
- })
34
- .catch(() => {
35
- assert.equal(false, true, 'something unexpected happened');
36
- });
37
- });
38
-
39
- it('does transfom when created is not True', async () => {
40
- const transform = transforms.find((t) => t.name === 'encryptActivity');
41
- const transformStub = sinon.stub().resolves();
42
-
43
- const ctx = {
44
- transform: transformStub,
45
- };
46
- const key = null;
47
- const activity = {
48
- object: {
49
- created: 'false',
50
- },
51
- objectType: 'activity',
52
- verb: 'update',
53
- };
54
-
55
- // should go through the promise chain and last thing called is prepareActivityKmsMessage
56
- await transform.fn(ctx, key, activity);
57
- assert.equal(transformStub.lastCall.args[0], 'prepareActivityKmsMessage', key, activity);
58
- });
59
-
60
- it('does not have key and has verb delete', async () => {
61
- const transform = transforms.find((t) => t.name === 'prepareActivityKmsMessage');
62
-
63
- const ctx = {
64
- transform,
65
- };
66
- const key = null;
67
- const activity = {
68
- object: {
69
- created: 'false',
70
- },
71
- target: {
72
- defaultActivityEncryptionKeyUrl: 'fakeEncryptionKey',
73
- kmsResourceObjectUrl: 'meetingContainerKRO',
74
- },
75
- objectType: 'activity',
76
- verb: 'delete',
77
- kmsMessage: {
78
- uri: '<KRO>/authorizations?authId=123',
79
- method: 'delete',
80
- },
81
- };
82
-
83
- transform.fn(ctx, key, activity);
84
-
85
- assert.equal(
86
- activity.kmsMessage.uri,
87
- 'meetingContainerKRO/authorizations?authId=123',
88
- 'did not properly transform KRO for delete meeting container activity'
89
- );
90
- });
91
- });
92
- });
93
- });
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import sinon from 'sinon';
6
+ import {assert} from '@webex/test-helper-chai';
7
+
8
+ import {transforms} from '@webex/internal-plugin-conversation/src/encryption-transforms';
9
+
10
+ describe('plugin-conversation', () => {
11
+ describe('encryption transforms', () => {
12
+ describe('encryptActivity()', () => {
13
+ it('does not call transfom when created is True', () => {
14
+ const transform = transforms.find((t) => t.name === 'encryptActivity');
15
+
16
+ const ctx = {
17
+ transform,
18
+ };
19
+ const key = null;
20
+ const activity = {
21
+ object: {
22
+ created: 'True',
23
+ },
24
+ objectType: 'activity',
25
+ verb: 'update',
26
+ };
27
+
28
+ // should just resolve immediately and return nothing
29
+ transform
30
+ .fn(ctx, key, activity)
31
+ .then((result) => {
32
+ assert.equal(undefined, result, 'should just return nothing');
33
+ })
34
+ .catch(() => {
35
+ assert.equal(false, true, 'something unexpected happened');
36
+ });
37
+ });
38
+
39
+ it('does transfom when created is not True', async () => {
40
+ const transform = transforms.find((t) => t.name === 'encryptActivity');
41
+ const transformStub = sinon.stub().resolves();
42
+
43
+ const ctx = {
44
+ transform: transformStub,
45
+ };
46
+ const key = null;
47
+ const activity = {
48
+ object: {
49
+ created: 'false',
50
+ },
51
+ objectType: 'activity',
52
+ verb: 'update',
53
+ };
54
+
55
+ // should go through the promise chain and last thing called is prepareActivityKmsMessage
56
+ await transform.fn(ctx, key, activity);
57
+ assert.equal(transformStub.lastCall.args[0], 'prepareActivityKmsMessage', key, activity);
58
+ });
59
+
60
+ it('does not have key and has verb delete', async () => {
61
+ const transform = transforms.find((t) => t.name === 'prepareActivityKmsMessage');
62
+
63
+ const ctx = {
64
+ transform,
65
+ };
66
+ const key = null;
67
+ const activity = {
68
+ object: {
69
+ created: 'false',
70
+ },
71
+ target: {
72
+ defaultActivityEncryptionKeyUrl: 'fakeEncryptionKey',
73
+ kmsResourceObjectUrl: 'meetingContainerKRO',
74
+ },
75
+ objectType: 'activity',
76
+ verb: 'delete',
77
+ kmsMessage: {
78
+ uri: '<KRO>/authorizations?authId=123',
79
+ method: 'delete',
80
+ },
81
+ };
82
+
83
+ transform.fn(ctx, key, activity);
84
+
85
+ assert.equal(
86
+ activity.kmsMessage.uri,
87
+ 'meetingContainerKRO/authorizations?authId=123',
88
+ 'did not properly transform KRO for delete meeting container activity'
89
+ );
90
+ });
91
+ });
92
+ });
93
+ });
@@ -1,178 +1,178 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import {assert} from '@webex/test-helper-chai';
6
- import {ShareActivity} from '@webex/internal-plugin-conversation';
7
- import sinon from 'sinon';
8
- import MockWebex from '@webex/test-helper-mock-webex';
9
- import sha256 from 'crypto-js/sha256';
10
-
11
- describe('plugin-conversation', () => {
12
- describe('ShareActivity', () => {
13
- let shareActivity;
14
-
15
- beforeEach(() => {
16
- shareActivity = new ShareActivity();
17
- });
18
-
19
- describe('#_determineContentCategory', () => {
20
- it('returns "documents" when not all files have a mimeType', () => {
21
- const items = [{mimeType: 'image/png'}, {}];
22
-
23
- assert.equal(shareActivity._determineContentCategory(items), 'documents');
24
- });
25
-
26
- it('returns "documents" for non-homogenous mimeTypes', () => {
27
- const items = [{mimeType: 'image/png'}, {mimeType: 'video/h264'}];
28
-
29
- assert.equal(shareActivity._determineContentCategory(items), 'documents');
30
- });
31
-
32
- it('returns "documents" if the potentially homogenous mimeType is not image or video', () => {
33
- const items = [{mimeType: 'application/xml'}, {mimeType: 'application/xml'}];
34
-
35
- assert.equal(shareActivity._determineContentCategory(items), 'documents');
36
- });
37
-
38
- it('returns "image" if all mimeTypes are image', () => {
39
- const items = [{mimeType: 'image/png'}, {mimeType: 'image/jpg'}];
40
-
41
- assert.equal(shareActivity._determineContentCategory(items), 'images');
42
- });
43
-
44
- it('returns "video" if all mimeTypes are video', () => {
45
- const items = [{mimeType: 'video/h264'}, {mimeType: 'video/vp8'}];
46
-
47
- assert.equal(shareActivity._determineContentCategory(items), 'videos');
48
- });
49
-
50
- it('returns "documents" if a whiteboard mimeType is found in item.actions', () => {
51
- const items = [
52
- {
53
- mimeType: 'image/png',
54
- actions: [
55
- {
56
- mimeType: 'application/x-cisco-webex-whiteboard',
57
- type: 'edit',
58
- url: 'https://boards.example.com/boards/1',
59
- },
60
- ],
61
- },
62
- ];
63
-
64
- assert.equal(shareActivity._determineContentCategory(items), 'documents');
65
- });
66
- });
67
- describe('#upload', () => {
68
- let shareActivityUpload;
69
- let webex;
70
- const fakeURL =
71
- 'https://encryption-a.wbx2.com/encryption/api/v1/keys/8a7d3d78-ce75-48aa-a943-2e8acf63fbc9';
72
-
73
- beforeEach(() => {
74
- webex = new MockWebex({
75
- upload: sinon.stub().returns(Promise.resolve({body: {downloadUrl: fakeURL}})),
76
- });
77
-
78
- shareActivityUpload = new ShareActivity(
79
- {},
80
- {
81
- parent: webex,
82
- }
83
- );
84
- });
85
-
86
- it('checks whether filehash is sent in body while making a call to /finish API', () => {
87
- const spy = sinon.spy(webex.upload);
88
- const fileSize = 3333;
89
- const fileHash = sha256(fakeURL).toString();
90
-
91
- const inputData = {
92
- phases: {
93
- initialize: {
94
- fileSize,
95
- },
96
- finalize: {
97
- body: {
98
- fileSize,
99
- fileHash,
100
- },
101
- },
102
- },
103
- };
104
-
105
- spy(inputData);
106
-
107
- assert.isTrue(spy.calledWith(inputData));
108
- });
109
-
110
- it('checks whether property role:spaceAvatar is sent in body while making a call to /finish API', () => {
111
- const fileSize = 100;
112
- const mockFile = {size: fileSize};
113
- const uploadOptions = {role: 'spaceAvatar'};
114
-
115
- shareActivityUpload._upload(mockFile, fakeURL, uploadOptions);
116
-
117
- const expectedResult = {fileSize, role: 'spaceAvatar'};
118
- const actualResult = webex.upload.getCall(0).args[0].phases.initialize.body;
119
-
120
- assert.match(actualResult, expectedResult);
121
- });
122
-
123
- it('checks whether property claimedFileType is sent with file extension in body while making a call to /finish API', () => {
124
- const fileSize = 100;
125
- const mockFile = {size: fileSize};
126
-
127
- const uploadOptions = {claimedFileType: '.zip'};
128
-
129
- shareActivityUpload._upload(mockFile, fakeURL, uploadOptions);
130
-
131
- const expectedResult = {fileSize, claimedFileType: '.zip'};
132
- const actualResult = webex.upload.getCall(0).args[0].phases.initialize.body;
133
-
134
- assert.match(actualResult, expectedResult);
135
- });
136
- });
137
-
138
- describe('#addGif', () => {
139
- const fakeHappyGif = {
140
- name: 'happy gif.gif',
141
- url: '/path/gif.gif',
142
- height: 200,
143
- width: 270,
144
- image: {height: 200, width: 270, url: '/path/thumbnailgif.gif'},
145
- };
146
- const fakeSadGif = {
147
- name: 'sad-gif.gif',
148
- url: '/path/gif.gif',
149
- height: 200,
150
- width: 270,
151
- image: {height: 200, width: 270, url: '/path/thumbnailgif.gif'},
152
- };
153
-
154
- it('adds gif to empty this.uploads', () => {
155
- shareActivity.addGif(fakeHappyGif); // attempt to add the gif to empty this.uploads
156
-
157
- // check that the gif was added via addGif
158
- assert.isTrue(shareActivity.uploads.size === 1);
159
- });
160
-
161
- it('if the giphy already exists, then do not add to this.uploads', () => {
162
- shareActivity.uploads.set(fakeHappyGif, {}); // add fake gif preemptively, mocking that we already added a gif
163
- shareActivity.addGif(fakeHappyGif); // attempt to add the same gif again
164
-
165
- // check that the gif was not added via addGif
166
- assert.isTrue(shareActivity.uploads.size === 1);
167
- });
168
-
169
- it('if the giphy does not exist, then add it to this.uploads', () => {
170
- shareActivity.uploads.set(fakeHappyGif, {}); // add fake gif preemptively, mocking that we already added a gif
171
- shareActivity.addGif(fakeSadGif); // attempt to add a different gif
172
-
173
- // check that the gif was added via addGif
174
- assert.isTrue(shareActivity.uploads.size === 2);
175
- });
176
- });
177
- });
178
- });
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import {assert} from '@webex/test-helper-chai';
6
+ import {ShareActivity} from '@webex/internal-plugin-conversation';
7
+ import sinon from 'sinon';
8
+ import MockWebex from '@webex/test-helper-mock-webex';
9
+ import sha256 from 'crypto-js/sha256';
10
+
11
+ describe('plugin-conversation', () => {
12
+ describe('ShareActivity', () => {
13
+ let shareActivity;
14
+
15
+ beforeEach(() => {
16
+ shareActivity = new ShareActivity();
17
+ });
18
+
19
+ describe('#_determineContentCategory', () => {
20
+ it('returns "documents" when not all files have a mimeType', () => {
21
+ const items = [{mimeType: 'image/png'}, {}];
22
+
23
+ assert.equal(shareActivity._determineContentCategory(items), 'documents');
24
+ });
25
+
26
+ it('returns "documents" for non-homogenous mimeTypes', () => {
27
+ const items = [{mimeType: 'image/png'}, {mimeType: 'video/h264'}];
28
+
29
+ assert.equal(shareActivity._determineContentCategory(items), 'documents');
30
+ });
31
+
32
+ it('returns "documents" if the potentially homogenous mimeType is not image or video', () => {
33
+ const items = [{mimeType: 'application/xml'}, {mimeType: 'application/xml'}];
34
+
35
+ assert.equal(shareActivity._determineContentCategory(items), 'documents');
36
+ });
37
+
38
+ it('returns "image" if all mimeTypes are image', () => {
39
+ const items = [{mimeType: 'image/png'}, {mimeType: 'image/jpg'}];
40
+
41
+ assert.equal(shareActivity._determineContentCategory(items), 'images');
42
+ });
43
+
44
+ it('returns "video" if all mimeTypes are video', () => {
45
+ const items = [{mimeType: 'video/h264'}, {mimeType: 'video/vp8'}];
46
+
47
+ assert.equal(shareActivity._determineContentCategory(items), 'videos');
48
+ });
49
+
50
+ it('returns "documents" if a whiteboard mimeType is found in item.actions', () => {
51
+ const items = [
52
+ {
53
+ mimeType: 'image/png',
54
+ actions: [
55
+ {
56
+ mimeType: 'application/x-cisco-webex-whiteboard',
57
+ type: 'edit',
58
+ url: 'https://boards.example.com/boards/1',
59
+ },
60
+ ],
61
+ },
62
+ ];
63
+
64
+ assert.equal(shareActivity._determineContentCategory(items), 'documents');
65
+ });
66
+ });
67
+ describe('#upload', () => {
68
+ let shareActivityUpload;
69
+ let webex;
70
+ const fakeURL =
71
+ 'https://encryption-a.wbx2.com/encryption/api/v1/keys/8a7d3d78-ce75-48aa-a943-2e8acf63fbc9';
72
+
73
+ beforeEach(() => {
74
+ webex = new MockWebex({
75
+ upload: sinon.stub().returns(Promise.resolve({body: {downloadUrl: fakeURL}})),
76
+ });
77
+
78
+ shareActivityUpload = new ShareActivity(
79
+ {},
80
+ {
81
+ parent: webex,
82
+ }
83
+ );
84
+ });
85
+
86
+ it('checks whether filehash is sent in body while making a call to /finish API', () => {
87
+ const spy = sinon.spy(webex.upload);
88
+ const fileSize = 3333;
89
+ const fileHash = sha256(fakeURL).toString();
90
+
91
+ const inputData = {
92
+ phases: {
93
+ initialize: {
94
+ fileSize,
95
+ },
96
+ finalize: {
97
+ body: {
98
+ fileSize,
99
+ fileHash,
100
+ },
101
+ },
102
+ },
103
+ };
104
+
105
+ spy(inputData);
106
+
107
+ assert.isTrue(spy.calledWith(inputData));
108
+ });
109
+
110
+ it('checks whether property role:spaceAvatar is sent in body while making a call to /finish API', () => {
111
+ const fileSize = 100;
112
+ const mockFile = {size: fileSize};
113
+ const uploadOptions = {role: 'spaceAvatar'};
114
+
115
+ shareActivityUpload._upload(mockFile, fakeURL, uploadOptions);
116
+
117
+ const expectedResult = {fileSize, role: 'spaceAvatar'};
118
+ const actualResult = webex.upload.getCall(0).args[0].phases.initialize.body;
119
+
120
+ assert.match(actualResult, expectedResult);
121
+ });
122
+
123
+ it('checks whether property claimedFileType is sent with file extension in body while making a call to /finish API', () => {
124
+ const fileSize = 100;
125
+ const mockFile = {size: fileSize};
126
+
127
+ const uploadOptions = {claimedFileType: '.zip'};
128
+
129
+ shareActivityUpload._upload(mockFile, fakeURL, uploadOptions);
130
+
131
+ const expectedResult = {fileSize, claimedFileType: '.zip'};
132
+ const actualResult = webex.upload.getCall(0).args[0].phases.initialize.body;
133
+
134
+ assert.match(actualResult, expectedResult);
135
+ });
136
+ });
137
+
138
+ describe('#addGif', () => {
139
+ const fakeHappyGif = {
140
+ name: 'happy gif.gif',
141
+ url: '/path/gif.gif',
142
+ height: 200,
143
+ width: 270,
144
+ image: {height: 200, width: 270, url: '/path/thumbnailgif.gif'},
145
+ };
146
+ const fakeSadGif = {
147
+ name: 'sad-gif.gif',
148
+ url: '/path/gif.gif',
149
+ height: 200,
150
+ width: 270,
151
+ image: {height: 200, width: 270, url: '/path/thumbnailgif.gif'},
152
+ };
153
+
154
+ it('adds gif to empty this.uploads', () => {
155
+ shareActivity.addGif(fakeHappyGif); // attempt to add the gif to empty this.uploads
156
+
157
+ // check that the gif was added via addGif
158
+ assert.isTrue(shareActivity.uploads.size === 1);
159
+ });
160
+
161
+ it('if the giphy already exists, then do not add to this.uploads', () => {
162
+ shareActivity.uploads.set(fakeHappyGif, {}); // add fake gif preemptively, mocking that we already added a gif
163
+ shareActivity.addGif(fakeHappyGif); // attempt to add the same gif again
164
+
165
+ // check that the gif was not added via addGif
166
+ assert.isTrue(shareActivity.uploads.size === 1);
167
+ });
168
+
169
+ it('if the giphy does not exist, then add it to this.uploads', () => {
170
+ shareActivity.uploads.set(fakeHappyGif, {}); // add fake gif preemptively, mocking that we already added a gif
171
+ shareActivity.addGif(fakeSadGif); // attempt to add a different gif
172
+
173
+ // check that the gif was added via addGif
174
+ assert.isTrue(shareActivity.uploads.size === 2);
175
+ });
176
+ });
177
+ });
178
+ });