ringcentral-softphone 1.3.3 → 1.3.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.
Files changed (66) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  2. package/dist/call-session/inbound.cjs +41 -83
  3. package/dist/call-session/inbound.d.cts +10 -0
  4. package/dist/call-session/inbound.d.ts +8 -5
  5. package/dist/call-session/inbound.js +36 -49
  6. package/dist/call-session/index.cjs +212 -269
  7. package/dist/call-session/index.d.cts +48 -0
  8. package/dist/call-session/index.d.ts +44 -39
  9. package/dist/call-session/index.js +204 -239
  10. package/dist/call-session/outbound.cjs +56 -99
  11. package/dist/call-session/outbound.d.cts +13 -0
  12. package/dist/call-session/outbound.d.ts +11 -8
  13. package/dist/call-session/outbound.js +54 -68
  14. package/dist/call-session/streamer.cjs +66 -111
  15. package/dist/call-session/streamer.d.cts +19 -0
  16. package/dist/call-session/streamer.d.ts +16 -13
  17. package/dist/call-session/streamer.js +61 -79
  18. package/dist/codec.cjs +68 -84
  19. package/dist/codec.d.cts +17 -0
  20. package/dist/codec.d.ts +15 -12
  21. package/dist/codec.js +65 -63
  22. package/dist/dtmf.cjs +42 -64
  23. package/dist/dtmf.d.cts +9 -0
  24. package/dist/dtmf.d.ts +9 -7
  25. package/dist/dtmf.js +40 -44
  26. package/dist/index.cjs +166 -248
  27. package/dist/index.d.cts +31 -0
  28. package/dist/index.d.ts +28 -24
  29. package/dist/index.js +156 -224
  30. package/dist/sip-message/inbound/index.cjs +16 -50
  31. package/dist/sip-message/inbound/index.d.cts +7 -0
  32. package/dist/sip-message/inbound/index.d.ts +5 -2
  33. package/dist/sip-message/inbound/index.js +14 -19
  34. package/dist/sip-message/index.cjs +11 -49
  35. package/dist/sip-message/index.d.cts +6 -0
  36. package/dist/sip-message/index.d.ts +6 -5
  37. package/dist/sip-message/index.js +6 -12
  38. package/dist/sip-message/outbound/index.cjs +10 -40
  39. package/dist/sip-message/outbound/index.d.cts +7 -0
  40. package/dist/sip-message/outbound/index.d.ts +5 -2
  41. package/dist/sip-message/outbound/index.js +9 -10
  42. package/dist/sip-message/outbound/request.cjs +20 -61
  43. package/dist/sip-message/outbound/request.d.cts +9 -0
  44. package/dist/sip-message/outbound/request.d.ts +7 -4
  45. package/dist/sip-message/outbound/request.js +17 -29
  46. package/dist/sip-message/outbound/response.cjs +25 -54
  47. package/dist/sip-message/outbound/response.d.cts +8 -0
  48. package/dist/sip-message/outbound/response.d.ts +6 -3
  49. package/dist/sip-message/outbound/response.js +24 -24
  50. package/dist/sip-message/response-codes.cjs +80 -100
  51. package/dist/sip-message/response-codes.d.cts +5 -0
  52. package/dist/sip-message/response-codes.d.ts +4 -2
  53. package/dist/sip-message/response-codes.js +80 -81
  54. package/dist/sip-message/sip-message.cjs +25 -52
  55. package/dist/sip-message/sip-message.d.cts +12 -0
  56. package/dist/sip-message/sip-message.d.ts +11 -9
  57. package/dist/sip-message/sip-message.js +25 -33
  58. package/dist/types.cjs +0 -15
  59. package/dist/types.d.cts +12 -0
  60. package/dist/types.d.ts +11 -8
  61. package/dist/types.js +1 -0
  62. package/dist/utils.cjs +27 -73
  63. package/dist/utils.d.cts +12 -0
  64. package/dist/utils.d.ts +12 -8
  65. package/dist/utils.js +15 -31
  66. package/package.json +5 -5
