@webex/internal-plugin-device 2.60.0-next.8 → 2.60.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/dist/config.js +2 -1
- package/dist/config.js.map +1 -1
- package/dist/constants.js +16 -8
- package/dist/constants.js.map +1 -1
- package/dist/device.js +7 -13
- package/dist/device.js.map +1 -1
- package/dist/features/feature-collection.js +2 -1
- package/dist/features/feature-collection.js.map +1 -1
- package/dist/features/feature-model.js +11 -8
- package/dist/features/feature-model.js.map +1 -1
- package/dist/features/features-model.js +2 -1
- package/dist/features/features-model.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/interceptors/device-url.js +5 -6
- package/dist/interceptors/device-url.js.map +1 -1
- package/dist/metrics.js +2 -1
- package/dist/metrics.js.map +1 -1
- package/package.json +17 -18
- package/src/device.js +0 -7
- package/dist/ipNetworkDetector.js +0 -199
- package/dist/ipNetworkDetector.js.map +0 -1
- package/src/ipNetworkDetector.ts +0 -176
- package/test/unit/spec/ipNetworkDetector.js +0 -410
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
import {assert} from '@webex/test-helper-chai';
|
|
2
|
-
import sinon from 'sinon';
|
|
3
|
-
import IpNetworkDetector from '@webex/internal-plugin-device/src/ipNetworkDetector';
|
|
4
|
-
import MockWebex from '@webex/test-helper-mock-webex';
|
|
5
|
-
|
|
6
|
-
describe('plugin-device', () => {
|
|
7
|
-
describe('IpNetworkDetector', () => {
|
|
8
|
-
let webex;
|
|
9
|
-
let ipNetworkDetector;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
webex = new MockWebex({});
|
|
13
|
-
|
|
14
|
-
ipNetworkDetector = new IpNetworkDetector({}, {parent: webex});
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('is initialized correctly', () => {
|
|
18
|
-
assert.equal(ipNetworkDetector.supportsIpV4, undefined);
|
|
19
|
-
assert.equal(ipNetworkDetector.supportsIpV6, undefined);
|
|
20
|
-
assert.equal(ipNetworkDetector.firstIpV4, -1);
|
|
21
|
-
assert.equal(ipNetworkDetector.firstIpV6, -1);
|
|
22
|
-
assert.equal(ipNetworkDetector.firstMdns, -1);
|
|
23
|
-
assert.equal(ipNetworkDetector.totalTime, -1);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('detect', () => {
|
|
27
|
-
let previousRTCPeerConnection;
|
|
28
|
-
let clock;
|
|
29
|
-
let fakePeerConnection;
|
|
30
|
-
|
|
31
|
-
const FAKE_OFFER = {type: 'offer', sdp: 'some sdp'};
|
|
32
|
-
|
|
33
|
-
beforeEach(() => {
|
|
34
|
-
clock = sinon.useFakeTimers();
|
|
35
|
-
|
|
36
|
-
previousRTCPeerConnection = global.RTCPeerConnection;
|
|
37
|
-
|
|
38
|
-
fakePeerConnection = {
|
|
39
|
-
createDataChannel: sinon.stub(),
|
|
40
|
-
createOffer: sinon.stub().resolves(FAKE_OFFER),
|
|
41
|
-
setLocalDescription: sinon.stub().resolves(),
|
|
42
|
-
close: sinon.stub(),
|
|
43
|
-
iceGatheringState: 'new',
|
|
44
|
-
};
|
|
45
|
-
global.RTCPeerConnection = sinon.stub().returns(fakePeerConnection);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
afterEach(() => {
|
|
49
|
-
global.RTCPeerConnection = previousRTCPeerConnection;
|
|
50
|
-
clock.restore();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const simulateCandidate = (delay, address) => {
|
|
54
|
-
clock.tick(delay);
|
|
55
|
-
|
|
56
|
-
fakePeerConnection.onicecandidate({
|
|
57
|
-
candidate: {address},
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const simulateEndOfCandidateGathering = (delay, useGatheringStateChange = true) => {
|
|
62
|
-
clock.tick(delay);
|
|
63
|
-
|
|
64
|
-
// browsers have 2 ways of notifying about ICE candidate gathering being completed
|
|
65
|
-
// 1. through gathering state change
|
|
66
|
-
// 2. by sending a null candidate
|
|
67
|
-
if (useGatheringStateChange) {
|
|
68
|
-
fakePeerConnection.iceGatheringState = 'complete';
|
|
69
|
-
fakePeerConnection.onicegatheringstatechange();
|
|
70
|
-
} else {
|
|
71
|
-
fakePeerConnection.onicecandidate({
|
|
72
|
-
candidate: null,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const checkResults = (expectedResults) => {
|
|
78
|
-
assert.equal(ipNetworkDetector.supportsIpV4, expectedResults.supportsIpV4);
|
|
79
|
-
assert.equal(ipNetworkDetector.supportsIpV6, expectedResults.supportsIpV6);
|
|
80
|
-
assert.equal(ipNetworkDetector.firstIpV4, expectedResults.timings.ipv4);
|
|
81
|
-
assert.equal(ipNetworkDetector.firstIpV6, expectedResults.timings.ipv6);
|
|
82
|
-
assert.equal(ipNetworkDetector.firstMdns, expectedResults.timings.mdns);
|
|
83
|
-
assert.equal(ipNetworkDetector.totalTime, expectedResults.timings.totalTime);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
it('creates an RTCPeerConnection with a data channel and does ice candidate gathering', async () => {
|
|
87
|
-
const promise = ipNetworkDetector.detect();
|
|
88
|
-
|
|
89
|
-
simulateEndOfCandidateGathering();
|
|
90
|
-
|
|
91
|
-
await promise;
|
|
92
|
-
|
|
93
|
-
assert.calledOnceWithExactly(fakePeerConnection.createDataChannel, 'data');
|
|
94
|
-
assert.calledOnceWithExactly(fakePeerConnection.createOffer);
|
|
95
|
-
assert.calledOnceWithExactly(fakePeerConnection.setLocalDescription, FAKE_OFFER);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('works correctly when we get only ipv4 candidates', async () => {
|
|
99
|
-
const promise = ipNetworkDetector.detect();
|
|
100
|
-
|
|
101
|
-
simulateCandidate(70, '192.168.0.1');
|
|
102
|
-
simulateCandidate(30, '192.168.16.1');
|
|
103
|
-
simulateEndOfCandidateGathering(50);
|
|
104
|
-
|
|
105
|
-
await promise;
|
|
106
|
-
|
|
107
|
-
checkResults({
|
|
108
|
-
supportsIpV4: true,
|
|
109
|
-
supportsIpV6: false,
|
|
110
|
-
timings: {
|
|
111
|
-
totalTime: 150,
|
|
112
|
-
ipv4: 70, // this should match the first ipv4 candidate's delay
|
|
113
|
-
ipv6: -1,
|
|
114
|
-
mdns: -1,
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('works correctly when we get only ipv6 candidates (chrome, safari)', async () => {
|
|
120
|
-
const promise = ipNetworkDetector.detect();
|
|
121
|
-
|
|
122
|
-
// chrome and safari for some reason wrap the ipv6 addresses with []
|
|
123
|
-
simulateCandidate(150, '[2a02:c7c:a0d0:8a00:db9b:d4de:d1f7:4c49]');
|
|
124
|
-
simulateCandidate(50, '[2a02:c7c:a0d0:8a00:d089:7baf:ceef:b9d8]');
|
|
125
|
-
simulateEndOfCandidateGathering(100);
|
|
126
|
-
|
|
127
|
-
await promise;
|
|
128
|
-
|
|
129
|
-
checkResults({
|
|
130
|
-
supportsIpV4: false,
|
|
131
|
-
supportsIpV6: true,
|
|
132
|
-
timings: {
|
|
133
|
-
totalTime: 300,
|
|
134
|
-
ipv4: -1,
|
|
135
|
-
ipv6: 150, // this should match the first ipv6 candidate's delay
|
|
136
|
-
mdns: -1,
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('works correctly when we get only ipv6 candidates (Firefox)', async () => {
|
|
142
|
-
const promise = ipNetworkDetector.detect();
|
|
143
|
-
|
|
144
|
-
simulateCandidate(150, '2a02:c7c:a0d0:8a00:db9b:d4de:d1f7:4c49');
|
|
145
|
-
simulateCandidate(50, '2a02:c7c:a0d0:8a00:d089:7baf:ceef:b9d8');
|
|
146
|
-
simulateEndOfCandidateGathering(100);
|
|
147
|
-
|
|
148
|
-
await promise;
|
|
149
|
-
|
|
150
|
-
checkResults({
|
|
151
|
-
supportsIpV4: false,
|
|
152
|
-
supportsIpV6: true,
|
|
153
|
-
timings: {
|
|
154
|
-
totalTime: 300,
|
|
155
|
-
ipv4: -1,
|
|
156
|
-
ipv6: 150, // this should match the first ipv6 candidate's delay
|
|
157
|
-
mdns: -1,
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('works correctly when we get both ipv6 and ipv4 candidates', async () => {
|
|
163
|
-
const promise = ipNetworkDetector.detect();
|
|
164
|
-
|
|
165
|
-
simulateCandidate(50, '2a02:c7c:a0d0:8a00:db9b:d4de:d1f7:4c49');
|
|
166
|
-
simulateCandidate(50, '192.168.10.10');
|
|
167
|
-
|
|
168
|
-
// at this point, as we've got at least 1 IPv4 and IPv6 candidate the promise should already be resolved
|
|
169
|
-
await promise;
|
|
170
|
-
|
|
171
|
-
checkResults({
|
|
172
|
-
supportsIpV4: true,
|
|
173
|
-
supportsIpV6: true,
|
|
174
|
-
timings: {
|
|
175
|
-
totalTime: -1, // ice gathering has not finished, so this one is still -1
|
|
176
|
-
ipv4: 100,
|
|
177
|
-
ipv6: 50,
|
|
178
|
-
mdns: -1,
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
// receiving any more candidates should not cause any problems
|
|
183
|
-
simulateCandidate(50, '192.168.1.1');
|
|
184
|
-
simulateCandidate(50, '2a02:c7c:a0d0:8a00:d089:7baf:ceef:b9d8');
|
|
185
|
-
simulateEndOfCandidateGathering(100);
|
|
186
|
-
|
|
187
|
-
// check final results haven't changed (except for totalTime)
|
|
188
|
-
checkResults({
|
|
189
|
-
supportsIpV4: true,
|
|
190
|
-
supportsIpV6: true,
|
|
191
|
-
timings: {
|
|
192
|
-
totalTime: 300,
|
|
193
|
-
ipv4: 100,
|
|
194
|
-
ipv6: 50,
|
|
195
|
-
mdns: -1,
|
|
196
|
-
},
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('works correctly when we get only mDNS candidates', async () => {
|
|
201
|
-
const promise = ipNetworkDetector.detect();
|
|
202
|
-
|
|
203
|
-
// simulate some mDNS candidates (this happens if we don't have user media permissions)
|
|
204
|
-
simulateCandidate(50, '686a3cac-2840-4c62-9f85-9f0b03e84298.local');
|
|
205
|
-
simulateCandidate(50, '12f3ab4a3-4741-48c8-b1c9-8dd93d123aa1.local');
|
|
206
|
-
simulateEndOfCandidateGathering(100);
|
|
207
|
-
|
|
208
|
-
await promise;
|
|
209
|
-
|
|
210
|
-
checkResults({
|
|
211
|
-
supportsIpV4: undefined,
|
|
212
|
-
supportsIpV6: undefined,
|
|
213
|
-
timings: {
|
|
214
|
-
totalTime: 200,
|
|
215
|
-
ipv4: -1,
|
|
216
|
-
ipv6: -1,
|
|
217
|
-
mdns: 50,
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('works correctly when we get no candidates at all', async () => {
|
|
223
|
-
const promise = ipNetworkDetector.detect();
|
|
224
|
-
|
|
225
|
-
simulateEndOfCandidateGathering(100);
|
|
226
|
-
|
|
227
|
-
await promise;
|
|
228
|
-
|
|
229
|
-
checkResults({
|
|
230
|
-
supportsIpV4: false,
|
|
231
|
-
supportsIpV6: false,
|
|
232
|
-
timings: {
|
|
233
|
-
totalTime: 100,
|
|
234
|
-
ipv4: -1,
|
|
235
|
-
ipv6: -1,
|
|
236
|
-
mdns: -1,
|
|
237
|
-
},
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
// this never happens right now, but in theory browsers might change and if we get
|
|
242
|
-
// mDNS candidates with IPv4, but without IPv6, it is probably safe to assume that we're only on IPv4 network
|
|
243
|
-
it('works correctly when we get mDNS and ipv4 candidates', async () => {
|
|
244
|
-
const promise = ipNetworkDetector.detect();
|
|
245
|
-
|
|
246
|
-
simulateCandidate(50, '686a3cac-2840-4c62-9f85-9f0b03e84298.local');
|
|
247
|
-
simulateCandidate(50, '192.168.0.0');
|
|
248
|
-
simulateEndOfCandidateGathering(100);
|
|
249
|
-
|
|
250
|
-
await promise;
|
|
251
|
-
|
|
252
|
-
checkResults({
|
|
253
|
-
supportsIpV4: true,
|
|
254
|
-
supportsIpV6: false,
|
|
255
|
-
timings: {
|
|
256
|
-
totalTime: 200,
|
|
257
|
-
ipv4: 100,
|
|
258
|
-
ipv6: -1,
|
|
259
|
-
mdns: 50,
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
// this never happens right now, but in theory browsers might change and if we get
|
|
265
|
-
// mDNS candidates with IPv6, but without IPv4, it is probably safe to assume that we're only on IPv6 network
|
|
266
|
-
it('works correctly when we get mDNS and ipv6 candidates', async () => {
|
|
267
|
-
const promise = ipNetworkDetector.detect();
|
|
268
|
-
|
|
269
|
-
simulateCandidate(50, '686a3cac-2840-4c62-9f85-9f0b03e84298.local');
|
|
270
|
-
simulateCandidate(50, '2a02:c7c:a0d0:8a00:db9b:d4de:d1f7:4c49');
|
|
271
|
-
simulateEndOfCandidateGathering(100);
|
|
272
|
-
|
|
273
|
-
await promise;
|
|
274
|
-
|
|
275
|
-
checkResults({
|
|
276
|
-
supportsIpV4: false,
|
|
277
|
-
supportsIpV6: true,
|
|
278
|
-
timings: {
|
|
279
|
-
totalTime: 200,
|
|
280
|
-
ipv4: -1,
|
|
281
|
-
ipv6: 100,
|
|
282
|
-
mdns: 50,
|
|
283
|
-
},
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it('works correctly when we get null candidate at the end instead of gathering state change event', async () => {
|
|
288
|
-
const promise = ipNetworkDetector.detect();
|
|
289
|
-
|
|
290
|
-
simulateCandidate(50, '2a02:c7c:a0d0:8a00:db9b:d4de:d1f7:4c49');
|
|
291
|
-
simulateCandidate(50, '192.168.10.10');
|
|
292
|
-
simulateEndOfCandidateGathering(100, false);
|
|
293
|
-
|
|
294
|
-
await promise;
|
|
295
|
-
|
|
296
|
-
checkResults({
|
|
297
|
-
supportsIpV4: true,
|
|
298
|
-
supportsIpV6: true,
|
|
299
|
-
timings: {
|
|
300
|
-
totalTime: 200,
|
|
301
|
-
ipv4: 100,
|
|
302
|
-
ipv6: 50,
|
|
303
|
-
mdns: -1,
|
|
304
|
-
},
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it('resets all the props when called again', async () => {
|
|
309
|
-
const promise = ipNetworkDetector.detect();
|
|
310
|
-
|
|
311
|
-
simulateCandidate(50, '192.168.0.1');
|
|
312
|
-
simulateCandidate(50, '2a02:c7c:a0d0:8a00:db9b:d4de:d1f7:4c49');
|
|
313
|
-
simulateEndOfCandidateGathering(10);
|
|
314
|
-
|
|
315
|
-
await promise;
|
|
316
|
-
|
|
317
|
-
checkResults({
|
|
318
|
-
supportsIpV4: true,
|
|
319
|
-
supportsIpV6: true,
|
|
320
|
-
timings: {
|
|
321
|
-
totalTime: 110,
|
|
322
|
-
ipv4: 50,
|
|
323
|
-
ipv6: 100,
|
|
324
|
-
mdns: -1,
|
|
325
|
-
},
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
// now call detect() again
|
|
329
|
-
const promise2 = ipNetworkDetector.detect();
|
|
330
|
-
|
|
331
|
-
// everything should have been reset
|
|
332
|
-
assert.equal(ipNetworkDetector.supportsIpV4, undefined);
|
|
333
|
-
assert.equal(ipNetworkDetector.supportsIpV6, undefined);
|
|
334
|
-
assert.equal(ipNetworkDetector.firstIpV4, -1);
|
|
335
|
-
assert.equal(ipNetworkDetector.firstIpV6, -1);
|
|
336
|
-
assert.equal(ipNetworkDetector.firstMdns, -1);
|
|
337
|
-
assert.equal(ipNetworkDetector.totalTime, -1);
|
|
338
|
-
|
|
339
|
-
simulateEndOfCandidateGathering(10);
|
|
340
|
-
await promise2;
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
it('rejects if one of RTCPeerConnection operations fails', async () => {
|
|
344
|
-
const fakeError = new Error('fake error');
|
|
345
|
-
|
|
346
|
-
fakePeerConnection.createOffer.rejects(fakeError);
|
|
347
|
-
|
|
348
|
-
await assert.isRejected(ipNetworkDetector.detect(), fakeError);
|
|
349
|
-
|
|
350
|
-
assert.calledOnce(fakePeerConnection.close);
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
describe('while detection is in progress', () => {
|
|
354
|
-
describe('supportsIpv4 prop', () => {
|
|
355
|
-
it('returns undefined before any ipv4 candidate is received and true afterwards', async () => {
|
|
356
|
-
const promise = ipNetworkDetector.detect();
|
|
357
|
-
|
|
358
|
-
assert.equal(ipNetworkDetector.supportsIpV4, undefined);
|
|
359
|
-
assert.equal(ipNetworkDetector.firstIpV4, -1);
|
|
360
|
-
|
|
361
|
-
simulateCandidate(50, 'fd64:17cf:f4ad:0:d089:7baf:ceef:b9d8');
|
|
362
|
-
// still no ipv4 candidates...
|
|
363
|
-
assert.equal(ipNetworkDetector.supportsIpV4, undefined);
|
|
364
|
-
assert.equal(ipNetworkDetector.firstIpV4, -1);
|
|
365
|
-
|
|
366
|
-
simulateCandidate(50, '686a3cac-2840-4c62-9f85-9f0b03e84298.local');
|
|
367
|
-
// still no ipv4 candidates...
|
|
368
|
-
assert.equal(ipNetworkDetector.supportsIpV4, undefined);
|
|
369
|
-
assert.equal(ipNetworkDetector.firstIpV4, -1);
|
|
370
|
-
|
|
371
|
-
simulateCandidate(50, '192.168.0.0');
|
|
372
|
-
// now we've got one
|
|
373
|
-
assert.equal(ipNetworkDetector.supportsIpV4, true);
|
|
374
|
-
assert.equal(ipNetworkDetector.firstIpV4, 150);
|
|
375
|
-
|
|
376
|
-
simulateEndOfCandidateGathering(1);
|
|
377
|
-
await promise;
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
describe('supportsIpv6 prop', () => {
|
|
382
|
-
it('returns undefined before any ipv6 candidate is received and true afterwards', async () => {
|
|
383
|
-
const promise = ipNetworkDetector.detect();
|
|
384
|
-
|
|
385
|
-
assert.equal(ipNetworkDetector.supportsIpV6, undefined);
|
|
386
|
-
assert.equal(ipNetworkDetector.firstIpV6, -1);
|
|
387
|
-
|
|
388
|
-
simulateCandidate(50, '192.168.0.0');
|
|
389
|
-
// still no ipv6 candidates...
|
|
390
|
-
assert.equal(ipNetworkDetector.supportsIpV6, undefined);
|
|
391
|
-
assert.equal(ipNetworkDetector.firstIpV6, -1);
|
|
392
|
-
|
|
393
|
-
simulateCandidate(50, '686a3cac-2860-6c62-9f85-9f0b03e86298.local');
|
|
394
|
-
// still no ipv6 candidates...
|
|
395
|
-
assert.equal(ipNetworkDetector.supportsIpV6, undefined);
|
|
396
|
-
assert.equal(ipNetworkDetector.firstIpV6, -1);
|
|
397
|
-
|
|
398
|
-
simulateCandidate(50, 'fd64:17cf:f4ad:0:d089:7baf:ceef:b9d8');
|
|
399
|
-
// now we've got one
|
|
400
|
-
assert.equal(ipNetworkDetector.supportsIpV6, true);
|
|
401
|
-
assert.equal(ipNetworkDetector.firstIpV6, 150);
|
|
402
|
-
|
|
403
|
-
simulateEndOfCandidateGathering(1);
|
|
404
|
-
await promise;
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
});
|