@signalapp/ringrtc 2.25.1 → 2.26.0

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/package.json CHANGED
@@ -1,26 +1,29 @@
1
1
  {
2
2
  "name": "@signalapp/ringrtc",
3
- "version": "2.25.1",
3
+ "version": "2.26.0",
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
- "format": "prettier --write \"*.{css,js,json,md,scss,ts,tsx}\" \"./**/*.{css,js,json,md,scss,ts,tsx}\"",
20
+ "format": "prettier --write .",
18
21
  "install": "node scripts/fetch-prebuild.js",
19
22
  "prepublishOnly": "node scripts/prepublish.js"
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": "eea4b238619ac1c259b703d7c66a57b6436ea63496fff03a0dd407b410507700"
26
+ "prebuildChecksum": "1e55feb92467730da4b2481e390d4f6257b88e70dcd47c4feff27925f44443a3"
24
27
  },
25
28
  "author": "",
26
29
  "license": "AGPL-3.0-only",
@@ -35,7 +38,6 @@
35
38
  "@types/mocha": "10.0.1",
36
39
  "@types/node": "18.14.0",
37
40
  "@types/offscreencanvas": "^2019.7.0",
38
- "@types/react": "18.0.28",
39
41
  "@types/sinon-chai": "^3.2.9",
40
42
  "chai": "4.3.7",
41
43
  "chai-as-promised": "^7.1.1",
@@ -47,13 +49,13 @@
47
49
  "eslint-plugin-import": "2.27.5",
48
50
  "eslint-plugin-mocha": "10.1.0",
49
51
  "eslint-plugin-more": "1.0.5",
50
- "eslint-plugin-react": "7.32.2",
51
52
  "long": "5.2.1",
52
53
  "mocha": "10.2.0",
53
54
  "prettier": "^2.8.4",
54
55
  "rimraf": "4.1.2",
55
56
  "sinon": "^15.0.1",
56
57
  "sinon-chai": "^3.7.0",
58
+ "source-map-support": "^0.5.19",
57
59
  "typescript": "4.9.3",
58
60
  "yarn-audit-fix": "^9.3.9"