@@ -1,83 +1,82 @@
1
+ //#region src/sip-message/response-codes.ts
1
2
  const responseCodes = {
2
- 100: "Trying",
3
- 180: "Ringing",
4
- 181: "Call is Being Forwarded",
5
- 182: "Queued",
6
- 183: "Session Progress",
7
- 199: "Early Dialog Terminated",
8
- 200: "OK",
9
- 202: "Accepted",
10
- 204: "No Notification",
11
- 300: "Multiple Choices",
12
- 301: "Moved Permanently",
13
- 302: "Moved Temporarily",
14
- 305: "Use Proxy",
15
- 380: "Alternative Service",
16
- 400: "Bad Request",
17
- 401: "Unauthorized",
18
- 402: "Payment Required",
19
- 403: "Forbidden",
20
- 404: "Not Found",
21
- 405: "Method Not Allowed",
22
- 406: "Not Acceptable",
23
- 407: "Proxy Authentication Required",
24
- 408: "Request Timeout",
25
- 409: "Conflict",
26
- 410: "Gone",
27
- 411: "Length Required",
28
- 412: "Conditional Request Failed",
29
- 413: "Request Entity Too Large",
30
- 414: "Request-URI Too Long",
31
- 415: "Unsupported Media Type",
32
- 416: "Unsupported URI Scheme",
33
- 417: "Unknown Resource-Priority",
34
- 420: "Bad Extension",
35
- 421: "Extension Required",
36
- 422: "Session Interval Too Small",
37
- 423: "Interval Too Brief",
38
- 424: "Bad Location Information",
39
- 425: "Bad Alert Message",
40
- 428: "Use Identity Header",
41
- 429: "Provide Referrer Identity",
42
- 430: "Flow Failed",
43
- 433: "Anonymity Disallowed",
44
- 436: "Bad Identity-Info",
45
- 437: "Unsupported Certificate",
46
- 438: "Invalid Identity Header",
47
- 439: "First Hop Lacks Outbound Support",
48
- 440: "Max-Breadth Exceeded",
49
- 469: "Bad Info Package",
50
- 470: "Consent Needed",
51
- 480: "Temporarily Unavailable",
52
- 481: "Call/Transaction Does Not Exist",
53
- 482: "Loop Detected",
54
- 483: "Too Many Hops",
55
- 484: "Address Incomplete",
56
- 485: "Ambiguous",
57
- 486: "Busy Here",
58
- 487: "Request Terminated",
59
- 488: "Not Acceptable Here",
60
- 489: "Bad Event",
61
- 491: "Request Pending",
62
- 493: "Undecipherable",
63
- 494: "Security Agreement Required",
64
- 500: "Server Internal Error",
65
- 501: "Not Implemented",
66
- 502: "Bad Gateway",
67
- 503: "Service Unavailable",
68
- 504: "Server Time-out",
69
- 505: "Version Not Supported",
70
- 513: "Message Too Large",
71
- 555: "Push Notification Service Not Supported",
72
- 580: "Precondition Failure",
73
- 600: "Busy Everywhere",
74
- 603: "Decline",
75
- 604: "Does Not Exist Anywhere",
76
- 606: "Not Acceptable",
77
- 607: "Unwanted",
78
- 608: "Rejected"
79
- };
80
- var response_codes_default = responseCodes;
81
- export {
82
- response_codes_default as default
3
+ 100: "Trying",
4
+ 180: "Ringing",
5
+ 181: "Call is Being Forwarded",
6
+ 182: "Queued",
7
+ 183: "Session Progress",
8
+ 199: "Early Dialog Terminated",
9
+ 200: "OK",
10
+ 202: "Accepted",
11
+ 204: "No Notification",
12
+ 300: "Multiple Choices",
13
+ 301: "Moved Permanently",
14
+ 302: "Moved Temporarily",
15
+ 305: "Use Proxy",
16
+ 380: "Alternative Service",
17
+ 400: "Bad Request",
18
+ 401: "Unauthorized",
19
+ 402: "Payment Required",
20
+ 403: "Forbidden",
21
+ 404: "Not Found",
22
+ 405: "Method Not Allowed",
23
+ 406: "Not Acceptable",
24
+ 407: "Proxy Authentication Required",
25
+ 408: "Request Timeout",
26
+ 409: "Conflict",
27
+ 410: "Gone",
28
+ 411: "Length Required",
29
+ 412: "Conditional Request Failed",
30
+ 413: "Request Entity Too Large",
31
+ 414: "Request-URI Too Long",
32
+ 415: "Unsupported Media Type",
33
+ 416: "Unsupported URI Scheme",
34
+ 417: "Unknown Resource-Priority",
35
+ 420: "Bad Extension",
36
+ 421: "Extension Required",
37
+ 422: "Session Interval Too Small",
38
+ 423: "Interval Too Brief",
39
+ 424: "Bad Location Information",
40
+ 425: "Bad Alert Message",
41
+ 428: "Use Identity Header",
42
+ 429: "Provide Referrer Identity",
43
+ 430: "Flow Failed",
44
+ 433: "Anonymity Disallowed",
45
+ 436: "Bad Identity-Info",
46
+ 437: "Unsupported Certificate",
47
+ 438: "Invalid Identity Header",
48
+ 439: "First Hop Lacks Outbound Support",
49
+ 440: "Max-Breadth Exceeded",
50
+ 469: "Bad Info Package",
51
+ 470: "Consent Needed",
52
+ 480: "Temporarily Unavailable",
53
+ 481: "Call/Transaction Does Not Exist",
54
+ 482: "Loop Detected",
55
+ 483: "Too Many Hops",
56
+ 484: "Address Incomplete",
57
+ 485: "Ambiguous",
58
+ 486: "Busy Here",
59
+ 487: "Request Terminated",
60
+ 488: "Not Acceptable Here",
61
+ 489: "Bad Event",
62
+ 491: "Request Pending",
63
+ 493: "Undecipherable",
64
+ 494: "Security Agreement Required",
65
+ 500: "Server Internal Error",
66
+ 501: "Not Implemented",
67
+ 502: "Bad Gateway",
68
+ 503: "Service Unavailable",
69
+ 504: "Server Time-out",
70
+ 505: "Version Not Supported",
71
+ 513: "Message Too Large",
72
+ 555: "Push Notification Service Not Supported",
73
+ 580: "Precondition Failure",
74
+ 600: "Busy Everywhere",
75
+ 603: "Decline",
76
+ 604: "Does Not Exist Anywhere",
77
+ 606: "Not Acceptable",
78
+ 607: "Unwanted",
79
+ 608: "Rejected"
83
80
  };
