@voicenter-team/opensips-js 1.0.138 → 1.0.139

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.
@@ -8881,8 +8881,8 @@ function jc(c, t) {
8881
8881
  a[n] = c[n];
8882
8882
  return a;
8883
8883
  }
8884
- var Jp = ht, lh = lt, qc = Ss, ku = bt(), Mu = new Jp("sanityCheck"), zp = [lm], Xp = [em, tm, sm, nm], Qp = [rm, im], Fe, rs, ah, Zp = function(c, t, n) {
8885
- Fe = c, rs = t, ah = n;
8884
+ var Jp = ht, lh = lt, qc = Ss, ku = bt(), Mu = new Jp("sanityCheck"), zp = [lm], Xp = [em, tm, sm, nm], Qp = [rm, im], He, rs, ah, Zp = function(c, t, n) {
8885
+ He = c, rs = t, ah = n;
8886
8886
  var a = Ia(zp), o;
8887
8887
  try {
8888
8888
  for (a.s(); !(o = a.n()).done; ) {
@@ -8895,7 +8895,7 @@ var Jp = ht, lh = lt, qc = Ss, ku = bt(), Mu = new Jp("sanityCheck"), zp = [lm],
8895
8895
  } finally {
8896
8896
  a.f();
8897
8897
  }
8898
- if (Fe instanceof qc.IncomingRequest) {
8898
+ if (He instanceof qc.IncomingRequest) {
8899
8899
  var r = Ia(Xp), d;
8900
8900
  try {
8901
8901
  for (r.s(); !(d = r.n()).done; ) {
@@ -8908,7 +8908,7 @@ var Jp = ht, lh = lt, qc = Ss, ku = bt(), Mu = new Jp("sanityCheck"), zp = [lm],
8908
8908
  } finally {
8909
8909
  r.f();
8910
8910
  }
8911
- } else if (Fe instanceof qc.IncomingResponse) {
8911
+ } else if (He instanceof qc.IncomingResponse) {
8912
8912
  var _ = Ia(Qp), g;
8913
8913
  try {
8914
8914
  for (_.s(); !(g = _.n()).done; ) {
@@ -8925,29 +8925,29 @@ var Jp = ht, lh = lt, qc = Ss, ku = bt(), Mu = new Jp("sanityCheck"), zp = [lm],
8925
8925
  return !0;
8926
8926
  };
8927
8927
  function em() {
8928
- if (Fe.s("to").uri.scheme !== "sip")
8928
+ if (He.s("to").uri.scheme !== "sip")
8929
8929
  return tl(416), !1;
8930
8930
  }
8931
8931
  function tm() {
8932
- if (!Fe.to_tag && Fe.call_id.substr(0, 5) === rs.configuration.jssip_id)
8932
+ if (!He.to_tag && He.call_id.substr(0, 5) === rs.configuration.jssip_id)
8933
8933
  return tl(482), !1;
8934
8934
  }
8935
8935
  function sm() {
8936
- var c = ku.str_utf8_length(Fe.body), t = Fe.getHeader("content-length");
8936
+ var c = ku.str_utf8_length(He.body), t = He.getHeader("content-length");
8937
8937
  if (c < t)
8938
8938
  return tl(400), !1;
8939
8939
  }
8940
8940
  function nm() {
8941
- var c = Fe.from_tag, t = Fe.call_id, n = Fe.cseq, a;
8942
- if (!Fe.to_tag)
8943
- if (Fe.method === lh.INVITE) {
8944
- if (rs._transactions.ist[Fe.via_branch])
8941
+ var c = He.from_tag, t = He.call_id, n = He.cseq, a;
8942
+ if (!He.to_tag)
8943
+ if (He.method === lh.INVITE) {
8944
+ if (rs._transactions.ist[He.via_branch])
8945
8945
  return !1;
8946
8946
  for (var o in rs._transactions.ist)
8947
8947
  if (Object.prototype.hasOwnProperty.call(rs._transactions.ist, o) && (a = rs._transactions.ist[o], a.request.from_tag === c && a.request.call_id === t && a.request.cseq === n))
8948
8948
  return tl(482), !1;
8949
8949
  } else {
8950
- if (rs._transactions.nist[Fe.via_branch])
8950
+ if (rs._transactions.nist[He.via_branch])
8951
8951
  return !1;
8952
8952
  for (var s in rs._transactions.nist)
8953
8953
  if (Object.prototype.hasOwnProperty.call(rs._transactions.nist, s) && (a = rs._transactions.nist[s], a.request.from_tag === c && a.request.call_id === t && a.request.cseq === n))
@@ -8955,23 +8955,23 @@ function nm() {
8955
8955
  }
8956
8956
  }
8957
8957
  function rm() {
8958
- if (Fe.getHeaders("via").length > 1)
8958
+ if (He.getHeaders("via").length > 1)
8959
8959
  return Mu.debug("more than one Via header field present in the response, dropping the response"), !1;
8960
8960
  }
8961
8961
  function im() {
8962
- var c = ku.str_utf8_length(Fe.body), t = Fe.getHeader("content-length");
8962
+ var c = ku.str_utf8_length(He.body), t = He.getHeader("content-length");
8963
8963
  if (c < t)
8964
8964
  return Mu.debug("message body length is lower than the value in Content-Length header field, dropping the response"), !1;
8965
8965
  }
8966
8966
  function lm() {
8967
8967
  for (var c = ["from", "to", "call_id", "cseq", "via"], t = 0, n = c; t < n.length; t++) {
8968
8968
  var a = n[t];
8969
- if (!Fe.hasHeader(a))
8969
+ if (!He.hasHeader(a))
8970
8970
  return Mu.debug("missing mandatory header field : ".concat(a, ", dropping the response")), !1;
8971
8971
  }
8972
8972
  }
8973
8973
  function tl(c) {
8974
- var t = Fe.getHeaders("via"), n, a = "SIP/2.0 ".concat(c, " ").concat(lh.REASON_PHRASE[c], `\r
8974
+ var t = He.getHeaders("via"), n, a = "SIP/2.0 ".concat(c, " ").concat(lh.REASON_PHRASE[c], `\r
8975
8975
  `), o = Ia(t), s;
8976
8976
  try {
8977
8977
  for (o.s(); !(s = o.n()).done; ) {
@@ -8984,10 +8984,10 @@ function tl(c) {
8984
8984
  } finally {
8985
8985
  o.f();
8986
8986
  }
8987
- n = Fe.getHeader("To"), Fe.to_tag || (n += ";tag=".concat(ku.newTag())), a += "To: ".concat(n, `\r
8988
- `), a += "From: ".concat(Fe.getHeader("From"), `\r
8989
- `), a += "Call-ID: ".concat(Fe.call_id, `\r
8990
- `), a += "CSeq: ".concat(Fe.cseq, " ").concat(Fe.method, `\r
8987
+ n = He.getHeader("To"), He.to_tag || (n += ";tag=".concat(ku.newTag())), a += "To: ".concat(n, `\r
8988
+ `), a += "From: ".concat(He.getHeader("From"), `\r
8989
+ `), a += "Call-ID: ".concat(He.call_id, `\r
8990
+ `), a += "CSeq: ".concat(He.cseq, " ").concat(He.method, `\r
8991
8991
  `), a += `\r
8992
8992
  `, ah.send(a);
8993
8993
  }
@@ -9312,7 +9312,7 @@ function La(c) {
9312
9312
  return n.__proto__ || Object.getPrototypeOf(n);
9313
9313
  }, La(c);
9314
9314
  }
9315
- var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp, No = hl, mm = Vp, Jl = bt(), gm = Ws, Tm = Ks(), vm = ih, Uo = Ss, Em = Zp, Po = Lu, qe = new _m("UA"), Tt = {
9315
+ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp, No = hl, mm = Vp, Jl = bt(), gm = Ws, Tm = Ks(), vm = ih, Uo = Ss, Em = Zp, Po = Lu, je = new _m("UA"), Tt = {
9316
9316
  // UA status codes.
9317
9317
  STATUS_INIT: 0,
9318
9318
  STATUS_READY: 1,
@@ -9333,7 +9333,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9333
9333
  }]);
9334
9334
  function n(a) {
9335
9335
  var o;
9336
- if (om(this, n), console.log("constructor es5"), qe.debug("new() [configuration:%o]", a), o = t.call(this), o._cache = {
9336
+ if (om(this, n), je.debug("new() [configuration:%o]", a), o = t.call(this), o._cache = {
9337
9337
  credentials: {}
9338
9338
  }, o._configuration = Object.assign({}, Po.settings), o._dynConfiguration = {}, o._dialogs = {}, o._applicants = {}, o._sessions = {}, o._transport = null, o._contact = null, o._status = Tt.STATUS_INIT, o._error = null, o._transactions = {
9339
9339
  nist: {},
@@ -9359,7 +9359,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9359
9359
  * Resume UA after being closed.
9360
9360
  */
9361
9361
  value: function() {
9362
- qe.debug("start()"), this._status === Tt.STATUS_INIT ? this._transport.connect() : this._status === Tt.STATUS_USER_CLOSED ? (qe.debug("restarting UA"), this._closeTimer !== null && (clearTimeout(this._closeTimer), this._closeTimer = null, this._transport.disconnect()), this._status = Tt.STATUS_INIT, this._transport.connect()) : this._status === Tt.STATUS_READY ? qe.debug("UA is in READY status, not restarted") : qe.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"), this._dynConfiguration.register = this._configuration.register;
9362
+ je.debug("start()"), this._status === Tt.STATUS_INIT ? this._transport.connect() : this._status === Tt.STATUS_USER_CLOSED ? (je.debug("restarting UA"), this._closeTimer !== null && (clearTimeout(this._closeTimer), this._closeTimer = null, this._transport.disconnect()), this._status = Tt.STATUS_INIT, this._transport.connect()) : this._status === Tt.STATUS_READY ? je.debug("UA is in READY status, not restarted") : je.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"), this._dynConfiguration.register = this._configuration.register;
9363
9363
  }
9364
9364
  /**
9365
9365
  * Register.
@@ -9367,7 +9367,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9367
9367
  }, {
9368
9368
  key: "register",
9369
9369
  value: function() {
9370
- qe.debug("register()"), this._dynConfiguration.register = !0, this._registrator.register();
9370
+ je.debug("register()"), this._dynConfiguration.register = !0, this._registrator.register();
9371
9371
  }
9372
9372
  /**
9373
9373
  * Unregister.
@@ -9375,7 +9375,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9375
9375
  }, {
9376
9376
  key: "unregister",
9377
9377
  value: function(o) {
9378
- qe.debug("unregister()"), this._dynConfiguration.register = !1, this._registrator.unregister(o);
9378
+ je.debug("unregister()"), this._dynConfiguration.register = !1, this._registrator.unregister(o);
9379
9379
  }
9380
9380
  /**
9381
9381
  * Get the Registrator instance.
@@ -9413,7 +9413,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9413
9413
  }, {
9414
9414
  key: "call",
9415
9415
  value: function(o, s) {
9416
- qe.debug("call()");
9416
+ je.debug("call()");
9417
9417
  var r = new Yc(this);
9418
9418
  return r.connect(o, s), r;
9419
9419
  }
@@ -9430,7 +9430,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9430
9430
  }, {
9431
9431
  key: "sendMessage",
9432
9432
  value: function(o, s, r) {
9433
- qe.debug("sendMessage()");
9433
+ je.debug("sendMessage()");
9434
9434
  var d = new Jc(this);
9435
9435
  return d.send(o, s, r), d;
9436
9436
  }
@@ -9447,7 +9447,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9447
9447
  }, {
9448
9448
  key: "sendOptions",
9449
9449
  value: function(o, s, r) {
9450
- qe.debug("sendOptions()");
9450
+ je.debug("sendOptions()");
9451
9451
  var d = new zc(this);
9452
9452
  return d.send(o, s, r), d;
9453
9453
  }
@@ -9457,7 +9457,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9457
9457
  }, {
9458
9458
  key: "terminateSessions",
9459
9459
  value: function(o) {
9460
- qe.debug("terminateSessions()");
9460
+ je.debug("terminateSessions()");
9461
9461
  for (var s in this._sessions)
9462
9462
  this._sessions[s].isEnded() || this._sessions[s].terminate(o);
9463
9463
  }
@@ -9469,15 +9469,15 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9469
9469
  key: "stop",
9470
9470
  value: function() {
9471
9471
  var o = this;
9472
- if (qe.debug("stop()"), this._dynConfiguration = {}, this._status === Tt.STATUS_USER_CLOSED) {
9473
- qe.debug("UA already closed");
9472
+ if (je.debug("stop()"), this._dynConfiguration = {}, this._status === Tt.STATUS_USER_CLOSED) {
9473
+ je.debug("UA already closed");
9474
9474
  return;
9475
9475
  }
9476
9476
  this._registrator.close();
9477
9477
  var s = Object.keys(this._sessions).length;
9478
9478
  for (var r in this._sessions)
9479
9479
  if (Object.prototype.hasOwnProperty.call(this._sessions, r)) {
9480
- qe.debug("closing session ".concat(r));
9480
+ je.debug("closing session ".concat(r));
9481
9481
  try {
9482
9482
  this._sessions[r].terminate();
9483
9483
  } catch {
@@ -9521,7 +9521,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9521
9521
  case "authorization_jwt":
9522
9522
  return this._configuration.authorization_jwt;
9523
9523
  default:
9524
- qe.warn('get() | cannot get "%s" parameter in runtime', o);
9524
+ je.warn('get() | cannot get "%s" parameter in runtime', o);
9525
9525
  return;
9526
9526
  }
9527
9527
  }
@@ -9558,7 +9558,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9558
9558
  break;
9559
9559
  }
9560
9560
  default:
9561
- return qe.warn('set() | cannot set "%s" parameter in runtime', o), !1;
9561
+ return je.warn('set() | cannot set "%s" parameter in runtime', o), !1;
9562
9562
  }
9563
9563
  return !0;
9564
9564
  }
@@ -9674,10 +9674,9 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9674
9674
  }, {
9675
9675
  key: "receiveRequest",
9676
9676
  value: function(o) {
9677
- console.log("receiveRequest");
9678
9677
  var s = o.method;
9679
9678
  if (o.ruri.user !== this._configuration.uri.user && o.ruri.user !== this._contact.uri.user) {
9680
- qe.debug("Request-URI does not point to us"), o.method !== pt.ACK && o.reply_sl(404);
9679
+ je.debug("Request-URI does not point to us"), o.method !== pt.ACK && o.reply_sl(404);
9681
9680
  return;
9682
9681
  }
9683
9682
  if (o.ruri.scheme === pt.SIPS) {
@@ -9686,7 +9685,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9686
9685
  }
9687
9686
  if (!No.checkTransaction(this, o)) {
9688
9687
  if (s === pt.INVITE ? new No.InviteServerTransaction(this, this._transport, o) : s !== pt.ACK && s !== pt.CANCEL && new No.NonInviteServerTransaction(this, this._transport, o), s === pt.OPTIONS) {
9689
- if (console.log("OPPP in option"), this.listeners("newOptions").length === 0) {
9688
+ if (this.listeners("newOptions").length === 0) {
9690
9689
  o.reply(200);
9691
9690
  return;
9692
9691
  }
@@ -9705,7 +9704,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9705
9704
  }
9706
9705
  var h, _;
9707
9706
  if (o.to_tag)
9708
- h = this._findDialog(o.call_id, o.from_tag, o.to_tag), h ? h.receiveRequest(o) : s === pt.NOTIFY ? (_ = this._findSession(o), _ ? _.receiveRequest(o) : (qe.debug("received NOTIFY request for a non existent subscription"), o.reply(481, "Subscription does not exist"))) : s !== pt.ACK && o.reply(481);
9707
+ h = this._findDialog(o.call_id, o.from_tag, o.to_tag), h ? h.receiveRequest(o) : s === pt.NOTIFY ? (_ = this._findSession(o), _ ? _.receiveRequest(o) : (je.debug("received NOTIFY request for a non existent subscription"), o.reply(481, "Subscription does not exist"))) : s !== pt.ACK && o.reply(481);
9709
9708
  else
9710
9709
  switch (s) {
9711
9710
  case pt.INVITE:
@@ -9716,13 +9715,13 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9716
9715
  } else
9717
9716
  _ = new Yc(this), _.init_incoming(o);
9718
9717
  else
9719
- qe.warn("INVITE received but WebRTC is not supported"), o.reply(488);
9718
+ je.warn("INVITE received but WebRTC is not supported"), o.reply(488);
9720
9719
  break;
9721
9720
  case pt.BYE:
9722
9721
  o.reply(481);
9723
9722
  break;
9724
9723
  case pt.CANCEL:
9725
- _ = this._findSession(o), _ ? _.receiveRequest(o) : qe.debug("received CANCEL request for a non existent session");
9724
+ _ = this._findSession(o), _ ? _.receiveRequest(o) : je.debug("received CANCEL request for a non existent session");
9726
9725
  break;
9727
9726
  case pt.ACK:
9728
9727
  break;
@@ -9777,7 +9776,7 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9777
9776
  min_interval: this._configuration.connection_recovery_min_interval
9778
9777
  }), this._transport.onconnecting = ym.bind(this), this._transport.onconnect = Cm.bind(this), this._transport.ondisconnect = Am.bind(this), this._transport.ondata = Rm.bind(this);
9779
9778
  } catch (g) {
9780
- throw qe.warn(g), new gm.ConfigurationError("sockets", this._configuration.sockets);
9779
+ throw je.warn(g), new gm.ConfigurationError("sockets", this._configuration.sockets);
9781
9780
  }
9782
9781
  if (delete this._configuration.sockets, this._configuration.authorization_user || (this._configuration.authorization_user = this._configuration.uri.user), !this._configuration.registrar_server) {
9783
9782
  var r = this._configuration.uri.clone();
@@ -9803,21 +9802,21 @@ var dm = ft.EventEmitter, _m = ht, pt = lt, pm = s_, Yc = fp, Jc = Ap, zc = Mp,
9803
9802
  writable: !1,
9804
9803
  configurable: !1
9805
9804
  }));
9806
- qe.debug("configuration parameters after validation:");
9805
+ je.debug("configuration parameters after validation:");
9807
9806
  for (var _ in this._configuration)
9808
9807
  if (Object.prototype.hasOwnProperty.call(Po.settings, _))
9809
9808
  switch (_) {
9810
9809
  case "uri":
9811
9810
  case "registrar_server":
9812
- qe.debug("- ".concat(_, ": ").concat(this._configuration[_]));
9811
+ je.debug("- ".concat(_, ": ").concat(this._configuration[_]));
9813
9812
  break;
9814
9813
  case "password":
9815
9814
  case "ha1":
9816
9815
  case "authorization_jwt":
9817
- qe.debug("- ".concat(_, ": NOT SHOWN"));
9816
+ je.debug("- ".concat(_, ": NOT SHOWN"));
9818
9817
  break;
9819
9818
  default:
9820
- qe.debug("- ".concat(_, ": ").concat(JSON.stringify(this._configuration[_])));
9819
+ je.debug("- ".concat(_, ": ").concat(JSON.stringify(this._configuration[_])));
9821
9820
  }
9822
9821
  }
9823
9822
  }, {
@@ -9862,7 +9861,6 @@ function Am(c) {
9862
9861
  this.emit("disconnected", c), this._registrator.onTransportClosed(), this._status !== Tt.STATUS_USER_CLOSED && (this._status = Tt.STATUS_NOT_READY, this._error = Tt.NETWORK_ERROR);
9863
9862
  }
9864
9863
  function Rm(c) {
9865
- console.log("onTransportData");
9866
9864
  var t = c.transport, n = c.message;
9867
9865
  if (n = vm.parseMessage(n, this), !!n && !(this._status === Tt.STATUS_USER_CLOSED && n instanceof Uo.IncomingRequest) && Em(n, this, t)) {
9868
9866
  if (n instanceof Uo.IncomingRequest)
@@ -15831,17 +15829,17 @@ const sT = ut, Ah = De, Af = yt, Vu = Ct(), Bu = new sT("sanityCheck"), nT = [hT
15831
15829
  cT,
15832
15830
  fT
15833
15831
  ];
15834
- let je, is, Rh;
15832
+ let Fe, is, Rh;
15835
15833
  var Ih = (c, t, n) => {
15836
- je = c, is = t, Rh = n;
15834
+ Fe = c, is = t, Rh = n;
15837
15835
  for (const a of nT)
15838
15836
  if (a() === !1)
15839
15837
  return !1;
15840
- if (je instanceof Af.IncomingRequest) {
15838
+ if (Fe instanceof Af.IncomingRequest) {
15841
15839
  for (const a of rT)
15842
15840
  if (a() === !1)
15843
15841
  return !1;
15844
- } else if (je instanceof Af.IncomingResponse) {
15842
+ } else if (Fe instanceof Af.IncomingResponse) {
15845
15843
  for (const a of iT)
15846
15844
  if (a() === !1)
15847
15845
  return !1;
@@ -15849,30 +15847,30 @@ var Ih = (c, t, n) => {
15849
15847
  return !0;
15850
15848
  };
15851
15849
  function lT() {
15852
- if (je.s("to").uri.scheme !== "sip")
15850
+ if (Fe.s("to").uri.scheme !== "sip")
15853
15851
  return nl(416), !1;
15854
15852
  }
15855
15853
  function aT() {
15856
- if (!je.to_tag && je.call_id.substr(0, 5) === is.configuration.jssip_id)
15854
+ if (!Fe.to_tag && Fe.call_id.substr(0, 5) === is.configuration.jssip_id)
15857
15855
  return nl(482), !1;
15858
15856
  }
15859
15857
  function oT() {
15860
- const c = Vu.str_utf8_length(je.body), t = je.getHeader("content-length");
15858
+ const c = Vu.str_utf8_length(Fe.body), t = Fe.getHeader("content-length");
15861
15859
  if (c < t)
15862
15860
  return nl(400), !1;
15863
15861
  }
15864
15862
  function uT() {
15865
- const c = je.from_tag, t = je.call_id, n = je.cseq;
15863
+ const c = Fe.from_tag, t = Fe.call_id, n = Fe.cseq;
15866
15864
  let a;
15867
- if (!je.to_tag)
15868
- if (je.method === Ah.INVITE) {
15869
- if (is._transactions.ist[je.via_branch])
15865
+ if (!Fe.to_tag)
15866
+ if (Fe.method === Ah.INVITE) {
15867
+ if (is._transactions.ist[Fe.via_branch])
15870
15868
  return !1;
15871
15869
  for (const o in is._transactions.ist)
15872
15870
  if (Object.prototype.hasOwnProperty.call(is._transactions.ist, o) && (a = is._transactions.ist[o], a.request.from_tag === c && a.request.call_id === t && a.request.cseq === n))
15873
15871
  return nl(482), !1;
15874
15872
  } else {
15875
- if (is._transactions.nist[je.via_branch])
15873
+ if (is._transactions.nist[Fe.via_branch])
15876
15874
  return !1;
15877
15875
  for (const o in is._transactions.nist)
15878
15876
  if (Object.prototype.hasOwnProperty.call(is._transactions.nist, o) && (a = is._transactions.nist[o], a.request.from_tag === c && a.request.call_id === t && a.request.cseq === n))
@@ -15880,31 +15878,31 @@ function uT() {
15880
15878
  }
15881
15879
  }
15882
15880
  function cT() {
15883
- if (je.getHeaders("via").length > 1)
15881
+ if (Fe.getHeaders("via").length > 1)
15884
15882
  return Bu.debug("more than one Via header field present in the response, dropping the response"), !1;
15885
15883
  }
15886
15884
  function fT() {
15887
- const c = Vu.str_utf8_length(je.body), t = je.getHeader("content-length");
15885
+ const c = Vu.str_utf8_length(Fe.body), t = Fe.getHeader("content-length");
15888
15886
  if (c < t)
15889
15887
  return Bu.debug("message body length is lower than the value in Content-Length header field, dropping the response"), !1;
15890
15888
  }
15891
15889
  function hT() {
15892
15890
  const c = ["from", "to", "call_id", "cseq", "via"];
15893
15891
  for (const t of c)
15894
- if (!je.hasHeader(t))
15892
+ if (!Fe.hasHeader(t))
15895
15893
  return Bu.debug(`missing mandatory header field : ${t}, dropping the response`), !1;
15896
15894
  }
15897
15895
  function nl(c) {
15898
- const t = je.getHeaders("via");
15896
+ const t = Fe.getHeaders("via");
15899
15897
  let n, a = `SIP/2.0 ${c} ${Ah.REASON_PHRASE[c]}\r
15900
15898
  `;
15901
15899
  for (const o of t)
15902
15900
  a += `Via: ${o}\r
15903
15901
  `;
15904
- n = je.getHeader("To"), je.to_tag || (n += `;tag=${Vu.newTag()}`), a += `To: ${n}\r
15905
- `, a += `From: ${je.getHeader("From")}\r
15906
- `, a += `Call-ID: ${je.call_id}\r
15907
- `, a += `CSeq: ${je.cseq} ${je.method}\r
15902
+ n = Fe.getHeader("To"), Fe.to_tag || (n += `;tag=${Vu.newTag()}`), a += `To: ${n}\r
15903
+ `, a += `From: ${Fe.getHeader("From")}\r
15904
+ `, a += `Call-ID: ${Fe.call_id}\r
15905
+ `, a += `CSeq: ${Fe.cseq} ${Fe.method}\r
15908
15906
  `, a += `\r
15909
15907
  `, Rh.send(a);
15910
15908
  }
@@ -16090,7 +16088,7 @@ rl.load = (c, t) => {
16090
16088
  throw new Xo.ConfigurationError(n, a);
16091
16089
  }
16092
16090
  };
16093
- const _T = ft.EventEmitter, pT = ut, mt = De, mT = rg, If = Sh, bf = qg, wf = Kg, Qo = Tr, gT = yh, aa = Ct(), TT = Cs, vT = ys(), ET = Ch, Zo = yt, ST = Ih, eu = rl, He = new pT("UA"), vt = {
16091
+ const _T = ft.EventEmitter, pT = ut, mt = De, mT = rg, If = Sh, bf = qg, wf = Kg, Qo = Tr, gT = yh, aa = Ct(), TT = Cs, vT = ys(), ET = Ch, Zo = yt, ST = Ih, eu = rl, qe = new pT("UA"), vt = {
16094
16092
  // UA status codes.
16095
16093
  STATUS_INIT: 0,
16096
16094
  STATUS_READY: 1,
@@ -16106,7 +16104,7 @@ var bh = class extends _T {
16106
16104
  return vt;
16107
16105
  }
16108
16106
  constructor(t) {
16109
- if (He.debug("new() [configuration:%o]", t), super(), this._cache = {
16107
+ if (qe.debug("new() [configuration:%o]", t), super(), this._cache = {
16110
16108
  credentials: {}
16111
16109
  }, this._configuration = Object.assign({}, eu.settings), this._dynConfiguration = {}, this._dialogs = {}, this._applicants = {}, this._sessions = {}, this._transport = null, this._contact = null, this._status = vt.STATUS_INIT, this._error = null, this._transactions = {
16112
16110
  nist: {},
@@ -16145,19 +16143,19 @@ var bh = class extends _T {
16145
16143
  * Resume UA after being closed.
16146
16144
  */
16147
16145
  start() {
16148
- He.debug("start()"), this._status === vt.STATUS_INIT ? this._transport.connect() : this._status === vt.STATUS_USER_CLOSED ? (He.debug("restarting UA"), this._closeTimer !== null && (clearTimeout(this._closeTimer), this._closeTimer = null, this._transport.disconnect()), this._status = vt.STATUS_INIT, this._transport.connect()) : this._status === vt.STATUS_READY ? He.debug("UA is in READY status, not restarted") : He.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"), this._dynConfiguration.register = this._configuration.register;
16146
+ qe.debug("start()"), this._status === vt.STATUS_INIT ? this._transport.connect() : this._status === vt.STATUS_USER_CLOSED ? (qe.debug("restarting UA"), this._closeTimer !== null && (clearTimeout(this._closeTimer), this._closeTimer = null, this._transport.disconnect()), this._status = vt.STATUS_INIT, this._transport.connect()) : this._status === vt.STATUS_READY ? qe.debug("UA is in READY status, not restarted") : qe.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"), this._dynConfiguration.register = this._configuration.register;
16149
16147
  }
16150
16148
  /**
16151
16149
  * Register.
16152
16150
  */
16153
16151
  register() {
16154
- He.debug("register()"), this._dynConfiguration.register = !0, this._registrator.register();
16152
+ qe.debug("register()"), this._dynConfiguration.register = !0, this._registrator.register();
16155
16153
  }
16156
16154
  /**
16157
16155
  * Unregister.
16158
16156
  */
16159
16157
  unregister(t) {
16160
- He.debug("unregister()"), this._dynConfiguration.register = !1, this._registrator.unregister(t);
16158
+ qe.debug("unregister()"), this._dynConfiguration.register = !1, this._registrator.unregister(t);
16161
16159
  }
16162
16160
  /**
16163
16161
  * Get the Registrator instance.
@@ -16187,7 +16185,7 @@ var bh = class extends _T {
16187
16185
  *
16188
16186
  */
16189
16187
  call(t, n) {
16190
- He.debug("call()");
16188
+ qe.debug("call()");
16191
16189
  const a = new If(this);
16192
16190
  return a.connect(t, n), a;
16193
16191
  }
@@ -16202,7 +16200,7 @@ var bh = class extends _T {
16202
16200
  *
16203
16201
  */
16204
16202
  sendMessage(t, n, a) {
16205
- He.debug("sendMessage()");
16203
+ qe.debug("sendMessage()");
16206
16204
  const o = new bf(this);
16207
16205
  return o.send(t, n, a), o;
16208
16206
  }
@@ -16217,7 +16215,7 @@ var bh = class extends _T {
16217
16215
  *
16218
16216
  */
16219
16217
  sendOptions(t, n, a) {
16220
- He.debug("sendOptions()");
16218
+ qe.debug("sendOptions()");
16221
16219
  const o = new wf(this);
16222
16220
  return o.send(t, n, a), o;
16223
16221
  }
@@ -16225,7 +16223,7 @@ var bh = class extends _T {
16225
16223
  * Terminate ongoing sessions.
16226
16224
  */
16227
16225
  terminateSessions(t) {
16228
- He.debug("terminateSessions()");
16226
+ qe.debug("terminateSessions()");
16229
16227
  for (const n in this._sessions)
16230
16228
  this._sessions[n].isEnded() || this._sessions[n].terminate(t);
16231
16229
  }
@@ -16234,15 +16232,15 @@ var bh = class extends _T {
16234
16232
  *
16235
16233
  */
16236
16234
  stop() {
16237
- if (He.debug("stop()"), this._dynConfiguration = {}, this._status === vt.STATUS_USER_CLOSED) {
16238
- He.debug("UA already closed");
16235
+ if (qe.debug("stop()"), this._dynConfiguration = {}, this._status === vt.STATUS_USER_CLOSED) {
16236
+ qe.debug("UA already closed");
16239
16237
  return;
16240
16238
  }
16241
16239
  this._registrator.close();
16242
16240
  const t = Object.keys(this._sessions).length;
16243
16241
  for (const a in this._sessions)
16244
16242
  if (Object.prototype.hasOwnProperty.call(this._sessions, a)) {
16245
- He.debug(`closing session ${a}`);
16243
+ qe.debug(`closing session ${a}`);
16246
16244
  try {
16247
16245
  this._sessions[a].terminate();
16248
16246
  } catch {
@@ -16280,7 +16278,7 @@ var bh = class extends _T {
16280
16278
  case "authorization_jwt":
16281
16279
  return this._configuration.authorization_jwt;
16282
16280
  default:
16283
- He.warn('get() | cannot get "%s" parameter in runtime', t);
16281
+ qe.warn('get() | cannot get "%s" parameter in runtime', t);
16284
16282
  return;
16285
16283
  }
16286
16284
  }
@@ -16315,7 +16313,7 @@ var bh = class extends _T {
16315
16313
  break;
16316
16314
  }
16317
16315
  default:
16318
- return He.warn('set() | cannot set "%s" parameter in runtime', t), !1;
16316
+ return qe.warn('set() | cannot set "%s" parameter in runtime', t), !1;
16319
16317
  }
16320
16318
  return !0;
16321
16319
  }
@@ -16405,10 +16403,9 @@ var bh = class extends _T {
16405
16403
  * Request reception
16406
16404
  */
16407
16405
  receiveRequest(t) {
16408
- console.log("receiveRequest");
16409
16406
  const n = t.method;
16410
16407
  if (t.ruri.user !== this._configuration.uri.user && t.ruri.user !== this._contact.uri.user) {
16411
- He.debug("Request-URI does not point to us"), t.method !== mt.ACK && t.reply_sl(404);
16408
+ qe.debug("Request-URI does not point to us"), t.method !== mt.ACK && t.reply_sl(404);
16412
16409
  return;
16413
16410
  }
16414
16411
  if (t.ruri.scheme === mt.SIPS) {
@@ -16418,7 +16415,7 @@ var bh = class extends _T {
16418
16415
  if (Qo.checkTransaction(this, t))
16419
16416
  return;
16420
16417
  if (n === mt.INVITE ? new Qo.InviteServerTransaction(this, this._transport, t) : n !== mt.ACK && n !== mt.CANCEL && new Qo.NonInviteServerTransaction(this, this._transport, t), n === mt.OPTIONS) {
16421
- if (console.log("OPPP in option"), this.listeners("newOptions").length === 0) {
16418
+ if (this.listeners("newOptions").length === 0) {
16422
16419
  t.reply(200);
16423
16420
  return;
16424
16421
  }
@@ -16435,7 +16432,7 @@ var bh = class extends _T {
16435
16432
  }
16436
16433
  let a, o;
16437
16434
  if (t.to_tag)
16438
- a = this._findDialog(t.call_id, t.from_tag, t.to_tag), a ? a.receiveRequest(t) : n === mt.NOTIFY ? (o = this._findSession(t), o ? o.receiveRequest(t) : (He.debug("received NOTIFY request for a non existent subscription"), t.reply(481, "Subscription does not exist"))) : n !== mt.ACK && t.reply(481);
16435
+ a = this._findDialog(t.call_id, t.from_tag, t.to_tag), a ? a.receiveRequest(t) : n === mt.NOTIFY ? (o = this._findSession(t), o ? o.receiveRequest(t) : (qe.debug("received NOTIFY request for a non existent subscription"), t.reply(481, "Subscription does not exist"))) : n !== mt.ACK && t.reply(481);
16439
16436
  else
16440
16437
  switch (n) {
16441
16438
  case mt.INVITE:
@@ -16450,13 +16447,13 @@ var bh = class extends _T {
16450
16447
  } else
16451
16448
  o = new If(this), o.init_incoming(t);
16452
16449
  else
16453
- He.warn("INVITE received but WebRTC is not supported"), t.reply(488);
16450
+ qe.warn("INVITE received but WebRTC is not supported"), t.reply(488);
16454
16451
  break;
16455
16452
  case mt.BYE:
16456
16453
  t.reply(481);
16457
16454
  break;
16458
16455
  case mt.CANCEL:
16459
- o = this._findSession(t), o ? o.receiveRequest(t) : He.debug("received CANCEL request for a non existent session");
16456
+ o = this._findSession(t), o ? o.receiveRequest(t) : qe.debug("received CANCEL request for a non existent session");
16460
16457
  break;
16461
16458
  case mt.ACK:
16462
16459
  break;
@@ -16489,36 +16486,35 @@ var bh = class extends _T {
16489
16486
  return s || (o = t + a + n, s = this._dialogs[o], s || null);
16490
16487
  }
16491
16488
  _loadConfig(t) {
16492
- console.log("in _loadConfig");
16493
16489
  try {
16494
- console.log("config.load"), eu.load(this._configuration, t);
16490
+ eu.load(this._configuration, t);
16495
16491
  } catch (o) {
16496
- throw console.log("throw in _loadConfig", o), o;
16492
+ throw o;
16497
16493
  }
16498
16494
  this._configuration.display_name === 0 && (this._configuration.display_name = "0"), this._configuration.instance_id || (this._configuration.instance_id = aa.newUUID()), this._configuration.jssip_id = aa.createRandomToken(5);
16499
16495
  const n = this._configuration.uri.clone();
16500
16496
  n.user = null, this._configuration.hostport_params = n.toString().replace(/^sip:/i, "");
16501
16497
  try {
16502
- console.log("new transport"), this._transport = new gT(this._configuration.sockets, {
16498
+ this._transport = new gT(this._configuration.sockets, {
16503
16499
  // Recovery options.
16504
16500
  max_interval: this._configuration.connection_recovery_max_interval,
16505
16501
  min_interval: this._configuration.connection_recovery_min_interval
16506
16502
  }), this._transport.onconnecting = yT.bind(this), this._transport.onconnect = CT.bind(this), this._transport.ondisconnect = AT.bind(this), this._transport.ondata = RT.bind(this);
16507
16503
  } catch (o) {
16508
- throw He.warn(o), new TT.ConfigurationError("sockets", this._configuration.sockets);
16504
+ throw qe.warn(o), new TT.ConfigurationError("sockets", this._configuration.sockets);
16509
16505
  }
16510
16506
  if (delete this._configuration.sockets, this._configuration.authorization_user || (this._configuration.authorization_user = this._configuration.uri.user), !this._configuration.registrar_server) {
16511
16507
  const o = this._configuration.uri.clone();
16512
16508
  o.user = null, o.clearParams(), o.clearHeaders(), this._configuration.registrar_server = o;
16513
16509
  }
16514
- this._configuration.no_answer_timeout *= 1e3, this._configuration.contact_uri ? this._configuration.via_host = this._configuration.contact_uri.host : (console.log("this._configuration.contact_uri 1"), this._configuration.contact_uri = new vT("sip", aa.createRandomToken(8), this._configuration.via_host, null, { transport: "ws" }), console.log("this._configuration.contact_uri 2", this._configuration.contact_uri)), this._contact = {
16510
+ this._configuration.no_answer_timeout *= 1e3, this._configuration.contact_uri ? this._configuration.via_host = this._configuration.contact_uri.host : this._configuration.contact_uri = new vT("sip", aa.createRandomToken(8), this._configuration.via_host, null, { transport: "ws" }), this._contact = {
16515
16511
  pub_gruu: null,
16516
16512
  temp_gruu: null,
16517
16513
  uri: this._configuration.contact_uri,
16518
16514
  toString(o = {}) {
16519
16515
  const s = o.anonymous || null, r = o.outbound || null;
16520
16516
  let d = "<";
16521
- return s ? d += this.temp_gruu || "sip:anonymous@anonymous.invalid;transport=ws" : d += this.pub_gruu || this.uri.toString(), r && (s ? !this.temp_gruu : !this.pub_gruu) && (d += ";ob"), d += ">", console.log("contact", d), d;
16517
+ return s ? d += this.temp_gruu || "sip:anonymous@anonymous.invalid;transport=ws" : d += this.pub_gruu || this.uri.toString(), r && (s ? !this.temp_gruu : !this.pub_gruu) && (d += ";ob"), d += ">", d;
16522
16518
  }
16523
16519
  };
16524
16520
  const a = [
@@ -16538,23 +16534,22 @@ var bh = class extends _T {
16538
16534
  writable: !1,
16539
16535
  configurable: !1
16540
16536
  }));
16541
- He.debug("configuration parameters after validation:"), He.debug("this._contact.toString:", this._contact.toString());
16537
+ qe.debug("configuration parameters after validation:");
16542
16538
  for (const o in this._configuration)
16543
16539
  if (Object.prototype.hasOwnProperty.call(eu.settings, o))
16544
16540
  switch (o) {
16545
16541
  case "uri":
16546
16542
  case "registrar_server":
16547
- He.debug(`- ${o}: ${this._configuration[o]}`);
16543
+ qe.debug(`- ${o}: ${this._configuration[o]}`);
16548
16544
  break;
16549
16545
  case "password":
16550
16546
  case "ha1":
16551
16547
  case "authorization_jwt":
16552
- He.debug(`- ${o}: NOT SHOWN`);
16548
+ qe.debug(`- ${o}: NOT SHOWN`);
16553
16549
  break;
16554
16550
  default:
16555
- He.debug(`- ${o}: ${JSON.stringify(this._configuration[o])}`);
16551
+ qe.debug(`- ${o}: ${JSON.stringify(this._configuration[o])}`);
16556
16552
  }
16557
- console.log("_loadConfig retun");
16558
16553
  }
16559
16554
  };
16560
16555
  function yT(c) {
@@ -16571,7 +16566,6 @@ function AT(c) {
16571
16566
  this.emit("disconnected", c), this._registrator.onTransportClosed(), this._status !== vt.STATUS_USER_CLOSED && (this._status = vt.STATUS_NOT_READY, this._error = vt.NETWORK_ERROR);
16572
16567
  }
16573
16568
  function RT(c) {
16574
- console.log("onTransportData", c);
16575
16569
  const t = c.transport;
16576
16570
  let n = c.message;
16577
16571
  if (n = ET.parseMessage(n, this), !!n && !(this._status === vt.STATUS_USER_CLOSED && n instanceof Zo.IncomingRequest) && ST(n, this, t)) {
@@ -23413,7 +23407,7 @@ const _a = {
23413
23407
  }, aE = 0;
23414
23408
  class oE {
23415
23409
  constructor(t) {
23416
- this.isAutoAnswer = !1, this.muteWhenJoinEnabled = !1, this.isDNDEnabled = !1, this.muted = !1, this.microphoneInputLevelValue = 1, this.speakerVolumeValue = 1, this.activeRooms = {}, this.activeCalls = {}, this.extendedCalls = {}, this.availableMediaDevices = [], this.selectedMediaDevices = {
23410
+ this.isAutoAnswer = !1, this.muteWhenJoinEnabled = !1, this.isDNDEnabled = !1, this.isCallWaitingEnabled = !0, this.muted = !1, this.microphoneInputLevelValue = 1, this.speakerVolumeValue = 1, this.activeRooms = {}, this.activeCalls = {}, this.extendedCalls = {}, this.availableMediaDevices = [], this.selectedMediaDevices = {
23417
23411
  input: "default",
23418
23412
  output: "default"
23419
23413
  }, this.callStatus = {}, this.callTime = {}, this.callMetrics = {}, this.timeIntervals = {}, this.metricConfig = {
@@ -23514,6 +23508,20 @@ class oE {
23514
23508
  get isDND() {
23515
23509
  return this.isDNDEnabled;
23516
23510
  }
23511
+ /**
23512
+ * Gets the current state of the call waiting feature.
23513
+ *
23514
+ * When call waiting is enabled (true), incoming calls will be allowed even when
23515
+ * other calls are active.
23516
+ *
23517
+ * When call waiting is disabled (false) and there are already active calls,
23518
+ * any new incoming calls will be automatically rejected with a "busy" status.
23519
+ *
23520
+ * @returns {boolean} True if call waiting is enabled, false if disabled
23521
+ */
23522
+ get isCallWaiting() {
23523
+ return this.isCallWaitingEnabled;
23524
+ }
23517
23525
  get speakerVolume() {
23518
23526
  return this.speakerVolumeValue;
23519
23527
  }
@@ -23904,6 +23912,23 @@ class oE {
23904
23912
  setDND(t) {
23905
23913
  this.isDNDEnabled = t, this.context.emit("changeIsDND", t);
23906
23914
  }
23915
+ /**
23916
+ * Sets the call waiting feature state.
23917
+ *
23918
+ * When call waiting is disabled (false) and there are already active calls,
23919
+ * any new incoming calls will be automatically rejected with a "busy" status.
23920
+ *
23921
+ * When call waiting is enabled (true), incoming calls will be allowed even when
23922
+ * other calls are active.
23923
+ *
23924
+ * This setting is used in the shouldTerminateNewSession method to determine whether
23925
+ * to automatically terminate new incoming sessions when the user is already on a call.
23926
+ *
23927
+ * @param {boolean} value - True to enable call waiting, false to disable
23928
+ */
23929
+ setCallWaiting(t) {
23930
+ this.isCallWaitingEnabled = t, this.context.emit("changeIsCallWaiting", t);
23931
+ }
23907
23932
  startCallTimer(t) {
23908
23933
  this.removeTimeInterval(t);
23909
23934
  const n = {
@@ -23976,9 +24001,22 @@ class oE {
23976
24001
  const a = n.roomId;
23977
24002
  this.removeCall(t._id), this.roomReconfigure(a);
23978
24003
  }
24004
+ /**
24005
+ * Determines whether a new incoming session should be automatically terminated
24006
+ * based on Do Not Disturb (DND) settings and Call Waiting settings.
24007
+ *
24008
+ * @param {RTCSessionEvent} event - The event containing the new RTC session
24009
+ * @returns {boolean} True if the session should be terminated automatically, false otherwise
24010
+ */
24011
+ shouldTerminateNewSession(t) {
24012
+ if (t.session.direction === "outgoing")
24013
+ return !1;
24014
+ const a = !this.isCallWaiting && this.hasActiveCalls;
24015
+ return this.isDND || a;
24016
+ }
23979
24017
  async newRTCSessionCallback(t) {
23980
24018
  const n = t.session;
23981
- if (this.isDND) {
24019
+ if (this.shouldTerminateNewSession(t)) {
23982
24020
  n.terminate({
23983
24021
  status_code: 486,
23984
24022
  reason_phrase: "Do Not Disturb"