@signalapp/ringrtc 2.25.2 → 2.26.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/dist/index.d.ts +1 -1
- package/dist/index.js +8 -1
- package/dist/ringrtc/Service.d.ts +24 -18
- package/dist/ringrtc/Service.js +45 -18
- package/dist/ringrtc/VideoSupport.js +1 -0
- package/package.json +8 -4
- package/dist/test/CallingClass.d.ts +0 -25
- package/dist/test/CallingClass.js +0 -182
- package/dist/test/RingRTC-test.d.ts +0 -1
- package/dist/test/RingRTC-test.js +0 -216
- package/dist/test/Utils.d.ts +0 -7
- package/dist/test/Utils.js +0 -52
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RingRTCType } from './ringrtc/Service';
|
|
2
|
-
export { AudioDevice, BandwidthMode, Call, CallEndedReason, CallId, CallLogLevel, CallMessageUrgency, CallSettings, CallState, CallingMessage, ConnectionState, DeviceId, GroupCall, GroupCallEndReason, GroupCallObserver, GroupMemberInfo, HangupMessage, HangupType, HttpMethod, JoinState, LocalDeviceState, OfferType, OpaqueMessage, PeekInfo, RemoteDeviceState, RingCancelReason, RingRTCType, RingUpdate, UserId, VideoCapturer, VideoRenderer, VideoRequest, } from './ringrtc/Service';
|
|
2
|
+
export { AnswerMessage, AudioDevice, BandwidthMode, BusyMessage, Call, CallEndedReason, CallId, CallLogLevel, CallMessageUrgency, CallSettings, CallState, CallingMessage, ConnectionState, DeviceId, GroupCall, GroupCallEndReason, GroupCallObserver, GroupMemberInfo, HangupMessage, HangupType, HttpMethod, IceCandidateMessage, JoinState, LocalDeviceState, OfferMessage, OfferType, OpaqueMessage, PeekInfo, RemoteDeviceState, RingCancelReason, RingRTCType, RingUpdate, UserId, VideoCapturer, VideoRenderer, VideoRequest, callIdFromEra, callIdFromRingId, } from './ringrtc/Service';
|
|
3
3
|
export { CanvasVideoRenderer, GumVideoCapturer, VideoFrameSource, MAX_VIDEO_CAPTURE_AREA, MAX_VIDEO_CAPTURE_BUFFER_SIZE, MAX_VIDEO_CAPTURE_HEIGHT, MAX_VIDEO_CAPTURE_WIDTH, } from './ringrtc/VideoSupport';
|
|
4
4
|
export declare const RingRTC: RingRTCType;
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
5
|
//
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.RingRTC = exports.MAX_VIDEO_CAPTURE_WIDTH = exports.MAX_VIDEO_CAPTURE_HEIGHT = exports.MAX_VIDEO_CAPTURE_BUFFER_SIZE = exports.MAX_VIDEO_CAPTURE_AREA = exports.GumVideoCapturer = exports.CanvasVideoRenderer = exports.VideoRequest = exports.RingUpdate = exports.RingRTCType = exports.RingCancelReason = exports.RemoteDeviceState = exports.PeekInfo = exports.OpaqueMessage = exports.OfferType = exports.LocalDeviceState = exports.JoinState = exports.HttpMethod = exports.HangupType = exports.HangupMessage = exports.GroupMemberInfo = exports.GroupCallEndReason = exports.GroupCall = exports.ConnectionState = exports.CallingMessage = exports.CallState = exports.CallMessageUrgency = exports.CallLogLevel = exports.CallEndedReason = exports.Call = exports.BandwidthMode = void 0;
|
|
7
|
+
exports.RingRTC = exports.MAX_VIDEO_CAPTURE_WIDTH = exports.MAX_VIDEO_CAPTURE_HEIGHT = exports.MAX_VIDEO_CAPTURE_BUFFER_SIZE = exports.MAX_VIDEO_CAPTURE_AREA = exports.GumVideoCapturer = exports.CanvasVideoRenderer = exports.callIdFromRingId = exports.callIdFromEra = exports.VideoRequest = exports.RingUpdate = exports.RingRTCType = exports.RingCancelReason = exports.RemoteDeviceState = exports.PeekInfo = exports.OpaqueMessage = exports.OfferType = exports.OfferMessage = exports.LocalDeviceState = exports.JoinState = exports.IceCandidateMessage = exports.HttpMethod = exports.HangupType = exports.HangupMessage = exports.GroupMemberInfo = exports.GroupCallEndReason = exports.GroupCall = exports.ConnectionState = exports.CallingMessage = exports.CallState = exports.CallMessageUrgency = exports.CallLogLevel = exports.CallEndedReason = exports.Call = exports.BusyMessage = exports.BandwidthMode = exports.AnswerMessage = void 0;
|
|
8
8
|
const Service_1 = require("./ringrtc/Service");
|
|
9
9
|
var Service_2 = require("./ringrtc/Service");
|
|
10
|
+
Object.defineProperty(exports, "AnswerMessage", { enumerable: true, get: function () { return Service_2.AnswerMessage; } });
|
|
10
11
|
Object.defineProperty(exports, "BandwidthMode", { enumerable: true, get: function () { return Service_2.BandwidthMode; } });
|
|
12
|
+
Object.defineProperty(exports, "BusyMessage", { enumerable: true, get: function () { return Service_2.BusyMessage; } });
|
|
11
13
|
Object.defineProperty(exports, "Call", { enumerable: true, get: function () { return Service_2.Call; } });
|
|
12
14
|
Object.defineProperty(exports, "CallEndedReason", { enumerable: true, get: function () { return Service_2.CallEndedReason; } });
|
|
13
15
|
Object.defineProperty(exports, "CallLogLevel", { enumerable: true, get: function () { return Service_2.CallLogLevel; } });
|
|
@@ -21,8 +23,10 @@ Object.defineProperty(exports, "GroupMemberInfo", { enumerable: true, get: funct
|
|
|
21
23
|
Object.defineProperty(exports, "HangupMessage", { enumerable: true, get: function () { return Service_2.HangupMessage; } });
|
|
22
24
|
Object.defineProperty(exports, "HangupType", { enumerable: true, get: function () { return Service_2.HangupType; } });
|
|
23
25
|
Object.defineProperty(exports, "HttpMethod", { enumerable: true, get: function () { return Service_2.HttpMethod; } });
|
|
26
|
+
Object.defineProperty(exports, "IceCandidateMessage", { enumerable: true, get: function () { return Service_2.IceCandidateMessage; } });
|
|
24
27
|
Object.defineProperty(exports, "JoinState", { enumerable: true, get: function () { return Service_2.JoinState; } });
|
|
25
28
|
Object.defineProperty(exports, "LocalDeviceState", { enumerable: true, get: function () { return Service_2.LocalDeviceState; } });
|
|
29
|
+
Object.defineProperty(exports, "OfferMessage", { enumerable: true, get: function () { return Service_2.OfferMessage; } });
|
|
26
30
|
Object.defineProperty(exports, "OfferType", { enumerable: true, get: function () { return Service_2.OfferType; } });
|
|
27
31
|
Object.defineProperty(exports, "OpaqueMessage", { enumerable: true, get: function () { return Service_2.OpaqueMessage; } });
|
|
28
32
|
Object.defineProperty(exports, "PeekInfo", { enumerable: true, get: function () { return Service_2.PeekInfo; } });
|
|
@@ -31,6 +35,8 @@ Object.defineProperty(exports, "RingCancelReason", { enumerable: true, get: func
|
|
|
31
35
|
Object.defineProperty(exports, "RingRTCType", { enumerable: true, get: function () { return Service_2.RingRTCType; } });
|
|
32
36
|
Object.defineProperty(exports, "RingUpdate", { enumerable: true, get: function () { return Service_2.RingUpdate; } });
|
|
33
37
|
Object.defineProperty(exports, "VideoRequest", { enumerable: true, get: function () { return Service_2.VideoRequest; } });
|
|
38
|
+
Object.defineProperty(exports, "callIdFromEra", { enumerable: true, get: function () { return Service_2.callIdFromEra; } });
|
|
39
|
+
Object.defineProperty(exports, "callIdFromRingId", { enumerable: true, get: function () { return Service_2.callIdFromRingId; } });
|
|
34
40
|
var VideoSupport_1 = require("./ringrtc/VideoSupport");
|
|
35
41
|
Object.defineProperty(exports, "CanvasVideoRenderer", { enumerable: true, get: function () { return VideoSupport_1.CanvasVideoRenderer; } });
|
|
36
42
|
Object.defineProperty(exports, "GumVideoCapturer", { enumerable: true, get: function () { return VideoSupport_1.GumVideoCapturer; } });
|
|
@@ -39,3 +45,4 @@ Object.defineProperty(exports, "MAX_VIDEO_CAPTURE_BUFFER_SIZE", { enumerable: tr
|
|
|
39
45
|
Object.defineProperty(exports, "MAX_VIDEO_CAPTURE_HEIGHT", { enumerable: true, get: function () { return VideoSupport_1.MAX_VIDEO_CAPTURE_HEIGHT; } });
|
|
40
46
|
Object.defineProperty(exports, "MAX_VIDEO_CAPTURE_WIDTH", { enumerable: true, get: function () { return VideoSupport_1.MAX_VIDEO_CAPTURE_WIDTH; } });
|
|
41
47
|
exports.RingRTC = new Service_1.RingRTCType();
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { GumVideoCaptureOptions, VideoPixelFormatEnum } from './VideoSupport';
|
|
3
|
+
export declare const callIdFromEra: (era: string) => CallId;
|
|
4
|
+
export declare function callIdFromRingId(ringId: bigint): CallId;
|
|
3
5
|
declare class Config {
|
|
4
6
|
use_new_audio_device_module: boolean;
|
|
5
7
|
field_trials: Record<string, string> | undefined;
|
|
@@ -347,7 +349,11 @@ type ProtobufBuffer = Buffer | {
|
|
|
347
349
|
};
|
|
348
350
|
export type UserId = string;
|
|
349
351
|
export type DeviceId = number;
|
|
350
|
-
export type CallId =
|
|
352
|
+
export type CallId = {
|
|
353
|
+
high: number;
|
|
354
|
+
low: number;
|
|
355
|
+
unsigned: boolean;
|
|
356
|
+
};
|
|
351
357
|
export declare class CallingMessage {
|
|
352
358
|
offer?: OfferMessage;
|
|
353
359
|
answer?: AnswerMessage;
|
|
@@ -360,34 +366,34 @@ export declare class CallingMessage {
|
|
|
360
366
|
destinationDeviceId?: DeviceId;
|
|
361
367
|
}
|
|
362
368
|
export declare class OfferMessage {
|
|
363
|
-
callId
|
|
364
|
-
type
|
|
365
|
-
opaque
|
|
366
|
-
|
|
369
|
+
callId: CallId;
|
|
370
|
+
type: OfferType;
|
|
371
|
+
opaque: ProtobufBuffer;
|
|
372
|
+
constructor(callId: CallId, type: OfferType, opaque: ProtobufBuffer);
|
|
367
373
|
}
|
|
368
374
|
export declare enum OfferType {
|
|
369
375
|
AudioCall = 0,
|
|
370
376
|
VideoCall = 1
|
|
371
377
|
}
|
|
372
378
|
export declare class AnswerMessage {
|
|
373
|
-
callId
|
|
374
|
-
opaque
|
|
375
|
-
|
|
379
|
+
callId: CallId;
|
|
380
|
+
opaque: ProtobufBuffer;
|
|
381
|
+
constructor(callId: CallId, opaque: ProtobufBuffer);
|
|
376
382
|
}
|
|
377
383
|
export declare class IceCandidateMessage {
|
|
378
|
-
callId
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
opaque?: ProtobufBuffer;
|
|
382
|
-
sdp?: string;
|
|
384
|
+
callId: CallId;
|
|
385
|
+
opaque: ProtobufBuffer;
|
|
386
|
+
constructor(callId: CallId, opaque: ProtobufBuffer);
|
|
383
387
|
}
|
|
384
388
|
export declare class BusyMessage {
|
|
385
|
-
callId
|
|
389
|
+
callId: CallId;
|
|
390
|
+
constructor(callId: CallId);
|
|
386
391
|
}
|
|
387
392
|
export declare class HangupMessage {
|
|
388
|
-
callId
|
|
389
|
-
type
|
|
390
|
-
deviceId
|
|
393
|
+
callId: CallId;
|
|
394
|
+
type: HangupType;
|
|
395
|
+
deviceId: DeviceId;
|
|
396
|
+
constructor(callId: CallId, type: HangupType, deviceId: DeviceId);
|
|
391
397
|
}
|
|
392
398
|
export declare class OpaqueMessage {
|
|
393
399
|
data?: ProtobufBuffer;
|
|
@@ -424,7 +430,7 @@ export interface CallManager {
|
|
|
424
430
|
updateBandwidthMode(bandwidthMode: BandwidthMode): void;
|
|
425
431
|
sendVideoFrame(width: number, height: number, format: VideoPixelFormatEnum, buffer: Buffer): void;
|
|
426
432
|
receiveVideoFrame(buffer: Buffer, maxWidth: number, maxHeight: number): [number, number] | undefined;
|
|
427
|
-
receivedOffer(remoteUserId: UserId, remoteDeviceId: DeviceId, messageAgeSec: number, callId: CallId, offerType: OfferType,
|
|
433
|
+
receivedOffer(remoteUserId: UserId, remoteDeviceId: DeviceId, localDeviceId: DeviceId, messageAgeSec: number, callId: CallId, offerType: OfferType, opaque: Buffer, senderIdentityKey: Buffer, receiverIdentityKey: Buffer): void;
|
|
428
434
|
receivedAnswer(remoteUserId: UserId, remoteDeviceId: DeviceId, callId: CallId, opaque: Buffer, senderIdentityKey: Buffer, receiverIdentityKey: Buffer): void;
|
|
429
435
|
receivedIceCandidates(remoteUserId: UserId, remoteDeviceId: DeviceId, callId: CallId, candidates: Array<Buffer>): void;
|
|
430
436
|
receivedHangup(remoteUserId: UserId, remoteDeviceId: DeviceId, callId: CallId, hangupType: HangupType, hangupDeviceId: DeviceId | null): void;
|
package/dist/ringrtc/Service.js
CHANGED
|
@@ -36,12 +36,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.CallLogLevel = exports.CallEndedReason = exports.CallState = exports.RingCancelReason = exports.BandwidthMode = exports.HangupType = exports.OpaqueMessage = exports.HangupMessage = exports.BusyMessage = exports.IceCandidateMessage = exports.AnswerMessage = exports.OfferType = exports.OfferMessage = exports.CallingMessage = exports.GroupCall = exports.VideoRequest = exports.GroupMemberInfo = exports.RemoteDeviceState = exports.LocalDeviceState = exports.HttpMethod = exports.RingUpdate = exports.CallMessageUrgency = exports.GroupCallEndReason = exports.JoinState = exports.ConnectionState = exports.Call = exports.RingRTCType = exports.ReceivedAudioLevel = exports.NetworkRoute = exports.PeekInfo = exports.PeekDeviceInfo = void 0;
|
|
39
|
+
exports.CallLogLevel = exports.CallEndedReason = exports.CallState = exports.RingCancelReason = exports.BandwidthMode = exports.HangupType = exports.OpaqueMessage = exports.HangupMessage = exports.BusyMessage = exports.IceCandidateMessage = exports.AnswerMessage = exports.OfferType = exports.OfferMessage = exports.CallingMessage = exports.GroupCall = exports.VideoRequest = exports.GroupMemberInfo = exports.RemoteDeviceState = exports.LocalDeviceState = exports.HttpMethod = exports.RingUpdate = exports.CallMessageUrgency = exports.GroupCallEndReason = exports.JoinState = exports.ConnectionState = exports.Call = exports.RingRTCType = exports.ReceivedAudioLevel = exports.NetworkRoute = exports.PeekInfo = exports.PeekDeviceInfo = exports.callIdFromRingId = exports.callIdFromEra = void 0;
|
|
40
40
|
/* eslint-disable max-classes-per-file */
|
|
41
41
|
const os = __importStar(require("os"));
|
|
42
42
|
const process = __importStar(require("process"));
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require
|
|
44
44
|
const Native = require(`../../build/${os.platform()}/libringrtc-${process.arch}.node`);
|
|
45
|
+
exports.callIdFromEra = Native.callIdFromEra;
|
|
46
|
+
function callIdFromRingId(ringId) {
|
|
47
|
+
return {
|
|
48
|
+
low: Number(BigInt.asIntN(32, ringId)),
|
|
49
|
+
high: Number(BigInt.asIntN(32, ringId >> BigInt(32))),
|
|
50
|
+
unsigned: true,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
exports.callIdFromRingId = callIdFromRingId;
|
|
45
54
|
class Config {
|
|
46
55
|
constructor() {
|
|
47
56
|
this.use_new_audio_device_module = false;
|
|
@@ -240,7 +249,10 @@ class CallInfo {
|
|
|
240
249
|
class RingRTCType {
|
|
241
250
|
getCallInfoKey(callId) {
|
|
242
251
|
// CallId is u64 so use a string key instead.
|
|
243
|
-
|
|
252
|
+
// Note that the representation is not padded, so we include a separator.
|
|
253
|
+
// Otherwise {1, 123} and {11, 23} would have the same key.
|
|
254
|
+
// (We could use Long.toString as well, but it doesn't matter what the key is.)
|
|
255
|
+
return `${callId.high} ${callId.low}`;
|
|
244
256
|
}
|
|
245
257
|
constructor() {
|
|
246
258
|
// Set by UX
|
|
@@ -476,18 +488,13 @@ class RingRTCType {
|
|
|
476
488
|
// Called by Rust
|
|
477
489
|
onSendOffer(remoteUserId, remoteDeviceId, callId, broadcast, offerType, opaque) {
|
|
478
490
|
const message = new CallingMessage();
|
|
479
|
-
message.offer = new OfferMessage();
|
|
480
|
-
message.offer.callId = callId;
|
|
481
|
-
message.offer.type = offerType;
|
|
482
|
-
message.offer.opaque = opaque;
|
|
491
|
+
message.offer = new OfferMessage(callId, offerType, opaque);
|
|
483
492
|
this.sendSignaling(remoteUserId, remoteDeviceId, callId, broadcast, message);
|
|
484
493
|
}
|
|
485
494
|
// Called by Rust
|
|
486
495
|
onSendAnswer(remoteUserId, remoteDeviceId, callId, broadcast, opaque) {
|
|
487
496
|
const message = new CallingMessage();
|
|
488
|
-
message.answer = new AnswerMessage();
|
|
489
|
-
message.answer.callId = callId;
|
|
490
|
-
message.answer.opaque = opaque;
|
|
497
|
+
message.answer = new AnswerMessage(callId, opaque);
|
|
491
498
|
this.sendSignaling(remoteUserId, remoteDeviceId, callId, broadcast, message);
|
|
492
499
|
}
|
|
493
500
|
// Called by Rust
|
|
@@ -495,9 +502,7 @@ class RingRTCType {
|
|
|
495
502
|
const message = new CallingMessage();
|
|
496
503
|
message.iceCandidates = [];
|
|
497
504
|
for (const candidate of candidates) {
|
|
498
|
-
const copy = new IceCandidateMessage();
|
|
499
|
-
copy.callId = callId;
|
|
500
|
-
copy.opaque = candidate;
|
|
505
|
+
const copy = new IceCandidateMessage(callId, candidate);
|
|
501
506
|
message.iceCandidates.push(copy);
|
|
502
507
|
}
|
|
503
508
|
this.sendSignaling(remoteUserId, remoteDeviceId, callId, broadcast, message);
|
|
@@ -505,17 +510,13 @@ class RingRTCType {
|
|
|
505
510
|
// Called by Rust
|
|
506
511
|
onSendHangup(remoteUserId, remoteDeviceId, callId, broadcast, hangupType, deviceId) {
|
|
507
512
|
const message = new CallingMessage();
|
|
508
|
-
message.hangup = new HangupMessage();
|
|
509
|
-
message.hangup.callId = callId;
|
|
510
|
-
message.hangup.type = hangupType;
|
|
511
|
-
message.hangup.deviceId = deviceId || 0;
|
|
513
|
+
message.hangup = new HangupMessage(callId, hangupType, deviceId || 0);
|
|
512
514
|
this.sendSignaling(remoteUserId, remoteDeviceId, callId, broadcast, message);
|
|
513
515
|
}
|
|
514
516
|
// Called by Rust
|
|
515
517
|
onSendBusy(remoteUserId, remoteDeviceId, callId, broadcast) {
|
|
516
518
|
const message = new CallingMessage();
|
|
517
|
-
message.busy = new BusyMessage();
|
|
518
|
-
message.busy.callId = callId;
|
|
519
|
+
message.busy = new BusyMessage(callId);
|
|
519
520
|
this.sendSignaling(remoteUserId, remoteDeviceId, callId, broadcast, message);
|
|
520
521
|
}
|
|
521
522
|
sendSignaling(remoteUserId, remoteDeviceId, callId, broadcast, message) {
|
|
@@ -769,6 +770,10 @@ class RingRTCType {
|
|
|
769
770
|
this.logWarn('handleCallingMessage(): No ice candidates in ice message, remote should update');
|
|
770
771
|
return;
|
|
771
772
|
}
|
|
773
|
+
if (!callId) {
|
|
774
|
+
this.logWarn('handleCallingMessage(): No call ID in ice message');
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
772
777
|
this.callManager.receivedIceCandidates(remoteUserId, remoteDeviceId, callId, candidates);
|
|
773
778
|
}
|
|
774
779
|
if ((_c = message.hangup) === null || _c === void 0 ? void 0 : _c.callId) {
|
|
@@ -1427,6 +1432,11 @@ class CallingMessage {
|
|
|
1427
1432
|
}
|
|
1428
1433
|
exports.CallingMessage = CallingMessage;
|
|
1429
1434
|
class OfferMessage {
|
|
1435
|
+
constructor(callId, type, opaque) {
|
|
1436
|
+
this.callId = callId;
|
|
1437
|
+
this.type = type;
|
|
1438
|
+
this.opaque = opaque;
|
|
1439
|
+
}
|
|
1430
1440
|
}
|
|
1431
1441
|
exports.OfferMessage = OfferMessage;
|
|
1432
1442
|
var OfferType;
|
|
@@ -1435,15 +1445,31 @@ var OfferType;
|
|
|
1435
1445
|
OfferType[OfferType["VideoCall"] = 1] = "VideoCall";
|
|
1436
1446
|
})(OfferType = exports.OfferType || (exports.OfferType = {}));
|
|
1437
1447
|
class AnswerMessage {
|
|
1448
|
+
constructor(callId, opaque) {
|
|
1449
|
+
this.callId = callId;
|
|
1450
|
+
this.opaque = opaque;
|
|
1451
|
+
}
|
|
1438
1452
|
}
|
|
1439
1453
|
exports.AnswerMessage = AnswerMessage;
|
|
1440
1454
|
class IceCandidateMessage {
|
|
1455
|
+
constructor(callId, opaque) {
|
|
1456
|
+
this.callId = callId;
|
|
1457
|
+
this.opaque = opaque;
|
|
1458
|
+
}
|
|
1441
1459
|
}
|
|
1442
1460
|
exports.IceCandidateMessage = IceCandidateMessage;
|
|
1443
1461
|
class BusyMessage {
|
|
1462
|
+
constructor(callId) {
|
|
1463
|
+
this.callId = callId;
|
|
1464
|
+
}
|
|
1444
1465
|
}
|
|
1445
1466
|
exports.BusyMessage = BusyMessage;
|
|
1446
1467
|
class HangupMessage {
|
|
1468
|
+
constructor(callId, type, deviceId) {
|
|
1469
|
+
this.callId = callId;
|
|
1470
|
+
this.type = type;
|
|
1471
|
+
this.deviceId = deviceId;
|
|
1472
|
+
}
|
|
1447
1473
|
}
|
|
1448
1474
|
exports.HangupMessage = HangupMessage;
|
|
1449
1475
|
class OpaqueMessage {
|
|
@@ -1516,3 +1542,4 @@ function sillyDeadlockProtection(f) {
|
|
|
1516
1542
|
f();
|
|
1517
1543
|
}))();
|
|
1518
1544
|
}
|
|
1545
|
+
//# sourceMappingURL=Service.js.map
|
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signalapp/ringrtc",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.2",
|
|
4
4
|
"description": "Signal Messenger voice and video calling library.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist
|
|
8
|
+
"dist/*.js",
|
|
9
|
+
"dist/*.d.ts",
|
|
10
|
+
"dist/ringrtc/*.js",
|
|
11
|
+
"dist/ringrtc/*.d.ts",
|
|
9
12
|
"scripts/fetch-prebuild.js"
|
|
10
13
|
],
|
|
11
14
|
"scripts": {
|
|
12
15
|
"build": "tsc",
|
|
13
16
|
"clean": "rimraf dist",
|
|
14
|
-
"test": "electron-mocha --renderer --recursive dist/test --timeout 10000",
|
|
17
|
+
"test": "electron-mocha --renderer --recursive dist/test --timeout 10000 --require source-map-support/register",
|
|
15
18
|
"eslint": "eslint --cache .",
|
|
16
19
|
"lint": "yarn format --list-different && yarn eslint",
|
|
17
20
|
"format": "prettier --write .",
|
|
@@ -20,7 +23,7 @@
|
|
|
20
23
|
},
|
|
21
24
|
"config": {
|
|
22
25
|
"prebuildUrl": "https://build-artifacts.signal.org/libraries/ringrtc-desktop-build-v${npm_package_version}.tar.gz",
|
|
23
|
-
"prebuildChecksum": "
|
|
26
|
+
"prebuildChecksum": "da18a941541930f29418b67b7091d8508e991ae0cf39e8b9e71580962a0c0aa5"
|
|
24
27
|
},
|
|
25
28
|
"author": "",
|
|
26
29
|
"license": "AGPL-3.0-only",
|
|
@@ -52,6 +55,7 @@
|
|
|
52
55
|
"rimraf": "4.1.2",
|
|
53
56
|
"sinon": "^15.0.1",
|
|
54
57
|
"sinon-chai": "^3.7.0",
|
|
58
|
+
"source-map-support": "^0.5.19",
|
|
55
59
|
"typescript": "4.9.3",
|
|
56
60
|
"yarn-audit-fix": "^9.3.9"
|
|
57
61
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export declare class CallingClass {
|
|
2
|
-
private _name;
|
|
3
|
-
private _id;
|
|
4
|
-
private _localDeviceId;
|
|
5
|
-
private _call;
|
|
6
|
-
private _delayIncomingCallSettingsRequest;
|
|
7
|
-
private _delayOutgoingCallSettingsRequest;
|
|
8
|
-
set delayIncomingCallSettingsRequest(value: number);
|
|
9
|
-
set delayOutgoingCallSettingsRequest(value: number);
|
|
10
|
-
constructor(name: string, id: string);
|
|
11
|
-
private setupCallCallbacks;
|
|
12
|
-
private handleOutgoingSignaling;
|
|
13
|
-
private handleIncomingCall;
|
|
14
|
-
private handleStartCall;
|
|
15
|
-
private handleAutoEndedIncomingCallRequest;
|
|
16
|
-
private handleLogMessage;
|
|
17
|
-
private handleSendHttpRequest;
|
|
18
|
-
private handleSendCallMessage;
|
|
19
|
-
private handleSendCallMessageToGroup;
|
|
20
|
-
private handleGroupCallRingUpdate;
|
|
21
|
-
private getCallSettings;
|
|
22
|
-
initialize(): void;
|
|
23
|
-
startOutgoingDirectCall(remoteUserId: string): Promise<void>;
|
|
24
|
-
hangup(): boolean;
|
|
25
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2023 Signal Messenger, LLC
|
|
4
|
-
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
|
-
//
|
|
6
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.CallingClass = void 0;
|
|
20
|
-
/* eslint-disable no-console, @typescript-eslint/require-await, @typescript-eslint/no-unused-vars */
|
|
21
|
-
const Service_1 = require("../ringrtc/Service");
|
|
22
|
-
const index_1 = require("../index");
|
|
23
|
-
const long_1 = __importDefault(require("long"));
|
|
24
|
-
const Utils_1 = require("./Utils");
|
|
25
|
-
// This class mimics the Desktop Client CallingClass in ts/services/calling.ts to facilitate testing
|
|
26
|
-
class CallingClass {
|
|
27
|
-
set delayIncomingCallSettingsRequest(value) {
|
|
28
|
-
this._delayIncomingCallSettingsRequest = value;
|
|
29
|
-
}
|
|
30
|
-
set delayOutgoingCallSettingsRequest(value) {
|
|
31
|
-
this._delayIncomingCallSettingsRequest = value;
|
|
32
|
-
}
|
|
33
|
-
constructor(name, id) {
|
|
34
|
-
this._name = name;
|
|
35
|
-
this._id = id;
|
|
36
|
-
this._localDeviceId = 1;
|
|
37
|
-
this._delayIncomingCallSettingsRequest = 0;
|
|
38
|
-
this._delayOutgoingCallSettingsRequest = 0;
|
|
39
|
-
}
|
|
40
|
-
setupCallCallbacks(call) {
|
|
41
|
-
// eslint-disable-next-line no-param-reassign
|
|
42
|
-
call.handleStateChanged = () => {
|
|
43
|
-
(0, Utils_1.log)('handleCallStateChanged');
|
|
44
|
-
(0, Utils_1.log)(`call.state === ${call.state}`);
|
|
45
|
-
if (call.state === Service_1.CallState.Ended) {
|
|
46
|
-
(0, Utils_1.log)(`call.endedReason === ${call.endedReason}`);
|
|
47
|
-
this._call = undefined;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
// eslint-disable-next-line no-param-reassign
|
|
51
|
-
call.handleRemoteVideoEnabled = () => {
|
|
52
|
-
(0, Utils_1.log)('handleRemoteVideoEnabled');
|
|
53
|
-
};
|
|
54
|
-
// eslint-disable-next-line no-param-reassign
|
|
55
|
-
call.handleRemoteSharingScreen = () => {
|
|
56
|
-
(0, Utils_1.log)('handleRemoteSharingScreen');
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
60
|
-
// Callbacks
|
|
61
|
-
handleOutgoingSignaling(remoteUserId, message, urgency) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
(0, Utils_1.log)(`handleOutgoingSignaling remoteUserId: ${remoteUserId}`);
|
|
64
|
-
return true;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
handleIncomingCall(call) {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
(0, Utils_1.log)('handleIncomingCall');
|
|
70
|
-
this._call = call;
|
|
71
|
-
this.setupCallCallbacks(call);
|
|
72
|
-
return true;
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
handleStartCall(call) {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
const callSettings = yield this.getCallSettings(call.isIncoming);
|
|
78
|
-
index_1.RingRTC.proceed(call.callId, callSettings);
|
|
79
|
-
return true;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
handleAutoEndedIncomingCallRequest(callId, remoteUserId, reason, ageInSeconds, wasVideoCall, receivedAtCounter) {
|
|
83
|
-
(0, Utils_1.log)('handleAutoEndedIncomingCallRequest');
|
|
84
|
-
}
|
|
85
|
-
handleLogMessage(level, fileName, line, message) {
|
|
86
|
-
switch (level) {
|
|
87
|
-
case Service_1.CallLogLevel.Info:
|
|
88
|
-
// FgGray
|
|
89
|
-
console.log(`\x1b[90m${fileName}:${line} ${message}\x1b[0m`);
|
|
90
|
-
break;
|
|
91
|
-
case Service_1.CallLogLevel.Warn:
|
|
92
|
-
// FgYellow
|
|
93
|
-
console.warn(`\x1b[33m${fileName}:${line} ${message}\x1b[0m`);
|
|
94
|
-
break;
|
|
95
|
-
case Service_1.CallLogLevel.Error:
|
|
96
|
-
// FgRed
|
|
97
|
-
console.error(`\x1b[31m${fileName}:${line} ${message}\x1b[0m`);
|
|
98
|
-
break;
|
|
99
|
-
default:
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
handleSendHttpRequest(requestId, url, method, headers, body) {
|
|
104
|
-
(0, Utils_1.log)('handleSendHttpRequest');
|
|
105
|
-
}
|
|
106
|
-
handleSendCallMessage(recipient, data, urgency) {
|
|
107
|
-
(0, Utils_1.log)('handleSendCallMessage');
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
handleSendCallMessageToGroup(groupIdBytes, data, urgency) {
|
|
111
|
-
(0, Utils_1.log)('handleSendCallMessageToGroup');
|
|
112
|
-
}
|
|
113
|
-
handleGroupCallRingUpdate(groupIdBytes, ringId, ringerBytes, update) {
|
|
114
|
-
(0, Utils_1.log)('handleGroupCallRingUpdate');
|
|
115
|
-
}
|
|
116
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
117
|
-
// Support
|
|
118
|
-
getCallSettings(isIncoming) {
|
|
119
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
if (isIncoming) {
|
|
121
|
-
(0, Utils_1.log)(`getCallSettings delayed by ${this._delayIncomingCallSettingsRequest}ms`);
|
|
122
|
-
yield (0, Utils_1.sleep)(this._delayIncomingCallSettingsRequest);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
(0, Utils_1.log)(`getCallSettings delayed by ${this._delayOutgoingCallSettingsRequest}ms`);
|
|
126
|
-
yield (0, Utils_1.sleep)(this._delayOutgoingCallSettingsRequest);
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
iceServer: {
|
|
130
|
-
urls: ['stun:turn3.voip.signal.org'],
|
|
131
|
-
},
|
|
132
|
-
hideIp: false,
|
|
133
|
-
bandwidthMode: Service_1.BandwidthMode.Normal,
|
|
134
|
-
};
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
138
|
-
// Actions
|
|
139
|
-
initialize() {
|
|
140
|
-
(0, Utils_1.log)('initialize');
|
|
141
|
-
index_1.RingRTC.setConfig({
|
|
142
|
-
use_new_audio_device_module: true,
|
|
143
|
-
field_trials: undefined,
|
|
144
|
-
});
|
|
145
|
-
index_1.RingRTC.handleOutgoingSignaling = this.handleOutgoingSignaling.bind(this);
|
|
146
|
-
index_1.RingRTC.handleIncomingCall = this.handleIncomingCall.bind(this);
|
|
147
|
-
index_1.RingRTC.handleStartCall = this.handleStartCall.bind(this);
|
|
148
|
-
index_1.RingRTC.handleAutoEndedIncomingCallRequest =
|
|
149
|
-
this.handleAutoEndedIncomingCallRequest.bind(this);
|
|
150
|
-
index_1.RingRTC.handleLogMessage = this.handleLogMessage.bind(this);
|
|
151
|
-
index_1.RingRTC.handleSendHttpRequest = this.handleSendHttpRequest.bind(this);
|
|
152
|
-
index_1.RingRTC.handleSendCallMessage = this.handleSendCallMessage.bind(this);
|
|
153
|
-
index_1.RingRTC.handleSendCallMessageToGroup =
|
|
154
|
-
this.handleSendCallMessageToGroup.bind(this);
|
|
155
|
-
index_1.RingRTC.handleGroupCallRingUpdate =
|
|
156
|
-
this.handleGroupCallRingUpdate.bind(this);
|
|
157
|
-
index_1.RingRTC.setSelfUuid(Buffer.from((0, Utils_1.uuidToBytes)(this._id)));
|
|
158
|
-
}
|
|
159
|
-
startOutgoingDirectCall(remoteUserId) {
|
|
160
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
(0, Utils_1.log)('startOutgoingDirectCall');
|
|
162
|
-
if (index_1.RingRTC.call && index_1.RingRTC.call.state !== Service_1.CallState.Ended) {
|
|
163
|
-
(0, Utils_1.log)('Call already in progress, new call not allowed.');
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
const call = index_1.RingRTC.startOutgoingCall(remoteUserId, false, this._localDeviceId);
|
|
167
|
-
(0, Utils_1.log)(`Outgoing callId ${long_1.default.fromValue(call.callId)}`);
|
|
168
|
-
index_1.RingRTC.setOutgoingAudio(call.callId, true);
|
|
169
|
-
this._call = call;
|
|
170
|
-
this.setupCallCallbacks(call);
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
hangup() {
|
|
174
|
-
(0, Utils_1.log)('hangup');
|
|
175
|
-
if (this._call) {
|
|
176
|
-
index_1.RingRTC.hangup(this._call.callId);
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
exports.CallingClass = CallingClass;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2019-2021 Signal Messenger, LLC
|
|
4
|
-
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
|
-
//
|
|
6
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
20
|
-
const chai_1 = require("chai");
|
|
21
|
-
const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
|
|
22
|
-
const crypto_1 = require("crypto");
|
|
23
|
-
const index_1 = require("../index");
|
|
24
|
-
const long_1 = __importDefault(require("long"));
|
|
25
|
-
const chai_2 = require("chai");
|
|
26
|
-
const sinon_1 = __importDefault(require("sinon"));
|
|
27
|
-
const sinon_chai_1 = __importDefault(require("sinon-chai"));
|
|
28
|
-
const CallingClass_1 = require("./CallingClass");
|
|
29
|
-
const Utils_1 = require("./Utils");
|
|
30
|
-
(0, chai_1.use)(chai_as_promised_1.default);
|
|
31
|
-
(0, chai_2.should)();
|
|
32
|
-
(0, chai_1.use)(sinon_chai_1.default);
|
|
33
|
-
function generateOfferCallingMessage(callId) {
|
|
34
|
-
// Audio-only hex based SDP generated from a direct client call
|
|
35
|
-
const audioOnlySdp = Buffer.from('22560a204b18bc751315cb718c643db7b3a65aaabe826c7094932afaf5aebc86d36bb6491204484b6b481a18524b3041496f63334245514e5670424b57786f38787051712204082e1034220408281034220208082880897a', 'hex');
|
|
36
|
-
return {
|
|
37
|
-
offer: {
|
|
38
|
-
callId: callId,
|
|
39
|
-
opaque: audioOnlySdp,
|
|
40
|
-
type: index_1.OfferType.AudioCall,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
describe('RingRTC', () => {
|
|
45
|
-
const identity_key_length = 31;
|
|
46
|
-
const user1_name = 'user1';
|
|
47
|
-
const user1_id = '11';
|
|
48
|
-
const user1_device_id = 11;
|
|
49
|
-
const user1_identity_key = (0, crypto_1.randomBytes)(identity_key_length);
|
|
50
|
-
const user2_id = '22';
|
|
51
|
-
const user2_device_id = 22;
|
|
52
|
-
const user2_identity_key = (0, crypto_1.randomBytes)(identity_key_length);
|
|
53
|
-
let handleOutgoingSignalingSpy;
|
|
54
|
-
let handleIncomingCallSpy;
|
|
55
|
-
let handleAutoEndedIncomingCallRequestSpy;
|
|
56
|
-
it('reports an age for expired offers', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
-
const offer = {
|
|
58
|
-
offer: {
|
|
59
|
-
callId: { high: 0, low: 123 },
|
|
60
|
-
type: index_1.OfferType.AudioCall,
|
|
61
|
-
opaque: Buffer.from([]),
|
|
62
|
-
},
|
|
63
|
-
supportsMultiRing: true,
|
|
64
|
-
};
|
|
65
|
-
const age = 60 * 60;
|
|
66
|
-
try {
|
|
67
|
-
const { reason, ageSec: reportedAge } = yield new Promise((resolve, _reject) => {
|
|
68
|
-
/* eslint-disable @typescript-eslint/no-shadow */
|
|
69
|
-
index_1.RingRTC.handleAutoEndedIncomingCallRequest = (_callId, _remoteUserId, reason, ageSec) => {
|
|
70
|
-
resolve({ reason, ageSec });
|
|
71
|
-
};
|
|
72
|
-
/* eslint-enable @typescript-eslint/no-shadow */
|
|
73
|
-
index_1.RingRTC.handleCallingMessage('remote', null, 4, 2, age, 1, offer, Buffer.from([]), Buffer.from([]));
|
|
74
|
-
});
|
|
75
|
-
chai_1.assert.equal(reason, index_1.CallEndedReason.ReceivedOfferExpired);
|
|
76
|
-
chai_1.assert.equal(reportedAge, age);
|
|
77
|
-
}
|
|
78
|
-
finally {
|
|
79
|
-
index_1.RingRTC.handleAutoEndedIncomingCallRequest = null;
|
|
80
|
-
}
|
|
81
|
-
}));
|
|
82
|
-
it('reports 0 as the age of other auto-ended offers', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
-
const offer = {
|
|
84
|
-
offer: {
|
|
85
|
-
callId: { high: 0, low: 123 },
|
|
86
|
-
type: index_1.OfferType.AudioCall,
|
|
87
|
-
opaque: Buffer.from([]),
|
|
88
|
-
},
|
|
89
|
-
supportsMultiRing: true,
|
|
90
|
-
};
|
|
91
|
-
try {
|
|
92
|
-
const { reason, ageSec: reportedAge } = yield new Promise((resolve, _reject) => {
|
|
93
|
-
/* eslint-disable @typescript-eslint/no-shadow */
|
|
94
|
-
index_1.RingRTC.handleAutoEndedIncomingCallRequest = (_callId, _remoteUserId, reason, ageSec) => {
|
|
95
|
-
resolve({ reason, ageSec });
|
|
96
|
-
};
|
|
97
|
-
/* eslint-enable @typescript-eslint/no-shadow */
|
|
98
|
-
index_1.RingRTC.handleCallingMessage('remote', null, 4, 2, 10, 2, offer, Buffer.from([]), Buffer.from([]));
|
|
99
|
-
});
|
|
100
|
-
chai_1.assert.equal(reason, index_1.CallEndedReason.Declined); // because we didn't set handleIncomingCall.
|
|
101
|
-
chai_1.assert.equal(reportedAge, 0);
|
|
102
|
-
}
|
|
103
|
-
finally {
|
|
104
|
-
index_1.RingRTC.handleAutoEndedIncomingCallRequest = null;
|
|
105
|
-
}
|
|
106
|
-
}));
|
|
107
|
-
function initializeSpies() {
|
|
108
|
-
handleAutoEndedIncomingCallRequestSpy = sinon_1.default.spy(index_1.RingRTC, 'handleAutoEndedIncomingCallRequest');
|
|
109
|
-
handleIncomingCallSpy = sinon_1.default.spy(index_1.RingRTC, 'handleIncomingCall');
|
|
110
|
-
handleOutgoingSignalingSpy = sinon_1.default.spy(index_1.RingRTC, 'handleOutgoingSignaling');
|
|
111
|
-
}
|
|
112
|
-
it('can initialize RingRTC', () => {
|
|
113
|
-
chai_1.assert.isNotNull(index_1.RingRTC, "RingRTC didn't initialize!");
|
|
114
|
-
});
|
|
115
|
-
it('can establish outgoing call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
|
-
const calling = new CallingClass_1.CallingClass(user1_name, user1_id);
|
|
117
|
-
calling.initialize();
|
|
118
|
-
initializeSpies();
|
|
119
|
-
yield calling.startOutgoingDirectCall(user2_id);
|
|
120
|
-
yield (0, Utils_1.sleep)(1000);
|
|
121
|
-
// An offer and at least one ICE message should have been sent.
|
|
122
|
-
(0, chai_1.expect)(handleOutgoingSignalingSpy.callCount).to.be.gt(1);
|
|
123
|
-
yield (0, Utils_1.sleep)(2000);
|
|
124
|
-
// Cleanup.
|
|
125
|
-
const handleStateChangedSpy = sinon_1.default.spy(index_1.RingRTC.call, 'handleStateChanged');
|
|
126
|
-
(0, chai_1.expect)(calling.hangup()).to.be.true;
|
|
127
|
-
yield (0, Utils_1.sleep)(500);
|
|
128
|
-
handleStateChangedSpy.should.have.been.calledOnce;
|
|
129
|
-
(0, chai_1.expect)(calling.hangup()).to.be.false;
|
|
130
|
-
yield (0, Utils_1.sleep)(100);
|
|
131
|
-
}));
|
|
132
|
-
it('can establish incoming call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
-
const calling = new CallingClass_1.CallingClass(user1_name, user1_id);
|
|
134
|
-
calling.initialize();
|
|
135
|
-
initializeSpies();
|
|
136
|
-
// Generate incoming calling message
|
|
137
|
-
const message_age_sec = 1;
|
|
138
|
-
const message_received_at_counter = 10;
|
|
139
|
-
const callId = new long_1.default(1, 1, true);
|
|
140
|
-
const offerCallingMessage = generateOfferCallingMessage(callId);
|
|
141
|
-
index_1.RingRTC.handleCallingMessage(user2_id, Buffer.from((0, Utils_1.uuidToBytes)(user2_id)), user2_device_id, user1_device_id, message_age_sec, message_received_at_counter, offerCallingMessage, user2_identity_key, user1_identity_key);
|
|
142
|
-
yield (0, Utils_1.sleep)(1000);
|
|
143
|
-
handleIncomingCallSpy.should.have.been.calledOnce;
|
|
144
|
-
chai_1.assert.equal(index_1.CallState.Prering, index_1.RingRTC.call.state);
|
|
145
|
-
// Hangup call
|
|
146
|
-
(0, chai_1.expect)(calling.hangup()).to.be.true;
|
|
147
|
-
yield (0, Utils_1.sleep)(500);
|
|
148
|
-
// Validate hangup related callbacks and call state
|
|
149
|
-
handleAutoEndedIncomingCallRequestSpy.should.have.been.calledOnce;
|
|
150
|
-
(0, chai_1.expect)(handleOutgoingSignalingSpy.callCount).to.be.gt(1);
|
|
151
|
-
chai_1.assert.equal(index_1.CallState.Ended, index_1.RingRTC.call.state);
|
|
152
|
-
}));
|
|
153
|
-
it('outgoing call wins glare when incoming call id is lower', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
154
|
-
const calling = new CallingClass_1.CallingClass(user1_name, user1_id);
|
|
155
|
-
calling.initialize();
|
|
156
|
-
initializeSpies();
|
|
157
|
-
yield runGlareScenario(calling, true, 0, 0);
|
|
158
|
-
}));
|
|
159
|
-
it('outgoing call wins glare when incoming call id is lower even when outgoing call settings are delayed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
160
|
-
const calling = new CallingClass_1.CallingClass(user1_name, user1_id);
|
|
161
|
-
calling.initialize();
|
|
162
|
-
initializeSpies();
|
|
163
|
-
yield runGlareScenario(calling, true, 0, 1000);
|
|
164
|
-
}));
|
|
165
|
-
it('outgoing call loses glare when incoming call id is higher even when outgoing call settings are delayed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
166
|
-
const calling = new CallingClass_1.CallingClass(user1_name, user1_id);
|
|
167
|
-
calling.initialize();
|
|
168
|
-
initializeSpies();
|
|
169
|
-
yield runGlareScenario(calling, false, 0, 1000);
|
|
170
|
-
}));
|
|
171
|
-
it('outgoing call loses glare when incoming call id is higher', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
172
|
-
const calling = new CallingClass_1.CallingClass(user1_name, user1_id);
|
|
173
|
-
calling.initialize();
|
|
174
|
-
initializeSpies();
|
|
175
|
-
yield runGlareScenario(calling, false, 0, 0);
|
|
176
|
-
}));
|
|
177
|
-
function runGlareScenario(calling, outgoingWinner, delayIncomingCallSetings, delayOutgoingCallSetings) {
|
|
178
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
-
calling.delayOutgoingCallSettingsRequest = delayOutgoingCallSetings;
|
|
180
|
-
calling.delayIncomingCallSettingsRequest = delayIncomingCallSetings;
|
|
181
|
-
const outgoingCallLatch = (0, Utils_1.countDownLatch)(1);
|
|
182
|
-
calling
|
|
183
|
-
.startOutgoingDirectCall(user2_id)
|
|
184
|
-
.then(_result => {
|
|
185
|
-
(0, Utils_1.log)('Outgoing call succeeded as expected');
|
|
186
|
-
outgoingCallLatch.countDown();
|
|
187
|
-
})
|
|
188
|
-
.catch(e => {
|
|
189
|
-
chai_1.assert.fail(`Outgoing call should not have failed: ${e}`);
|
|
190
|
-
});
|
|
191
|
-
yield outgoingCallLatch.finished;
|
|
192
|
-
const outgoingCallId = long_1.default.fromValue(index_1.RingRTC.call.callId);
|
|
193
|
-
// Generate a call id based on the desired glare winner
|
|
194
|
-
const incomingCallId = outgoingCallId.unsigned
|
|
195
|
-
? new long_1.default(outgoingWinner ? outgoingCallId.low - 1 : outgoingCallId.low + 1, outgoingCallId.high, outgoingCallId.unsigned)
|
|
196
|
-
: new long_1.default(outgoingWinner ? outgoingCallId.low + 1 : outgoingCallId.low - 1, outgoingCallId.high, outgoingCallId.unsigned);
|
|
197
|
-
// Generate incoming calling message
|
|
198
|
-
const message_age_sec = 1;
|
|
199
|
-
const message_received_at_counter = 10;
|
|
200
|
-
const offerCallingMessage = generateOfferCallingMessage(incomingCallId);
|
|
201
|
-
// Initiate an incoming call
|
|
202
|
-
index_1.RingRTC.handleCallingMessage(user2_id, Buffer.from((0, Utils_1.uuidToBytes)(user2_id)), user2_device_id, user1_device_id, message_age_sec, message_received_at_counter, offerCallingMessage, user2_identity_key, user1_identity_key);
|
|
203
|
-
yield (0, Utils_1.sleep)(1000);
|
|
204
|
-
if (outgoingWinner) {
|
|
205
|
-
chai_1.assert.isTrue(outgoingCallId.eq(long_1.default.fromValue(index_1.RingRTC.call.callId)));
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
chai_1.assert.isTrue(incomingCallId.eq(long_1.default.fromValue(index_1.RingRTC.call.callId)));
|
|
209
|
-
}
|
|
210
|
-
// Cleanup.
|
|
211
|
-
(0, chai_1.expect)(calling.hangup()).to.be.true;
|
|
212
|
-
yield (0, Utils_1.sleep)(500);
|
|
213
|
-
chai_1.assert.equal(index_1.CallState.Ended, index_1.RingRTC.call.state);
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
});
|
package/dist/test/Utils.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare function countDownLatch(count: number): {
|
|
2
|
-
countDown: () => void;
|
|
3
|
-
finished: Promise<void>;
|
|
4
|
-
};
|
|
5
|
-
export declare function log(line: string): void;
|
|
6
|
-
export declare function sleep(timeout: number): Promise<void>;
|
|
7
|
-
export declare function uuidToBytes(uuid: string): Uint8Array;
|
package/dist/test/Utils.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2023 Signal Messenger, LLC
|
|
4
|
-
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
|
-
//
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.uuidToBytes = exports.sleep = exports.log = exports.countDownLatch = void 0;
|
|
8
|
-
/* eslint-disable no-console */
|
|
9
|
-
const lodash_1 = require("lodash");
|
|
10
|
-
const chai_1 = require("chai");
|
|
11
|
-
function countDownLatch(count) {
|
|
12
|
-
(0, chai_1.assert)(count > 0, 'count must be a positive number');
|
|
13
|
-
let resolve;
|
|
14
|
-
const finished = new Promise(resolveInternal => {
|
|
15
|
-
resolve = resolveInternal;
|
|
16
|
-
});
|
|
17
|
-
const countDown = () => {
|
|
18
|
-
count--;
|
|
19
|
-
if (count == 0) {
|
|
20
|
-
resolve();
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
return {
|
|
24
|
-
countDown: countDown,
|
|
25
|
-
finished,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
exports.countDownLatch = countDownLatch;
|
|
29
|
-
function log(line) {
|
|
30
|
-
// Standard logging used for checkpoints.
|
|
31
|
-
// Use --renderer to see the log output. (edit: Maybe always shown now?)
|
|
32
|
-
// BgYellow
|
|
33
|
-
console.log(`\x1b[43m${line}\x1b[0m`);
|
|
34
|
-
}
|
|
35
|
-
exports.log = log;
|
|
36
|
-
function sleep(timeout) {
|
|
37
|
-
return new Promise(resolve => {
|
|
38
|
-
setTimeout(() => {
|
|
39
|
-
// BgBlue
|
|
40
|
-
console.log(`\x1b[44msleeping ${timeout} ms\x1b[0m`);
|
|
41
|
-
resolve();
|
|
42
|
-
}, timeout);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
exports.sleep = sleep;
|
|
46
|
-
function uuidToBytes(uuid) {
|
|
47
|
-
if (uuid.length !== 36) {
|
|
48
|
-
return new Uint8Array(0);
|
|
49
|
-
}
|
|
50
|
-
return Uint8Array.from((0, lodash_1.chunk)(uuid.replace(/-/g, ''), 2).map(pair => parseInt(pair.join(''), 16)));
|
|
51
|
-
}
|
|
52
|
-
exports.uuidToBytes = uuidToBytes;
|