ringcentral-softphone 1.4.0-beta.1 → 1.4.0-beta.3
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.
|
@@ -9,10 +9,15 @@ class ResponseMessage extends index_js_1.default {
|
|
|
9
9
|
constructor(inboundMessage, responseCode, headers = {}, body = "") {
|
|
10
10
|
super(undefined, { ...headers }, body);
|
|
11
11
|
this.subject = `SIP/2.0 ${responseCode} ${response_codes_js_1.default[responseCode]}`;
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const requiredKeys = new Set(["via", "from", "to", "call-id", "cseq"]);
|
|
13
|
+
const allKeys = Object.keys(inboundMessage.headers).reduce((acc, key) => {
|
|
14
|
+
acc[key.toLowerCase()] = key;
|
|
15
|
+
return acc;
|
|
16
|
+
}, {});
|
|
17
|
+
for (const key of requiredKeys) {
|
|
18
|
+
if (allKeys[key]) {
|
|
19
|
+
const originalKey = allKeys[key];
|
|
20
|
+
this.headers[originalKey] = inboundMessage.headers[originalKey];
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
23
|
}
|
|
@@ -4,10 +4,15 @@ class ResponseMessage extends OutboundMessage {
|
|
|
4
4
|
constructor(inboundMessage, responseCode, headers = {}, body = "") {
|
|
5
5
|
super(undefined, { ...headers }, body);
|
|
6
6
|
this.subject = `SIP/2.0 ${responseCode} ${responseCodes[responseCode]}`;
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const requiredKeys = new Set(["via", "from", "to", "call-id", "cseq"]);
|
|
8
|
+
const allKeys = Object.keys(inboundMessage.headers).reduce((acc, key) => {
|
|
9
|
+
acc[key.toLowerCase()] = key;
|
|
10
|
+
return acc;
|
|
11
|
+
}, {});
|
|
12
|
+
for (const key of requiredKeys) {
|
|
13
|
+
if (allKeys[key]) {
|
|
14
|
+
const originalKey = allKeys[key];
|
|
15
|
+
this.headers[originalKey] = inboundMessage.headers[originalKey];
|
|
11
16
|
}
|
|
12
17
|
}
|
|
13
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ringcentral-softphone",
|
|
3
|
-
"version": "1.4.0-beta.
|
|
3
|
+
"version": "1.4.0-beta.3",
|
|
4
4
|
"homepage": "https://github.com/ringcentral/ringcentral-softphone-ts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"werift-rtp": "^0.8.8"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/node": "^25.
|
|
40
|
+
"@types/node": "^25.3.3",
|
|
41
41
|
"dotenv-override-true": "^6.2.2",
|
|
42
42
|
"tsx": "^4.21.0",
|
|
43
43
|
"typescript": "^5.9.3",
|
package/dist/cjs/sdp.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export interface SdpConfig {
|
|
2
|
-
localAddress: string;
|
|
3
|
-
codecId: number;
|
|
4
|
-
codecName: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Builds SDP (Session Description Protocol) payloads for SIP messaging.
|
|
8
|
-
*/
|
|
9
|
-
export declare class SdpBuilder {
|
|
10
|
-
/**
|
|
11
|
-
* Creates an SDP offer/answer for audio communication.
|
|
12
|
-
*/
|
|
13
|
-
static create(config: SdpConfig): string;
|
|
14
|
-
}
|
|
15
|
-
export interface ParsedSdp {
|
|
16
|
-
ip: string;
|
|
17
|
-
port: number;
|
|
18
|
-
srtpKey: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Parses SDP (Session Description Protocol) payloads to extract connection info.
|
|
22
|
-
*/
|
|
23
|
-
export declare class SdpParser {
|
|
24
|
-
/**
|
|
25
|
-
* Extracts the IP address from the connection line (c=IN IP4 ...).
|
|
26
|
-
* @throws Error if connection line is missing or malformed
|
|
27
|
-
*/
|
|
28
|
-
static extractIP(sdp: string, context?: string): string;
|
|
29
|
-
/**
|
|
30
|
-
* Extracts the audio port from the media line (m=audio ...).
|
|
31
|
-
* @throws Error if media line is missing or malformed
|
|
32
|
-
*/
|
|
33
|
-
static extractPort(sdp: string, context?: string): number;
|
|
34
|
-
/**
|
|
35
|
-
* Extracts the SRTP key from the crypto line.
|
|
36
|
-
* @throws Error if crypto line is missing or malformed
|
|
37
|
-
*/
|
|
38
|
-
static extractSrtpKey(sdp: string, context?: string): string;
|
|
39
|
-
/**
|
|
40
|
-
* Parses all connection information from an SDP body.
|
|
41
|
-
* @throws Error if any required field is missing
|
|
42
|
-
*/
|
|
43
|
-
static parse(sdp: string, context?: string): ParsedSdp;
|
|
44
|
-
}
|
package/dist/cjs/sdp.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SdpParser = exports.SdpBuilder = void 0;
|
|
4
|
-
const constants_js_1 = require("./constants.js");
|
|
5
|
-
const utils_js_1 = require("./utils.js");
|
|
6
|
-
/**
|
|
7
|
-
* Builds SDP (Session Description Protocol) payloads for SIP messaging.
|
|
8
|
-
*/
|
|
9
|
-
class SdpBuilder {
|
|
10
|
-
/**
|
|
11
|
-
* Creates an SDP offer/answer for audio communication.
|
|
12
|
-
*/
|
|
13
|
-
static create(config) {
|
|
14
|
-
const { localAddress, codecId, codecName } = config;
|
|
15
|
-
return `
|
|
16
|
-
v=0
|
|
17
|
-
o=- ${Date.now()} 0 IN IP4 ${localAddress}
|
|
18
|
-
s=rc-softphone-ts
|
|
19
|
-
c=IN IP4 ${localAddress}
|
|
20
|
-
t=0 0
|
|
21
|
-
m=audio ${(0, utils_js_1.randomInt)()} RTP/SAVP ${codecId} ${constants_js_1.DTMF_PAYLOAD_TYPE}
|
|
22
|
-
a=rtpmap:${codecId} ${codecName}
|
|
23
|
-
a=rtpmap:${constants_js_1.DTMF_PAYLOAD_TYPE} telephone-event/8000
|
|
24
|
-
a=fmtp:${constants_js_1.DTMF_PAYLOAD_TYPE} 0-15
|
|
25
|
-
a=sendrecv
|
|
26
|
-
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${utils_js_1.localKey}
|
|
27
|
-
`.trim();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.SdpBuilder = SdpBuilder;
|
|
31
|
-
/**
|
|
32
|
-
* Parses SDP (Session Description Protocol) payloads to extract connection info.
|
|
33
|
-
*/
|
|
34
|
-
class SdpParser {
|
|
35
|
-
/**
|
|
36
|
-
* Extracts the IP address from the connection line (c=IN IP4 ...).
|
|
37
|
-
* @throws Error if connection line is missing or malformed
|
|
38
|
-
*/
|
|
39
|
-
static extractIP(sdp, context = "SDP") {
|
|
40
|
-
const match = sdp.match(/c=IN IP4 ([\d.]+)/);
|
|
41
|
-
if (!match) {
|
|
42
|
-
throw new Error(`${context}: missing connection line (c=IN IP4) in SDP body`);
|
|
43
|
-
}
|
|
44
|
-
return match[1];
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Extracts the audio port from the media line (m=audio ...).
|
|
48
|
-
* @throws Error if media line is missing or malformed
|
|
49
|
-
*/
|
|
50
|
-
static extractPort(sdp, context = "SDP") {
|
|
51
|
-
const match = sdp.match(/m=audio (\d+) /);
|
|
52
|
-
if (!match) {
|
|
53
|
-
throw new Error(`${context}: missing media line (m=audio) in SDP body`);
|
|
54
|
-
}
|
|
55
|
-
return parseInt(match[1], 10);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Extracts the SRTP key from the crypto line.
|
|
59
|
-
* @throws Error if crypto line is missing or malformed
|
|
60
|
-
*/
|
|
61
|
-
static extractSrtpKey(sdp, context = "SDP") {
|
|
62
|
-
const match = sdp.match(/AES_CM_128_HMAC_SHA1_80 inline:([\w+/]+)/);
|
|
63
|
-
if (!match) {
|
|
64
|
-
throw new Error(`${context}: missing SRTP key (AES_CM_128_HMAC_SHA1_80) in SDP body`);
|
|
65
|
-
}
|
|
66
|
-
return match[1];
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Parses all connection information from an SDP body.
|
|
70
|
-
* @throws Error if any required field is missing
|
|
71
|
-
*/
|
|
72
|
-
static parse(sdp, context = "SDP") {
|
|
73
|
-
return {
|
|
74
|
-
ip: SdpParser.extractIP(sdp, context),
|
|
75
|
-
port: SdpParser.extractPort(sdp, context),
|
|
76
|
-
srtpKey: SdpParser.extractSrtpKey(sdp, context),
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.SdpParser = SdpParser;
|
package/dist/esm/sdp.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export interface SdpConfig {
|
|
2
|
-
localAddress: string;
|
|
3
|
-
codecId: number;
|
|
4
|
-
codecName: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Builds SDP (Session Description Protocol) payloads for SIP messaging.
|
|
8
|
-
*/
|
|
9
|
-
export declare class SdpBuilder {
|
|
10
|
-
/**
|
|
11
|
-
* Creates an SDP offer/answer for audio communication.
|
|
12
|
-
*/
|
|
13
|
-
static create(config: SdpConfig): string;
|
|
14
|
-
}
|
|
15
|
-
export interface ParsedSdp {
|
|
16
|
-
ip: string;
|
|
17
|
-
port: number;
|
|
18
|
-
srtpKey: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Parses SDP (Session Description Protocol) payloads to extract connection info.
|
|
22
|
-
*/
|
|
23
|
-
export declare class SdpParser {
|
|
24
|
-
/**
|
|
25
|
-
* Extracts the IP address from the connection line (c=IN IP4 ...).
|
|
26
|
-
* @throws Error if connection line is missing or malformed
|
|
27
|
-
*/
|
|
28
|
-
static extractIP(sdp: string, context?: string): string;
|
|
29
|
-
/**
|
|
30
|
-
* Extracts the audio port from the media line (m=audio ...).
|
|
31
|
-
* @throws Error if media line is missing or malformed
|
|
32
|
-
*/
|
|
33
|
-
static extractPort(sdp: string, context?: string): number;
|
|
34
|
-
/**
|
|
35
|
-
* Extracts the SRTP key from the crypto line.
|
|
36
|
-
* @throws Error if crypto line is missing or malformed
|
|
37
|
-
*/
|
|
38
|
-
static extractSrtpKey(sdp: string, context?: string): string;
|
|
39
|
-
/**
|
|
40
|
-
* Parses all connection information from an SDP body.
|
|
41
|
-
* @throws Error if any required field is missing
|
|
42
|
-
*/
|
|
43
|
-
static parse(sdp: string, context?: string): ParsedSdp;
|
|
44
|
-
}
|
package/dist/esm/sdp.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { DTMF_PAYLOAD_TYPE } from "./constants.js";
|
|
2
|
-
import { localKey, randomInt } from "./utils.js";
|
|
3
|
-
/**
|
|
4
|
-
* Builds SDP (Session Description Protocol) payloads for SIP messaging.
|
|
5
|
-
*/
|
|
6
|
-
export class SdpBuilder {
|
|
7
|
-
/**
|
|
8
|
-
* Creates an SDP offer/answer for audio communication.
|
|
9
|
-
*/
|
|
10
|
-
static create(config) {
|
|
11
|
-
const { localAddress, codecId, codecName } = config;
|
|
12
|
-
return `
|
|
13
|
-
v=0
|
|
14
|
-
o=- ${Date.now()} 0 IN IP4 ${localAddress}
|
|
15
|
-
s=rc-softphone-ts
|
|
16
|
-
c=IN IP4 ${localAddress}
|
|
17
|
-
t=0 0
|
|
18
|
-
m=audio ${randomInt()} RTP/SAVP ${codecId} ${DTMF_PAYLOAD_TYPE}
|
|
19
|
-
a=rtpmap:${codecId} ${codecName}
|
|
20
|
-
a=rtpmap:${DTMF_PAYLOAD_TYPE} telephone-event/8000
|
|
21
|
-
a=fmtp:${DTMF_PAYLOAD_TYPE} 0-15
|
|
22
|
-
a=sendrecv
|
|
23
|
-
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${localKey}
|
|
24
|
-
`.trim();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Parses SDP (Session Description Protocol) payloads to extract connection info.
|
|
29
|
-
*/
|
|
30
|
-
export class SdpParser {
|
|
31
|
-
/**
|
|
32
|
-
* Extracts the IP address from the connection line (c=IN IP4 ...).
|
|
33
|
-
* @throws Error if connection line is missing or malformed
|
|
34
|
-
*/
|
|
35
|
-
static extractIP(sdp, context = "SDP") {
|
|
36
|
-
const match = sdp.match(/c=IN IP4 ([\d.]+)/);
|
|
37
|
-
if (!match) {
|
|
38
|
-
throw new Error(`${context}: missing connection line (c=IN IP4) in SDP body`);
|
|
39
|
-
}
|
|
40
|
-
return match[1];
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Extracts the audio port from the media line (m=audio ...).
|
|
44
|
-
* @throws Error if media line is missing or malformed
|
|
45
|
-
*/
|
|
46
|
-
static extractPort(sdp, context = "SDP") {
|
|
47
|
-
const match = sdp.match(/m=audio (\d+) /);
|
|
48
|
-
if (!match) {
|
|
49
|
-
throw new Error(`${context}: missing media line (m=audio) in SDP body`);
|
|
50
|
-
}
|
|
51
|
-
return parseInt(match[1], 10);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Extracts the SRTP key from the crypto line.
|
|
55
|
-
* @throws Error if crypto line is missing or malformed
|
|
56
|
-
*/
|
|
57
|
-
static extractSrtpKey(sdp, context = "SDP") {
|
|
58
|
-
const match = sdp.match(/AES_CM_128_HMAC_SHA1_80 inline:([\w+/]+)/);
|
|
59
|
-
if (!match) {
|
|
60
|
-
throw new Error(`${context}: missing SRTP key (AES_CM_128_HMAC_SHA1_80) in SDP body`);
|
|
61
|
-
}
|
|
62
|
-
return match[1];
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Parses all connection information from an SDP body.
|
|
66
|
-
* @throws Error if any required field is missing
|
|
67
|
-
*/
|
|
68
|
-
static parse(sdp, context = "SDP") {
|
|
69
|
-
return {
|
|
70
|
-
ip: SdpParser.extractIP(sdp, context),
|
|
71
|
-
port: SdpParser.extractPort(sdp, context),
|
|
72
|
-
srtpKey: SdpParser.extractSrtpKey(sdp, context),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|