@nethesis/chat-island 0.1.2 → 0.1.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.
- package/README.md +1 -1
- package/dist/ChatIsland.d.ts +3 -1
- package/dist/index.js +257 -257
- package/dist-widget/index.widget.js +6 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -277,7 +277,7 @@ var D = /* @__PURE__ */ y(((e) => {
|
|
|
277
277
|
}
|
|
278
278
|
};
|
|
279
279
|
r.prototype.tree = r.prototype.root, t.exports = r;
|
|
280
|
-
})),
|
|
280
|
+
})), ee = /* @__PURE__ */ y(((e, t) => {
|
|
281
281
|
var n = O();
|
|
282
282
|
function r(e, t) {
|
|
283
283
|
if (Array.isArray(t)) {
|
|
@@ -296,7 +296,7 @@ var D = /* @__PURE__ */ y(((e) => {
|
|
|
296
296
|
return a;
|
|
297
297
|
}
|
|
298
298
|
t.exports = i;
|
|
299
|
-
})),
|
|
299
|
+
})), k = /* @__PURE__ */ y(((e, t) => {
|
|
300
300
|
var n = typeof Reflect == "object" ? Reflect : null, r = n && typeof n.apply == "function" ? n.apply : function(e, t, n) {
|
|
301
301
|
return Function.prototype.apply.call(e, t, n);
|
|
302
302
|
}, i = n && typeof n.ownKeys == "function" ? n.ownKeys : Object.getOwnPropertySymbols ? function(e) {
|
|
@@ -471,8 +471,8 @@ var D = /* @__PURE__ */ y(((e) => {
|
|
|
471
471
|
});
|
|
472
472
|
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
|
|
473
473
|
}
|
|
474
|
-
})),
|
|
475
|
-
var n =
|
|
474
|
+
})), te = /* @__PURE__ */ y(((e, t) => {
|
|
475
|
+
var n = k(), r = D(), i = 0, a = 1, o = 2, s = 3, c = 4, l = 5, u = 6, d = 7, f = 8, p = 9, m = 10;
|
|
476
476
|
t.exports = class extends n.EventEmitter {
|
|
477
477
|
constructor() {
|
|
478
478
|
super();
|
|
@@ -565,14 +565,14 @@ var D = /* @__PURE__ */ y(((e) => {
|
|
|
565
565
|
e && this.write(e), this.write = function() {};
|
|
566
566
|
}
|
|
567
567
|
};
|
|
568
|
-
})),
|
|
568
|
+
})), A = D(), j = /* @__PURE__ */ x(O(), 1), ne = /* @__PURE__ */ x(ee(), 1), M = k(), re = /* @__PURE__ */ x(te(), 1), ie = class extends Error {
|
|
569
569
|
constructor(e) {
|
|
570
570
|
super(e), this.name = "TimeoutError";
|
|
571
571
|
}
|
|
572
572
|
};
|
|
573
573
|
//#endregion
|
|
574
574
|
//#region node_modules/@xmpp/events/lib/delay.js
|
|
575
|
-
function
|
|
575
|
+
function ae(e) {
|
|
576
576
|
let t, n = new Promise((n) => {
|
|
577
577
|
t = setTimeout(n, e);
|
|
578
578
|
});
|
|
@@ -580,32 +580,32 @@ function re(e) {
|
|
|
580
580
|
}
|
|
581
581
|
//#endregion
|
|
582
582
|
//#region node_modules/@xmpp/events/lib/timeout.js
|
|
583
|
-
function
|
|
584
|
-
let n =
|
|
583
|
+
function oe(e, t) {
|
|
584
|
+
let n = ae(t);
|
|
585
585
|
function r() {
|
|
586
586
|
clearTimeout(n.timeout);
|
|
587
587
|
}
|
|
588
|
-
let i = new
|
|
588
|
+
let i = new ie();
|
|
589
589
|
return Promise.race([e.finally(r), n.then(() => {
|
|
590
590
|
throw i;
|
|
591
591
|
})]);
|
|
592
592
|
}
|
|
593
593
|
//#endregion
|
|
594
594
|
//#region node_modules/@xmpp/events/lib/onoff.js
|
|
595
|
-
var
|
|
596
|
-
function
|
|
597
|
-
let t =
|
|
595
|
+
var se = /* @__PURE__ */ new WeakMap();
|
|
596
|
+
function ce(e) {
|
|
597
|
+
let t = se.get(e);
|
|
598
598
|
return t || (t = {
|
|
599
599
|
on: (e.addEventListener ?? e.addListener).bind(e),
|
|
600
600
|
off: (e.removeEventListener ?? e.removeListener).bind(e),
|
|
601
601
|
once: (e.once ?? ((t, n) => e.addEventListener(t, n, { once: !0 }))).bind(e)
|
|
602
|
-
},
|
|
602
|
+
}, se.set(e, t)), t;
|
|
603
603
|
}
|
|
604
604
|
//#endregion
|
|
605
605
|
//#region node_modules/@xmpp/events/lib/promise.js
|
|
606
|
-
function
|
|
606
|
+
function N(e, t, n = "error", r) {
|
|
607
607
|
return new Promise((i, a) => {
|
|
608
|
-
let o, { off: s, once: c } =
|
|
608
|
+
let o, { off: s, once: c } = ce(e), l = () => {
|
|
609
609
|
clearTimeout(o), s(t, d), s(n, u);
|
|
610
610
|
};
|
|
611
611
|
function u(e) {
|
|
@@ -615,7 +615,7 @@ function F(e, t, n = "error", r) {
|
|
|
615
615
|
i(e), l();
|
|
616
616
|
}
|
|
617
617
|
if (c(t, d), n && c(n, u), r) {
|
|
618
|
-
let e = new
|
|
618
|
+
let e = new ie();
|
|
619
619
|
o = setTimeout(() => {
|
|
620
620
|
l(), a(e);
|
|
621
621
|
}, r);
|
|
@@ -624,14 +624,14 @@ function F(e, t, n = "error", r) {
|
|
|
624
624
|
}
|
|
625
625
|
//#endregion
|
|
626
626
|
//#region node_modules/@xmpp/events/lib/Deferred.js
|
|
627
|
-
function
|
|
627
|
+
function le() {
|
|
628
628
|
this.promise = new Promise((e, t) => {
|
|
629
629
|
this.resolve = e, this.reject = t;
|
|
630
630
|
});
|
|
631
631
|
}
|
|
632
632
|
//#endregion
|
|
633
633
|
//#region node_modules/@xmpp/events/lib/procedure.js
|
|
634
|
-
function
|
|
634
|
+
function ue(e, t = null, n) {
|
|
635
635
|
return new Promise((r, i) => {
|
|
636
636
|
function a(t) {
|
|
637
637
|
e.removeListener("nonza", s), i(t);
|
|
@@ -651,38 +651,38 @@ function ce(e, t = null, n) {
|
|
|
651
651
|
}
|
|
652
652
|
//#endregion
|
|
653
653
|
//#region node_modules/@xmpp/events/lib/listeners.js
|
|
654
|
-
function
|
|
654
|
+
function de(e) {
|
|
655
655
|
return {
|
|
656
656
|
subscribe(t) {
|
|
657
|
-
let { on: n } =
|
|
657
|
+
let { on: n } = ce(t);
|
|
658
658
|
for (let [t, r] of Object.entries(e)) n(t, r);
|
|
659
659
|
},
|
|
660
660
|
unsubscribe(t) {
|
|
661
|
-
let { off: n } =
|
|
661
|
+
let { off: n } = ce(t);
|
|
662
662
|
for (let [t, r] of Object.entries(e)) n(t, r);
|
|
663
663
|
}
|
|
664
664
|
};
|
|
665
665
|
}
|
|
666
666
|
//#endregion
|
|
667
667
|
//#region node_modules/@xmpp/xml/lib/XMLError.js
|
|
668
|
-
var
|
|
668
|
+
var fe = class extends Error {
|
|
669
669
|
constructor(...e) {
|
|
670
670
|
super(...e), this.name = "XMLError";
|
|
671
671
|
}
|
|
672
|
-
},
|
|
672
|
+
}, pe = class extends M.EventEmitter {
|
|
673
673
|
constructor() {
|
|
674
674
|
super();
|
|
675
|
-
let e = new
|
|
675
|
+
let e = new re.default();
|
|
676
676
|
this.root = null, this.cursor = null, e.on("startElement", this.onStartElement.bind(this)), e.on("endElement", this.onEndElement.bind(this)), e.on("text", this.onText.bind(this)), this.parser = e;
|
|
677
677
|
}
|
|
678
678
|
onStartElement(e, t) {
|
|
679
|
-
let n = new
|
|
679
|
+
let n = new j.default(e, t), { root: r, cursor: i } = this;
|
|
680
680
|
r ? i !== r && i.append(n) : (this.root = n, this.emit("start", n)), this.cursor = n;
|
|
681
681
|
}
|
|
682
682
|
onEndElement(e) {
|
|
683
683
|
let { root: t, cursor: n } = this;
|
|
684
684
|
if (e !== n.name) {
|
|
685
|
-
this.emit("error", new
|
|
685
|
+
this.emit("error", new fe(`${n.name} must be closed.`));
|
|
686
686
|
return;
|
|
687
687
|
}
|
|
688
688
|
if (n === t) {
|
|
@@ -698,7 +698,7 @@ var ue = class extends Error {
|
|
|
698
698
|
onText(e) {
|
|
699
699
|
let { cursor: t } = this;
|
|
700
700
|
if (!t) {
|
|
701
|
-
this.emit("error", new
|
|
701
|
+
this.emit("error", new fe(`${e} must be a child.`));
|
|
702
702
|
return;
|
|
703
703
|
}
|
|
704
704
|
t.t(e);
|
|
@@ -710,37 +710,37 @@ var ue = class extends Error {
|
|
|
710
710
|
e && this.parser.write(e);
|
|
711
711
|
}
|
|
712
712
|
};
|
|
713
|
-
|
|
713
|
+
pe.XMLError = fe;
|
|
714
714
|
//#endregion
|
|
715
715
|
//#region node_modules/@xmpp/xml/index.js
|
|
716
|
-
function
|
|
717
|
-
return (0,
|
|
716
|
+
function P(...e) {
|
|
717
|
+
return (0, ne.default)(...e);
|
|
718
718
|
}
|
|
719
|
-
Object.assign(
|
|
720
|
-
Element:
|
|
721
|
-
createElement:
|
|
722
|
-
Parser:
|
|
723
|
-
escapeXML:
|
|
724
|
-
unescapeXML:
|
|
725
|
-
escapeXMLText:
|
|
726
|
-
unescapeXMLText:
|
|
727
|
-
XMLError:
|
|
728
|
-
xml:
|
|
719
|
+
Object.assign(P, {
|
|
720
|
+
Element: j.default,
|
|
721
|
+
createElement: ne.default,
|
|
722
|
+
Parser: pe,
|
|
723
|
+
escapeXML: A.escapeXML,
|
|
724
|
+
unescapeXML: A.unescapeXML,
|
|
725
|
+
escapeXMLText: A.escapeXMLText,
|
|
726
|
+
unescapeXMLText: A.unescapeXMLText,
|
|
727
|
+
XMLError: fe,
|
|
728
|
+
xml: P
|
|
729
729
|
});
|
|
730
730
|
//#endregion
|
|
731
731
|
//#region node_modules/@xmpp/jid/lib/escaping.js
|
|
732
|
-
function
|
|
732
|
+
function me(e) {
|
|
733
733
|
return !(!e || e.replaceAll(String.raw`\20`, "").replaceAll(String.raw`\22`, "").replaceAll(String.raw`\26`, "").replaceAll(String.raw`\27`, "").replaceAll(String.raw`\2f`, "").replaceAll(String.raw`\3a`, "").replaceAll(String.raw`\3c`, "").replaceAll(String.raw`\3e`, "").replaceAll(String.raw`\40`, "").replaceAll(String.raw`\5c`, "").search(/[ "&'/:<>@\\]/g) === -1);
|
|
734
734
|
}
|
|
735
|
-
function
|
|
735
|
+
function he(e) {
|
|
736
736
|
return e === null ? null : e.replaceAll(/^\s+|\s+$/g, "").replaceAll("\\", String.raw`\5c`).replaceAll(" ", String.raw`\20`).replaceAll("\"", String.raw`\22`).replaceAll("&", String.raw`\26`).replaceAll("'", String.raw`\27`).replaceAll("/", String.raw`\2f`).replaceAll(":", String.raw`\3a`).replaceAll("<", String.raw`\3c`).replaceAll(">", String.raw`\3e`).replaceAll("@", String.raw`\40`);
|
|
737
737
|
}
|
|
738
|
-
function
|
|
738
|
+
function ge(e) {
|
|
739
739
|
return e === null ? null : e.replaceAll(String.raw`\20`, " ").replaceAll(String.raw`\22`, "\"").replaceAll(String.raw`\26`, "&").replaceAll(String.raw`\27`, "'").replaceAll(String.raw`\2f`, "/").replaceAll(String.raw`\3a`, ":").replaceAll(String.raw`\3c`, "<").replaceAll(String.raw`\3e`, ">").replaceAll(String.raw`\40`, "@").replaceAll(String.raw`\5c`, "\\");
|
|
740
740
|
}
|
|
741
741
|
//#endregion
|
|
742
742
|
//#region node_modules/@xmpp/jid/lib/JID.js
|
|
743
|
-
var
|
|
743
|
+
var F = class e {
|
|
744
744
|
constructor(e, t, n) {
|
|
745
745
|
if (typeof t != "string" || !t) throw TypeError("Invalid domain.");
|
|
746
746
|
this.setDomain(t), this.setLocal(typeof e == "string" ? e : ""), this.setResource(typeof n == "string" ? n : "");
|
|
@@ -759,11 +759,11 @@ var L = class e {
|
|
|
759
759
|
return this._local === e._local && this._domain === e._domain && this._resource === e._resource;
|
|
760
760
|
}
|
|
761
761
|
setLocal(e, t) {
|
|
762
|
-
return t ||=
|
|
762
|
+
return t ||= me(e), t && (e = he(e)), this._local = e && e.toLowerCase(), this;
|
|
763
763
|
}
|
|
764
764
|
getLocal(e = !1) {
|
|
765
765
|
let t = null;
|
|
766
|
-
return t = e ?
|
|
766
|
+
return t = e ? ge(this._local) : this._local, t;
|
|
767
767
|
}
|
|
768
768
|
setDomain(e) {
|
|
769
769
|
return this._domain = e.toLowerCase(), this;
|
|
@@ -778,37 +778,37 @@ var L = class e {
|
|
|
778
778
|
return this._resource;
|
|
779
779
|
}
|
|
780
780
|
};
|
|
781
|
-
Object.defineProperty(
|
|
782
|
-
get:
|
|
783
|
-
set:
|
|
784
|
-
}), Object.defineProperty(
|
|
785
|
-
get:
|
|
786
|
-
set:
|
|
787
|
-
}), Object.defineProperty(
|
|
788
|
-
get:
|
|
789
|
-
set:
|
|
781
|
+
Object.defineProperty(F.prototype, "local", {
|
|
782
|
+
get: F.prototype.getLocal,
|
|
783
|
+
set: F.prototype.setLocal
|
|
784
|
+
}), Object.defineProperty(F.prototype, "domain", {
|
|
785
|
+
get: F.prototype.getDomain,
|
|
786
|
+
set: F.prototype.setDomain
|
|
787
|
+
}), Object.defineProperty(F.prototype, "resource", {
|
|
788
|
+
get: F.prototype.getResource,
|
|
789
|
+
set: F.prototype.setResource
|
|
790
790
|
});
|
|
791
791
|
//#endregion
|
|
792
792
|
//#region node_modules/@xmpp/jid/lib/parse.js
|
|
793
|
-
function
|
|
793
|
+
function _e(e) {
|
|
794
794
|
let t, n, r = e.indexOf("/");
|
|
795
795
|
r !== -1 && (n = e.slice(r + 1), e = e.slice(0, r));
|
|
796
796
|
let i = e.indexOf("@");
|
|
797
|
-
return i !== -1 && (t = e.slice(0, i), e = e.slice(i + 1)), new
|
|
797
|
+
return i !== -1 && (t = e.slice(0, i), e = e.slice(i + 1)), new F(t, e, n);
|
|
798
798
|
}
|
|
799
799
|
//#endregion
|
|
800
800
|
//#region node_modules/@xmpp/jid/index.js
|
|
801
|
-
function
|
|
801
|
+
function ve(e, t) {
|
|
802
802
|
return e.equals(t);
|
|
803
803
|
}
|
|
804
|
-
function
|
|
805
|
-
return !e[1] && !e[2] ?
|
|
804
|
+
function ye(...e) {
|
|
805
|
+
return !e[1] && !e[2] ? _e(...e) : new F(...e);
|
|
806
806
|
}
|
|
807
|
-
var
|
|
808
|
-
|
|
807
|
+
var I = ye.bind();
|
|
808
|
+
I.jid = ye, I.JID = F, I.parse = _e, I.equal = ve, I.detectEscape = me, I.escapeLocal = he, I.unescapeLocal = ge;
|
|
809
809
|
//#endregion
|
|
810
810
|
//#region node_modules/@xmpp/error/index.js
|
|
811
|
-
var
|
|
811
|
+
var L = class extends Error {
|
|
812
812
|
constructor(e, t, n) {
|
|
813
813
|
super(e + (t ? ` - ${t}` : "")), this.name = "XMPPError", this.condition = e, this.text = t, this.application = n;
|
|
814
814
|
}
|
|
@@ -818,14 +818,14 @@ var ve = class extends Error {
|
|
|
818
818
|
let o = new this(t.name, i ? i.text() : "", a);
|
|
819
819
|
return o.element = e, o;
|
|
820
820
|
}
|
|
821
|
-
},
|
|
821
|
+
}, be = class extends L {
|
|
822
822
|
constructor(...e) {
|
|
823
823
|
super(...e), this.name = "StreamError";
|
|
824
824
|
}
|
|
825
825
|
};
|
|
826
826
|
//#endregion
|
|
827
827
|
//#region node_modules/@xmpp/connection/lib/util.js
|
|
828
|
-
function
|
|
828
|
+
function xe(e) {
|
|
829
829
|
let { port: t, hostname: n, protocol: r } = new URL(e);
|
|
830
830
|
return n === "[::1]" && (n = "::1"), {
|
|
831
831
|
port: t,
|
|
@@ -833,19 +833,19 @@ function be(e) {
|
|
|
833
833
|
protocol: r
|
|
834
834
|
};
|
|
835
835
|
}
|
|
836
|
-
function
|
|
837
|
-
let { port: t, hostname: n } =
|
|
836
|
+
function Se(e) {
|
|
837
|
+
let { port: t, hostname: n } = xe(`http://${e}`);
|
|
838
838
|
return {
|
|
839
839
|
port: t,
|
|
840
840
|
hostname: n
|
|
841
841
|
};
|
|
842
842
|
}
|
|
843
|
-
function
|
|
844
|
-
return e.includes("://") ?
|
|
843
|
+
function Ce(e) {
|
|
844
|
+
return e.includes("://") ? xe(e) : Se(e);
|
|
845
845
|
}
|
|
846
846
|
//#endregion
|
|
847
847
|
//#region node_modules/@xmpp/connection/index.js
|
|
848
|
-
var
|
|
848
|
+
var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/streams", R = class extends M.EventEmitter {
|
|
849
849
|
#e = null;
|
|
850
850
|
#t = null;
|
|
851
851
|
constructor(e = {}) {
|
|
@@ -856,7 +856,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
856
856
|
}
|
|
857
857
|
async _streamError(e, t) {
|
|
858
858
|
try {
|
|
859
|
-
await this.send(
|
|
859
|
+
await this.send(P("stream:error", {}, [P(e, { xmlns: we }, t)]));
|
|
860
860
|
} catch {}
|
|
861
861
|
return this.disconnect();
|
|
862
862
|
}
|
|
@@ -880,7 +880,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
880
880
|
});
|
|
881
881
|
}
|
|
882
882
|
_attachSocket(e) {
|
|
883
|
-
this.socket = e, this.#e ??=
|
|
883
|
+
this.socket = e, this.#e ??= de({
|
|
884
884
|
data: this._onData.bind(this),
|
|
885
885
|
close: this.#r.bind(this),
|
|
886
886
|
connect: () => this._status("connect"),
|
|
@@ -891,19 +891,19 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
891
891
|
this.socket && this.#e?.unsubscribe(this.socket), this.socket = null;
|
|
892
892
|
}
|
|
893
893
|
_onElement(e) {
|
|
894
|
-
let t = e.is("error",
|
|
894
|
+
let t = e.is("error", Te);
|
|
895
895
|
t && this._onStreamError(e), this.emit("element", e), this.emit(this.isStanza(e) ? "stanza" : "nonza", e), t && this.disconnect();
|
|
896
896
|
}
|
|
897
897
|
_onStreamError(e) {
|
|
898
|
-
let t =
|
|
898
|
+
let t = be.fromElement(e);
|
|
899
899
|
if (t.condition === "see-other-host") return this._onSeeOtherHost(t);
|
|
900
900
|
this.emit("error", t);
|
|
901
901
|
}
|
|
902
902
|
async _onSeeOtherHost(e) {
|
|
903
|
-
let { protocol: t } =
|
|
903
|
+
let { protocol: t } = Ce(this.options.service), n = e.element.getChildText("see-other-host"), { port: r } = Se(n), i;
|
|
904
904
|
i = r ? `${t || "xmpp:"}//${n}` : (t ? `${t}//` : "") + n;
|
|
905
905
|
try {
|
|
906
|
-
await
|
|
906
|
+
await N(this, "disconnect");
|
|
907
907
|
let { domain: e, lang: t } = this.options;
|
|
908
908
|
await this.connect(i), await this.open({
|
|
909
909
|
domain: e,
|
|
@@ -914,7 +914,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
914
914
|
}
|
|
915
915
|
}
|
|
916
916
|
_attachParser(e) {
|
|
917
|
-
this.parser = e, this.#t ??=
|
|
917
|
+
this.parser = e, this.#t ??= de({
|
|
918
918
|
element: this._onElement.bind(this),
|
|
919
919
|
error: this.#n.bind(this),
|
|
920
920
|
end: this.#i.bind(this),
|
|
@@ -925,7 +925,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
925
925
|
this.parser && this.#t?.unsubscribe(this.parser), this.parser = null, this.root = null;
|
|
926
926
|
}
|
|
927
927
|
_jid(e) {
|
|
928
|
-
return this.jid =
|
|
928
|
+
return this.jid = I(e), this.jid;
|
|
929
929
|
}
|
|
930
930
|
_status(e, ...t) {
|
|
931
931
|
this.status !== e && (this.status = e, this.emit("status", e, ...t), this.emit(e, ...t));
|
|
@@ -951,7 +951,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
951
951
|
if (this.status !== "offline") throw Error("Connection is not offline");
|
|
952
952
|
let { service: e, domain: t, lang: n } = this.options;
|
|
953
953
|
await this.connect(e);
|
|
954
|
-
let r =
|
|
954
|
+
let r = N(this, "online");
|
|
955
955
|
return await this.open({
|
|
956
956
|
domain: t,
|
|
957
957
|
lang: n
|
|
@@ -960,15 +960,15 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
960
960
|
async connect(e) {
|
|
961
961
|
this._status("connecting", e);
|
|
962
962
|
let t = new this.Socket();
|
|
963
|
-
return this._attachSocket(t), t.connect(this.socketParameters(e)),
|
|
963
|
+
return this._attachSocket(t), t.connect(this.socketParameters(e)), N(t, "connect");
|
|
964
964
|
}
|
|
965
965
|
async _closeSocket(e = this.timeout) {
|
|
966
|
-
this._status("disconnecting"), this.socket.end(), await
|
|
966
|
+
this._status("disconnecting"), this.socket.end(), await N(this.socket, "close", "error", e);
|
|
967
967
|
}
|
|
968
968
|
async open(e) {
|
|
969
969
|
this._status("opening");
|
|
970
970
|
let { domain: t, lang: n } = e, r = this.headerElement();
|
|
971
|
-
return r.attrs.to = t, r.attrs["xml:lang"] = n, this.root = r, this._attachParser(new this.Parser()), await this.write(this.header(r)),
|
|
971
|
+
return r.attrs.to = t, r.attrs["xml:lang"] = n, this.root = r, this._attachParser(new this.Parser()), await this.write(this.header(r)), N(this, "open", "error", this.timeout);
|
|
972
972
|
}
|
|
973
973
|
async stop() {
|
|
974
974
|
let e = await this.disconnect();
|
|
@@ -977,7 +977,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
977
977
|
async _closeStream(e = this.timeout) {
|
|
978
978
|
await this.#c("close");
|
|
979
979
|
let t = this.footer(this.footerElement());
|
|
980
|
-
return await this.write(t), this._status("closing"),
|
|
980
|
+
return await this.write(t), this._status("closing"), N(this.parser, "end", "error", e);
|
|
981
981
|
}
|
|
982
982
|
async restart() {
|
|
983
983
|
this._detachParser();
|
|
@@ -991,7 +991,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
991
991
|
e.parent = this.root, await this.write(e.toString()), this.emit("send", e);
|
|
992
992
|
}
|
|
993
993
|
sendReceive(e, t = this.timeout) {
|
|
994
|
-
return Promise.all([this.send(e),
|
|
994
|
+
return Promise.all([this.send(e), N(this, "element", "error", t)]).then(([, e]) => e);
|
|
995
995
|
}
|
|
996
996
|
async write(e) {
|
|
997
997
|
if (this.status === "closing") throw Error("Connection is closing");
|
|
@@ -1010,7 +1010,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
1010
1010
|
return e.toString();
|
|
1011
1011
|
}
|
|
1012
1012
|
headerElement() {
|
|
1013
|
-
return new
|
|
1013
|
+
return new P.Element("", {
|
|
1014
1014
|
version: "1.0",
|
|
1015
1015
|
xmlns: this.NS
|
|
1016
1016
|
});
|
|
@@ -1045,10 +1045,10 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
1045
1045
|
}));
|
|
1046
1046
|
}
|
|
1047
1047
|
};
|
|
1048
|
-
|
|
1048
|
+
R.prototype.NS = "", R.prototype.Socket = null, R.prototype.Parser = null;
|
|
1049
1049
|
//#endregion
|
|
1050
1050
|
//#region node_modules/@xmpp/client-core/lib/Client.js
|
|
1051
|
-
var Ee = class extends
|
|
1051
|
+
var Ee = class extends R {
|
|
1052
1052
|
constructor(e) {
|
|
1053
1053
|
super(e), this.transports = [];
|
|
1054
1054
|
}
|
|
@@ -1092,7 +1092,7 @@ var Ee = class extends Te {
|
|
|
1092
1092
|
Ee.prototype.NS = "jabber:client";
|
|
1093
1093
|
//#endregion
|
|
1094
1094
|
//#region node_modules/@xmpp/reconnect/index.js
|
|
1095
|
-
var De = class extends
|
|
1095
|
+
var De = class extends M.EventEmitter {
|
|
1096
1096
|
constructor(e) {
|
|
1097
1097
|
super(), this.delay = 1e3, this.entity = e, this._timeout = null;
|
|
1098
1098
|
}
|
|
@@ -1133,14 +1133,14 @@ function Oe({ entity: e }) {
|
|
|
1133
1133
|
//#region node_modules/@xmpp/websocket/lib/Socket.js
|
|
1134
1134
|
var ke = "ECONNERROR";
|
|
1135
1135
|
function Ae(e) {
|
|
1136
|
-
let t =
|
|
1136
|
+
let t = xe(e);
|
|
1137
1137
|
return !!(t.protocol === "wss:" || [
|
|
1138
1138
|
"localhost",
|
|
1139
1139
|
"127.0.0.1",
|
|
1140
1140
|
"::1"
|
|
1141
1141
|
].includes(t.hostname));
|
|
1142
1142
|
}
|
|
1143
|
-
var je = class extends
|
|
1143
|
+
var je = class extends M.EventEmitter {
|
|
1144
1144
|
#e = null;
|
|
1145
1145
|
socket = null;
|
|
1146
1146
|
url = null;
|
|
@@ -1149,7 +1149,7 @@ var je = class extends P.EventEmitter {
|
|
|
1149
1149
|
this.url = e, this.secure = Ae(e), this._attachSocket(new WebSocket(e, ["xmpp"]));
|
|
1150
1150
|
}
|
|
1151
1151
|
_attachSocket(e) {
|
|
1152
|
-
this.socket = e, this.#e ??=
|
|
1152
|
+
this.socket = e, this.#e ??= de({
|
|
1153
1153
|
open: () => this.emit("connect"),
|
|
1154
1154
|
message: ({ data: e }) => this.emit("data", e),
|
|
1155
1155
|
error: (e) => {
|
|
@@ -1179,15 +1179,15 @@ var je = class extends P.EventEmitter {
|
|
|
1179
1179
|
}
|
|
1180
1180
|
n();
|
|
1181
1181
|
}
|
|
1182
|
-
}, Me = class extends
|
|
1182
|
+
}, Me = class extends pe {
|
|
1183
1183
|
onStartElement(e, t) {
|
|
1184
|
-
let n = new
|
|
1184
|
+
let n = new j.default(e, t), { cursor: r } = this;
|
|
1185
1185
|
r && r.append(n), this.cursor = n;
|
|
1186
1186
|
}
|
|
1187
1187
|
onEndElement(e) {
|
|
1188
1188
|
let { cursor: t } = this;
|
|
1189
1189
|
if (e !== t.name) {
|
|
1190
|
-
this.emit("error", new
|
|
1190
|
+
this.emit("error", new fe(`${t.name} must be closed.`));
|
|
1191
1191
|
return;
|
|
1192
1192
|
}
|
|
1193
1193
|
if (t.parent) {
|
|
@@ -1196,7 +1196,7 @@ var je = class extends P.EventEmitter {
|
|
|
1196
1196
|
}
|
|
1197
1197
|
t.is("open", "urn:ietf:params:xml:ns:xmpp-framing") ? this.emit("start", t) : t.is("close", "urn:ietf:params:xml:ns:xmpp-framing") ? this.emit("end", t) : this.emit("element", t), this.cursor = null;
|
|
1198
1198
|
}
|
|
1199
|
-
}, Ne = "urn:ietf:params:xml:ns:xmpp-framing", Pe = class extends
|
|
1199
|
+
}, Ne = "urn:ietf:params:xml:ns:xmpp-framing", Pe = class extends R {
|
|
1200
1200
|
send(e, ...t) {
|
|
1201
1201
|
return e.attrs.xmlns ??= this.NS, super.send(e, ...t);
|
|
1202
1202
|
}
|
|
@@ -1204,7 +1204,7 @@ var je = class extends P.EventEmitter {
|
|
|
1204
1204
|
for (let t of e) t.attrs.xmlns ??= this.NS, t.parent = this.root, this.socket.write(t.toString()), this.emit("send", t);
|
|
1205
1205
|
}
|
|
1206
1206
|
footerElement() {
|
|
1207
|
-
return new
|
|
1207
|
+
return new P.Element("close", { xmlns: Ne });
|
|
1208
1208
|
}
|
|
1209
1209
|
headerElement() {
|
|
1210
1210
|
let e = super.headerElement();
|
|
@@ -1255,13 +1255,13 @@ var Ie = /* @__PURE__ */ y(((e, t) => {
|
|
|
1255
1255
|
constructor(e, t) {
|
|
1256
1256
|
super(e, t);
|
|
1257
1257
|
let { jid: n } = e, { domain: r } = e.options ?? {}, i = t.attrs.to || n?.toString(), a = t.attrs.from || r;
|
|
1258
|
-
i && (this.to = new
|
|
1258
|
+
i && (this.to = new I(i)), a && (this.from = new I(a), this.local = this.from.local, this.domain = this.from.domain, this.resource = this.from.resource);
|
|
1259
1259
|
}
|
|
1260
1260
|
}, Ve = class extends ze {
|
|
1261
1261
|
constructor(e, t) {
|
|
1262
1262
|
super(e, t);
|
|
1263
1263
|
let { jid: n } = e, { domain: r } = e.options ?? {}, i = t.attrs.from || n?.toString(), a = t.attrs.to || r;
|
|
1264
|
-
i && (this.from = new
|
|
1264
|
+
i && (this.from = new I(i)), a && (this.to = new I(a), this.local = this.to.local, this.domain = this.to.domain, this.resource = this.to.resource);
|
|
1265
1265
|
}
|
|
1266
1266
|
};
|
|
1267
1267
|
//#endregion
|
|
@@ -1310,7 +1310,7 @@ function Ke() {
|
|
|
1310
1310
|
}
|
|
1311
1311
|
//#endregion
|
|
1312
1312
|
//#region node_modules/@xmpp/middleware/lib/StanzaError.js
|
|
1313
|
-
var qe = class extends
|
|
1313
|
+
var qe = class extends L {
|
|
1314
1314
|
constructor(e, t, n, r) {
|
|
1315
1315
|
super(e, t, n), this.type = r, this.name = "StanzaError";
|
|
1316
1316
|
}
|
|
@@ -1342,10 +1342,10 @@ var Ye = class {
|
|
|
1342
1342
|
}
|
|
1343
1343
|
async request(e, t = 3e4) {
|
|
1344
1344
|
e.attrs.id || (e.attrs.id = Ke());
|
|
1345
|
-
let n = new
|
|
1345
|
+
let n = new le();
|
|
1346
1346
|
this.handlers.set(e.attrs.id, n);
|
|
1347
1347
|
try {
|
|
1348
|
-
await this.entity.send(e), await
|
|
1348
|
+
await this.entity.send(e), await oe(n.promise, t);
|
|
1349
1349
|
} catch (t) {
|
|
1350
1350
|
throw this.handlers.delete(e.attrs.id), t;
|
|
1351
1351
|
}
|
|
@@ -1353,7 +1353,7 @@ var Ye = class {
|
|
|
1353
1353
|
}
|
|
1354
1354
|
_childRequest(e, t, n, ...r) {
|
|
1355
1355
|
let { name: i, attrs: { xmlns: a } } = t;
|
|
1356
|
-
return this.request(
|
|
1356
|
+
return this.request(P("iq", {
|
|
1357
1357
|
type: e,
|
|
1358
1358
|
to: n
|
|
1359
1359
|
}, t), ...r).then((e) => e.getChild(i, a));
|
|
@@ -1379,7 +1379,7 @@ function $e({ type: e }, t, n) {
|
|
|
1379
1379
|
return !(e !== "get" && e !== "set" || t.length !== 1 || !n);
|
|
1380
1380
|
}
|
|
1381
1381
|
function et({ stanza: e }) {
|
|
1382
|
-
return
|
|
1382
|
+
return P("iq", {
|
|
1383
1383
|
to: e.attrs.from,
|
|
1384
1384
|
from: e.attrs.to,
|
|
1385
1385
|
id: e.attrs.id
|
|
@@ -1394,7 +1394,7 @@ function nt(e, t, n) {
|
|
|
1394
1394
|
return r.attrs.type = "error", n && r.append(n), r.append(t), r;
|
|
1395
1395
|
}
|
|
1396
1396
|
function rt(e, t) {
|
|
1397
|
-
return
|
|
1397
|
+
return P("error", { type: e }, P(t, Ze));
|
|
1398
1398
|
}
|
|
1399
1399
|
function it(e) {
|
|
1400
1400
|
return async function(t, n) {
|
|
@@ -1408,7 +1408,7 @@ function it(e) {
|
|
|
1408
1408
|
} catch (t) {
|
|
1409
1409
|
e.emit("error", t), o = rt("cancel", "internal-server-error");
|
|
1410
1410
|
}
|
|
1411
|
-
return o ||= rt("cancel", "service-unavailable"), o instanceof
|
|
1411
|
+
return o ||= rt("cancel", "service-unavailable"), o instanceof P.Element && o.is("error") ? nt(t, o, a) : tt(t, o instanceof P.Element ? o : void 0);
|
|
1412
1412
|
};
|
|
1413
1413
|
}
|
|
1414
1414
|
function at(e, t, n, r) {
|
|
@@ -1532,7 +1532,7 @@ function ft(e, t = {}) {
|
|
|
1532
1532
|
//#endregion
|
|
1533
1533
|
//#region node_modules/@xmpp/xml/lib/parse.js
|
|
1534
1534
|
function pt(e) {
|
|
1535
|
-
let t = new
|
|
1535
|
+
let t = new pe(), n = null, r = null;
|
|
1536
1536
|
if (t.on("start", (e) => {
|
|
1537
1537
|
n = e;
|
|
1538
1538
|
}), t.on("element", (e) => {
|
|
@@ -1594,7 +1594,7 @@ async function bt(e, t) {
|
|
|
1594
1594
|
e._status("connecting", n);
|
|
1595
1595
|
let i = r.prototype.socketParameters(n), a = new r.prototype.Socket();
|
|
1596
1596
|
try {
|
|
1597
|
-
a.connect(i), await
|
|
1597
|
+
a.connect(i), await N(a, "connect");
|
|
1598
1598
|
} catch {
|
|
1599
1599
|
return bt(e, t);
|
|
1600
1600
|
}
|
|
@@ -1623,7 +1623,7 @@ function Ct(e) {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
//#endregion
|
|
1625
1625
|
//#region node_modules/@xmpp/sasl/lib/SASLError.js
|
|
1626
|
-
var wt = class extends
|
|
1626
|
+
var wt = class extends L {
|
|
1627
1627
|
constructor(...e) {
|
|
1628
1628
|
super(...e), this.name = "SASLError";
|
|
1629
1629
|
}
|
|
@@ -1645,7 +1645,7 @@ async function Dt({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
|
|
|
1645
1645
|
serviceName: a,
|
|
1646
1646
|
...r
|
|
1647
1647
|
};
|
|
1648
|
-
await
|
|
1648
|
+
await ue(t, i.clientFirst && P("auth", {
|
|
1649
1649
|
xmlns: Tt,
|
|
1650
1650
|
mechanism: i.name
|
|
1651
1651
|
}, St(await i.response(o))), async (e, n) => {
|
|
@@ -1653,7 +1653,7 @@ async function Dt({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
|
|
|
1653
1653
|
if (e.name === "challenge") {
|
|
1654
1654
|
await i.challenge(Ct(e.text()));
|
|
1655
1655
|
let n = await i.response(o);
|
|
1656
|
-
await t.send(
|
|
1656
|
+
await t.send(P("response", {
|
|
1657
1657
|
xmlns: Tt,
|
|
1658
1658
|
mechanism: i.name
|
|
1659
1659
|
}, typeof n == "string" ? St(n) : ""));
|
|
@@ -1695,11 +1695,11 @@ async function At({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
|
|
|
1695
1695
|
serviceName: c,
|
|
1696
1696
|
...r
|
|
1697
1697
|
};
|
|
1698
|
-
await
|
|
1698
|
+
await ue(t, P("authenticate", {
|
|
1699
1699
|
xmlns: kt,
|
|
1700
1700
|
mechanism: s.name
|
|
1701
1701
|
}, [
|
|
1702
|
-
s.clientFirst &&
|
|
1702
|
+
s.clientFirst && P("initial-response", {}, St(await s.response(l))),
|
|
1703
1703
|
i,
|
|
1704
1704
|
...a
|
|
1705
1705
|
]), async (e, n) => {
|
|
@@ -1707,7 +1707,7 @@ async function At({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
|
|
|
1707
1707
|
if (e.name === "challenge") {
|
|
1708
1708
|
await s.challenge(Ct(e.text()));
|
|
1709
1709
|
let n = await s.response(l);
|
|
1710
|
-
await t.send(
|
|
1710
|
+
await t.send(P("response", {
|
|
1711
1711
|
xmlns: kt,
|
|
1712
1712
|
mechanism: s.name
|
|
1713
1713
|
}, typeof n == "string" ? St(n) : ""));
|
|
@@ -1775,7 +1775,7 @@ async function Mt({ element: e, features: t }) {
|
|
|
1775
1775
|
//#region node_modules/@xmpp/resource-binding/index.js
|
|
1776
1776
|
var Nt = "urn:ietf:params:xml:ns:xmpp-bind";
|
|
1777
1777
|
function Pt(e) {
|
|
1778
|
-
return
|
|
1778
|
+
return P("bind", { xmlns: Nt }, e && P("resource", {}, e));
|
|
1779
1779
|
}
|
|
1780
1780
|
async function Ft(e, t, n) {
|
|
1781
1781
|
let r = (await t.set(Pt(n))).getChildText("jid");
|
|
@@ -1832,36 +1832,36 @@ function Vt({ streamFeatures: e, sm: t, entity: n, resumed: r, failed: i, enable
|
|
|
1832
1832
|
});
|
|
1833
1833
|
}
|
|
1834
1834
|
function Ht(e, t) {
|
|
1835
|
-
return
|
|
1835
|
+
return ue(e, Wt({ sm: t }), (e, t) => {
|
|
1836
1836
|
if (e.is("enabled", "urn:xmpp:sm:3")) return t(e);
|
|
1837
|
-
if (e.is("failed", "urn:xmpp:sm:3")) throw
|
|
1837
|
+
if (e.is("failed", "urn:xmpp:sm:3")) throw L.fromElement(e);
|
|
1838
1838
|
});
|
|
1839
1839
|
}
|
|
1840
1840
|
async function Ut(e, t) {
|
|
1841
|
-
return
|
|
1841
|
+
return ue(e, Gt({ sm: t }), (e, t) => {
|
|
1842
1842
|
if (e.is("resumed", "urn:xmpp:sm:3")) return t(e);
|
|
1843
|
-
if (e.is("failed", "urn:xmpp:sm:3")) throw
|
|
1843
|
+
if (e.is("failed", "urn:xmpp:sm:3")) throw L.fromElement(e);
|
|
1844
1844
|
});
|
|
1845
1845
|
}
|
|
1846
1846
|
//#endregion
|
|
1847
1847
|
//#region node_modules/@xmpp/stream-management/index.js
|
|
1848
1848
|
var B = "urn:xmpp:sm:3";
|
|
1849
1849
|
function Wt({ sm: e }) {
|
|
1850
|
-
return
|
|
1850
|
+
return P("enable", {
|
|
1851
1851
|
xmlns: B,
|
|
1852
1852
|
max: e.preferredMaximum,
|
|
1853
1853
|
resume: "true"
|
|
1854
1854
|
});
|
|
1855
1855
|
}
|
|
1856
1856
|
function Gt({ sm: e }) {
|
|
1857
|
-
return
|
|
1857
|
+
return P("resume", {
|
|
1858
1858
|
xmlns: B,
|
|
1859
1859
|
h: e.inbound,
|
|
1860
1860
|
previd: e.id
|
|
1861
1861
|
});
|
|
1862
1862
|
}
|
|
1863
1863
|
function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i }) {
|
|
1864
|
-
let a = null, o = null, s = null, c = new
|
|
1864
|
+
let a = null, o = null, s = null, c = new M.EventEmitter();
|
|
1865
1865
|
Object.assign(c, {
|
|
1866
1866
|
preferredMaximum: null,
|
|
1867
1867
|
enabled: !1,
|
|
@@ -1877,7 +1877,7 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
|
|
|
1877
1877
|
});
|
|
1878
1878
|
async function l() {
|
|
1879
1879
|
try {
|
|
1880
|
-
await t.send(
|
|
1880
|
+
await t.send(P("a", {
|
|
1881
1881
|
xmlns: B,
|
|
1882
1882
|
h: c.inbound
|
|
1883
1883
|
}));
|
|
@@ -1940,7 +1940,7 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
|
|
|
1940
1940
|
function g() {
|
|
1941
1941
|
clearTimeout(o), clearTimeout(s), c.enabled && (c.timeout && !a && (a = setTimeout(() => {
|
|
1942
1942
|
clearTimeout(o), t.disconnect().catch(() => {});
|
|
1943
|
-
}, c.timeout)), t.send(
|
|
1943
|
+
}, c.timeout)), t.send(P("r", { xmlns: B })).catch(() => {}), h());
|
|
1944
1944
|
}
|
|
1945
1945
|
return n.filter((e, t) => {
|
|
1946
1946
|
let { stanza: n } = e;
|
|
@@ -1963,7 +1963,7 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
|
|
|
1963
1963
|
}
|
|
1964
1964
|
function qt({ entity: e, item: t }) {
|
|
1965
1965
|
let { stanza: n, stamp: r } = t;
|
|
1966
|
-
return n.name === "message" && !n.getChild("delay", "urn:xmpp:delay") && n.append(
|
|
1966
|
+
return n.name === "message" && !n.getChild("delay", "urn:xmpp:delay") && n.append(P("delay", {
|
|
1967
1967
|
xmlns: "urn:xmpp:delay",
|
|
1968
1968
|
from: e.jid.toString(),
|
|
1969
1969
|
stamp: r
|
|
@@ -1981,7 +1981,7 @@ function Yt({ sasl2: e, entity: t }, n) {
|
|
|
1981
1981
|
element: e,
|
|
1982
1982
|
features: r
|
|
1983
1983
|
});
|
|
1984
|
-
return
|
|
1984
|
+
return P("bind", { xmlns: "urn:xmpp:bind:0" }, n && P("tag", null, n), ...t);
|
|
1985
1985
|
}, (e) => {
|
|
1986
1986
|
if (e.is("bound")) {
|
|
1987
1987
|
t._ready(!1);
|
|
@@ -2034,7 +2034,7 @@ var Zt = /* @__PURE__ */ y(((e, t) => {
|
|
|
2034
2034
|
});
|
|
2035
2035
|
})))(), 1), V = "urn:xmpp:fast:0";
|
|
2036
2036
|
function $t({ sasl2: e, entity: t }) {
|
|
2037
|
-
let n = new Qt.default(), r, i = new
|
|
2037
|
+
let n = new Qt.default(), r, i = new M.EventEmitter();
|
|
2038
2038
|
Object.assign(i, {
|
|
2039
2039
|
mechanism: null,
|
|
2040
2040
|
mechanisms: [],
|
|
@@ -2081,7 +2081,7 @@ function $t({ sasl2: e, entity: t }) {
|
|
|
2081
2081
|
...r,
|
|
2082
2082
|
password: c.token
|
|
2083
2083
|
},
|
|
2084
|
-
streamFeatures: [...o,
|
|
2084
|
+
streamFeatures: [...o, P("fast", { xmlns: V })],
|
|
2085
2085
|
entity: t,
|
|
2086
2086
|
userAgent: n,
|
|
2087
2087
|
features: s
|
|
@@ -2095,7 +2095,7 @@ function $t({ sasl2: e, entity: t }) {
|
|
|
2095
2095
|
}
|
|
2096
2096
|
});
|
|
2097
2097
|
function a(e) {
|
|
2098
|
-
e.push(
|
|
2098
|
+
e.push(P("request-token", {
|
|
2099
2099
|
xmlns: V,
|
|
2100
2100
|
mechanism: i.mechanism
|
|
2101
2101
|
}));
|
|
@@ -2221,7 +2221,7 @@ function mn(e = {}) {
|
|
|
2221
2221
|
let { resource: t, credentials: n, username: r, password: i, userAgent: a, ...o } = e, { domain: s, service: c } = o;
|
|
2222
2222
|
!s && c && (o.domain = pn(c));
|
|
2223
2223
|
let l = new Ee(o);
|
|
2224
|
-
r && o.domain && (l.jid =
|
|
2224
|
+
r && o.domain && (l.jid = I(r, o.domain));
|
|
2225
2225
|
let u = Oe({ entity: l }), d = Fe({ entity: l }), f = hn(z.default, { entity: l }), p = hn(z.default, { entity: l }), m = We({ entity: l }), h = Ge({ middleware: m }), g = Xe({
|
|
2226
2226
|
middleware: m,
|
|
2227
2227
|
entity: l
|
|
@@ -2233,7 +2233,7 @@ function mn(e = {}) {
|
|
|
2233
2233
|
plain: rn,
|
|
2234
2234
|
anonymous: sn
|
|
2235
2235
|
}).map(([e, t]) => ({ [e]: t(y) }));
|
|
2236
|
-
a ??=
|
|
2236
|
+
a ??= P("user-agent", { id: globalThis.crypto.randomUUID() });
|
|
2237
2237
|
let x = hn(z.default, { streamFeatures: h }), S = jt({
|
|
2238
2238
|
streamFeatures: h,
|
|
2239
2239
|
saslFactory: y
|
|
@@ -2360,10 +2360,10 @@ var U = {
|
|
|
2360
2360
|
}
|
|
2361
2361
|
this.attempt = 0, this.connected = !0;
|
|
2362
2362
|
try {
|
|
2363
|
-
await this.xmpp.send(
|
|
2363
|
+
await this.xmpp.send(P("iq", {
|
|
2364
2364
|
type: "set",
|
|
2365
2365
|
id: "carbons"
|
|
2366
|
-
},
|
|
2366
|
+
}, P("enable", { xmlns: U.carbons }))), await this.xmpp.send(P("presence"));
|
|
2367
2367
|
} catch {
|
|
2368
2368
|
return;
|
|
2369
2369
|
}
|
|
@@ -2389,10 +2389,10 @@ var U = {
|
|
|
2389
2389
|
document.visibilityState === "visible" && this.wake();
|
|
2390
2390
|
};
|
|
2391
2391
|
ping() {
|
|
2392
|
-
this.connected && this.xmpp.iqCaller.request(
|
|
2392
|
+
this.connected && this.xmpp.iqCaller.request(P("iq", {
|
|
2393
2393
|
type: "get",
|
|
2394
2394
|
to: this.domain
|
|
2395
|
-
},
|
|
2395
|
+
}, P("ping", { xmlns: U.ping })), 1e4).catch((e) => {
|
|
2396
2396
|
!this.stopped && this.connected && e.name !== "StanzaError" && this.xmpp.disconnect().catch(() => {});
|
|
2397
2397
|
});
|
|
2398
2398
|
}
|
|
@@ -2424,14 +2424,14 @@ var U = {
|
|
|
2424
2424
|
}
|
|
2425
2425
|
async send(e, t, n) {
|
|
2426
2426
|
let r = crypto.randomUUID(), i = [
|
|
2427
|
-
|
|
2428
|
-
|
|
2427
|
+
P("body", {}, t),
|
|
2428
|
+
P("origin-id", {
|
|
2429
2429
|
xmlns: U.sid,
|
|
2430
2430
|
id: r
|
|
2431
2431
|
}),
|
|
2432
|
-
|
|
2432
|
+
P("store", { xmlns: U.hints })
|
|
2433
2433
|
];
|
|
2434
|
-
return n && i.push(
|
|
2434
|
+
return n && i.push(P("x", { xmlns: U.oob }, P("url", {}, n))), this.isGroup(e) ? (await this.xmpp.send(P("message", {
|
|
2435
2435
|
to: e,
|
|
2436
2436
|
type: "groupchat",
|
|
2437
2437
|
id: r
|
|
@@ -2446,7 +2446,7 @@ var U = {
|
|
|
2446
2446
|
oob: n,
|
|
2447
2447
|
room: e,
|
|
2448
2448
|
nick: this.cfg.username
|
|
2449
|
-
}) : (i.push(
|
|
2449
|
+
}) : (i.push(P("active", { xmlns: U.chatstates })), await this.xmpp.send(P("message", {
|
|
2450
2450
|
to: `${e}@${this.domain}`,
|
|
2451
2451
|
type: "chat",
|
|
2452
2452
|
id: r
|
|
@@ -2462,34 +2462,34 @@ var U = {
|
|
|
2462
2462
|
});
|
|
2463
2463
|
}
|
|
2464
2464
|
async react(e, t, n) {
|
|
2465
|
-
let r = this.isGroup(e), i =
|
|
2465
|
+
let r = this.isGroup(e), i = P("reactions", {
|
|
2466
2466
|
xmlns: U.reactions,
|
|
2467
2467
|
id: t
|
|
2468
|
-
}, ...n.map((e) =>
|
|
2469
|
-
await this.xmpp.send(
|
|
2468
|
+
}, ...n.map((e) => P("reaction", {}, e)));
|
|
2469
|
+
await this.xmpp.send(P("message", {
|
|
2470
2470
|
to: r ? e : `${e}@${this.domain}`,
|
|
2471
2471
|
type: r ? "groupchat" : "chat",
|
|
2472
2472
|
id: crypto.randomUUID()
|
|
2473
|
-
}, i,
|
|
2473
|
+
}, i, P("store", { xmlns: U.hints })));
|
|
2474
2474
|
}
|
|
2475
2475
|
async announce(e) {
|
|
2476
|
-
for (let t of e) await this.xmpp.send(
|
|
2476
|
+
for (let t of e) await this.xmpp.send(P("presence", { to: `${t}@${this.domain}` }, P("x", { xmlns: U.hello }))).catch(() => {});
|
|
2477
2477
|
}
|
|
2478
2478
|
typing(e, t) {
|
|
2479
|
-
return this.isGroup(e) ? Promise.resolve() : this.xmpp.send(
|
|
2479
|
+
return this.isGroup(e) ? Promise.resolve() : this.xmpp.send(P("message", {
|
|
2480
2480
|
to: `${e}@${this.domain}`,
|
|
2481
2481
|
type: "chat"
|
|
2482
|
-
},
|
|
2482
|
+
}, P(t ? "composing" : "paused", { xmlns: U.chatstates })));
|
|
2483
2483
|
}
|
|
2484
2484
|
enablePush(e, t) {
|
|
2485
|
-
return this.xmpp.iqCaller.request(
|
|
2485
|
+
return this.xmpp.iqCaller.request(P("iq", { type: "set" }, P("enable", {
|
|
2486
2486
|
xmlns: U.push,
|
|
2487
2487
|
jid: e,
|
|
2488
2488
|
node: t
|
|
2489
2489
|
})), 15e3);
|
|
2490
2490
|
}
|
|
2491
2491
|
disablePush(e, t) {
|
|
2492
|
-
return this.xmpp.iqCaller.request(
|
|
2492
|
+
return this.xmpp.iqCaller.request(P("iq", { type: "set" }, P("disable", {
|
|
2493
2493
|
xmlns: U.push,
|
|
2494
2494
|
jid: e,
|
|
2495
2495
|
node: t
|
|
@@ -2504,20 +2504,20 @@ var U = {
|
|
|
2504
2504
|
async mam(e, t, n) {
|
|
2505
2505
|
let r = crypto.randomUUID();
|
|
2506
2506
|
this.mamQueries.set(r, []), this.mamReactions.set(r, []);
|
|
2507
|
-
let i =
|
|
2507
|
+
let i = P("set", { xmlns: U.rsm }, P("max", {}, String(n)), P("before", {}, t ?? "")), a = [P("field", {
|
|
2508
2508
|
var: "FORM_TYPE",
|
|
2509
2509
|
type: "hidden"
|
|
2510
|
-
},
|
|
2511
|
-
e && a.push(
|
|
2512
|
-
let o =
|
|
2510
|
+
}, P("value", {}, U.mam))];
|
|
2511
|
+
e && a.push(P("field", { var: "with" }, P("value", {}, this.isGroup(e) ? e : `${e}@${this.domain}`)));
|
|
2512
|
+
let o = P("x", {
|
|
2513
2513
|
xmlns: U.data,
|
|
2514
2514
|
type: "submit"
|
|
2515
2515
|
}, ...a), s, c, l;
|
|
2516
2516
|
try {
|
|
2517
|
-
s = await this.xmpp.iqCaller.request(
|
|
2517
|
+
s = await this.xmpp.iqCaller.request(P("iq", {
|
|
2518
2518
|
type: "set",
|
|
2519
2519
|
id: r
|
|
2520
|
-
},
|
|
2520
|
+
}, P("query", {
|
|
2521
2521
|
xmlns: U.mam,
|
|
2522
2522
|
queryid: r
|
|
2523
2523
|
}, o, i)), 3e4);
|
|
@@ -2534,42 +2534,42 @@ var U = {
|
|
|
2534
2534
|
}
|
|
2535
2535
|
async createGroup(e, t, n) {
|
|
2536
2536
|
let r = `g-${Math.random().toString(36).slice(2, 10)}@${this.mucHost}`, i = this.cfg.username, a = this.waitFor((e) => e.is("presence") && W(e.attrs.from) === r, 1e4);
|
|
2537
|
-
await this.xmpp.send(
|
|
2538
|
-
let o = (e, t) =>
|
|
2539
|
-
await this.xmpp.iqCaller.request(
|
|
2537
|
+
await this.xmpp.send(P("presence", { to: `${r}/${i}` }, P("x", { xmlns: U.muc }))), await a;
|
|
2538
|
+
let o = (e, t) => P("field", { var: e }, P("value", {}, t));
|
|
2539
|
+
await this.xmpp.iqCaller.request(P("iq", {
|
|
2540
2540
|
type: "set",
|
|
2541
2541
|
to: r
|
|
2542
|
-
},
|
|
2542
|
+
}, P("query", { xmlns: U.mucOwner }, P("x", {
|
|
2543
2543
|
xmlns: U.data,
|
|
2544
2544
|
type: "submit"
|
|
2545
2545
|
}, o("FORM_TYPE", "http://jabber.org/protocol/muc#roomconfig"), o("muc#roomconfig_roomname", e), o("muc#roomconfig_persistentroom", "1"), o("muc#roomconfig_membersonly", "1"), o("muc#roomconfig_publicroom", "0"), o("muc#roomconfig_whois", "anyone"), o("allow_subscription", "1"), o("mam", "1")))), 15e3), n && await this.setGroupAvatar(r, n).catch(() => {});
|
|
2546
2546
|
let s = t.filter((e) => e && e !== this.cfg.username);
|
|
2547
|
-
await this.xmpp.iqCaller.request(
|
|
2547
|
+
await this.xmpp.iqCaller.request(P("iq", {
|
|
2548
2548
|
type: "set",
|
|
2549
2549
|
to: r
|
|
2550
|
-
},
|
|
2550
|
+
}, P("query", { xmlns: U.mucAdmin }, ...s.map((e) => P("item", {
|
|
2551
2551
|
affiliation: "member",
|
|
2552
2552
|
jid: `${e}@${this.domain}`
|
|
2553
2553
|
})))), 15e3);
|
|
2554
|
-
for (let e of s) await this.xmpp.iqCaller.request(
|
|
2554
|
+
for (let e of s) await this.xmpp.iqCaller.request(P("iq", {
|
|
2555
2555
|
type: "set",
|
|
2556
2556
|
to: r
|
|
2557
|
-
},
|
|
2557
|
+
}, P("subscribe", {
|
|
2558
2558
|
xmlns: U.mucsub,
|
|
2559
2559
|
jid: `${e}@${this.domain}`,
|
|
2560
2560
|
nick: e
|
|
2561
|
-
},
|
|
2562
|
-
await this.xmpp.iqCaller.request(
|
|
2561
|
+
}, P("event", { node: U.mucsubMessages }))), 15e3).catch(() => {});
|
|
2562
|
+
await this.xmpp.iqCaller.request(P("iq", {
|
|
2563
2563
|
type: "set",
|
|
2564
2564
|
to: r
|
|
2565
|
-
},
|
|
2565
|
+
}, P("subscribe", {
|
|
2566
2566
|
xmlns: U.mucsub,
|
|
2567
2567
|
nick: i
|
|
2568
|
-
},
|
|
2568
|
+
}, P("event", { node: U.mucsubMessages }))), 15e3), await this.xmpp.send(P("presence", {
|
|
2569
2569
|
to: `${r}/${i}`,
|
|
2570
2570
|
type: "unavailable"
|
|
2571
2571
|
}));
|
|
2572
|
-
for (let t of s) await this.xmpp.send(
|
|
2572
|
+
for (let t of s) await this.xmpp.send(P("message", { to: `${t}@${this.domain}` }, P("x", {
|
|
2573
2573
|
xmlns: U.conference,
|
|
2574
2574
|
jid: r,
|
|
2575
2575
|
reason: e
|
|
@@ -2577,58 +2577,58 @@ var U = {
|
|
|
2577
2577
|
return r;
|
|
2578
2578
|
}
|
|
2579
2579
|
async leaveGroup(e, t) {
|
|
2580
|
-
t ? await this.xmpp.iqCaller.request(
|
|
2580
|
+
t ? await this.xmpp.iqCaller.request(P("iq", {
|
|
2581
2581
|
type: "set",
|
|
2582
2582
|
to: e
|
|
2583
|
-
},
|
|
2583
|
+
}, P("query", { xmlns: U.mucOwner }, P("destroy", {}))), 1e4) : await this.xmpp.iqCaller.request(P("iq", {
|
|
2584
2584
|
type: "set",
|
|
2585
2585
|
to: e
|
|
2586
|
-
},
|
|
2586
|
+
}, P("unsubscribe", { xmlns: U.mucsub })), 1e4);
|
|
2587
2587
|
}
|
|
2588
2588
|
async setGroupAvatar(e, t) {
|
|
2589
2589
|
let n = /^data:(image\/[a-z+]+);base64,(.+)$/i.exec(t);
|
|
2590
|
-
n && await this.xmpp.iqCaller.request(
|
|
2590
|
+
n && await this.xmpp.iqCaller.request(P("iq", {
|
|
2591
2591
|
type: "set",
|
|
2592
2592
|
to: e
|
|
2593
|
-
},
|
|
2593
|
+
}, P("vCard", { xmlns: U.vcard }, P("PHOTO", {}, P("TYPE", {}, n[1]), P("BINVAL", {}, n[2])))), 15e3);
|
|
2594
2594
|
}
|
|
2595
2595
|
async groupAvatar(e) {
|
|
2596
|
-
let t = (await this.xmpp.iqCaller.request(
|
|
2596
|
+
let t = (await this.xmpp.iqCaller.request(P("iq", {
|
|
2597
2597
|
type: "get",
|
|
2598
2598
|
to: e
|
|
2599
|
-
},
|
|
2599
|
+
}, P("vCard", { xmlns: U.vcard })), 1e4)).getChild("vCard", U.vcard)?.getChild("PHOTO"), n = t?.getChildText("BINVAL");
|
|
2600
2600
|
return n ? `data:${t?.getChildText("TYPE") || "image/jpeg"};base64,${n.replace(/\s+/g, "")}` : void 0;
|
|
2601
2601
|
}
|
|
2602
2602
|
async listGroups() {
|
|
2603
|
-
let e = ((await this.xmpp.iqCaller.request(
|
|
2603
|
+
let e = ((await this.xmpp.iqCaller.request(P("iq", {
|
|
2604
2604
|
type: "get",
|
|
2605
2605
|
to: this.mucHost
|
|
2606
|
-
},
|
|
2606
|
+
}, P("subscriptions", { xmlns: U.mucsub })), 15e3)).getChild("subscriptions", U.mucsub)?.getChildren("subscription") ?? []).map((e) => e.attrs.jid);
|
|
2607
2607
|
return Promise.all(e.map((e) => this.groupInfo(e)));
|
|
2608
2608
|
}
|
|
2609
2609
|
async subscribed(e) {
|
|
2610
|
-
return ((await this.xmpp.iqCaller.request(
|
|
2610
|
+
return ((await this.xmpp.iqCaller.request(P("iq", {
|
|
2611
2611
|
type: "get",
|
|
2612
2612
|
to: this.mucHost
|
|
2613
|
-
},
|
|
2613
|
+
}, P("subscriptions", { xmlns: U.mucsub })), 15e3)).getChild("subscriptions", U.mucsub)?.getChildren("subscription") ?? []).some((t) => W(t.attrs.jid) === e);
|
|
2614
2614
|
}
|
|
2615
2615
|
async groupInfo(e) {
|
|
2616
2616
|
let t = e.split("@")[0], n = [], r = !1;
|
|
2617
2617
|
try {
|
|
2618
|
-
t = (await this.xmpp.iqCaller.request(
|
|
2618
|
+
t = (await this.xmpp.iqCaller.request(P("iq", {
|
|
2619
2619
|
type: "get",
|
|
2620
2620
|
to: e
|
|
2621
|
-
},
|
|
2621
|
+
}, P("query", { xmlns: U.discoInfo })), 1e4)).getChild("query", U.discoInfo)?.getChild("identity")?.attrs.name || t;
|
|
2622
2622
|
} catch {}
|
|
2623
2623
|
try {
|
|
2624
|
-
n = ((await this.xmpp.iqCaller.request(
|
|
2624
|
+
n = ((await this.xmpp.iqCaller.request(P("iq", {
|
|
2625
2625
|
type: "get",
|
|
2626
2626
|
to: e
|
|
2627
|
-
},
|
|
2628
|
-
let t = await this.xmpp.iqCaller.request(
|
|
2627
|
+
}, P("query", { xmlns: U.mucAdmin }, P("item", { affiliation: "member" }))), 1e4)).getChild("query", U.mucAdmin)?.getChildren("item") ?? []).map((e) => G(e.attrs.jid));
|
|
2628
|
+
let t = await this.xmpp.iqCaller.request(P("iq", {
|
|
2629
2629
|
type: "get",
|
|
2630
2630
|
to: e
|
|
2631
|
-
},
|
|
2631
|
+
}, P("query", { xmlns: U.mucAdmin }, P("item", { affiliation: "owner" }))), 1e4);
|
|
2632
2632
|
for (let e of t.getChild("query", U.mucAdmin)?.getChildren("item") ?? []) n.push(G(e.attrs.jid)), G(e.attrs.jid) === this.cfg.username && (r = !0);
|
|
2633
2633
|
} catch {}
|
|
2634
2634
|
let i = await this.groupAvatar(e).catch(() => void 0);
|
|
@@ -2641,10 +2641,10 @@ var U = {
|
|
|
2641
2641
|
};
|
|
2642
2642
|
}
|
|
2643
2643
|
async upload(e) {
|
|
2644
|
-
let t = await this.findUploadService(), n = (await this.xmpp.iqCaller.request(
|
|
2644
|
+
let t = await this.findUploadService(), n = (await this.xmpp.iqCaller.request(P("iq", {
|
|
2645
2645
|
type: "get",
|
|
2646
2646
|
to: t
|
|
2647
|
-
},
|
|
2647
|
+
}, P("request", {
|
|
2648
2648
|
xmlns: U.upload,
|
|
2649
2649
|
filename: e.name,
|
|
2650
2650
|
size: String(e.size),
|
|
@@ -2665,19 +2665,19 @@ var U = {
|
|
|
2665
2665
|
if (this.uploadService) return this.uploadService;
|
|
2666
2666
|
let e = async (e) => {
|
|
2667
2667
|
try {
|
|
2668
|
-
return (await this.xmpp.iqCaller.request(
|
|
2668
|
+
return (await this.xmpp.iqCaller.request(P("iq", {
|
|
2669
2669
|
type: "get",
|
|
2670
2670
|
to: e
|
|
2671
|
-
},
|
|
2671
|
+
}, P("query", { xmlns: U.discoInfo })), 1e4)).getChild("query", U.discoInfo)?.getChildren("feature").some((e) => e.attrs.var === U.upload) ?? !1;
|
|
2672
2672
|
} catch {
|
|
2673
2673
|
return !1;
|
|
2674
2674
|
}
|
|
2675
2675
|
}, t = [`upload.${this.domain}`];
|
|
2676
2676
|
try {
|
|
2677
|
-
let e = await this.xmpp.iqCaller.request(
|
|
2677
|
+
let e = await this.xmpp.iqCaller.request(P("iq", {
|
|
2678
2678
|
type: "get",
|
|
2679
2679
|
to: this.domain
|
|
2680
|
-
},
|
|
2680
|
+
}, P("query", { xmlns: U.disco })), 1e4);
|
|
2681
2681
|
for (let n of e.getChild("query", U.disco)?.getChildren("item") ?? []) t.includes(n.attrs.jid) || t.push(n.attrs.jid);
|
|
2682
2682
|
} catch {}
|
|
2683
2683
|
for (let n of t) if (await e(n)) return this.uploadService = n, n;
|
|
@@ -2704,7 +2704,7 @@ var U = {
|
|
|
2704
2704
|
let r = G(n), i = this.online.get(r) ?? /* @__PURE__ */ new Set();
|
|
2705
2705
|
e.attrs.type === "unavailable" ? i.delete(t) : i.add(t), this.online.set(r, i), this.h.presence(r, i.size > 0);
|
|
2706
2706
|
let a = e.getChild("x", U.hello);
|
|
2707
|
-
a && !a.attrs.reply && e.attrs.type !== "unavailable" && this.xmpp.send(
|
|
2707
|
+
a && !a.attrs.reply && e.attrs.type !== "unavailable" && this.xmpp.send(P("presence", { to: n }, P("x", {
|
|
2708
2708
|
xmlns: U.hello,
|
|
2709
2709
|
reply: "1"
|
|
2710
2710
|
}))).catch(() => {});
|
|
@@ -4157,15 +4157,15 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4157
4157
|
a(() => {
|
|
4158
4158
|
m.current !== null && (g.current?.setSelectionRange(m.current, m.current), m.current = null);
|
|
4159
4159
|
}, [o]);
|
|
4160
|
-
let
|
|
4160
|
+
let ee = (e) => {
|
|
4161
4161
|
let t = g.current, n = t?.selectionStart ?? o.length, r = t?.selectionEnd ?? n;
|
|
4162
4162
|
O(o.slice(0, n) + e + o.slice(r)), requestAnimationFrame(() => {
|
|
4163
4163
|
t?.focus(), t?.setSelectionRange(n + e.length, n + e.length);
|
|
4164
4164
|
});
|
|
4165
|
-
},
|
|
4165
|
+
}, k = () => {
|
|
4166
4166
|
let t = o.trim();
|
|
4167
4167
|
t && (l(""), Promise.resolve(e(t)).catch(() => l((e) => e || t)), window.clearTimeout(_.current), v.current = !1);
|
|
4168
|
-
},
|
|
4168
|
+
}, te = async () => {
|
|
4169
4169
|
if (w.current || y) return;
|
|
4170
4170
|
w.current = !0;
|
|
4171
4171
|
let e;
|
|
@@ -4191,7 +4191,7 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4191
4191
|
} finally {
|
|
4192
4192
|
w.current = !1;
|
|
4193
4193
|
}
|
|
4194
|
-
},
|
|
4194
|
+
}, A = (e) => {
|
|
4195
4195
|
C.current = e, y?.r.stop();
|
|
4196
4196
|
};
|
|
4197
4197
|
return y ? /* @__PURE__ */ f("div", {
|
|
@@ -4201,7 +4201,7 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4201
4201
|
variant: "transparent",
|
|
4202
4202
|
title: "Discard",
|
|
4203
4203
|
"aria-label": "Discard",
|
|
4204
|
-
onClick: () =>
|
|
4204
|
+
onClick: () => A(!0),
|
|
4205
4205
|
className: "ci-h-10 ci-w-10",
|
|
4206
4206
|
children: Q.close
|
|
4207
4207
|
}),
|
|
@@ -4213,7 +4213,7 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4213
4213
|
variant: "green",
|
|
4214
4214
|
title: "Send voice note",
|
|
4215
4215
|
"aria-label": "Send voice note",
|
|
4216
|
-
onClick: () =>
|
|
4216
|
+
onClick: () => A(!1),
|
|
4217
4217
|
className: "ci-h-10 ci-w-10",
|
|
4218
4218
|
children: Q.send
|
|
4219
4219
|
})
|
|
@@ -4223,7 +4223,7 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4223
4223
|
children: [
|
|
4224
4224
|
u && /* @__PURE__ */ d($n, {
|
|
4225
4225
|
className: "ci-absolute ci-bottom-full ci-left-3 ci-mb-1",
|
|
4226
|
-
onPick:
|
|
4226
|
+
onPick: ee,
|
|
4227
4227
|
onClose: () => p(!1)
|
|
4228
4228
|
}),
|
|
4229
4229
|
/* @__PURE__ */ d("input", {
|
|
@@ -4260,7 +4260,7 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4260
4260
|
onChange: (e) => O(e.target.value),
|
|
4261
4261
|
onKeyDown: (e) => {
|
|
4262
4262
|
let t = (o.match(/```/g) ?? []).length % 2 == 1;
|
|
4263
|
-
e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(),
|
|
4263
|
+
e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(), k());
|
|
4264
4264
|
},
|
|
4265
4265
|
className: "ci-block ci-w-full ci-resize-none ci-max-h-32 ci-pl-11 ci-pr-4 ci-py-2.5 ci-rounded-3xl ci-border-0 ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-gray-900 dark:ci-text-white placeholder:ci-text-gray-500 dark:placeholder:ci-text-gray-400 ci-outline-none focus:ci-ring-2 focus:ci-ring-gray-400 dark:focus:ci-ring-gray-500 ci-text-sm",
|
|
4266
4266
|
style: { height: Math.min(128, 40 + 20 * (o.split("\n").length - 1)) }
|
|
@@ -4269,14 +4269,14 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4269
4269
|
o.trim() ? /* @__PURE__ */ d(Z, {
|
|
4270
4270
|
variant: "default",
|
|
4271
4271
|
disabled: r,
|
|
4272
|
-
onClick:
|
|
4272
|
+
onClick: k,
|
|
4273
4273
|
title: "Send",
|
|
4274
4274
|
className: "ci-h-10 ci-w-10",
|
|
4275
4275
|
children: Q.send
|
|
4276
4276
|
}) : /* @__PURE__ */ d(Z, {
|
|
4277
4277
|
variant: "default",
|
|
4278
4278
|
disabled: r || typeof MediaRecorder > "u",
|
|
4279
|
-
onClick:
|
|
4279
|
+
onClick: te,
|
|
4280
4280
|
title: "Record a voice note",
|
|
4281
4281
|
"aria-label": "Record a voice note",
|
|
4282
4282
|
className: "ci-h-10 ci-w-10",
|
|
@@ -4685,30 +4685,30 @@ function zr(e) {
|
|
|
4685
4685
|
}
|
|
4686
4686
|
}
|
|
4687
4687
|
var Br = (e) => (sr(e) ? "Attachment" : $(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
|
|
4688
|
-
function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWorker: r, maxHeads: a = 5, newChatButton: l = !0, notifications: u = "click", sound: p = !0, drag: m = !0 }) {
|
|
4689
|
-
let
|
|
4688
|
+
function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWorker: r, maxHeads: a = 5, newChatButton: l = !0, notifications: u = "click", sound: p = !0, drag: m = !0, onDragStart: h }) {
|
|
4689
|
+
let g = o(() => zr(e), [e]), _ = Ir(n), v = s(g), y = s(p), b = s(u);
|
|
4690
4690
|
i(() => {
|
|
4691
|
-
|
|
4691
|
+
v.current = g, y.current = p, b.current = u;
|
|
4692
4692
|
}, [
|
|
4693
|
-
|
|
4693
|
+
g,
|
|
4694
4694
|
p,
|
|
4695
4695
|
u
|
|
4696
4696
|
]), i(() => J.setState({
|
|
4697
4697
|
maxHeads: a,
|
|
4698
4698
|
newChatButton: l
|
|
4699
4699
|
}), [a, l]);
|
|
4700
|
-
let [
|
|
4700
|
+
let [x, S] = c(0);
|
|
4701
4701
|
i(() => {
|
|
4702
|
-
let e = (e) => e.persisted &&
|
|
4702
|
+
let e = (e) => e.persisted && S((e) => e + 1);
|
|
4703
4703
|
return window.addEventListener("pageshow", e), () => window.removeEventListener("pageshow", e);
|
|
4704
4704
|
}, []);
|
|
4705
|
-
let
|
|
4705
|
+
let C = s(null), T = s(/* @__PURE__ */ new Set()), D = s(!1), O = s(null), ee = s(null), k = E(ee, `chat-island-pos:${g?.host ?? ""}:${g?.username ?? ""}`), { open: te, picker: A, status: j } = J(w((e) => ({
|
|
4706
4706
|
open: e.open,
|
|
4707
4707
|
picker: e.picker,
|
|
4708
4708
|
status: e.status
|
|
4709
|
-
}))),
|
|
4709
|
+
}))), ne = o(() => ({
|
|
4710
4710
|
send: async (e, t) => {
|
|
4711
|
-
let n =
|
|
4711
|
+
let n = C.current;
|
|
4712
4712
|
if (!n) throw Error("not connected");
|
|
4713
4713
|
try {
|
|
4714
4714
|
J.getState().addMessage(e, await n.send(e, $(t)));
|
|
@@ -4719,9 +4719,9 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4719
4719
|
}), e;
|
|
4720
4720
|
}
|
|
4721
4721
|
},
|
|
4722
|
-
typing: (e, t) => J.getState().online[e] &&
|
|
4722
|
+
typing: (e, t) => J.getState().online[e] && C.current?.typing(e, t).catch(() => {}),
|
|
4723
4723
|
upload: async (e, t) => {
|
|
4724
|
-
let n =
|
|
4724
|
+
let n = C.current;
|
|
4725
4725
|
if (n) try {
|
|
4726
4726
|
let r = await n.upload(t);
|
|
4727
4727
|
J.getState().addMessage(e, await n.send(e, t.name, r));
|
|
@@ -4733,7 +4733,7 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4733
4733
|
}
|
|
4734
4734
|
},
|
|
4735
4735
|
createGroup: async (e, t, n) => {
|
|
4736
|
-
let r =
|
|
4736
|
+
let r = C.current, i = v.current;
|
|
4737
4737
|
if (r && i) try {
|
|
4738
4738
|
let a = await r.createGroup(e, t, n), o = J.getState();
|
|
4739
4739
|
o.setGroup(a, e, [...t, i.username], n), o.openChat(a);
|
|
@@ -4745,7 +4745,7 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4745
4745
|
}
|
|
4746
4746
|
},
|
|
4747
4747
|
remove: async (e) => {
|
|
4748
|
-
let t =
|
|
4748
|
+
let t = C.current, n = v.current;
|
|
4749
4749
|
if (!t || !n) return;
|
|
4750
4750
|
let r = J.getState().conversations[e];
|
|
4751
4751
|
try {
|
|
@@ -4758,7 +4758,7 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4758
4758
|
}
|
|
4759
4759
|
},
|
|
4760
4760
|
react: async (e, t, n) => {
|
|
4761
|
-
let r =
|
|
4761
|
+
let r = C.current, i = v.current?.username;
|
|
4762
4762
|
if (!r || !i) return;
|
|
4763
4763
|
let a = (J.getState().conversations[e]?.reactions?.[t]?.[i] ?? []).includes(n) ? [] : [n];
|
|
4764
4764
|
try {
|
|
@@ -4776,9 +4776,9 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4776
4776
|
}
|
|
4777
4777
|
},
|
|
4778
4778
|
loadOlder: async (e) => {
|
|
4779
|
-
let t =
|
|
4780
|
-
if (!(!t || n.complete ||
|
|
4781
|
-
|
|
4779
|
+
let t = C.current, n = J.getState().ensure(e);
|
|
4780
|
+
if (!(!t || n.complete || T.current.has(e))) {
|
|
4781
|
+
T.current.add(e);
|
|
4782
4782
|
try {
|
|
4783
4783
|
let r = await t.history(e, n.oldest);
|
|
4784
4784
|
J.getState().prependHistory(e, r.messages, r.complete, r.first), J.getState().applyReactions(r.reactions);
|
|
@@ -4788,31 +4788,31 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4788
4788
|
message: e.message
|
|
4789
4789
|
});
|
|
4790
4790
|
} finally {
|
|
4791
|
-
|
|
4791
|
+
T.current.delete(e);
|
|
4792
4792
|
}
|
|
4793
4793
|
}
|
|
4794
4794
|
}
|
|
4795
4795
|
}), []);
|
|
4796
4796
|
i(() => {
|
|
4797
|
-
if (!
|
|
4797
|
+
if (!g) return;
|
|
4798
4798
|
let e = J.getState();
|
|
4799
4799
|
e.reset(), J.setState({
|
|
4800
|
-
me:
|
|
4801
|
-
mucHost: `conference.${
|
|
4800
|
+
me: g.username,
|
|
4801
|
+
mucHost: `conference.${g.host}`,
|
|
4802
4802
|
maxHeads: a,
|
|
4803
4803
|
newChatButton: l
|
|
4804
4804
|
});
|
|
4805
|
-
let t = new _n(
|
|
4805
|
+
let t = new _n(g, {
|
|
4806
4806
|
status: (n, a) => {
|
|
4807
4807
|
if (e.setStatus(n, a), Y("chat-island-status", {
|
|
4808
4808
|
status: n,
|
|
4809
4809
|
error: a
|
|
4810
|
-
}), n === "online" && r && !
|
|
4810
|
+
}), n === "online" && r && !D.current && typeof Notification < "u") {
|
|
4811
4811
|
let e = Notification.permission;
|
|
4812
|
-
(e === "granted" ||
|
|
4812
|
+
(e === "granted" || b.current === "auto" && e === "default") && i();
|
|
4813
4813
|
}
|
|
4814
4814
|
n === "online" && t.listGroups().then((t) => t.forEach((t) => e.setGroup(t.peer, t.name, t.members, t.avatar, t.owner))).catch(() => {}).then(() => t.recent()).then((e) => {
|
|
4815
|
-
e && (J.getState().seed(e.messages,
|
|
4815
|
+
e && (J.getState().seed(e.messages, g.username), J.getState().applyReactions(e.reactions));
|
|
4816
4816
|
}).catch(() => {});
|
|
4817
4817
|
},
|
|
4818
4818
|
typing: (t, n) => e.setTyping(t, n),
|
|
@@ -4836,7 +4836,7 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4836
4836
|
let n = J.getState(), r = document.visibilityState === "visible";
|
|
4837
4837
|
if (r && n.open === e) return;
|
|
4838
4838
|
let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? e, o = t.oob ? "Attachment" : $(t.body), s = i?.kind === "group" && t.nick ? `${n.contacts[t.nick]?.name ?? t.nick}: ${o}` : o;
|
|
4839
|
-
if (
|
|
4839
|
+
if (y.current && xn(), Y("chat-island-notify", {
|
|
4840
4840
|
peer: e,
|
|
4841
4841
|
name: a,
|
|
4842
4842
|
body: s
|
|
@@ -4850,18 +4850,18 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4850
4850
|
};
|
|
4851
4851
|
} catch {}
|
|
4852
4852
|
};
|
|
4853
|
-
|
|
4853
|
+
C.current = t;
|
|
4854
4854
|
let i = () => {
|
|
4855
|
-
r && !
|
|
4855
|
+
r && !D.current && (D.current = !0, zn(g, r).then((e) => {
|
|
4856
4856
|
if (!e) {
|
|
4857
|
-
|
|
4857
|
+
D.current = !1, J.setState({ push: Notification.permission === "denied" ? "denied" : "ask" });
|
|
4858
4858
|
return;
|
|
4859
4859
|
}
|
|
4860
4860
|
return t.enablePush(e.service, e.node).then(() => {
|
|
4861
|
-
|
|
4861
|
+
O.current = e, J.setState({ push: "enabled" }), Y("chat-island-push", { enabled: !0 });
|
|
4862
4862
|
});
|
|
4863
4863
|
}).catch((e) => {
|
|
4864
|
-
|
|
4864
|
+
D.current = !1, Y("chat-island-error", {
|
|
4865
4865
|
scope: "push",
|
|
4866
4866
|
message: e.message
|
|
4867
4867
|
});
|
|
@@ -4873,52 +4873,52 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4873
4873
|
});
|
|
4874
4874
|
let s = () => t.stop();
|
|
4875
4875
|
window.addEventListener("pagehide", s), t.start();
|
|
4876
|
-
let c = () => Pn(
|
|
4876
|
+
let c = () => Pn(g.host, g.token).then(e.setMobile).catch(() => {});
|
|
4877
4877
|
c();
|
|
4878
4878
|
let u = window.setInterval(c, 12e4);
|
|
4879
|
-
Nn(
|
|
4879
|
+
Nn(g.host, g.token, g.username).then(e.setContacts).catch((e) => Y("chat-island-error", {
|
|
4880
4880
|
scope: "contacts",
|
|
4881
4881
|
message: e.message
|
|
4882
4882
|
}));
|
|
4883
|
-
let d = X("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = X("chat-island-close", () => e.closeChat()), p = X("chat-island-new", () => e.setPicker(!0)), m = X("chat-island-delete", ({ username: e }) => e &&
|
|
4883
|
+
let d = X("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = X("chat-island-close", () => e.closeChat()), p = X("chat-island-new", () => e.setPicker(!0)), m = X("chat-island-delete", ({ username: e }) => e && ne.remove(e)), h = X("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), _ = X("chat-island-conversations-request", () => Y("chat-island-conversations", { conversations: Lr() }));
|
|
4884
4884
|
return () => {
|
|
4885
|
-
window.removeEventListener("pagehide", s), window.clearInterval(u), _(), p(), m(), d(), f(),
|
|
4885
|
+
window.removeEventListener("pagehide", s), window.clearInterval(u), _(), p(), m(), d(), f(), h(), O.current && t.disablePush(O.current.service, O.current.node).catch(() => {}), O.current = null, t.stop(), C.current = null, D.current = !1;
|
|
4886
4886
|
};
|
|
4887
4887
|
}, [
|
|
4888
|
-
|
|
4888
|
+
g,
|
|
4889
4889
|
r,
|
|
4890
|
-
|
|
4890
|
+
x
|
|
4891
4891
|
]);
|
|
4892
|
-
let
|
|
4892
|
+
let M = J((e) => Object.keys(e.contacts).join(","));
|
|
4893
4893
|
i(() => {
|
|
4894
|
-
j === "online" &&
|
|
4895
|
-
}, [j,
|
|
4896
|
-
let
|
|
4897
|
-
i(() => Y("chat-island-conversations", { conversations: Lr() }), [
|
|
4898
|
-
let
|
|
4899
|
-
if (i(() => Y("chat-island-unread", { total:
|
|
4900
|
-
let
|
|
4894
|
+
j === "online" && M && C.current?.announce(M.split(","));
|
|
4895
|
+
}, [j, M]);
|
|
4896
|
+
let re = J((e) => Object.values(e.conversations).map((e) => `${e.peer}:${e.kind}:${e.name ?? ""}:${(e.members ?? []).length}:${e.unread}:${e.messages[e.messages.length - 1]?.id ?? ""}`).join("|") + "#" + Object.keys(e.contacts).length + "#" + Object.values(e.online).filter(Boolean).length);
|
|
4897
|
+
i(() => Y("chat-island-conversations", { conversations: Lr() }), [re]);
|
|
4898
|
+
let ie = J((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
|
|
4899
|
+
if (i(() => Y("chat-island-unread", { total: ie }), [ie]), !g) return null;
|
|
4900
|
+
let ae = m && !h && k.anchor ? {
|
|
4901
4901
|
right: k.anchor.right,
|
|
4902
4902
|
bottom: k.anchor.bottom
|
|
4903
|
-
} : void 0,
|
|
4903
|
+
} : void 0, oe = ae ? "" : t === "bottom-left" ? "ci-left-4 ci-bottom-5" : "ci-right-4 ci-bottom-5";
|
|
4904
4904
|
return /* @__PURE__ */ d("div", {
|
|
4905
|
-
ref:
|
|
4906
|
-
style:
|
|
4905
|
+
ref: ee,
|
|
4906
|
+
style: ae,
|
|
4907
4907
|
onClickCapture: k.onClickCapture,
|
|
4908
|
-
className: `chat-island-root ${
|
|
4908
|
+
className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${oe} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
|
|
4909
4909
|
"data-status": j,
|
|
4910
4910
|
children: /* @__PURE__ */ f(Rr, { children: [
|
|
4911
|
-
|
|
4912
|
-
peer:
|
|
4913
|
-
actions:
|
|
4914
|
-
onDragStart: m ? k.start : void 0
|
|
4911
|
+
te && /* @__PURE__ */ d(jr, {
|
|
4912
|
+
peer: te,
|
|
4913
|
+
actions: ne,
|
|
4914
|
+
onDragStart: h ?? (m ? k.start : void 0)
|
|
4915
4915
|
}),
|
|
4916
|
-
|
|
4916
|
+
A && /* @__PURE__ */ d(Nr, {
|
|
4917
4917
|
onOpen: (e) => J.getState().openChat(e),
|
|
4918
|
-
onCreateGroup:
|
|
4918
|
+
onCreateGroup: ne.createGroup
|
|
4919
4919
|
}),
|
|
4920
4920
|
/* @__PURE__ */ d(Kn, {
|
|
4921
|
-
onDragStart: m ? k.start : void 0,
|
|
4921
|
+
onDragStart: h ?? (m ? k.start : void 0),
|
|
4922
4922
|
pushButton: u !== "auto"
|
|
4923
4923
|
})
|
|
4924
4924
|
] })
|