59
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,197 +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
- const Service_1 = require("../ringrtc/Service");
21
- const index_1 = require("../index");
22
- const long_1 = __importDefault(require("long"));
23
- const Utils_1 = require("./Utils");
24
- // This class mimics the Desktop Client CallingClass in ts/services/calling.ts to facilitate testing
25
- class CallingClass {
26
- set delayIncomingCallSettingsRequest(value) {
27
- this._delayIncomingCallSettingsRequest = value;
28
- }
29
- set delayOutgoingCallSettingsRequest(value) {
30
- this._delayIncomingCallSettingsRequest = value;
31
- }
32
- constructor(name, id) {
33
- this._name = name;
34
- this._id = id;
35
- this._localDeviceId = 1;
36
- this._delayIncomingCallSettingsRequest = 0;
37
- this._delayOutgoingCallSettingsRequest = 0;
38
- }
39
- setupCallCallbacks(call) {
40
- // eslint-disable-next-line no-param-reassign
41
- call.handleStateChanged = () => __awaiter(this, void 0, void 0, function* () {
42
- (0, Utils_1.log)('handleCallStateChanged');
43
- (0, Utils_1.log)(`call.state === ${call.state}`);
44
- if (call.state === Service_1.CallState.Ended) {
45
- (0, Utils_1.log)(`call.endedReason === ${call.endedReason}`);
46
- this._call = undefined;
47
- }
48
- });
49
- // eslint-disable-next-line no-param-reassign
50
- call.handleRemoteVideoEnabled = () => {
51
- (0, Utils_1.log)('handleRemoteVideoEnabled');
52
- };
53
- // eslint-disable-next-line no-param-reassign
54
- call.handleRemoteSharingScreen = () => {
55
- (0, Utils_1.log)('handleRemoteSharingScreen');
56
- };
57
- }
58
- ////////////////////////////////////////////////////////////////////////////////
59
- // Callbacks
60
- handleOutgoingSignaling(remoteUserId, message, urgency) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- (0, Utils_1.log)('handleOutgoingSignaling remoteUserId: ' + remoteUserId);
63
- return true;
64
- });
65
- }
66
- handleIncomingCall(call) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- (0, Utils_1.log)('handleIncomingCall');
69
- this._call = call;
70
- this.setupCallCallbacks(call);
71
- return true;
72
- });
73
- }
74
- handleStartCall(call) {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- const callSettings = yield this.getCallSettings(call.isIncoming);
77
- index_1.RingRTC.proceed(call.callId, callSettings);
78
- return true;
79
- });
80
- }
81
- handleAutoEndedIncomingCallRequest(callId, remoteUserId, reason, ageInSeconds, wasVideoCall, receivedAtCounter) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- (0, Utils_1.log)('handleAutoEndedIncomingCallRequest');
84
- });
85
- }
86
- handleLogMessage(level, fileName, line, message) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- switch (level) {
89
- case Service_1.CallLogLevel.Info:
90
- // FgGray
91
- console.log(`\x1b[90m${fileName}:${line} ${message}\x1b[0m`);
92
- break;
93
- case Service_1.CallLogLevel.Warn:
94
- // FgYellow
95
- console.warn(`\x1b[33m${fileName}:${line} ${message}\x1b[0m`);
96
- break;
97
- case Service_1.CallLogLevel.Error:
98
- // FgRed
99
- console.error(`\x1b[31m${fileName}:${line} ${message}\x1b[0m`);
100
- break;
101
- default:
102
- break;
103
- }
104
- });
105
- }
106
- handleSendHttpRequest(requestId, url, method, headers, body) {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- (0, Utils_1.log)('handleSendHttpRequest');
109
- });
110
- }
111
- handleSendCallMessage(recipient, data, urgency) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- (0, Utils_1.log)('handleSendCallMessage');
114
- return true;
115
- });
116
- }
117
- handleSendCallMessageToGroup(groupIdBytes, data, urgency) {
118
- return __awaiter(this, void 0, void 0, function* () {
119
- (0, Utils_1.log)('handleSendCallMessageToGroup');
120
- });
121
- }
122
- handleGroupCallRingUpdate(groupIdBytes, ringId, ringerBytes, update) {
123
- return __awaiter(this, void 0, void 0, function* () {
124
- (0, Utils_1.log)('handleGroupCallRingUpdate');
125
- });
126
- }
127
- ////////////////////////////////////////////////////////////////////////////////
128
- // Support
129
- getCallSettings(isIncoming) {
130
- return __awaiter(this, void 0, void 0, function* () {
131
- if (isIncoming) {
132
- (0, Utils_1.log)('getCallSettings delayed by ' +
133
- this._delayIncomingCallSettingsRequest.toString() +
134
- 'ms');
135
- yield (0, Utils_1.sleep)(this._delayIncomingCallSettingsRequest);
136
- }
137
- else {
138
- (0, Utils_1.log)('getCallSettings delayed by ' +
139
- this._delayOutgoingCallSettingsRequest.toString() +
140
- 'ms');
141
- yield (0, Utils_1.sleep)(this._delayOutgoingCallSettingsRequest);
142
- }
143
- return {
144
- iceServer: {
145
- urls: ['stun:turn3.voip.signal.org'],
146
- },
147
- hideIp: false,
148
- bandwidthMode: Service_1.BandwidthMode.Normal,
149
- };
150
- });
151
- }
152
- ////////////////////////////////////////////////////////////////////////////////
153
- // Actions
154
- initialize() {
155
- (0, Utils_1.log)('initialize');
156
- index_1.RingRTC.setConfig({
157
- use_new_audio_device_module: true,
158
- field_trials: undefined,
159
- });
160
- index_1.RingRTC.handleOutgoingSignaling = this.handleOutgoingSignaling.bind(this);
161
- index_1.RingRTC.handleIncomingCall = this.handleIncomingCall.bind(this);
162
- index_1.RingRTC.handleStartCall = this.handleStartCall.bind(this);
163
- index_1.RingRTC.handleAutoEndedIncomingCallRequest =
164
- this.handleAutoEndedIncomingCallRequest.bind(this);
165
- index_1.RingRTC.handleLogMessage = this.handleLogMessage.bind(this);
166
- index_1.RingRTC.handleSendHttpRequest = this.handleSendHttpRequest.bind(this);
167
- index_1.RingRTC.handleSendCallMessage = this.handleSendCallMessage.bind(this);
168
- index_1.RingRTC.handleSendCallMessageToGroup =
169
- this.handleSendCallMessageToGroup.bind(this);
170
- index_1.RingRTC.handleGroupCallRingUpdate =
171
- this.handleGroupCallRingUpdate.bind(this);
172
- index_1.RingRTC.setSelfUuid(Buffer.from((0, Utils_1.uuidToBytes)(this._id)));
173
- }
174
- startOutgoingDirectCall(remoteUserId) {
175
- return __awaiter(this, void 0, void 0, function* () {
176
- (0, Utils_1.log)('startOutgoingDirectCall');
177
- if (index_1.RingRTC.call && index_1.RingRTC.call.state !== Service_1.CallState.Ended) {
178
- (0, Utils_1.log)('Call already in progress, new call not allowed.');
179
- return;
180
- }
181
- const call = index_1.RingRTC.startOutgoingCall(remoteUserId, false, this._localDeviceId);
182
- (0, Utils_1.log)('Outgoing callId ' + long_1.default.fromValue(call.callId).toString());
183
- index_1.RingRTC.setOutgoingAudio(call.callId, true);
184
- this._call = call;
185
- this.setupCallCallbacks(call);
186
- });
187
- }
188
- hangup() {
189
- (0, Utils_1.log)('hangup');
190
- if (this._call) {
191
- index_1.RingRTC.hangup(this._call.callId);
192
- return true;
193
- }
194
- return false;
195
- }
196
- }
197
- exports.CallingClass = CallingClass;
@@ -1 +0,0 @@
1
- export {};
@@ -1,211 +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
- const chai_1 = require("chai");
20
- const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
21
- const crypto_1 = require("crypto");
22
- const index_1 = require("../index");
23
- const long_1 = __importDefault(require("long"));
24
- const chai_2 = require("chai");
25
- const sinon_1 = __importDefault(require("sinon"));
26
- const sinon_chai_1 = __importDefault(require("sinon-chai"));
27
- const CallingClass_1 = require("./CallingClass");
28
- const Utils_1 = require("./Utils");
29
- (0, chai_1.use)(chai_as_promised_1.default);
30
- (0, chai_2.should)();
31
- (0, chai_1.use)(sinon_chai_1.default);
32
- function generateOfferCallingMessage(callId) {
33
- // Audio-only hex based SDP generated from a direct client call
34
- const audioOnlySdp = Buffer.from('22560a204b18bc751315cb718c643db7b3a65aaabe826c7094932afaf5aebc86d36bb6491204484b6b481a18524b3041496f63334245514e5670424b57786f38787051712204082e1034220408281034220208082880897a', 'hex');
35
- return {
36
- offer: {
37
- callId: callId,
38
- opaque: audioOnlySdp,
39
- type: index_1.OfferType.AudioCall,
40
- },
41
- };
42
- }
43
- describe('RingRTC', () => {
44
- const identity_key_length = 31;
45
- const user1_name = 'user1';
46
- const user1_id = '11';
47
- const user1_device_id = 11;
48
- const user1_identity_key = (0, crypto_1.randomBytes)(identity_key_length);
49
- const user2_id = '22';
50
- const user2_device_id = 22;
51
- const user2_identity_key = (0, crypto_1.randomBytes)(identity_key_length);
52
- let handleOutgoingSignalingSpy;
53
- let handleIncomingCallSpy;
54
- let handleAutoEndedIncomingCallRequestSpy;
55
- it('reports an age for expired offers', () => __awaiter(void 0, void 0, void 0, function* () {
56
- const offer = {
57
- offer: {
58
- callId: { high: 0, low: 123 },
59
- type: index_1.OfferType.AudioCall,
60
- opaque: Buffer.from([]),
61
- },
62
- supportsMultiRing: true,
63
- };
64
- const age = 60 * 60;
65
- try {
66
- const { reason, ageSec: reportedAge } = yield new Promise((resolve, _reject) => {
67
- index_1.RingRTC.handleAutoEndedIncomingCallRequest = (_callId, _remoteUserId, reason, ageSec) => {
68
- resolve({ reason, ageSec });
69
- };
70
- index_1.RingRTC.handleCallingMessage('remote', null, 4, 2, age, 1, offer, Buffer.from([]), Buffer.from([]));
71
- });
72
- chai_1.assert.equal(reason, index_1.CallEndedReason.ReceivedOfferExpired);
73
- chai_1.assert.equal(reportedAge, age);
74
- }
75
- finally {
76
- index_1.RingRTC.handleAutoEndedIncomingCallRequest = null;
77
- }
78
- }));
79
- it('reports 0 as the age of other auto-ended offers', () => __awaiter(void 0, void 0, void 0, function* () {
80
- const offer = {
81
- offer: {
82
- callId: { high: 0, low: 123 },
83
- type: index_1.OfferType.AudioCall,
84
- opaque: Buffer.from([]),
85
- },
86
- supportsMultiRing: true,
87
- };
88
- try {
89
- const { reason, ageSec: reportedAge } = yield new Promise((resolve, _reject) => {
90
- index_1.RingRTC.handleAutoEndedIncomingCallRequest = (_callId, _remoteUserId, reason, ageSec) => {
91
- resolve({ reason, ageSec });
92
- };
93
- index_1.RingRTC.handleCallingMessage('remote', null, 4, 2, 10, 2, offer, Buffer.from([]), Buffer.from([]));
94
- });
95
- chai_1.assert.equal(reason, index_1.CallEndedReason.Declined); // because we didn't set handleIncomingCall.
96
- chai_1.assert.equal(reportedAge, 0);
97
- }
98
- finally {
99
- index_1.RingRTC.handleAutoEndedIncomingCallRequest = null;
100
- }
101
- }));
102
- function initializeSpies() {
103
- handleAutoEndedIncomingCallRequestSpy = sinon_1.default.spy(index_1.RingRTC, 'handleAutoEndedIncomingCallRequest');
104
- handleIncomingCallSpy = sinon_1.default.spy(index_1.RingRTC, 'handleIncomingCall');
105
- handleOutgoingSignalingSpy = sinon_1.default.spy(index_1.RingRTC, 'handleOutgoingSignaling');
106
- }
107
- it('can initialize RingRTC', () => {
108
- chai_1.assert.isNotNull(index_1.RingRTC, "RingRTC didn't initialize!");
109
- });
110
- it('can establish outgoing call', () => __awaiter(void 0, void 0, void 0, function* () {
111
- let calling = new CallingClass_1.CallingClass(user1_name, user1_id);
112
- calling.initialize();
113
- initializeSpies();
114
- yield calling.startOutgoingDirectCall(user2_id);
115
- yield (0, Utils_1.sleep)(1000);
116
- // An offer and at least one ICE message should have been sent.
117
- (0, chai_1.expect)(handleOutgoingSignalingSpy.callCount).to.be.gt(1);
118
- yield (0, Utils_1.sleep)(2000);
119
- // Cleanup.
120
- const handleStateChangedSpy = sinon_1.default.spy(index_1.RingRTC.call, 'handleStateChanged');
121
- (0, chai_1.expect)(calling.hangup()).to.be.true;
122
- yield (0, Utils_1.sleep)(500);
123
- handleStateChangedSpy.should.have.been.calledOnce;
124
- (0, chai_1.expect)(calling.hangup()).to.be.false;
125
- yield (0, Utils_1.sleep)(100);
126
- }));
127
- it('can establish incoming call', () => __awaiter(void 0, void 0, void 0, function* () {
128
- let calling = new CallingClass_1.CallingClass(user1_name, user1_id);
129
- calling.initialize();
130
- initializeSpies();
131
- // Generate incoming calling message
132
- const message_age_sec = 1;
133
- const message_received_at_counter = 10;
134
- const callId = new long_1.default(1, 1, true);
135
- const offerCallingMessage = generateOfferCallingMessage(callId);
136
- 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);
137
- yield (0, Utils_1.sleep)(1000);
138
- handleIncomingCallSpy.should.have.been.calledOnce;
139
- chai_1.assert.equal(index_1.CallState.Prering, index_1.RingRTC.call.state);
140
- // Hangup call
141
- (0, chai_1.expect)(calling.hangup()).to.be.true;
142
- yield (0, Utils_1.sleep)(500);
143
- // Validate hangup related callbacks and call state
144
- handleAutoEndedIncomingCallRequestSpy.should.have.been.calledOnce;
145
- (0, chai_1.expect)(handleOutgoingSignalingSpy.callCount).to.be.gt(1);
146
- chai_1.assert.equal(index_1.CallState.Ended, index_1.RingRTC.call.state);
147
- }));
148
- it('outgoing call wins glare when incoming call id is lower', () => __awaiter(void 0, void 0, void 0, function* () {
149
- let calling = new CallingClass_1.CallingClass(user1_name, user1_id);
150
- calling.initialize();
151
- initializeSpies();
152
- yield runGlareScenario(calling, true, 0, 0);
153
- }));
154
- 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* () {
155
- let calling = new CallingClass_1.CallingClass(user1_name, user1_id);
156
- calling.initialize();
157
- initializeSpies();
158
- yield runGlareScenario(calling, true, 0, 1000);
159
- }));
160
- 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* () {
161
- let calling = new CallingClass_1.CallingClass(user1_name, user1_id);
162
- calling.initialize();
163
- initializeSpies();
164
- yield runGlareScenario(calling, false, 0, 1000);
165
- }));
166
- it('outgoing call loses glare when incoming call id is higher', () => __awaiter(void 0, void 0, void 0, function* () {
167
- let calling = new CallingClass_1.CallingClass(user1_name, user1_id);
168
- calling.initialize();
169
- initializeSpies();
170
- yield runGlareScenario(calling, false, 0, 0);
171
- }));
172
- function runGlareScenario(calling, outgoingWinner, delayIncomingCallSetings, delayOutgoingCallSetings) {
173
- return __awaiter(this, void 0, void 0, function* () {
174
- calling.delayOutgoingCallSettingsRequest = delayOutgoingCallSetings;
175
- calling.delayIncomingCallSettingsRequest = delayIncomingCallSetings;
176
- const outgoingCallLatch = (0, Utils_1.countDownLatch)(1);
177
- calling
178
- .startOutgoingDirectCall(user2_id)
179
- .then(result => {
180
- (0, Utils_1.log)('Outgoing call succeeded as expected');
181
- outgoingCallLatch.countDown();
182
- })
183
- .catch(e => {
184
- chai_1.assert.fail('Outgoing call should not have failed');
185
- });
186
- yield outgoingCallLatch.finished;
187
- const outgoingCallId = long_1.default.fromValue(index_1.RingRTC.call.callId);
188
- // Generate a call id based on the desired glare winner
189
- const incomingCallId = outgoingCallId.unsigned
190
- ? new long_1.default(outgoingWinner ? outgoingCallId.low - 1 : outgoingCallId.low + 1, outgoingCallId.high, outgoingCallId.unsigned)
191
- : new long_1.default(outgoingWinner ? outgoingCallId.low + 1 : outgoingCallId.low - 1, outgoingCallId.high, outgoingCallId.unsigned);
192
- // Generate incoming calling message
193
- const message_age_sec = 1;
194
- const message_received_at_counter = 10;
195
- const offerCallingMessage = generateOfferCallingMessage(incomingCallId);
196
- // Initiate an incoming call
197
- 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);
198
- yield (0, Utils_1.sleep)(1000);
199
- if (outgoingWinner) {
200
- chai_1.assert.isTrue(outgoingCallId.eq(long_1.default.fromValue(index_1.RingRTC.call.callId)));
201
- }
202
- else {
203
- chai_1.assert.isTrue(incomingCallId.eq(long_1.default.fromValue(index_1.RingRTC.call.callId)));
204
- }
205
- // Cleanup.
206
- (0, chai_1.expect)(calling.hangup()).to.be.true;
207
- yield (0, Utils_1.sleep)(500);
208
- chai_1.assert.equal(index_1.CallState.Ended, index_1.RingRTC.call.state);
209
- });
210
- }
211
- });
@@ -1,7 +0,0 @@
1
- export declare function countDownLatch(count: number): {
2
- countDown: () => void;
3
- finished: Promise<unknown>;
4
- };
5
- export declare function log(line: string): void;
6
- export declare let sleep: (timeout: number) => Promise<void>;
7
- export declare function uuidToBytes(uuid: string): Uint8Array;
@@ -1,51 +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
- const lodash_1 = require("lodash");
9
- const chai_1 = require("chai");
10
- function countDownLatch(count) {
11
- (0, chai_1.assert)(count > 0, 'count must be a positive number');
12
- let resolve;
13
- const finished = new Promise(resolveInternal => {
14
- resolve = resolveInternal;
15
- });
16
- const countDown = () => {
17
- count--;
18
- if (count == 0) {
19
- resolve();
20
- }
21
- };
22
- return {
23
- countDown: countDown,
24
- finished,
25
- };
26
- }
27
- exports.countDownLatch = countDownLatch;
28
- function log(line) {
29
- // Standard logging used for checkpoints.
30
- // Use --renderer to see the log output. (edit: Maybe always shown now?)
31
- // BgYellow
32
- console.log(`\x1b[43m${line}\x1b[0m`);
33
- }
34
- exports.log = log;
35
- let sleep = (timeout) => {
36
- return new Promise(resolve => {
37
- setTimeout(() => {
38
- // BgBlue
39
- console.log(`\x1b[44msleeping ${timeout} ms\x1b[0m`);
40
- resolve();
41
- }, timeout);
42
- });
43
- };
44
- exports.sleep = sleep;
45
- function uuidToBytes(uuid) {
46
- if (uuid.length !== 36) {
47
- return new Uint8Array(0);
48
- }
49
- return Uint8Array.from((0, lodash_1.chunk)(uuid.replace(/-/g, ''), 2).map(pair => parseInt(pair.join(''), 16)));
50
- }
51
- exports.uuidToBytes = uuidToBytes;