@jokio/sdk 0.1.12 → 0.2.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 +7 -4
- package/dist/index.d.ts +3 -0
- package/dist/jokio.sdk.es.js +488 -459
- package/dist/jokio.sdk.umd.js +14 -14
- package/dist/nats.service.d.ts +3 -0
- package/dist/storage.service.d.ts +5 -0
- package/package.json +1 -1
package/dist/jokio.sdk.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (r, e, t) =>
|
|
1
|
+
var Si = Object.defineProperty;
|
|
2
|
+
var Ei = (r, e, t) => e in r ? Si(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var h = (r, e, t) => Ei(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
function je(r) {
|
|
5
5
|
const e = new Uint8Array(r);
|
|
6
6
|
let t = "";
|
|
@@ -14,13 +14,13 @@ function zt(r) {
|
|
|
14
14
|
o[a] = i.charCodeAt(a);
|
|
15
15
|
return n;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
17
|
+
function qs() {
|
|
18
|
+
return vi.stubThis((globalThis == null ? void 0 : globalThis.PublicKeyCredential) !== void 0 && typeof globalThis.PublicKeyCredential == "function");
|
|
19
19
|
}
|
|
20
|
-
const
|
|
20
|
+
const vi = {
|
|
21
21
|
stubThis: (r) => r
|
|
22
22
|
};
|
|
23
|
-
function
|
|
23
|
+
function $r(r) {
|
|
24
24
|
const { id: e } = r;
|
|
25
25
|
return {
|
|
26
26
|
...r,
|
|
@@ -33,7 +33,7 @@ function Ur(r) {
|
|
|
33
33
|
transports: r.transports
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function Ur(r) {
|
|
37
37
|
return (
|
|
38
38
|
// Consider localhost valid as well since it's okay wrt Secure Contexts
|
|
39
39
|
r === "localhost" || /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(r)
|
|
@@ -49,7 +49,7 @@ class he extends Error {
|
|
|
49
49
|
}), this.name = i ?? s.name, this.code = t;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function Ai({ error: r, options: e }) {
|
|
53
53
|
var s, i, n;
|
|
54
54
|
const { publicKey: t } = e;
|
|
55
55
|
if (!t)
|
|
@@ -108,7 +108,7 @@ function Ei({ error: r, options: e }) {
|
|
|
108
108
|
});
|
|
109
109
|
if (r.name === "SecurityError") {
|
|
110
110
|
const o = globalThis.location.hostname;
|
|
111
|
-
if (
|
|
111
|
+
if (Ur(o)) {
|
|
112
112
|
if (t.rp.id !== o)
|
|
113
113
|
return new he({
|
|
114
114
|
message: `The RP ID "${t.rp.id}" is invalid for this domain`,
|
|
@@ -136,7 +136,7 @@ function Ei({ error: r, options: e }) {
|
|
|
136
136
|
}
|
|
137
137
|
return r;
|
|
138
138
|
}
|
|
139
|
-
class
|
|
139
|
+
class Pi {
|
|
140
140
|
constructor() {
|
|
141
141
|
Object.defineProperty(this, "controller", {
|
|
142
142
|
enumerable: !0,
|
|
@@ -160,16 +160,16 @@ class vi {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
const
|
|
164
|
-
function
|
|
165
|
-
if (r && !(
|
|
163
|
+
const Lr = new Pi(), Oi = ["cross-platform", "platform"];
|
|
164
|
+
function qr(r) {
|
|
165
|
+
if (r && !(Oi.indexOf(r) < 0))
|
|
166
166
|
return r;
|
|
167
167
|
}
|
|
168
|
-
async function
|
|
168
|
+
async function ki(r) {
|
|
169
169
|
var I;
|
|
170
170
|
!r.optionsJSON && r.challenge && (console.warn("startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information."), r = { optionsJSON: r });
|
|
171
171
|
const { optionsJSON: e, useAutoRegister: t = !1 } = r;
|
|
172
|
-
if (!
|
|
172
|
+
if (!qs())
|
|
173
173
|
throw new Error("WebAuthn is not supported in this browser");
|
|
174
174
|
const s = {
|
|
175
175
|
...e,
|
|
@@ -178,14 +178,14 @@ async function Pi(r) {
|
|
|
178
178
|
...e.user,
|
|
179
179
|
id: zt(e.user.id)
|
|
180
180
|
},
|
|
181
|
-
excludeCredentials: (I = e.excludeCredentials) == null ? void 0 : I.map(
|
|
181
|
+
excludeCredentials: (I = e.excludeCredentials) == null ? void 0 : I.map($r)
|
|
182
182
|
}, i = {};
|
|
183
|
-
t && (i.mediation = "conditional"), i.publicKey = s, i.signal =
|
|
183
|
+
t && (i.mediation = "conditional"), i.publicKey = s, i.signal = Lr.createNewAbortSignal();
|
|
184
184
|
let n;
|
|
185
185
|
try {
|
|
186
186
|
n = await navigator.credentials.create(i);
|
|
187
187
|
} catch (T) {
|
|
188
|
-
throw
|
|
188
|
+
throw Ai({ error: T, options: i });
|
|
189
189
|
}
|
|
190
190
|
if (!n)
|
|
191
191
|
throw new Error("Registration was not completed");
|
|
@@ -227,15 +227,15 @@ async function Pi(r) {
|
|
|
227
227
|
},
|
|
228
228
|
type: p,
|
|
229
229
|
clientExtensionResults: n.getClientExtensionResults(),
|
|
230
|
-
authenticatorAttachment:
|
|
230
|
+
authenticatorAttachment: qr(n.authenticatorAttachment)
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
233
|
function ms(r, e) {
|
|
234
234
|
console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${r}. You should report this error to them.
|
|
235
235
|
`, e);
|
|
236
236
|
}
|
|
237
|
-
function
|
|
238
|
-
if (!
|
|
237
|
+
function Ci() {
|
|
238
|
+
if (!qs())
|
|
239
239
|
return bs.stubThis(new Promise((e) => e(!1)));
|
|
240
240
|
const r = globalThis.PublicKeyCredential;
|
|
241
241
|
return (r == null ? void 0 : r.isConditionalMediationAvailable) === void 0 ? bs.stubThis(new Promise((e) => e(!1))) : bs.stubThis(r.isConditionalMediationAvailable());
|
|
@@ -243,7 +243,7 @@ function Oi() {
|
|
|
243
243
|
const bs = {
|
|
244
244
|
stubThis: (r) => r
|
|
245
245
|
};
|
|
246
|
-
function
|
|
246
|
+
function Ii({ error: r, options: e }) {
|
|
247
247
|
const { publicKey: t } = e;
|
|
248
248
|
if (!t)
|
|
249
249
|
throw Error("options was missing required publicKey property");
|
|
@@ -263,7 +263,7 @@ function ki({ error: r, options: e }) {
|
|
|
263
263
|
});
|
|
264
264
|
if (r.name === "SecurityError") {
|
|
265
265
|
const s = globalThis.location.hostname;
|
|
266
|
-
if (
|
|
266
|
+
if (Ur(s)) {
|
|
267
267
|
if (t.rpId !== s)
|
|
268
268
|
return new he({
|
|
269
269
|
message: `The RP ID "${t.rpId}" is invalid for this domain`,
|
|
@@ -284,32 +284,32 @@ function ki({ error: r, options: e }) {
|
|
|
284
284
|
}
|
|
285
285
|
return r;
|
|
286
286
|
}
|
|
287
|
-
async function
|
|
287
|
+
async function ji(r) {
|
|
288
288
|
var P, I;
|
|
289
289
|
!r.optionsJSON && r.challenge && (console.warn("startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information."), r = { optionsJSON: r });
|
|
290
290
|
const { optionsJSON: e, useBrowserAutofill: t = !1, verifyBrowserAutofillInput: s = !0 } = r;
|
|
291
|
-
if (!
|
|
291
|
+
if (!qs())
|
|
292
292
|
throw new Error("WebAuthn is not supported in this browser");
|
|
293
293
|
let i;
|
|
294
|
-
((P = e.allowCredentials) == null ? void 0 : P.length) !== 0 && (i = (I = e.allowCredentials) == null ? void 0 : I.map(
|
|
294
|
+
((P = e.allowCredentials) == null ? void 0 : P.length) !== 0 && (i = (I = e.allowCredentials) == null ? void 0 : I.map($r));
|
|
295
295
|
const n = {
|
|
296
296
|
...e,
|
|
297
297
|
challenge: zt(e.challenge),
|
|
298
298
|
allowCredentials: i
|
|
299
299
|
}, o = {};
|
|
300
300
|
if (t) {
|
|
301
|
-
if (!await
|
|
301
|
+
if (!await Ci())
|
|
302
302
|
throw Error("Browser does not support WebAuthn autofill");
|
|
303
303
|
if (document.querySelectorAll("input[autocomplete$='webauthn']").length < 1 && s)
|
|
304
304
|
throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');
|
|
305
305
|
o.mediation = "conditional", n.allowCredentials = [];
|
|
306
306
|
}
|
|
307
|
-
o.publicKey = n, o.signal =
|
|
307
|
+
o.publicKey = n, o.signal = Lr.createNewAbortSignal();
|
|
308
308
|
let a;
|
|
309
309
|
try {
|
|
310
310
|
a = await navigator.credentials.get(o);
|
|
311
311
|
} catch (T) {
|
|
312
|
-
throw
|
|
312
|
+
throw Ii({ error: T, options: o });
|
|
313
313
|
}
|
|
314
314
|
if (!a)
|
|
315
315
|
throw new Error("Authentication was not completed");
|
|
@@ -326,26 +326,29 @@ async function Ci(r) {
|
|
|
326
326
|
},
|
|
327
327
|
type: y,
|
|
328
328
|
clientExtensionResults: a.getClientExtensionResults(),
|
|
329
|
-
authenticatorAttachment:
|
|
329
|
+
authenticatorAttachment: qr(a.authenticatorAttachment)
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
332
|
const dt = "LAST_AUTH_DATA";
|
|
333
|
-
class
|
|
333
|
+
class Fr {
|
|
334
334
|
constructor(e) {
|
|
335
|
-
this.
|
|
335
|
+
this.options = e;
|
|
336
|
+
}
|
|
337
|
+
get url() {
|
|
338
|
+
return this.options.authUrl;
|
|
336
339
|
}
|
|
337
340
|
async requestEmailLogin(e, t = location.href) {
|
|
338
341
|
return await fetch(
|
|
339
|
-
this.
|
|
342
|
+
this.options.authUrl + `/email-verification-request/${e}?returnUrl=${t}`,
|
|
340
343
|
{ credentials: "include" }
|
|
341
344
|
).then(pt);
|
|
342
345
|
}
|
|
343
346
|
async completeEmailLogin(e, t) {
|
|
344
347
|
const s = await fetch(
|
|
345
|
-
this.
|
|
348
|
+
this.options.authUrl + `/email-verification-complete/${e}/${t}`,
|
|
346
349
|
{ credentials: "include" }
|
|
347
350
|
).then(pt);
|
|
348
|
-
return
|
|
351
|
+
return await this.options.storage.setItem(dt, s), s;
|
|
349
352
|
}
|
|
350
353
|
async requestPasskeyLogin(e = {}) {
|
|
351
354
|
var d;
|
|
@@ -354,14 +357,14 @@ class As {
|
|
|
354
357
|
isRegistration: s = !1,
|
|
355
358
|
addAsAdditionalDevice: i = !1
|
|
356
359
|
} = e, n = await fetch(
|
|
357
|
-
this.
|
|
360
|
+
this.options.authUrl + `/webauth-challenge-request?registration=${s ? "true" : ""}&displayName=${t}`,
|
|
358
361
|
{ credentials: "include" }
|
|
359
362
|
).then(pt);
|
|
360
363
|
let o;
|
|
361
364
|
try {
|
|
362
|
-
(d = n.user) != null && d.id ? o = await
|
|
365
|
+
(d = n.user) != null && d.id ? o = await ki({
|
|
363
366
|
optionsJSON: n
|
|
364
|
-
}) : o = await
|
|
367
|
+
}) : o = await ji({
|
|
365
368
|
optionsJSON: n
|
|
366
369
|
});
|
|
367
370
|
} catch (p) {
|
|
@@ -370,7 +373,7 @@ class As {
|
|
|
370
373
|
) : alert(p.message), p;
|
|
371
374
|
}
|
|
372
375
|
const a = await fetch(
|
|
373
|
-
this.
|
|
376
|
+
this.options.authUrl + `/webauth-challenge-complete?displayName=${t}&addAsAdditionalDevice=${i ? "true" : ""}`,
|
|
374
377
|
{
|
|
375
378
|
method: "POST",
|
|
376
379
|
body: JSON.stringify(o),
|
|
@@ -380,26 +383,21 @@ class As {
|
|
|
380
383
|
credentials: "include"
|
|
381
384
|
}
|
|
382
385
|
).then(pt);
|
|
383
|
-
return
|
|
386
|
+
return await this.options.storage.setItem(dt, a), a;
|
|
384
387
|
}
|
|
385
388
|
async guestLogin() {
|
|
386
|
-
const e = await fetch(this.
|
|
389
|
+
const e = await fetch(this.options.authUrl + "/sign-out", {
|
|
387
390
|
credentials: "include"
|
|
388
391
|
}).then(pt);
|
|
389
|
-
return
|
|
392
|
+
return await this.options.storage.setItem(dt, e), e;
|
|
390
393
|
}
|
|
391
394
|
async clearLoginData() {
|
|
392
|
-
|
|
395
|
+
await this.options.storage.removeItem(dt);
|
|
393
396
|
}
|
|
394
397
|
getLastLoginData() {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
try {
|
|
399
|
-
return JSON.parse(e) || null;
|
|
400
|
-
} catch {
|
|
401
|
-
return null;
|
|
402
|
-
}
|
|
398
|
+
return this.options.storage.getItem(
|
|
399
|
+
dt
|
|
400
|
+
);
|
|
403
401
|
}
|
|
404
402
|
}
|
|
405
403
|
const pt = async (r) => {
|
|
@@ -407,10 +405,10 @@ const pt = async (r) => {
|
|
|
407
405
|
if (!r.ok)
|
|
408
406
|
throw new Error(e.message);
|
|
409
407
|
return e;
|
|
410
|
-
}, gs = (r) => [...r].map((e) => e.toString(16).padStart(2, "0")).join(""),
|
|
408
|
+
}, gs = (r) => [...r].map((e) => e.toString(16).padStart(2, "0")).join(""), ar = (r) => new Uint8Array(
|
|
411
409
|
r.match(/.{1,2}/g).map((e) => parseInt(e, 16))
|
|
412
|
-
),
|
|
413
|
-
class
|
|
410
|
+
), cr = (r) => btoa(String.fromCharCode(...new Uint8Array(r))), Ri = (r) => Uint8Array.from(atob(r), (e) => e.charCodeAt(0)).buffer, Ni = async (r) => await crypto.subtle.digest("SHA-256", r), Ti = new TextEncoder();
|
|
411
|
+
class Mi {
|
|
414
412
|
async createSessionKeyPair() {
|
|
415
413
|
return await crypto.subtle.generateKey(
|
|
416
414
|
{
|
|
@@ -424,10 +422,10 @@ class Ni {
|
|
|
424
422
|
}
|
|
425
423
|
async exportPublicKey(e) {
|
|
426
424
|
const t = await crypto.subtle.exportKey("spki", e);
|
|
427
|
-
return
|
|
425
|
+
return cr(t);
|
|
428
426
|
}
|
|
429
427
|
async deriveAESKey(e, t) {
|
|
430
|
-
const s =
|
|
428
|
+
const s = Ri(t), i = await crypto.subtle.importKey(
|
|
431
429
|
"spki",
|
|
432
430
|
s,
|
|
433
431
|
{ name: "ECDH", namedCurve: "P-256" },
|
|
@@ -458,7 +456,7 @@ class Ni {
|
|
|
458
456
|
return `${gs(new Uint8Array(n))}_${gs(s)}`;
|
|
459
457
|
}
|
|
460
458
|
async decrypt(e, t) {
|
|
461
|
-
const s = e.split("_"), i =
|
|
459
|
+
const s = e.split("_"), i = ar(s[0]).buffer, n = ar(s[1]), o = await crypto.subtle.decrypt(
|
|
462
460
|
{ name: "AES-GCM", iv: n },
|
|
463
461
|
t,
|
|
464
462
|
i
|
|
@@ -466,12 +464,12 @@ class Ni {
|
|
|
466
464
|
return new TextDecoder().decode(o);
|
|
467
465
|
}
|
|
468
466
|
async hashString(e) {
|
|
469
|
-
const t = await
|
|
470
|
-
return
|
|
467
|
+
const t = await Ni(Ti.encode(e).buffer);
|
|
468
|
+
return cr(t);
|
|
471
469
|
}
|
|
472
470
|
}
|
|
473
471
|
const ye = new Uint8Array(0), Ke = new TextEncoder(), ge = new TextDecoder();
|
|
474
|
-
function
|
|
472
|
+
function $i(...r) {
|
|
475
473
|
let e = 0;
|
|
476
474
|
for (let i = 0; i < r.length; i++)
|
|
477
475
|
e += r[i].length;
|
|
@@ -485,46 +483,46 @@ function yt(...r) {
|
|
|
485
483
|
const e = [];
|
|
486
484
|
for (let t = 0; t < r.length; t++)
|
|
487
485
|
e.push(Ke.encode(r[t]));
|
|
488
|
-
return e.length === 0 ? ye : e.length === 1 ? e[0] :
|
|
486
|
+
return e.length === 0 ? ye : e.length === 1 ? e[0] : $i(...e);
|
|
489
487
|
}
|
|
490
|
-
function
|
|
488
|
+
function hr(r) {
|
|
491
489
|
return !r || r.length === 0 ? "" : ge.decode(r);
|
|
492
490
|
}
|
|
493
|
-
const
|
|
494
|
-
function
|
|
491
|
+
const ur = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", lr = 36, Ui = 3656158440062976, fr = 33, Li = 333, dr = 22;
|
|
492
|
+
function qi(r) {
|
|
495
493
|
for (let e = 0; e < r.length; e++)
|
|
496
494
|
r[e] = Math.floor(Math.random() * 255);
|
|
497
495
|
}
|
|
498
|
-
function
|
|
496
|
+
function Fi(r) {
|
|
499
497
|
var e;
|
|
500
|
-
(e = globalThis == null ? void 0 : globalThis.crypto) != null && e.getRandomValues ? globalThis.crypto.getRandomValues(r) :
|
|
498
|
+
(e = globalThis == null ? void 0 : globalThis.crypto) != null && e.getRandomValues ? globalThis.crypto.getRandomValues(r) : qi(r);
|
|
501
499
|
}
|
|
502
|
-
class
|
|
500
|
+
class Bi {
|
|
503
501
|
constructor() {
|
|
504
502
|
h(this, "buf");
|
|
505
503
|
h(this, "seq");
|
|
506
504
|
h(this, "inc");
|
|
507
505
|
h(this, "inited");
|
|
508
|
-
this.buf = new Uint8Array(
|
|
506
|
+
this.buf = new Uint8Array(dr), this.inited = !1;
|
|
509
507
|
}
|
|
510
508
|
init() {
|
|
511
509
|
this.inited = !0, this.setPre(), this.initSeqAndInc(), this.fillSeq();
|
|
512
510
|
}
|
|
513
511
|
initSeqAndInc() {
|
|
514
|
-
this.seq = Math.floor(Math.random() *
|
|
512
|
+
this.seq = Math.floor(Math.random() * Ui), this.inc = Math.floor(Math.random() * (Li - fr) + fr);
|
|
515
513
|
}
|
|
516
514
|
setPre() {
|
|
517
515
|
const e = new Uint8Array(12);
|
|
518
|
-
|
|
516
|
+
Fi(e);
|
|
519
517
|
for (let t = 0; t < 12; t++) {
|
|
520
518
|
const s = e[t] % 36;
|
|
521
|
-
this.buf[t] =
|
|
519
|
+
this.buf[t] = ur.charCodeAt(s);
|
|
522
520
|
}
|
|
523
521
|
}
|
|
524
522
|
fillSeq() {
|
|
525
523
|
let e = this.seq;
|
|
526
|
-
for (let t =
|
|
527
|
-
this.buf[t] =
|
|
524
|
+
for (let t = dr - 1; t >= 12; t--)
|
|
525
|
+
this.buf[t] = ur.charCodeAt(e % lr), e = Math.floor(e / lr);
|
|
528
526
|
}
|
|
529
527
|
next() {
|
|
530
528
|
return this.inited || this.init(), this.seq += this.inc, this.seq > 3656158440062976 && (this.setPre(), this.initSeqAndInc()), this.fillSeq(), String.fromCharCode.apply(String, this.buf);
|
|
@@ -533,7 +531,7 @@ class qi {
|
|
|
533
531
|
this.init();
|
|
534
532
|
}
|
|
535
533
|
}
|
|
536
|
-
const De = new
|
|
534
|
+
const De = new Bi();
|
|
537
535
|
var Ee;
|
|
538
536
|
(function(r) {
|
|
539
537
|
r.Disconnect = "disconnect", r.Reconnect = "reconnect", r.Update = "update", r.LDM = "ldm", r.Error = "error";
|
|
@@ -546,7 +544,7 @@ var O;
|
|
|
546
544
|
(function(r) {
|
|
547
545
|
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";
|
|
548
546
|
})(O || (O = {}));
|
|
549
|
-
function
|
|
547
|
+
function Di(r) {
|
|
550
548
|
return typeof r.code == "string";
|
|
551
549
|
}
|
|
552
550
|
class Br {
|
|
@@ -555,13 +553,13 @@ class Br {
|
|
|
555
553
|
this.messages = /* @__PURE__ */ new Map(), this.messages.set(O.InvalidPayload, "Invalid payload type - payloads can be 'binary', 'string', or 'json'"), this.messages.set(O.BadJson, "Bad JSON"), this.messages.set(O.WssRequired, "TLS is required, therefore a secure websocket connection is also required");
|
|
556
554
|
}
|
|
557
555
|
static getMessage(e) {
|
|
558
|
-
return
|
|
556
|
+
return Hi.getMessage(e);
|
|
559
557
|
}
|
|
560
558
|
getMessage(e) {
|
|
561
559
|
return this.messages.get(e) || e;
|
|
562
560
|
}
|
|
563
561
|
}
|
|
564
|
-
const
|
|
562
|
+
const Hi = new Br();
|
|
565
563
|
class N extends Error {
|
|
566
564
|
constructor(t, s, i) {
|
|
567
565
|
super(t);
|
|
@@ -636,7 +634,7 @@ function Me(r = "") {
|
|
|
636
634
|
throw new Error(`inbox prefixes cannot have wildcards '${r}'`);
|
|
637
635
|
}), `${r}.${De.next()}`;
|
|
638
636
|
}
|
|
639
|
-
const
|
|
637
|
+
const As = "127.0.0.1";
|
|
640
638
|
var qe;
|
|
641
639
|
(function(r) {
|
|
642
640
|
r.PING = "PING", r.STATS = "STATS", r.INFO = "INFO";
|
|
@@ -701,10 +699,10 @@ function Dr(r) {
|
|
|
701
699
|
}
|
|
702
700
|
return r;
|
|
703
701
|
}
|
|
704
|
-
function
|
|
702
|
+
function Ji(r) {
|
|
705
703
|
return r === 0 ? 0 : Math.floor(r / 2 + Math.random() * r);
|
|
706
704
|
}
|
|
707
|
-
function
|
|
705
|
+
function Fs(r = [
|
|
708
706
|
0,
|
|
709
707
|
250,
|
|
710
708
|
250,
|
|
@@ -725,17 +723,17 @@ function Bs(r = [
|
|
|
725
723
|
const e = r.length - 1;
|
|
726
724
|
return {
|
|
727
725
|
backoff(t) {
|
|
728
|
-
return
|
|
726
|
+
return Ji(t > e ? r[e] : r[t]);
|
|
729
727
|
}
|
|
730
728
|
};
|
|
731
729
|
}
|
|
732
730
|
function G(r) {
|
|
733
731
|
return r * 1e6;
|
|
734
732
|
}
|
|
735
|
-
function
|
|
733
|
+
function Bs(r) {
|
|
736
734
|
return Math.floor(r / 1e6);
|
|
737
735
|
}
|
|
738
|
-
function
|
|
736
|
+
function pr(r) {
|
|
739
737
|
let s = !0;
|
|
740
738
|
const i = new Array(r.length);
|
|
741
739
|
for (let n = 0; n < r.length; n++) {
|
|
@@ -838,7 +836,7 @@ ${t}: ${s[i]}`;
|
|
|
838
836
|
case me.Exact:
|
|
839
837
|
return s.filter((i) => i === e);
|
|
840
838
|
case me.CanonicalMIME:
|
|
841
|
-
return e =
|
|
839
|
+
return e = pr(e), s.filter((i) => i === e);
|
|
842
840
|
default: {
|
|
843
841
|
const i = e.toLowerCase();
|
|
844
842
|
return s.filter((n) => i === n.toLowerCase());
|
|
@@ -870,7 +868,7 @@ ${t}: ${s[i]}`;
|
|
|
870
868
|
this.delete(e, s), this.append(e, t, s);
|
|
871
869
|
}
|
|
872
870
|
append(e, t, s = me.Exact) {
|
|
873
|
-
const i =
|
|
871
|
+
const i = pr(e);
|
|
874
872
|
s === me.CanonicalMIME && (e = i);
|
|
875
873
|
const n = this.findKeys(e, s);
|
|
876
874
|
e = n.length > 0 ? n[0] : e;
|
|
@@ -915,7 +913,7 @@ ${t}: ${s[i]}`;
|
|
|
915
913
|
return t;
|
|
916
914
|
}
|
|
917
915
|
}
|
|
918
|
-
function
|
|
916
|
+
function mr() {
|
|
919
917
|
return {
|
|
920
918
|
encode(r) {
|
|
921
919
|
return Ke.encode(r);
|
|
@@ -947,7 +945,7 @@ function Hr(r) {
|
|
|
947
945
|
var e;
|
|
948
946
|
return r && r.data.length === 0 && ((e = r.headers) == null ? void 0 : e.code) === 503 ? N.errorForCode(O.NoResponders) : null;
|
|
949
947
|
}
|
|
950
|
-
class
|
|
948
|
+
class Ds {
|
|
951
949
|
constructor(e, t, s) {
|
|
952
950
|
h(this, "_headers");
|
|
953
951
|
h(this, "_msg");
|
|
@@ -998,7 +996,7 @@ class Hs {
|
|
|
998
996
|
}) : null;
|
|
999
997
|
}
|
|
1000
998
|
}
|
|
1001
|
-
h(
|
|
999
|
+
h(Ds, "jc");
|
|
1002
1000
|
function et(r) {
|
|
1003
1001
|
return ts("durable", r);
|
|
1004
1002
|
}
|
|
@@ -1040,11 +1038,11 @@ function ts(r, e = "") {
|
|
|
1040
1038
|
function gt(r, e = "") {
|
|
1041
1039
|
if (e === "")
|
|
1042
1040
|
throw Error(`${r} name required`);
|
|
1043
|
-
const t =
|
|
1041
|
+
const t = zi(e);
|
|
1044
1042
|
if (t.length)
|
|
1045
1043
|
throw new Error(`invalid ${r} name - ${r} name ${t}`);
|
|
1046
1044
|
}
|
|
1047
|
-
function
|
|
1045
|
+
function zi(r = "") {
|
|
1048
1046
|
if (r === "")
|
|
1049
1047
|
throw Error("name required");
|
|
1050
1048
|
const e = /^[-\w]+$/g;
|
|
@@ -1055,22 +1053,22 @@ function Hi(r = "") {
|
|
|
1055
1053
|
}
|
|
1056
1054
|
return "";
|
|
1057
1055
|
}
|
|
1058
|
-
function
|
|
1056
|
+
function Ps(r) {
|
|
1059
1057
|
if (r.data.length > 0)
|
|
1060
1058
|
return !1;
|
|
1061
1059
|
const e = r.headers;
|
|
1062
1060
|
return e ? e.code >= 100 && e.code < 200 : !1;
|
|
1063
1061
|
}
|
|
1064
|
-
function
|
|
1062
|
+
function Os(r) {
|
|
1065
1063
|
var e;
|
|
1066
|
-
return
|
|
1064
|
+
return Ps(r) && ((e = r.headers) == null ? void 0 : e.description) === "Idle Heartbeat";
|
|
1067
1065
|
}
|
|
1068
|
-
function
|
|
1066
|
+
function Gi(r, e, t) {
|
|
1069
1067
|
const s = $e(r, e), i = {
|
|
1070
1068
|
hdr: 1,
|
|
1071
1069
|
sid: 0,
|
|
1072
1070
|
size: 0
|
|
1073
|
-
}, n = new
|
|
1071
|
+
}, n = new Ds(i, ye, {});
|
|
1074
1072
|
return n._headers = s, n._subject = t, n;
|
|
1075
1073
|
}
|
|
1076
1074
|
function tt(r) {
|
|
@@ -1083,7 +1081,7 @@ var Se;
|
|
|
1083
1081
|
(function(r) {
|
|
1084
1082
|
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";
|
|
1085
1083
|
})(Se || (Se = {}));
|
|
1086
|
-
function
|
|
1084
|
+
function Ki(r) {
|
|
1087
1085
|
return r.code !== O.JetStream409 ? !1 : [
|
|
1088
1086
|
Se.MaxBatchExceeded,
|
|
1089
1087
|
Se.MaxExpiresExceeded,
|
|
@@ -1203,7 +1201,7 @@ class oe {
|
|
|
1203
1201
|
return this.received - this.filtered;
|
|
1204
1202
|
}
|
|
1205
1203
|
}
|
|
1206
|
-
class
|
|
1204
|
+
class Hs {
|
|
1207
1205
|
constructor(e, t, s = {
|
|
1208
1206
|
maxOut: 2
|
|
1209
1207
|
}) {
|
|
@@ -1243,18 +1241,18 @@ class Js {
|
|
|
1243
1241
|
}, this.interval);
|
|
1244
1242
|
}
|
|
1245
1243
|
}
|
|
1246
|
-
var
|
|
1244
|
+
var ks;
|
|
1247
1245
|
(function(r) {
|
|
1248
1246
|
r.Limits = "limits", r.Interest = "interest", r.Workqueue = "workqueue";
|
|
1249
|
-
})(
|
|
1247
|
+
})(ks || (ks = {}));
|
|
1250
1248
|
var Et;
|
|
1251
1249
|
(function(r) {
|
|
1252
1250
|
r.Old = "old", r.New = "new";
|
|
1253
1251
|
})(Et || (Et = {}));
|
|
1254
|
-
var
|
|
1252
|
+
var Cs;
|
|
1255
1253
|
(function(r) {
|
|
1256
1254
|
r.File = "file", r.Memory = "memory";
|
|
1257
|
-
})(
|
|
1255
|
+
})(Cs || (Cs = {}));
|
|
1258
1256
|
var Q;
|
|
1259
1257
|
(function(r) {
|
|
1260
1258
|
r.All = "all", r.Last = "last", r.New = "new", r.StartSequence = "by_start_sequence", r.StartTime = "by_start_time", r.LastPerSubject = "last_per_subject";
|
|
@@ -1275,7 +1273,7 @@ var Wt;
|
|
|
1275
1273
|
(function(r) {
|
|
1276
1274
|
r.CreateOrUpdate = "", r.Update = "update", r.Create = "create";
|
|
1277
1275
|
})(Wt || (Wt = {}));
|
|
1278
|
-
function
|
|
1276
|
+
function Vi(r, e = {}) {
|
|
1279
1277
|
return Object.assign({
|
|
1280
1278
|
name: r,
|
|
1281
1279
|
deliver_policy: Q.All,
|
|
@@ -1284,10 +1282,10 @@ function Gi(r, e = {}) {
|
|
|
1284
1282
|
replay_policy: nt.Instant
|
|
1285
1283
|
}, e);
|
|
1286
1284
|
}
|
|
1287
|
-
var
|
|
1285
|
+
var br;
|
|
1288
1286
|
(function(r) {
|
|
1289
1287
|
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";
|
|
1290
|
-
})(
|
|
1288
|
+
})(br || (br = {}));
|
|
1291
1289
|
var de;
|
|
1292
1290
|
(function(r) {
|
|
1293
1291
|
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";
|
|
@@ -1300,12 +1298,12 @@ var Qe;
|
|
|
1300
1298
|
(function(r) {
|
|
1301
1299
|
r.Stream = "Nats-Stream", r.Sequence = "Nats-Sequence", r.TimeStamp = "Nats-Time-Stamp", r.Subject = "Nats-Subject";
|
|
1302
1300
|
})(Qe || (Qe = {}));
|
|
1303
|
-
var
|
|
1301
|
+
var gr;
|
|
1304
1302
|
(function(r) {
|
|
1305
1303
|
r.Stream = "Nats-Stream", r.Subject = "Nats-Subject", r.Sequence = "Nats-Sequence", r.LastSequence = "Nats-Last-Sequence", r.Size = "Nats-Msg-Size";
|
|
1306
|
-
})(
|
|
1304
|
+
})(gr || (gr = {}));
|
|
1307
1305
|
const be = "KV_";
|
|
1308
|
-
class
|
|
1306
|
+
class Wi {
|
|
1309
1307
|
constructor(e) {
|
|
1310
1308
|
h(this, "config");
|
|
1311
1309
|
h(this, "ordered");
|
|
@@ -1316,7 +1314,7 @@ class Ki {
|
|
|
1316
1314
|
h(this, "qname");
|
|
1317
1315
|
h(this, "isBind");
|
|
1318
1316
|
h(this, "filters");
|
|
1319
|
-
this.stream = "", this.mack = !1, this.ordered = !1, this.config =
|
|
1317
|
+
this.stream = "", this.mack = !1, this.ordered = !1, this.config = Vi("", e || {});
|
|
1320
1318
|
}
|
|
1321
1319
|
getOpts() {
|
|
1322
1320
|
var t;
|
|
@@ -1458,12 +1456,12 @@ class Ki {
|
|
|
1458
1456
|
}
|
|
1459
1457
|
}
|
|
1460
1458
|
function Be(r) {
|
|
1461
|
-
return new
|
|
1459
|
+
return new Wi(r);
|
|
1462
1460
|
}
|
|
1463
|
-
function
|
|
1461
|
+
function _r(r) {
|
|
1464
1462
|
return typeof r.getOpts == "function";
|
|
1465
1463
|
}
|
|
1466
|
-
class
|
|
1464
|
+
class Yi {
|
|
1467
1465
|
static encode(e) {
|
|
1468
1466
|
if (typeof e == "string")
|
|
1469
1467
|
return btoa(e);
|
|
@@ -1477,7 +1475,7 @@ class Vi {
|
|
|
1477
1475
|
}
|
|
1478
1476
|
class st {
|
|
1479
1477
|
static encode(e) {
|
|
1480
|
-
return st.toB64URLEncoding(
|
|
1478
|
+
return st.toB64URLEncoding(Yi.encode(e));
|
|
1481
1479
|
}
|
|
1482
1480
|
static decode(e, t = !1) {
|
|
1483
1481
|
return st.decode(st.fromB64URLEncoding(e), t);
|
|
@@ -1559,7 +1557,7 @@ class ot {
|
|
|
1559
1557
|
return this.buffers.length;
|
|
1560
1558
|
}
|
|
1561
1559
|
}
|
|
1562
|
-
function
|
|
1560
|
+
function Xi(r, e) {
|
|
1563
1561
|
return e.forEach(function(t) {
|
|
1564
1562
|
t && typeof t != "string" && !Array.isArray(t) && Object.keys(t).forEach(function(s) {
|
|
1565
1563
|
if (s !== "default" && !(s in r)) {
|
|
@@ -1574,12 +1572,12 @@ function Wi(r, e) {
|
|
|
1574
1572
|
});
|
|
1575
1573
|
}), Object.freeze(r);
|
|
1576
1574
|
}
|
|
1577
|
-
var
|
|
1575
|
+
var Zi = typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {}, mt = Zi.performance || {};
|
|
1578
1576
|
mt.now || mt.mozNow || mt.msNow || mt.oNow || mt.webkitNow;
|
|
1579
|
-
var
|
|
1577
|
+
var yr = {
|
|
1580
1578
|
versions: {}
|
|
1581
|
-
},
|
|
1582
|
-
function
|
|
1579
|
+
}, Qi = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
1580
|
+
function en(r) {
|
|
1583
1581
|
if (r.__esModule) return r;
|
|
1584
1582
|
var e = Object.defineProperty({}, "__esModule", {
|
|
1585
1583
|
value: !0
|
|
@@ -1596,17 +1594,17 @@ function Zi(r) {
|
|
|
1596
1594
|
}
|
|
1597
1595
|
var ys, ss = {
|
|
1598
1596
|
exports: {}
|
|
1599
|
-
},
|
|
1597
|
+
}, wr = {}, xr = en(Xi({
|
|
1600
1598
|
__proto__: null,
|
|
1601
|
-
default:
|
|
1599
|
+
default: wr
|
|
1602
1600
|
}, [
|
|
1603
|
-
|
|
1601
|
+
wr
|
|
1604
1602
|
]));
|
|
1605
1603
|
ys = ss, function() {
|
|
1606
1604
|
var r = "input is invalid type", e = typeof window == "object", t = e ? window : {};
|
|
1607
1605
|
t.JS_SHA256_NO_WINDOW && (e = !1);
|
|
1608
|
-
var s = !e && typeof self == "object", i = !t.JS_SHA256_NO_NODE_JS &&
|
|
1609
|
-
i ? t =
|
|
1606
|
+
var s = !e && typeof self == "object", i = !t.JS_SHA256_NO_NODE_JS && yr.versions && yr.versions.node;
|
|
1607
|
+
i ? t = Qi : s && (t = self);
|
|
1610
1608
|
var n = !t.JS_SHA256_NO_COMMON_JS && ys.exports, o = !t.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", a = "0123456789abcdef".split(""), d = [
|
|
1611
1609
|
-2147483648,
|
|
1612
1610
|
8388608,
|
|
@@ -1710,7 +1708,7 @@ ys = ss, function() {
|
|
|
1710
1708
|
}
|
|
1711
1709
|
return j;
|
|
1712
1710
|
}, T = function(w, j) {
|
|
1713
|
-
var F, R =
|
|
1711
|
+
var F, R = xr, A = xr.Buffer, $ = j ? "sha224" : "sha256";
|
|
1714
1712
|
return F = A.from && !t.JS_SHA256_NO_BUFFER_FROM ? A.from : function(q) {
|
|
1715
1713
|
return new A(q);
|
|
1716
1714
|
}, function(q) {
|
|
@@ -1857,23 +1855,23 @@ ys = ss, function() {
|
|
|
1857
1855
|
}();
|
|
1858
1856
|
ss.exports;
|
|
1859
1857
|
ss.exports.sha224;
|
|
1860
|
-
var
|
|
1861
|
-
function
|
|
1862
|
-
return
|
|
1858
|
+
var Sr = ss.exports.sha256;
|
|
1859
|
+
function Is(r) {
|
|
1860
|
+
return an(r);
|
|
1863
1861
|
}
|
|
1864
|
-
function
|
|
1862
|
+
function tn(r) {
|
|
1865
1863
|
if (!/^[0-9A-Fa-f]+$/.test(r))
|
|
1866
1864
|
return !1;
|
|
1867
1865
|
const t = /^[0-9A-F]+$/.test(r), s = /^[0-9a-f]+$/.test(r);
|
|
1868
1866
|
return t || s ? r.length % 2 === 0 : !1;
|
|
1869
1867
|
}
|
|
1870
|
-
function
|
|
1868
|
+
function sn(r) {
|
|
1871
1869
|
return /^[A-Za-z0-9\-_]*(={0,2})?$/.test(r) || /^[A-Za-z0-9+/]*(={0,2})?$/.test(r);
|
|
1872
1870
|
}
|
|
1873
|
-
function
|
|
1874
|
-
return
|
|
1871
|
+
function rn(r) {
|
|
1872
|
+
return tn(r) ? "hex" : sn(r) ? "b64" : "";
|
|
1875
1873
|
}
|
|
1876
|
-
function
|
|
1874
|
+
function nn(r) {
|
|
1877
1875
|
if (r.length % 2 !== 0)
|
|
1878
1876
|
throw new Error("hex string must have an even length");
|
|
1879
1877
|
const e = new Uint8Array(r.length / 2);
|
|
@@ -1881,22 +1879,22 @@ function sn(r) {
|
|
|
1881
1879
|
e[t / 2] = parseInt(r.substring(t, t + 2), 16);
|
|
1882
1880
|
return e;
|
|
1883
1881
|
}
|
|
1884
|
-
function
|
|
1882
|
+
function on(r) {
|
|
1885
1883
|
r = r.replace(/-/g, "+"), r = r.replace(/_/g, "/");
|
|
1886
1884
|
const e = atob(r);
|
|
1887
1885
|
return Uint8Array.from(e, (t) => t.charCodeAt(0));
|
|
1888
1886
|
}
|
|
1889
|
-
function
|
|
1890
|
-
switch (
|
|
1887
|
+
function an(r) {
|
|
1888
|
+
switch (rn(r)) {
|
|
1891
1889
|
case "hex":
|
|
1892
|
-
return
|
|
1890
|
+
return nn(r);
|
|
1893
1891
|
case "b64":
|
|
1894
|
-
return
|
|
1892
|
+
return on(r);
|
|
1895
1893
|
}
|
|
1896
1894
|
return null;
|
|
1897
1895
|
}
|
|
1898
|
-
function
|
|
1899
|
-
const t = typeof r == "string" ?
|
|
1896
|
+
function cn(r, e) {
|
|
1897
|
+
const t = typeof r == "string" ? Is(r) : r, s = typeof e == "string" ? Is(e) : e;
|
|
1900
1898
|
if (t === null || s === null || t.length !== s.length)
|
|
1901
1899
|
return !1;
|
|
1902
1900
|
for (let i = 0; i < t.length; i++)
|
|
@@ -1914,7 +1912,7 @@ class zr {
|
|
|
1914
1912
|
this.mux = e, this.requestSubject = t, this.received = 0, this.token = De.next(), s && (this.ctx = new Error());
|
|
1915
1913
|
}
|
|
1916
1914
|
}
|
|
1917
|
-
class
|
|
1915
|
+
class hn extends zr {
|
|
1918
1916
|
constructor(t, s, i = {
|
|
1919
1917
|
maxWait: 1e3
|
|
1920
1918
|
}) {
|
|
@@ -1961,10 +1959,10 @@ ${this.ctx.stack}`), this.deferred.reject(t)) : this.deferred.resolve(s), this.c
|
|
|
1961
1959
|
this.timer && this.timer.cancel(), this.mux.cancel(this), this.deferred.reject(t || N.errorForCode(O.Cancelled));
|
|
1962
1960
|
}
|
|
1963
1961
|
}
|
|
1964
|
-
const
|
|
1965
|
-
function
|
|
1962
|
+
const un = "$JS.API";
|
|
1963
|
+
function ln(r) {
|
|
1966
1964
|
return r = r || {}, r.domain && (r.apiPrefix = `$JS.${r.domain}.API`, delete r.domain), es({
|
|
1967
|
-
apiPrefix:
|
|
1965
|
+
apiPrefix: un,
|
|
1968
1966
|
timeout: 5e3
|
|
1969
1967
|
}, r);
|
|
1970
1968
|
}
|
|
@@ -1975,7 +1973,7 @@ class Ot {
|
|
|
1975
1973
|
h(this, "prefix");
|
|
1976
1974
|
h(this, "timeout");
|
|
1977
1975
|
h(this, "jc");
|
|
1978
|
-
this.nc = e, this.opts =
|
|
1976
|
+
this.nc = e, this.opts = ln(t), this._parseOpts(), this.prefix = this.opts.apiPrefix, this.timeout = this.opts.timeout, this.jc = ve();
|
|
1979
1977
|
}
|
|
1980
1978
|
getOptions() {
|
|
1981
1979
|
return Object.assign({}, this.opts);
|
|
@@ -1992,7 +1990,7 @@ class Ot {
|
|
|
1992
1990
|
t && (i = this.jc.encode(t));
|
|
1993
1991
|
let { retries: n } = s;
|
|
1994
1992
|
n = n || 1, n = n === -1 ? Number.MAX_SAFE_INTEGER : n;
|
|
1995
|
-
const o =
|
|
1993
|
+
const o = Fs();
|
|
1996
1994
|
for (let a = 0; a < n; a++)
|
|
1997
1995
|
try {
|
|
1998
1996
|
const d = await this.nc.request(e, i, s);
|
|
@@ -2091,14 +2089,14 @@ function Ge(r = "") {
|
|
|
2091
2089
|
};
|
|
2092
2090
|
throw new Error(`'${r}' is not a semver value`);
|
|
2093
2091
|
}
|
|
2094
|
-
function
|
|
2092
|
+
function js(r, e) {
|
|
2095
2093
|
return r.major < e.major ? -1 : r.major > e.major ? 1 : r.minor < e.minor ? -1 : r.minor > e.minor ? 1 : r.micro < e.micro ? -1 : r.micro > e.micro ? 1 : 0;
|
|
2096
2094
|
}
|
|
2097
2095
|
var H;
|
|
2098
2096
|
(function(r) {
|
|
2099
2097
|
r.JS_KV = "js_kv", r.JS_OBJECTSTORE = "js_objectstore", r.JS_PULL_MAX_BYTES = "js_pull_max_bytes", r.JS_NEW_CONSUMER_CREATE_API = "js_new_consumer_create", r.JS_ALLOW_DIRECT = "js_allow_direct", r.JS_MULTIPLE_CONSUMER_FILTER = "js_multiple_consumer_filter", r.JS_SIMPLIFICATION = "js_simplification", r.JS_STREAM_CONSUMER_METADATA = "js_stream_consumer_metadata", r.JS_CONSUMER_FILTER_SUBJECTS = "js_consumer_filter_subjects", r.JS_STREAM_FIRST_SEQ = "js_stream_first_seq", r.JS_STREAM_SUBJECT_TRANSFORM = "js_stream_subject_transform", r.JS_STREAM_SOURCE_SUBJECT_TRANSFORM = "js_stream_source_subject_transform", r.JS_STREAM_COMPRESSION = "js_stream_compression", r.JS_DEFAULT_CONSUMER_LIMITS = "js_default_consumer_limits", r.JS_BATCH_DIRECT_GET = "js_batch_direct_get";
|
|
2100
2098
|
})(H || (H = {}));
|
|
2101
|
-
class
|
|
2099
|
+
class fn {
|
|
2102
2100
|
constructor(e) {
|
|
2103
2101
|
h(this, "server");
|
|
2104
2102
|
h(this, "features");
|
|
@@ -2122,7 +2120,7 @@ class un {
|
|
|
2122
2120
|
set(e, t) {
|
|
2123
2121
|
this.features.set(e, {
|
|
2124
2122
|
min: t,
|
|
2125
|
-
ok:
|
|
2123
|
+
ok: js(this.server, Ge(t)) >= 0
|
|
2126
2124
|
});
|
|
2127
2125
|
}
|
|
2128
2126
|
get(e) {
|
|
@@ -2136,7 +2134,7 @@ class un {
|
|
|
2136
2134
|
return ((t = this.get(e)) == null ? void 0 : t.ok) || !1;
|
|
2137
2135
|
}
|
|
2138
2136
|
require(e) {
|
|
2139
|
-
return typeof e == "string" && (e = Ge(e)),
|
|
2137
|
+
return typeof e == "string" && (e = Ge(e)), js(this.server, e) >= 0;
|
|
2140
2138
|
}
|
|
2141
2139
|
}
|
|
2142
2140
|
class Yt extends Ot {
|
|
@@ -2212,7 +2210,7 @@ function Ze(r, e, t = !1) {
|
|
|
2212
2210
|
if (r && typeof r != "function")
|
|
2213
2211
|
throw N.errorForCode(O.ApiError, new Error(`${e} is not a function`));
|
|
2214
2212
|
}
|
|
2215
|
-
class
|
|
2213
|
+
class dn extends oe {
|
|
2216
2214
|
constructor(t, s, i) {
|
|
2217
2215
|
super();
|
|
2218
2216
|
h(this, "sub");
|
|
@@ -2294,7 +2292,7 @@ class ln extends oe {
|
|
|
2294
2292
|
}
|
|
2295
2293
|
}
|
|
2296
2294
|
let _e;
|
|
2297
|
-
function
|
|
2295
|
+
function pn(r) {
|
|
2298
2296
|
_e = r;
|
|
2299
2297
|
}
|
|
2300
2298
|
function Kr() {
|
|
@@ -2303,34 +2301,34 @@ function Kr() {
|
|
|
2303
2301
|
function ws() {
|
|
2304
2302
|
return _e !== void 0 && _e.urlParseFn ? _e.urlParseFn : void 0;
|
|
2305
2303
|
}
|
|
2306
|
-
function
|
|
2304
|
+
function mn() {
|
|
2307
2305
|
if (!_e || typeof _e.factory != "function")
|
|
2308
2306
|
throw new Error("transport fn is not set");
|
|
2309
2307
|
return _e.factory();
|
|
2310
2308
|
}
|
|
2311
|
-
function
|
|
2309
|
+
function Rs() {
|
|
2312
2310
|
return _e !== void 0 && _e.dnsResolveFn ? _e.dnsResolveFn : void 0;
|
|
2313
2311
|
}
|
|
2314
2312
|
const Ht = `\r
|
|
2315
|
-
`, Xt = ot.fromAscii(Ht),
|
|
2316
|
-
function
|
|
2313
|
+
`, Xt = ot.fromAscii(Ht), bn = new Uint8Array(Xt)[0], gn = new Uint8Array(Xt)[1];
|
|
2314
|
+
function _n(r) {
|
|
2317
2315
|
for (let e = 0; e < r.length; e++) {
|
|
2318
2316
|
const t = e + 1;
|
|
2319
|
-
if (r.byteLength > t && r[e] ===
|
|
2317
|
+
if (r.byteLength > t && r[e] === bn && r[t] === gn)
|
|
2320
2318
|
return t + 1;
|
|
2321
2319
|
}
|
|
2322
2320
|
return 0;
|
|
2323
2321
|
}
|
|
2324
|
-
function
|
|
2325
|
-
const e =
|
|
2322
|
+
function yn(r) {
|
|
2323
|
+
const e = _n(r);
|
|
2326
2324
|
if (e > 0) {
|
|
2327
2325
|
const s = new Uint8Array(r).slice(0, e);
|
|
2328
2326
|
return ge.decode(s);
|
|
2329
2327
|
}
|
|
2330
2328
|
return "";
|
|
2331
2329
|
}
|
|
2332
|
-
const
|
|
2333
|
-
function
|
|
2330
|
+
const wn = 4, Vr = 48, xn = 65, Sn = 97;
|
|
2331
|
+
function En(r, e, t, s) {
|
|
2334
2332
|
const i = new Uint8Array(16);
|
|
2335
2333
|
return [
|
|
2336
2334
|
0,
|
|
@@ -2349,16 +2347,16 @@ function xn(r, e, t, s) {
|
|
|
2349
2347
|
i[a] = o;
|
|
2350
2348
|
}), i[12] = r, i[13] = e, i[14] = t, i[15] = s, i;
|
|
2351
2349
|
}
|
|
2352
|
-
function
|
|
2353
|
-
return
|
|
2350
|
+
function Ns(r) {
|
|
2351
|
+
return vn(r) !== void 0;
|
|
2354
2352
|
}
|
|
2355
|
-
function
|
|
2353
|
+
function vn(r) {
|
|
2356
2354
|
for (let e = 0; e < r.length; e++)
|
|
2357
2355
|
switch (r[e]) {
|
|
2358
2356
|
case ".":
|
|
2359
2357
|
return Wr(r);
|
|
2360
2358
|
case ":":
|
|
2361
|
-
return
|
|
2359
|
+
return An(r);
|
|
2362
2360
|
}
|
|
2363
2361
|
}
|
|
2364
2362
|
function Wr(r) {
|
|
@@ -2371,21 +2369,21 @@ function Wr(r) {
|
|
|
2371
2369
|
return;
|
|
2372
2370
|
r = r.substring(1);
|
|
2373
2371
|
}
|
|
2374
|
-
const { n: s, c: i, ok: n } =
|
|
2372
|
+
const { n: s, c: i, ok: n } = Pn(r);
|
|
2375
2373
|
if (!n || s > 255)
|
|
2376
2374
|
return;
|
|
2377
2375
|
r = r.substring(i), e[t] = s;
|
|
2378
2376
|
}
|
|
2379
|
-
return
|
|
2377
|
+
return En(e[0], e[1], e[2], e[3]);
|
|
2380
2378
|
}
|
|
2381
|
-
function
|
|
2379
|
+
function An(r) {
|
|
2382
2380
|
const e = new Uint8Array(16);
|
|
2383
2381
|
let t = -1;
|
|
2384
2382
|
if (r.length >= 2 && r[0] === ":" && r[1] === ":" && (t = 0, r = r.substring(2), r.length === 0))
|
|
2385
2383
|
return e;
|
|
2386
2384
|
let s = 0;
|
|
2387
2385
|
for (; s < 16; ) {
|
|
2388
|
-
const { n: i, c: n, ok: o } =
|
|
2386
|
+
const { n: i, c: n, ok: o } = On(r);
|
|
2389
2387
|
if (!o || i > 65535)
|
|
2390
2388
|
return;
|
|
2391
2389
|
if (n < r.length && r[n] === ".") {
|
|
@@ -2394,7 +2392,7 @@ function En(r) {
|
|
|
2394
2392
|
const a = Wr(r);
|
|
2395
2393
|
if (a === void 0)
|
|
2396
2394
|
return;
|
|
2397
|
-
e[s] = a[12], e[s + 1] = a[13], e[s + 2] = a[14], e[s + 3] = a[15], r = "", s +=
|
|
2395
|
+
e[s] = a[12], e[s + 1] = a[13], e[s + 2] = a[14], e[s + 3] = a[15], r = "", s += wn;
|
|
2398
2396
|
break;
|
|
2399
2397
|
}
|
|
2400
2398
|
if (e[s] = i >> 8, e[s + 1] = i, s += 2, r = r.substring(n), r.length === 0)
|
|
@@ -2422,7 +2420,7 @@ function En(r) {
|
|
|
2422
2420
|
return e;
|
|
2423
2421
|
}
|
|
2424
2422
|
}
|
|
2425
|
-
function
|
|
2423
|
+
function Pn(r) {
|
|
2426
2424
|
let e = 0, t = 0;
|
|
2427
2425
|
for (e = 0; e < r.length && 48 <= r.charCodeAt(e) && r.charCodeAt(e) <= 57; e++)
|
|
2428
2426
|
if (t = t * 10 + (r.charCodeAt(e) - Vr), t >= 16777215)
|
|
@@ -2441,15 +2439,15 @@ function vn(r) {
|
|
|
2441
2439
|
ok: !0
|
|
2442
2440
|
};
|
|
2443
2441
|
}
|
|
2444
|
-
function
|
|
2442
|
+
function On(r) {
|
|
2445
2443
|
let e = 0, t = 0;
|
|
2446
2444
|
for (t = 0; t < r.length; t++) {
|
|
2447
2445
|
if (48 <= r.charCodeAt(t) && r.charCodeAt(t) <= 57)
|
|
2448
2446
|
e *= 16, e += r.charCodeAt(t) - Vr;
|
|
2449
2447
|
else if (97 <= r.charCodeAt(t) && r.charCodeAt(t) <= 102)
|
|
2450
|
-
e *= 16, e += r.charCodeAt(t) -
|
|
2448
|
+
e *= 16, e += r.charCodeAt(t) - Sn + 10;
|
|
2451
2449
|
else if (65 <= r.charCodeAt(t) && r.charCodeAt(t) <= 70)
|
|
2452
|
-
e *= 16, e += r.charCodeAt(t) -
|
|
2450
|
+
e *= 16, e += r.charCodeAt(t) - xn + 10;
|
|
2453
2451
|
else
|
|
2454
2452
|
break;
|
|
2455
2453
|
if (e >= 16777215)
|
|
@@ -2469,13 +2467,13 @@ function An(r) {
|
|
|
2469
2467
|
ok: !0
|
|
2470
2468
|
};
|
|
2471
2469
|
}
|
|
2472
|
-
function
|
|
2470
|
+
function kn(r) {
|
|
2473
2471
|
return r.indexOf("[") !== -1 || r.indexOf("::") !== -1 ? !1 : r.indexOf(".") !== -1 || r.split(":").length <= 2;
|
|
2474
2472
|
}
|
|
2475
|
-
function
|
|
2476
|
-
return !
|
|
2473
|
+
function Ts(r) {
|
|
2474
|
+
return !kn(r);
|
|
2477
2475
|
}
|
|
2478
|
-
function
|
|
2476
|
+
function Cn(r) {
|
|
2479
2477
|
const e = "::FFFF:", t = r.toUpperCase().indexOf(e);
|
|
2480
2478
|
if (t !== -1 && r.indexOf(".") !== -1) {
|
|
2481
2479
|
let s = r.substring(t + e.length);
|
|
@@ -2483,9 +2481,9 @@ function On(r) {
|
|
|
2483
2481
|
}
|
|
2484
2482
|
return r;
|
|
2485
2483
|
}
|
|
2486
|
-
function
|
|
2487
|
-
r = r.trim(), r.match(/^(.*:\/\/)(.*)/m) && (r = r.replace(/^(.*:\/\/)(.*)/gm, "$2")), r =
|
|
2488
|
-
const e =
|
|
2484
|
+
function In(r) {
|
|
2485
|
+
r = r.trim(), r.match(/^(.*:\/\/)(.*)/m) && (r = r.replace(/^(.*:\/\/)(.*)/gm, "$2")), r = Cn(r), Ts(r) && r.indexOf("[") === -1 && (r = `[${r}]`);
|
|
2486
|
+
const e = Ts(r) ? r.match(/(]:)(\d+)/) : r.match(/(:)(\d+)/), t = e && e.length === 3 && e[1] && e[2] ? parseInt(e[2]) : 4222, s = t === 80 ? "https" : "http", i = new URL(`${s}://${r}`);
|
|
2489
2487
|
i.port = `${t}`;
|
|
2490
2488
|
let n = i.hostname;
|
|
2491
2489
|
return n.charAt(0) === "[" && (n = n.substring(1, n.length - 1)), {
|
|
@@ -2507,7 +2505,7 @@ class xt {
|
|
|
2507
2505
|
h(this, "tlsName");
|
|
2508
2506
|
h(this, "resolves");
|
|
2509
2507
|
this.src = e, this.tlsName = "";
|
|
2510
|
-
const s =
|
|
2508
|
+
const s = In(e);
|
|
2511
2509
|
this.listen = s.listen, this.hostname = s.hostname, this.port = s.port, this.didConnect = !1, this.reconnects = 0, this.lastConnect = 0, this.gossiped = t;
|
|
2512
2510
|
}
|
|
2513
2511
|
toString() {
|
|
@@ -2519,7 +2517,7 @@ class xt {
|
|
|
2519
2517
|
this
|
|
2520
2518
|
];
|
|
2521
2519
|
const t = [];
|
|
2522
|
-
if (
|
|
2520
|
+
if (Ns(this.hostname))
|
|
2523
2521
|
return [
|
|
2524
2522
|
this
|
|
2525
2523
|
];
|
|
@@ -2527,7 +2525,7 @@ class xt {
|
|
|
2527
2525
|
const s = await e.fn(this.hostname);
|
|
2528
2526
|
e.debug && console.log(`resolve ${this.hostname} = ${s.join(",")}`);
|
|
2529
2527
|
for (const i of s) {
|
|
2530
|
-
const n = this.port === 80 ? "https" : "http", o = new URL(`${n}://${
|
|
2528
|
+
const n = this.port === 80 ? "https" : "http", o = new URL(`${n}://${Ts(i) ? "[" + i + "]" : i}`);
|
|
2531
2529
|
o.port = `${this.port}`;
|
|
2532
2530
|
const a = new xt(o.host, !1);
|
|
2533
2531
|
a.tlsName = this.hostname, t.push(a);
|
|
@@ -2536,7 +2534,7 @@ class xt {
|
|
|
2536
2534
|
return e.randomize && Dr(t), this.resolves = t, t;
|
|
2537
2535
|
}
|
|
2538
2536
|
}
|
|
2539
|
-
class
|
|
2537
|
+
class jn {
|
|
2540
2538
|
constructor(e = [], t = {}) {
|
|
2541
2539
|
h(this, "firstSelect");
|
|
2542
2540
|
h(this, "servers");
|
|
@@ -2547,14 +2545,14 @@ class Cn {
|
|
|
2547
2545
|
const s = ws();
|
|
2548
2546
|
e && (e.forEach((i) => {
|
|
2549
2547
|
i = s ? s(i) : i, this.servers.push(new xt(i));
|
|
2550
|
-
}), this.randomize && (this.servers = Dr(this.servers))), this.servers.length === 0 && this.addServer(`${
|
|
2548
|
+
}), this.randomize && (this.servers = Dr(this.servers))), this.servers.length === 0 && this.addServer(`${As}:${Kr()}`, !1), this.currentServer = this.servers[0];
|
|
2551
2549
|
}
|
|
2552
2550
|
clear() {
|
|
2553
2551
|
this.servers.length = 0;
|
|
2554
2552
|
}
|
|
2555
2553
|
updateTLSName() {
|
|
2556
2554
|
const e = this.getCurrentServer();
|
|
2557
|
-
|
|
2555
|
+
Ns(e.hostname) || (this.tlsName = e.hostname, this.servers.forEach((t) => {
|
|
2558
2556
|
t.gossiped && (t.tlsName = this.tlsName);
|
|
2559
2557
|
}));
|
|
2560
2558
|
}
|
|
@@ -2565,7 +2563,7 @@ class Cn {
|
|
|
2565
2563
|
const s = ws();
|
|
2566
2564
|
e = s ? s(e) : e;
|
|
2567
2565
|
const i = new xt(e, t);
|
|
2568
|
-
|
|
2566
|
+
Ns(i.hostname) && (i.tlsName = this.tlsName), this.servers.push(i);
|
|
2569
2567
|
}
|
|
2570
2568
|
selectServer() {
|
|
2571
2569
|
if (this.firstSelect)
|
|
@@ -2615,7 +2613,7 @@ class Cn {
|
|
|
2615
2613
|
};
|
|
2616
2614
|
}
|
|
2617
2615
|
}
|
|
2618
|
-
class
|
|
2616
|
+
class Rn {
|
|
2619
2617
|
constructor() {
|
|
2620
2618
|
h(this, "baseInbox");
|
|
2621
2619
|
h(this, "reqs");
|
|
@@ -2674,7 +2672,7 @@ class In {
|
|
|
2674
2672
|
});
|
|
2675
2673
|
}
|
|
2676
2674
|
}
|
|
2677
|
-
class
|
|
2675
|
+
class Nn {
|
|
2678
2676
|
constructor(e, t, s) {
|
|
2679
2677
|
h(this, "ph");
|
|
2680
2678
|
h(this, "interval");
|
|
@@ -2710,16 +2708,16 @@ class jn {
|
|
|
2710
2708
|
this.pendings = this.pendings.filter((e) => (e.resolve(), !1));
|
|
2711
2709
|
}
|
|
2712
2710
|
}
|
|
2713
|
-
class
|
|
2711
|
+
class Tn extends Error {
|
|
2714
2712
|
constructor(e) {
|
|
2715
2713
|
super(e), this.name = "AssertionError";
|
|
2716
2714
|
}
|
|
2717
2715
|
}
|
|
2718
|
-
function
|
|
2716
|
+
function Mn(r, e = "Assertion failed.") {
|
|
2719
2717
|
if (!r)
|
|
2720
|
-
throw new
|
|
2718
|
+
throw new Tn(e);
|
|
2721
2719
|
}
|
|
2722
|
-
const
|
|
2720
|
+
const Er = 32 * 1024, xs = 2 ** 32 - 2;
|
|
2723
2721
|
function qt(r, e, t = 0) {
|
|
2724
2722
|
const s = e.byteLength - t;
|
|
2725
2723
|
return r.byteLength > s && (r = r.subarray(0, s)), e.set(r, t), r.byteLength;
|
|
@@ -2765,7 +2763,7 @@ class Ss {
|
|
|
2765
2763
|
return e <= this.capacity - t ? (this._reslice(t + e), t) : -1;
|
|
2766
2764
|
}
|
|
2767
2765
|
_reslice(e) {
|
|
2768
|
-
|
|
2766
|
+
Mn(e <= this._buf.buffer.byteLength), this._buf = new Uint8Array(this._buf.buffer, 0, e);
|
|
2769
2767
|
}
|
|
2770
2768
|
readByte() {
|
|
2771
2769
|
const e = new Uint8Array(1);
|
|
@@ -2814,9 +2812,9 @@ class Ss {
|
|
|
2814
2812
|
}
|
|
2815
2813
|
readFrom(e) {
|
|
2816
2814
|
let t = 0;
|
|
2817
|
-
const s = new Uint8Array(
|
|
2815
|
+
const s = new Uint8Array(Er);
|
|
2818
2816
|
for (; ; ) {
|
|
2819
|
-
const i = this.capacity - this.length <
|
|
2817
|
+
const i = this.capacity - this.length < Er, n = i ? s : new Uint8Array(this._buf.buffer, this.length), o = e.read(n);
|
|
2820
2818
|
if (o === null)
|
|
2821
2819
|
return t;
|
|
2822
2820
|
i ? this.write(n.subarray(0, o)) : this._reslice(this.length + o), t += o;
|
|
@@ -2827,12 +2825,12 @@ var fe;
|
|
|
2827
2825
|
(function(r) {
|
|
2828
2826
|
r[r.OK = 0] = "OK", r[r.ERR = 1] = "ERR", r[r.MSG = 2] = "MSG", r[r.INFO = 3] = "INFO", r[r.PING = 4] = "PING", r[r.PONG = 5] = "PONG";
|
|
2829
2827
|
})(fe || (fe = {}));
|
|
2830
|
-
function
|
|
2828
|
+
function vr() {
|
|
2831
2829
|
const r = {};
|
|
2832
2830
|
return r.sid = -1, r.hdr = -1, r.size = -1, r;
|
|
2833
2831
|
}
|
|
2834
|
-
const
|
|
2835
|
-
class
|
|
2832
|
+
const $n = 48;
|
|
2833
|
+
class Ar {
|
|
2836
2834
|
constructor(e) {
|
|
2837
2835
|
h(this, "dispatcher");
|
|
2838
2836
|
h(this, "state");
|
|
@@ -2853,11 +2851,11 @@ class Pr {
|
|
|
2853
2851
|
switch (s) {
|
|
2854
2852
|
case C.M:
|
|
2855
2853
|
case C.m:
|
|
2856
|
-
this.state = k.OP_M, this.hdr = -1, this.ma =
|
|
2854
|
+
this.state = k.OP_M, this.hdr = -1, this.ma = vr();
|
|
2857
2855
|
break;
|
|
2858
2856
|
case C.H:
|
|
2859
2857
|
case C.h:
|
|
2860
|
-
this.state = k.OP_H, this.hdr = 0, this.ma =
|
|
2858
|
+
this.state = k.OP_H, this.hdr = 0, this.ma = vr();
|
|
2861
2859
|
break;
|
|
2862
2860
|
case C.P:
|
|
2863
2861
|
case C.p:
|
|
@@ -3286,7 +3284,7 @@ class Pr {
|
|
|
3286
3284
|
for (let s = 0; s < e.length; s++) {
|
|
3287
3285
|
if (e[s] < 48 || e[s] > 57)
|
|
3288
3286
|
return -1;
|
|
3289
|
-
t = t * 10 + (e[s] -
|
|
3287
|
+
t = t * 10 + (e[s] - $n);
|
|
3290
3288
|
}
|
|
3291
3289
|
return t;
|
|
3292
3290
|
}
|
|
@@ -3588,11 +3586,11 @@ var C;
|
|
|
3588
3586
|
for (u = 0; u < 16; u++)
|
|
3589
3587
|
c[2 * u] = E[u] & 255, c[2 * u + 1] = E[u] >> 8;
|
|
3590
3588
|
}
|
|
3591
|
-
function
|
|
3589
|
+
function Vs(c, l) {
|
|
3592
3590
|
var u = new Uint8Array(32), f = new Uint8Array(32);
|
|
3593
3591
|
return Ve(u, c), Ve(f, l), w(u, 0, f, 0);
|
|
3594
3592
|
}
|
|
3595
|
-
function
|
|
3593
|
+
function Ws(c) {
|
|
3596
3594
|
var l = new Uint8Array(32);
|
|
3597
3595
|
return Ve(l, c), l[0] & 1;
|
|
3598
3596
|
}
|
|
@@ -3623,14 +3621,14 @@ var C;
|
|
|
3623
3621
|
function we(c, l) {
|
|
3624
3622
|
B(c, l, l);
|
|
3625
3623
|
}
|
|
3626
|
-
function
|
|
3624
|
+
function Ys(c, l) {
|
|
3627
3625
|
var u = t(), f;
|
|
3628
3626
|
for (f = 0; f < 16; f++) u[f] = l[f];
|
|
3629
3627
|
for (f = 253; f >= 0; f--)
|
|
3630
3628
|
we(u, u), f !== 2 && f !== 4 && B(u, u, l);
|
|
3631
3629
|
for (f = 0; f < 16; f++) c[f] = u[f];
|
|
3632
3630
|
}
|
|
3633
|
-
function
|
|
3631
|
+
function Xs(c, l) {
|
|
3634
3632
|
var u = t(), f;
|
|
3635
3633
|
for (f = 0; f < 16; f++) u[f] = l[f];
|
|
3636
3634
|
for (f = 250; f >= 0; f--)
|
|
@@ -3647,26 +3645,26 @@ var C;
|
|
|
3647
3645
|
for (E = 0; E < 16; E++)
|
|
3648
3646
|
m[E + 16] = v[E], m[E + 32] = S[E], m[E + 48] = g[E], m[E + 64] = M[E];
|
|
3649
3647
|
var Oe = m.subarray(32), Xe = m.subarray(16);
|
|
3650
|
-
return
|
|
3648
|
+
return Ys(Oe, Oe), B(Xe, Xe, Oe), Ve(c, Xe), 0;
|
|
3651
3649
|
}
|
|
3652
3650
|
function It(c, l) {
|
|
3653
3651
|
return Ct(c, l, n);
|
|
3654
3652
|
}
|
|
3655
|
-
function
|
|
3653
|
+
function Zs(c, l) {
|
|
3656
3654
|
return s(l, 32), It(c, l);
|
|
3657
3655
|
}
|
|
3658
3656
|
function jt(c, l, u) {
|
|
3659
3657
|
var f = new Uint8Array(32);
|
|
3660
3658
|
return Ct(f, u, l), R(c, i, f, A);
|
|
3661
3659
|
}
|
|
3662
|
-
var
|
|
3663
|
-
function
|
|
3660
|
+
var Qs = ae, ai = ce;
|
|
3661
|
+
function ci(c, l, u, f, m, b) {
|
|
3664
3662
|
var E = new Uint8Array(32);
|
|
3665
|
-
return jt(E, m, b),
|
|
3663
|
+
return jt(E, m, b), Qs(c, l, u, f, E);
|
|
3666
3664
|
}
|
|
3667
|
-
function
|
|
3665
|
+
function hi(c, l, u, f, m, b) {
|
|
3668
3666
|
var E = new Uint8Array(32);
|
|
3669
|
-
return jt(E, m, b),
|
|
3667
|
+
return jt(E, m, b), ai(c, l, u, f, E);
|
|
3670
3668
|
}
|
|
3671
3669
|
function ct() {
|
|
3672
3670
|
var c = 0, l = 0, u = 0, f = 0, m = 65535, b, E, v;
|
|
@@ -3674,7 +3672,7 @@ var C;
|
|
|
3674
3672
|
b = arguments[v].lo, E = arguments[v].hi, c += b & m, l += b >>> 16, u += E & m, f += E >>> 16;
|
|
3675
3673
|
return l += c >>> 16, u += l >>> 16, f += u >>> 16, new e(u & m | f << 16, c & m | l << 16);
|
|
3676
3674
|
}
|
|
3677
|
-
function
|
|
3675
|
+
function er(c, l) {
|
|
3678
3676
|
return new e(c.hi >>> l, c.lo >>> l | c.hi << 32 - l);
|
|
3679
3677
|
}
|
|
3680
3678
|
function Rt() {
|
|
@@ -3687,27 +3685,27 @@ var C;
|
|
|
3687
3685
|
var u, f, m = 32 - l;
|
|
3688
3686
|
return l < 32 ? (u = c.hi >>> l | c.lo << m, f = c.lo >>> l | c.hi << m) : l < 64 && (u = c.lo >>> l | c.hi << m, f = c.hi >>> l | c.lo << m), new e(u, f);
|
|
3689
3687
|
}
|
|
3690
|
-
function
|
|
3688
|
+
function ui(c, l, u) {
|
|
3691
3689
|
var f = c.hi & l.hi ^ ~c.hi & u.hi, m = c.lo & l.lo ^ ~c.lo & u.lo;
|
|
3692
3690
|
return new e(f, m);
|
|
3693
3691
|
}
|
|
3694
|
-
function
|
|
3692
|
+
function li(c, l, u) {
|
|
3695
3693
|
var f = c.hi & l.hi ^ c.hi & u.hi ^ l.hi & u.hi, m = c.lo & l.lo ^ c.lo & u.lo ^ l.lo & u.lo;
|
|
3696
3694
|
return new e(f, m);
|
|
3697
3695
|
}
|
|
3698
|
-
function
|
|
3696
|
+
function fi(c) {
|
|
3699
3697
|
return Rt(Ie(c, 28), Ie(c, 34), Ie(c, 39));
|
|
3700
3698
|
}
|
|
3701
|
-
function
|
|
3699
|
+
function di(c) {
|
|
3702
3700
|
return Rt(Ie(c, 14), Ie(c, 18), Ie(c, 41));
|
|
3703
3701
|
}
|
|
3704
|
-
function
|
|
3705
|
-
return Rt(Ie(c, 1), Ie(c, 8),
|
|
3702
|
+
function pi(c) {
|
|
3703
|
+
return Rt(Ie(c, 1), Ie(c, 8), er(c, 7));
|
|
3706
3704
|
}
|
|
3707
|
-
function
|
|
3708
|
-
return Rt(Ie(c, 19), Ie(c, 61),
|
|
3705
|
+
function mi(c) {
|
|
3706
|
+
return Rt(Ie(c, 19), Ie(c, 61), er(c, 6));
|
|
3709
3707
|
}
|
|
3710
|
-
var
|
|
3708
|
+
var bi = [
|
|
3711
3709
|
new e(1116352408, 3609767458),
|
|
3712
3710
|
new e(1899447441, 602891725),
|
|
3713
3711
|
new e(3049323471, 3964484399),
|
|
@@ -3789,17 +3787,17 @@ var C;
|
|
|
3789
3787
|
new e(1607167915, 987167468),
|
|
3790
3788
|
new e(1816402316, 1246189591)
|
|
3791
3789
|
];
|
|
3792
|
-
function
|
|
3790
|
+
function tr(c, l, u) {
|
|
3793
3791
|
var f = [], m = [], b = [], E = [], v, g, S;
|
|
3794
3792
|
for (g = 0; g < 8; g++) f[g] = b[g] = J(c, 8 * g);
|
|
3795
3793
|
for (var M = 0; u >= 128; ) {
|
|
3796
3794
|
for (g = 0; g < 16; g++) E[g] = J(l, 8 * g + M);
|
|
3797
3795
|
for (g = 0; g < 80; g++) {
|
|
3798
3796
|
for (S = 0; S < 8; S++) m[S] = b[S];
|
|
3799
|
-
for (v = ct(b[7],
|
|
3797
|
+
for (v = ct(b[7], di(b[4]), ui(b[4], b[5], b[6]), bi[g], E[g % 16]), m[7] = ct(v, fi(b[0]), li(b[0], b[1], b[2])), m[3] = ct(m[3], v), S = 0; S < 8; S++) b[(S + 1) % 8] = m[S];
|
|
3800
3798
|
if (g % 16 === 15)
|
|
3801
3799
|
for (S = 0; S < 16; S++)
|
|
3802
|
-
E[S] = ct(E[S], E[(S + 9) % 16],
|
|
3800
|
+
E[S] = ct(E[S], E[(S + 9) % 16], pi(E[(S + 1) % 16]), mi(E[(S + 14) % 16]));
|
|
3803
3801
|
}
|
|
3804
3802
|
for (g = 0; g < 8; g++)
|
|
3805
3803
|
b[g] = ct(b[g], f[g]), f[g] = b[g];
|
|
@@ -3808,7 +3806,7 @@ var C;
|
|
|
3808
3806
|
for (g = 0; g < 8; g++) L(c, 8 * g, f[g]);
|
|
3809
3807
|
return u;
|
|
3810
3808
|
}
|
|
3811
|
-
var
|
|
3809
|
+
var gi = new Uint8Array([
|
|
3812
3810
|
106,
|
|
3813
3811
|
9,
|
|
3814
3812
|
230,
|
|
@@ -3876,29 +3874,29 @@ var C;
|
|
|
3876
3874
|
]);
|
|
3877
3875
|
function Je(c, l, u) {
|
|
3878
3876
|
var f = new Uint8Array(64), m = new Uint8Array(256), b, E = u;
|
|
3879
|
-
for (b = 0; b < 64; b++) f[b] =
|
|
3880
|
-
for (
|
|
3877
|
+
for (b = 0; b < 64; b++) f[b] = gi[b];
|
|
3878
|
+
for (tr(f, l, u), u %= 128, b = 0; b < 256; b++) m[b] = 0;
|
|
3881
3879
|
for (b = 0; b < u; b++) m[b] = l[E - u + b];
|
|
3882
|
-
for (m[u] = 128, u = 256 - 128 * (u < 112 ? 1 : 0), m[u - 9] = 0, L(m, u - 8, new e(E / 536870912 | 0, E << 3)),
|
|
3880
|
+
for (m[u] = 128, u = 256 - 128 * (u < 112 ? 1 : 0), m[u - 9] = 0, L(m, u - 8, new e(E / 536870912 | 0, E << 3)), tr(f, m, u), b = 0; b < 64; b++) c[b] = f[b];
|
|
3883
3881
|
return 0;
|
|
3884
3882
|
}
|
|
3885
3883
|
function Nt(c, l) {
|
|
3886
3884
|
var u = t(), f = t(), m = t(), b = t(), E = t(), v = t(), g = t(), S = t(), M = t();
|
|
3887
3885
|
Pe(u, c[1], c[0]), Pe(M, l[1], l[0]), B(u, u, M), Ae(f, c[0], c[1]), Ae(M, l[0], l[1]), B(f, f, M), B(m, c[3], l[3]), B(m, m, _), B(b, c[2], l[2]), Ae(b, b, b), Pe(E, f, u), Pe(v, b, m), Ae(g, b, m), Ae(S, f, u), B(c[0], E, v), B(c[1], S, g), B(c[2], g, v), B(c[3], E, S);
|
|
3888
3886
|
}
|
|
3889
|
-
function
|
|
3887
|
+
function sr(c, l, u) {
|
|
3890
3888
|
var f;
|
|
3891
3889
|
for (f = 0; f < 4; f++)
|
|
3892
3890
|
ie(c[f], l[f], u);
|
|
3893
3891
|
}
|
|
3894
3892
|
function ns(c, l) {
|
|
3895
3893
|
var u = t(), f = t(), m = t();
|
|
3896
|
-
|
|
3894
|
+
Ys(m, l[2]), B(u, l[0], m), B(f, l[1], m), Ve(c, f), c[31] ^= Ws(u) << 7;
|
|
3897
3895
|
}
|
|
3898
3896
|
function os(c, l, u) {
|
|
3899
3897
|
var f, m;
|
|
3900
3898
|
for (V(c[0], o), V(c[1], a), V(c[2], a), V(c[3], o), m = 255; m >= 0; --m)
|
|
3901
|
-
f = u[m / 8 | 0] >> (m & 7) & 1,
|
|
3899
|
+
f = u[m / 8 | 0] >> (m & 7) & 1, sr(c, l, f), Nt(l, c), Nt(c, c), sr(c, l, f);
|
|
3902
3900
|
}
|
|
3903
3901
|
function Tt(c, l) {
|
|
3904
3902
|
var u = [
|
|
@@ -3972,7 +3970,7 @@ var C;
|
|
|
3972
3970
|
for (u = 0; u < 64; u++) c[u] = 0;
|
|
3973
3971
|
cs(c, l);
|
|
3974
3972
|
}
|
|
3975
|
-
function
|
|
3973
|
+
function rr(c, l, u, f) {
|
|
3976
3974
|
var m = new Uint8Array(64), b = new Uint8Array(64), E = new Uint8Array(64), v, g, S = new Float64Array(64), M = [
|
|
3977
3975
|
t(),
|
|
3978
3976
|
t(),
|
|
@@ -3991,9 +3989,9 @@ var C;
|
|
|
3991
3989
|
S[v + g] += b[v] * m[g];
|
|
3992
3990
|
return cs(c.subarray(32), S), D;
|
|
3993
3991
|
}
|
|
3994
|
-
function
|
|
3992
|
+
function _i(c, l) {
|
|
3995
3993
|
var u = t(), f = t(), m = t(), b = t(), E = t(), v = t(), g = t();
|
|
3996
|
-
return V(c[2], a), is(c[1], l), we(m, c[1]), B(b, m, p), Pe(m, m, c[2]), Ae(b, c[2], b), we(E, b), we(v, E), B(g, v, E), B(u, g, m), B(u, u, b),
|
|
3994
|
+
return V(c[2], a), is(c[1], l), we(m, c[1]), B(b, m, p), Pe(m, m, c[2]), Ae(b, c[2], b), we(E, b), we(v, E), B(g, v, E), B(u, g, m), B(u, u, b), Xs(u, u), B(u, u, m), B(u, u, b), B(u, u, b), B(c[0], u, b), we(f, c[0]), B(f, f, b), Vs(f, m) && B(c[0], c[0], P), we(f, c[0]), B(f, f, b), Vs(f, m) ? -1 : (Ws(c[0]) === l[31] >> 7 && Pe(c[0], o, c[0]), B(c[3], c[0], c[1]), 0);
|
|
3997
3995
|
}
|
|
3998
3996
|
function us(c, l, u, f) {
|
|
3999
3997
|
var m, b = new Uint8Array(32), E = new Uint8Array(64), v = [
|
|
@@ -4007,7 +4005,7 @@ var C;
|
|
|
4007
4005
|
t(),
|
|
4008
4006
|
t()
|
|
4009
4007
|
];
|
|
4010
|
-
if (u < 64 ||
|
|
4008
|
+
if (u < 64 || _i(g, f)) return -1;
|
|
4011
4009
|
for (m = 0; m < u; m++) c[m] = l[m];
|
|
4012
4010
|
for (m = 0; m < 32; m++) c[m + 32] = f[m];
|
|
4013
4011
|
if (Je(E, c, u), hs(E), os(v, g, E), Tt(g, l.subarray(32)), Nt(v, g), ns(b, v), u -= 64, w(l, 0, b, 0)) {
|
|
@@ -4017,7 +4015,7 @@ var C;
|
|
|
4017
4015
|
for (m = 0; m < u; m++) c[m] = l[m + 64];
|
|
4018
4016
|
return u;
|
|
4019
4017
|
}
|
|
4020
|
-
var ls = 32, $t = 24, ht = 32, We = 16, ut = 32, Ut = 32, lt = 32, ft = 32, fs = 32,
|
|
4018
|
+
var ls = 32, $t = 24, ht = 32, We = 16, ut = 32, Ut = 32, lt = 32, ft = 32, fs = 32, ir = $t, yi = ht, wi = We, Te = 64, ze = 32, Ye = 64, ds = 32, ps = 64;
|
|
4021
4019
|
r.lowlevel = {
|
|
4022
4020
|
crypto_core_hsalsa20: R,
|
|
4023
4021
|
crypto_stream_xor: z,
|
|
@@ -4033,12 +4031,12 @@ var C;
|
|
|
4033
4031
|
crypto_scalarmult: Ct,
|
|
4034
4032
|
crypto_scalarmult_base: It,
|
|
4035
4033
|
crypto_box_beforenm: jt,
|
|
4036
|
-
crypto_box_afternm:
|
|
4037
|
-
crypto_box:
|
|
4038
|
-
crypto_box_open:
|
|
4039
|
-
crypto_box_keypair:
|
|
4034
|
+
crypto_box_afternm: Qs,
|
|
4035
|
+
crypto_box: ci,
|
|
4036
|
+
crypto_box_open: hi,
|
|
4037
|
+
crypto_box_keypair: Zs,
|
|
4040
4038
|
crypto_hash: Je,
|
|
4041
|
-
crypto_sign:
|
|
4039
|
+
crypto_sign: rr,
|
|
4042
4040
|
crypto_sign_keypair: as,
|
|
4043
4041
|
crypto_sign_open: us,
|
|
4044
4042
|
crypto_secretbox_KEYBYTES: ls,
|
|
@@ -4050,9 +4048,9 @@ var C;
|
|
|
4050
4048
|
crypto_box_PUBLICKEYBYTES: lt,
|
|
4051
4049
|
crypto_box_SECRETKEYBYTES: ft,
|
|
4052
4050
|
crypto_box_BEFORENMBYTES: fs,
|
|
4053
|
-
crypto_box_NONCEBYTES:
|
|
4054
|
-
crypto_box_ZEROBYTES:
|
|
4055
|
-
crypto_box_BOXZEROBYTES:
|
|
4051
|
+
crypto_box_NONCEBYTES: ir,
|
|
4052
|
+
crypto_box_ZEROBYTES: yi,
|
|
4053
|
+
crypto_box_BOXZEROBYTES: wi,
|
|
4056
4054
|
crypto_sign_BYTES: Te,
|
|
4057
4055
|
crypto_sign_PUBLICKEYBYTES: ze,
|
|
4058
4056
|
crypto_sign_SECRETKEYBYTES: Ye,
|
|
@@ -4067,18 +4065,18 @@ var C;
|
|
|
4067
4065
|
A: Ae,
|
|
4068
4066
|
S: we,
|
|
4069
4067
|
Z: Pe,
|
|
4070
|
-
pow2523:
|
|
4068
|
+
pow2523: Xs,
|
|
4071
4069
|
add: Nt,
|
|
4072
4070
|
set25519: V,
|
|
4073
4071
|
modL: cs,
|
|
4074
4072
|
scalarmult: os,
|
|
4075
4073
|
scalarbase: Tt
|
|
4076
4074
|
};
|
|
4077
|
-
function
|
|
4075
|
+
function nr(c, l) {
|
|
4078
4076
|
if (c.length !== ls) throw new Error("bad key size");
|
|
4079
4077
|
if (l.length !== $t) throw new Error("bad nonce size");
|
|
4080
4078
|
}
|
|
4081
|
-
function
|
|
4079
|
+
function xi(c, l) {
|
|
4082
4080
|
if (c.length !== lt) throw new Error("bad public key size");
|
|
4083
4081
|
if (l.length !== ft) throw new Error("bad secret key size");
|
|
4084
4082
|
}
|
|
@@ -4086,18 +4084,18 @@ var C;
|
|
|
4086
4084
|
for (var c = 0; c < arguments.length; c++)
|
|
4087
4085
|
if (!(arguments[c] instanceof Uint8Array)) throw new TypeError("unexpected type, use Uint8Array");
|
|
4088
4086
|
}
|
|
4089
|
-
function
|
|
4087
|
+
function or(c) {
|
|
4090
4088
|
for (var l = 0; l < c.length; l++) c[l] = 0;
|
|
4091
4089
|
}
|
|
4092
4090
|
r.randomBytes = function(c) {
|
|
4093
4091
|
var l = new Uint8Array(c);
|
|
4094
4092
|
return s(l, c), l;
|
|
4095
4093
|
}, r.secretbox = function(c, l, u) {
|
|
4096
|
-
pe(c, l, u),
|
|
4094
|
+
pe(c, l, u), nr(u, l);
|
|
4097
4095
|
for (var f = new Uint8Array(ht + c.length), m = new Uint8Array(f.length), b = 0; b < c.length; b++) f[b + ht] = c[b];
|
|
4098
4096
|
return ae(m, f, f.length, l, u), m.subarray(We);
|
|
4099
4097
|
}, r.secretbox.open = function(c, l, u) {
|
|
4100
|
-
pe(c, l, u),
|
|
4098
|
+
pe(c, l, u), nr(u, l);
|
|
4101
4099
|
for (var f = new Uint8Array(We + c.length), m = new Uint8Array(f.length), b = 0; b < c.length; b++) f[b + We] = c[b];
|
|
4102
4100
|
return f.length < 32 || ce(m, f, f.length, l, u) !== 0 ? null : m.subarray(ht);
|
|
4103
4101
|
}, r.secretbox.keyLength = ls, r.secretbox.nonceLength = $t, r.secretbox.overheadLength = We, r.scalarMult = function(c, l) {
|
|
@@ -4113,7 +4111,7 @@ var C;
|
|
|
4113
4111
|
var m = r.box.before(u, f);
|
|
4114
4112
|
return r.secretbox(c, l, m);
|
|
4115
4113
|
}, r.box.before = function(c, l) {
|
|
4116
|
-
pe(c, l),
|
|
4114
|
+
pe(c, l), xi(c, l);
|
|
4117
4115
|
var u = new Uint8Array(fs);
|
|
4118
4116
|
return jt(u, c, l), u;
|
|
4119
4117
|
}, r.box.after = r.secretbox, r.box.open = function(c, l, u, f) {
|
|
@@ -4121,7 +4119,7 @@ var C;
|
|
|
4121
4119
|
return r.secretbox.open(c, l, m);
|
|
4122
4120
|
}, r.box.open.after = r.secretbox.open, r.box.keyPair = function() {
|
|
4123
4121
|
var c = new Uint8Array(lt), l = new Uint8Array(ft);
|
|
4124
|
-
return
|
|
4122
|
+
return Zs(c, l), {
|
|
4125
4123
|
publicKey: c,
|
|
4126
4124
|
secretKey: l
|
|
4127
4125
|
};
|
|
@@ -4132,10 +4130,10 @@ var C;
|
|
|
4132
4130
|
publicKey: l,
|
|
4133
4131
|
secretKey: new Uint8Array(c)
|
|
4134
4132
|
};
|
|
4135
|
-
}, r.box.publicKeyLength = lt, r.box.secretKeyLength = ft, r.box.sharedKeyLength = fs, r.box.nonceLength =
|
|
4133
|
+
}, r.box.publicKeyLength = lt, r.box.secretKeyLength = ft, r.box.sharedKeyLength = fs, r.box.nonceLength = ir, r.box.overheadLength = r.secretbox.overheadLength, r.sign = function(c, l) {
|
|
4136
4134
|
if (pe(c, l), l.length !== Ye) throw new Error("bad secret key size");
|
|
4137
4135
|
var u = new Uint8Array(Te + c.length);
|
|
4138
|
-
return
|
|
4136
|
+
return rr(u, c, c.length, l), u;
|
|
4139
4137
|
}, r.sign.open = function(c, l) {
|
|
4140
4138
|
if (pe(c, l), l.length !== ze) throw new Error("bad public key size");
|
|
4141
4139
|
var u = new Uint8Array(c.length), f = us(u, c, c.length, l);
|
|
@@ -4189,26 +4187,26 @@ var C;
|
|
|
4189
4187
|
for (m = 0; m < f; m += l)
|
|
4190
4188
|
c.getRandomValues(b.subarray(m, m + Math.min(f - m, l)));
|
|
4191
4189
|
for (m = 0; m < f; m++) u[m] = b[m];
|
|
4192
|
-
|
|
4190
|
+
or(b);
|
|
4193
4191
|
});
|
|
4194
4192
|
} else typeof require < "u" && (c = require("crypto"), c && c.randomBytes && r.setPRNG(function(u, f) {
|
|
4195
4193
|
var m, b = c.randomBytes(f);
|
|
4196
4194
|
for (m = 0; m < f; m++) u[m] = b[m];
|
|
4197
|
-
|
|
4195
|
+
or(b);
|
|
4198
4196
|
}));
|
|
4199
4197
|
}();
|
|
4200
4198
|
})(typeof module < "u" && module.exports ? module.exports : globalThis.nacl = globalThis.nacl || {});
|
|
4201
4199
|
const Ft = typeof module < "u" && module.exports ? module.exports : globalThis.nacl;
|
|
4202
4200
|
Ft.sign.keyPair.fromSeed, Ft.sign.detached, Ft.sign.detached.verify, Ft.randomBytes;
|
|
4203
|
-
var
|
|
4201
|
+
var Pr;
|
|
4204
4202
|
(function(r) {
|
|
4205
4203
|
r.InvalidPrefixByte = "nkeys: invalid prefix byte", r.InvalidKey = "nkeys: invalid key", r.InvalidPublicKey = "nkeys: invalid public key", r.InvalidSeedLen = "nkeys: invalid seed length", r.InvalidSeed = "nkeys: invalid seed", r.InvalidEncoding = "nkeys: invalid encoded key", r.InvalidSignature = "nkeys: signature verification failed", r.CannotSign = "nkeys: cannot sign, no private key available", r.PublicKeyOnly = "nkeys: no seed or private key available", r.InvalidChecksum = "nkeys: invalid checksum", r.SerializationError = "nkeys: serialization error", r.ApiError = "nkeys: api error", r.ClearedPair = "nkeys: pair is cleared";
|
|
4206
|
-
})(
|
|
4207
|
-
var
|
|
4204
|
+
})(Pr || (Pr = {}));
|
|
4205
|
+
var Or;
|
|
4208
4206
|
(function(r) {
|
|
4209
4207
|
r[r.Seed = 144] = "Seed", r[r.Private = 120] = "Private", r[r.Operator = 112] = "Operator", r[r.Server = 104] = "Server", r[r.Cluster = 16] = "Cluster", r[r.Account = 0] = "Account", r[r.User = 160] = "User";
|
|
4210
|
-
})(
|
|
4211
|
-
function
|
|
4208
|
+
})(Or || (Or = {}));
|
|
4209
|
+
function Un(r) {
|
|
4212
4210
|
return (e) => {
|
|
4213
4211
|
let t = {};
|
|
4214
4212
|
return r.forEach((s) => {
|
|
@@ -4217,11 +4215,11 @@ function Mn(r) {
|
|
|
4217
4215
|
}), t;
|
|
4218
4216
|
};
|
|
4219
4217
|
}
|
|
4220
|
-
function
|
|
4218
|
+
function Ln() {
|
|
4221
4219
|
return () => {
|
|
4222
4220
|
};
|
|
4223
4221
|
}
|
|
4224
|
-
function
|
|
4222
|
+
function qn(r, e) {
|
|
4225
4223
|
return () => {
|
|
4226
4224
|
const t = typeof r == "function" ? r() : r, s = typeof e == "function" ? e() : e;
|
|
4227
4225
|
return {
|
|
@@ -4230,13 +4228,13 @@ function Un(r, e) {
|
|
|
4230
4228
|
};
|
|
4231
4229
|
};
|
|
4232
4230
|
}
|
|
4233
|
-
function
|
|
4231
|
+
function Fn(r) {
|
|
4234
4232
|
return () => ({
|
|
4235
4233
|
auth_token: typeof r == "function" ? r() : r
|
|
4236
4234
|
});
|
|
4237
4235
|
}
|
|
4238
|
-
const Yr = 2 * 60 * 1e3,
|
|
4239
|
-
function
|
|
4236
|
+
const Yr = 2 * 60 * 1e3, Bn = 2, Xr = 2 * 1e3;
|
|
4237
|
+
function Dn() {
|
|
4240
4238
|
return {
|
|
4241
4239
|
maxPingOut: 2,
|
|
4242
4240
|
maxReconnectAttempts: 10,
|
|
@@ -4253,12 +4251,12 @@ function Fn() {
|
|
|
4253
4251
|
ignoreAuthErrorAbort: !1
|
|
4254
4252
|
};
|
|
4255
4253
|
}
|
|
4256
|
-
function
|
|
4254
|
+
function Hn(r) {
|
|
4257
4255
|
const e = [];
|
|
4258
|
-
return typeof r.authenticator == "function" && e.push(r.authenticator), Array.isArray(r.authenticator) && e.push(...r.authenticator), r.token && e.push(
|
|
4256
|
+
return typeof r.authenticator == "function" && e.push(r.authenticator), Array.isArray(r.authenticator) && e.push(...r.authenticator), r.token && e.push(Fn(r.token)), r.user && e.push(qn(r.user, r.pass)), e.length === 0 ? Ln() : Un(e);
|
|
4259
4257
|
}
|
|
4260
|
-
function
|
|
4261
|
-
const e = `${
|
|
4258
|
+
function Jn(r) {
|
|
4259
|
+
const e = `${As}:${Kr()}`;
|
|
4262
4260
|
if (r = r || {
|
|
4263
4261
|
servers: [
|
|
4264
4262
|
e
|
|
@@ -4268,12 +4266,12 @@ function Dn(r) {
|
|
|
4268
4266
|
]), r.servers.length > 0 && r.port)
|
|
4269
4267
|
throw new N("port and servers options are mutually exclusive", O.InvalidOption);
|
|
4270
4268
|
r.servers.length === 0 && r.port && (r.servers = [
|
|
4271
|
-
`${
|
|
4269
|
+
`${As}:${r.port}`
|
|
4272
4270
|
]), r.servers && r.servers.length === 0 && (r.servers = [
|
|
4273
4271
|
e
|
|
4274
4272
|
]);
|
|
4275
|
-
const t = es(
|
|
4276
|
-
if (t.authenticator =
|
|
4273
|
+
const t = es(Dn(), r);
|
|
4274
|
+
if (t.authenticator = Hn(t), [
|
|
4277
4275
|
"reconnectDelayHandler",
|
|
4278
4276
|
"authenticator"
|
|
4279
4277
|
].forEach((s) => {
|
|
@@ -4288,11 +4286,11 @@ function Dn(r) {
|
|
|
4288
4286
|
} catch (s) {
|
|
4289
4287
|
throw new N(s.message, O.ApiError);
|
|
4290
4288
|
}
|
|
4291
|
-
if (t.resolve === void 0 && (t.resolve = typeof
|
|
4289
|
+
if (t.resolve === void 0 && (t.resolve = typeof Rs() == "function"), t.resolve && typeof Rs() != "function")
|
|
4292
4290
|
throw new N("'resolve' is not supported on this client", O.InvalidOption);
|
|
4293
4291
|
return t;
|
|
4294
4292
|
}
|
|
4295
|
-
function
|
|
4293
|
+
function zn(r, e) {
|
|
4296
4294
|
const { proto: t, tls_required: s, tls_available: i } = r;
|
|
4297
4295
|
if ((t === void 0 || t < 1) && e.noEcho)
|
|
4298
4296
|
throw new N("noEcho", O.ServerOptionNotAvailable);
|
|
@@ -4300,10 +4298,10 @@ function Hn(r, e) {
|
|
|
4300
4298
|
if (e.tls && !n)
|
|
4301
4299
|
throw new N("tls", O.ServerOptionNotAvailable);
|
|
4302
4300
|
}
|
|
4303
|
-
const
|
|
4304
|
-
`),
|
|
4301
|
+
const Gn = 1024 * 32, Kn = /^INFO\s+([^\r\n]+)\r\n/i, Vn = yt(`PONG\r
|
|
4302
|
+
`), kr = yt(`PING\r
|
|
4305
4303
|
`);
|
|
4306
|
-
class
|
|
4304
|
+
class Wn {
|
|
4307
4305
|
constructor(e, t, s) {
|
|
4308
4306
|
h(this, "echo");
|
|
4309
4307
|
h(this, "no_responders");
|
|
@@ -4412,7 +4410,7 @@ class Zr extends oe {
|
|
|
4412
4410
|
return this.sid;
|
|
4413
4411
|
}
|
|
4414
4412
|
}
|
|
4415
|
-
class
|
|
4413
|
+
class Yn {
|
|
4416
4414
|
constructor() {
|
|
4417
4415
|
h(this, "mux");
|
|
4418
4416
|
h(this, "subs");
|
|
@@ -4490,7 +4488,7 @@ class Zt {
|
|
|
4490
4488
|
h(this, "server");
|
|
4491
4489
|
h(this, "features");
|
|
4492
4490
|
h(this, "connectPromise");
|
|
4493
|
-
this._closed = !1, this.connected = !1, this.connectedOnce = !1, this.infoReceived = !1, this.noMorePublishing = !1, this.abortReconnect = !1, this.listeners = [], this.pendingLimit =
|
|
4491
|
+
this._closed = !1, this.connected = !1, this.connectedOnce = !1, this.infoReceived = !1, this.noMorePublishing = !1, this.abortReconnect = !1, this.listeners = [], this.pendingLimit = Gn, this.outMsgs = 0, this.inMsgs = 0, this.outBytes = 0, this.inBytes = 0, this.options = e, this.publisher = t, this.subscriptions = new Yn(), this.muxSubscriptions = new Rn(), this.outbound = new ot(), this.pongs = [], this.whyClosed = "", this.pendingLimit = e.pendingLimit || this.pendingLimit, this.features = new fn({
|
|
4494
4492
|
major: 0,
|
|
4495
4493
|
minor: 0,
|
|
4496
4494
|
micro: 0
|
|
@@ -4498,9 +4496,9 @@ class Zt {
|
|
|
4498
4496
|
const s = typeof e.servers == "string" ? [
|
|
4499
4497
|
e.servers
|
|
4500
4498
|
] : e.servers;
|
|
4501
|
-
this.servers = new
|
|
4499
|
+
this.servers = new jn(s, {
|
|
4502
4500
|
randomize: !e.noRandomize
|
|
4503
|
-
}), this.closed = K(), this.parser = new
|
|
4501
|
+
}), this.closed = K(), this.parser = new Ar(this), this.heartbeats = new Nn(this, this.options.pingInterval || Yr, this.options.maxPingOut || Bn);
|
|
4504
4502
|
}
|
|
4505
4503
|
resetOutbound() {
|
|
4506
4504
|
this.outbound.reset();
|
|
@@ -4509,7 +4507,7 @@ class Zt {
|
|
|
4509
4507
|
const t = N.errorForCode(O.Disconnect);
|
|
4510
4508
|
t.stack = "", e.forEach((s) => {
|
|
4511
4509
|
s.reject(t);
|
|
4512
|
-
}), this.parser = new
|
|
4510
|
+
}), this.parser = new Ar(this), this.infoReceived = !1;
|
|
4513
4511
|
}
|
|
4514
4512
|
dispatchStatus(e) {
|
|
4515
4513
|
this.listeners.forEach((t) => {
|
|
@@ -4526,7 +4524,7 @@ class Zt {
|
|
|
4526
4524
|
return e.catch(() => {
|
|
4527
4525
|
}), this.pongs.unshift(e), this.connectError = (t) => {
|
|
4528
4526
|
e.reject(t);
|
|
4529
|
-
}, this.transport =
|
|
4527
|
+
}, this.transport = mn(), this.transport.closed().then(async (t) => {
|
|
4530
4528
|
if (this.connected = !1, !this.isClosed()) {
|
|
4531
4529
|
await this.disconnected(this.transport.closeError || this.lastError);
|
|
4532
4530
|
return;
|
|
@@ -4590,7 +4588,7 @@ class Zt {
|
|
|
4590
4588
|
}
|
|
4591
4589
|
async _doDial(e) {
|
|
4592
4590
|
const { resolve: t } = this.options, s = await e.resolve({
|
|
4593
|
-
fn:
|
|
4591
|
+
fn: Rs(),
|
|
4594
4592
|
debug: this.options.debug,
|
|
4595
4593
|
randomize: !this.options.noRandomize,
|
|
4596
4594
|
resolve: t
|
|
@@ -4668,10 +4666,10 @@ class Zt {
|
|
|
4668
4666
|
if (this.inMsgs++, this.inBytes += t.length, !this.subscriptions.sidCounter)
|
|
4669
4667
|
return;
|
|
4670
4668
|
const s = this.subscriptions.get(e.sid);
|
|
4671
|
-
s && (s.received += 1, s.callback && s.callback(null, new
|
|
4669
|
+
s && (s.received += 1, s.callback && s.callback(null, new Ds(e, t, this)), s.max !== void 0 && s.received >= s.max && s.unsubscribe());
|
|
4672
4670
|
}
|
|
4673
4671
|
processError(e) {
|
|
4674
|
-
const t =
|
|
4672
|
+
const t = hr(e), s = Zt.toError(t), i = {
|
|
4675
4673
|
type: Ee.Error,
|
|
4676
4674
|
data: s.code
|
|
4677
4675
|
};
|
|
@@ -4693,27 +4691,27 @@ class Zt {
|
|
|
4693
4691
|
this.lastError && e.code === this.lastError.code && this.options.ignoreAuthErrorAbort === !1 && (this.abortReconnect = !0), this.connectError ? this.connectError(e) : this.disconnect();
|
|
4694
4692
|
}
|
|
4695
4693
|
processPing() {
|
|
4696
|
-
this.transport.send(
|
|
4694
|
+
this.transport.send(Vn);
|
|
4697
4695
|
}
|
|
4698
4696
|
processPong() {
|
|
4699
4697
|
const e = this.pongs.shift();
|
|
4700
4698
|
e && e.resolve();
|
|
4701
4699
|
}
|
|
4702
4700
|
processInfo(e) {
|
|
4703
|
-
const t = JSON.parse(
|
|
4701
|
+
const t = JSON.parse(hr(e));
|
|
4704
4702
|
this.info = t;
|
|
4705
4703
|
const s = this.options && this.options.ignoreClusterUpdates ? void 0 : this.servers.update(t, this.transport.isEncrypted());
|
|
4706
4704
|
if (!this.infoReceived) {
|
|
4707
4705
|
this.features.update(Ge(t.version)), this.infoReceived = !0, this.transport.isEncrypted() && this.servers.updateTLSName();
|
|
4708
4706
|
const { version: n, lang: o } = this.transport;
|
|
4709
4707
|
try {
|
|
4710
|
-
const a = new
|
|
4708
|
+
const a = new Wn({
|
|
4711
4709
|
version: n,
|
|
4712
4710
|
lang: o
|
|
4713
4711
|
}, this.options, t.nonce);
|
|
4714
4712
|
t.headers && (a.headers = !0, a.no_responders = !0);
|
|
4715
4713
|
const d = JSON.stringify(a);
|
|
4716
|
-
this.transport.send(yt(`CONNECT ${d}${Ht}`)), this.transport.send(
|
|
4714
|
+
this.transport.send(yt(`CONNECT ${d}${Ht}`)), this.transport.send(kr);
|
|
4717
4715
|
} catch (a) {
|
|
4718
4716
|
this._close(a);
|
|
4719
4717
|
}
|
|
@@ -4808,7 +4806,7 @@ class Zt {
|
|
|
4808
4806
|
!e || this.isClosed() || (this.unsub(e), e.subject = t, this.subscriptions.resub(e), this._sub(e));
|
|
4809
4807
|
}
|
|
4810
4808
|
flush(e) {
|
|
4811
|
-
return e || (e = K()), this.pongs.push(e), this.outbound.fill(
|
|
4809
|
+
return e || (e = K()), this.pongs.push(e), this.outbound.fill(kr), this.flushPending(), e;
|
|
4812
4810
|
}
|
|
4813
4811
|
sendSubscriptions() {
|
|
4814
4812
|
const e = [];
|
|
@@ -4856,8 +4854,8 @@ class Zt {
|
|
|
4856
4854
|
return this.server;
|
|
4857
4855
|
}
|
|
4858
4856
|
}
|
|
4859
|
-
const
|
|
4860
|
-
class
|
|
4857
|
+
const Xn = "$SRV";
|
|
4858
|
+
class Cr {
|
|
4861
4859
|
constructor(e) {
|
|
4862
4860
|
h(this, "msg");
|
|
4863
4861
|
this.msg = e;
|
|
@@ -4896,7 +4894,7 @@ class vt {
|
|
|
4896
4894
|
h(this, "subject");
|
|
4897
4895
|
h(this, "queue");
|
|
4898
4896
|
h(this, "srv");
|
|
4899
|
-
t !== "" &&
|
|
4897
|
+
t !== "" && Qn("service group", t);
|
|
4900
4898
|
let i = "";
|
|
4901
4899
|
if (e instanceof kt)
|
|
4902
4900
|
this.srv = e, i = "";
|
|
@@ -4920,7 +4918,7 @@ class vt {
|
|
|
4920
4918
|
} : t;
|
|
4921
4919
|
gt("endpoint", e);
|
|
4922
4920
|
let { subject: i, handler: n, metadata: o, queue: a } = s;
|
|
4923
|
-
i = i || e, a = a || this.queue,
|
|
4921
|
+
i = i || e, a = a || this.queue, Zn("endpoint subject", i), i = this.calcSubject(this.subject, i);
|
|
4924
4922
|
const d = {
|
|
4925
4923
|
name: e,
|
|
4926
4924
|
subject: i,
|
|
@@ -4934,7 +4932,7 @@ class vt {
|
|
|
4934
4932
|
return new vt(this, e, t);
|
|
4935
4933
|
}
|
|
4936
4934
|
}
|
|
4937
|
-
function
|
|
4935
|
+
function Zn(r, e) {
|
|
4938
4936
|
if (e === "")
|
|
4939
4937
|
throw new Error(`${r} cannot be empty`);
|
|
4940
4938
|
if (e.indexOf(" ") !== -1)
|
|
@@ -4945,7 +4943,7 @@ function Yn(r, e) {
|
|
|
4945
4943
|
throw new Error(`${r} cannot have internal '>': '${e}'`);
|
|
4946
4944
|
});
|
|
4947
4945
|
}
|
|
4948
|
-
function
|
|
4946
|
+
function Qn(r, e) {
|
|
4949
4947
|
if (e.indexOf(" ") !== -1)
|
|
4950
4948
|
throw new Error(`${r} cannot contain spaces: '${e}'`);
|
|
4951
4949
|
e.split(".").forEach((s) => {
|
|
@@ -4973,7 +4971,7 @@ class kt {
|
|
|
4973
4971
|
});
|
|
4974
4972
|
}
|
|
4975
4973
|
static controlSubject(e, t = "", s = "", i) {
|
|
4976
|
-
const n = i ??
|
|
4974
|
+
const n = i ?? Xn;
|
|
4977
4975
|
return t === "" && s === "" ? `${n}.${e}` : (gt("control subject name", t), s !== "" ? (gt("control subject id", s), `${n}.${e}.${t}.${s}`) : `${n}.${e}.${t}`);
|
|
4978
4976
|
}
|
|
4979
4977
|
get subjects() {
|
|
@@ -5005,7 +5003,7 @@ class kt {
|
|
|
5005
5003
|
}
|
|
5006
5004
|
setupHandler(e, t = !1) {
|
|
5007
5005
|
const s = t ? "" : e.queue ? e.queue : this.config.queue, { name: i, subject: n, handler: o } = e, a = e;
|
|
5008
|
-
a.internal = t, t && this.internal.push(a), a.stats = new
|
|
5006
|
+
a.internal = t, t && this.internal.push(a), a.stats = new eo(i, n, s), a.queue = s;
|
|
5009
5007
|
const d = o ? (p, _) => {
|
|
5010
5008
|
if (p) {
|
|
5011
5009
|
this.close(p);
|
|
@@ -5013,7 +5011,7 @@ class kt {
|
|
|
5013
5011
|
}
|
|
5014
5012
|
const y = Date.now();
|
|
5015
5013
|
try {
|
|
5016
|
-
o(p, new
|
|
5014
|
+
o(p, new Cr(_));
|
|
5017
5015
|
} catch (x) {
|
|
5018
5016
|
a.stats.countError(x), _ == null || _.respond(ye, {
|
|
5019
5017
|
headers: this.errorToHeader(x)
|
|
@@ -5133,7 +5131,7 @@ class kt {
|
|
|
5133
5131
|
_addEndpoint(e) {
|
|
5134
5132
|
const t = new oe();
|
|
5135
5133
|
t.noIterator = typeof e.handler == "function", t.noIterator || (e.handler = (i, n) => {
|
|
5136
|
-
i ? this.stop(i).catch() : t.push(new
|
|
5134
|
+
i ? this.stop(i).catch() : t.push(new Cr(n));
|
|
5137
5135
|
}, t.iterClosed.then(() => {
|
|
5138
5136
|
this.close().catch();
|
|
5139
5137
|
}));
|
|
@@ -5141,7 +5139,7 @@ class kt {
|
|
|
5141
5139
|
return s.qi = t, this.handlers.push(s), t;
|
|
5142
5140
|
}
|
|
5143
5141
|
}
|
|
5144
|
-
class
|
|
5142
|
+
class eo {
|
|
5145
5143
|
constructor(e, t, s = "") {
|
|
5146
5144
|
h(this, "name");
|
|
5147
5145
|
h(this, "subject");
|
|
@@ -5185,7 +5183,7 @@ class Zn {
|
|
|
5185
5183
|
return (t == null ? void 0 : t.noIterator) === !1 && (this.processing_time = G(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();
|
|
5186
5184
|
}
|
|
5187
5185
|
}
|
|
5188
|
-
class
|
|
5186
|
+
class to {
|
|
5189
5187
|
constructor(e, t = {
|
|
5190
5188
|
strategy: Ce.JitterTimer,
|
|
5191
5189
|
maxWait: 2e3
|
|
@@ -5244,7 +5242,7 @@ function Qr() {
|
|
|
5244
5242
|
}
|
|
5245
5243
|
};
|
|
5246
5244
|
}
|
|
5247
|
-
function
|
|
5245
|
+
function so() {
|
|
5248
5246
|
return {
|
|
5249
5247
|
replicas: 1,
|
|
5250
5248
|
history: 1,
|
|
@@ -5252,19 +5250,19 @@ function eo() {
|
|
|
5252
5250
|
max_bytes: -1,
|
|
5253
5251
|
maxValueSize: -1,
|
|
5254
5252
|
codec: Qr(),
|
|
5255
|
-
storage:
|
|
5253
|
+
storage: Cs.File
|
|
5256
5254
|
};
|
|
5257
5255
|
}
|
|
5258
|
-
const Qt = "KV-Operation",
|
|
5259
|
-
function
|
|
5260
|
-
if (r.startsWith(".") || r.endsWith(".") || !
|
|
5256
|
+
const Qt = "KV-Operation", Ir = "$KV", ro = /^[-/=.\w]+$/, io = /^[-/=.>*\w]+$/, no = /^[-\w]+$/;
|
|
5257
|
+
function oo(r) {
|
|
5258
|
+
if (r.startsWith(".") || r.endsWith(".") || !ro.test(r))
|
|
5261
5259
|
throw new Error(`invalid key: ${r}`);
|
|
5262
5260
|
}
|
|
5263
|
-
function
|
|
5264
|
-
if (r.startsWith(".") || r.endsWith(".") || !
|
|
5261
|
+
function ao(r) {
|
|
5262
|
+
if (r.startsWith(".") || r.endsWith(".") || !io.test(r))
|
|
5265
5263
|
throw new Error(`invalid key: ${r}`);
|
|
5266
5264
|
}
|
|
5267
|
-
function
|
|
5265
|
+
function co(r) {
|
|
5268
5266
|
if (r.startsWith(".") || r.endsWith("."))
|
|
5269
5267
|
throw new Error(`invalid key: ${r}`);
|
|
5270
5268
|
const e = r.split(".");
|
|
@@ -5283,7 +5281,7 @@ function oo(r) {
|
|
|
5283
5281
|
return t;
|
|
5284
5282
|
}
|
|
5285
5283
|
function Jt(r) {
|
|
5286
|
-
if (!
|
|
5284
|
+
if (!no.test(r))
|
|
5287
5285
|
throw new Error(`invalid bucket name: ${r}`);
|
|
5288
5286
|
}
|
|
5289
5287
|
var Re;
|
|
@@ -5302,10 +5300,10 @@ class At {
|
|
|
5302
5300
|
h(this, "editPrefix");
|
|
5303
5301
|
h(this, "useJsPrefix");
|
|
5304
5302
|
h(this, "_prefixLen");
|
|
5305
|
-
h(this, "validateKey",
|
|
5306
|
-
h(this, "validateSearchKey",
|
|
5307
|
-
h(this, "hasWildcards",
|
|
5308
|
-
Jt(e), this.js = t, this.jsm = s, this.bucket = e, this.prefix =
|
|
5303
|
+
h(this, "validateKey", oo);
|
|
5304
|
+
h(this, "validateSearchKey", ao);
|
|
5305
|
+
h(this, "hasWildcards", co);
|
|
5306
|
+
Jt(e), this.js = t, this.jsm = s, this.bucket = e, this.prefix = Ir, this.editPrefix = "", this.useJsPrefix = !1, this._prefixLen = 0;
|
|
5309
5307
|
}
|
|
5310
5308
|
static async create(e, t, s = {}) {
|
|
5311
5309
|
Jt(t);
|
|
@@ -5323,10 +5321,10 @@ class At {
|
|
|
5323
5321
|
return n.config.name = s.streamName ?? o.bucketName(), Object.assign(o, n), o.stream = n.config.name, o.codec = s.codec || Qr(), o.direct = n.config.allow_direct ?? !1, o.initializePrefixes(n), o;
|
|
5324
5322
|
}
|
|
5325
5323
|
async init(e = {}) {
|
|
5326
|
-
const t = Object.assign(
|
|
5324
|
+
const t = Object.assign(so(), e);
|
|
5327
5325
|
this.codec = t.codec;
|
|
5328
5326
|
const s = {};
|
|
5329
|
-
this.stream = s.name = e.streamName ?? this.bucketName(), s.retention =
|
|
5327
|
+
this.stream = s.name = e.streamName ?? this.bucketName(), s.retention = ks.Limits, s.max_msgs_per_subject = t.history, t.maxBucketSize && (t.max_bytes = t.maxBucketSize), t.max_bytes && (s.max_bytes = t.max_bytes), s.max_msg_size = t.maxValueSize, s.storage = t.storage;
|
|
5330
5328
|
const i = e.placementCluster ?? "";
|
|
5331
5329
|
if (i && (e.placement = {}, e.placement.cluster = i, e.placement.tags = []), e.placement && (s.placement = e.placement), e.republish && (s.republish = e.republish), e.description && (s.description = e.description), e.mirror) {
|
|
5332
5330
|
const y = Object.assign({}, e.mirror);
|
|
@@ -5349,7 +5347,7 @@ class At {
|
|
|
5349
5347
|
this.subjectForBucket()
|
|
5350
5348
|
];
|
|
5351
5349
|
e.metadata && (s.metadata = e.metadata), typeof e.compression == "boolean" && (s.compression = e.compression ? He.S2 : He.None);
|
|
5352
|
-
const n = this.js.nc, o = n.getServerVersion(), a = o ?
|
|
5350
|
+
const n = this.js.nc, o = n.getServerVersion(), a = o ? js(o, Ge("2.7.2")) >= 0 : !1;
|
|
5353
5351
|
s.discard = a ? Et.New : Et.Old;
|
|
5354
5352
|
const { ok: d, min: p } = n.features.get(H.JS_ALLOW_DIRECT);
|
|
5355
5353
|
if (!d && e.allow_direct === !0) {
|
|
@@ -5391,7 +5389,7 @@ class At {
|
|
|
5391
5389
|
return t ? (this.useJsPrefix && s.push(this.js.apiPrefix), this.editPrefix !== "" ? s.push(this.editPrefix) : s.push(this.prefix)) : this.prefix && s.push(this.prefix), s.push(e), s.join(".");
|
|
5392
5390
|
}
|
|
5393
5391
|
fullKeyName(e) {
|
|
5394
|
-
return this.prefix !== "" ? `${this.prefix}.${e}` : `${
|
|
5392
|
+
return this.prefix !== "" ? `${this.prefix}.${e}` : `${Ir}.${this.bucket}.${e}`;
|
|
5395
5393
|
}
|
|
5396
5394
|
get prefixLen() {
|
|
5397
5395
|
return this._prefixLen === 0 && (this._prefixLen = this.prefix.length + 1), this._prefixLen;
|
|
@@ -5432,11 +5430,11 @@ class At {
|
|
|
5432
5430
|
return s !== "" ? parseInt(s, 10) : e.length;
|
|
5433
5431
|
}
|
|
5434
5432
|
smToEntry(e) {
|
|
5435
|
-
return new
|
|
5433
|
+
return new vo(this.bucket, this.prefixLen, e);
|
|
5436
5434
|
}
|
|
5437
5435
|
jmToEntry(e) {
|
|
5438
5436
|
const t = this.decodeKey(e.subject.substring(this.prefixLen));
|
|
5439
|
-
return new
|
|
5437
|
+
return new Ao(this.bucket, t, e);
|
|
5440
5438
|
}
|
|
5441
5439
|
async create(e, t) {
|
|
5442
5440
|
var n;
|
|
@@ -5707,7 +5705,7 @@ class ei {
|
|
|
5707
5705
|
return this.si.config.max_msgs_per_subject;
|
|
5708
5706
|
}
|
|
5709
5707
|
get ttl() {
|
|
5710
|
-
return
|
|
5708
|
+
return Bs(this.si.config.max_age);
|
|
5711
5709
|
}
|
|
5712
5710
|
get bucket_location() {
|
|
5713
5711
|
return this.cluster;
|
|
@@ -5762,21 +5760,21 @@ class ei {
|
|
|
5762
5760
|
return this.si.config.compression ? this.si.config.compression !== He.None : !1;
|
|
5763
5761
|
}
|
|
5764
5762
|
}
|
|
5765
|
-
const
|
|
5766
|
-
function
|
|
5767
|
-
return Jt(r), `${
|
|
5763
|
+
const Js = "OBJ_", jr = "SHA-256=";
|
|
5764
|
+
function ho(r) {
|
|
5765
|
+
return Jt(r), `${Js}${r}`;
|
|
5768
5766
|
}
|
|
5769
|
-
function
|
|
5770
|
-
return r.startsWith(
|
|
5767
|
+
function uo(r) {
|
|
5768
|
+
return r.startsWith(Js) ? r.substring(4) : r;
|
|
5771
5769
|
}
|
|
5772
|
-
class
|
|
5770
|
+
class Ms {
|
|
5773
5771
|
constructor(e) {
|
|
5774
5772
|
h(this, "si");
|
|
5775
5773
|
h(this, "backingStore");
|
|
5776
5774
|
this.si = e, this.backingStore = "JetStream";
|
|
5777
5775
|
}
|
|
5778
5776
|
get bucket() {
|
|
5779
|
-
return
|
|
5777
|
+
return uo(this.si.config.name);
|
|
5780
5778
|
}
|
|
5781
5779
|
get description() {
|
|
5782
5780
|
return this.si.config.description ?? "";
|
|
@@ -5833,9 +5831,9 @@ var rt;
|
|
|
5833
5831
|
(function(r) {
|
|
5834
5832
|
r.DebugEvent = "debug", r.Discard = "discard", r.Reset = "reset", r.Next = "next";
|
|
5835
5833
|
})(rt || (rt = {}));
|
|
5836
|
-
const
|
|
5834
|
+
const Rr = Uint8Array.of(43, 65, 67, 75), lo = Uint8Array.of(45, 78, 65, 75), bt = Uint8Array.of(43, 87, 80, 73), fo = Uint8Array.of(43, 78, 88, 84), po = Uint8Array.of(43, 84, 69, 82, 77), mo = Uint8Array.of(32);
|
|
5837
5835
|
function Pt(r, e = 5e3) {
|
|
5838
|
-
return new
|
|
5836
|
+
return new Ro(r, e);
|
|
5839
5837
|
}
|
|
5840
5838
|
class Es extends oe {
|
|
5841
5839
|
constructor(t, s, i = !1) {
|
|
@@ -5884,7 +5882,7 @@ class Es extends oe {
|
|
|
5884
5882
|
return;
|
|
5885
5883
|
}
|
|
5886
5884
|
if ((y = this.monitor) == null || y.work(), p.subject === this.inbox) {
|
|
5887
|
-
if (
|
|
5885
|
+
if (Os(p))
|
|
5888
5886
|
return;
|
|
5889
5887
|
const T = (x = p.headers) == null ? void 0 : x.code, J = ((I = (P = p.headers) == null ? void 0 : P.description) == null ? void 0 : I.toLowerCase()) || "unknown", { msgsLeft: X, bytesLeft: L } = this.parseDiscard(p.headers);
|
|
5890
5888
|
if (X > 0 || L > 0)
|
|
@@ -5924,7 +5922,7 @@ class Es extends oe {
|
|
|
5924
5922
|
this.sub.draining && this._push(() => {
|
|
5925
5923
|
this.stop();
|
|
5926
5924
|
});
|
|
5927
|
-
}), i && (this.monitor = new
|
|
5925
|
+
}), i && (this.monitor = new Hs(i, (d) => (this.notify(Ne.HeartbeatsMissed, d), this.resetPending().then(() => {
|
|
5928
5926
|
}).catch(() => {
|
|
5929
5927
|
}), !1), {
|
|
5930
5928
|
maxOut: 2
|
|
@@ -5977,7 +5975,7 @@ class Es extends oe {
|
|
|
5977
5975
|
if (this.inBackOff)
|
|
5978
5976
|
return !1;
|
|
5979
5977
|
let t = 0, s = 0;
|
|
5980
|
-
const i =
|
|
5978
|
+
const i = Fs([
|
|
5981
5979
|
this.opts.expires
|
|
5982
5980
|
]);
|
|
5983
5981
|
let n = 0;
|
|
@@ -6083,7 +6081,7 @@ class Es extends oe {
|
|
|
6083
6081
|
return this.listeners.push(t), Promise.resolve(t);
|
|
6084
6082
|
}
|
|
6085
6083
|
}
|
|
6086
|
-
class
|
|
6084
|
+
class bo extends oe {
|
|
6087
6085
|
constructor() {
|
|
6088
6086
|
super();
|
|
6089
6087
|
h(this, "src");
|
|
@@ -6125,7 +6123,7 @@ class po extends oe {
|
|
|
6125
6123
|
return this.listeners.push(t), Promise.resolve(t);
|
|
6126
6124
|
}
|
|
6127
6125
|
}
|
|
6128
|
-
class
|
|
6126
|
+
class $s {
|
|
6129
6127
|
constructor(e, t) {
|
|
6130
6128
|
h(this, "api");
|
|
6131
6129
|
h(this, "_info");
|
|
@@ -6192,7 +6190,7 @@ class Us {
|
|
|
6192
6190
|
return this.api.info(t, s).then((i) => (this._info = i, this._info));
|
|
6193
6191
|
}
|
|
6194
6192
|
}
|
|
6195
|
-
class
|
|
6193
|
+
class go {
|
|
6196
6194
|
constructor(e, t, s = {}) {
|
|
6197
6195
|
h(this, "api");
|
|
6198
6196
|
h(this, "consumerOpts");
|
|
@@ -6235,7 +6233,7 @@ class mo {
|
|
|
6235
6233
|
}), e = e === 0 ? 1 : e, this.cursor.deliver_seq = 0;
|
|
6236
6234
|
const s = this.getConsumerOpts(e);
|
|
6237
6235
|
s.max_deliver = 1, s.mem_storage = !0;
|
|
6238
|
-
const i =
|
|
6236
|
+
const i = Fs([
|
|
6239
6237
|
((a = this.opts) == null ? void 0 : a.expires) || 3e4
|
|
6240
6238
|
]);
|
|
6241
6239
|
let n;
|
|
@@ -6276,7 +6274,7 @@ class mo {
|
|
|
6276
6274
|
(d = this.iter) == null || d.src.stop(), await ((p = this.iter) == null ? void 0 : p.closed()), this.currentConsumer = null;
|
|
6277
6275
|
return;
|
|
6278
6276
|
}
|
|
6279
|
-
(this.currentConsumer === null || i) && (this.currentConsumer = await this.resetConsumer(this.cursor.stream_seq + 1)), (this.iter === null || s) && (this.iter = new
|
|
6277
|
+
(this.currentConsumer === null || i) && (this.currentConsumer = await this.resetConsumer(this.cursor.stream_seq + 1)), (this.iter === null || s) && (this.iter = new bo()), this.consumer = new $s(this.api, this.currentConsumer);
|
|
6280
6278
|
const n = e;
|
|
6281
6279
|
n.callback = this.internalHandler(this.serial);
|
|
6282
6280
|
let o = null;
|
|
@@ -6346,7 +6344,7 @@ class mo {
|
|
|
6346
6344
|
return this.currentConsumer == null ? (this.currentConsumer = await this.resetConsumer(this.startSeq), Promise.resolve(this.currentConsumer)) : e && this.currentConsumer ? Promise.resolve(this.currentConsumer) : this.api.info(this.stream, this.currentConsumer.name);
|
|
6347
6345
|
}
|
|
6348
6346
|
}
|
|
6349
|
-
class
|
|
6347
|
+
class Us {
|
|
6350
6348
|
constructor(e) {
|
|
6351
6349
|
h(this, "api");
|
|
6352
6350
|
h(this, "notified");
|
|
@@ -6359,15 +6357,15 @@ class Ls {
|
|
|
6359
6357
|
getPullConsumerFor(e) {
|
|
6360
6358
|
if (e.config.deliver_subject !== void 0)
|
|
6361
6359
|
throw new Error("push consumer not supported");
|
|
6362
|
-
return new
|
|
6360
|
+
return new $s(this.api, e);
|
|
6363
6361
|
}
|
|
6364
6362
|
async get(e, t = {}) {
|
|
6365
|
-
return typeof t == "object" ? this.ordered(e, t) : (await this.checkVersion(), this.api.info(e, t).then((s) => s.config.deliver_subject !== void 0 ? Promise.reject(new Error("push consumer not supported")) : new
|
|
6363
|
+
return typeof t == "object" ? this.ordered(e, t) : (await this.checkVersion(), this.api.info(e, t).then((s) => s.config.deliver_subject !== void 0 ? Promise.reject(new Error("push consumer not supported")) : new $s(this.api, s)).catch((s) => Promise.reject(s)));
|
|
6366
6364
|
}
|
|
6367
6365
|
async ordered(e, t) {
|
|
6368
6366
|
await this.checkVersion();
|
|
6369
6367
|
const s = this.api;
|
|
6370
|
-
return new
|
|
6368
|
+
return new zs(s.nc, s.opts).info(e).then((n) => Promise.resolve(new go(this.api, e, t))).catch((n) => Promise.reject(n));
|
|
6371
6369
|
}
|
|
6372
6370
|
}
|
|
6373
6371
|
class rs {
|
|
@@ -6393,10 +6391,10 @@ class rs {
|
|
|
6393
6391
|
return e ? Promise.resolve(this._info) : this.api.info(this.name, t).then((s) => (this._info = s, this._info));
|
|
6394
6392
|
}
|
|
6395
6393
|
getConsumerFromInfo(e) {
|
|
6396
|
-
return new
|
|
6394
|
+
return new Us(new Yt(this.api.nc, this.api.opts)).getPullConsumerFor(e);
|
|
6397
6395
|
}
|
|
6398
6396
|
getConsumer(e) {
|
|
6399
|
-
return new
|
|
6397
|
+
return new Us(new Yt(this.api.nc, this.api.opts)).get(this.name, e);
|
|
6400
6398
|
}
|
|
6401
6399
|
getMessage(e) {
|
|
6402
6400
|
return this.api.getMessage(this.name, e);
|
|
@@ -6405,7 +6403,7 @@ class rs {
|
|
|
6405
6403
|
return this.api.deleteMessage(this.name, e, t);
|
|
6406
6404
|
}
|
|
6407
6405
|
}
|
|
6408
|
-
class
|
|
6406
|
+
class zs extends Ot {
|
|
6409
6407
|
constructor(e, t) {
|
|
6410
6408
|
super(e, t);
|
|
6411
6409
|
}
|
|
@@ -6544,10 +6542,10 @@ class Gs extends Ot {
|
|
|
6544
6542
|
}
|
|
6545
6543
|
listObjectStores() {
|
|
6546
6544
|
const e = (s) => {
|
|
6547
|
-
const n = s.streams.filter((a) => a.config.name.startsWith(
|
|
6545
|
+
const n = s.streams.filter((a) => a.config.name.startsWith(Js));
|
|
6548
6546
|
return n.forEach((a) => {
|
|
6549
6547
|
this._fixInfo(a);
|
|
6550
|
-
}), n.map((a) => new
|
|
6548
|
+
}), n.map((a) => new Ms(a));
|
|
6551
6549
|
}, t = `${this.prefix}.STREAM.LIST`;
|
|
6552
6550
|
return new _t(t, e, this);
|
|
6553
6551
|
}
|
|
@@ -6562,7 +6560,7 @@ class Gs extends Ot {
|
|
|
6562
6560
|
return Promise.resolve(new rs(this, t));
|
|
6563
6561
|
}
|
|
6564
6562
|
}
|
|
6565
|
-
class
|
|
6563
|
+
class _o extends Ot {
|
|
6566
6564
|
constructor(e, t) {
|
|
6567
6565
|
super(e, t);
|
|
6568
6566
|
}
|
|
@@ -6576,7 +6574,7 @@ class bo extends Ot {
|
|
|
6576
6574
|
}), p = tt(d);
|
|
6577
6575
|
if (p)
|
|
6578
6576
|
return Promise.reject(p);
|
|
6579
|
-
const _ = new
|
|
6577
|
+
const _ = new Ls(d);
|
|
6580
6578
|
return Promise.resolve(_);
|
|
6581
6579
|
}
|
|
6582
6580
|
async getBatch(e, t) {
|
|
@@ -6605,7 +6603,7 @@ class bo extends Ot {
|
|
|
6605
6603
|
}
|
|
6606
6604
|
if (I.data.length === 0)
|
|
6607
6605
|
break;
|
|
6608
|
-
o.push(new
|
|
6606
|
+
o.push(new Ls(I));
|
|
6609
6607
|
}
|
|
6610
6608
|
o.push(() => {
|
|
6611
6609
|
if (p)
|
|
@@ -6617,7 +6615,7 @@ class bo extends Ot {
|
|
|
6617
6615
|
})(), Promise.resolve(o);
|
|
6618
6616
|
}
|
|
6619
6617
|
}
|
|
6620
|
-
class
|
|
6618
|
+
class Ls {
|
|
6621
6619
|
constructor(e) {
|
|
6622
6620
|
h(this, "data");
|
|
6623
6621
|
h(this, "header");
|
|
@@ -6648,14 +6646,14 @@ class qs {
|
|
|
6648
6646
|
return ge.decode(this.data);
|
|
6649
6647
|
}
|
|
6650
6648
|
}
|
|
6651
|
-
h(
|
|
6652
|
-
class
|
|
6649
|
+
h(Ls, "jc");
|
|
6650
|
+
class yo extends Ot {
|
|
6653
6651
|
constructor(t, s) {
|
|
6654
6652
|
super(t, s);
|
|
6655
6653
|
h(this, "streams");
|
|
6656
6654
|
h(this, "consumers");
|
|
6657
6655
|
h(this, "direct");
|
|
6658
|
-
this.streams = new
|
|
6656
|
+
this.streams = new zs(t, s), this.consumers = new Yt(t, s), this.direct = new _o(t, s);
|
|
6659
6657
|
}
|
|
6660
6658
|
async getAccountInfo() {
|
|
6661
6659
|
return await this._request(`${this.prefix}.INFO`);
|
|
@@ -6726,7 +6724,7 @@ class ti {
|
|
|
6726
6724
|
}
|
|
6727
6725
|
}
|
|
6728
6726
|
h(ti, "jc");
|
|
6729
|
-
class
|
|
6727
|
+
class wo {
|
|
6730
6728
|
constructor(e) {
|
|
6731
6729
|
h(this, "api");
|
|
6732
6730
|
this.api = e;
|
|
@@ -6785,7 +6783,7 @@ class vs {
|
|
|
6785
6783
|
return ((e = this.info.options) == null ? void 0 : e.link) !== void 0 && ((t = this.info.options) == null ? void 0 : t.link) !== null;
|
|
6786
6784
|
}
|
|
6787
6785
|
}
|
|
6788
|
-
function
|
|
6786
|
+
function Nr(r) {
|
|
6789
6787
|
const e = {
|
|
6790
6788
|
name: r.name,
|
|
6791
6789
|
description: r.description ?? "",
|
|
@@ -6798,7 +6796,7 @@ function Tr(r) {
|
|
|
6798
6796
|
}
|
|
6799
6797
|
return e;
|
|
6800
6798
|
}
|
|
6801
|
-
function
|
|
6799
|
+
function xo() {
|
|
6802
6800
|
return new ReadableStream({
|
|
6803
6801
|
pull(r) {
|
|
6804
6802
|
r.enqueue(new Uint8Array(0)), r.close();
|
|
@@ -6860,11 +6858,11 @@ class St {
|
|
|
6860
6858
|
}
|
|
6861
6859
|
async seal() {
|
|
6862
6860
|
let e = await this._si();
|
|
6863
|
-
return e === null ? Promise.reject(new Error("object store not found")) : (e.config.sealed = !0, e = await this.jsm.streams.update(this.stream, e.config), Promise.resolve(new
|
|
6861
|
+
return e === null ? Promise.reject(new Error("object store not found")) : (e.config.sealed = !0, e = await this.jsm.streams.update(this.stream, e.config), Promise.resolve(new Ms(e)));
|
|
6864
6862
|
}
|
|
6865
6863
|
async status(e) {
|
|
6866
6864
|
const t = await this._si(e);
|
|
6867
|
-
return t === null ? Promise.reject(new Error("object store not found")) : Promise.resolve(new
|
|
6865
|
+
return t === null ? Promise.reject(new Error("object store not found")) : Promise.resolve(new Ms(t));
|
|
6868
6866
|
}
|
|
6869
6867
|
destroy() {
|
|
6870
6868
|
return this.jsm.streams.delete(this.stream);
|
|
@@ -6887,9 +6885,9 @@ class St {
|
|
|
6887
6885
|
nuid: P,
|
|
6888
6886
|
size: 0,
|
|
6889
6887
|
chunks: 0
|
|
6890
|
-
},
|
|
6888
|
+
}, Nr(e)), X = K(), L = [], Y = new ot();
|
|
6891
6889
|
try {
|
|
6892
|
-
const w = t ? t.getReader() : null, j =
|
|
6890
|
+
const w = t ? t.getReader() : null, j = Sr.create();
|
|
6893
6891
|
for (; ; ) {
|
|
6894
6892
|
const { done: F, value: R } = w ? await w.read() : {
|
|
6895
6893
|
done: !0,
|
|
@@ -6904,7 +6902,7 @@ class St {
|
|
|
6904
6902
|
}
|
|
6905
6903
|
await Promise.all(L), L.length = 0, J.mtime = (/* @__PURE__ */ new Date()).toISOString();
|
|
6906
6904
|
const A = st.encode(j.digest());
|
|
6907
|
-
J.digest = `${
|
|
6905
|
+
J.digest = `${jr}${A}`, J.deleted = !1;
|
|
6908
6906
|
const $ = $e();
|
|
6909
6907
|
typeof o == "number" && $.set(Re.ExpectedLastSubjectSequenceHdr, `${o}`), $.set(de.RollupHdr, de.RollupValueSubject);
|
|
6910
6908
|
const q = await this.js.publish(T, ve().encode(J), {
|
|
@@ -6980,9 +6978,9 @@ class St {
|
|
|
6980
6978
|
throw new Error("link is a bucket");
|
|
6981
6979
|
return (t.options.link.bucket !== this.name ? await St.create(this.js, t.options.link.bucket) : this).get(y);
|
|
6982
6980
|
}
|
|
6983
|
-
if (!t.digest.startsWith(
|
|
6981
|
+
if (!t.digest.startsWith(jr))
|
|
6984
6982
|
return Promise.reject(new Error(`unknown digest type: ${t.digest}`));
|
|
6985
|
-
const s =
|
|
6983
|
+
const s = Is(t.digest.substring(8));
|
|
6986
6984
|
if (s === null)
|
|
6987
6985
|
return Promise.reject(new Error(`unable to parse digest: ${t.digest}`));
|
|
6988
6986
|
const i = K(), n = {
|
|
@@ -6990,14 +6988,14 @@ class St {
|
|
|
6990
6988
|
error: i
|
|
6991
6989
|
};
|
|
6992
6990
|
if (t.size === 0)
|
|
6993
|
-
return n.data =
|
|
6991
|
+
return n.data = xo(), i.resolve(null), Promise.resolve(n);
|
|
6994
6992
|
let o;
|
|
6995
6993
|
const a = Be();
|
|
6996
6994
|
a.orderedConsumer();
|
|
6997
|
-
const d =
|
|
6995
|
+
const d = Sr.create(), p = `$O.${this.name}.C.${t.nuid}`, _ = await this.js.subscribe(p, a);
|
|
6998
6996
|
return (async () => {
|
|
6999
6997
|
for await (const y of _)
|
|
7000
|
-
y.data.length > 0 && (d.update(y.data), o.enqueue(y.data)), y.info.pending === 0 && (
|
|
6998
|
+
y.data.length > 0 && (d.update(y.data), o.enqueue(y.data)), y.info.pending === 0 && (cn(s, d.digest()) ? o.close() : o.error(new Error(`received a corrupt object, digests do not match received: ${t.digest} calculated ${s}`)), _.unsubscribe());
|
|
7001
6999
|
})().then(() => {
|
|
7002
7000
|
i.resolve();
|
|
7003
7001
|
}).catch((y) => {
|
|
@@ -7083,7 +7081,7 @@ class St {
|
|
|
7083
7081
|
return Promise.reject(new Error("an object already exists with that name"));
|
|
7084
7082
|
}
|
|
7085
7083
|
t.name = i;
|
|
7086
|
-
const o = Object.assign({}, s,
|
|
7084
|
+
const o = Object.assign({}, s, Nr(t)), a = await this.js.publish(this._metaSubject(o.name), JSON.stringify(o));
|
|
7087
7085
|
return e !== t.name && await this.jsm.streams.purge(this.stream, {
|
|
7088
7086
|
filter: this._metaSubject(e)
|
|
7089
7087
|
}), Promise.resolve(a);
|
|
@@ -7131,7 +7129,7 @@ class St {
|
|
|
7131
7129
|
}
|
|
7132
7130
|
async init(e = {}) {
|
|
7133
7131
|
try {
|
|
7134
|
-
this.stream =
|
|
7132
|
+
this.stream = ho(this.name);
|
|
7135
7133
|
} catch (i) {
|
|
7136
7134
|
return Promise.reject(i);
|
|
7137
7135
|
}
|
|
@@ -7155,7 +7153,7 @@ class St {
|
|
|
7155
7153
|
return await n.init(s), Promise.resolve(n);
|
|
7156
7154
|
}
|
|
7157
7155
|
}
|
|
7158
|
-
class
|
|
7156
|
+
class So {
|
|
7159
7157
|
constructor(e) {
|
|
7160
7158
|
h(this, "js");
|
|
7161
7159
|
this.js = e;
|
|
@@ -7172,14 +7170,14 @@ class wo {
|
|
|
7172
7170
|
return i ? St.create(this.js, e, t) : Promise.reject(new Error(`objectstore is only supported on servers ${n} or better`));
|
|
7173
7171
|
}
|
|
7174
7172
|
}
|
|
7175
|
-
class
|
|
7173
|
+
class Gs extends Ot {
|
|
7176
7174
|
constructor(t, s) {
|
|
7177
7175
|
super(t, s);
|
|
7178
7176
|
h(this, "consumers");
|
|
7179
7177
|
h(this, "streams");
|
|
7180
7178
|
h(this, "consumerAPI");
|
|
7181
7179
|
h(this, "streamAPI");
|
|
7182
|
-
this.consumerAPI = new Yt(t, s), this.streamAPI = new
|
|
7180
|
+
this.consumerAPI = new Yt(t, s), this.streamAPI = new zs(t, s), this.consumers = new Us(this.consumerAPI), this.streams = new wo(this.streamAPI);
|
|
7183
7181
|
}
|
|
7184
7182
|
jetstreamManager(t) {
|
|
7185
7183
|
t === void 0 && (t = this.opts.checkAPI);
|
|
@@ -7192,7 +7190,7 @@ class Ks extends Ot {
|
|
|
7192
7190
|
return this.prefix;
|
|
7193
7191
|
}
|
|
7194
7192
|
get views() {
|
|
7195
|
-
return new
|
|
7193
|
+
return new So(this);
|
|
7196
7194
|
}
|
|
7197
7195
|
async publish(t, s = ye, i) {
|
|
7198
7196
|
i = i || {}, i.expect = i.expect || {};
|
|
@@ -7256,7 +7254,7 @@ class Ks extends Ot {
|
|
|
7256
7254
|
x && (_.idle_heartbeat = G(x), i.delay_heartbeat === !0 && (_.idle_heartbeat = G(x * 4)));
|
|
7257
7255
|
const P = new oe(), I = _.batch;
|
|
7258
7256
|
let T = 0;
|
|
7259
|
-
P.protocolFilterFn = (L, Y = !1) =>
|
|
7257
|
+
P.protocolFilterFn = (L, Y = !1) => Os(L.msg) ? (p == null || p.work(), !1) : !0, P.dispatchedFn = (L) => {
|
|
7260
7258
|
if (L) {
|
|
7261
7259
|
if (o && (a += L.data.length), T++, n && L.info.pending === 0)
|
|
7262
7260
|
return;
|
|
@@ -7266,7 +7264,7 @@ class Ks extends Ot {
|
|
|
7266
7264
|
const J = Me(this.nc.options.inboxPrefix), X = this.nc.subscribe(J, {
|
|
7267
7265
|
max: i.batch,
|
|
7268
7266
|
callback: (L, Y) => {
|
|
7269
|
-
L === null && (L = tt(Y)), L !== null ? (n && (n.cancel(), n = null),
|
|
7267
|
+
L === null && (L = tt(Y)), L !== null ? (n && (n.cancel(), n = null), Di(L) ? P.stop(ri(L) === null ? void 0 : L) : P.stop(L)) : (p == null || p.work(), P.received++, P.push(Pt(Y, this.timeout)));
|
|
7270
7268
|
}
|
|
7271
7269
|
});
|
|
7272
7270
|
return y && (n = it(y), n.catch(() => {
|
|
@@ -7274,7 +7272,7 @@ class Ks extends Ot {
|
|
|
7274
7272
|
}), n = null), p && p.cancel();
|
|
7275
7273
|
})), (async () => {
|
|
7276
7274
|
try {
|
|
7277
|
-
x && (p = new
|
|
7275
|
+
x && (p = new Hs(x, (L) => (P.push(() => {
|
|
7278
7276
|
P.err = new N(`${Se.IdleHeartbeatMissed}: ${L}`, O.JetStreamIdleHeartBeat);
|
|
7279
7277
|
}), !0)));
|
|
7280
7278
|
} catch {
|
|
@@ -7293,7 +7291,7 @@ class Ks extends Ot {
|
|
|
7293
7291
|
const n = i.config.ack_policy;
|
|
7294
7292
|
if (n === ne.None || n === ne.All)
|
|
7295
7293
|
throw new Error("ack policy for pull consumers must be explicit");
|
|
7296
|
-
const o = this._buildTypedSubscriptionOpts(i), a = new
|
|
7294
|
+
const o = this._buildTypedSubscriptionOpts(i), a = new Po(this, i.deliver, o);
|
|
7297
7295
|
a.info = i;
|
|
7298
7296
|
try {
|
|
7299
7297
|
await this._maybeCreateConsumer(i);
|
|
@@ -7316,8 +7314,8 @@ class Ks extends Ot {
|
|
|
7316
7314
|
return o._maybeSetupHbMonitoring(), o;
|
|
7317
7315
|
}
|
|
7318
7316
|
async _processOptions(t, s = Be()) {
|
|
7319
|
-
const i =
|
|
7320
|
-
if (i.isBind =
|
|
7317
|
+
const i = _r(s) ? s.getOpts() : s;
|
|
7318
|
+
if (i.isBind = _r(s) ? s.isBind : !1, i.flow_control = {
|
|
7321
7319
|
heartbeat_count: 0,
|
|
7322
7320
|
fc_count: 0,
|
|
7323
7321
|
consumer_restarts: 0
|
|
@@ -7359,10 +7357,10 @@ class Ks extends Ot {
|
|
|
7359
7357
|
}
|
|
7360
7358
|
_buildTypedSubscriptionOpts(t) {
|
|
7361
7359
|
const s = {};
|
|
7362
|
-
return s.adapter =
|
|
7360
|
+
return s.adapter = Oo(t.callbackFn === void 0, this.timeout), s.ingestionFilterFn = Gs.ingestionFn(t.ordered), s.protocolFilterFn = (i, n = !1) => {
|
|
7363
7361
|
const o = i;
|
|
7364
|
-
return
|
|
7365
|
-
}, !t.mack && t.config.ack_policy !== ne.None && (s.dispatchedFn =
|
|
7362
|
+
return Ps(o.msg) ? (n || o.msg.respond(), !1) : !0;
|
|
7363
|
+
}, !t.mack && t.config.ack_policy !== ne.None && (s.dispatchedFn = Io), t.callbackFn && (s.callback = t.callbackFn), s.max = t.max || 0, s.queue = t.queue, s;
|
|
7366
7364
|
}
|
|
7367
7365
|
async _maybeCreateConsumer(t) {
|
|
7368
7366
|
if (t.attached)
|
|
@@ -7389,13 +7387,13 @@ class Ks extends Ot {
|
|
|
7389
7387
|
protocol: !1
|
|
7390
7388
|
};
|
|
7391
7389
|
const o = s;
|
|
7392
|
-
if (tt(o.msg) || (d = n.monitor) == null || d.work(),
|
|
7390
|
+
if (tt(o.msg) || (d = n.monitor) == null || d.work(), Os(o.msg)) {
|
|
7393
7391
|
const p = t ? n._checkHbOrderConsumer(o.msg) : !0;
|
|
7394
7392
|
return t || n.info.flow_control.heartbeat_count++, {
|
|
7395
7393
|
ingest: p,
|
|
7396
7394
|
protocol: !0
|
|
7397
7395
|
};
|
|
7398
|
-
} else if (
|
|
7396
|
+
} else if (Ps(o.msg))
|
|
7399
7397
|
return n.info.flow_control.fc_count++, {
|
|
7400
7398
|
ingest: !0,
|
|
7401
7399
|
protocol: !0
|
|
@@ -7407,18 +7405,18 @@ class Ks extends Ot {
|
|
|
7407
7405
|
};
|
|
7408
7406
|
}
|
|
7409
7407
|
}
|
|
7410
|
-
class
|
|
7408
|
+
class Ks {
|
|
7411
7409
|
constructor(e) {
|
|
7412
7410
|
h(this, "options");
|
|
7413
7411
|
h(this, "protocol");
|
|
7414
7412
|
h(this, "draining");
|
|
7415
7413
|
h(this, "listeners");
|
|
7416
7414
|
h(this, "_services");
|
|
7417
|
-
this.draining = !1, this.options =
|
|
7415
|
+
this.draining = !1, this.options = Jn(e), this.listeners = [];
|
|
7418
7416
|
}
|
|
7419
7417
|
static connect(e = {}) {
|
|
7420
7418
|
return new Promise((t, s) => {
|
|
7421
|
-
const i = new
|
|
7419
|
+
const i = new Ks(e);
|
|
7422
7420
|
Zt.connect(i.options, i).then((n) => {
|
|
7423
7421
|
i.protocol = n, async function() {
|
|
7424
7422
|
for await (const o of n.status())
|
|
@@ -7547,7 +7545,7 @@ ${d}`), y(I);
|
|
|
7547
7545
|
}).catch((_) => {
|
|
7548
7546
|
p.cancel(_);
|
|
7549
7547
|
});
|
|
7550
|
-
const p = new
|
|
7548
|
+
const p = new hn(this.protocol.muxSubscriptions, e, d);
|
|
7551
7549
|
this.protocol.request(p);
|
|
7552
7550
|
try {
|
|
7553
7551
|
this.publish(e, t, {
|
|
@@ -7648,7 +7646,7 @@ ${a.stack}`), o.reject(p)) : o.resolve(_));
|
|
|
7648
7646
|
};
|
|
7649
7647
|
}
|
|
7650
7648
|
async jetstreamManager(e = {}) {
|
|
7651
|
-
const t = new
|
|
7649
|
+
const t = new yo(this, e);
|
|
7652
7650
|
if (e.checkAPI !== !1)
|
|
7653
7651
|
try {
|
|
7654
7652
|
await t.getAccountInfo();
|
|
@@ -7659,7 +7657,7 @@ ${a.stack}`), o.reject(p)) : o.resolve(_));
|
|
|
7659
7657
|
return t;
|
|
7660
7658
|
}
|
|
7661
7659
|
jetstream(e = {}) {
|
|
7662
|
-
return new
|
|
7660
|
+
return new Gs(this, e);
|
|
7663
7661
|
}
|
|
7664
7662
|
getServerVersion() {
|
|
7665
7663
|
const e = this.info;
|
|
@@ -7675,13 +7673,13 @@ ${a.stack}`), o.reject(p)) : o.resolve(_));
|
|
|
7675
7673
|
return this.protocol.features;
|
|
7676
7674
|
}
|
|
7677
7675
|
get services() {
|
|
7678
|
-
return this._services || (this._services = new
|
|
7676
|
+
return this._services || (this._services = new Eo(this)), this._services;
|
|
7679
7677
|
}
|
|
7680
7678
|
reconnect() {
|
|
7681
7679
|
return this.isClosed() ? Promise.reject(N.errorForCode(O.ConnectionClosed)) : this.isDraining() ? Promise.reject(N.errorForCode(O.ConnectionDraining)) : this.protocol.reconnect();
|
|
7682
7680
|
}
|
|
7683
7681
|
}
|
|
7684
|
-
class
|
|
7682
|
+
class Eo {
|
|
7685
7683
|
constructor(e) {
|
|
7686
7684
|
h(this, "nc");
|
|
7687
7685
|
this.nc = e;
|
|
@@ -7694,10 +7692,10 @@ class xo {
|
|
|
7694
7692
|
}
|
|
7695
7693
|
}
|
|
7696
7694
|
client(e, t) {
|
|
7697
|
-
return new
|
|
7695
|
+
return new to(this.nc, e, t);
|
|
7698
7696
|
}
|
|
7699
7697
|
}
|
|
7700
|
-
class
|
|
7698
|
+
class vo {
|
|
7701
7699
|
constructor(e, t, s) {
|
|
7702
7700
|
h(this, "bucket");
|
|
7703
7701
|
h(this, "sm");
|
|
@@ -7733,7 +7731,7 @@ class So {
|
|
|
7733
7731
|
return this.sm.string();
|
|
7734
7732
|
}
|
|
7735
7733
|
}
|
|
7736
|
-
class
|
|
7734
|
+
class Ao {
|
|
7737
7735
|
constructor(e, t, s) {
|
|
7738
7736
|
h(this, "bucket");
|
|
7739
7737
|
h(this, "key");
|
|
@@ -7744,7 +7742,7 @@ class Eo {
|
|
|
7744
7742
|
return this.sm.data;
|
|
7745
7743
|
}
|
|
7746
7744
|
get created() {
|
|
7747
|
-
return new Date(
|
|
7745
|
+
return new Date(Bs(this.sm.info.timestampNanos));
|
|
7748
7746
|
}
|
|
7749
7747
|
get revision() {
|
|
7750
7748
|
return this.sm.seq;
|
|
@@ -7768,7 +7766,7 @@ class Eo {
|
|
|
7768
7766
|
return this.sm.string();
|
|
7769
7767
|
}
|
|
7770
7768
|
}
|
|
7771
|
-
class si extends
|
|
7769
|
+
class si extends dn {
|
|
7772
7770
|
constructor(t, s, i) {
|
|
7773
7771
|
super(t.nc, s, i);
|
|
7774
7772
|
h(this, "js");
|
|
@@ -7806,7 +7804,7 @@ class si extends ln {
|
|
|
7806
7804
|
_maybeSetupHbMonitoring() {
|
|
7807
7805
|
var s, i;
|
|
7808
7806
|
const t = ((i = (s = this.info) == null ? void 0 : s.config) == null ? void 0 : i.idle_heartbeat) || 0;
|
|
7809
|
-
t && this._setupHbMonitoring(
|
|
7807
|
+
t && this._setupHbMonitoring(Bs(t));
|
|
7810
7808
|
}
|
|
7811
7809
|
_setupHbMonitoring(t, s = 0) {
|
|
7812
7810
|
const i = {
|
|
@@ -7816,7 +7814,7 @@ class si extends ln {
|
|
|
7816
7814
|
s && (i.cancelAfter = s);
|
|
7817
7815
|
const n = this.sub, o = (a) => {
|
|
7818
7816
|
var _, y, x, P;
|
|
7819
|
-
const d =
|
|
7817
|
+
const d = Gi(409, `${Se.IdleHeartbeatMissed}: ${a}`, this.sub.subject);
|
|
7820
7818
|
if (!((_ = this.info) == null ? void 0 : _.ordered))
|
|
7821
7819
|
this.sub.callback(null, d);
|
|
7822
7820
|
else {
|
|
@@ -7827,7 +7825,7 @@ class si extends ln {
|
|
|
7827
7825
|
}
|
|
7828
7826
|
return !n.noIterator;
|
|
7829
7827
|
};
|
|
7830
|
-
this.monitor = new
|
|
7828
|
+
this.monitor = new Hs(t, o, i);
|
|
7831
7829
|
}
|
|
7832
7830
|
_checkHbOrderConsumer(t) {
|
|
7833
7831
|
const s = t.headers.get(de.ConsumerStalledHdr);
|
|
@@ -7849,7 +7847,7 @@ class si extends ln {
|
|
|
7849
7847
|
return t.last = n, n;
|
|
7850
7848
|
}
|
|
7851
7849
|
}
|
|
7852
|
-
class
|
|
7850
|
+
class Po extends si {
|
|
7853
7851
|
constructor(e, t, s) {
|
|
7854
7852
|
super(e, t, s);
|
|
7855
7853
|
}
|
|
@@ -7879,10 +7877,10 @@ class vo extends si {
|
|
|
7879
7877
|
}
|
|
7880
7878
|
}
|
|
7881
7879
|
}
|
|
7882
|
-
function
|
|
7883
|
-
return r ?
|
|
7880
|
+
function Oo(r, e) {
|
|
7881
|
+
return r ? Co(e) : ko(e);
|
|
7884
7882
|
}
|
|
7885
|
-
function
|
|
7883
|
+
function ko(r) {
|
|
7886
7884
|
return (e, t) => e ? [
|
|
7887
7885
|
e,
|
|
7888
7886
|
null
|
|
@@ -7894,7 +7892,7 @@ function Po(r) {
|
|
|
7894
7892
|
Pt(t, r)
|
|
7895
7893
|
]);
|
|
7896
7894
|
}
|
|
7897
|
-
function
|
|
7895
|
+
function Co(r) {
|
|
7898
7896
|
return (e, t) => {
|
|
7899
7897
|
if (e)
|
|
7900
7898
|
return [
|
|
@@ -7918,23 +7916,23 @@ function ri(r) {
|
|
|
7918
7916
|
case O.JetStream408RequestTimeout:
|
|
7919
7917
|
return null;
|
|
7920
7918
|
case O.JetStream409:
|
|
7921
|
-
return
|
|
7919
|
+
return Ki(r) ? r : null;
|
|
7922
7920
|
default:
|
|
7923
7921
|
return r;
|
|
7924
7922
|
}
|
|
7925
7923
|
return null;
|
|
7926
7924
|
}
|
|
7927
|
-
function
|
|
7925
|
+
function Io(r) {
|
|
7928
7926
|
r && r.ack();
|
|
7929
7927
|
}
|
|
7930
|
-
function
|
|
7928
|
+
function jo(r) {
|
|
7931
7929
|
const e = r.split(".");
|
|
7932
7930
|
if (e.length === 9 && e.splice(2, 0, "_", ""), e.length < 11 || e[0] !== "$JS" || e[1] !== "ACK")
|
|
7933
7931
|
throw new Error("not js message");
|
|
7934
7932
|
const t = {};
|
|
7935
7933
|
return t.domain = e[2] === "_" ? "" : e[2], t.account_hash = e[3], t.stream = e[4], t.consumer = e[5], t.deliveryCount = parseInt(e[6], 10), t.redeliveryCount = t.deliveryCount, t.redelivered = t.deliveryCount > 1, t.streamSequence = parseInt(e[7], 10), t.deliverySequence = parseInt(e[8], 10), t.timestampNanos = parseInt(e[9], 10), t.pending = parseInt(e[10], 10), t;
|
|
7936
7934
|
}
|
|
7937
|
-
class
|
|
7935
|
+
class Ro {
|
|
7938
7936
|
constructor(e, t) {
|
|
7939
7937
|
h(this, "msg");
|
|
7940
7938
|
h(this, "di");
|
|
@@ -7955,7 +7953,7 @@ class Io {
|
|
|
7955
7953
|
return this.msg.headers;
|
|
7956
7954
|
}
|
|
7957
7955
|
get info() {
|
|
7958
|
-
return this.di || (this.di =
|
|
7956
|
+
return this.di || (this.di = jo(this.reply)), this.di;
|
|
7959
7957
|
}
|
|
7960
7958
|
get redelivered() {
|
|
7961
7959
|
return this.info.deliveryCount > 1;
|
|
@@ -7984,7 +7982,7 @@ class Io {
|
|
|
7984
7982
|
}, o);
|
|
7985
7983
|
n.request(a);
|
|
7986
7984
|
try {
|
|
7987
|
-
n.publish(this.msg.reply,
|
|
7985
|
+
n.publish(this.msg.reply, Rr, {
|
|
7988
7986
|
reply: `${n.muxSubscriptions.baseInbox}${a.token}`
|
|
7989
7987
|
});
|
|
7990
7988
|
} catch (d) {
|
|
@@ -8003,11 +8001,11 @@ class Io {
|
|
|
8003
8001
|
return t;
|
|
8004
8002
|
}
|
|
8005
8003
|
ack() {
|
|
8006
|
-
this.doAck(
|
|
8004
|
+
this.doAck(Rr);
|
|
8007
8005
|
}
|
|
8008
8006
|
nak(e) {
|
|
8009
|
-
let t =
|
|
8010
|
-
e && (t =
|
|
8007
|
+
let t = lo;
|
|
8008
|
+
e && (t = mr().encode(`-NAK ${JSON.stringify({
|
|
8011
8009
|
delay: G(e)
|
|
8012
8010
|
})}`)), this.doAck(t);
|
|
8013
8011
|
}
|
|
@@ -8019,14 +8017,14 @@ class Io {
|
|
|
8019
8017
|
}) {
|
|
8020
8018
|
const s = {};
|
|
8021
8019
|
s.batch = t.batch || 1, s.no_wait = t.no_wait || !1, t.expires && t.expires > 0 && (s.expires = G(t.expires));
|
|
8022
|
-
const i = ve().encode(s), n = ot.concat(
|
|
8020
|
+
const i = ve().encode(s), n = ot.concat(fo, mo, i), o = e ? {
|
|
8023
8021
|
reply: e
|
|
8024
8022
|
} : void 0;
|
|
8025
8023
|
this.msg.respond(n, o);
|
|
8026
8024
|
}
|
|
8027
8025
|
term(e = "") {
|
|
8028
|
-
let t =
|
|
8029
|
-
(e == null ? void 0 : e.length) > 0 && (t =
|
|
8026
|
+
let t = po;
|
|
8027
|
+
(e == null ? void 0 : e.length) > 0 && (t = mr().encode(`+TERM ${e}`)), this.doAck(t);
|
|
8030
8028
|
}
|
|
8031
8029
|
json() {
|
|
8032
8030
|
return this.msg.json();
|
|
@@ -8035,8 +8033,8 @@ class Io {
|
|
|
8035
8033
|
return this.msg.string();
|
|
8036
8034
|
}
|
|
8037
8035
|
}
|
|
8038
|
-
const
|
|
8039
|
-
class
|
|
8036
|
+
const No = "1.30.3", To = "nats.ws";
|
|
8037
|
+
class Mo {
|
|
8040
8038
|
constructor() {
|
|
8041
8039
|
h(this, "version");
|
|
8042
8040
|
h(this, "lang");
|
|
@@ -8051,7 +8049,7 @@ class No {
|
|
|
8051
8049
|
h(this, "yields");
|
|
8052
8050
|
h(this, "signal");
|
|
8053
8051
|
h(this, "closedNotification");
|
|
8054
|
-
this.version =
|
|
8052
|
+
this.version = No, this.lang = To, this.connected = !1, this.done = !1, this.socketClosed = !1, this.encrypted = !1, this.peeked = !1, this.yields = [], this.signal = K(), this.closedNotification = K();
|
|
8055
8053
|
}
|
|
8056
8054
|
async connect(e, t) {
|
|
8057
8055
|
const s = K();
|
|
@@ -8073,16 +8071,16 @@ class No {
|
|
|
8073
8071
|
this.signal.resolve();
|
|
8074
8072
|
return;
|
|
8075
8073
|
}
|
|
8076
|
-
const o = ot.concat(...this.yields), a =
|
|
8074
|
+
const o = ot.concat(...this.yields), a = yn(o);
|
|
8077
8075
|
if (a !== "") {
|
|
8078
|
-
const d =
|
|
8076
|
+
const d = Kn.exec(a);
|
|
8079
8077
|
if (!d) {
|
|
8080
8078
|
t.debug && console.error("!!!", Lt(o)), s.reject(new Error("unexpected response from server"));
|
|
8081
8079
|
return;
|
|
8082
8080
|
}
|
|
8083
8081
|
try {
|
|
8084
8082
|
const p = JSON.parse(d[1]);
|
|
8085
|
-
|
|
8083
|
+
zn(p, this.options), this.peeked = !0, this.connected = !0, this.signal.resolve(), s.resolve();
|
|
8086
8084
|
} catch (p) {
|
|
8087
8085
|
s.reject(p);
|
|
8088
8086
|
return;
|
|
@@ -8167,7 +8165,7 @@ class No {
|
|
|
8167
8165
|
}
|
|
8168
8166
|
}
|
|
8169
8167
|
}
|
|
8170
|
-
function
|
|
8168
|
+
function $o(r, e) {
|
|
8171
8169
|
/^(.*:\/\/)(.*)/.test(r) || (typeof e == "boolean" ? r = `${e === !0 ? "https" : "http"}://${r}` : r = `https://${r}`);
|
|
8172
8170
|
let s = new URL(r);
|
|
8173
8171
|
const i = s.protocol.toLowerCase();
|
|
@@ -8191,15 +8189,15 @@ function To(r, e) {
|
|
|
8191
8189
|
}
|
|
8192
8190
|
return `${n}//${a}:${o}${d}${p}`;
|
|
8193
8191
|
}
|
|
8194
|
-
function
|
|
8195
|
-
return
|
|
8192
|
+
function Uo(r = {}) {
|
|
8193
|
+
return pn({
|
|
8196
8194
|
defaultPort: 443,
|
|
8197
|
-
urlParseFn:
|
|
8198
|
-
factory: () => new
|
|
8199
|
-
}),
|
|
8195
|
+
urlParseFn: $o,
|
|
8196
|
+
factory: () => new Mo()
|
|
8197
|
+
}), Ks.connect(r);
|
|
8200
8198
|
}
|
|
8201
8199
|
const Ue = ve();
|
|
8202
|
-
class
|
|
8200
|
+
class Tr {
|
|
8203
8201
|
constructor(e) {
|
|
8204
8202
|
h(this, "onStatusChange");
|
|
8205
8203
|
h(this, "nc");
|
|
@@ -8213,15 +8211,18 @@ class Mr {
|
|
|
8213
8211
|
));
|
|
8214
8212
|
this.config = e;
|
|
8215
8213
|
}
|
|
8214
|
+
get url() {
|
|
8215
|
+
return this.config.natsUrl;
|
|
8216
|
+
}
|
|
8216
8217
|
async connect(e = {}) {
|
|
8217
8218
|
var a;
|
|
8218
8219
|
const { natsWsServerUrls: t, user: s, prefix: i } = e, n = t ?? [
|
|
8219
8220
|
this.config.natsUrl
|
|
8220
8221
|
];
|
|
8221
|
-
this.nc = await
|
|
8222
|
+
this.nc = await Uo({
|
|
8222
8223
|
servers: n
|
|
8223
8224
|
});
|
|
8224
|
-
const o = s ??
|
|
8225
|
+
const o = s ?? await this.config.auth.getLastLoginData();
|
|
8225
8226
|
if (!o)
|
|
8226
8227
|
throw new Error(
|
|
8227
8228
|
"Please authenticate first by calling `auth` apis"
|
|
@@ -8355,13 +8356,33 @@ class Mr {
|
|
|
8355
8356
|
return [this.globalPrefix, e, this.userId, this.sessionId].filter((t) => t).join(".");
|
|
8356
8357
|
}
|
|
8357
8358
|
}
|
|
8358
|
-
|
|
8359
|
+
class ii {
|
|
8360
|
+
async setItem(e, t) {
|
|
8361
|
+
if (!t)
|
|
8362
|
+
return this.removeItem(e);
|
|
8363
|
+
localStorage.setItem(e, JSON.stringify(t));
|
|
8364
|
+
}
|
|
8365
|
+
async getItem(e) {
|
|
8366
|
+
const t = localStorage.getItem(e);
|
|
8367
|
+
if (!t)
|
|
8368
|
+
return null;
|
|
8369
|
+
try {
|
|
8370
|
+
return JSON.parse(t);
|
|
8371
|
+
} catch {
|
|
8372
|
+
return null;
|
|
8373
|
+
}
|
|
8374
|
+
}
|
|
8375
|
+
async removeItem(e) {
|
|
8376
|
+
localStorage.removeItem(e);
|
|
8377
|
+
}
|
|
8378
|
+
}
|
|
8379
|
+
function ni(r) {
|
|
8359
8380
|
const e = new Blob([r], { type: "audio/mpeg" }), t = URL.createObjectURL(e), s = new Audio();
|
|
8360
8381
|
return s.src = t, s.onended = () => {
|
|
8361
8382
|
URL.revokeObjectURL(t);
|
|
8362
8383
|
}, s;
|
|
8363
8384
|
}
|
|
8364
|
-
class
|
|
8385
|
+
class Lo {
|
|
8365
8386
|
async getAudioBuffer(e, t, s) {
|
|
8366
8387
|
const i = [], n = crypto.randomUUID();
|
|
8367
8388
|
return new Promise((o, a) => {
|
|
@@ -8369,9 +8390,9 @@ class $o {
|
|
|
8369
8390
|
`${Dt.WSS_URL}?trustedclienttoken=${Dt.TRUSTED_CLIENT_TOKEN}&ConnectionId=${n}`
|
|
8370
8391
|
);
|
|
8371
8392
|
d.binaryType = "arraybuffer";
|
|
8372
|
-
const p =
|
|
8393
|
+
const p = Fo(e, t, s);
|
|
8373
8394
|
d.addEventListener("open", () => {
|
|
8374
|
-
const _ =
|
|
8395
|
+
const _ = qo();
|
|
8375
8396
|
d.send(_);
|
|
8376
8397
|
const y = `X-RequestId:${n}\r
|
|
8377
8398
|
Content-Type:application/ssml+xml\r
|
|
@@ -8384,7 +8405,7 @@ Path:ssml\r
|
|
|
8384
8405
|
const y = _.data;
|
|
8385
8406
|
if (y instanceof ArrayBuffer) {
|
|
8386
8407
|
const x = new Uint8Array(y), P = new TextEncoder().encode(`Path:audio\r
|
|
8387
|
-
`), I =
|
|
8408
|
+
`), I = Bo(x, P);
|
|
8388
8409
|
if (I !== -1) {
|
|
8389
8410
|
const J = x.subarray(I + P.length);
|
|
8390
8411
|
i.push(J);
|
|
@@ -8412,7 +8433,7 @@ Path:ssml\r
|
|
|
8412
8433
|
}
|
|
8413
8434
|
async getAudio(e, t, s) {
|
|
8414
8435
|
return this.getAudioBuffer(e, t, s).then(
|
|
8415
|
-
(i) =>
|
|
8436
|
+
(i) => ni(i)
|
|
8416
8437
|
);
|
|
8417
8438
|
}
|
|
8418
8439
|
async getVoices() {
|
|
@@ -8429,17 +8450,17 @@ const Dt = {
|
|
|
8429
8450
|
TRUSTED_CLIENT_TOKEN: "6A5AA1D4EAFF4E9FB37E23D68491D6F4",
|
|
8430
8451
|
WSS_URL: "wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1",
|
|
8431
8452
|
VOICES_URL: "https://speech.platform.bing.com/consumer/speech/synthesize/readaloud/voices/list"
|
|
8432
|
-
},
|
|
8453
|
+
}, qo = () => `X-Timestamp:${(/* @__PURE__ */ new Date()).toISOString()}Z\r
|
|
8433
8454
|
Content-Type:application/json; charset=utf-8\r
|
|
8434
8455
|
Path:speech.config\r
|
|
8435
8456
|
\r
|
|
8436
|
-
{"context":{"synthesis":{"audio":{"metadataoptions":{"sentenceBoundaryEnabled":false,"wordBoundaryEnabled":true},"outputFormat":"audio-24khz-48kbitrate-mono-mp3"}}}}`,
|
|
8457
|
+
{"context":{"synthesis":{"audio":{"metadataoptions":{"sentenceBoundaryEnabled":false,"wordBoundaryEnabled":true},"outputFormat":"audio-24khz-48kbitrate-mono-mp3"}}}}`, Fo = (r, e, t = {}) => {
|
|
8437
8458
|
var o;
|
|
8438
8459
|
t.pitch = (o = t.pitch) == null ? void 0 : o.replace("hz", "Hz");
|
|
8439
8460
|
const s = t.pitch || "0Hz", i = t.rate || "0%", n = t.volume || "0%";
|
|
8440
8461
|
return `<speak version='1.0' xml:lang='en-US'><voice name='${e}'><prosody pitch='${s}' rate='${i}' volume='${n}'>${r}</prosody></voice></speak>`;
|
|
8441
8462
|
};
|
|
8442
|
-
function
|
|
8463
|
+
function Bo(r, e) {
|
|
8443
8464
|
for (let t = 0; t <= r.length - e.length; t++) {
|
|
8444
8465
|
let s = !0;
|
|
8445
8466
|
for (let i = 0; i < e.length; i++)
|
|
@@ -8451,7 +8472,7 @@ function qo(r, e) {
|
|
|
8451
8472
|
}
|
|
8452
8473
|
return -1;
|
|
8453
8474
|
}
|
|
8454
|
-
class
|
|
8475
|
+
class Ho {
|
|
8455
8476
|
constructor(e) {
|
|
8456
8477
|
this.config = e;
|
|
8457
8478
|
}
|
|
@@ -8499,7 +8520,7 @@ class Bo {
|
|
|
8499
8520
|
}
|
|
8500
8521
|
async getAudio(e, t) {
|
|
8501
8522
|
return this.getAudioBuffer(e, t).then(
|
|
8502
|
-
(s) => s ?
|
|
8523
|
+
(s) => s ? ni(s) : null
|
|
8503
8524
|
);
|
|
8504
8525
|
}
|
|
8505
8526
|
async getVoices() {
|
|
@@ -8514,21 +8535,29 @@ class Bo {
|
|
|
8514
8535
|
);
|
|
8515
8536
|
}
|
|
8516
8537
|
}
|
|
8517
|
-
const
|
|
8538
|
+
const oi = {
|
|
8518
8539
|
debug: !1,
|
|
8519
8540
|
authUrl: "https://auth.jok.io",
|
|
8520
|
-
natsUrl: "https://natsx.jok.io"
|
|
8521
|
-
|
|
8541
|
+
natsUrl: "https://natsx.jok.io",
|
|
8542
|
+
storage: new ii()
|
|
8543
|
+
}, Mr = new Fr(oi), Jo = {
|
|
8522
8544
|
setup(r) {
|
|
8523
|
-
r.authUrl
|
|
8545
|
+
(r.authUrl || r.storage) && (this.auth = new Fr({
|
|
8546
|
+
authUrl: r.authUrl ?? this.auth.url,
|
|
8547
|
+
storage: r.storage ?? this.storage
|
|
8548
|
+
})), (r.natsUrl || r.storage) && (this.nats = new Tr({
|
|
8549
|
+
natsUrl: r.natsUrl ?? this.nats.url,
|
|
8550
|
+
auth: this.auth
|
|
8551
|
+
}));
|
|
8524
8552
|
},
|
|
8525
|
-
auth:
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8553
|
+
auth: Mr,
|
|
8554
|
+
storage: new ii(),
|
|
8555
|
+
tts: new Lo(),
|
|
8556
|
+
nats: new Tr({ ...oi, auth: Mr }),
|
|
8557
|
+
crypto: new Mi()
|
|
8529
8558
|
};
|
|
8530
8559
|
export {
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8560
|
+
Tr as NatsService,
|
|
8561
|
+
Ho as VoicevoxTtsService,
|
|
8562
|
+
Jo as jok
|
|
8534
8563
|
};
|