@webex/internal-plugin-board 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.
- package/README.md +1 -3
- package/dist/board.js +28 -108
- package/dist/board.js.map +1 -1
- package/dist/config.js +0 -8
- package/dist/config.js.map +1 -1
- package/dist/index.js +7 -28
- package/dist/index.js.map +1 -1
- package/dist/realtime-channel-collection.js +2 -8
- package/dist/realtime-channel-collection.js.map +1 -1
- package/dist/realtime-channel.js +1 -5
- package/dist/realtime-channel.js.map +1 -1
- package/dist/realtime.js +38 -82
- package/dist/realtime.js.map +1 -1
- package/dist/types/board.d.ts +2 -0
- package/dist/types/config.d.ts +11 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/realtime-channel-collection.d.ts +2 -0
- package/dist/types/realtime-channel.d.ts +2 -0
- package/dist/types/realtime.d.ts +7 -0
- package/package.json +14 -14
- package/src/board.js +257 -205
- package/src/config.js +2 -2
- package/src/index.js +19 -21
- package/src/realtime-channel-collection.js +2 -2
- package/src/realtime-channel.js +8 -9
- package/src/realtime.js +109 -93
- package/test/integration/spec/board.js +347 -221
- package/test/integration/spec/realtime.js +82 -56
- package/test/integration/spec/sharing-mercury.js +154 -73
- package/test/unit/spec/board.js +301 -215
- package/test/unit/spec/encryption.js +152 -120
- package/test/unit/spec/realtime.js +131 -89
|
@@ -11,29 +11,33 @@ describe('plugin-board', () => {
|
|
|
11
11
|
let webex;
|
|
12
12
|
const encryptedData = 'encryptedData';
|
|
13
13
|
const decryptedText = 'decryptedText';
|
|
14
|
-
const fakeURL = `${
|
|
14
|
+
const fakeURL = `${
|
|
15
|
+
process.env.ENCRYPTION_SERVICE_URL || 'https://encryption-a.wbx2.com'
|
|
16
|
+
}/encryption/api/v1/keys/8a7d3d78-ce75-48aa-a943-2e8acf63fbc9`;
|
|
15
17
|
|
|
16
18
|
before(() => {
|
|
17
19
|
webex = new MockWebex({
|
|
18
20
|
children: {
|
|
19
|
-
board: Board
|
|
20
|
-
}
|
|
21
|
+
board: Board,
|
|
22
|
+
},
|
|
21
23
|
});
|
|
22
24
|
|
|
23
25
|
Object.assign(webex.internal, {
|
|
24
26
|
device: {
|
|
25
|
-
deviceType: 'FAKE_DEVICE'
|
|
27
|
+
deviceType: 'FAKE_DEVICE',
|
|
26
28
|
},
|
|
27
29
|
encryption: {
|
|
28
30
|
decryptText: sinon.stub().returns(Promise.resolve(decryptedText)),
|
|
29
31
|
encryptText: sinon.stub().returns(Promise.resolve(encryptedData)),
|
|
30
|
-
encryptBinary: sinon.stub().returns(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
encryptBinary: sinon.stub().returns(
|
|
33
|
+
Promise.resolve({
|
|
34
|
+
scr: {},
|
|
35
|
+
cdata: encryptedData,
|
|
36
|
+
})
|
|
37
|
+
),
|
|
34
38
|
decryptScr: sinon.stub().returns(Promise.resolve('decryptedFoo')),
|
|
35
|
-
encryptScr: sinon.stub().returns(Promise.resolve('encryptedFoo'))
|
|
36
|
-
}
|
|
39
|
+
encryptScr: sinon.stub().returns(Promise.resolve('encryptedFoo')),
|
|
40
|
+
},
|
|
37
41
|
});
|
|
38
42
|
|
|
39
43
|
webex.config.board = boardConfig.board;
|
|
@@ -42,7 +46,9 @@ describe('plugin-board', () => {
|
|
|
42
46
|
describe('encryption', () => {
|
|
43
47
|
describe('#decryptContents', () => {
|
|
44
48
|
before(() => {
|
|
45
|
-
sinon
|
|
49
|
+
sinon
|
|
50
|
+
.stub(webex.internal.board, 'decryptSingleContent')
|
|
51
|
+
.callsFake(sinon.stub().returns(Promise.resolve({})));
|
|
46
52
|
sinon.spy(webex.internal.board, 'decryptSingleFileContent');
|
|
47
53
|
});
|
|
48
54
|
|
|
@@ -60,123 +66,142 @@ describe('plugin-board', () => {
|
|
|
60
66
|
|
|
61
67
|
it('calls decryptSingleContent when type is not image', () => {
|
|
62
68
|
const curveContents = {
|
|
63
|
-
items: [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
items: [
|
|
70
|
+
{
|
|
71
|
+
type: 'STRING',
|
|
72
|
+
payload: encryptedData,
|
|
73
|
+
encryptionKeyUrl: fakeURL,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
68
76
|
};
|
|
69
77
|
|
|
70
|
-
return webex.internal.board.decryptContents(curveContents)
|
|
71
|
-
.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
78
|
+
return webex.internal.board.decryptContents(curveContents).then(() => {
|
|
79
|
+
assert.calledWith(webex.internal.board.decryptSingleContent, fakeURL, encryptedData);
|
|
80
|
+
assert.notCalled(webex.internal.encryption.decryptScr);
|
|
81
|
+
assert.notCalled(webex.internal.encryption.decryptText);
|
|
82
|
+
});
|
|
76
83
|
});
|
|
77
84
|
|
|
78
85
|
it('calls decryptSingleFileContent when type is FILE', () => {
|
|
79
86
|
const imageContents = {
|
|
80
|
-
items: [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
items: [
|
|
88
|
+
{
|
|
89
|
+
type: 'FILE',
|
|
90
|
+
payload: JSON.stringify({
|
|
91
|
+
type: 'image',
|
|
92
|
+
displayName: 'encryptedDisplayName',
|
|
93
|
+
}),
|
|
94
|
+
file: {
|
|
95
|
+
scr: 'encryptedScr',
|
|
96
|
+
},
|
|
97
|
+
encryptionKeyUrl: fakeURL,
|
|
88
98
|
},
|
|
89
|
-
|
|
90
|
-
}]
|
|
99
|
+
],
|
|
91
100
|
};
|
|
92
101
|
|
|
93
|
-
return webex.internal.board.decryptContents(imageContents)
|
|
94
|
-
.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
return webex.internal.board.decryptContents(imageContents).then(() => {
|
|
103
|
+
assert.calledOnce(webex.internal.board.decryptSingleFileContent);
|
|
104
|
+
assert.calledWith(
|
|
105
|
+
webex.internal.encryption.decryptText,
|
|
106
|
+
fakeURL,
|
|
107
|
+
JSON.stringify({type: 'image', displayName: 'encryptedDisplayName'})
|
|
108
|
+
);
|
|
109
|
+
assert.calledWith(webex.internal.encryption.decryptScr, fakeURL, 'encryptedScr');
|
|
110
|
+
});
|
|
99
111
|
});
|
|
100
112
|
|
|
101
113
|
it('does not require payload when type is FILE', () => {
|
|
102
114
|
const imageContents = {
|
|
103
|
-
items: [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
115
|
+
items: [
|
|
116
|
+
{
|
|
117
|
+
type: 'FILE',
|
|
118
|
+
file: {
|
|
119
|
+
scr: 'encryptedScr',
|
|
120
|
+
},
|
|
121
|
+
encryptionKeyUrl: fakeURL,
|
|
107
122
|
},
|
|
108
|
-
|
|
109
|
-
}]
|
|
123
|
+
],
|
|
110
124
|
};
|
|
111
125
|
|
|
112
|
-
return webex.internal.board.decryptContents(imageContents)
|
|
113
|
-
.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
126
|
+
return webex.internal.board.decryptContents(imageContents).then(() => {
|
|
127
|
+
assert.calledOnce(webex.internal.board.decryptSingleFileContent);
|
|
128
|
+
assert.notCalled(webex.internal.encryption.decryptText);
|
|
129
|
+
assert.calledWith(webex.internal.encryption.decryptScr, fakeURL, 'encryptedScr');
|
|
130
|
+
});
|
|
118
131
|
});
|
|
119
132
|
|
|
120
133
|
it('decrypts FILE metadata displayName', () => {
|
|
121
134
|
const imageContentsWithMetadata = {
|
|
122
|
-
items: [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
135
|
+
items: [
|
|
136
|
+
{
|
|
137
|
+
type: 'FILE',
|
|
138
|
+
payload: JSON.stringify({
|
|
139
|
+
type: 'image',
|
|
140
|
+
displayName: 'encryptedDisplayName',
|
|
141
|
+
}),
|
|
142
|
+
file: {
|
|
143
|
+
scr: 'encryptedScr',
|
|
144
|
+
},
|
|
145
|
+
encryptionKeyUrl: fakeURL,
|
|
130
146
|
},
|
|
131
|
-
|
|
132
|
-
}]
|
|
147
|
+
],
|
|
133
148
|
};
|
|
134
149
|
|
|
135
|
-
webex.internal.encryption.decryptText
|
|
150
|
+
webex.internal.encryption.decryptText
|
|
151
|
+
.onFirstCall()
|
|
152
|
+
.returns(JSON.stringify({displayName: 'decryptedDisplayName'}));
|
|
136
153
|
|
|
137
|
-
return webex.internal.board.decryptContents(imageContentsWithMetadata)
|
|
138
|
-
.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
154
|
+
return webex.internal.board.decryptContents(imageContentsWithMetadata).then((contents) => {
|
|
155
|
+
assert.calledOnce(webex.internal.board.decryptSingleFileContent);
|
|
156
|
+
assert.calledWith(webex.internal.encryption.decryptScr, fakeURL, 'encryptedScr');
|
|
157
|
+
assert.calledWith(
|
|
158
|
+
webex.internal.encryption.decryptText,
|
|
159
|
+
fakeURL,
|
|
160
|
+
JSON.stringify({type: 'image', displayName: 'encryptedDisplayName'})
|
|
161
|
+
);
|
|
162
|
+
assert.equal(contents[0].metadata.displayName, 'decryptedDisplayName');
|
|
163
|
+
});
|
|
144
164
|
});
|
|
145
165
|
|
|
146
166
|
it('assigns FILE payload metadata to decrypted file', () => {
|
|
147
167
|
const imageContentsWithMetadata = {
|
|
148
|
-
items: [
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
168
|
+
items: [
|
|
169
|
+
{
|
|
170
|
+
type: 'FILE',
|
|
171
|
+
payload: JSON.stringify({
|
|
172
|
+
type: 'image',
|
|
173
|
+
size: 123,
|
|
174
|
+
}),
|
|
175
|
+
file: {
|
|
176
|
+
scr: 'encryptedScr',
|
|
177
|
+
},
|
|
178
|
+
encryptionKeyUrl: fakeURL,
|
|
156
179
|
},
|
|
157
|
-
|
|
158
|
-
}]
|
|
180
|
+
],
|
|
159
181
|
};
|
|
160
182
|
|
|
161
|
-
webex.internal.encryption.decryptText
|
|
183
|
+
webex.internal.encryption.decryptText
|
|
184
|
+
.onFirstCall()
|
|
185
|
+
.returns(JSON.stringify({type: 'image', size: 123}));
|
|
162
186
|
|
|
163
|
-
return webex.internal.board.decryptContents(imageContentsWithMetadata)
|
|
164
|
-
.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
size: 123
|
|
169
|
-
});
|
|
187
|
+
return webex.internal.board.decryptContents(imageContentsWithMetadata).then((contents) => {
|
|
188
|
+
assert.calledOnce(webex.internal.board.decryptSingleFileContent);
|
|
189
|
+
assert.deepEqual(contents[0].metadata, {
|
|
190
|
+
type: 'image',
|
|
191
|
+
size: 123,
|
|
170
192
|
});
|
|
193
|
+
});
|
|
171
194
|
});
|
|
172
195
|
});
|
|
173
196
|
|
|
174
197
|
describe('#encryptContents', () => {
|
|
175
198
|
before(() => {
|
|
176
|
-
sinon.stub(webex.internal.board, 'encryptSingleContent').returns(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
199
|
+
sinon.stub(webex.internal.board, 'encryptSingleContent').returns(
|
|
200
|
+
Promise.resolve({
|
|
201
|
+
encryptedData,
|
|
202
|
+
encryptionKeyUrl: fakeURL,
|
|
203
|
+
})
|
|
204
|
+
);
|
|
180
205
|
});
|
|
181
206
|
|
|
182
207
|
afterEach(() => {
|
|
@@ -184,43 +209,50 @@ describe('plugin-board', () => {
|
|
|
184
209
|
});
|
|
185
210
|
|
|
186
211
|
it('calls encryptSingleContent when type is not image', () => {
|
|
187
|
-
const curveContents = [
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
212
|
+
const curveContents = [
|
|
213
|
+
{
|
|
214
|
+
type: 'curve',
|
|
215
|
+
},
|
|
216
|
+
];
|
|
217
|
+
|
|
218
|
+
return webex.internal.board.encryptContents(fakeURL, curveContents).then(() => {
|
|
219
|
+
assert.calledWith(webex.internal.board.encryptSingleContent, fakeURL, curveContents[0]);
|
|
220
|
+
assert.notCalled(webex.internal.encryption.encryptScr);
|
|
221
|
+
});
|
|
196
222
|
});
|
|
197
223
|
|
|
198
224
|
it('calls encryptText and encryptScr when scr is found in content', () => {
|
|
199
|
-
const imageContents = [
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
225
|
+
const imageContents = [
|
|
226
|
+
{
|
|
227
|
+
displayName: 'FileName',
|
|
228
|
+
file: {
|
|
229
|
+
scr: {
|
|
230
|
+
loc: fakeURL,
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
];
|
|
235
|
+
|
|
236
|
+
return webex.internal.board.encryptContents(fakeURL, imageContents).then(() => {
|
|
237
|
+
assert.calledWith(webex.internal.encryption.encryptScr, fakeURL, {loc: fakeURL});
|
|
238
|
+
assert.calledWith(
|
|
239
|
+
webex.internal.encryption.encryptText,
|
|
240
|
+
fakeURL,
|
|
241
|
+
JSON.stringify({displayName: 'FileName'})
|
|
242
|
+
);
|
|
243
|
+
});
|
|
213
244
|
});
|
|
214
245
|
|
|
215
246
|
it('sets the device to config deviceType', () => {
|
|
216
|
-
const curveContents = [
|
|
217
|
-
|
|
218
|
-
|
|
247
|
+
const curveContents = [
|
|
248
|
+
{
|
|
249
|
+
type: 'curve',
|
|
250
|
+
},
|
|
251
|
+
];
|
|
219
252
|
|
|
220
|
-
return webex.internal.board.encryptContents(fakeURL, curveContents)
|
|
221
|
-
.
|
|
222
|
-
|
|
223
|
-
});
|
|
253
|
+
return webex.internal.board.encryptContents(fakeURL, curveContents).then((res) => {
|
|
254
|
+
assert.equal(res[0].device, 'FAKE_DEVICE');
|
|
255
|
+
});
|
|
224
256
|
});
|
|
225
257
|
});
|
|
226
258
|
});
|