@jokio/sdk 0.3.0 → 0.3.2

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.
@@ -329,7 +329,7 @@ async function ji(r) {
329
329
  authenticatorAttachment: qr(a.authenticatorAttachment)
330
330
  };
331
331
  }
332
- const dt = "LAST_AUTH_DATA";
332
+ const Ze = "LAST_AUTH_DATA";
333
333
  class Fr {
334
334
  constructor(e) {
335
335
  h(this, "onUserDataUpdate");
@@ -345,7 +345,7 @@ class Fr {
345
345
  }
346
346
  async init() {
347
347
  var t, s;
348
- const e = localStorage.getItem(dt);
348
+ const e = localStorage.getItem(Ze);
349
349
  if (e)
350
350
  try {
351
351
  const i = JSON.parse(e);
@@ -354,7 +354,7 @@ class Fr {
354
354
  }
355
355
  else {
356
356
  const i = await this.me();
357
- (s = this.onUserDataUpdate) == null || s.call(this, i), this.isAuthenticatedResolver();
357
+ await this.options.storage.setItem(Ze, i), (s = this.onUserDataUpdate) == null || s.call(this, i), this.isAuthenticatedResolver();
358
358
  }
359
359
  }
360
360
  async me() {
@@ -374,7 +374,7 @@ class Fr {
374
374
  this.options.authUrl + `/email-verification-complete/${e}/${t}`,
375
375
  { credentials: "include" }
376
376
  ).then(pt);
377
- return await this.options.storage.setItem(dt, s), (i = this.onUserDataUpdate) == null || i.call(this, s), s;
377
+ return await this.options.storage.setItem(Ze, s), (i = this.onUserDataUpdate) == null || i.call(this, s), s;
378
378
  }
379
379
  async requestPasskeyLogin(e = {}) {
380
380
  var d, p;
@@ -409,18 +409,18 @@ class Fr {
409
409
  credentials: "include"
410
410
  }
411
411
  ).then(pt);
412
- return await this.options.storage.setItem(dt, a), (p = this.onUserDataUpdate) == null || p.call(this, a), a;
412
+ return await this.options.storage.setItem(Ze, a), (p = this.onUserDataUpdate) == null || p.call(this, a), a;
413
413
  }
414
414
  async guestLogin() {
415
415
  var t;
416
416
  const e = await fetch(this.options.authUrl + "/sign-out", {
417
417
  credentials: "include"
418
418
  }).then(pt);
419
- return await this.options.storage.setItem(dt, e), (t = this.onUserDataUpdate) == null || t.call(this, e), e;
419
+ return await this.options.storage.setItem(Ze, e), (t = this.onUserDataUpdate) == null || t.call(this, e), e;
420
420
  }
421
421
  getLastLoginData() {
422
422
  return this.options.storage.getItem(
423
- dt
423
+ Ze
424
424
  );
425
425
  }
426
426
  }
@@ -675,7 +675,7 @@ function es(r, ...e) {
675
675
  function Lt(r) {
676
676
  return ge.decode(r).replace(/\n/g, "␊").replace(/\r/g, "␍");
677
677
  }
678
- function it(r, e = !0) {
678
+ function nt(r, e = !0) {
679
679
  const t = e ? N.errorForCode(O.Timeout) : null;
680
680
  let s, i;
681
681
  const n = new Promise((o, a) => {
@@ -689,7 +689,7 @@ function it(r, e = !0) {
689
689
  });
690
690
  return Object.assign(n, s);
691
691
  }
692
- function at(r = 0) {
692
+ function ct(r = 0) {
693
693
  let e;
694
694
  const t = new Promise((s) => {
695
695
  const i = setTimeout(() => {
@@ -1021,7 +1021,7 @@ class Ds {
1021
1021
  }
1022
1022
  }
1023
1023
  h(Ds, "jc");
1024
- function et(r) {
1024
+ function tt(r) {
1025
1025
  return ts("durable", r);
1026
1026
  }
1027
1027
  function le(r) {
@@ -1095,7 +1095,7 @@ function Gi(r, e, t) {
1095
1095
  }, n = new Ds(i, ye, {});
1096
1096
  return n._headers = s, n._subject = t, n;
1097
1097
  }
1098
- function tt(r) {
1098
+ function st(r) {
1099
1099
  if (r.data.length !== 0)
1100
1100
  return null;
1101
1101
  const e = r.headers;
@@ -1285,10 +1285,10 @@ var ne;
1285
1285
  (function(r) {
1286
1286
  r.None = "none", r.All = "all", r.Explicit = "explicit", r.NotSet = "";
1287
1287
  })(ne || (ne = {}));
1288
- var nt;
1288
+ var ot;
1289
1289
  (function(r) {
1290
1290
  r.Instant = "instant", r.Original = "original";
1291
- })(nt || (nt = {}));
1291
+ })(ot || (ot = {}));
1292
1292
  var He;
1293
1293
  (function(r) {
1294
1294
  r.None = "none", r.S2 = "s2";
@@ -1303,7 +1303,7 @@ function Vi(r, e = {}) {
1303
1303
  deliver_policy: Q.All,
1304
1304
  ack_policy: ne.Explicit,
1305
1305
  ack_wait: G(30 * 1e3),
1306
- replay_policy: nt.Instant
1306
+ replay_policy: ot.Instant
1307
1307
  }, e);
1308
1308
  }
1309
1309
  var br;
@@ -1318,10 +1318,10 @@ var ke;
1318
1318
  (function(r) {
1319
1319
  r.LastValue = "", r.AllHistory = "history", r.UpdatesOnly = "updates";
1320
1320
  })(ke || (ke = {}));
1321
- var Qe;
1321
+ var et;
1322
1322
  (function(r) {
1323
1323
  r.Stream = "Nats-Stream", r.Sequence = "Nats-Sequence", r.TimeStamp = "Nats-Time-Stamp", r.Subject = "Nats-Subject";
1324
- })(Qe || (Qe = {}));
1324
+ })(et || (et = {}));
1325
1325
  var gr;
1326
1326
  (function(r) {
1327
1327
  r.Stream = "Nats-Stream", r.Subject = "Nats-Subject", r.Sequence = "Nats-Sequence", r.LastSequence = "Nats-Last-Sequence", r.Size = "Nats-Msg-Size";
@@ -1364,7 +1364,7 @@ class Wi {
1364
1364
  return this.config.deliver_subject = e, this;
1365
1365
  }
1366
1366
  durable(e) {
1367
- return et(e), this.config.durable_name = e, this;
1367
+ return tt(e), this.config.durable_name = e, this;
1368
1368
  }
1369
1369
  startSequence(e) {
1370
1370
  if (e <= 0)
@@ -1411,10 +1411,10 @@ class Wi {
1411
1411
  return this.filters = this.filters || [], this.filters.push(e), this;
1412
1412
  }
1413
1413
  replayInstantly() {
1414
- return this.config.replay_policy = nt.Instant, this;
1414
+ return this.config.replay_policy = ot.Instant, this;
1415
1415
  }
1416
1416
  replayOriginal() {
1417
- return this.config.replay_policy = nt.Original, this;
1417
+ return this.config.replay_policy = ot.Original, this;
1418
1418
  }
1419
1419
  sample(e) {
1420
1420
  if (e = Math.trunc(e), e < 0 || e > 100)
@@ -1497,12 +1497,12 @@ class Yi {
1497
1497
  return t ? Uint8Array.from(s, (i) => i.charCodeAt(0)) : s;
1498
1498
  }
1499
1499
  }
1500
- class st {
1500
+ class rt {
1501
1501
  static encode(e) {
1502
- return st.toB64URLEncoding(Yi.encode(e));
1502
+ return rt.toB64URLEncoding(Yi.encode(e));
1503
1503
  }
1504
1504
  static decode(e, t = !1) {
1505
- return st.decode(st.fromB64URLEncoding(e), t);
1505
+ return rt.decode(rt.fromB64URLEncoding(e), t);
1506
1506
  }
1507
1507
  static toB64URLEncoding(e) {
1508
1508
  return e.replace(/\+/g, "-").replace(/\//g, "_");
@@ -1511,7 +1511,7 @@ class st {
1511
1511
  return e.replace(/_/g, "/").replace(/-/g, "+");
1512
1512
  }
1513
1513
  }
1514
- class ot {
1514
+ class at {
1515
1515
  constructor() {
1516
1516
  h(this, "buffers");
1517
1517
  h(this, "byteLength");
@@ -1972,7 +1972,7 @@ class Gr extends zr {
1972
1972
  super(t, s, n);
1973
1973
  h(this, "deferred");
1974
1974
  h(this, "timer");
1975
- this.deferred = K(), this.timer = it(i.timeout, n);
1975
+ this.deferred = K(), this.timer = nt(i.timeout, n);
1976
1976
  }
1977
1977
  resolver(t, s) {
1978
1978
  this.timer && this.timer.cancel(), t ? (this.ctx && (t.stack += `
@@ -2022,7 +2022,7 @@ class Ot {
2022
2022
  } catch (d) {
2023
2023
  const p = d;
2024
2024
  if ((p.code === "503" || p.code === O.Timeout) && a + 1 < n)
2025
- await at(o.backoff(a));
2025
+ await ct(o.backoff(a));
2026
2026
  else
2027
2027
  throw d;
2028
2028
  }
@@ -2171,7 +2171,7 @@ class Yt extends Ot {
2171
2171
  if (t.deliver_group && t.idle_heartbeat)
2172
2172
  throw new Error("jetstream idle heartbeat is not supported with queue groups");
2173
2173
  const i = {};
2174
- i.config = t, i.stream_name = e, i.action = s, i.config.durable_name && et(i.config.durable_name);
2174
+ i.config = t, i.stream_name = e, i.action = s, i.config.durable_name && tt(i.config.durable_name);
2175
2175
  const n = this.nc;
2176
2176
  let { min: o, ok: a } = n.features.get(H.JS_NEW_CONSUMER_CREATE_API);
2177
2177
  const d = t.name === "" ? void 0 : t.name;
@@ -2208,10 +2208,10 @@ class Yt extends Ot {
2208
2208
  return this.add(e, Object.assign(i.config, n), Wt.Update);
2209
2209
  }
2210
2210
  async info(e, t) {
2211
- return le(e), et(t), await this._request(`${this.prefix}.CONSUMER.INFO.${e}.${t}`);
2211
+ return le(e), tt(t), await this._request(`${this.prefix}.CONSUMER.INFO.${e}.${t}`);
2212
2212
  }
2213
2213
  async delete(e, t) {
2214
- return le(e), et(t), (await this._request(`${this.prefix}.CONSUMER.DELETE.${e}.${t}`)).success;
2214
+ return le(e), tt(t), (await this._request(`${this.prefix}.CONSUMER.DELETE.${e}.${t}`)).success;
2215
2215
  }
2216
2216
  list(e) {
2217
2217
  le(e);
@@ -2228,7 +2228,7 @@ class Yt extends Ot {
2228
2228
  return this.pause(e, t, /* @__PURE__ */ new Date(0));
2229
2229
  }
2230
2230
  }
2231
- function Ze(r, e, t = !1) {
2231
+ function Qe(r, e, t = !1) {
2232
2232
  if (t === !0 && !r)
2233
2233
  throw N.errorForCode(O.ApiError, new Error(`${e} is not a function`));
2234
2234
  if (r && typeof r != "function")
@@ -2240,7 +2240,7 @@ class dn extends oe {
2240
2240
  h(this, "sub");
2241
2241
  h(this, "adapter");
2242
2242
  h(this, "subIterDone");
2243
- Ze(i.adapter, "adapter", !0), this.adapter = i.adapter, i.callback && Ze(i.callback, "callback"), this.noIterator = typeof i.callback == "function", i.ingestionFilterFn && (Ze(i.ingestionFilterFn, "ingestionFilterFn"), this.ingestionFilterFn = i.ingestionFilterFn), i.protocolFilterFn && (Ze(i.protocolFilterFn, "protocolFilterFn"), this.protocolFilterFn = i.protocolFilterFn), i.dispatchedFn && (Ze(i.dispatchedFn, "dispatchedFn"), this.dispatchedFn = i.dispatchedFn), i.cleanupFn && Ze(i.cleanupFn, "cleanupFn");
2243
+ Qe(i.adapter, "adapter", !0), this.adapter = i.adapter, i.callback && Qe(i.callback, "callback"), this.noIterator = typeof i.callback == "function", i.ingestionFilterFn && (Qe(i.ingestionFilterFn, "ingestionFilterFn"), this.ingestionFilterFn = i.ingestionFilterFn), i.protocolFilterFn && (Qe(i.protocolFilterFn, "protocolFilterFn"), this.protocolFilterFn = i.protocolFilterFn), i.dispatchedFn && (Qe(i.dispatchedFn, "dispatchedFn"), this.dispatchedFn = i.dispatchedFn), i.cleanupFn && Qe(i.cleanupFn, "cleanupFn");
2244
2244
  let n = (g, y) => {
2245
2245
  this.callback(g, y);
2246
2246
  };
@@ -2334,7 +2334,7 @@ function Rs() {
2334
2334
  return _e !== void 0 && _e.dnsResolveFn ? _e.dnsResolveFn : void 0;
2335
2335
  }
2336
2336
  const Ht = `\r
2337
- `, Xt = ot.fromAscii(Ht), bn = new Uint8Array(Xt)[0], gn = new Uint8Array(Xt)[1];
2337
+ `, Xt = at.fromAscii(Ht), bn = new Uint8Array(Xt)[0], gn = new Uint8Array(Xt)[1];
2338
2338
  function _n(r) {
2339
2339
  for (let e = 0; e < r.length; e++) {
2340
2340
  const t = e + 1;
@@ -3690,7 +3690,7 @@ var C;
3690
3690
  var v = new Uint8Array(32);
3691
3691
  return jt(v, m, b), ai(c, l, u, f, v);
3692
3692
  }
3693
- function ct() {
3693
+ function ht() {
3694
3694
  var c = 0, l = 0, u = 0, f = 0, m = 65535, b, v, E;
3695
3695
  for (E = 0; E < arguments.length; E++)
3696
3696
  b = arguments[E].lo, v = arguments[E].hi, c += b & m, l += b >>> 16, u += v & m, f += v >>> 16;
@@ -3818,13 +3818,13 @@ var C;
3818
3818
  for (_ = 0; _ < 16; _++) v[_] = J(l, 8 * _ + M);
3819
3819
  for (_ = 0; _ < 80; _++) {
3820
3820
  for (S = 0; S < 8; S++) m[S] = b[S];
3821
- for (E = ct(b[7], di(b[4]), ui(b[4], b[5], b[6]), bi[_], v[_ % 16]), m[7] = ct(E, fi(b[0]), li(b[0], b[1], b[2])), m[3] = ct(m[3], E), S = 0; S < 8; S++) b[(S + 1) % 8] = m[S];
3821
+ for (E = ht(b[7], di(b[4]), ui(b[4], b[5], b[6]), bi[_], v[_ % 16]), m[7] = ht(E, fi(b[0]), li(b[0], b[1], b[2])), m[3] = ht(m[3], E), S = 0; S < 8; S++) b[(S + 1) % 8] = m[S];
3822
3822
  if (_ % 16 === 15)
3823
3823
  for (S = 0; S < 16; S++)
3824
- v[S] = ct(v[S], v[(S + 9) % 16], pi(v[(S + 1) % 16]), mi(v[(S + 14) % 16]));
3824
+ v[S] = ht(v[S], v[(S + 9) % 16], pi(v[(S + 1) % 16]), mi(v[(S + 14) % 16]));
3825
3825
  }
3826
3826
  for (_ = 0; _ < 8; _++)
3827
- b[_] = ct(b[_], f[_]), f[_] = b[_];
3827
+ b[_] = ht(b[_], f[_]), f[_] = b[_];
3828
3828
  M += 128, u -= 128;
3829
3829
  }
3830
3830
  for (_ = 0; _ < 8; _++) L(c, 8 * _, f[_]);
@@ -4039,7 +4039,7 @@ var C;
4039
4039
  for (m = 0; m < u; m++) c[m] = l[m + 64];
4040
4040
  return u;
4041
4041
  }
4042
- var ls = 32, Ut = 24, ht = 32, We = 16, ut = 32, $t = 32, lt = 32, ft = 32, fs = 32, ir = Ut, yi = ht, wi = We, Te = 64, ze = 32, Ye = 64, ds = 32, ps = 64;
4042
+ var ls = 32, Ut = 24, ut = 32, We = 16, lt = 32, $t = 32, ft = 32, dt = 32, fs = 32, ir = Ut, yi = ut, wi = We, Te = 64, ze = 32, Ye = 64, ds = 32, ps = 64;
4043
4043
  r.lowlevel = {
4044
4044
  crypto_core_hsalsa20: R,
4045
4045
  crypto_stream_xor: z,
@@ -4065,12 +4065,12 @@ var C;
4065
4065
  crypto_sign_open: us,
4066
4066
  crypto_secretbox_KEYBYTES: ls,
4067
4067
  crypto_secretbox_NONCEBYTES: Ut,
4068
- crypto_secretbox_ZEROBYTES: ht,
4068
+ crypto_secretbox_ZEROBYTES: ut,
4069
4069
  crypto_secretbox_BOXZEROBYTES: We,
4070
- crypto_scalarmult_BYTES: ut,
4070
+ crypto_scalarmult_BYTES: lt,
4071
4071
  crypto_scalarmult_SCALARBYTES: $t,
4072
- crypto_box_PUBLICKEYBYTES: lt,
4073
- crypto_box_SECRETKEYBYTES: ft,
4072
+ crypto_box_PUBLICKEYBYTES: ft,
4073
+ crypto_box_SECRETKEYBYTES: dt,
4074
4074
  crypto_box_BEFORENMBYTES: fs,
4075
4075
  crypto_box_NONCEBYTES: ir,
4076
4076
  crypto_box_ZEROBYTES: yi,
@@ -4101,8 +4101,8 @@ var C;
4101
4101
  if (l.length !== Ut) throw new Error("bad nonce size");
4102
4102
  }
4103
4103
  function xi(c, l) {
4104
- if (c.length !== lt) throw new Error("bad public key size");
4105
- if (l.length !== ft) throw new Error("bad secret key size");
4104
+ if (c.length !== ft) throw new Error("bad public key size");
4105
+ if (l.length !== dt) throw new Error("bad secret key size");
4106
4106
  }
4107
4107
  function pe() {
4108
4108
  for (var c = 0; c < arguments.length; c++)
@@ -4116,22 +4116,22 @@ var C;
4116
4116
  return s(l, c), l;
4117
4117
  }, r.secretbox = function(c, l, u) {
4118
4118
  pe(c, l, u), nr(u, l);
4119
- for (var f = new Uint8Array(ht + c.length), m = new Uint8Array(f.length), b = 0; b < c.length; b++) f[b + ht] = c[b];
4119
+ for (var f = new Uint8Array(ut + c.length), m = new Uint8Array(f.length), b = 0; b < c.length; b++) f[b + ut] = c[b];
4120
4120
  return ae(m, f, f.length, l, u), m.subarray(We);
4121
4121
  }, r.secretbox.open = function(c, l, u) {
4122
4122
  pe(c, l, u), nr(u, l);
4123
4123
  for (var f = new Uint8Array(We + c.length), m = new Uint8Array(f.length), b = 0; b < c.length; b++) f[b + We] = c[b];
4124
- return f.length < 32 || ce(m, f, f.length, l, u) !== 0 ? null : m.subarray(ht);
4124
+ return f.length < 32 || ce(m, f, f.length, l, u) !== 0 ? null : m.subarray(ut);
4125
4125
  }, r.secretbox.keyLength = ls, r.secretbox.nonceLength = Ut, r.secretbox.overheadLength = We, r.scalarMult = function(c, l) {
4126
4126
  if (pe(c, l), c.length !== $t) throw new Error("bad n size");
4127
- if (l.length !== ut) throw new Error("bad p size");
4128
- var u = new Uint8Array(ut);
4127
+ if (l.length !== lt) throw new Error("bad p size");
4128
+ var u = new Uint8Array(lt);
4129
4129
  return Ct(u, c, l), u;
4130
4130
  }, r.scalarMult.base = function(c) {
4131
4131
  if (pe(c), c.length !== $t) throw new Error("bad n size");
4132
- var l = new Uint8Array(ut);
4132
+ var l = new Uint8Array(lt);
4133
4133
  return It(l, c), l;
4134
- }, r.scalarMult.scalarLength = $t, r.scalarMult.groupElementLength = ut, r.box = function(c, l, u, f) {
4134
+ }, r.scalarMult.scalarLength = $t, r.scalarMult.groupElementLength = lt, r.box = function(c, l, u, f) {
4135
4135
  var m = r.box.before(u, f);
4136
4136
  return r.secretbox(c, l, m);
4137
4137
  }, r.box.before = function(c, l) {
@@ -4142,19 +4142,19 @@ var C;
4142
4142
  var m = r.box.before(u, f);
4143
4143
  return r.secretbox.open(c, l, m);
4144
4144
  }, r.box.open.after = r.secretbox.open, r.box.keyPair = function() {
4145
- var c = new Uint8Array(lt), l = new Uint8Array(ft);
4145
+ var c = new Uint8Array(ft), l = new Uint8Array(dt);
4146
4146
  return Zs(c, l), {
4147
4147
  publicKey: c,
4148
4148
  secretKey: l
4149
4149
  };
4150
4150
  }, r.box.keyPair.fromSecretKey = function(c) {
4151
- if (pe(c), c.length !== ft) throw new Error("bad secret key size");
4152
- var l = new Uint8Array(lt);
4151
+ if (pe(c), c.length !== dt) throw new Error("bad secret key size");
4152
+ var l = new Uint8Array(ft);
4153
4153
  return It(l, c), {
4154
4154
  publicKey: l,
4155
4155
  secretKey: new Uint8Array(c)
4156
4156
  };
4157
- }, 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) {
4157
+ }, r.box.publicKeyLength = ft, r.box.secretKeyLength = dt, r.box.sharedKeyLength = fs, r.box.nonceLength = ir, r.box.overheadLength = r.secretbox.overheadLength, r.sign = function(c, l) {
4158
4158
  if (pe(c, l), l.length !== Ye) throw new Error("bad secret key size");
4159
4159
  var u = new Uint8Array(Te + c.length);
4160
4160
  return rr(u, c, c.length, l), u;
@@ -4366,7 +4366,7 @@ class Zr extends oe {
4366
4366
  h(this, "requestSubject");
4367
4367
  es(this, i), this.protocol = t, this.subject = s, this.draining = !1, this.noIterator = typeof i.callback == "function", this.closed = K();
4368
4368
  const n = !((o = t.options) != null && o.noAsyncTraces);
4369
- i.timeout && (this.timer = it(i.timeout, n), this.timer.then(() => {
4369
+ i.timeout && (this.timer = nt(i.timeout, n), this.timer.then(() => {
4370
4370
  this.timer = void 0;
4371
4371
  }).catch((a) => {
4372
4372
  this.stop(a), this.noIterator && this.callback(a, {});
@@ -4512,7 +4512,7 @@ class Zt {
4512
4512
  h(this, "server");
4513
4513
  h(this, "features");
4514
4514
  h(this, "connectPromise");
4515
- 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({
4515
+ 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 at(), this.pongs = [], this.whyClosed = "", this.pendingLimit = e.pendingLimit || this.pendingLimit, this.features = new fn({
4516
4516
  major: 0,
4517
4517
  minor: 0,
4518
4518
  micro: 0
@@ -4585,7 +4585,7 @@ class Zt {
4585
4585
  const t = this.prepare();
4586
4586
  let s;
4587
4587
  try {
4588
- s = it(this.options.timeout || 2e4);
4588
+ s = nt(this.options.timeout || 2e4);
4589
4589
  const i = this.transport.connect(e, this.options);
4590
4590
  await Promise.race([
4591
4591
  i,
@@ -4663,7 +4663,7 @@ class Zt {
4663
4663
  a !== -1 && i.reconnects >= a && this.servers.removeCurrentServer();
4664
4664
  }
4665
4665
  } else
4666
- s = Math.min(s, i.lastConnect + t - n), await at(s);
4666
+ s = Math.min(s, i.lastConnect + t - n), await ct(s);
4667
4667
  }
4668
4668
  }
4669
4669
  static async connect(e, t) {
@@ -5851,10 +5851,10 @@ var Ne;
5851
5851
  (function(r) {
5852
5852
  r.HeartbeatsMissed = "heartbeats_missed", r.ConsumerNotFound = "consumer_not_found", r.StreamNotFound = "stream_not_found", r.ConsumerDeleted = "consumer_deleted", r.OrderedConsumerRecreated = "ordered_consumer_recreated", r.NoResponders = "no_responders";
5853
5853
  })(Ne || (Ne = {}));
5854
- var rt;
5854
+ var it;
5855
5855
  (function(r) {
5856
5856
  r.DebugEvent = "debug", r.Discard = "discard", r.Reset = "reset", r.Next = "next";
5857
- })(rt || (rt = {}));
5857
+ })(it || (it = {}));
5858
5858
  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);
5859
5859
  function Pt(r, e = 5e3) {
5860
5860
  return new Ro(r, e);
@@ -5910,7 +5910,7 @@ class vs extends oe {
5910
5910
  return;
5911
5911
  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);
5912
5912
  if (X > 0 || L > 0)
5913
- this.pending.msgs -= X, this.pending.bytes -= L, this.pending.requests--, this.notify(rt.Discard, {
5913
+ this.pending.msgs -= X, this.pending.bytes -= L, this.pending.requests--, this.notify(it.Discard, {
5914
5914
  msgsLeft: X,
5915
5915
  bytesLeft: L
5916
5916
  });
@@ -5930,7 +5930,7 @@ class vs extends oe {
5930
5930
  return;
5931
5931
  }
5932
5932
  } else
5933
- this.notify(rt.DebugEvent, `${T} ${J}`);
5933
+ this.notify(it.DebugEvent, `${T} ${J}`);
5934
5934
  } else
5935
5935
  this._push(Pt(p, this.consumer.api.timeout)), this.received++, this.pending.msgs && this.pending.msgs--, this.pending.bytes && (this.pending.bytes -= p.size());
5936
5936
  if (this.pending.msgs === 0 && this.pending.bytes === 0 && (this.pending.requests = 0), this.refilling) {
@@ -6027,7 +6027,7 @@ class vs extends oe {
6027
6027
  } else
6028
6028
  t = 0, s = 0;
6029
6029
  this.inBackOff = !0;
6030
- const a = i.backoff(n), d = at(a);
6030
+ const a = i.backoff(n), d = ct(a);
6031
6031
  await Promise.race([
6032
6032
  d,
6033
6033
  this.consumer.api.nc.closed()
@@ -6041,7 +6041,7 @@ class vs extends oe {
6041
6041
  this._push(() => {
6042
6042
  s.publish(`${this.consumer.api.prefix}.CONSUMER.MSG.NEXT.${this.consumer.stream}.${this.consumer.name}`, this.consumer.api.jc.encode(t), {
6043
6043
  reply: this.inbox
6044
- }), this.notify(rt.Next, t);
6044
+ }), this.notify(it.Next, t);
6045
6045
  });
6046
6046
  }
6047
6047
  pullOptions() {
@@ -6165,7 +6165,7 @@ class Us {
6165
6165
  max_messages: 100,
6166
6166
  expires: 3e4
6167
6167
  }) {
6168
- const t = new vs(this, e, !1), s = Math.round(t.opts.expires * 1.05), i = it(s);
6168
+ const t = new vs(this, e, !1), s = Math.round(t.opts.expires * 1.05), i = nt(s);
6169
6169
  return t.closed().catch(() => {
6170
6170
  }).finally(() => {
6171
6171
  i.cancel();
@@ -6192,7 +6192,7 @@ class Us {
6192
6192
  }
6193
6193
  })().catch(() => {
6194
6194
  });
6195
- const o = it(n);
6195
+ const o = nt(n);
6196
6196
  return i.closed().then((a) => {
6197
6197
  a ? t.reject(a) : t.resolve(null);
6198
6198
  }).catch((a) => {
@@ -6270,7 +6270,7 @@ class go {
6270
6270
  return (g = this.iter) == null || g.stop(x), Promise.reject(x);
6271
6271
  if (t && y >= this.maxInitialReset)
6272
6272
  throw x;
6273
- await at(i.backoff(y + 1));
6273
+ await ct(i.backoff(y + 1));
6274
6274
  }
6275
6275
  return n;
6276
6276
  }
@@ -6310,7 +6310,7 @@ class go {
6310
6310
  }
6311
6311
  notifyOrderedResetAndReset() {
6312
6312
  var e;
6313
- (e = this.iter) == null || e.notify(rt.Reset, ""), this.reset(this.opts, {
6313
+ (e = this.iter) == null || e.notify(it.Reset, ""), this.reset(this.opts, {
6314
6314
  orderedReset: !0
6315
6315
  });
6316
6316
  }
@@ -6595,7 +6595,7 @@ class _o extends Ot {
6595
6595
  i && (s = null);
6596
6596
  const n = s ? this.jc.encode(s) : ye, o = this.opts.apiPrefix || "$JS.API", a = i ? `${o}.DIRECT.GET.${e}.${i}` : `${o}.DIRECT.GET.${e}`, d = await this.nc.request(a, n, {
6597
6597
  timeout: this.timeout
6598
- }), p = tt(d);
6598
+ }), p = st(d);
6599
6599
  if (p)
6600
6600
  return Promise.reject(p);
6601
6601
  const g = new Ls(d);
@@ -6648,20 +6648,20 @@ class Ls {
6648
6648
  this.data = e.data, this.header = e.headers;
6649
6649
  }
6650
6650
  get subject() {
6651
- return this.header.last(Qe.Subject);
6651
+ return this.header.last(et.Subject);
6652
6652
  }
6653
6653
  get seq() {
6654
- const e = this.header.last(Qe.Sequence);
6654
+ const e = this.header.last(et.Sequence);
6655
6655
  return typeof e == "string" ? parseInt(e) : 0;
6656
6656
  }
6657
6657
  get time() {
6658
6658
  return new Date(Date.parse(this.timestamp));
6659
6659
  }
6660
6660
  get timestamp() {
6661
- return this.header.last(Qe.TimeStamp);
6661
+ return this.header.last(et.TimeStamp);
6662
6662
  }
6663
6663
  get stream() {
6664
- return this.header.last(Qe.Stream);
6664
+ return this.header.last(et.Stream);
6665
6665
  }
6666
6666
  json(e) {
6667
6667
  return Ee(e).decode(this.data);
@@ -6909,7 +6909,7 @@ class St {
6909
6909
  nuid: P,
6910
6910
  size: 0,
6911
6911
  chunks: 0
6912
- }, Nr(e)), X = K(), L = [], Y = new ot();
6912
+ }, Nr(e)), X = K(), L = [], Y = new at();
6913
6913
  try {
6914
6914
  const w = t ? t.getReader() : null, j = Sr.create();
6915
6915
  for (; ; ) {
@@ -6925,7 +6925,7 @@ class St {
6925
6925
  }));
6926
6926
  }
6927
6927
  await Promise.all(L), L.length = 0, J.mtime = (/* @__PURE__ */ new Date()).toISOString();
6928
- const A = st.encode(j.digest());
6928
+ const A = rt.encode(j.digest());
6929
6929
  J.digest = `${jr}${A}`, J.deleted = !1;
6930
6930
  const U = Ue();
6931
6931
  typeof o == "number" && U.set(Re.ExpectedLastSubjectSequenceHdr, `${o}`), U.set(de.RollupHdr, de.RollupValueSubject);
@@ -6975,7 +6975,7 @@ class St {
6975
6975
  }
6976
6976
  async getBlob(e) {
6977
6977
  async function t(n) {
6978
- const o = new ot(), a = n.getReader();
6978
+ const o = new at(), a = n.getReader();
6979
6979
  for (; ; ) {
6980
6980
  const { done: d, value: p } = await a.read();
6981
6981
  if (d)
@@ -7146,7 +7146,7 @@ class St {
7146
7146
  return `$O.${this.name}.C.${e}`;
7147
7147
  }
7148
7148
  _metaSubject(e) {
7149
- return `$O.${this.name}.M.${st.encode(e)}`;
7149
+ return `$O.${this.name}.M.${rt.encode(e)}`;
7150
7150
  }
7151
7151
  _metaSubjectAll() {
7152
7152
  return `$O.${this.name}.M.>`;
@@ -7231,7 +7231,7 @@ class Gs extends Ot {
7231
7231
  break;
7232
7232
  } catch (P) {
7233
7233
  if (P.code === "503" && x + 1 < d)
7234
- await at(p);
7234
+ await ct(p);
7235
7235
  else
7236
7236
  throw P;
7237
7237
  }
@@ -7241,7 +7241,7 @@ class Gs extends Ot {
7241
7241
  return y.duplicate = y.duplicate ? y.duplicate : !1, y;
7242
7242
  }
7243
7243
  async pull(t, s, i = 0) {
7244
- le(t), et(s);
7244
+ le(t), tt(s);
7245
7245
  let n = this.timeout;
7246
7246
  i > n && (n = i), i = i < 0 ? 0 : G(i);
7247
7247
  const o = {
@@ -7251,13 +7251,13 @@ class Gs extends Ot {
7251
7251
  }, a = await this.nc.request(`${this.prefix}.CONSUMER.MSG.NEXT.${t}.${s}`, this.jc.encode(o), {
7252
7252
  noMux: !0,
7253
7253
  timeout: n
7254
- }), d = tt(a);
7254
+ }), d = st(a);
7255
7255
  if (d)
7256
7256
  throw d;
7257
7257
  return Pt(a, this.timeout);
7258
7258
  }
7259
7259
  fetch(t, s, i = {}) {
7260
- le(t), et(s);
7260
+ le(t), tt(s);
7261
7261
  let n = null;
7262
7262
  const o = (i.max_bytes ?? 0) > 0;
7263
7263
  let a = 0;
@@ -7288,10 +7288,10 @@ class Gs extends Ot {
7288
7288
  const J = Me(this.nc.options.inboxPrefix), X = this.nc.subscribe(J, {
7289
7289
  max: i.batch,
7290
7290
  callback: (L, Y) => {
7291
- 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)));
7291
+ L === null && (L = st(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)));
7292
7292
  }
7293
7293
  });
7294
- return y && (n = it(y), n.catch(() => {
7294
+ return y && (n = nt(y), n.catch(() => {
7295
7295
  X.isClosed() || (X.drain().catch(() => {
7296
7296
  }), n = null), p && p.cancel();
7297
7297
  })), (async () => {
@@ -7395,7 +7395,7 @@ class Gs extends Ot {
7395
7395
  deliver_policy: Q.All,
7396
7396
  ack_policy: ne.Explicit,
7397
7397
  ack_wait: G(30 * 1e3),
7398
- replay_policy: nt.Instant
7398
+ replay_policy: ot.Instant
7399
7399
  }, t.config);
7400
7400
  const s = await this.consumerAPI.add(t.stream, t.config);
7401
7401
  if (Array.isArray(t.config.filter_subjects && !Array.isArray(s.config.filter_subjects)))
@@ -7411,7 +7411,7 @@ class Gs extends Ot {
7411
7411
  protocol: !1
7412
7412
  };
7413
7413
  const o = s;
7414
- if (tt(o.msg) || (d = n.monitor) == null || d.work(), Os(o.msg)) {
7414
+ if (st(o.msg) || (d = n.monitor) == null || d.work(), Os(o.msg)) {
7415
7415
  const p = t ? n._checkHbOrderConsumer(o.msg) : !0;
7416
7416
  return t || n.info.flow_control.heartbeat_count++, {
7417
7417
  ingest: p,
@@ -7908,7 +7908,7 @@ function ko(r) {
7908
7908
  return (e, t) => e ? [
7909
7909
  e,
7910
7910
  null
7911
- ] : (e = tt(t), e ? [
7911
+ ] : (e = st(t), e ? [
7912
7912
  e,
7913
7913
  null
7914
7914
  ] : [
@@ -7923,7 +7923,7 @@ function Co(r) {
7923
7923
  e,
7924
7924
  null
7925
7925
  ];
7926
- const s = tt(t);
7926
+ const s = st(t);
7927
7927
  return s !== null ? [
7928
7928
  ri(s),
7929
7929
  null
@@ -8041,7 +8041,7 @@ class Ro {
8041
8041
  }) {
8042
8042
  const s = {};
8043
8043
  s.batch = t.batch || 1, s.no_wait = t.no_wait || !1, t.expires && t.expires > 0 && (s.expires = G(t.expires));
8044
- const i = Ee().encode(s), n = ot.concat(fo, mo, i), o = e ? {
8044
+ const i = Ee().encode(s), n = at.concat(fo, mo, i), o = e ? {
8045
8045
  reply: e
8046
8046
  } : void 0;
8047
8047
  this.msg.respond(n, o);
@@ -8095,7 +8095,7 @@ class Mo {
8095
8095
  this.signal.resolve();
8096
8096
  return;
8097
8097
  }
8098
- const o = ot.concat(...this.yields), a = yn(o);
8098
+ const o = at.concat(...this.yields), a = yn(o);
8099
8099
  if (a !== "") {
8100
8100
  const d = Kn.exec(a);
8101
8101
  if (!d) {
@@ -8130,7 +8130,7 @@ class Mo {
8130
8130
  if (!this.isDiscarded() && this.connected && !this.done) {
8131
8131
  if (this.closeError = e, !e)
8132
8132
  for (; !this.socketClosed && this.socket.bufferedAmount > 0; )
8133
- await at(100);
8133
+ await ct(100);
8134
8134
  this.done = !0;
8135
8135
  try {
8136
8136
  this.socket.close(e ? 1002 : 1e3, e ? e.message : void 0);
@@ -8566,10 +8566,14 @@ const oi = {
8566
8566
  storage: new ii()
8567
8567
  }, Mr = new Fr(oi), Jo = {
8568
8568
  setup(r) {
8569
- (r.authUrl || r.storage) && (this.auth = new Fr({
8570
- authUrl: r.authUrl ?? this.auth.url,
8571
- storage: r.storage ?? this.storage
8572
- })), (r.natsUrl || r.storage) && (this.nats = new Tr({
8569
+ if (r.authUrl || r.storage) {
8570
+ const e = this.auth.onUserDataUpdate;
8571
+ this.auth = new Fr({
8572
+ authUrl: r.authUrl ?? this.auth.url,
8573
+ storage: r.storage ?? this.storage
8574
+ }), this.auth.onUserDataUpdate = e;
8575
+ }
8576
+ (r.natsUrl || r.storage) && (this.nats = new Tr({
8573
8577
  natsUrl: r.natsUrl ?? this.nats.url,
8574
8578
  auth: this.auth
8575
8579
  }));