ringcentral-softphone 1.1.3 → 1.1.5
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 +12 -26
- package/dist/cjs/call-session/inbound.d.ts +3 -3
- package/dist/cjs/call-session/inbound.js +7 -7
- package/dist/cjs/call-session/index.d.ts +3 -3
- package/dist/cjs/call-session/index.js +17 -17
- package/dist/cjs/call-session/outbound.d.ts +3 -3
- package/dist/cjs/call-session/outbound.js +7 -7
- package/dist/cjs/call-session/streamer.d.ts +1 -1
- package/dist/cjs/index.d.ts +5 -5
- package/dist/cjs/index.js +27 -29
- package/dist/cjs/sip-message/inbound/index.d.ts +1 -1
- package/dist/cjs/sip-message/inbound/index.js +5 -5
- package/dist/cjs/sip-message/index.d.ts +5 -5
- package/dist/cjs/sip-message/index.js +10 -10
- package/dist/cjs/sip-message/outbound/index.d.ts +1 -1
- package/dist/cjs/sip-message/outbound/index.js +2 -2
- package/dist/cjs/sip-message/outbound/request.d.ts +1 -1
- package/dist/cjs/sip-message/outbound/request.js +4 -4
- package/dist/cjs/sip-message/outbound/response.d.ts +2 -2
- package/dist/cjs/sip-message/outbound/response.js +4 -4
- package/dist/cjs/utils.d.ts +1 -1
- package/dist/esm/call-session/inbound.d.ts +3 -3
- package/dist/esm/call-session/inbound.js +3 -3
- package/dist/esm/call-session/index.d.ts +3 -3
- package/dist/esm/call-session/index.js +4 -4
- package/dist/esm/call-session/outbound.d.ts +3 -3
- package/dist/esm/call-session/outbound.js +3 -3
- package/dist/esm/call-session/streamer.d.ts +1 -1
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +7 -9
- package/dist/esm/sip-message/inbound/index.d.ts +1 -1
- package/dist/esm/sip-message/inbound/index.js +2 -2
- package/dist/esm/sip-message/index.d.ts +5 -5
- package/dist/esm/sip-message/index.js +5 -5
- package/dist/esm/sip-message/outbound/index.d.ts +1 -1
- package/dist/esm/sip-message/outbound/index.js +1 -1
- package/dist/esm/sip-message/outbound/request.d.ts +1 -1
- package/dist/esm/sip-message/outbound/request.js +2 -2
- package/dist/esm/sip-message/outbound/response.d.ts +2 -2
- package/dist/esm/sip-message/outbound/response.js +2 -2
- package/dist/esm/utils.d.ts +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -57,31 +57,6 @@ The credentials data returned by that API is like this:
|
|
|
57
57
|
"proxy": "sip71.ringcentral.com:5090",
|
|
58
58
|
"proxyTLS": "sip71.ringcentral.com:5096"
|
|
59
59
|
},
|
|
60
|
-
{
|
|
61
|
-
"region": "APAC",
|
|
62
|
-
"proxy": "sip60.ringcentral.com:5090",
|
|
63
|
-
"proxyTLS": "sip60.ringcentral.com:5096"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"region": "EMEA",
|
|
67
|
-
"proxy": "sip30.ringcentral.com:5090",
|
|
68
|
-
"proxyTLS": "sip30.ringcentral.com:5096"
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"region": "APAC",
|
|
72
|
-
"proxy": "sip70.ringcentral.com:5090",
|
|
73
|
-
"proxyTLS": "sip70.ringcentral.com:5096"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"region": "APAC",
|
|
77
|
-
"proxy": "sip50.ringcentral.com:5090",
|
|
78
|
-
"proxyTLS": "sip50.ringcentral.com:5096"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
"region": "NA",
|
|
82
|
-
"proxy": "SIP10.ringcentral.com:5090",
|
|
83
|
-
"proxyTLS": "sip10.ringcentral.com:5096"
|
|
84
|
-
},
|
|
85
60
|
{
|
|
86
61
|
"region": "NA",
|
|
87
62
|
"proxy": "SIP20.ringcentral.com:5090",
|
|
@@ -92,6 +67,7 @@ The credentials data returned by that API is like this:
|
|
|
92
67
|
"proxy": "sip80.ringcentral.com:5090",
|
|
93
68
|
"proxyTLS": "sip80.ringcentral.com:5096"
|
|
94
69
|
}
|
|
70
|
+
...
|
|
95
71
|
],
|
|
96
72
|
"userName": "16501234567",
|
|
97
73
|
"password": "password",
|
|
@@ -260,6 +236,16 @@ callSession1.on("rtpPacket", (rtpPacket: RtpPacket) => {
|
|
|
260
236
|
});
|
|
261
237
|
```
|
|
262
238
|
|
|
239
|
+
## Telephony Session ID
|
|
240
|
+
|
|
241
|
+
For outbound calls, you will be able to find header like this
|
|
242
|
+
`p-rc-api-ids: party-id=p-a0d17e323f0fez1953f50f90dz296e3440000-1;session-id=s-a0d17e323f0fez1953f50f90dz296e3440000`
|
|
243
|
+
from `callSession.sipMessage.headers`.
|
|
244
|
+
|
|
245
|
+
However, for inbound calls, the server doesn't tell us anything about the
|
|
246
|
+
Telephony Session ID. Here is a workaround solution:
|
|
247
|
+
https://github.com/tylerlong/rc-softphone-call-id-test
|
|
248
|
+
|
|
263
249
|
---
|
|
264
250
|
|
|
265
251
|
## Dev Notes
|
|
@@ -276,4 +262,4 @@ Content below is for the maintainer/contributor of this SDK.
|
|
|
276
262
|
|
|
277
263
|
#### Code style
|
|
278
264
|
|
|
279
|
-
We use `deno fmt` to format all code.
|
|
265
|
+
We use `deno fmt && deno lint --fix` to format and lint all code.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import CallSession from "./index";
|
|
2
|
-
import { type InboundMessage } from "../sip-message/index";
|
|
3
|
-
import type Softphone from "../index";
|
|
1
|
+
import CallSession from "./index.js";
|
|
2
|
+
import { type InboundMessage } from "../sip-message/index.js";
|
|
3
|
+
import type Softphone from "../index.js";
|
|
4
4
|
declare class InboundCallSession extends CallSession {
|
|
5
5
|
constructor(softphone: Softphone, inviteMessage: InboundMessage);
|
|
6
6
|
answer(): Promise<void>;
|
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
class InboundCallSession extends
|
|
6
|
+
const index_js_1 = __importDefault(require("./index.js"));
|
|
7
|
+
const index_js_2 = require("../sip-message/index.js");
|
|
8
|
+
const utils_js_1 = require("../utils.js");
|
|
9
|
+
class InboundCallSession extends index_js_1.default {
|
|
10
10
|
constructor(softphone, inviteMessage) {
|
|
11
11
|
super(softphone, inviteMessage);
|
|
12
12
|
this.localPeer = inviteMessage.headers.To;
|
|
@@ -20,14 +20,14 @@ o=- ${Date.now()} 0 IN IP4 ${this.softphone.client.localAddress}
|
|
|
20
20
|
s=rc-softphone-ts
|
|
21
21
|
c=IN IP4 ${this.softphone.client.localAddress}
|
|
22
22
|
t=0 0
|
|
23
|
-
m=audio ${(0,
|
|
23
|
+
m=audio ${(0, utils_js_1.randomInt)()} RTP/SAVP ${this.softphone.codec.id} 101
|
|
24
24
|
a=rtpmap:${this.softphone.codec.id} ${this.softphone.codec.name}
|
|
25
25
|
a=rtpmap:101 telephone-event/8000
|
|
26
26
|
a=fmtp:101 0-15
|
|
27
27
|
a=sendrecv
|
|
28
|
-
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${
|
|
28
|
+
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${utils_js_1.localKey}
|
|
29
29
|
`.trim();
|
|
30
|
-
const newMessage = new
|
|
30
|
+
const newMessage = new index_js_2.OutboundMessage("SIP/2.0 200 OK", {
|
|
31
31
|
Via: this.sipMessage.headers.Via,
|
|
32
32
|
"Call-ID": this.sipMessage.headers["Call-ID"],
|
|
33
33
|
From: this.sipMessage.headers.From,
|
|
@@ -2,9 +2,9 @@ import dgram from "node:dgram";
|
|
|
2
2
|
import EventEmitter from "node:events";
|
|
3
3
|
import { Buffer } from "node:buffer";
|
|
4
4
|
import { RtpPacket, SrtpSession } from "werift-rtp";
|
|
5
|
-
import { type InboundMessage } from "../sip-message/index";
|
|
6
|
-
import type Softphone from "../index";
|
|
7
|
-
import Streamer from "./streamer";
|
|
5
|
+
import { type InboundMessage } from "../sip-message/index.js";
|
|
6
|
+
import type Softphone from "../index.js";
|
|
7
|
+
import Streamer from "./streamer.js";
|
|
8
8
|
declare abstract class CallSession extends EventEmitter {
|
|
9
9
|
softphone: Softphone;
|
|
10
10
|
sipMessage: InboundMessage;
|
|
@@ -7,10 +7,10 @@ const node_dgram_1 = __importDefault(require("node:dgram"));
|
|
|
7
7
|
const node_events_1 = __importDefault(require("node:events"));
|
|
8
8
|
const node_buffer_1 = require("node:buffer");
|
|
9
9
|
const werift_rtp_1 = require("werift-rtp");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
10
|
+
const dtmf_js_1 = __importDefault(require("../dtmf.js"));
|
|
11
|
+
const index_js_1 = require("../sip-message/index.js");
|
|
12
|
+
const utils_js_1 = require("../utils.js");
|
|
13
|
+
const streamer_js_1 = __importDefault(require("./streamer.js"));
|
|
14
14
|
class CallSession extends node_events_1.default {
|
|
15
15
|
softphone;
|
|
16
16
|
sipMessage;
|
|
@@ -24,9 +24,9 @@ class CallSession extends node_events_1.default {
|
|
|
24
24
|
encoder;
|
|
25
25
|
decoder;
|
|
26
26
|
// for audio streaming
|
|
27
|
-
ssrc = (0,
|
|
28
|
-
sequenceNumber = (0,
|
|
29
|
-
timestamp = (0,
|
|
27
|
+
ssrc = (0, utils_js_1.randomInt)();
|
|
28
|
+
sequenceNumber = (0, utils_js_1.randomInt)();
|
|
29
|
+
timestamp = (0, utils_js_1.randomInt)();
|
|
30
30
|
constructor(softphone, sipMessage) {
|
|
31
31
|
super();
|
|
32
32
|
this.softphone = softphone;
|
|
@@ -37,7 +37,7 @@ class CallSession extends node_events_1.default {
|
|
|
37
37
|
this.remotePort = parseInt(this.sipMessage.body.match(/m=audio (\d+) /)[1], 10);
|
|
38
38
|
}
|
|
39
39
|
set remoteKey(key) {
|
|
40
|
-
const localKeyBuffer = node_buffer_1.Buffer.from(
|
|
40
|
+
const localKeyBuffer = node_buffer_1.Buffer.from(utils_js_1.localKey, "base64");
|
|
41
41
|
const remoteKeyBuffer = node_buffer_1.Buffer.from(key, "base64");
|
|
42
42
|
this.srtpSession = new werift_rtp_1.SrtpSession({
|
|
43
43
|
profile: 0x0001,
|
|
@@ -56,11 +56,11 @@ class CallSession extends node_events_1.default {
|
|
|
56
56
|
this.socket.send(data, this.remotePort, this.remoteIP);
|
|
57
57
|
}
|
|
58
58
|
async hangup() {
|
|
59
|
-
const requestMessage = new
|
|
59
|
+
const requestMessage = new index_js_1.RequestMessage(`BYE sip:${this.softphone.sipInfo.domain} SIP/2.0`, {
|
|
60
60
|
"Call-ID": this.callId,
|
|
61
61
|
From: this.localPeer,
|
|
62
62
|
To: this.remotePeer,
|
|
63
|
-
Via: `SIP/2.0/TLS ${this.softphone.fakeDomain};branch=${(0,
|
|
63
|
+
Via: `SIP/2.0/TLS ${this.softphone.fakeDomain};branch=${(0, utils_js_1.branch)()}`,
|
|
64
64
|
});
|
|
65
65
|
await this.softphone.send(requestMessage);
|
|
66
66
|
}
|
|
@@ -77,14 +77,14 @@ class CallSession extends node_events_1.default {
|
|
|
77
77
|
payloadType: 101,
|
|
78
78
|
sequenceNumber,
|
|
79
79
|
timestamp,
|
|
80
|
-
ssrc: (0,
|
|
80
|
+
ssrc: (0, utils_js_1.randomInt)(),
|
|
81
81
|
csrcLength: 0,
|
|
82
82
|
csrc: [],
|
|
83
83
|
extensionProfile: 48862,
|
|
84
84
|
extensionLength: undefined,
|
|
85
85
|
extensions: [],
|
|
86
86
|
});
|
|
87
|
-
for (const payload of
|
|
87
|
+
for (const payload of dtmf_js_1.default.charToPayloads(char)) {
|
|
88
88
|
rtpHeader.sequenceNumber = sequenceNumber++;
|
|
89
89
|
const rtpPacket = new werift_rtp_1.RtpPacket(rtpHeader, payload);
|
|
90
90
|
this.send(this.srtpSession.encrypt(rtpPacket.payload, rtpPacket.header));
|
|
@@ -93,7 +93,7 @@ class CallSession extends node_events_1.default {
|
|
|
93
93
|
// buffer is the content of a audio file, it is supposed to be uncompressed PCM data
|
|
94
94
|
// The audio should be playable by command: play -t raw -b 16 -r 16000 -e signed-integer test.wav
|
|
95
95
|
streamAudio(input) {
|
|
96
|
-
const streamer = new
|
|
96
|
+
const streamer = new streamer_js_1.default(this, input);
|
|
97
97
|
streamer.start();
|
|
98
98
|
return streamer;
|
|
99
99
|
}
|
|
@@ -111,7 +111,7 @@ class CallSession extends node_events_1.default {
|
|
|
111
111
|
this.emit("rtpPacket", rtpPacket);
|
|
112
112
|
if (rtpPacket.header.payloadType === 101) {
|
|
113
113
|
this.emit("dtmfPacket", rtpPacket);
|
|
114
|
-
const char =
|
|
114
|
+
const char = dtmf_js_1.default.payloadToChar(rtpPacket.payload);
|
|
115
115
|
if (char) {
|
|
116
116
|
this.emit("dtmf", char);
|
|
117
117
|
}
|
|
@@ -161,8 +161,8 @@ class CallSession extends node_events_1.default {
|
|
|
161
161
|
this.socket?.close();
|
|
162
162
|
}
|
|
163
163
|
transfer(transferTo) {
|
|
164
|
-
const requestMessage = new
|
|
165
|
-
Via: `SIP/2.0/TLS ${this.softphone.client.localAddress}:${this.softphone.client.localPort};rport;branch=${(0,
|
|
164
|
+
const requestMessage = new index_js_1.RequestMessage(`REFER sip:${this.softphone.sipInfo.username}@${this.softphone.sipInfo.outboundProxy};transport=tls SIP/2.0`, {
|
|
165
|
+
Via: `SIP/2.0/TLS ${this.softphone.client.localAddress}:${this.softphone.client.localPort};rport;branch=${(0, utils_js_1.branch)()};alias`,
|
|
166
166
|
"Max-Forwards": 70,
|
|
167
167
|
From: this.localPeer,
|
|
168
168
|
To: this.remotePeer,
|
|
@@ -182,7 +182,7 @@ class CallSession extends node_events_1.default {
|
|
|
182
182
|
if (!inboundMessage.subject.startsWith("NOTIFY ")) {
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
|
-
const responseMessage = new
|
|
185
|
+
const responseMessage = new index_js_1.ResponseMessage(inboundMessage, 200);
|
|
186
186
|
this.softphone.send(responseMessage);
|
|
187
187
|
if (inboundMessage.body.trim() === "SIP/2.0 200 OK") {
|
|
188
188
|
this.softphone.off("message", notifyHandler);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import CallSession from "./index";
|
|
2
|
-
import { type InboundMessage } from "../sip-message/index";
|
|
3
|
-
import type Softphone from "../index";
|
|
1
|
+
import CallSession from "./index.js";
|
|
2
|
+
import { type InboundMessage } from "../sip-message/index.js";
|
|
3
|
+
import type Softphone from "../index.js";
|
|
4
4
|
declare class OutboundCallSession extends CallSession {
|
|
5
5
|
constructor(softphone: Softphone, answerMessage: InboundMessage);
|
|
6
6
|
init(): void;
|
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
class OutboundCallSession extends
|
|
6
|
+
const index_js_1 = __importDefault(require("./index.js"));
|
|
7
|
+
const index_js_2 = require("../sip-message/index.js");
|
|
8
|
+
const utils_js_1 = require("../utils.js");
|
|
9
|
+
class OutboundCallSession extends index_js_1.default {
|
|
10
10
|
constructor(softphone, answerMessage) {
|
|
11
11
|
super(softphone, answerMessage);
|
|
12
12
|
this.localPeer = answerMessage.headers.From;
|
|
@@ -29,7 +29,7 @@ class OutboundCallSession extends index_1.default {
|
|
|
29
29
|
if (message.subject.startsWith("SIP/2.0 200")) {
|
|
30
30
|
this.softphone.off("message", answerHandler);
|
|
31
31
|
this.emit("answered");
|
|
32
|
-
const ackMessage = new
|
|
32
|
+
const ackMessage = new index_js_2.RequestMessage(`ACK ${(0, utils_js_1.extractAddress)(this.remotePeer)} SIP/2.0`, {
|
|
33
33
|
"Call-ID": this.callId,
|
|
34
34
|
From: this.localPeer,
|
|
35
35
|
To: this.remotePeer,
|
|
@@ -43,10 +43,10 @@ class OutboundCallSession extends index_1.default {
|
|
|
43
43
|
this.once("answered", () => this.startLocalServices());
|
|
44
44
|
}
|
|
45
45
|
async cancel() {
|
|
46
|
-
const requestMessage = new
|
|
46
|
+
const requestMessage = new index_js_2.RequestMessage(`CANCEL ${(0, utils_js_1.extractAddress)(this.remotePeer)} SIP/2.0`, {
|
|
47
47
|
"Call-ID": this.callId,
|
|
48
48
|
From: this.localPeer,
|
|
49
|
-
To: (0,
|
|
49
|
+
To: (0, utils_js_1.withoutTag)(this.remotePeer),
|
|
50
50
|
Via: this.sipMessage.headers.Via,
|
|
51
51
|
CSeq: this.sipMessage.headers.CSeq.replace(" INVITE", " CANCEL"),
|
|
52
52
|
});
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import EventEmitter from "node:events";
|
|
2
2
|
import { TLSSocket } from "node:tls";
|
|
3
|
-
import InboundCallSession from "./call-session/inbound";
|
|
4
|
-
import OutboundCallSession from "./call-session/outbound";
|
|
5
|
-
import { InboundMessage, OutboundMessage } from "./sip-message/index";
|
|
6
|
-
import { SoftPhoneOptions } from "./types";
|
|
7
|
-
import Codec from "./codec";
|
|
3
|
+
import InboundCallSession from "./call-session/inbound.js";
|
|
4
|
+
import OutboundCallSession from "./call-session/outbound.js";
|
|
5
|
+
import { InboundMessage, OutboundMessage } from "./sip-message/index.js";
|
|
6
|
+
import { SoftPhoneOptions } from "./types.js";
|
|
7
|
+
import Codec from "./codec.js";
|
|
8
8
|
declare class Softphone extends EventEmitter {
|
|
9
9
|
sipInfo: SoftPhoneOptions;
|
|
10
10
|
client: TLSSocket;
|
package/dist/cjs/index.js
CHANGED
|
@@ -6,17 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_events_1 = __importDefault(require("node:events"));
|
|
7
7
|
const node_tls_1 = __importDefault(require("node:tls"));
|
|
8
8
|
const wait_for_async_1 = __importDefault(require("wait-for-async"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
9
|
+
const inbound_js_1 = __importDefault(require("./call-session/inbound.js"));
|
|
10
|
+
const outbound_js_1 = __importDefault(require("./call-session/outbound.js"));
|
|
11
|
+
const index_js_1 = require("./sip-message/index.js");
|
|
12
|
+
const utils_js_1 = require("./utils.js");
|
|
13
|
+
const codec_js_1 = __importDefault(require("./codec.js"));
|
|
14
14
|
class Softphone extends node_events_1.default {
|
|
15
15
|
sipInfo;
|
|
16
16
|
client;
|
|
17
17
|
codec;
|
|
18
|
-
fakeDomain = (0,
|
|
19
|
-
fakeEmail = (0,
|
|
18
|
+
fakeDomain = (0, utils_js_1.uuid)() + ".invalid";
|
|
19
|
+
fakeEmail = (0, utils_js_1.uuid)() + "@" + this.fakeDomain;
|
|
20
20
|
intervalHandle;
|
|
21
21
|
connected = false;
|
|
22
22
|
constructor(sipInfo) {
|
|
@@ -24,7 +24,7 @@ class Softphone extends node_events_1.default {
|
|
|
24
24
|
if (sipInfo.codec === undefined) {
|
|
25
25
|
sipInfo.codec = "OPUS/16000";
|
|
26
26
|
}
|
|
27
|
-
this.codec = new
|
|
27
|
+
this.codec = new codec_js_1.default(sipInfo.codec);
|
|
28
28
|
this.sipInfo = sipInfo;
|
|
29
29
|
if (this.sipInfo.domain === undefined) {
|
|
30
30
|
this.sipInfo.domain = "sip.ringcentral.com";
|
|
@@ -53,28 +53,26 @@ class Softphone extends node_events_1.default {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
for (const message of tempMessages) {
|
|
56
|
-
this.emit("message",
|
|
56
|
+
this.emit("message", index_js_1.InboundMessage.fromString(message));
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
instanceId = (0,
|
|
61
|
-
registerCallId = (0,
|
|
60
|
+
instanceId = (0, utils_js_1.uuid)();
|
|
61
|
+
registerCallId = (0, utils_js_1.uuid)();
|
|
62
62
|
async register() {
|
|
63
63
|
if (!this.connected) {
|
|
64
64
|
await (0, wait_for_async_1.default)({ interval: 100, condition: () => this.connected });
|
|
65
65
|
}
|
|
66
66
|
const sipRegister = async () => {
|
|
67
|
-
const fromTag = (0,
|
|
68
|
-
const requestMessage = new
|
|
69
|
-
Via: `SIP/2.0/TLS ${this.client.localAddress}:${this.client.localPort};rport;branch=${(0,
|
|
70
|
-
Route: `<sip:${this.sipInfo.outboundProxy};transport=tls;lr>`,
|
|
67
|
+
const fromTag = (0, utils_js_1.uuid)();
|
|
68
|
+
const requestMessage = new index_js_1.RequestMessage(`REGISTER sip:${this.sipInfo.domain} SIP/2.0`, {
|
|
69
|
+
Via: `SIP/2.0/TLS ${this.client.localAddress}:${this.client.localPort};rport;branch=${(0, utils_js_1.branch)()};alias`,
|
|
71
70
|
"Max-Forwards": "70",
|
|
72
71
|
From: `<sip:${this.sipInfo.username}@${this.sipInfo.domain}>;tag=${fromTag}`,
|
|
73
72
|
To: `<sip:${this.sipInfo.username}@${this.sipInfo.domain}>`,
|
|
74
73
|
"Call-ID": this.registerCallId,
|
|
75
|
-
Supported: "outbound, path",
|
|
76
74
|
Contact: `<sip:${this.sipInfo.username}@${this.client.localAddress}:${this.client.localPort};transport=TLS;ob>;reg-id=1;+sip.instance="<urn:uuid:${this.instanceId}>"`,
|
|
77
|
-
Expires:
|
|
75
|
+
Expires: 3600,
|
|
78
76
|
Allow: "PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS",
|
|
79
77
|
});
|
|
80
78
|
const inboundMessage = await this.send(requestMessage, true);
|
|
@@ -86,7 +84,7 @@ class Softphone extends node_events_1.default {
|
|
|
86
84
|
inboundMessage.headers["WWW-Authenticate"];
|
|
87
85
|
const nonce = wwwAuth.match(/, nonce="(.+?)"/)[1];
|
|
88
86
|
const newMessage = requestMessage.fork();
|
|
89
|
-
newMessage.headers.Authorization = (0,
|
|
87
|
+
newMessage.headers.Authorization = (0, utils_js_1.generateAuthorization)(this.sipInfo, nonce, "REGISTER");
|
|
90
88
|
this.send(newMessage);
|
|
91
89
|
};
|
|
92
90
|
sipRegister();
|
|
@@ -97,7 +95,7 @@ class Softphone extends node_events_1.default {
|
|
|
97
95
|
if (!inboundMessage.subject.startsWith("INVITE sip:")) {
|
|
98
96
|
return;
|
|
99
97
|
}
|
|
100
|
-
const outboundMessage = new
|
|
98
|
+
const outboundMessage = new index_js_1.OutboundMessage("SIP/2.0 100 Trying", {
|
|
101
99
|
Via: inboundMessage.headers.Via,
|
|
102
100
|
"Call-ID": inboundMessage.headers["Call-ID"],
|
|
103
101
|
From: inboundMessage.headers.From,
|
|
@@ -145,13 +143,13 @@ class Softphone extends node_events_1.default {
|
|
|
145
143
|
});
|
|
146
144
|
}
|
|
147
145
|
async answer(inviteMessage) {
|
|
148
|
-
const inboundCallSession = new
|
|
146
|
+
const inboundCallSession = new inbound_js_1.default(this, inviteMessage);
|
|
149
147
|
await inboundCallSession.answer();
|
|
150
148
|
return inboundCallSession;
|
|
151
149
|
}
|
|
152
150
|
// decline an inbound call
|
|
153
151
|
async decline(inviteMessage) {
|
|
154
|
-
const newMessage = new
|
|
152
|
+
const newMessage = new index_js_1.ResponseMessage(inviteMessage, 603);
|
|
155
153
|
await this.send(newMessage);
|
|
156
154
|
}
|
|
157
155
|
async call(callee) {
|
|
@@ -161,20 +159,20 @@ o=- ${Date.now()} 0 IN IP4 ${this.client.localAddress}
|
|
|
161
159
|
s=rc-softphone-ts
|
|
162
160
|
c=IN IP4 ${this.client.localAddress}
|
|
163
161
|
t=0 0
|
|
164
|
-
m=audio ${(0,
|
|
162
|
+
m=audio ${(0, utils_js_1.randomInt)()} RTP/SAVP ${this.codec.id} 101
|
|
165
163
|
a=rtpmap:${this.codec.id} ${this.codec.name}
|
|
166
164
|
a=rtpmap:101 telephone-event/8000
|
|
167
165
|
a=fmtp:101 0-15
|
|
168
166
|
a=sendrecv
|
|
169
|
-
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${
|
|
167
|
+
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${utils_js_1.localKey}
|
|
170
168
|
`.trim();
|
|
171
|
-
const inviteMessage = new
|
|
172
|
-
Via: `SIP/2.0/TLS ${this.client.localAddress}:${this.client.localPort};rport;branch=${(0,
|
|
169
|
+
const inviteMessage = new index_js_1.RequestMessage(`INVITE sip:${callee}@${this.sipInfo.domain} SIP/2.0`, {
|
|
170
|
+
Via: `SIP/2.0/TLS ${this.client.localAddress}:${this.client.localPort};rport;branch=${(0, utils_js_1.branch)()};alias`,
|
|
173
171
|
"Max-Forwards": 70,
|
|
174
|
-
From: `<sip:${this.sipInfo.username}@${this.sipInfo.domain}>;tag=${(0,
|
|
172
|
+
From: `<sip:${this.sipInfo.username}@${this.sipInfo.domain}>;tag=${(0, utils_js_1.uuid)()}`,
|
|
175
173
|
To: `<sip:${callee}@sip.ringcentral.com>`,
|
|
176
174
|
Contact: ` <sip:${this.sipInfo.username}@${this.client.localAddress}:${this.client.localPort};transport=TLS;ob>`,
|
|
177
|
-
"Call-ID": (0,
|
|
175
|
+
"Call-ID": (0, utils_js_1.uuid)(),
|
|
178
176
|
Route: `<sip:${this.sipInfo.outboundProxy};transport=tls;lr>`,
|
|
179
177
|
Allow: `PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS`,
|
|
180
178
|
Supported: `replaces, 100rel, timer, norefersub`,
|
|
@@ -186,9 +184,9 @@ a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${utils_1.localKey}
|
|
|
186
184
|
const proxyAuthenticate = inboundMessage.headers["Proxy-Authenticate"];
|
|
187
185
|
const nonce = proxyAuthenticate.match(/, nonce="(.+?)"/)[1];
|
|
188
186
|
const newMessage = inviteMessage.fork();
|
|
189
|
-
newMessage.headers["Proxy-Authorization"] = (0,
|
|
187
|
+
newMessage.headers["Proxy-Authorization"] = (0, utils_js_1.generateAuthorization)(this.sipInfo, nonce, "INVITE");
|
|
190
188
|
const progressMessage = await this.send(newMessage, true);
|
|
191
|
-
return new
|
|
189
|
+
return new outbound_js_1.default(this, progressMessage);
|
|
192
190
|
}
|
|
193
191
|
}
|
|
194
192
|
exports.default = Softphone;
|
|
@@ -3,18 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
class InboundMessage extends
|
|
6
|
+
const utils_js_1 = require("../../utils.js");
|
|
7
|
+
const sip_message_js_1 = __importDefault(require("../sip-message.js"));
|
|
8
|
+
class InboundMessage extends sip_message_js_1.default {
|
|
9
9
|
static fromString(str) {
|
|
10
|
-
const sipMessage = new
|
|
10
|
+
const sipMessage = new sip_message_js_1.default();
|
|
11
11
|
const [init, ...body] = str.split("\r\n\r\n");
|
|
12
12
|
sipMessage.body = body.join("\r\n\r\n");
|
|
13
13
|
const [subject, ...headers] = init.split("\r\n");
|
|
14
14
|
sipMessage.subject = subject;
|
|
15
15
|
sipMessage.headers = Object.fromEntries(headers.map((line) => line.split(": ")));
|
|
16
16
|
if (sipMessage.headers.To && !sipMessage.headers.To.includes(";tag=")) {
|
|
17
|
-
sipMessage.headers.To += ";tag=" + (0,
|
|
17
|
+
sipMessage.headers.To += ";tag=" + (0, utils_js_1.uuid)(); // generate local tag
|
|
18
18
|
}
|
|
19
19
|
return sipMessage;
|
|
20
20
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { default as RequestMessage } from "./outbound/request";
|
|
2
|
-
export { default as ResponseMessage } from "./outbound/response";
|
|
3
|
-
export { default as OutboundMessage } from "./outbound/index";
|
|
4
|
-
export { default as InboundMessage } from "./inbound/index";
|
|
5
|
-
export { default as SipMessage } from "./sip-message";
|
|
1
|
+
export { default as RequestMessage } from "./outbound/request.js";
|
|
2
|
+
export { default as ResponseMessage } from "./outbound/response.js";
|
|
3
|
+
export { default as OutboundMessage } from "./outbound/index.js";
|
|
4
|
+
export { default as InboundMessage } from "./inbound/index.js";
|
|
5
|
+
export { default as SipMessage } from "./sip-message.js";
|
|
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SipMessage = exports.InboundMessage = exports.OutboundMessage = exports.ResponseMessage = exports.RequestMessage = void 0;
|
|
7
|
-
var
|
|
8
|
-
Object.defineProperty(exports, "RequestMessage", { enumerable: true, get: function () { return __importDefault(
|
|
9
|
-
var
|
|
10
|
-
Object.defineProperty(exports, "ResponseMessage", { enumerable: true, get: function () { return __importDefault(
|
|
11
|
-
var
|
|
12
|
-
Object.defineProperty(exports, "OutboundMessage", { enumerable: true, get: function () { return __importDefault(
|
|
13
|
-
var
|
|
14
|
-
Object.defineProperty(exports, "InboundMessage", { enumerable: true, get: function () { return __importDefault(
|
|
15
|
-
var
|
|
16
|
-
Object.defineProperty(exports, "SipMessage", { enumerable: true, get: function () { return __importDefault(
|
|
7
|
+
var request_js_1 = require("./outbound/request.js");
|
|
8
|
+
Object.defineProperty(exports, "RequestMessage", { enumerable: true, get: function () { return __importDefault(request_js_1).default; } });
|
|
9
|
+
var response_js_1 = require("./outbound/response.js");
|
|
10
|
+
Object.defineProperty(exports, "ResponseMessage", { enumerable: true, get: function () { return __importDefault(response_js_1).default; } });
|
|
11
|
+
var index_js_1 = require("./outbound/index.js");
|
|
12
|
+
Object.defineProperty(exports, "OutboundMessage", { enumerable: true, get: function () { return __importDefault(index_js_1).default; } });
|
|
13
|
+
var index_js_2 = require("./inbound/index.js");
|
|
14
|
+
Object.defineProperty(exports, "InboundMessage", { enumerable: true, get: function () { return __importDefault(index_js_2).default; } });
|
|
15
|
+
var sip_message_js_1 = require("./sip-message.js");
|
|
16
|
+
Object.defineProperty(exports, "SipMessage", { enumerable: true, get: function () { return __importDefault(sip_message_js_1).default; } });
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
class OutboundMessage extends
|
|
6
|
+
const sip_message_js_1 = __importDefault(require("../sip-message.js"));
|
|
7
|
+
class OutboundMessage extends sip_message_js_1.default {
|
|
8
8
|
constructor(subject = "", headers = {}, body = "") {
|
|
9
9
|
super(subject, headers, body);
|
|
10
10
|
this.headers["Content-Length"] = this.body.length.toString();
|
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const index_js_1 = __importDefault(require("./index.js"));
|
|
7
|
+
const utils_js_1 = require("../../utils.js");
|
|
8
8
|
let cseq = Math.floor(Math.random() * 10000);
|
|
9
|
-
class RequestMessage extends
|
|
9
|
+
class RequestMessage extends index_js_1.default {
|
|
10
10
|
constructor(subject = "", headers = {}, body = "") {
|
|
11
11
|
super(subject, headers, body);
|
|
12
12
|
if (this.headers.CSeq === undefined) {
|
|
@@ -20,7 +20,7 @@ class RequestMessage extends index_1.default {
|
|
|
20
20
|
const newMessage = new RequestMessage(this.subject, { ...this.headers }, this.body);
|
|
21
21
|
newMessage.newCseq();
|
|
22
22
|
if (newMessage.headers.Via) {
|
|
23
|
-
newMessage.headers.Via = newMessage.headers.Via.replace(/;branch=.+?$/, `;branch=${(0,
|
|
23
|
+
newMessage.headers.Via = newMessage.headers.Via.replace(/;branch=.+?$/, `;branch=${(0, utils_js_1.branch)()}`);
|
|
24
24
|
}
|
|
25
25
|
return newMessage;
|
|
26
26
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import OutboundMessage from "./index";
|
|
2
|
-
import type InboundMessage from "../inbound/index";
|
|
1
|
+
import OutboundMessage from "./index.js";
|
|
2
|
+
import type InboundMessage from "../inbound/index.js";
|
|
3
3
|
declare class ResponseMessage extends OutboundMessage {
|
|
4
4
|
constructor(inboundMessage: InboundMessage, responseCode: number, headers?: {}, body?: string);
|
|
5
5
|
}
|
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
class ResponseMessage extends
|
|
6
|
+
const index_js_1 = __importDefault(require("./index.js"));
|
|
7
|
+
const response_codes_js_1 = __importDefault(require("../response-codes.js"));
|
|
8
|
+
class ResponseMessage extends index_js_1.default {
|
|
9
9
|
constructor(inboundMessage, responseCode, headers = {}, body = "") {
|
|
10
10
|
super(undefined, { ...headers }, body);
|
|
11
|
-
this.subject = `SIP/2.0 ${responseCode} ${
|
|
11
|
+
this.subject = `SIP/2.0 ${responseCode} ${response_codes_js_1.default[responseCode]}`;
|
|
12
12
|
const keys = ["Via", "From", "To", "Call-ID", "CSeq"];
|
|
13
13
|
for (const key of keys) {
|
|
14
14
|
if (inboundMessage.headers[key]) {
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SoftPhoneOptions } from "./types";
|
|
1
|
+
import { SoftPhoneOptions } from "./types.js";
|
|
2
2
|
export declare const generateAuthorization: (sipInfo: SoftPhoneOptions, nonce: string, method: "REGISTER" | "INVITE") => string;
|
|
3
3
|
export declare const uuid: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
4
4
|
export declare const branch: () => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import CallSession from "./index";
|
|
2
|
-
import { type InboundMessage } from "../sip-message/index";
|
|
3
|
-
import type Softphone from "../index";
|
|
1
|
+
import CallSession from "./index.js";
|
|
2
|
+
import { type InboundMessage } from "../sip-message/index.js";
|
|
3
|
+
import type Softphone from "../index.js";
|
|
4
4
|
declare class InboundCallSession extends CallSession {
|
|
5
5
|
constructor(softphone: Softphone, inviteMessage: InboundMessage);
|
|
6
6
|
answer(): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import CallSession from "./index";
|
|
2
|
-
import { OutboundMessage } from "../sip-message/index";
|
|
3
|
-
import { localKey, randomInt } from "../utils";
|
|
1
|
+
import CallSession from "./index.js";
|
|
2
|
+
import { OutboundMessage } from "../sip-message/index.js";
|
|
3
|
+
import { localKey, randomInt } from "../utils.js";
|
|
4
4
|
class InboundCallSession extends CallSession {
|
|
5
5
|
constructor(softphone, inviteMessage) {
|
|
6
6
|
super(softphone, inviteMessage);
|
|
@@ -2,9 +2,9 @@ import dgram from "node:dgram";
|
|
|
2
2
|
import EventEmitter from "node:events";
|
|
3
3
|
import { Buffer } from "node:buffer";
|
|
4
4
|
import { RtpPacket, SrtpSession } from "werift-rtp";
|
|
5
|
-
import { type InboundMessage } from "../sip-message/index";
|
|
6
|
-
import type Softphone from "../index";
|
|
7
|
-
import Streamer from "./streamer";
|
|
5
|
+
import { type InboundMessage } from "../sip-message/index.js";
|
|
6
|
+
import type Softphone from "../index.js";
|
|
7
|
+
import Streamer from "./streamer.js";
|
|
8
8
|
declare abstract class CallSession extends EventEmitter {
|
|
9
9
|
softphone: Softphone;
|
|
10
10
|
sipMessage: InboundMessage;
|
|
@@ -2,10 +2,10 @@ import dgram from "node:dgram";
|
|
|
2
2
|
import EventEmitter from "node:events";
|
|
3
3
|
import { Buffer } from "node:buffer";
|
|
4
4
|
import { RtpHeader, RtpPacket, SrtpSession } from "werift-rtp";
|
|
5
|
-
import DTMF from "../dtmf";
|
|
6
|
-
import { RequestMessage, ResponseMessage, } from "../sip-message/index";
|
|
7
|
-
import { branch, localKey, randomInt } from "../utils";
|
|
8
|
-
import Streamer from "./streamer";
|
|
5
|
+
import DTMF from "../dtmf.js";
|
|
6
|
+
import { RequestMessage, ResponseMessage, } from "../sip-message/index.js";
|
|
7
|
+
import { branch, localKey, randomInt } from "../utils.js";
|
|
8
|
+
import Streamer from "./streamer.js";
|
|
9
9
|
class CallSession extends EventEmitter {
|
|
10
10
|
softphone;
|
|
11
11
|
sipMessage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import CallSession from "./index";
|
|
2
|
-
import { type InboundMessage } from "../sip-message/index";
|
|
3
|
-
import type Softphone from "../index";
|
|
1
|
+
import CallSession from "./index.js";
|
|
2
|
+
import { type InboundMessage } from "../sip-message/index.js";
|
|
3
|
+
import type Softphone from "../index.js";
|
|
4
4
|
declare class OutboundCallSession extends CallSession {
|
|
5
5
|
constructor(softphone: Softphone, answerMessage: InboundMessage);
|
|
6
6
|
init(): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import CallSession from "./index";
|
|
2
|
-
import { RequestMessage } from "../sip-message/index";
|
|
3
|
-
import { extractAddress, withoutTag } from "../utils";
|
|
1
|
+
import CallSession from "./index.js";
|
|
2
|
+
import { RequestMessage } from "../sip-message/index.js";
|
|
3
|
+
import { extractAddress, withoutTag } from "../utils.js";
|
|
4
4
|
class OutboundCallSession extends CallSession {
|
|
5
5
|
constructor(softphone, answerMessage) {
|
|
6
6
|
super(softphone, answerMessage);
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import EventEmitter from "node:events";
|
|
2
2
|
import { TLSSocket } from "node:tls";
|
|
3
|
-
import InboundCallSession from "./call-session/inbound";
|
|
4
|
-
import OutboundCallSession from "./call-session/outbound";
|
|
5
|
-
import { InboundMessage, OutboundMessage } from "./sip-message/index";
|
|
6
|
-
import { SoftPhoneOptions } from "./types";
|
|
7
|
-
import Codec from "./codec";
|
|
3
|
+
import InboundCallSession from "./call-session/inbound.js";
|
|
4
|
+
import OutboundCallSession from "./call-session/outbound.js";
|
|
5
|
+
import { InboundMessage, OutboundMessage } from "./sip-message/index.js";
|
|
6
|
+
import { SoftPhoneOptions } from "./types.js";
|
|
7
|
+
import Codec from "./codec.js";
|
|
8
8
|
declare class Softphone extends EventEmitter {
|
|
9
9
|
sipInfo: SoftPhoneOptions;
|
|
10
10
|
client: TLSSocket;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import EventEmitter from "node:events";
|
|
2
2
|
import tls from "node:tls";
|
|
3
3
|
import waitFor from "wait-for-async";
|
|
4
|
-
import InboundCallSession from "./call-session/inbound";
|
|
5
|
-
import OutboundCallSession from "./call-session/outbound";
|
|
6
|
-
import { InboundMessage, OutboundMessage, RequestMessage, ResponseMessage, } from "./sip-message/index";
|
|
7
|
-
import { branch, generateAuthorization, localKey, randomInt, uuid, } from "./utils";
|
|
8
|
-
import Codec from "./codec";
|
|
4
|
+
import InboundCallSession from "./call-session/inbound.js";
|
|
5
|
+
import OutboundCallSession from "./call-session/outbound.js";
|
|
6
|
+
import { InboundMessage, OutboundMessage, RequestMessage, ResponseMessage, } from "./sip-message/index.js";
|
|
7
|
+
import { branch, generateAuthorization, localKey, randomInt, uuid, } from "./utils.js";
|
|
8
|
+
import Codec from "./codec.js";
|
|
9
9
|
class Softphone extends EventEmitter {
|
|
10
10
|
sipInfo;
|
|
11
11
|
client;
|
|
@@ -62,14 +62,12 @@ class Softphone extends EventEmitter {
|
|
|
62
62
|
const fromTag = uuid();
|
|
63
63
|
const requestMessage = new RequestMessage(`REGISTER sip:${this.sipInfo.domain} SIP/2.0`, {
|
|
64
64
|
Via: `SIP/2.0/TLS ${this.client.localAddress}:${this.client.localPort};rport;branch=${branch()};alias`,
|
|
65
|
-
Route: `<sip:${this.sipInfo.outboundProxy};transport=tls;lr>`,
|
|
66
65
|
"Max-Forwards": "70",
|
|
67
66
|
From: `<sip:${this.sipInfo.username}@${this.sipInfo.domain}>;tag=${fromTag}`,
|
|
68
67
|
To: `<sip:${this.sipInfo.username}@${this.sipInfo.domain}>`,
|
|
69
68
|
"Call-ID": this.registerCallId,
|
|
70
|
-
Supported: "outbound, path",
|
|
71
69
|
Contact: `<sip:${this.sipInfo.username}@${this.client.localAddress}:${this.client.localPort};transport=TLS;ob>;reg-id=1;+sip.instance="<urn:uuid:${this.instanceId}>"`,
|
|
72
|
-
Expires:
|
|
70
|
+
Expires: 3600,
|
|
73
71
|
Allow: "PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS",
|
|
74
72
|
});
|
|
75
73
|
const inboundMessage = await this.send(requestMessage, true);
|
|
@@ -163,7 +161,7 @@ a=fmtp:101 0-15
|
|
|
163
161
|
a=sendrecv
|
|
164
162
|
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${localKey}
|
|
165
163
|
`.trim();
|
|
166
|
-
const inviteMessage = new RequestMessage(`INVITE sip:${callee} SIP/2.0`, {
|
|
164
|
+
const inviteMessage = new RequestMessage(`INVITE sip:${callee}@${this.sipInfo.domain} SIP/2.0`, {
|
|
167
165
|
Via: `SIP/2.0/TLS ${this.client.localAddress}:${this.client.localPort};rport;branch=${branch()};alias`,
|
|
168
166
|
"Max-Forwards": 70,
|
|
169
167
|
From: `<sip:${this.sipInfo.username}@${this.sipInfo.domain}>;tag=${uuid()}`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { uuid } from "../../utils";
|
|
2
|
-
import SipMessage from "../sip-message";
|
|
1
|
+
import { uuid } from "../../utils.js";
|
|
2
|
+
import SipMessage from "../sip-message.js";
|
|
3
3
|
class InboundMessage extends SipMessage {
|
|
4
4
|
static fromString(str) {
|
|
5
5
|
const sipMessage = new SipMessage();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { default as RequestMessage } from "./outbound/request";
|
|
2
|
-
export { default as ResponseMessage } from "./outbound/response";
|
|
3
|
-
export { default as OutboundMessage } from "./outbound/index";
|
|
4
|
-
export { default as InboundMessage } from "./inbound/index";
|
|
5
|
-
export { default as SipMessage } from "./sip-message";
|
|
1
|
+
export { default as RequestMessage } from "./outbound/request.js";
|
|
2
|
+
export { default as ResponseMessage } from "./outbound/response.js";
|
|
3
|
+
export { default as OutboundMessage } from "./outbound/index.js";
|
|
4
|
+
export { default as InboundMessage } from "./inbound/index.js";
|
|
5
|
+
export { default as SipMessage } from "./sip-message.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { default as RequestMessage } from "./outbound/request";
|
|
2
|
-
export { default as ResponseMessage } from "./outbound/response";
|
|
3
|
-
export { default as OutboundMessage } from "./outbound/index";
|
|
4
|
-
export { default as InboundMessage } from "./inbound/index";
|
|
5
|
-
export { default as SipMessage } from "./sip-message";
|
|
1
|
+
export { default as RequestMessage } from "./outbound/request.js";
|
|
2
|
+
export { default as ResponseMessage } from "./outbound/response.js";
|
|
3
|
+
export { default as OutboundMessage } from "./outbound/index.js";
|
|
4
|
+
export { default as InboundMessage } from "./inbound/index.js";
|
|
5
|
+
export { default as SipMessage } from "./sip-message.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import OutboundMessage from "./index";
|
|
2
|
-
import { branch } from "../../utils";
|
|
1
|
+
import OutboundMessage from "./index.js";
|
|
2
|
+
import { branch } from "../../utils.js";
|
|
3
3
|
let cseq = Math.floor(Math.random() * 10000);
|
|
4
4
|
class RequestMessage extends OutboundMessage {
|
|
5
5
|
constructor(subject = "", headers = {}, body = "") {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import OutboundMessage from "./index";
|
|
2
|
-
import type InboundMessage from "../inbound/index";
|
|
1
|
+
import OutboundMessage from "./index.js";
|
|
2
|
+
import type InboundMessage from "../inbound/index.js";
|
|
3
3
|
declare class ResponseMessage extends OutboundMessage {
|
|
4
4
|
constructor(inboundMessage: InboundMessage, responseCode: number, headers?: {}, body?: string);
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import OutboundMessage from "./index";
|
|
2
|
-
import responseCodes from "../response-codes";
|
|
1
|
+
import OutboundMessage from "./index.js";
|
|
2
|
+
import responseCodes from "../response-codes.js";
|
|
3
3
|
class ResponseMessage extends OutboundMessage {
|
|
4
4
|
constructor(inboundMessage, responseCode, headers = {}, body = "") {
|
|
5
5
|
super(undefined, { ...headers }, body);
|
package/dist/esm/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SoftPhoneOptions } from "./types";
|
|
1
|
+
import { SoftPhoneOptions } from "./types.js";
|
|
2
2
|
export declare const generateAuthorization: (sipInfo: SoftPhoneOptions, nonce: string, method: "REGISTER" | "INVITE") => string;
|
|
3
3
|
export declare const uuid: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
4
4
|
export declare const branch: () => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ringcentral-softphone",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"homepage": "https://github.com/ringcentral/ringcentral-softphone-ts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@evan/opus": "^1.0.3",
|
|
33
|
-
"wait-for-async": "^0.7.
|
|
33
|
+
"wait-for-async": "^0.7.13",
|
|
34
34
|
"werift-rtp": "^0.8.4"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/node": "^22.
|
|
37
|
+
"@types/node": "^22.13.13",
|
|
38
38
|
"dotenv-override-true": "^6.2.2",
|
|
39
|
-
"tsx": "^4.19.
|
|
40
|
-
"typescript": "^5.
|
|
41
|
-
"yarn-upgrade-all": "^0.7.
|
|
39
|
+
"tsx": "^4.19.3",
|
|
40
|
+
"typescript": "^5.8.2",
|
|
41
|
+
"yarn-upgrade-all": "^0.7.5"
|
|
42
42
|
}
|
|
43
43
|
}
|