@voicenter-team/opensips-js 1.0.144 → 1.0.146
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -0
- package/dist/opensips-js.cjs.js +2 -2
- package/dist/opensips-js.es.js +29 -33
- package/dist/opensips-js.iife.js +2 -2
- package/dist/opensips-js.umd.js +2 -2
- package/package.json +1 -1
package/dist/opensips-js.es.js
CHANGED
@@ -14207,47 +14207,47 @@ var Sh = class Au extends Dg {
|
|
14207
14207
|
* Terminate the call.
|
14208
14208
|
*/
|
14209
14209
|
terminate(t = {}) {
|
14210
|
-
|
14210
|
+
Y.debug("terminate()");
|
14211
14211
|
const n = t.cause || fe.causes.BYE, a = Be.cloneArray(t.extraHeaders), o = t.body;
|
14212
14212
|
let s, r = t.status_code, d = t.reason_phrase;
|
14213
14213
|
if (this._status === Z.STATUS_TERMINATED)
|
14214
|
-
throw
|
14214
|
+
throw new En.InvalidStateError(this._status);
|
14215
14215
|
switch (this._status) {
|
14216
14216
|
case Z.STATUS_NULL:
|
14217
14217
|
case Z.STATUS_INVITE_SENT:
|
14218
14218
|
case Z.STATUS_1XX_RECEIVED:
|
14219
14219
|
if (Y.debug("canceling session"), r && (r < 200 || r >= 700))
|
14220
|
-
throw
|
14220
|
+
throw new TypeError(`Invalid status_code: ${r}`);
|
14221
14221
|
r && (d = d || fe.REASON_PHRASE[r] || "", s = `SIP ;cause=${r} ;text="${d}"`), this._status === Z.STATUS_NULL || this._status === Z.STATUS_INVITE_SENT ? (this._is_canceled = !0, this._cancel_reason = s) : this._status === Z.STATUS_1XX_RECEIVED && this._request.cancel(s), this._status = Z.STATUS_CANCELED, this._failed("local", null, fe.causes.CANCELED);
|
14222
14222
|
break;
|
14223
14223
|
case Z.STATUS_WAITING_FOR_ANSWER:
|
14224
14224
|
case Z.STATUS_ANSWERED:
|
14225
|
-
if (
|
14226
|
-
throw
|
14227
|
-
|
14225
|
+
if (Y.debug("rejecting session"), r = r || 480, r < 300 || r >= 700)
|
14226
|
+
throw new TypeError(`Invalid status_code: ${r}`);
|
14227
|
+
this._request.reply(r, d, a, o), this._failed("local", null, fe.causes.REJECTED);
|
14228
14228
|
break;
|
14229
14229
|
case Z.STATUS_WAITING_FOR_ACK:
|
14230
14230
|
case Z.STATUS_CONFIRMED:
|
14231
|
-
if (
|
14232
|
-
throw
|
14231
|
+
if (Y.debug("terminating session"), d = t.reason_phrase || fe.REASON_PHRASE[r] || "", r && (r < 200 || r >= 700))
|
14232
|
+
throw new TypeError(`Invalid status_code: ${r}`);
|
14233
14233
|
if (r && a.push(`Reason: SIP ;cause=${r}; text="${d}"`), this._status === Z.STATUS_WAITING_FOR_ACK && this._direction === "incoming" && this._request.server_transaction.state !== Tf.C.STATUS_TERMINATED) {
|
14234
14234
|
const h = this._dialog;
|
14235
14235
|
this.receiveRequest = ({ method: _ }) => {
|
14236
14236
|
_ === fe.ACK && (this.sendRequest(fe.BYE, {
|
14237
14237
|
extraHeaders: a,
|
14238
14238
|
body: o
|
14239
|
-
}),
|
14239
|
+
}), h.terminate());
|
14240
14240
|
}, this._request.server_transaction.on("stateChanged", () => {
|
14241
14241
|
this._request.server_transaction.state === Tf.C.STATUS_TERMINATED && (this.sendRequest(fe.BYE, {
|
14242
14242
|
extraHeaders: a,
|
14243
14243
|
body: o
|
14244
|
-
}),
|
14245
|
-
}),
|
14244
|
+
}), h.terminate());
|
14245
|
+
}), this._ended("local", null, n), this._dialog = h, this._ua.newDialog(h);
|
14246
14246
|
} else
|
14247
14247
|
this.sendRequest(fe.BYE, {
|
14248
14248
|
extraHeaders: a,
|
14249
14249
|
body: o
|
14250
|
-
}),
|
14250
|
+
}), this._ended("local", null, n);
|
14251
14251
|
}
|
14252
14252
|
}
|
14253
14253
|
sendDTMF(t, n = {}) {
|
@@ -19554,13 +19554,7 @@ const $T = {
|
|
19554
19554
|
}, Wi = new Wa("Registrator"), ha = 10;
|
19555
19555
|
class HT {
|
19556
19556
|
constructor(t, n) {
|
19557
|
-
this._reg_id = 1, this._ua = t, this._transport = n, this._registrar = t.configuration.registrar_server, this._expires = t.configuration.register_expires, this._call_id = Ts.createRandomToken(22), this._cseq = 0, this._to_uri = t.configuration.uri, this._registrationTimer = null, this._registering = !1, this._registered = !1, this._contact = this._ua.contact.toString()
|
19558
|
-
const a = this._contact.indexOf(">");
|
19559
|
-
if (a !== -1) {
|
19560
|
-
const o = this._contact.slice(0, a) + this._contact.slice(a + 1, this._contact.length);
|
19561
|
-
this._contact = o;
|
19562
|
-
}
|
19563
|
-
this._extra_contact = "", this._extraContactParams = "", this._extra_contact += ";+sip.ice", this._extraHeaders = [], this._sipInstance = `"<urn:uuid:${this._ua.configuration.instance_id}>"`, this._extra_contact += `;reg-id=${this._reg_id}`, this._extra_contact += `;+sip.instance=${this._sipInstance}`;
|
19557
|
+
this._reg_id = 1, this._ua = t, this._transport = n, this._registrar = t.configuration.registrar_server, this._expires = t.configuration.register_expires, this._call_id = Ts.createRandomToken(22), this._cseq = 0, this._to_uri = t.configuration.uri, this._registrationTimer = null, this._registering = !1, this._registered = !1, this._contact = this._ua.contact.toString(), this._contact += ";+sip.ice", this._extraHeaders = [], this._extraContactParams = "", this._sipInstance = `"<urn:uuid:${this._ua.configuration.instance_id}>"`, this._contact += `;reg-id=${this._reg_id}`, this._contact += `;+sip.instance=${this._sipInstance}`;
|
19564
19558
|
}
|
19565
19559
|
get registered() {
|
19566
19560
|
return this._registered;
|
@@ -19576,21 +19570,13 @@ class HT {
|
|
19576
19570
|
this._extraContactParams += `;${n}`, a && (this._extraContactParams += `=${a}`);
|
19577
19571
|
}
|
19578
19572
|
}
|
19579
|
-
setExtraContactUriParams(t) {
|
19580
|
-
t instanceof Object || (t = {}), this._extraContactParams = "";
|
19581
|
-
for (const n in t)
|
19582
|
-
if (Object.prototype.hasOwnProperty.call(t, n)) {
|
19583
|
-
const a = t[n];
|
19584
|
-
this._extraContactParams += `;${n}`, a && (this._extraContactParams += `=${a}`);
|
19585
|
-
}
|
19586
|
-
}
|
19587
19573
|
register() {
|
19588
19574
|
if (this._registering) {
|
19589
19575
|
Wi.debug("Register request in progress...");
|
19590
19576
|
return;
|
19591
19577
|
}
|
19592
19578
|
const t = this._extraHeaders.slice();
|
19593
|
-
t.push(`Contact: ${this._contact}
|
19579
|
+
t.push(`Contact: ${this._contact};expires=${this._expires}${this._extraContactParams}`), t.push(`Expires: ${this._expires}`);
|
19594
19580
|
const n = new yt.OutgoingRequest(
|
19595
19581
|
L.REGISTER,
|
19596
19582
|
this._registrar,
|
@@ -19613,7 +19599,7 @@ class HT {
|
|
19613
19599
|
this._cseq += 1;
|
19614
19600
|
},
|
19615
19601
|
onReceiveResponse: (o) => {
|
19616
|
-
if (o.cseq === this._cseq)
|
19602
|
+
if (console.log("register onReceiveResponse", o), o.cseq === this._cseq)
|
19617
19603
|
switch (this._registrationTimer !== null && (clearTimeout(this._registrationTimer), this._registrationTimer = null), !0) {
|
19618
19604
|
case /^1[0-9]{2}$/.test(o.status_code):
|
19619
19605
|
break;
|
@@ -19628,6 +19614,7 @@ class HT {
|
|
19628
19614
|
Wi.debug("no Contact header pointing to us, response ignored");
|
19629
19615
|
break;
|
19630
19616
|
}
|
19617
|
+
this._ua.clearKeepAliveInterval(), this._ua.setLastRegisterTimestamp();
|
19631
19618
|
let d = r.getParam("expires");
|
19632
19619
|
!d && o.hasHeader("expires") && (d = o.getHeader("expires")), d || (d = this._expires), d = Number(d), d < ha && (d = ha);
|
19633
19620
|
const h = d > 64 ? d * 1e3 / 2 + Math.floor((d / 2 - 32) * 1e3 * Math.random()) : d * 1e3 - 5e3;
|
@@ -19656,7 +19643,7 @@ class HT {
|
|
19656
19643
|
}
|
19657
19644
|
this._registered = !1, this._registrationTimer !== null && (clearTimeout(this._registrationTimer), this._registrationTimer = null);
|
19658
19645
|
const n = this._extraHeaders.slice();
|
19659
|
-
t.all ? n.push(`Contact: *${this._extraContactParams}`) : n.push(`Contact: ${this._contact}${this._extraContactParams}
|
19646
|
+
t.all ? n.push(`Contact: *${this._extraContactParams}`) : n.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`), n.push("Expires: 0");
|
19660
19647
|
const a = new yt.OutgoingRequest(
|
19661
19648
|
L.REGISTER,
|
19662
19649
|
this._registrar,
|
@@ -19734,7 +19721,10 @@ class jT extends FT {
|
|
19734
19721
|
nict: {},
|
19735
19722
|
ist: {},
|
19736
19723
|
ict: {}
|
19737
|
-
}, this._janus_sessions = [], this.newStreamPlugins = [], this.processStreamPlugins = [], this._registrator = new HT(this);
|
19724
|
+
}, this._janus_sessions = [], this.newStreamPlugins = [], this.processStreamPlugins = [], this.optionsInterval = null, this.lastOptionsTimestamp = null, this.lastRegisterTimestamp = null, this._registrator = new HT(this);
|
19725
|
+
}
|
19726
|
+
setLastRegisterTimestamp() {
|
19727
|
+
this.lastRegisterTimestamp = Date.now();
|
19738
19728
|
}
|
19739
19729
|
call(t, n) {
|
19740
19730
|
return super.call(t, n);
|
@@ -19867,6 +19857,9 @@ class jT extends FT {
|
|
19867
19857
|
destroyJanusSession(t) {
|
19868
19858
|
delete this._janus_sessions[t.id];
|
19869
19859
|
}
|
19860
|
+
clearKeepAliveInterval() {
|
19861
|
+
clearInterval(this.optionsInterval), this.optionsInterval = null;
|
19862
|
+
}
|
19870
19863
|
receiveRequest(t) {
|
19871
19864
|
var s, r, d, h;
|
19872
19865
|
const n = t.method;
|
@@ -19881,7 +19874,10 @@ class jT extends FT {
|
|
19881
19874
|
if (Gt.checkTransaction(this, t))
|
19882
19875
|
return;
|
19883
19876
|
if (n === De.INVITE ? new Gt.InviteServerTransaction(this, this._transport, t) : n !== De.ACK && n !== De.CANCEL && new Gt.NonInviteServerTransaction(this, this._transport, t), n === De.OPTIONS) {
|
19884
|
-
if (this.
|
19877
|
+
if (this.lastOptionsTimestamp = Date.now(), this.optionsInterval || (this.emit("initKeepAliveInterval"), this.optionsInterval = setInterval(() => {
|
19878
|
+
const g = Date.now();
|
19879
|
+
this.lastOptionsTimestamp > g - 35e3 && this.lastRegisterTimestamp + this._configuration.register_expires * 1e3 > g && this.emit("keepAliveInterval");
|
19880
|
+
}, 35e3)), this.listeners("newOptions").length === 0) {
|
19885
19881
|
t.reply(200);
|
19886
19882
|
return;
|
19887
19883
|
}
|
@@ -20043,7 +20039,7 @@ function qT(c) {
|
|
20043
20039
|
this.emit("connecting", c);
|
20044
20040
|
}
|
20045
20041
|
function VT(c) {
|
20046
|
-
this._status !== Vs.STATUS_USER_CLOSED && (this._status = Vs.STATUS_READY, this._error = null, this.emit("connected", c), this._dynConfiguration.register && this._registrator.register());
|
20042
|
+
this._status !== Vs.STATUS_USER_CLOSED && (this._status = Vs.STATUS_READY, this._error = null, this.emit("connected", c), this._dynConfiguration.register && (console.log("do register"), this._registrator.register()));
|
20047
20043
|
}
|
20048
20044
|
function BT(c) {
|
20049
20045
|
const t = ["nict", "ict", "nist", "ist"];
|