@jokio/sdk 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth.service.d.ts +3 -0
- package/dist/jokio.sdk.es.js +220 -207
- package/dist/jokio.sdk.umd.js +1 -1
- package/package.json +1 -1
package/dist/jokio.sdk.es.js
CHANGED
|
@@ -359,20 +359,24 @@ class Xr {
|
|
|
359
359
|
}
|
|
360
360
|
async me() {
|
|
361
361
|
return await fetch(this.options.authUrl + "/me", {
|
|
362
|
-
|
|
362
|
+
headers: await this.getAuthHeader()
|
|
363
363
|
}).then((t) => t.json());
|
|
364
364
|
}
|
|
365
365
|
async requestEmailLogin(e, t = location.href) {
|
|
366
366
|
return await fetch(
|
|
367
367
|
this.options.authUrl + `/email-verification-request/${e}?returnUrl=${t}`,
|
|
368
|
-
{
|
|
368
|
+
{
|
|
369
|
+
headers: await this.getAuthHeader()
|
|
370
|
+
}
|
|
369
371
|
).then(xt);
|
|
370
372
|
}
|
|
371
373
|
async completeEmailLogin(e, t) {
|
|
372
374
|
var i;
|
|
373
375
|
const s = await fetch(
|
|
374
376
|
this.options.authUrl + `/email-verification-complete/${e}/${t}`,
|
|
375
|
-
{
|
|
377
|
+
{
|
|
378
|
+
headers: await this.getAuthHeader()
|
|
379
|
+
}
|
|
376
380
|
).then(xt);
|
|
377
381
|
return await this.options.storage.setItem(
|
|
378
382
|
wt,
|
|
@@ -387,7 +391,9 @@ class Xr {
|
|
|
387
391
|
addAsAdditionalDevice: i = !1
|
|
388
392
|
} = e, n = await fetch(
|
|
389
393
|
this.options.authUrl + `/webauth-challenge-request?registration=${s ? "true" : ""}&displayName=${t}`,
|
|
390
|
-
{
|
|
394
|
+
{
|
|
395
|
+
headers: await this.getAuthHeader()
|
|
396
|
+
}
|
|
391
397
|
).then(xt);
|
|
392
398
|
let o;
|
|
393
399
|
try {
|
|
@@ -407,9 +413,9 @@ class Xr {
|
|
|
407
413
|
method: "POST",
|
|
408
414
|
body: JSON.stringify(o),
|
|
409
415
|
headers: {
|
|
410
|
-
"Content-Type": "application/json"
|
|
411
|
-
|
|
412
|
-
|
|
416
|
+
"Content-Type": "application/json",
|
|
417
|
+
...await this.getAuthHeader()
|
|
418
|
+
}
|
|
413
419
|
}
|
|
414
420
|
).then(xt);
|
|
415
421
|
return await this.options.storage.setItem(
|
|
@@ -445,6 +451,13 @@ class Xr {
|
|
|
445
451
|
getSessionSeed() {
|
|
446
452
|
return this.options.storage.getItem(_r);
|
|
447
453
|
}
|
|
454
|
+
async getAuthHeader() {
|
|
455
|
+
const e = await this.getAccessToken();
|
|
456
|
+
if (e)
|
|
457
|
+
return {
|
|
458
|
+
authorization: "bearer " + e
|
|
459
|
+
};
|
|
460
|
+
}
|
|
448
461
|
}
|
|
449
462
|
const xt = async (r) => {
|
|
450
463
|
const e = await r.json();
|
|
@@ -578,25 +591,25 @@ class en {
|
|
|
578
591
|
}
|
|
579
592
|
}
|
|
580
593
|
const Ge = new en();
|
|
581
|
-
var
|
|
594
|
+
var ke;
|
|
582
595
|
(function(r) {
|
|
583
596
|
r.Disconnect = "disconnect", r.Reconnect = "reconnect", r.Update = "update", r.LDM = "ldm", r.Error = "error";
|
|
584
|
-
})(
|
|
597
|
+
})(ke || (ke = {}));
|
|
585
598
|
var He;
|
|
586
599
|
(function(r) {
|
|
587
600
|
r.Reconnecting = "reconnecting", r.PingTimer = "pingTimer", r.StaleConnection = "staleConnection", r.ClientInitiatedReconnect = "client initiated reconnect";
|
|
588
601
|
})(He || (He = {}));
|
|
589
|
-
var
|
|
602
|
+
var k;
|
|
590
603
|
(function(r) {
|
|
591
604
|
r.ApiError = "BAD API", r.BadAuthentication = "BAD_AUTHENTICATION", r.BadCreds = "BAD_CREDS", r.BadHeader = "BAD_HEADER", r.BadJson = "BAD_JSON", r.BadPayload = "BAD_PAYLOAD", r.BadSubject = "BAD_SUBJECT", r.Cancelled = "CANCELLED", r.ConnectionClosed = "CONNECTION_CLOSED", r.ConnectionDraining = "CONNECTION_DRAINING", r.ConnectionRefused = "CONNECTION_REFUSED", r.ConnectionTimeout = "CONNECTION_TIMEOUT", r.Disconnect = "DISCONNECT", r.InvalidOption = "INVALID_OPTION", r.InvalidPayload = "INVALID_PAYLOAD", r.MaxPayloadExceeded = "MAX_PAYLOAD_EXCEEDED", r.NoResponders = "503", r.NotFunction = "NOT_FUNC", r.RequestError = "REQUEST_ERROR", r.ServerOptionNotAvailable = "SERVER_OPT_NA", r.SubClosed = "SUB_CLOSED", r.SubDraining = "SUB_DRAINING", r.Timeout = "TIMEOUT", r.Tls = "TLS", r.Unknown = "UNKNOWN_ERROR", r.WssRequired = "WSS_REQUIRED", r.JetStreamInvalidAck = "JESTREAM_INVALID_ACK", r.JetStream404NoMessages = "404", r.JetStream408RequestTimeout = "408", r.JetStream409MaxAckPendingExceeded = "409", r.JetStream409 = "409", r.JetStreamNotEnabled = "503", r.JetStreamIdleHeartBeat = "IDLE_HEARTBEAT", r.AuthorizationViolation = "AUTHORIZATION_VIOLATION", r.AuthenticationExpired = "AUTHENTICATION_EXPIRED", r.ProtocolError = "NATS_PROTOCOL_ERR", r.PermissionsViolation = "PERMISSIONS_VIOLATION", r.AuthenticationTimeout = "AUTHENTICATION_TIMEOUT", r.AccountExpired = "ACCOUNT_EXPIRED";
|
|
592
|
-
})(
|
|
605
|
+
})(k || (k = {}));
|
|
593
606
|
function tn(r) {
|
|
594
607
|
return typeof r.code == "string";
|
|
595
608
|
}
|
|
596
609
|
class Zr {
|
|
597
610
|
constructor() {
|
|
598
611
|
h(this, "messages");
|
|
599
|
-
this.messages = /* @__PURE__ */ new Map(), this.messages.set(
|
|
612
|
+
this.messages = /* @__PURE__ */ new Map(), this.messages.set(k.InvalidPayload, "Invalid payload type - payloads can be 'binary', 'string', or 'json'"), this.messages.set(k.BadJson, "Bad JSON"), this.messages.set(k.WssRequired, "TLS is required, therefore a secure websocket connection is also required");
|
|
600
613
|
}
|
|
601
614
|
static getMessage(e) {
|
|
602
615
|
return sn.getMessage(e);
|
|
@@ -622,16 +635,16 @@ class T extends Error {
|
|
|
622
635
|
return new T(i, t, s);
|
|
623
636
|
}
|
|
624
637
|
isAuthError() {
|
|
625
|
-
return this.code ===
|
|
638
|
+
return this.code === k.AuthenticationExpired || this.code === k.AuthorizationViolation || this.code === k.AccountExpired;
|
|
626
639
|
}
|
|
627
640
|
isAuthTimeout() {
|
|
628
|
-
return this.code ===
|
|
641
|
+
return this.code === k.AuthenticationTimeout;
|
|
629
642
|
}
|
|
630
643
|
isPermissionError() {
|
|
631
|
-
return this.code ===
|
|
644
|
+
return this.code === k.PermissionsViolation;
|
|
632
645
|
}
|
|
633
646
|
isProtocolError() {
|
|
634
|
-
return this.code ===
|
|
647
|
+
return this.code === k.ProtocolError;
|
|
635
648
|
}
|
|
636
649
|
isJetStreamError() {
|
|
637
650
|
return this.api_error !== void 0;
|
|
@@ -648,10 +661,10 @@ var Ne;
|
|
|
648
661
|
(function(r) {
|
|
649
662
|
r.Timer = "timer", r.Count = "count", r.JitterTimer = "jitterTimer", r.SentinelMsg = "sentinelMsg";
|
|
650
663
|
})(Ne || (Ne = {}));
|
|
651
|
-
var
|
|
664
|
+
var kt;
|
|
652
665
|
(function(r) {
|
|
653
666
|
r.STATS = "io.nats.micro.v1.stats_response", r.INFO = "io.nats.micro.v1.info_response", r.PING = "io.nats.micro.v1.ping_response";
|
|
654
|
-
})(
|
|
667
|
+
})(kt || (kt = {}));
|
|
655
668
|
const Qt = "Nats-Service-Error", es = "Nats-Service-Error-Code";
|
|
656
669
|
class ts extends Error {
|
|
657
670
|
constructor(t, s) {
|
|
@@ -698,7 +711,7 @@ function Kt(r) {
|
|
|
698
711
|
return xe.decode(r).replace(/\n/g, "␊").replace(/\r/g, "␍");
|
|
699
712
|
}
|
|
700
713
|
function lt(r, e = !0) {
|
|
701
|
-
const t = e ? T.errorForCode(
|
|
714
|
+
const t = e ? T.errorForCode(k.Timeout) : null;
|
|
702
715
|
let s, i;
|
|
703
716
|
const n = new Promise((o, a) => {
|
|
704
717
|
s = {
|
|
@@ -706,7 +719,7 @@ function lt(r, e = !0) {
|
|
|
706
719
|
i && clearTimeout(i);
|
|
707
720
|
}
|
|
708
721
|
}, i = setTimeout(() => {
|
|
709
|
-
a(t === null ? T.errorForCode(
|
|
722
|
+
a(t === null ? T.errorForCode(k.Timeout) : t);
|
|
710
723
|
}, r);
|
|
711
724
|
});
|
|
712
725
|
return Object.assign(n, s);
|
|
@@ -785,7 +798,7 @@ function Pr(r) {
|
|
|
785
798
|
for (let n = 0; n < r.length; n++) {
|
|
786
799
|
let o = r.charCodeAt(n);
|
|
787
800
|
if (o === 58 || o < 33 || o > 126)
|
|
788
|
-
throw new T(`'${r[n]}' is not a valid character for a header key`,
|
|
801
|
+
throw new T(`'${r[n]}' is not a valid character for a header key`, k.BadHeader);
|
|
789
802
|
s && 97 <= o && o <= 122 ? o -= 32 : !s && 65 <= o && o <= 90 && (o += 32), i[n] = o, s = o == 45;
|
|
790
803
|
}
|
|
791
804
|
return String.fromCharCode(...i);
|
|
@@ -795,7 +808,7 @@ function Fe(r = 0, e = "") {
|
|
|
795
808
|
throw new Error("setting status requires both code and description");
|
|
796
809
|
return new Ke(r, e);
|
|
797
810
|
}
|
|
798
|
-
const
|
|
811
|
+
const ks = "NATS/1.0";
|
|
799
812
|
class Ke {
|
|
800
813
|
constructor(e = 0, t = "") {
|
|
801
814
|
h(this, "_code");
|
|
@@ -831,8 +844,8 @@ class Ke {
|
|
|
831
844
|
static decode(e) {
|
|
832
845
|
const t = new Ke(), i = xe.decode(e).split(`\r
|
|
833
846
|
`), n = i[0];
|
|
834
|
-
if (n !==
|
|
835
|
-
let o = n.replace(
|
|
847
|
+
if (n !== ks) {
|
|
848
|
+
let o = n.replace(ks, "").trim();
|
|
836
849
|
if (o.length > 0) {
|
|
837
850
|
t._code = parseInt(o, 10), isNaN(t._code) && (t._code = 0);
|
|
838
851
|
const a = t._code.toString();
|
|
@@ -852,7 +865,7 @@ class Ke {
|
|
|
852
865
|
toString() {
|
|
853
866
|
if (this.headers.size === 0 && this._code === 0)
|
|
854
867
|
return "";
|
|
855
|
-
let e =
|
|
868
|
+
let e = ks;
|
|
856
869
|
this._code > 0 && this._description !== "" && (e += ` ${this._code} ${this._description}`);
|
|
857
870
|
for (const [t, s] of this.headers)
|
|
858
871
|
for (let i = 0; i < s.length; i++)
|
|
@@ -867,7 +880,7 @@ ${t}: ${s[i]}`;
|
|
|
867
880
|
}
|
|
868
881
|
static validHeaderValue(e) {
|
|
869
882
|
if (/[\r\n]/.test(e))
|
|
870
|
-
throw new T("invalid header value - \\r and \\n are not allowed.",
|
|
883
|
+
throw new T("invalid header value - \\r and \\n are not allowed.", k.BadHeader);
|
|
871
884
|
return e.trim();
|
|
872
885
|
}
|
|
873
886
|
keys() {
|
|
@@ -969,27 +982,27 @@ function Us() {
|
|
|
969
982
|
}
|
|
970
983
|
};
|
|
971
984
|
}
|
|
972
|
-
function
|
|
985
|
+
function Oe(r) {
|
|
973
986
|
return {
|
|
974
987
|
encode(e) {
|
|
975
988
|
try {
|
|
976
989
|
return e === void 0 && (e = null), We.encode(JSON.stringify(e));
|
|
977
990
|
} catch (t) {
|
|
978
|
-
throw T.errorForCode(
|
|
991
|
+
throw T.errorForCode(k.BadJson, t);
|
|
979
992
|
}
|
|
980
993
|
},
|
|
981
994
|
decode(e) {
|
|
982
995
|
try {
|
|
983
996
|
return JSON.parse(xe.decode(e), r);
|
|
984
997
|
} catch (t) {
|
|
985
|
-
throw T.errorForCode(
|
|
998
|
+
throw T.errorForCode(k.BadJson, t);
|
|
986
999
|
}
|
|
987
1000
|
}
|
|
988
1001
|
};
|
|
989
1002
|
}
|
|
990
1003
|
function ei(r) {
|
|
991
1004
|
var e;
|
|
992
|
-
return r && r.data.length === 0 && ((e = r.headers) == null ? void 0 : e.code) === 503 ? T.errorForCode(
|
|
1005
|
+
return r && r.data.length === 0 && ((e = r.headers) == null ? void 0 : e.code) === 503 ? T.errorForCode(k.NoResponders) : null;
|
|
993
1006
|
}
|
|
994
1007
|
class Qs {
|
|
995
1008
|
constructor(e, t, s) {
|
|
@@ -1029,7 +1042,7 @@ class Qs {
|
|
|
1029
1042
|
return e + t + s;
|
|
1030
1043
|
}
|
|
1031
1044
|
json(e) {
|
|
1032
|
-
return
|
|
1045
|
+
return Oe(e).decode(this.data);
|
|
1033
1046
|
}
|
|
1034
1047
|
string() {
|
|
1035
1048
|
return xe.decode(this.data);
|
|
@@ -1128,7 +1141,7 @@ var Pe;
|
|
|
1128
1141
|
r.MaxBatchExceeded = "exceeded maxrequestbatch of", r.MaxExpiresExceeded = "exceeded maxrequestexpires of", r.MaxBytesExceeded = "exceeded maxrequestmaxbytes of", r.MaxMessageSizeExceeded = "message size exceeds maxbytes", r.PushConsumer = "consumer is push based", r.MaxWaitingExceeded = "exceeded maxwaiting", r.IdleHeartbeatMissed = "idle heartbeats missed", r.ConsumerDeleted = "consumer deleted";
|
|
1129
1142
|
})(Pe || (Pe = {}));
|
|
1130
1143
|
function an(r) {
|
|
1131
|
-
return r.code !==
|
|
1144
|
+
return r.code !== k.JetStream409 ? !1 : [
|
|
1132
1145
|
Pe.MaxBatchExceeded,
|
|
1133
1146
|
Pe.MaxExpiresExceeded,
|
|
1134
1147
|
Pe.MaxBytesExceeded,
|
|
@@ -1143,17 +1156,17 @@ function ti(r, e = "") {
|
|
|
1143
1156
|
return null;
|
|
1144
1157
|
switch (e = e.toLowerCase(), r) {
|
|
1145
1158
|
case 404:
|
|
1146
|
-
return new T(e,
|
|
1159
|
+
return new T(e, k.JetStream404NoMessages);
|
|
1147
1160
|
case 408:
|
|
1148
|
-
return new T(e,
|
|
1161
|
+
return new T(e, k.JetStream408RequestTimeout);
|
|
1149
1162
|
case 409: {
|
|
1150
|
-
const t = e.startsWith(Pe.IdleHeartbeatMissed) ?
|
|
1163
|
+
const t = e.startsWith(Pe.IdleHeartbeatMissed) ? k.JetStreamIdleHeartBeat : k.JetStream409;
|
|
1151
1164
|
return new T(e, t);
|
|
1152
1165
|
}
|
|
1153
1166
|
case 503:
|
|
1154
|
-
return T.errorForCode(
|
|
1167
|
+
return T.errorForCode(k.JetStreamNotEnabled, new Error(e));
|
|
1155
1168
|
default:
|
|
1156
|
-
return e === "" && (e =
|
|
1169
|
+
return e === "" && (e = k.Unknown), new T(e, `${r}`);
|
|
1157
1170
|
}
|
|
1158
1171
|
}
|
|
1159
1172
|
class he {
|
|
@@ -1196,9 +1209,9 @@ class he {
|
|
|
1196
1209
|
}
|
|
1197
1210
|
async *iterate() {
|
|
1198
1211
|
if (this.noIterator)
|
|
1199
|
-
throw new T("unsupported iterator",
|
|
1212
|
+
throw new T("unsupported iterator", k.ApiError);
|
|
1200
1213
|
if (this.yielding)
|
|
1201
|
-
throw new T("already yielding",
|
|
1214
|
+
throw new T("already yielding", k.ApiError);
|
|
1202
1215
|
this.yielding = !0;
|
|
1203
1216
|
try {
|
|
1204
1217
|
for (; ; ) {
|
|
@@ -1328,10 +1341,10 @@ function cn(r, e = {}) {
|
|
|
1328
1341
|
replay_policy: ft.Instant
|
|
1329
1342
|
}, e);
|
|
1330
1343
|
}
|
|
1331
|
-
var
|
|
1344
|
+
var kr;
|
|
1332
1345
|
(function(r) {
|
|
1333
1346
|
r.API = "api_audit", r.StreamAction = "stream_action", r.ConsumerAction = "consumer_action", r.SnapshotCreate = "snapshot_create", r.SnapshotComplete = "snapshot_complete", r.RestoreCreate = "restore_create", r.RestoreComplete = "restore_complete", r.MaxDeliver = "max_deliver", r.Terminated = "terminated", r.Ack = "consumer_ack", r.StreamLeaderElected = "stream_leader_elected", r.StreamQuorumLost = "stream_quorum_lost", r.ConsumerLeaderElected = "consumer_leader_elected", r.ConsumerQuorumLost = "consumer_quorum_lost";
|
|
1334
|
-
})(
|
|
1347
|
+
})(kr || (kr = {}));
|
|
1335
1348
|
var ge;
|
|
1336
1349
|
(function(r) {
|
|
1337
1350
|
r.StreamSourceHdr = "Nats-Stream-Source", r.LastConsumerSeqHdr = "Nats-Last-Consumer", r.LastStreamSeqHdr = "Nats-Last-Stream", r.ConsumerStalledHdr = "Nats-Consumer-Stalled", r.MessageSizeHdr = "Nats-Msg-Size", r.RollupHdr = "Nats-Rollup", r.RollupValueSubject = "sub", r.RollupValueAll = "all", r.PendingMessagesHdr = "Nats-Pending-Messages", r.PendingBytesHdr = "Nats-Pending-Bytes";
|
|
@@ -1344,10 +1357,10 @@ var nt;
|
|
|
1344
1357
|
(function(r) {
|
|
1345
1358
|
r.Stream = "Nats-Stream", r.Sequence = "Nats-Sequence", r.TimeStamp = "Nats-Time-Stamp", r.Subject = "Nats-Subject";
|
|
1346
1359
|
})(nt || (nt = {}));
|
|
1347
|
-
var
|
|
1360
|
+
var Or;
|
|
1348
1361
|
(function(r) {
|
|
1349
1362
|
r.Stream = "Nats-Stream", r.Subject = "Nats-Subject", r.Sequence = "Nats-Sequence", r.LastSequence = "Nats-Last-Sequence", r.Size = "Nats-Msg-Size";
|
|
1350
|
-
})(
|
|
1363
|
+
})(Or || (Or = {}));
|
|
1351
1364
|
const we = "KV_";
|
|
1352
1365
|
class hn {
|
|
1353
1366
|
constructor(e) {
|
|
@@ -1638,7 +1651,7 @@ function pn(r) {
|
|
|
1638
1651
|
});
|
|
1639
1652
|
}), e;
|
|
1640
1653
|
}
|
|
1641
|
-
var
|
|
1654
|
+
var Os, us = {
|
|
1642
1655
|
exports: {}
|
|
1643
1656
|
}, jr = {}, Rr = pn(ln({
|
|
1644
1657
|
__proto__: null,
|
|
@@ -1646,12 +1659,12 @@ var ks, us = {
|
|
|
1646
1659
|
}, [
|
|
1647
1660
|
jr
|
|
1648
1661
|
]));
|
|
1649
|
-
|
|
1662
|
+
Os = us, function() {
|
|
1650
1663
|
var r = "input is invalid type", e = typeof window == "object", t = e ? window : {};
|
|
1651
1664
|
t.JS_SHA256_NO_WINDOW && (e = !1);
|
|
1652
1665
|
var s = !e && typeof self == "object", i = !t.JS_SHA256_NO_NODE_JS && Ir.versions && Ir.versions.node;
|
|
1653
1666
|
i ? t = dn : s && (t = self);
|
|
1654
|
-
var n = !t.JS_SHA256_NO_COMMON_JS &&
|
|
1667
|
+
var n = !t.JS_SHA256_NO_COMMON_JS && Os.exports, o = !t.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", a = "0123456789abcdef".split(""), f = [
|
|
1655
1668
|
-2147483648,
|
|
1656
1669
|
8388608,
|
|
1657
1670
|
32768,
|
|
@@ -1897,7 +1910,7 @@ ks = us, function() {
|
|
|
1897
1910
|
}
|
|
1898
1911
|
};
|
|
1899
1912
|
var de = I();
|
|
1900
|
-
de.sha256 = de, de.sha224 = I(!0), de.sha256.hmac = ee(), de.sha224.hmac = ee(!0), n ?
|
|
1913
|
+
de.sha256 = de, de.sha224 = I(!0), de.sha256.hmac = ee(), de.sha224.hmac = ee(!0), n ? Os.exports = de : (t.sha256 = de.sha256, t.sha224 = de.sha224);
|
|
1901
1914
|
}();
|
|
1902
1915
|
us.exports;
|
|
1903
1916
|
us.exports.sha224;
|
|
@@ -2002,7 +2015,7 @@ class ri extends si {
|
|
|
2002
2015
|
${this.ctx.stack}`), this.deferred.reject(t)) : this.deferred.resolve(s), this.cancel();
|
|
2003
2016
|
}
|
|
2004
2017
|
cancel(t) {
|
|
2005
|
-
this.timer && this.timer.cancel(), this.mux.cancel(this), this.deferred.reject(t || T.errorForCode(
|
|
2018
|
+
this.timer && this.timer.cancel(), this.mux.cancel(this), this.deferred.reject(t || T.errorForCode(k.Cancelled));
|
|
2006
2019
|
}
|
|
2007
2020
|
}
|
|
2008
2021
|
const vn = "$JS.API";
|
|
@@ -2019,7 +2032,7 @@ class Tt {
|
|
|
2019
2032
|
h(this, "prefix");
|
|
2020
2033
|
h(this, "timeout");
|
|
2021
2034
|
h(this, "jc");
|
|
2022
|
-
this.nc = e, this.opts = En(t), this._parseOpts(), this.prefix = this.opts.apiPrefix, this.timeout = this.opts.timeout, this.jc =
|
|
2035
|
+
this.nc = e, this.opts = En(t), this._parseOpts(), this.prefix = this.opts.apiPrefix, this.timeout = this.opts.timeout, this.jc = Oe();
|
|
2023
2036
|
}
|
|
2024
2037
|
getOptions() {
|
|
2025
2038
|
return Object.assign({}, this.opts);
|
|
@@ -2043,7 +2056,7 @@ class Tt {
|
|
|
2043
2056
|
return this.parseJsResponse(f);
|
|
2044
2057
|
} catch (f) {
|
|
2045
2058
|
const p = f;
|
|
2046
|
-
if ((p.code === "503" || p.code ===
|
|
2059
|
+
if ((p.code === "503" || p.code === k.Timeout) && a + 1 < n)
|
|
2047
2060
|
await pt(o.backoff(a));
|
|
2048
2061
|
else
|
|
2049
2062
|
throw f;
|
|
@@ -2252,9 +2265,9 @@ class rs extends Tt {
|
|
|
2252
2265
|
}
|
|
2253
2266
|
function it(r, e, t = !1) {
|
|
2254
2267
|
if (t === !0 && !r)
|
|
2255
|
-
throw T.errorForCode(
|
|
2268
|
+
throw T.errorForCode(k.ApiError, new Error(`${e} is not a function`));
|
|
2256
2269
|
if (r && typeof r != "function")
|
|
2257
|
-
throw T.errorForCode(
|
|
2270
|
+
throw T.errorForCode(k.ApiError, new Error(`${e} is not a function`));
|
|
2258
2271
|
}
|
|
2259
2272
|
class Pn extends he {
|
|
2260
2273
|
constructor(t, s, i) {
|
|
@@ -2338,7 +2351,7 @@ class Pn extends he {
|
|
|
2338
2351
|
}
|
|
2339
2352
|
}
|
|
2340
2353
|
let Se;
|
|
2341
|
-
function
|
|
2354
|
+
function kn(r) {
|
|
2342
2355
|
Se = r;
|
|
2343
2356
|
}
|
|
2344
2357
|
function ii() {
|
|
@@ -2347,7 +2360,7 @@ function ii() {
|
|
|
2347
2360
|
function Cs() {
|
|
2348
2361
|
return Se !== void 0 && Se.urlParseFn ? Se.urlParseFn : void 0;
|
|
2349
2362
|
}
|
|
2350
|
-
function
|
|
2363
|
+
function On() {
|
|
2351
2364
|
if (!Se || typeof Se.factory != "function")
|
|
2352
2365
|
throw new Error("transport fn is not set");
|
|
2353
2366
|
return Se.factory();
|
|
@@ -2538,7 +2551,7 @@ function Hn(r) {
|
|
|
2538
2551
|
port: t
|
|
2539
2552
|
};
|
|
2540
2553
|
}
|
|
2541
|
-
class
|
|
2554
|
+
class Ot {
|
|
2542
2555
|
constructor(e, t = !1) {
|
|
2543
2556
|
h(this, "src");
|
|
2544
2557
|
h(this, "listen");
|
|
@@ -2573,7 +2586,7 @@ class kt {
|
|
|
2573
2586
|
for (const i of s) {
|
|
2574
2587
|
const n = this.port === 80 ? "https" : "http", o = new URL(`${n}://${Ks(i) ? "[" + i + "]" : i}`);
|
|
2575
2588
|
o.port = `${this.port}`;
|
|
2576
|
-
const a = new
|
|
2589
|
+
const a = new Ot(o.host, !1);
|
|
2577
2590
|
a.tlsName = this.hostname, t.push(a);
|
|
2578
2591
|
}
|
|
2579
2592
|
}
|
|
@@ -2590,7 +2603,7 @@ class Jn {
|
|
|
2590
2603
|
this.firstSelect = !0, this.servers = [], this.tlsName = "", this.randomize = t.randomize || !1;
|
|
2591
2604
|
const s = Cs();
|
|
2592
2605
|
e && (e.forEach((i) => {
|
|
2593
|
-
i = s ? s(i) : i, this.servers.push(new
|
|
2606
|
+
i = s ? s(i) : i, this.servers.push(new Ot(i));
|
|
2594
2607
|
}), this.randomize && (this.servers = Qr(this.servers))), this.servers.length === 0 && this.addServer(`${Ms}:${ii()}`, !1), this.currentServer = this.servers[0];
|
|
2595
2608
|
}
|
|
2596
2609
|
clear() {
|
|
@@ -2608,7 +2621,7 @@ class Jn {
|
|
|
2608
2621
|
addServer(e, t = !1) {
|
|
2609
2622
|
const s = Cs();
|
|
2610
2623
|
e = s ? s(e) : e;
|
|
2611
|
-
const i = new
|
|
2624
|
+
const i = new Ot(e, t);
|
|
2612
2625
|
Js(i.hostname) && (i.tlsName = this.tlsName), this.servers.push(i);
|
|
2613
2626
|
}
|
|
2614
2627
|
selectServer() {
|
|
@@ -2641,7 +2654,7 @@ class Jn {
|
|
|
2641
2654
|
const n = Cs(), o = /* @__PURE__ */ new Map();
|
|
2642
2655
|
e.connect_urls && e.connect_urls.length > 0 && e.connect_urls.forEach((f) => {
|
|
2643
2656
|
f = n ? n(f, t) : f;
|
|
2644
|
-
const p = new
|
|
2657
|
+
const p = new Ot(f, !0);
|
|
2645
2658
|
o.set(f, p);
|
|
2646
2659
|
});
|
|
2647
2660
|
const a = [];
|
|
@@ -2712,7 +2725,7 @@ class Kn {
|
|
|
2712
2725
|
};
|
|
2713
2726
|
}
|
|
2714
2727
|
close() {
|
|
2715
|
-
const e = T.errorForCode(
|
|
2728
|
+
const e = T.errorForCode(k.Timeout);
|
|
2716
2729
|
this.reqs.forEach((t) => {
|
|
2717
2730
|
t.resolver(e, {});
|
|
2718
2731
|
});
|
|
@@ -2886,105 +2899,105 @@ class Ur {
|
|
|
2886
2899
|
h(this, "ma");
|
|
2887
2900
|
h(this, "argBuf");
|
|
2888
2901
|
h(this, "msgBuf");
|
|
2889
|
-
this.dispatcher = e, this.state =
|
|
2902
|
+
this.dispatcher = e, this.state = O.OP_START, this.as = 0, this.drop = 0, this.hdr = 0;
|
|
2890
2903
|
}
|
|
2891
2904
|
parse(e) {
|
|
2892
2905
|
let t;
|
|
2893
2906
|
for (t = 0; t < e.length; t++) {
|
|
2894
2907
|
const s = e[t];
|
|
2895
2908
|
switch (this.state) {
|
|
2896
|
-
case
|
|
2909
|
+
case O.OP_START:
|
|
2897
2910
|
switch (s) {
|
|
2898
2911
|
case C.M:
|
|
2899
2912
|
case C.m:
|
|
2900
|
-
this.state =
|
|
2913
|
+
this.state = O.OP_M, this.hdr = -1, this.ma = Mr();
|
|
2901
2914
|
break;
|
|
2902
2915
|
case C.H:
|
|
2903
2916
|
case C.h:
|
|
2904
|
-
this.state =
|
|
2917
|
+
this.state = O.OP_H, this.hdr = 0, this.ma = Mr();
|
|
2905
2918
|
break;
|
|
2906
2919
|
case C.P:
|
|
2907
2920
|
case C.p:
|
|
2908
|
-
this.state =
|
|
2921
|
+
this.state = O.OP_P;
|
|
2909
2922
|
break;
|
|
2910
2923
|
case C.PLUS:
|
|
2911
|
-
this.state =
|
|
2924
|
+
this.state = O.OP_PLUS;
|
|
2912
2925
|
break;
|
|
2913
2926
|
case C.MINUS:
|
|
2914
|
-
this.state =
|
|
2927
|
+
this.state = O.OP_MINUS;
|
|
2915
2928
|
break;
|
|
2916
2929
|
case C.I:
|
|
2917
2930
|
case C.i:
|
|
2918
|
-
this.state =
|
|
2931
|
+
this.state = O.OP_I;
|
|
2919
2932
|
break;
|
|
2920
2933
|
default:
|
|
2921
2934
|
throw this.fail(e.subarray(t));
|
|
2922
2935
|
}
|
|
2923
2936
|
break;
|
|
2924
|
-
case
|
|
2937
|
+
case O.OP_H:
|
|
2925
2938
|
switch (s) {
|
|
2926
2939
|
case C.M:
|
|
2927
2940
|
case C.m:
|
|
2928
|
-
this.state =
|
|
2941
|
+
this.state = O.OP_M;
|
|
2929
2942
|
break;
|
|
2930
2943
|
default:
|
|
2931
2944
|
throw this.fail(e.subarray(t));
|
|
2932
2945
|
}
|
|
2933
2946
|
break;
|
|
2934
|
-
case
|
|
2947
|
+
case O.OP_M:
|
|
2935
2948
|
switch (s) {
|
|
2936
2949
|
case C.S:
|
|
2937
2950
|
case C.s:
|
|
2938
|
-
this.state =
|
|
2951
|
+
this.state = O.OP_MS;
|
|
2939
2952
|
break;
|
|
2940
2953
|
default:
|
|
2941
2954
|
throw this.fail(e.subarray(t));
|
|
2942
2955
|
}
|
|
2943
2956
|
break;
|
|
2944
|
-
case
|
|
2957
|
+
case O.OP_MS:
|
|
2945
2958
|
switch (s) {
|
|
2946
2959
|
case C.G:
|
|
2947
2960
|
case C.g:
|
|
2948
|
-
this.state =
|
|
2961
|
+
this.state = O.OP_MSG;
|
|
2949
2962
|
break;
|
|
2950
2963
|
default:
|
|
2951
2964
|
throw this.fail(e.subarray(t));
|
|
2952
2965
|
}
|
|
2953
2966
|
break;
|
|
2954
|
-
case
|
|
2967
|
+
case O.OP_MSG:
|
|
2955
2968
|
switch (s) {
|
|
2956
2969
|
case C.SPACE:
|
|
2957
2970
|
case C.TAB:
|
|
2958
|
-
this.state =
|
|
2971
|
+
this.state = O.OP_MSG_SPC;
|
|
2959
2972
|
break;
|
|
2960
2973
|
default:
|
|
2961
2974
|
throw this.fail(e.subarray(t));
|
|
2962
2975
|
}
|
|
2963
2976
|
break;
|
|
2964
|
-
case
|
|
2977
|
+
case O.OP_MSG_SPC:
|
|
2965
2978
|
switch (s) {
|
|
2966
2979
|
case C.SPACE:
|
|
2967
2980
|
case C.TAB:
|
|
2968
2981
|
continue;
|
|
2969
2982
|
default:
|
|
2970
|
-
this.state =
|
|
2983
|
+
this.state = O.MSG_ARG, this.as = t;
|
|
2971
2984
|
}
|
|
2972
2985
|
break;
|
|
2973
|
-
case
|
|
2986
|
+
case O.MSG_ARG:
|
|
2974
2987
|
switch (s) {
|
|
2975
2988
|
case C.CR:
|
|
2976
2989
|
this.drop = 1;
|
|
2977
2990
|
break;
|
|
2978
2991
|
case C.NL: {
|
|
2979
2992
|
const i = this.argBuf ? this.argBuf.bytes() : e.subarray(this.as, t - this.drop);
|
|
2980
|
-
this.processMsgArgs(i), this.drop = 0, this.as = t + 1, this.state =
|
|
2993
|
+
this.processMsgArgs(i), this.drop = 0, this.as = t + 1, this.state = O.MSG_PAYLOAD, t = this.as + this.ma.size - 1;
|
|
2981
2994
|
break;
|
|
2982
2995
|
}
|
|
2983
2996
|
default:
|
|
2984
2997
|
this.argBuf && this.argBuf.writeByte(s);
|
|
2985
2998
|
}
|
|
2986
2999
|
break;
|
|
2987
|
-
case
|
|
3000
|
+
case O.MSG_PAYLOAD:
|
|
2988
3001
|
if (this.msgBuf)
|
|
2989
3002
|
if (this.msgBuf.length >= this.ma.size) {
|
|
2990
3003
|
const i = this.msgBuf.bytes({
|
|
@@ -2994,7 +3007,7 @@ class Ur {
|
|
|
2994
3007
|
kind: me.MSG,
|
|
2995
3008
|
msg: this.ma,
|
|
2996
3009
|
data: i
|
|
2997
|
-
}), this.argBuf = void 0, this.msgBuf = void 0, this.state =
|
|
3010
|
+
}), this.argBuf = void 0, this.msgBuf = void 0, this.state = O.MSG_END;
|
|
2998
3011
|
} else {
|
|
2999
3012
|
let i = this.ma.size - this.msgBuf.length;
|
|
3000
3013
|
const n = e.length - t;
|
|
@@ -3004,96 +3017,96 @@ class Ur {
|
|
|
3004
3017
|
kind: me.MSG,
|
|
3005
3018
|
msg: this.ma,
|
|
3006
3019
|
data: e.subarray(this.as, t)
|
|
3007
|
-
}), this.argBuf = void 0, this.msgBuf = void 0, this.state =
|
|
3020
|
+
}), this.argBuf = void 0, this.msgBuf = void 0, this.state = O.MSG_END);
|
|
3008
3021
|
break;
|
|
3009
|
-
case
|
|
3022
|
+
case O.MSG_END:
|
|
3010
3023
|
switch (s) {
|
|
3011
3024
|
case C.NL:
|
|
3012
|
-
this.drop = 0, this.as = t + 1, this.state =
|
|
3025
|
+
this.drop = 0, this.as = t + 1, this.state = O.OP_START;
|
|
3013
3026
|
break;
|
|
3014
3027
|
default:
|
|
3015
3028
|
continue;
|
|
3016
3029
|
}
|
|
3017
3030
|
break;
|
|
3018
|
-
case
|
|
3031
|
+
case O.OP_PLUS:
|
|
3019
3032
|
switch (s) {
|
|
3020
3033
|
case C.O:
|
|
3021
3034
|
case C.o:
|
|
3022
|
-
this.state =
|
|
3035
|
+
this.state = O.OP_PLUS_O;
|
|
3023
3036
|
break;
|
|
3024
3037
|
default:
|
|
3025
3038
|
throw this.fail(e.subarray(t));
|
|
3026
3039
|
}
|
|
3027
3040
|
break;
|
|
3028
|
-
case
|
|
3041
|
+
case O.OP_PLUS_O:
|
|
3029
3042
|
switch (s) {
|
|
3030
3043
|
case C.K:
|
|
3031
3044
|
case C.k:
|
|
3032
|
-
this.state =
|
|
3045
|
+
this.state = O.OP_PLUS_OK;
|
|
3033
3046
|
break;
|
|
3034
3047
|
default:
|
|
3035
3048
|
throw this.fail(e.subarray(t));
|
|
3036
3049
|
}
|
|
3037
3050
|
break;
|
|
3038
|
-
case
|
|
3051
|
+
case O.OP_PLUS_OK:
|
|
3039
3052
|
switch (s) {
|
|
3040
3053
|
case C.NL:
|
|
3041
3054
|
this.dispatcher.push({
|
|
3042
3055
|
kind: me.OK
|
|
3043
|
-
}), this.drop = 0, this.state =
|
|
3056
|
+
}), this.drop = 0, this.state = O.OP_START;
|
|
3044
3057
|
break;
|
|
3045
3058
|
}
|
|
3046
3059
|
break;
|
|
3047
|
-
case
|
|
3060
|
+
case O.OP_MINUS:
|
|
3048
3061
|
switch (s) {
|
|
3049
3062
|
case C.E:
|
|
3050
3063
|
case C.e:
|
|
3051
|
-
this.state =
|
|
3064
|
+
this.state = O.OP_MINUS_E;
|
|
3052
3065
|
break;
|
|
3053
3066
|
default:
|
|
3054
3067
|
throw this.fail(e.subarray(t));
|
|
3055
3068
|
}
|
|
3056
3069
|
break;
|
|
3057
|
-
case
|
|
3070
|
+
case O.OP_MINUS_E:
|
|
3058
3071
|
switch (s) {
|
|
3059
3072
|
case C.R:
|
|
3060
3073
|
case C.r:
|
|
3061
|
-
this.state =
|
|
3074
|
+
this.state = O.OP_MINUS_ER;
|
|
3062
3075
|
break;
|
|
3063
3076
|
default:
|
|
3064
3077
|
throw this.fail(e.subarray(t));
|
|
3065
3078
|
}
|
|
3066
3079
|
break;
|
|
3067
|
-
case
|
|
3080
|
+
case O.OP_MINUS_ER:
|
|
3068
3081
|
switch (s) {
|
|
3069
3082
|
case C.R:
|
|
3070
3083
|
case C.r:
|
|
3071
|
-
this.state =
|
|
3084
|
+
this.state = O.OP_MINUS_ERR;
|
|
3072
3085
|
break;
|
|
3073
3086
|
default:
|
|
3074
3087
|
throw this.fail(e.subarray(t));
|
|
3075
3088
|
}
|
|
3076
3089
|
break;
|
|
3077
|
-
case
|
|
3090
|
+
case O.OP_MINUS_ERR:
|
|
3078
3091
|
switch (s) {
|
|
3079
3092
|
case C.SPACE:
|
|
3080
3093
|
case C.TAB:
|
|
3081
|
-
this.state =
|
|
3094
|
+
this.state = O.OP_MINUS_ERR_SPC;
|
|
3082
3095
|
break;
|
|
3083
3096
|
default:
|
|
3084
3097
|
throw this.fail(e.subarray(t));
|
|
3085
3098
|
}
|
|
3086
3099
|
break;
|
|
3087
|
-
case
|
|
3100
|
+
case O.OP_MINUS_ERR_SPC:
|
|
3088
3101
|
switch (s) {
|
|
3089
3102
|
case C.SPACE:
|
|
3090
3103
|
case C.TAB:
|
|
3091
3104
|
continue;
|
|
3092
3105
|
default:
|
|
3093
|
-
this.state =
|
|
3106
|
+
this.state = O.MINUS_ERR_ARG, this.as = t;
|
|
3094
3107
|
}
|
|
3095
3108
|
break;
|
|
3096
|
-
case
|
|
3109
|
+
case O.MINUS_ERR_ARG:
|
|
3097
3110
|
switch (s) {
|
|
3098
3111
|
case C.CR:
|
|
3099
3112
|
this.drop = 1;
|
|
@@ -3103,135 +3116,135 @@ class Ur {
|
|
|
3103
3116
|
this.argBuf ? (i = this.argBuf.bytes(), this.argBuf = void 0) : i = e.subarray(this.as, t - this.drop), this.dispatcher.push({
|
|
3104
3117
|
kind: me.ERR,
|
|
3105
3118
|
data: i
|
|
3106
|
-
}), this.drop = 0, this.as = t + 1, this.state =
|
|
3119
|
+
}), this.drop = 0, this.as = t + 1, this.state = O.OP_START;
|
|
3107
3120
|
break;
|
|
3108
3121
|
}
|
|
3109
3122
|
default:
|
|
3110
3123
|
this.argBuf && this.argBuf.write(Uint8Array.of(s));
|
|
3111
3124
|
}
|
|
3112
3125
|
break;
|
|
3113
|
-
case
|
|
3126
|
+
case O.OP_P:
|
|
3114
3127
|
switch (s) {
|
|
3115
3128
|
case C.I:
|
|
3116
3129
|
case C.i:
|
|
3117
|
-
this.state =
|
|
3130
|
+
this.state = O.OP_PI;
|
|
3118
3131
|
break;
|
|
3119
3132
|
case C.O:
|
|
3120
3133
|
case C.o:
|
|
3121
|
-
this.state =
|
|
3134
|
+
this.state = O.OP_PO;
|
|
3122
3135
|
break;
|
|
3123
3136
|
default:
|
|
3124
3137
|
throw this.fail(e.subarray(t));
|
|
3125
3138
|
}
|
|
3126
3139
|
break;
|
|
3127
|
-
case
|
|
3140
|
+
case O.OP_PO:
|
|
3128
3141
|
switch (s) {
|
|
3129
3142
|
case C.N:
|
|
3130
3143
|
case C.n:
|
|
3131
|
-
this.state =
|
|
3144
|
+
this.state = O.OP_PON;
|
|
3132
3145
|
break;
|
|
3133
3146
|
default:
|
|
3134
3147
|
throw this.fail(e.subarray(t));
|
|
3135
3148
|
}
|
|
3136
3149
|
break;
|
|
3137
|
-
case
|
|
3150
|
+
case O.OP_PON:
|
|
3138
3151
|
switch (s) {
|
|
3139
3152
|
case C.G:
|
|
3140
3153
|
case C.g:
|
|
3141
|
-
this.state =
|
|
3154
|
+
this.state = O.OP_PONG;
|
|
3142
3155
|
break;
|
|
3143
3156
|
default:
|
|
3144
3157
|
throw this.fail(e.subarray(t));
|
|
3145
3158
|
}
|
|
3146
3159
|
break;
|
|
3147
|
-
case
|
|
3160
|
+
case O.OP_PONG:
|
|
3148
3161
|
switch (s) {
|
|
3149
3162
|
case C.NL:
|
|
3150
3163
|
this.dispatcher.push({
|
|
3151
3164
|
kind: me.PONG
|
|
3152
|
-
}), this.drop = 0, this.state =
|
|
3165
|
+
}), this.drop = 0, this.state = O.OP_START;
|
|
3153
3166
|
break;
|
|
3154
3167
|
}
|
|
3155
3168
|
break;
|
|
3156
|
-
case
|
|
3169
|
+
case O.OP_PI:
|
|
3157
3170
|
switch (s) {
|
|
3158
3171
|
case C.N:
|
|
3159
3172
|
case C.n:
|
|
3160
|
-
this.state =
|
|
3173
|
+
this.state = O.OP_PIN;
|
|
3161
3174
|
break;
|
|
3162
3175
|
default:
|
|
3163
3176
|
throw this.fail(e.subarray(t));
|
|
3164
3177
|
}
|
|
3165
3178
|
break;
|
|
3166
|
-
case
|
|
3179
|
+
case O.OP_PIN:
|
|
3167
3180
|
switch (s) {
|
|
3168
3181
|
case C.G:
|
|
3169
3182
|
case C.g:
|
|
3170
|
-
this.state =
|
|
3183
|
+
this.state = O.OP_PING;
|
|
3171
3184
|
break;
|
|
3172
3185
|
default:
|
|
3173
3186
|
throw this.fail(e.subarray(t));
|
|
3174
3187
|
}
|
|
3175
3188
|
break;
|
|
3176
|
-
case
|
|
3189
|
+
case O.OP_PING:
|
|
3177
3190
|
switch (s) {
|
|
3178
3191
|
case C.NL:
|
|
3179
3192
|
this.dispatcher.push({
|
|
3180
3193
|
kind: me.PING
|
|
3181
|
-
}), this.drop = 0, this.state =
|
|
3194
|
+
}), this.drop = 0, this.state = O.OP_START;
|
|
3182
3195
|
break;
|
|
3183
3196
|
}
|
|
3184
3197
|
break;
|
|
3185
|
-
case
|
|
3198
|
+
case O.OP_I:
|
|
3186
3199
|
switch (s) {
|
|
3187
3200
|
case C.N:
|
|
3188
3201
|
case C.n:
|
|
3189
|
-
this.state =
|
|
3202
|
+
this.state = O.OP_IN;
|
|
3190
3203
|
break;
|
|
3191
3204
|
default:
|
|
3192
3205
|
throw this.fail(e.subarray(t));
|
|
3193
3206
|
}
|
|
3194
3207
|
break;
|
|
3195
|
-
case
|
|
3208
|
+
case O.OP_IN:
|
|
3196
3209
|
switch (s) {
|
|
3197
3210
|
case C.F:
|
|
3198
3211
|
case C.f:
|
|
3199
|
-
this.state =
|
|
3212
|
+
this.state = O.OP_INF;
|
|
3200
3213
|
break;
|
|
3201
3214
|
default:
|
|
3202
3215
|
throw this.fail(e.subarray(t));
|
|
3203
3216
|
}
|
|
3204
3217
|
break;
|
|
3205
|
-
case
|
|
3218
|
+
case O.OP_INF:
|
|
3206
3219
|
switch (s) {
|
|
3207
3220
|
case C.O:
|
|
3208
3221
|
case C.o:
|
|
3209
|
-
this.state =
|
|
3222
|
+
this.state = O.OP_INFO;
|
|
3210
3223
|
break;
|
|
3211
3224
|
default:
|
|
3212
3225
|
throw this.fail(e.subarray(t));
|
|
3213
3226
|
}
|
|
3214
3227
|
break;
|
|
3215
|
-
case
|
|
3228
|
+
case O.OP_INFO:
|
|
3216
3229
|
switch (s) {
|
|
3217
3230
|
case C.SPACE:
|
|
3218
3231
|
case C.TAB:
|
|
3219
|
-
this.state =
|
|
3232
|
+
this.state = O.OP_INFO_SPC;
|
|
3220
3233
|
break;
|
|
3221
3234
|
default:
|
|
3222
3235
|
throw this.fail(e.subarray(t));
|
|
3223
3236
|
}
|
|
3224
3237
|
break;
|
|
3225
|
-
case
|
|
3238
|
+
case O.OP_INFO_SPC:
|
|
3226
3239
|
switch (s) {
|
|
3227
3240
|
case C.SPACE:
|
|
3228
3241
|
case C.TAB:
|
|
3229
3242
|
continue;
|
|
3230
3243
|
default:
|
|
3231
|
-
this.state =
|
|
3244
|
+
this.state = O.INFO_ARG, this.as = t;
|
|
3232
3245
|
}
|
|
3233
3246
|
break;
|
|
3234
|
-
case
|
|
3247
|
+
case O.INFO_ARG:
|
|
3235
3248
|
switch (s) {
|
|
3236
3249
|
case C.CR:
|
|
3237
3250
|
this.drop = 1;
|
|
@@ -3241,7 +3254,7 @@ class Ur {
|
|
|
3241
3254
|
this.argBuf ? (i = this.argBuf.bytes(), this.argBuf = void 0) : i = e.subarray(this.as, t - this.drop), this.dispatcher.push({
|
|
3242
3255
|
kind: me.INFO,
|
|
3243
3256
|
data: i
|
|
3244
|
-
}), this.drop = 0, this.as = t + 1, this.state =
|
|
3257
|
+
}), this.drop = 0, this.as = t + 1, this.state = O.OP_START;
|
|
3245
3258
|
break;
|
|
3246
3259
|
}
|
|
3247
3260
|
default:
|
|
@@ -3252,7 +3265,7 @@ class Ur {
|
|
|
3252
3265
|
throw this.fail(e.subarray(t));
|
|
3253
3266
|
}
|
|
3254
3267
|
}
|
|
3255
|
-
(this.state ===
|
|
3268
|
+
(this.state === O.MSG_ARG || this.state === O.MINUS_ERR_ARG || this.state === O.INFO_ARG) && !this.argBuf && (this.argBuf = new js(e.subarray(this.as, t - this.drop))), this.state === O.MSG_PAYLOAD && !this.msgBuf && (this.argBuf || this.cloneMsgArg(), this.msgBuf = new js(e.subarray(this.as)));
|
|
3256
3269
|
}
|
|
3257
3270
|
cloneMsgArg() {
|
|
3258
3271
|
const e = this.ma.subject.length, t = this.ma.reply ? this.ma.reply.length : 0, s = new Uint8Array(e + t);
|
|
@@ -3335,10 +3348,10 @@ class Ur {
|
|
|
3335
3348
|
return t;
|
|
3336
3349
|
}
|
|
3337
3350
|
}
|
|
3338
|
-
var
|
|
3351
|
+
var O;
|
|
3339
3352
|
(function(r) {
|
|
3340
3353
|
r[r.OP_START = 0] = "OP_START", r[r.OP_PLUS = 1] = "OP_PLUS", r[r.OP_PLUS_O = 2] = "OP_PLUS_O", r[r.OP_PLUS_OK = 3] = "OP_PLUS_OK", r[r.OP_MINUS = 4] = "OP_MINUS", r[r.OP_MINUS_E = 5] = "OP_MINUS_E", r[r.OP_MINUS_ER = 6] = "OP_MINUS_ER", r[r.OP_MINUS_ERR = 7] = "OP_MINUS_ERR", r[r.OP_MINUS_ERR_SPC = 8] = "OP_MINUS_ERR_SPC", r[r.MINUS_ERR_ARG = 9] = "MINUS_ERR_ARG", r[r.OP_M = 10] = "OP_M", r[r.OP_MS = 11] = "OP_MS", r[r.OP_MSG = 12] = "OP_MSG", r[r.OP_MSG_SPC = 13] = "OP_MSG_SPC", r[r.MSG_ARG = 14] = "MSG_ARG", r[r.MSG_PAYLOAD = 15] = "MSG_PAYLOAD", r[r.MSG_END = 16] = "MSG_END", r[r.OP_H = 17] = "OP_H", r[r.OP_P = 18] = "OP_P", r[r.OP_PI = 19] = "OP_PI", r[r.OP_PIN = 20] = "OP_PIN", r[r.OP_PING = 21] = "OP_PING", r[r.OP_PO = 22] = "OP_PO", r[r.OP_PON = 23] = "OP_PON", r[r.OP_PONG = 24] = "OP_PONG", r[r.OP_I = 25] = "OP_I", r[r.OP_IN = 26] = "OP_IN", r[r.OP_INF = 27] = "OP_INF", r[r.OP_INFO = 28] = "OP_INFO", r[r.OP_INFO_SPC = 29] = "OP_INFO_SPC", r[r.INFO_ARG = 30] = "INFO_ARG";
|
|
3341
|
-
})(
|
|
3354
|
+
})(O || (O = {}));
|
|
3342
3355
|
var C;
|
|
3343
3356
|
(function(r) {
|
|
3344
3357
|
r[r.CR = 13] = "CR", r[r.E = 69] = "E", r[r.e = 101] = "e", r[r.F = 70] = "F", r[r.f = 102] = "f", r[r.G = 71] = "G", r[r.g = 103] = "g", r[r.H = 72] = "H", r[r.h = 104] = "h", r[r.I = 73] = "I", r[r.i = 105] = "i", r[r.K = 75] = "K", r[r.k = 107] = "k", r[r.M = 77] = "M", r[r.m = 109] = "m", r[r.MINUS = 45] = "MINUS", r[r.N = 78] = "N", r[r.n = 110] = "n", r[r.NL = 10] = "NL", r[r.O = 79] = "O", r[r.o = 111] = "o", r[r.P = 80] = "P", r[r.p = 112] = "p", r[r.PLUS = 43] = "PLUS", r[r.R = 82] = "R", r[r.r = 114] = "r", r[r.S = 83] = "S", r[r.s = 115] = "s", r[r.SPACE = 32] = "SPACE", r[r.TAB = 9] = "TAB";
|
|
@@ -3745,10 +3758,10 @@ var C;
|
|
|
3745
3758
|
function Pi(c) {
|
|
3746
3759
|
return qt(Te(c, 14), Te(c, 18), Te(c, 41));
|
|
3747
3760
|
}
|
|
3748
|
-
function
|
|
3761
|
+
function ki(c) {
|
|
3749
3762
|
return qt(Te(c, 1), Te(c, 8), lr(c, 7));
|
|
3750
3763
|
}
|
|
3751
|
-
function
|
|
3764
|
+
function Oi(c) {
|
|
3752
3765
|
return qt(Te(c, 19), Te(c, 61), lr(c, 6));
|
|
3753
3766
|
}
|
|
3754
3767
|
var Ci = [
|
|
@@ -3843,7 +3856,7 @@ var C;
|
|
|
3843
3856
|
for (E = mt(b[7], Pi(b[4]), vi(b[4], b[5], b[6]), Ci[_], v[_ % 16]), m[7] = mt(E, Ai(b[0]), Ei(b[0], b[1], b[2])), m[3] = mt(m[3], E), S = 0; S < 8; S++) b[(S + 1) % 8] = m[S];
|
|
3844
3857
|
if (_ % 16 === 15)
|
|
3845
3858
|
for (S = 0; S < 16; S++)
|
|
3846
|
-
v[S] = mt(v[S], v[(S + 9) % 16],
|
|
3859
|
+
v[S] = mt(v[S], v[(S + 9) % 16], ki(v[(S + 1) % 16]), Oi(v[(S + 14) % 16]));
|
|
3847
3860
|
}
|
|
3848
3861
|
for (_ = 0; _ < 8; _++)
|
|
3849
3862
|
b[_] = mt(b[_], d[_]), d[_] = b[_];
|
|
@@ -4872,7 +4885,7 @@ function go(r) {
|
|
|
4872
4885
|
}, r.servers = r.servers || [], typeof r.servers == "string" && (r.servers = [
|
|
4873
4886
|
r.servers
|
|
4874
4887
|
]), r.servers.length > 0 && r.port)
|
|
4875
|
-
throw new T("port and servers options are mutually exclusive",
|
|
4888
|
+
throw new T("port and servers options are mutually exclusive", k.InvalidOption);
|
|
4876
4889
|
r.servers.length === 0 && r.port && (r.servers = [
|
|
4877
4890
|
`${Ms}:${r.port}`
|
|
4878
4891
|
]), r.servers && r.servers.length === 0 && (r.servers = [
|
|
@@ -4884,7 +4897,7 @@ function go(r) {
|
|
|
4884
4897
|
"authenticator"
|
|
4885
4898
|
].forEach((s) => {
|
|
4886
4899
|
if (t[s] && typeof t[s] != "function")
|
|
4887
|
-
throw new T(`${s} option should be a function`,
|
|
4900
|
+
throw new T(`${s} option should be a function`, k.NotFunction);
|
|
4888
4901
|
}), t.reconnectDelayHandler || (t.reconnectDelayHandler = () => {
|
|
4889
4902
|
let s = t.tls ? t.reconnectJitterTLS : t.reconnectJitter;
|
|
4890
4903
|
return s && (s++, s = Math.floor(Math.random() * s)), t.reconnectTimeWait + s;
|
|
@@ -4892,19 +4905,19 @@ function go(r) {
|
|
|
4892
4905
|
try {
|
|
4893
4906
|
qe(t.inboxPrefix);
|
|
4894
4907
|
} catch (s) {
|
|
4895
|
-
throw new T(s.message,
|
|
4908
|
+
throw new T(s.message, k.ApiError);
|
|
4896
4909
|
}
|
|
4897
4910
|
if (t.resolve === void 0 && (t.resolve = typeof Hs() == "function"), t.resolve && typeof Hs() != "function")
|
|
4898
|
-
throw new T("'resolve' is not supported on this client",
|
|
4911
|
+
throw new T("'resolve' is not supported on this client", k.InvalidOption);
|
|
4899
4912
|
return t;
|
|
4900
4913
|
}
|
|
4901
4914
|
function _o(r, e) {
|
|
4902
4915
|
const { proto: t, tls_required: s, tls_available: i } = r;
|
|
4903
4916
|
if ((t === void 0 || t < 1) && e.noEcho)
|
|
4904
|
-
throw new T("noEcho",
|
|
4917
|
+
throw new T("noEcho", k.ServerOptionNotAvailable);
|
|
4905
4918
|
const n = s || i || !1;
|
|
4906
4919
|
if (e.tls && !n)
|
|
4907
|
-
throw new T("tls",
|
|
4920
|
+
throw new T("tls", k.ServerOptionNotAvailable);
|
|
4908
4921
|
}
|
|
4909
4922
|
const yo = 1024 * 32, wo = /^INFO\s+([^\r\n]+)\r\n/i, xo = Pt(`PONG\r
|
|
4910
4923
|
`), qr = Pt(`PING\r
|
|
@@ -4996,7 +5009,7 @@ class li extends he {
|
|
|
4996
5009
|
this.timer && (this.timer.cancel(), this.timer = void 0);
|
|
4997
5010
|
}
|
|
4998
5011
|
drain() {
|
|
4999
|
-
return this.protocol.isClosed() ? Promise.reject(T.errorForCode(
|
|
5012
|
+
return this.protocol.isClosed() ? Promise.reject(T.errorForCode(k.ConnectionClosed)) : this.isClosed() ? Promise.reject(T.errorForCode(k.SubClosed)) : (this.drained || (this.draining = !0, this.protocol.unsub(this), this.drained = this.protocol.flush(Y()).then(() => {
|
|
5000
5013
|
this.protocol.subscriptions.cancel(this);
|
|
5001
5014
|
}).catch(() => {
|
|
5002
5015
|
this.protocol.subscriptions.cancel(this);
|
|
@@ -5112,7 +5125,7 @@ class os {
|
|
|
5112
5125
|
this.outbound.reset();
|
|
5113
5126
|
const e = this.pongs;
|
|
5114
5127
|
this.pongs = [];
|
|
5115
|
-
const t = T.errorForCode(
|
|
5128
|
+
const t = T.errorForCode(k.Disconnect);
|
|
5116
5129
|
t.stack = "", e.forEach((s) => {
|
|
5117
5130
|
s.reject(t);
|
|
5118
5131
|
}), this.parser = new Ur(this), this.infoReceived = !1;
|
|
@@ -5132,7 +5145,7 @@ class os {
|
|
|
5132
5145
|
return e.catch(() => {
|
|
5133
5146
|
}), this.pongs.unshift(e), this.connectError = (t) => {
|
|
5134
5147
|
e.reject(t);
|
|
5135
|
-
}, this.transport =
|
|
5148
|
+
}, this.transport = On(), this.transport.closed().then(async (t) => {
|
|
5136
5149
|
if (this.connected = !1, !this.isClosed()) {
|
|
5137
5150
|
await this.disconnected(this.transport.closeError || this.lastError);
|
|
5138
5151
|
return;
|
|
@@ -5153,14 +5166,14 @@ class os {
|
|
|
5153
5166
|
}
|
|
5154
5167
|
async disconnected(e) {
|
|
5155
5168
|
this.dispatchStatus({
|
|
5156
|
-
type:
|
|
5169
|
+
type: ke.Disconnect,
|
|
5157
5170
|
data: this.servers.getCurrentServer().toString()
|
|
5158
5171
|
}), this.options.reconnect ? await this.dialLoop().then(() => {
|
|
5159
5172
|
var t;
|
|
5160
5173
|
this.dispatchStatus({
|
|
5161
|
-
type:
|
|
5174
|
+
type: ke.Reconnect,
|
|
5162
5175
|
data: this.servers.getCurrentServer().toString()
|
|
5163
|
-
}), ((t = this.lastError) == null ? void 0 : t.code) ===
|
|
5176
|
+
}), ((t = this.lastError) == null ? void 0 : t.code) === k.AuthenticationExpired && (this.lastError = void 0);
|
|
5164
5177
|
}).catch((t) => {
|
|
5165
5178
|
this._close(t);
|
|
5166
5179
|
}) : await this._close(e);
|
|
@@ -5229,7 +5242,7 @@ class os {
|
|
|
5229
5242
|
let s = t;
|
|
5230
5243
|
const i = this.selectServer();
|
|
5231
5244
|
if (!i || this.abortReconnect)
|
|
5232
|
-
throw e || (this.lastError ? this.lastError : T.errorForCode(
|
|
5245
|
+
throw e || (this.lastError ? this.lastError : T.errorForCode(k.ConnectionRefused));
|
|
5233
5246
|
const n = Date.now();
|
|
5234
5247
|
if (i.lastConnect === 0 || i.lastConnect + t <= n) {
|
|
5235
5248
|
i.lastConnect = Date.now();
|
|
@@ -5257,7 +5270,7 @@ class os {
|
|
|
5257
5270
|
static toError(e) {
|
|
5258
5271
|
const t = e ? e.toLowerCase() : "";
|
|
5259
5272
|
if (t.indexOf("permissions violation") !== -1) {
|
|
5260
|
-
const s = new T(e,
|
|
5273
|
+
const s = new T(e, k.PermissionsViolation), i = e.match(/(Publish|Subscription) to "(\S+)"/);
|
|
5261
5274
|
if (i) {
|
|
5262
5275
|
s.permissionContext = {
|
|
5263
5276
|
operation: i[1].toLowerCase(),
|
|
@@ -5268,7 +5281,7 @@ class os {
|
|
|
5268
5281
|
n && (s.permissionContext.queue = n[1]);
|
|
5269
5282
|
}
|
|
5270
5283
|
return s;
|
|
5271
|
-
} else return t.indexOf("authorization violation") !== -1 ? new T(e,
|
|
5284
|
+
} else return t.indexOf("authorization violation") !== -1 ? new T(e, k.AuthorizationViolation) : t.indexOf("user authentication expired") !== -1 ? new T(e, k.AuthenticationExpired) : t.indexOf("account authentication expired") != -1 ? new T(e, k.AccountExpired) : t.indexOf("authentication timeout") !== -1 ? new T(e, k.AuthenticationTimeout) : new T(e, k.ProtocolError);
|
|
5272
5285
|
}
|
|
5273
5286
|
processMsg(e, t) {
|
|
5274
5287
|
if (this.inMsgs++, this.inBytes += t.length, !this.subscriptions.sidCounter)
|
|
@@ -5278,7 +5291,7 @@ class os {
|
|
|
5278
5291
|
}
|
|
5279
5292
|
processError(e) {
|
|
5280
5293
|
const t = xr(e), s = os.toError(t), i = {
|
|
5281
|
-
type:
|
|
5294
|
+
type: ke.Error,
|
|
5282
5295
|
data: s.code
|
|
5283
5296
|
};
|
|
5284
5297
|
if (s.isPermissionError()) {
|
|
@@ -5325,10 +5338,10 @@ class os {
|
|
|
5325
5338
|
}
|
|
5326
5339
|
}
|
|
5327
5340
|
s && this.dispatchStatus({
|
|
5328
|
-
type:
|
|
5341
|
+
type: ke.Update,
|
|
5329
5342
|
data: s
|
|
5330
5343
|
}), (t.ldm !== void 0 ? t.ldm : !1) && this.dispatchStatus({
|
|
5331
|
-
type:
|
|
5344
|
+
type: ke.LDM,
|
|
5332
5345
|
data: this.servers.getCurrentServer().toString()
|
|
5333
5346
|
});
|
|
5334
5347
|
}
|
|
@@ -5369,17 +5382,17 @@ class os {
|
|
|
5369
5382
|
else if (typeof t == "string")
|
|
5370
5383
|
i = We.encode(t);
|
|
5371
5384
|
else
|
|
5372
|
-
throw T.errorForCode(
|
|
5385
|
+
throw T.errorForCode(k.BadPayload);
|
|
5373
5386
|
let n = i.length;
|
|
5374
5387
|
s = s || {}, s.reply = s.reply || "";
|
|
5375
5388
|
let o = ve, a = 0;
|
|
5376
5389
|
if (s.headers) {
|
|
5377
5390
|
if (this.info && !this.info.headers)
|
|
5378
|
-
throw new T("headers",
|
|
5391
|
+
throw new T("headers", k.ServerOptionNotAvailable);
|
|
5379
5392
|
o = s.headers.encode(), a = o.length, n = i.length + a;
|
|
5380
5393
|
}
|
|
5381
5394
|
if (this.info && n > this.info.max_payload)
|
|
5382
|
-
throw T.errorForCode(
|
|
5395
|
+
throw T.errorForCode(k.MaxPayloadExceeded);
|
|
5383
5396
|
this.outBytes += n, this.outMsgs++;
|
|
5384
5397
|
let f;
|
|
5385
5398
|
s.headers ? (s.reply ? f = `HPUB ${e} ${s.reply} ${a} ${n}\r
|
|
@@ -5611,7 +5624,7 @@ class Mt {
|
|
|
5611
5624
|
}
|
|
5612
5625
|
setupHandler(e, t = !1) {
|
|
5613
5626
|
const s = t ? "" : e.queue ? e.queue : this.config.queue, { name: i, subject: n, handler: o } = e, a = e;
|
|
5614
|
-
a.internal = t, t && this.internal.push(a), a.stats = new
|
|
5627
|
+
a.internal = t, t && this.internal.push(a), a.stats = new ko(i, n, s), a.queue = s;
|
|
5615
5628
|
const f = o ? (p, g) => {
|
|
5616
5629
|
if (p) {
|
|
5617
5630
|
this.close(p);
|
|
@@ -5642,7 +5655,7 @@ class Mt {
|
|
|
5642
5655
|
}
|
|
5643
5656
|
info() {
|
|
5644
5657
|
return {
|
|
5645
|
-
type:
|
|
5658
|
+
type: kt.INFO,
|
|
5646
5659
|
name: this.name,
|
|
5647
5660
|
id: this.id,
|
|
5648
5661
|
version: this.version,
|
|
@@ -5674,7 +5687,7 @@ class Mt {
|
|
|
5674
5687
|
e.push(t.stats.stats(t.qi));
|
|
5675
5688
|
}
|
|
5676
5689
|
return {
|
|
5677
|
-
type:
|
|
5690
|
+
type: kt.STATS,
|
|
5678
5691
|
name: this.name,
|
|
5679
5692
|
id: this.id,
|
|
5680
5693
|
version: this.version,
|
|
@@ -5692,7 +5705,7 @@ class Mt {
|
|
|
5692
5705
|
o.name = e, o.subject = Mt.controlSubject(t, i, n), o.handler = s, this.setupHandler(o, !0);
|
|
5693
5706
|
}
|
|
5694
5707
|
start() {
|
|
5695
|
-
const e =
|
|
5708
|
+
const e = Oe(), t = (o, a) => o ? (this.close(o), Promise.reject(o)) : this.stats().then((f) => (a == null || a.respond(e.encode(f)), Promise.resolve())), s = (o, a) => o ? (this.close(o), Promise.reject(o)) : (a == null || a.respond(e.encode(this.info())), Promise.resolve()), i = e.encode(this.ping()), n = (o, a) => o ? (this.close(o).then().catch(), Promise.reject(o)) : (a.respond(i), Promise.resolve());
|
|
5696
5709
|
return this.addInternalHandler(Je.PING, n), this.addInternalHandler(Je.STATS, t), this.addInternalHandler(Je.INFO, s), this.handlers.forEach((o) => {
|
|
5697
5710
|
const { subject: a } = o;
|
|
5698
5711
|
typeof a == "string" && o.handler !== null && this.setupHandler(o);
|
|
@@ -5718,7 +5731,7 @@ class Mt {
|
|
|
5718
5731
|
}
|
|
5719
5732
|
ping() {
|
|
5720
5733
|
return {
|
|
5721
|
-
type:
|
|
5734
|
+
type: kt.PING,
|
|
5722
5735
|
name: this.name,
|
|
5723
5736
|
id: this.id,
|
|
5724
5737
|
version: this.version,
|
|
@@ -5747,7 +5760,7 @@ class Mt {
|
|
|
5747
5760
|
return s.qi = t, this.handlers.push(s), t;
|
|
5748
5761
|
}
|
|
5749
5762
|
}
|
|
5750
|
-
class
|
|
5763
|
+
class ko {
|
|
5751
5764
|
constructor(e, t, s = "") {
|
|
5752
5765
|
h(this, "name");
|
|
5753
5766
|
h(this, "subject");
|
|
@@ -5791,7 +5804,7 @@ class Oo {
|
|
|
5791
5804
|
return (t == null ? void 0 : t.noIterator) === !1 && (this.processing_time = W(t.time), this.num_requests = t.processed, this.average_processing_time = this.processing_time > 0 && this.num_requests > 0 ? this.processing_time / this.num_requests : 0), this._stats();
|
|
5792
5805
|
}
|
|
5793
5806
|
}
|
|
5794
|
-
class
|
|
5807
|
+
class Oo {
|
|
5795
5808
|
constructor(e, t = {
|
|
5796
5809
|
strategy: Ne.JitterTimer,
|
|
5797
5810
|
maxWait: 2e3
|
|
@@ -5811,7 +5824,7 @@ class ko {
|
|
|
5811
5824
|
return this.q(Je.INFO, e, t);
|
|
5812
5825
|
}
|
|
5813
5826
|
async q(e, t = "", s = "") {
|
|
5814
|
-
const i = new he(), n =
|
|
5827
|
+
const i = new he(), n = Oe(), o = Mt.controlSubject(e, t, s, this.prefix), a = await this.nc.requestMany(o, ve, this.opts);
|
|
5815
5828
|
return (async () => {
|
|
5816
5829
|
for await (const f of a)
|
|
5817
5830
|
try {
|
|
@@ -6102,7 +6115,7 @@ class Rt {
|
|
|
6102
6115
|
const o = this.smToEntry(n);
|
|
6103
6116
|
return o.key !== s ? null : o;
|
|
6104
6117
|
} catch (o) {
|
|
6105
|
-
if (o.code ===
|
|
6118
|
+
if (o.code === k.JetStream404NoMessages)
|
|
6106
6119
|
return null;
|
|
6107
6120
|
throw o;
|
|
6108
6121
|
}
|
|
@@ -6540,10 +6553,10 @@ class Ns extends he {
|
|
|
6540
6553
|
this.statusIterator = f;
|
|
6541
6554
|
for await (const g of f)
|
|
6542
6555
|
switch (g.type) {
|
|
6543
|
-
case
|
|
6556
|
+
case ke.Disconnect:
|
|
6544
6557
|
(p = this.monitor) == null || p.cancel();
|
|
6545
6558
|
break;
|
|
6546
|
-
case
|
|
6559
|
+
case ke.Reconnect:
|
|
6547
6560
|
this.resetPending().then((y) => {
|
|
6548
6561
|
var x;
|
|
6549
6562
|
y && ((x = this.monitor) == null || x.restart());
|
|
@@ -7248,7 +7261,7 @@ class Ws {
|
|
|
7248
7261
|
return this.header.last(nt.Stream);
|
|
7249
7262
|
}
|
|
7250
7263
|
json(e) {
|
|
7251
|
-
return
|
|
7264
|
+
return Oe(e).decode(this.data);
|
|
7252
7265
|
}
|
|
7253
7266
|
string() {
|
|
7254
7267
|
return xe.decode(this.data);
|
|
@@ -7325,7 +7338,7 @@ class pi {
|
|
|
7325
7338
|
return i;
|
|
7326
7339
|
}
|
|
7327
7340
|
json(e) {
|
|
7328
|
-
return
|
|
7341
|
+
return Oe(e).decode(this.data);
|
|
7329
7342
|
}
|
|
7330
7343
|
string() {
|
|
7331
7344
|
return xe.decode(this.data);
|
|
@@ -7451,7 +7464,7 @@ class Ct {
|
|
|
7451
7464
|
try {
|
|
7452
7465
|
const n = await this.jsm.streams.getMessage(this.stream, {
|
|
7453
7466
|
last_by_subj: i
|
|
7454
|
-
}), a =
|
|
7467
|
+
}), a = Oe().decode(n.data);
|
|
7455
7468
|
return a.revision = n.seq, a;
|
|
7456
7469
|
} catch (n) {
|
|
7457
7470
|
return n.code === "404" ? null : Promise.reject(n);
|
|
@@ -7513,7 +7526,7 @@ class Ct {
|
|
|
7513
7526
|
J.digest = `${Dr}${P}`, J.deleted = !1;
|
|
7514
7527
|
const U = Fe();
|
|
7515
7528
|
typeof o == "number" && U.set(Ue.ExpectedLastSubjectSequenceHdr, `${o}`), U.set(ge.RollupHdr, ge.RollupValueSubject);
|
|
7516
|
-
const q = await this.js.publish(N,
|
|
7529
|
+
const q = await this.js.publish(N, Oe().encode(J), {
|
|
7517
7530
|
headers: U,
|
|
7518
7531
|
timeout: n
|
|
7519
7532
|
});
|
|
@@ -7666,7 +7679,7 @@ class Ct {
|
|
|
7666
7679
|
success: !1
|
|
7667
7680
|
});
|
|
7668
7681
|
t.deleted = !0, t.size = 0, t.chunks = 0, t.digest = "";
|
|
7669
|
-
const s =
|
|
7682
|
+
const s = Oe(), i = Fe();
|
|
7670
7683
|
return i.set(ge.RollupHdr, ge.RollupValueSubject), await this.js.publish(this._metaSubject(t.name), s.encode(t), {
|
|
7671
7684
|
headers: i
|
|
7672
7685
|
}), this.jsm.streams.purge(this.stream, {
|
|
@@ -7705,7 +7718,7 @@ class Ct {
|
|
|
7705
7718
|
} catch (f) {
|
|
7706
7719
|
f.code === "404" ? (s.push(null), t = !0) : s.stop(f);
|
|
7707
7720
|
}
|
|
7708
|
-
const n =
|
|
7721
|
+
const n = Oe(), o = ze();
|
|
7709
7722
|
o.orderedConsumer(), e.includeHistory ? o.deliverLastPerSubject() : (t = !0, o.deliverNew()), o.callback((f, p) => {
|
|
7710
7723
|
var g;
|
|
7711
7724
|
if (f) {
|
|
@@ -7821,7 +7834,7 @@ class rr extends Tt {
|
|
|
7821
7834
|
}
|
|
7822
7835
|
const y = this.parseJsResponse(g);
|
|
7823
7836
|
if (y.stream === "")
|
|
7824
|
-
throw T.errorForCode(
|
|
7837
|
+
throw T.errorForCode(k.JetStreamInvalidAck);
|
|
7825
7838
|
return y.duplicate = y.duplicate ? y.duplicate : !1, y;
|
|
7826
7839
|
}
|
|
7827
7840
|
async pull(t, s, i = 0) {
|
|
@@ -7881,7 +7894,7 @@ class rr extends Tt {
|
|
|
7881
7894
|
})), (async () => {
|
|
7882
7895
|
try {
|
|
7883
7896
|
x && (p = new er(x, (L) => (A.push(() => {
|
|
7884
|
-
A.err = new T(`${Pe.IdleHeartbeatMissed}: ${L}`,
|
|
7897
|
+
A.err = new T(`${Pe.IdleHeartbeatMissed}: ${L}`, k.JetStreamIdleHeartBeat);
|
|
7885
7898
|
}), !0)));
|
|
7886
7899
|
} catch {
|
|
7887
7900
|
}
|
|
@@ -7932,15 +7945,15 @@ class rr extends Tt {
|
|
|
7932
7945
|
stream_seq: 0,
|
|
7933
7946
|
delivery_seq: 0
|
|
7934
7947
|
}, i.config.ack_policy !== ce.NotSet && i.config.ack_policy !== ce.None)
|
|
7935
|
-
throw new T("ordered consumer: ack_policy can only be set to 'none'",
|
|
7948
|
+
throw new T("ordered consumer: ack_policy can only be set to 'none'", k.ApiError);
|
|
7936
7949
|
if (i.config.durable_name && i.config.durable_name.length > 0)
|
|
7937
|
-
throw new T("ordered consumer: durable_name cannot be set",
|
|
7950
|
+
throw new T("ordered consumer: durable_name cannot be set", k.ApiError);
|
|
7938
7951
|
if (i.config.deliver_subject && i.config.deliver_subject.length > 0)
|
|
7939
|
-
throw new T("ordered consumer: deliver_subject cannot be set",
|
|
7952
|
+
throw new T("ordered consumer: deliver_subject cannot be set", k.ApiError);
|
|
7940
7953
|
if (i.config.max_deliver !== void 0 && i.config.max_deliver > 1)
|
|
7941
|
-
throw new T("ordered consumer: max_deliver cannot be set",
|
|
7954
|
+
throw new T("ordered consumer: max_deliver cannot be set", k.ApiError);
|
|
7942
7955
|
if (i.config.deliver_group && i.config.deliver_group.length > 0)
|
|
7943
|
-
throw new T("ordered consumer: deliver_group cannot be set",
|
|
7956
|
+
throw new T("ordered consumer: deliver_group cannot be set", k.ApiError);
|
|
7944
7957
|
i.config.deliver_subject = qe(this.nc.options.inboxPrefix), i.config.ack_policy = ce.None, i.config.max_deliver = 1, i.config.flow_control = !0, i.config.idle_heartbeat = i.config.idle_heartbeat || W(5e3), i.config.ack_wait = W(22 * 60 * 60 * 1e3), i.config.mem_storage = !0, i.config.num_replicas = 1;
|
|
7945
7958
|
}
|
|
7946
7959
|
if (i.config.ack_policy === ce.NotSet && (i.config.ack_policy = ce.All), i.api = this, i.config = i.config || {}, i.stream = i.stream ? i.stream : await this.findStream(t), i.attached = !1, i.config.durable_name)
|
|
@@ -8045,11 +8058,11 @@ class ir {
|
|
|
8045
8058
|
}
|
|
8046
8059
|
_check(e, t, s) {
|
|
8047
8060
|
if (this.isClosed())
|
|
8048
|
-
throw T.errorForCode(
|
|
8061
|
+
throw T.errorForCode(k.ConnectionClosed);
|
|
8049
8062
|
if (t && this.isDraining() || s && this.protocol.noMorePublishing)
|
|
8050
|
-
throw T.errorForCode(
|
|
8063
|
+
throw T.errorForCode(k.ConnectionDraining);
|
|
8051
8064
|
if (e = e || "", e.length === 0)
|
|
8052
|
-
throw T.errorForCode(
|
|
8065
|
+
throw T.errorForCode(k.BadSubject);
|
|
8053
8066
|
}
|
|
8054
8067
|
publish(e, t, s) {
|
|
8055
8068
|
this._check(e, !1, !0), this.protocol.publish(e, t, s);
|
|
@@ -8087,7 +8100,7 @@ class ir {
|
|
|
8087
8100
|
return Promise.reject(f);
|
|
8088
8101
|
}
|
|
8089
8102
|
if (s.strategy = s.strategy || Ne.Timer, s.maxWait = s.maxWait || 1e3, s.maxWait < 1)
|
|
8090
|
-
return Promise.reject(new T("timeout",
|
|
8103
|
+
return Promise.reject(new T("timeout", k.InvalidOption));
|
|
8091
8104
|
const n = new he();
|
|
8092
8105
|
function o(f) {
|
|
8093
8106
|
n.push(() => {
|
|
@@ -8103,7 +8116,7 @@ class ir {
|
|
|
8103
8116
|
const g = this.subscribe(qe(this.options.inboxPrefix), {
|
|
8104
8117
|
callback: (I, N) => {
|
|
8105
8118
|
var J, ee;
|
|
8106
|
-
if (((J = N == null ? void 0 : N.data) == null ? void 0 : J.length) === 0 && ((ee = N == null ? void 0 : N.headers) == null ? void 0 : ee.status) ===
|
|
8119
|
+
if (((J = N == null ? void 0 : N.data) == null ? void 0 : J.length) === 0 && ((ee = N == null ? void 0 : N.headers) == null ? void 0 : ee.status) === k.NoResponders && (I = T.errorForCode(k.NoResponders)), I) {
|
|
8107
8120
|
f && (I.stack += `
|
|
8108
8121
|
|
|
8109
8122
|
${f}`), y(I);
|
|
@@ -8177,15 +8190,15 @@ ${f}`), y(I);
|
|
|
8177
8190
|
}
|
|
8178
8191
|
const i = !this.protocol.options.noAsyncTraces;
|
|
8179
8192
|
if (s.timeout = s.timeout || 1e3, s.timeout < 1)
|
|
8180
|
-
return Promise.reject(new T("timeout",
|
|
8193
|
+
return Promise.reject(new T("timeout", k.InvalidOption));
|
|
8181
8194
|
if (!s.noMux && s.reply)
|
|
8182
|
-
return Promise.reject(new T("reply can only be used with noMux",
|
|
8195
|
+
return Promise.reject(new T("reply can only be used with noMux", k.InvalidOption));
|
|
8183
8196
|
if (s.noMux) {
|
|
8184
8197
|
const n = s.reply ? s.reply : qe(this.options.inboxPrefix), o = Y(), a = i ? new Error() : null, f = this.subscribe(n, {
|
|
8185
8198
|
max: 1,
|
|
8186
8199
|
timeout: s.timeout,
|
|
8187
8200
|
callback: (p, g) => {
|
|
8188
|
-
p ? (a && p.code !==
|
|
8201
|
+
p ? (a && p.code !== k.Timeout && (p.stack += `
|
|
8189
8202
|
|
|
8190
8203
|
${a.stack}`), f.unsubscribe(), o.reject(p)) : (p = ei(g), p ? (a && (p.stack += `
|
|
8191
8204
|
|
|
@@ -8217,10 +8230,10 @@ ${a.stack}`), o.reject(p)) : o.resolve(g));
|
|
|
8217
8230
|
}
|
|
8218
8231
|
}
|
|
8219
8232
|
flush() {
|
|
8220
|
-
return this.isClosed() ? Promise.reject(T.errorForCode(
|
|
8233
|
+
return this.isClosed() ? Promise.reject(T.errorForCode(k.ConnectionClosed)) : this.protocol.flush();
|
|
8221
8234
|
}
|
|
8222
8235
|
drain() {
|
|
8223
|
-
return this.isClosed() ? Promise.reject(T.errorForCode(
|
|
8236
|
+
return this.isClosed() ? Promise.reject(T.errorForCode(k.ConnectionClosed)) : this.isDraining() ? Promise.reject(T.errorForCode(k.ConnectionDraining)) : (this.draining = !0, this.protocol.drain());
|
|
8224
8237
|
}
|
|
8225
8238
|
isClosed() {
|
|
8226
8239
|
return this.protocol.isClosed();
|
|
@@ -8260,7 +8273,7 @@ ${a.stack}`), o.reject(p)) : o.resolve(g));
|
|
|
8260
8273
|
await t.getAccountInfo();
|
|
8261
8274
|
} catch (s) {
|
|
8262
8275
|
const i = s;
|
|
8263
|
-
throw i.code ===
|
|
8276
|
+
throw i.code === k.NoResponders && (i.code = k.JetStreamNotEnabled), i;
|
|
8264
8277
|
}
|
|
8265
8278
|
return t;
|
|
8266
8279
|
}
|
|
@@ -8273,7 +8286,7 @@ ${a.stack}`), o.reject(p)) : o.resolve(g));
|
|
|
8273
8286
|
}
|
|
8274
8287
|
async rtt() {
|
|
8275
8288
|
if (!this.protocol._closed && !this.protocol.connected)
|
|
8276
|
-
throw T.errorForCode(
|
|
8289
|
+
throw T.errorForCode(k.Disconnect);
|
|
8277
8290
|
const e = Date.now();
|
|
8278
8291
|
return await this.flush(), Date.now() - e;
|
|
8279
8292
|
}
|
|
@@ -8284,7 +8297,7 @@ ${a.stack}`), o.reject(p)) : o.resolve(g));
|
|
|
8284
8297
|
return this._services || (this._services = new Wo(this)), this._services;
|
|
8285
8298
|
}
|
|
8286
8299
|
reconnect() {
|
|
8287
|
-
return this.isClosed() ? Promise.reject(T.errorForCode(
|
|
8300
|
+
return this.isClosed() ? Promise.reject(T.errorForCode(k.ConnectionClosed)) : this.isDraining() ? Promise.reject(T.errorForCode(k.ConnectionDraining)) : this.protocol.reconnect();
|
|
8288
8301
|
}
|
|
8289
8302
|
}
|
|
8290
8303
|
class Wo {
|
|
@@ -8300,7 +8313,7 @@ class Wo {
|
|
|
8300
8313
|
}
|
|
8301
8314
|
}
|
|
8302
8315
|
client(e, t) {
|
|
8303
|
-
return new
|
|
8316
|
+
return new Oo(this.nc, e, t);
|
|
8304
8317
|
}
|
|
8305
8318
|
}
|
|
8306
8319
|
class Yo {
|
|
@@ -8405,7 +8418,7 @@ class mi extends Pn {
|
|
|
8405
8418
|
const p = f, g = this.sub.info;
|
|
8406
8419
|
g.last = p, this.info.config = p.config, this.info.name = p.name;
|
|
8407
8420
|
}).catch((f) => {
|
|
8408
|
-
const p = new T(`unable to recreate ordered consumer ${n.stream} at seq ${t}`,
|
|
8421
|
+
const p = new T(`unable to recreate ordered consumer ${n.stream} at seq ${t}`, k.RequestError, f);
|
|
8409
8422
|
this.sub.callback(p, {});
|
|
8410
8423
|
});
|
|
8411
8424
|
}
|
|
@@ -8520,10 +8533,10 @@ function ta(r) {
|
|
|
8520
8533
|
function bi(r) {
|
|
8521
8534
|
if (r !== null)
|
|
8522
8535
|
switch (r.code) {
|
|
8523
|
-
case
|
|
8524
|
-
case
|
|
8536
|
+
case k.JetStream404NoMessages:
|
|
8537
|
+
case k.JetStream408RequestTimeout:
|
|
8525
8538
|
return null;
|
|
8526
|
-
case
|
|
8539
|
+
case k.JetStream409:
|
|
8527
8540
|
return an(r) ? r : null;
|
|
8528
8541
|
default:
|
|
8529
8542
|
return r;
|
|
@@ -8625,7 +8638,7 @@ class ia {
|
|
|
8625
8638
|
}) {
|
|
8626
8639
|
const s = {};
|
|
8627
8640
|
s.batch = t.batch || 1, s.no_wait = t.no_wait || !1, t.expires && t.expires > 0 && (s.expires = W(t.expires));
|
|
8628
|
-
const i =
|
|
8641
|
+
const i = Oe().encode(s), n = dt.concat(qo, Bo, i), o = e ? {
|
|
8629
8642
|
reply: e
|
|
8630
8643
|
} : void 0;
|
|
8631
8644
|
this.msg.respond(n, o);
|
|
@@ -8662,7 +8675,7 @@ class aa {
|
|
|
8662
8675
|
async connect(e, t) {
|
|
8663
8676
|
const s = Y();
|
|
8664
8677
|
if (t.tls)
|
|
8665
|
-
return s.reject(new T("tls",
|
|
8678
|
+
return s.reject(new T("tls", k.InvalidOption)), s;
|
|
8666
8679
|
this.options = t;
|
|
8667
8680
|
const i = e.src;
|
|
8668
8681
|
if (t.wsFactory) {
|
|
@@ -8703,7 +8716,7 @@ class aa {
|
|
|
8703
8716
|
}, this.socket.onerror = (n) => {
|
|
8704
8717
|
if (this.isDiscarded())
|
|
8705
8718
|
return;
|
|
8706
|
-
const o = n, a = new T(o.message,
|
|
8719
|
+
const o = n, a = new T(o.message, k.Unknown, new Error(o.error));
|
|
8707
8720
|
s.reject(a);
|
|
8708
8721
|
}, s;
|
|
8709
8722
|
}
|
|
@@ -8798,13 +8811,13 @@ function ca(r, e) {
|
|
|
8798
8811
|
return `${n}//${a}:${o}${f}${p}`;
|
|
8799
8812
|
}
|
|
8800
8813
|
function ha(r = {}) {
|
|
8801
|
-
return
|
|
8814
|
+
return kn({
|
|
8802
8815
|
defaultPort: 443,
|
|
8803
8816
|
urlParseFn: ca,
|
|
8804
8817
|
factory: () => new aa()
|
|
8805
8818
|
}), ir.connect(r);
|
|
8806
8819
|
}
|
|
8807
|
-
const Be =
|
|
8820
|
+
const Be = Oe();
|
|
8808
8821
|
class Kr {
|
|
8809
8822
|
constructor(e) {
|
|
8810
8823
|
h(this, "onStatusChange");
|
|
@@ -8850,11 +8863,11 @@ class Kr {
|
|
|
8850
8863
|
var A, I;
|
|
8851
8864
|
for await (const N of this.nc.status())
|
|
8852
8865
|
switch (N.type !== He.PingTimer && console.log("[nats] connection status:", N.type), N.type) {
|
|
8853
|
-
case
|
|
8866
|
+
case ke.Reconnect:
|
|
8854
8867
|
(A = this.onStatusChange) == null || A.call(this, !0);
|
|
8855
8868
|
break;
|
|
8856
|
-
case
|
|
8857
|
-
case
|
|
8869
|
+
case ke.Disconnect:
|
|
8870
|
+
case ke.Error:
|
|
8858
8871
|
case He.Reconnecting:
|
|
8859
8872
|
(I = this.onStatusChange) == null || I.call(this, !1);
|
|
8860
8873
|
break;
|