81
+ //#endregion
82
+ export { responseCodes as default };
@@ -1,53 +1,26 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ //#region src/sip-message/sip-message.ts
2
+ var SipMessage = class {
3
+ subject;
4
+ headers;
5
+ body;
6
+ constructor(subject = "", headers = {}, body = "") {
7
+ this.subject = subject;
8
+ this.headers = headers;
9
+ this.body = body.trim().split(/[\r\n]+/).join("\r\n");
10
+ if (this.body.length > 0) this.body += "\r\n";
11
+ }
12
+ toString() {
13
+ return [
14
+ this.subject,
15
+ ...Object.keys(this.headers).map((key) => `${key}: ${this.headers[key]}`),
16
+ "",
17
+ this.body
18
+ ].join("\r\n");
19
+ }
20
+ getHeader(key) {
21
+ const foundKey = Object.keys(this.headers).find((k) => k.toLowerCase() === key.toLowerCase());
22
+ if (foundKey) return this.headers[foundKey];
23
+ }
8
24
  };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var sip_message_exports = {};
19
- __export(sip_message_exports, {
20
- default: () => sip_message_default
21
- });
22
- module.exports = __toCommonJS(sip_message_exports);
23
- class SipMessage {
24
- subject;
25
- headers;
26
- body;
27
- constructor(subject = "", headers = {}, body = "") {
28
- this.subject = subject;
29
- this.headers = headers;
30
- this.body = body.trim().split(/[\r\n]+/).join("\r\n");
31
- if (this.body.length > 0) {
32
- this.body += "\r\n";
33
- }
34
- }
35
- toString() {
36
- const r = [
37
- this.subject,
38
- ...Object.keys(this.headers).map((key) => `${key}: ${this.headers[key]}`),
39
- "",
40
- this.body
41
- ].join("\r\n");
42
- return r;
43
- }
44
- getHeader(key) {
45
- const foundKey = Object.keys(this.headers).find(
46
- (k) => k.toLowerCase() === key.toLowerCase()
47
- );
48
- if (foundKey) {
49
- return this.headers[foundKey];
50
- }
51
- }
52
- }
53
- var sip_message_default = SipMessage;
25
+ //#endregion
26
+ module.exports = SipMessage;
@@ -0,0 +1,12 @@
1
+ //#region src/sip-message/sip-message.d.ts
2
+ declare class SipMessage {
3
+ subject: string;
4
+ headers: {
5
+ [key: string]: string;
6
+ };
7
+ body: string;
8
+ constructor(subject?: string, headers?: {}, body?: string);
9
+ toString(): string;
10
+ getHeader(key: string): string | undefined;
11
+ }
12
+ export = SipMessage;
@@ -1,11 +1,13 @@
1
+ //#region src/sip-message/sip-message.d.ts
1
2
  declare class SipMessage {
2
- subject: string;
3
- headers: {
4
- [key: string]: string;
5
- };
6
- body: string;
7
- constructor(subject?: string, headers?: {}, body?: string);
8
- toString(): string;
9
- getHeader(key: string): string | undefined;
3
+ subject: string;
4
+ headers: {
5
+ [key: string]: string;
6
+ };
7
+ body: string;
8
+ constructor(subject?: string, headers?: {}, body?: string);
9
+ toString(): string;
10
+ getHeader(key: string): string | undefined;
10
11
  }
11
- export default SipMessage;
12
+ //#endregion
13
+ export { SipMessage as default };
@@ -1,34 +1,26 @@
1
- class SipMessage {
2
- subject;
3
- headers;
4
- body;
5
- constructor(subject = "", headers = {}, body = "") {
6
- this.subject = subject;
7
- this.headers = headers;
8
- this.body = body.trim().split(/[\r\n]+/).join("\r\n");
9
- if (this.body.length > 0) {
10
- this.body += "\r\n";
11
- }
12
- }
13
- toString() {
14
- const r = [
15
- this.subject,
16
- ...Object.keys(this.headers).map((key) => `${key}: ${this.headers[key]}`),
17
- "",
18
- this.body
19
- ].join("\r\n");
20
- return r;
21
- }
22
- getHeader(key) {
23
- const foundKey = Object.keys(this.headers).find(
24
- (k) => k.toLowerCase() === key.toLowerCase()
25
- );
26
- if (foundKey) {
27
- return this.headers[foundKey];
28
- }
29
- }
30
- }
31
- var sip_message_default = SipMessage;
32
- export {
33
- sip_message_default as default
1
+ //#region src/sip-message/sip-message.ts
2
+ var SipMessage = class {
3
+ subject;
4
+ headers;
5
+ body;
6
+ constructor(subject = "", headers = {}, body = "") {
7
+ this.subject = subject;
8
+ this.headers = headers;
9
+ this.body = body.trim().split(/[\r\n]+/).join("\r\n");
10
+ if (this.body.length > 0) this.body += "\r\n";
11
+ }
12
+ toString() {
13
+ return [
14
+ this.subject,
15
+ ...Object.keys(this.headers).map((key) => `${key}: ${this.headers[key]}`),
16
+ "",
17
+ this.body
18
+ ].join("\r\n");
19
+ }
20
+ getHeader(key) {
21
+ const foundKey = Object.keys(this.headers).find((k) => k.toLowerCase() === key.toLowerCase());
22
+ if (foundKey) return this.headers[foundKey];
23
+ }
34
24
  };
25
+ //#endregion
26
+ export { SipMessage as default };
package/dist/types.cjs CHANGED
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var types_exports = {};
15
- module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,12 @@
1
+ //#region src/types.d.ts
2
+ type SoftPhoneOptions = {
3
+ domain: string;
4
+ outboundProxy: string;
5
+ username: string;
6
+ password: string;
7
+ authorizationId: string;
8
+ codec?: "OPUS/16000" | "OPUS/48000/2" | "PCMU/8000";
9
+ ignoreTlsCertErrors?: boolean;
10
+ };
11
+ //#endregion
12
+ export { SoftPhoneOptions };
package/dist/types.d.ts CHANGED
@@ -1,9 +1,12 @@
1
- export type SoftPhoneOptions = {
2
- domain: string;
3
- outboundProxy: string;
4
- username: string;
5
- password: string;
6
- authorizationId: string;
7
- codec?: "OPUS/16000" | "OPUS/48000/2" | "PCMU/8000";
8
- ignoreTlsCertErrors?: boolean;
1
+ //#region src/types.d.ts
2
+ type SoftPhoneOptions = {
3
+ domain: string;
4
+ outboundProxy: string;
5
+ username: string;
6
+ password: string;
7
+ authorizationId: string;
8
+ codec?: "OPUS/16000" | "OPUS/48000/2" | "PCMU/8000";
9
+ ignoreTlsCertErrors?: boolean;
9
10
  };
11
+ //#endregion
12
+ export { SoftPhoneOptions };
package/dist/types.js CHANGED
@@ -0,0 +1 @@
1
+ export {};
package/dist/utils.cjs CHANGED
@@ -1,80 +1,34 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var utils_exports = {};
29
- __export(utils_exports, {
30
- branch: () => branch,
31
- extractAddress: () => extractAddress,
32
- generateAuthorization: () => generateAuthorization,
33
- localKey: () => localKey,
34
- randomInt: () => randomInt,
35
- uuid: () => uuid,
36
- withoutTag: () => withoutTag
37
- });
38
- module.exports = __toCommonJS(utils_exports);
39
- var import_node_crypto = __toESM(require("node:crypto"), 1);
40
- const md5 = (s) => import_node_crypto.default.createHash("md5").update(s).digest("hex");
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
3
+ let node_crypto = require("node:crypto");
4
+ node_crypto = require_runtime.__toESM(node_crypto, 1);
5
+ //#region src/utils.ts
6
+ const md5 = (s) => node_crypto.default.createHash("md5").update(s).digest("hex");
41
7
  const generateResponse = (sipInfo, endpoint, nonce) => {
42
- const ha1 = md5(
43
- `${sipInfo.authorizationId}:${sipInfo.domain}:${sipInfo.password}`
44
- );
45
- const ha2 = md5(endpoint);
46
- const response = md5(`${ha1}:${nonce}:${ha2}`);
47
- return response;
8
+ return md5(`${md5(`${sipInfo.authorizationId}:${sipInfo.domain}:${sipInfo.password}`)}:${nonce}:${md5(endpoint)}`);
48
9
  };
49
10
  const generateAuthorization = (sipInfo, nonce, method) => {
50
- const authObj = {
51
- "Digest algorithm": "MD5",
52
- username: sipInfo.authorizationId,
53
- realm: sipInfo.domain,
54
- nonce,
55
- uri: `sip:${sipInfo.domain}`,
56
- response: generateResponse(
57
- sipInfo,
58
- `${method}:sip:${sipInfo.domain}`,
59
- nonce
60
- )
61
- };
62
- return Object.entries(authObj).map(([key, value]) => `${key}="${value}"`).join(", ");
11
+ const authObj = {
12
+ "Digest algorithm": "MD5",
13
+ username: sipInfo.authorizationId,
14
+ realm: sipInfo.domain,
15
+ nonce,
16
+ uri: `sip:${sipInfo.domain}`,
17
+ response: generateResponse(sipInfo, `${method}:sip:${sipInfo.domain}`, nonce)
18
+ };
19
+ return Object.entries(authObj).map(([key, value]) => `${key}="${value}"`).join(", ");
63
20
  };
64
- const uuid = () => import_node_crypto.default.randomUUID();
21
+ const uuid = () => node_crypto.default.randomUUID();
65
22
  const branch = () => `z9hG4bK-${uuid()}`;
66
- const randomInt = () => Math.floor(Math.random() * (65535 - 1024 + 1)) + 1024;
23
+ const randomInt = () => Math.floor(Math.random() * 64512) + 1024;
67
24
  const withoutTag = (s) => s.replace(/;tag=.*$/, "");
68
25
  const extractAddress = (s) => s.match(/<(sip:.+?)>/)?.[1];
69
- const keyAndSalt = import_node_crypto.default.randomBytes(30);
70
- const localKey = keyAndSalt.toString("base64").replace(/=+$/, "");
71
- // Annotate the CommonJS export names for ESM import in node:
72
- 0 && (module.exports = {
73
- branch,
74
- extractAddress,
75
- generateAuthorization,
76
- localKey,
77
- randomInt,
78
- uuid,
79
- withoutTag
80
- });
26
+ const localKey = node_crypto.default.randomBytes(30).toString("base64").replace(/=+$/, "");
27
+ //#endregion
28
+ exports.branch = branch;
29
+ exports.extractAddress = extractAddress;
30
+ exports.generateAuthorization = generateAuthorization;
31
+ exports.localKey = localKey;
32
+ exports.randomInt = randomInt;
33
+ exports.uuid = uuid;
34
+ exports.withoutTag = withoutTag;
@@ -0,0 +1,12 @@
1
+ import { SoftPhoneOptions } from "./types.cjs";
2
+
3
+ //#region src/utils.d.ts
4
+ declare const generateAuthorization: (sipInfo: SoftPhoneOptions, nonce: string, method: "REGISTER" | "INVITE") => string;
5
+ declare const uuid: () => `${string}-${string}-${string}-${string}-${string}`;
6
+ declare const branch: () => string;
7
+ declare const randomInt: () => number;
8
+ declare const withoutTag: (s: string) => string;
9
+ declare const extractAddress: (s: string) => string | undefined;
10
+ declare const localKey: string;
11
+ //#endregion
12
+ export { branch, extractAddress, generateAuthorization, localKey, randomInt, uuid, withoutTag };
package/dist/utils.d.ts CHANGED
@@ -1,8 +1,12 @@
1
- import type { SoftPhoneOptions } from "./types.js";
2
- export declare const generateAuthorization: (sipInfo: SoftPhoneOptions, nonce: string, method: "REGISTER" | "INVITE") => string;
3
- export declare const uuid: () => `${string}-${string}-${string}-${string}-${string}`;
4
- export declare const branch: () => string;
5
- export declare const randomInt: () => number;
6
- export declare const withoutTag: (s: string) => string;
7
- export declare const extractAddress: (s: string) => string | undefined;
8
- export declare const localKey: string;
1
+ import { SoftPhoneOptions } from "./types.js";
2
+
3
+ //#region src/utils.d.ts
4
+ declare const generateAuthorization: (sipInfo: SoftPhoneOptions, nonce: string, method: "REGISTER" | "INVITE") => string;
5
+ declare const uuid: () => `${string}-${string}-${string}-${string}-${string}`;
6
+ declare const branch: () => string;
7
+ declare const randomInt: () => number;
8
+ declare const withoutTag: (s: string) => string;
9
+ declare const extractAddress: (s: string) => string | undefined;
10
+ declare const localKey: string;
11
+ //#endregion
12
+ export { branch, extractAddress, generateAuthorization, localKey, randomInt, uuid, withoutTag };
package/dist/utils.js CHANGED
@@ -1,41 +1,25 @@
1
1
  import crypto from "node:crypto";
2
+ //#region src/utils.ts
2
3
  const md5 = (s) => crypto.createHash("md5").update(s).digest("hex");
3
4
  const generateResponse = (sipInfo, endpoint, nonce) => {
4
- const ha1 = md5(
5
- `${sipInfo.authorizationId}:${sipInfo.domain}:${sipInfo.password}`
6
- );
7
- const ha2 = md5(endpoint);
8
- const response = md5(`${ha1}:${nonce}:${ha2}`);
9
- return response;
5
+ return md5(`${md5(`${sipInfo.authorizationId}:${sipInfo.domain}:${sipInfo.password}`)}:${nonce}:${md5(endpoint)}`);
10
6
  };
11
7
  const generateAuthorization = (sipInfo, nonce, method) => {
12
- const authObj = {
13
- "Digest algorithm": "MD5",
14
- username: sipInfo.authorizationId,
15
- realm: sipInfo.domain,
16
- nonce,
17
- uri: `sip:${sipInfo.domain}`,
18
- response: generateResponse(
19
- sipInfo,
20
- `${method}:sip:${sipInfo.domain}`,
21
- nonce
22
- )
23
- };
24
- return Object.entries(authObj).map(([key, value]) => `${key}="${value}"`).join(", ");
8
+ const authObj = {
9
+ "Digest algorithm": "MD5",
10
+ username: sipInfo.authorizationId,
11
+ realm: sipInfo.domain,
12
+ nonce,
13
+ uri: `sip:${sipInfo.domain}`,
14
+ response: generateResponse(sipInfo, `${method}:sip:${sipInfo.domain}`, nonce)
15
+ };
16
+ return Object.entries(authObj).map(([key, value]) => `${key}="${value}"`).join(", ");
25
17
  };
26
18
  const uuid = () => crypto.randomUUID();
27
19
  const branch = () => `z9hG4bK-${uuid()}`;
28
- const randomInt = () => Math.floor(Math.random() * (65535 - 1024 + 1)) + 1024;
20
+ const randomInt = () => Math.floor(Math.random() * 64512) + 1024;
29
21
  const withoutTag = (s) => s.replace(/;tag=.*$/, "");
30
22
  const extractAddress = (s) => s.match(/<(sip:.+?)>/)?.[1];
31
- const keyAndSalt = crypto.randomBytes(30);
32
- const localKey = keyAndSalt.toString("base64").replace(/=+$/, "");
33
- export {
34
- branch,
35
- extractAddress,
36
- generateAuthorization,
37
- localKey,
38
- randomInt,
39
- uuid,
40
- withoutTag
41
- };
23
+ const localKey = crypto.randomBytes(30).toString("base64").replace(/=+$/, "");
24
+ //#endregion
25
+ export { branch, extractAddress, generateAuthorization, localKey, randomInt, uuid, withoutTag };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ringcentral-softphone",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "homepage": "https://github.com/ringcentral/ringcentral-softphone-ts",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,7 +30,7 @@
30
30
  "join": "rm -rf *.wav && tsx -r dotenv-override-true/config demos/join-rcv-meeting.ts",
31
31
  "multi": "tsx -r dotenv-override-true/config demos/multiple-calls-sequentially.ts",
32
32
  "lint": "biome check --write .",
33
- "build": "tsup && tsc -p tsconfig.json --emitDeclarationOnly",
33
+ "build": "tsdown",
34
34
  "prepublishOnly": "yarn build",
35
35
  "postpublish": "rm -rf dist"
36
36
  },
@@ -41,13 +41,13 @@
41
41
  "werift-rtp": "^0.8.8"
42
42
  },
43
43
  "devDependencies": {
44
- "@biomejs/biome": "^2.4.1",
44
+ "@biomejs/biome": "^2.4.12",
45
45
  "@types/node": "^25.6.0",
46
46
  "dotenv-override-true": "^6.2.2",
47
- "tsup": "^8.5.1",
47
+ "tsdown": "^0.21.10",
48
48
  "tsx": "^4.21.0",
49
49
  "typescript": "^6.0.3",
50
- "yarn-upgrade-all": "^0.7.5"
50
+ "yarn-upgrade-all": "^0.8.1"
51
51
  },
52
52
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
53
53
  }