@nexus-cross/crossx-sdk-core 1.2.4-beta.1 → 1.2.5

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.
Files changed (31) hide show
  1. package/dist/adapters/crypto/JoseCryptoAdapter.d.ts +2 -0
  2. package/dist/adapters/crypto/JoseCryptoAdapter.d.ts.map +1 -1
  3. package/dist/adapters/oauth/BrowserOAuthAdapter.d.ts.map +1 -1
  4. package/dist/adapters/storage/IndexedDBStorageAdapter.d.ts +7 -0
  5. package/dist/adapters/storage/IndexedDBStorageAdapter.d.ts.map +1 -1
  6. package/dist/adapters/transport/FetchTransportAdapter.d.ts +1 -0
  7. package/dist/adapters/transport/FetchTransportAdapter.d.ts.map +1 -1
  8. package/dist/adapters/wallet/RemoteWalletProviderAdapter.d.ts.map +1 -1
  9. package/dist/core/constants.d.ts +2 -2
  10. package/dist/core/constants.d.ts.map +1 -1
  11. package/dist/core/ports/CryptoPort.d.ts +5 -0
  12. package/dist/core/ports/CryptoPort.d.ts.map +1 -1
  13. package/dist/core/ports/TransportPort.d.ts +2 -0
  14. package/dist/core/ports/TransportPort.d.ts.map +1 -1
  15. package/dist/core/services/JsonRpcService.d.ts +1 -0
  16. package/dist/core/services/JsonRpcService.d.ts.map +1 -1
  17. package/dist/core/services/TokenMemoryStore.d.ts +1 -0
  18. package/dist/core/services/TokenMemoryStore.d.ts.map +1 -1
  19. package/dist/core/types/internal.d.ts +5 -0
  20. package/dist/core/types/internal.d.ts.map +1 -1
  21. package/dist/core/usecases/SignInUseCase.d.ts +10 -0
  22. package/dist/core/usecases/SignInUseCase.d.ts.map +1 -1
  23. package/dist/core/usecases/SignOutUseCase.d.ts +3 -0
  24. package/dist/core/usecases/SignOutUseCase.d.ts.map +1 -1
  25. package/dist/crossx.global +116 -116
  26. package/dist/index.cjs +31 -31
  27. package/dist/index.js +965 -824
  28. package/dist/sdk/CROSSxSDK.d.ts +11 -0
  29. package/dist/sdk/CROSSxSDK.d.ts.map +1 -1
  30. package/dist/sdk/factory.d.ts.map +1 -1
  31. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- var Cs = Object.defineProperty;
2
- var Os = (r, e, s) => e in r ? Cs(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
- var I = (r, e, s) => Os(r, typeof e != "symbol" ? e + "" : e, s);
4
- import { decodeJwt as Ls } from "jose";
1
+ var Os = Object.defineProperty;
2
+ var Ls = (r, e, s) => e in r ? Os(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
+ var T = (r, e, s) => Ls(r, typeof e != "symbol" ? e + "" : e, s);
4
+ import { createRemoteJWKSet as Ds, jwtVerify as Ms, decodeJwt as $s } from "jose";
5
5
  var p = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.ALREADY_AUTHENTICATED = "ALREADY_AUTHENTICATED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", r.USER_REJECTED = "USER_REJECTED", r.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", r.NETWORK_ERROR = "NETWORK_ERROR", r.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", r.INVALID_CHAIN = "INVALID_CHAIN", r.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", r.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.SIGNATURE_FAILED = "SIGNATURE_FAILED", r.TRANSACTION_FAILED = "TRANSACTION_FAILED", r.PREPARE_FAILED = "PREPARE_FAILED", r.PREPARE_EXPIRED = "PREPARE_EXPIRED", r.PREPARE_MISMATCH = "PREPARE_MISMATCH", r.MIGRATION_FAILED = "MIGRATION_FAILED", r.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", r.MIGRATION_PIN_LOCKED = "MIGRATION_PIN_LOCKED", r.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", r.WALLET_INCONSISTENT_STATE = "WALLET_INCONSISTENT_STATE", r.PROJECT_ID_MISSING = "PROJECT_ID_MISSING", r.ORIGIN_NOT_ALLOWED = "ORIGIN_NOT_ALLOWED", r.APP_IDENTIFIER_MISSING = "APP_IDENTIFIER_MISSING", r.INVALID_APP_TYPE = "INVALID_APP_TYPE", r.PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED", r.SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH", r.GAS_ESTIMATION_FAILED = "GAS_ESTIMATION_FAILED", r.TYPED_DATA_CHAIN_ID_MISMATCH = "TYPED_DATA_CHAIN_ID_MISMATCH", r.PIN_NOT_SET = "PIN_NOT_SET", r.PIN_WRONG = "PIN_WRONG", r.PIN_INVALID = "PIN_INVALID", r.PIN_CANCELLED = "PIN_CANCELLED", r.PIN_LOCKED = "PIN_LOCKED", r.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(p || {});
6
6
  class g extends Error {
7
7
  constructor(e, s, t) {
@@ -65,20 +65,20 @@ const Ke = {
65
65
  rpcUrl: "https://saigon-testnet.roninchain.com/rpc",
66
66
  testnet: !0
67
67
  }
68
- }, Xn = Object.fromEntries(
68
+ }, eo = Object.fromEntries(
69
69
  Object.entries(Ke).map(([r, e]) => [r, e.caipId])
70
- ), Ds = new Map(
70
+ ), Bs = new Map(
71
71
  Object.values(Ke).map((r) => [r.caipId, r])
72
72
  );
73
73
  new Map(
74
74
  Object.values(Ke).map((r) => [r.chainId, r])
75
75
  );
76
- const Ms = { symbol: "", decimals: 18 };
77
- function Ze(r) {
76
+ const Us = { symbol: "", decimals: 18 };
77
+ function Ye(r) {
78
78
  var e;
79
- return ((e = Ds.get(r)) == null ? void 0 : e.nativeCurrency) ?? Ms;
79
+ return ((e = Bs.get(r)) == null ? void 0 : e.nativeCurrency) ?? Us;
80
80
  }
81
- class $s {
81
+ class Hs {
82
82
  constructor(e, s) {
83
83
  this.sdk = e, this.chainId = s, this._listeners = /* @__PURE__ */ new Map();
84
84
  }
@@ -167,30 +167,30 @@ class $s {
167
167
  };
168
168
  }
169
169
  }
170
- let ye = null;
171
- function vt(r) {
172
- ye = r;
170
+ let Se = null;
171
+ function bt(r) {
172
+ Se = r;
173
173
  }
174
174
  const u = {
175
175
  log(...r) {
176
- if (ye) {
177
- ye.log(...r);
176
+ if (Se) {
177
+ Se.log(...r);
178
178
  return;
179
179
  }
180
180
  },
181
181
  warn(...r) {
182
- if (ye) {
183
- ye.warn(...r);
182
+ if (Se) {
183
+ Se.warn(...r);
184
184
  return;
185
185
  }
186
186
  },
187
187
  error(...r) {
188
- if (ye) {
189
- ye.error(...r);
188
+ if (Se) {
189
+ Se.error(...r);
190
190
  return;
191
191
  }
192
192
  }
193
- }, Bs = {
193
+ }, Fs = {
194
194
  // ── 공통 버튼 ────────────────────────────────────────────────
195
195
  confirm: "확인",
196
196
  cancel: "취소",
@@ -255,7 +255,7 @@ const u = {
255
255
  // ── PIN 잠금 안내 ─────────────────────────────────────────────
256
256
  pinLocked_message: "잠금이 해제된 후 다시 시도해 주세요.",
257
257
  pinLocked_availableFrom: "이용 가능 시간"
258
- }, Zt = {
258
+ }, Xt = {
259
259
  // ── Common buttons ───────────────────────────────────────────
260
260
  confirm: "Confirm",
261
261
  cancel: "Cancel",
@@ -320,17 +320,19 @@ const u = {
320
320
  // ── PIN lock message ─────────────────────────────────────────
321
321
  pinLocked_message: "Please try again after the lock expires.",
322
322
  pinLocked_availableFrom: "Available from"
323
- }, Us = {
324
- ko: Bs,
325
- en: Zt
323
+ }, Gs = {
324
+ ko: Fs,
325
+ en: Xt
326
326
  };
327
- function St(r = "en", e) {
328
- return Us[r] ?? Zt;
327
+ function vt(r = "en", e) {
328
+ return Gs[r] ?? Xt;
329
329
  }
330
- const $e = "crossx_access_token", Ne = "crossx_refresh_token", Re = "crossx_user_info";
331
- class Hs {
330
+ const St = "crossx_access_token", Et = "crossx_refresh_token", It = "crossx_user_info";
331
+ class Ws {
332
332
  constructor(e, s, t, n, o, i, a) {
333
- this.config = e, this.storage = s, this.crypto = t, this.oauth = n, this.transport = o, this.walletProvider = i, this.tokenStore = a, this._refreshPromise = null;
333
+ this.config = e, this.storage = s, this.crypto = t, this.oauth = n, this.transport = o, this.walletProvider = i, this.tokenStore = a, this._refreshPromise = null, this._migrated = !1;
334
+ const c = e.projectId;
335
+ this.STORAGE_KEY_ACCESS_TOKEN = `crossx_${c}_access_token`, this.STORAGE_KEY_REFRESH_TOKEN = `crossx_${c}_refresh_token`, this.STORAGE_KEY_USER = `crossx_${c}_user_info`;
334
336
  }
335
337
  get useCookieAuth() {
336
338
  return this.config.authMode === "cookie";
@@ -386,13 +388,13 @@ class Hs {
386
388
  const b = await this.crypto.verifyJWT(w);
387
389
  if (t = b.signatureVerified ?? !1, !b.valid)
388
390
  throw u.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
389
- const P = b.payload;
391
+ const k = b.payload;
390
392
  s = {
391
- id: P.sub,
392
- email: P.email,
393
+ id: k.sub,
394
+ email: k.email,
393
395
  signInProvider: S,
394
396
  providerSub: y
395
- }, this.tokenStore.set(w), this.useCookieAuth || (await this.storage.set($e, w), E && await this.storage.set(Ne, E));
397
+ }, this.tokenStore.set(w), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, w), E && this.config.secureStorageAvailable !== !1 ? await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, E) : E && u.warn("[CROSSx] 안전한 스토리지 미사용 — refresh_token 영속 저장을 건너뜁니다"));
396
398
  } else {
397
399
  const B = this.crypto.decodeJWT(x);
398
400
  s = {
@@ -404,7 +406,7 @@ class Hs {
404
406
  }
405
407
  u.log("[CROSSx] 사용자 정보 — id:", s.id);
406
408
  const O = this.useCookieAuth ? { id: s.id, signInProvider: s.signInProvider, providerSub: s.providerSub } : s;
407
- await this.storage.set(Re, O), u.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
409
+ await this.storage.set(this.STORAGE_KEY_USER, O), u.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
408
410
  } catch (c) {
409
411
  return u.error("[CROSSx] SignIn 에러 (OAuth/토큰 교환 단계):", c), {
410
412
  success: !1,
@@ -495,11 +497,12 @@ class Hs {
495
497
  */
496
498
  async restoreSession() {
497
499
  try {
500
+ await this.migrateStorageKeys();
498
501
  const e = this.tokenStore.get();
499
502
  if (e) {
500
503
  const t = await this.crypto.verifyJWT(e);
501
504
  if (t.valid) {
502
- const n = await this.storage.get(Re);
505
+ const n = await this.storage.get(this.STORAGE_KEY_USER);
503
506
  if (n)
504
507
  return u.log("[CROSSx] restoreSession — 메모리 토큰 유효, 세션 복원"), this.loadWallet(n, t.signatureVerified);
505
508
  }
@@ -510,7 +513,7 @@ class Hs {
510
513
  const t = await this.silentRefresh();
511
514
  t && this.tokenStore.set(t);
512
515
  } else {
513
- const t = await this.storage.get($e), n = await this.storage.get(Ne);
516
+ const t = await this.storage.get(this.STORAGE_KEY_ACCESS_TOKEN), n = await this.storage.get(this.STORAGE_KEY_REFRESH_TOKEN);
514
517
  if (u.log(
515
518
  "[CROSSx] restoreSession — access_token:",
516
519
  t ? "있음" : "없음",
@@ -522,7 +525,7 @@ class Hs {
522
525
  const o = await this.silentRefresh(n);
523
526
  u.log("[CROSSx] restoreSession — silentRefresh 결과:", o ? "토큰 발급 성공" : "토큰 없음"), o && this.tokenStore.set(o);
524
527
  }
525
- const s = await this.storage.get(Re);
528
+ const s = await this.storage.get(this.STORAGE_KEY_USER);
526
529
  if (u.log("[CROSSx] restoreSession — userInfo 조회:", s ? `있음 (id: ${s.id})` : "없음"), !s)
527
530
  return null;
528
531
  u.log("[CROSSx] restoreSession — silentRefresh 성공, 세션 복원 — userId:", s.id);
@@ -532,17 +535,12 @@ class Hs {
532
535
  return u.warn("[CROSSx] restoreSession — 지갑 로드 실패 (세션은 유지):", t), { success: !0, user: s, tokenSignatureVerified: !1 };
533
536
  }
534
537
  } catch (e) {
535
- return u.log("[CROSSx] restoreSession — 세션 복원 실패, 스토리지 정리:", e), this.tokenStore.clear(), this.useCookieAuth || await this.storage.remove(Ne), await this.storage.remove(Re), null;
538
+ return u.log("[CROSSx] restoreSession — 세션 복원 실패, 스토리지 정리:", e), this.tokenStore.clear(), this.useCookieAuth || await this.storage.remove(this.STORAGE_KEY_REFRESH_TOKEN), await this.storage.remove(this.STORAGE_KEY_USER), null;
536
539
  }
537
540
  }
538
- /**
539
- * silent refresh (새 access_token 발급)
540
- * 동시 호출 시 단일 요청으로 deduplicate.
541
- * cookie 모드에서는 JWT가 body에 없을 수 있으므로 undefined 반환 가능.
542
- */
543
541
  silentRefresh(e) {
544
- return this._refreshPromise ? this._refreshPromise : (this._refreshPromise = this._doSilentRefresh(e).finally(() => {
545
- this._refreshPromise = null;
542
+ return this._refreshPromise && this._lastRefreshToken === e ? this._refreshPromise : (this._lastRefreshToken = e, this._refreshPromise = this._doSilentRefresh(e).finally(() => {
543
+ this._refreshPromise = null, this._lastRefreshToken = void 0;
546
544
  }), this._refreshPromise);
547
545
  }
548
546
  async _doSilentRefresh(e) {
@@ -569,9 +567,9 @@ class Hs {
569
567
  if (!c)
570
568
  throw new g(p.AUTH_FAILED, "토큰 자동 갱신 실패: 응답에 토큰이 없습니다");
571
569
  if (this.tokenStore.set(c), !t) {
572
- await this.storage.set($e, c);
570
+ await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, c);
573
571
  const l = this.extractRefreshToken(a);
574
- l && await this.storage.set(Ne, l);
572
+ l && this.config.secureStorageAvailable !== !1 && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, l);
575
573
  }
576
574
  return u.log("[CROSSx] silentRefresh 성공"), c;
577
575
  }
@@ -603,7 +601,7 @@ class Hs {
603
601
  u.log("[CROSSx] signInWithJWT — sub:", i.sub, "signatureVerified:", n), t = {
604
602
  id: i.sub,
605
603
  email: i.email
606
- }, this.tokenStore.set(e), this.useCookieAuth || (await this.storage.set($e, e), s && await this.storage.set(Ne, s)), await this.storage.set(Re, t), u.log("[CROSSx] signInWithJWT — 토큰 및 사용자 정보 저장 완료");
604
+ }, this.tokenStore.set(e), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, e), s && this.config.secureStorageAvailable !== !1 && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, s)), await this.storage.set(this.STORAGE_KEY_USER, t), u.log("[CROSSx] signInWithJWT — 토큰 및 사용자 정보 저장 완료");
607
605
  } catch (o) {
608
606
  return u.error("[CROSSx] signInWithJWT 에러:", o), {
609
607
  success: !1,
@@ -612,6 +610,26 @@ class Hs {
612
610
  }
613
611
  return this.loadWallet(t, n);
614
612
  }
613
+ /**
614
+ * 레거시 고정 키(`crossx_*`) → projectId 스코프 키(`crossx_{pid}_*`) 마이그레이션.
615
+ * 최초 1회만 실행되며, 레거시 키의 데이터가 있고 새 키에 데이터가 없을 때만 이동.
616
+ */
617
+ async migrateStorageKeys() {
618
+ if (!this._migrated) {
619
+ this._migrated = !0;
620
+ try {
621
+ const e = await this.storage.get(It);
622
+ if (!e || await this.storage.get(this.STORAGE_KEY_USER)) return;
623
+ await this.storage.set(this.STORAGE_KEY_USER, e);
624
+ const t = await this.storage.get(St);
625
+ t && await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, t);
626
+ const n = await this.storage.get(Et);
627
+ n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(It), await this.storage.remove(St), await this.storage.remove(Et), u.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
628
+ } catch (e) {
629
+ u.warn("[CROSSx] 스토리지 키 마이그레이션 실패:", e);
630
+ }
631
+ }
632
+ }
615
633
  async loadWallet(e, s) {
616
634
  let t, n = !1;
617
635
  try {
@@ -641,16 +659,17 @@ class Hs {
641
659
  return u.log("[CROSSx] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
642
660
  }
643
661
  }
644
- const Fs = "crossx_access_token", Gs = "crossx_refresh_token", Ws = "crossx_user_info";
645
662
  class qs {
646
663
  constructor(e, s, t) {
647
664
  this.config = e, this.storage = s, this.tokenStore = t;
665
+ const n = e.projectId;
666
+ this.STORAGE_KEY_ACCESS_TOKEN = `crossx_${n}_access_token`, this.STORAGE_KEY_REFRESH_TOKEN = `crossx_${n}_refresh_token`, this.STORAGE_KEY_USER = `crossx_${n}_user_info`;
648
667
  }
649
668
  async execute() {
650
- this.tokenStore.clear(), this.config.authMode !== "cookie" && (await this.storage.remove(Fs), await this.storage.remove(Gs)), await this.storage.remove(Ws);
669
+ this.tokenStore.clear(), this.config.authMode !== "cookie" && (await this.storage.remove(this.STORAGE_KEY_ACCESS_TOKEN), await this.storage.remove(this.STORAGE_KEY_REFRESH_TOKEN)), await this.storage.remove(this.STORAGE_KEY_USER), await this.storage.clear();
651
670
  }
652
671
  }
653
- class Vs {
672
+ class Ks {
654
673
  constructor(e, s) {
655
674
  this.storage = e, this.walletProvider = s;
656
675
  }
@@ -667,7 +686,7 @@ class Vs {
667
686
  };
668
687
  }
669
688
  }
670
- class Xt {
689
+ class Qt {
671
690
  constructor() {
672
691
  this.encryptedBytes = null, this.xorKey = null;
673
692
  }
@@ -708,9 +727,9 @@ class Xt {
708
727
  return this.encryptedBytes !== null;
709
728
  }
710
729
  }
711
- class zs {
730
+ class Vs {
712
731
  constructor(e, s) {
713
- this.chainRegistry = e, this.transport = s;
732
+ this.chainRegistry = e, this.transport = s, this._nextId = 1;
714
733
  }
715
734
  /**
716
735
  * JSON-RPC 호출
@@ -725,7 +744,7 @@ class zs {
725
744
  jsonrpc: "2.0",
726
745
  method: e,
727
746
  params: s,
728
- id: Date.now()
747
+ id: this._nextId++
729
748
  }, a = (await this.transport.request({
730
749
  url: n.rpcUrl,
731
750
  method: "POST",
@@ -740,7 +759,7 @@ class zs {
740
759
  return a == null ? void 0 : a.result;
741
760
  }
742
761
  }
743
- class Ks {
762
+ class zs {
744
763
  constructor() {
745
764
  this.listeners = /* @__PURE__ */ new Map();
746
765
  }
@@ -763,7 +782,7 @@ class Ks {
763
782
  this.listeners.clear();
764
783
  }
765
784
  }
766
- const We = {
785
+ const Fe = {
767
786
  // TODO(v2.0.0-BEFORE-RELEASE): 아래 블록으로 교체
768
787
  // production: {
769
788
  // oauthServiceUrl: 'https://cross-wallet-oauth.crosstoken.io',
@@ -788,7 +807,7 @@ const We = {
788
807
  };
789
808
  function js(r) {
790
809
  const e = r.environment;
791
- return e && e in We ? We[e] : null;
810
+ return e && e in Fe ? Fe[e] : null;
792
811
  }
793
812
  function Ys() {
794
813
  try {
@@ -798,12 +817,12 @@ function Ys() {
798
817
  }
799
818
  } catch {
800
819
  }
801
- return We.production;
820
+ return Fe.production;
802
821
  }
803
- const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA00", Tt = 130, At = 6, kt = 18, er = 0, tr = 30 * 1e3, re = class re extends Ks {
822
+ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA00", Rt = 130, kt = 6, Pt = 18, er = 5 * 60 * 1e3, tr = 30 * 1e3, re = class re extends zs {
804
823
  constructor(e, s, t, n, o, i, a, c, l, d, h) {
805
824
  var m;
806
- super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this._initPromise = null, this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._verifyPinMutex = null, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && vt(e.logger), this.confirmation = l, this.pinStore = h ?? new Xt(), this.chainRegistry = d, this.jsonRpc = new zs(d, o), this.signInUseCase = new Hs(
825
+ super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this._initPromise = null, this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._verifyPinMutex = null, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && bt(e.logger), this.confirmation = l, this.pinStore = h ?? new Qt(), this.chainRegistry = d, this.jsonRpc = new Vs(d, o), this.signInUseCase = new Ws(
807
826
  this.internalConfig,
808
827
  t,
809
828
  n,
@@ -811,7 +830,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
811
830
  o,
812
831
  a,
813
832
  c
814
- ), this.signOutUseCase = new qs(this.internalConfig, t, c), this.migrateWalletUseCase = new Vs(t, a), (m = a.setOnUnauthorized) == null || m.call(a, () => this.forceLogout());
833
+ ), this.signOutUseCase = new qs(this.internalConfig, t, c), this.migrateWalletUseCase = new Ks(t, a), (m = a.setOnUnauthorized) == null || m.call(a, () => this.forceLogout());
815
834
  }
816
835
  get config() {
817
836
  return this._config;
@@ -836,24 +855,25 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
836
855
  }), this._initPromise);
837
856
  }
838
857
  async _doInitialize(e) {
839
- console.log("[CROSSx SDK] v1.2.4 초기화 중..."), this.confirmation.setMessages(St(this._config.locale));
858
+ var s, t;
859
+ u.log("[CROSSx SDK] v1.2.5 초기화 중..."), this.confirmation.setMessages(vt(this._config.locale));
840
860
  try {
841
- const s = Ys();
842
- this.internalConfig.oauthServiceUrl = s.oauthServiceUrl, this.internalConfig.authApiUrl = s.authApiUrl, this.internalConfig.walletGatewayUrl = s.walletGatewayUrl, this.adapterConfig.gatewayUrl = s.walletGatewayUrl;
843
- const t = await this.signInUseCase.restoreSession();
844
- if (t != null && t.success) {
845
- this.applyAuthResult(t);
861
+ const n = Ys();
862
+ this.internalConfig.oauthServiceUrl = n.oauthServiceUrl, this.internalConfig.authApiUrl = n.authApiUrl, this.internalConfig.walletGatewayUrl = n.walletGatewayUrl, this.adapterConfig.gatewayUrl = n.walletGatewayUrl, (t = (s = this.crypto).setJWKSEndpoint) == null || t.call(s, `${n.authApiUrl}/.well-known/jwks.json`);
863
+ const o = await this.signInUseCase.restoreSession();
864
+ if (o != null && o.success) {
865
+ this.applyAuthResult(o);
846
866
  try {
847
867
  await this.loadWalletAfterAuth(e == null ? void 0 : e.preferredWalletIndex);
848
- } catch (n) {
849
- if (!(n instanceof g && n.code === p.PIN_CANCELLED))
850
- throw n;
868
+ } catch (i) {
869
+ if (!(i instanceof g && i.code === p.PIN_CANCELLED))
870
+ throw i;
851
871
  u.log("[CROSSx] initialize: 비밀번호 입력 취소 — 지갑 미로드 상태로 계속");
852
872
  }
853
873
  }
854
- return this.initialized = !0, this.emit("initialized", { restored: !!(t != null && t.success) }), t ?? null;
855
- } catch (s) {
856
- throw new g(p.AUTH_NOT_INITIALIZED, "SDK 초기화에 실패했습니다", s);
874
+ return this.initialized = !0, this.emit("initialized", { restored: !!(o != null && o.success) }), o ?? null;
875
+ } catch (n) {
876
+ throw new g(p.AUTH_NOT_INITIALIZED, "SDK 초기화에 실패했습니다", n);
857
877
  }
858
878
  }
859
879
  async signIn(e) {
@@ -948,6 +968,26 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
948
968
  isAuthenticated() {
949
969
  return this.authenticated;
950
970
  }
971
+ /**
972
+ * SDK 초기화 완료까지 대기합니다.
973
+ *
974
+ * wagmi 등 외부 프레임워크가 connector.setup()을 await하지 않아
975
+ * 초기화 도중 isAuthenticated()가 false를 반환하는 race condition을 방지합니다.
976
+ *
977
+ * - 이미 초기화 완료: 즉시 `true`
978
+ * - 초기화 진행 중(`_initPromise` 존재): 완료 대기 후 결과 반환
979
+ * - 초기화 미시작: 즉시 `false`
980
+ */
981
+ async whenReady() {
982
+ if (this.initialized) return !0;
983
+ if (this._initPromise)
984
+ try {
985
+ return await this._initPromise, this.initialized;
986
+ } catch {
987
+ return !1;
988
+ }
989
+ return !1;
990
+ }
951
991
  /** 현재 지갑 주소 (동기) — useSyncExternalStore 등에서 사용 */
952
992
  get currentAddress() {
953
993
  return this.address;
@@ -1188,7 +1228,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
1188
1228
  * sdk.applyLocale('ko');
1189
1229
  */
1190
1230
  applyLocale(e = this._config.locale ?? "en") {
1191
- this._config = Object.freeze({ ...this._config, locale: e }), this.confirmation.setMessages(St(e));
1231
+ this._config = Object.freeze({ ...this._config, locale: e }), this.confirmation.setMessages(vt(e));
1192
1232
  }
1193
1233
  /**
1194
1234
  * 지갑 생성/로드 (로그인 후 address가 없는 경우)
@@ -1402,7 +1442,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
1402
1442
  throw new g(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
1403
1443
  const n = await this.withResolvedGasAndFee(s, e);
1404
1444
  n.from || (n.from = (await this.resolveAddress(t == null ? void 0 : t.index)).address);
1405
- const o = Ze(e);
1445
+ const o = Ye(e);
1406
1446
  if (!await this.confirmation.requestConfirmation({
1407
1447
  type: "sign",
1408
1448
  chainId: e,
@@ -1457,7 +1497,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
1457
1497
  throw new g(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
1458
1498
  const n = await this.withResolvedGasAndFee(s, e);
1459
1499
  n.from || (n.from = (await this.resolveAddress(t == null ? void 0 : t.index)).address);
1460
- const o = Ze(e);
1500
+ const o = Ye(e);
1461
1501
  if (!await this.confirmation.requestConfirmation({
1462
1502
  type: "send",
1463
1503
  chainId: e,
@@ -1524,7 +1564,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
1524
1564
  * @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
1525
1565
  */
1526
1566
  async waitForTxAndGetReceipt(e, s, t = {}) {
1527
- const n = t.intervalMs ?? Zs, o = Xs, i = t.timeoutMs ?? It, a = Date.now() + i;
1567
+ const n = t.intervalMs ?? Zs, o = Xs, i = t.timeoutMs ?? Tt, a = Date.now() + i;
1528
1568
  let c = n;
1529
1569
  for (; Date.now() < a; ) {
1530
1570
  const l = await this.getTransactionReceipt(e, s);
@@ -1553,19 +1593,19 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
1553
1593
  */
1554
1594
  async sendTransactionWithWaitForReceipt(e, s, t = {}) {
1555
1595
  var E, y;
1556
- const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((E = this._config.receiptPolling) == null ? void 0 : E.intervalMs) ?? Js, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? It, d = Ze(e), h = s.from ?? "";
1596
+ const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((E = this._config.receiptPolling) == null ? void 0 : E.intervalMs) ?? Js, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? Tt, d = Ye(e), h = s.from ?? "";
1557
1597
  let m, x;
1558
1598
  const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((S) => {
1559
1599
  m = S;
1560
- const O = BigInt(S.gasUsed) * BigInt(S.effectiveGasPrice), B = s.value ? BigInt(s.value) : 0n, b = re.formatTxAmount(s.value, d.symbol, d.decimals), P = re.formatTxAmount("0x" + O.toString(16), d.symbol, d.decimals), N = re.formatTxAmount("0x" + (B + O).toString(16), d.symbol, d.decimals);
1600
+ const O = BigInt(S.gasUsed) * BigInt(S.effectiveGasPrice), B = s.value ? BigInt(s.value) : 0n, b = re.formatTxAmount(s.value, d.symbol, d.decimals), k = re.formatTxAmount("0x" + O.toString(16), d.symbol, d.decimals), P = re.formatTxAmount("0x" + (B + O).toString(16), d.symbol, d.decimals);
1561
1601
  return {
1562
1602
  chainId: e,
1563
1603
  txHash: a,
1564
1604
  from: S.from,
1565
1605
  to: S.to ?? s.to,
1566
1606
  amount: b,
1567
- fees: P,
1568
- total: N,
1607
+ fees: k,
1608
+ total: P,
1569
1609
  nativeSymbol: d.symbol,
1570
1610
  status: S.status === "0x1" ? "success" : "reverted"
1571
1611
  };
@@ -1764,7 +1804,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
1764
1804
  try {
1765
1805
  const s = BigInt(e);
1766
1806
  if (s === 0n) return "0";
1767
- const t = 10n ** BigInt(kt), n = s / t, i = (s % t).toString().padStart(kt, "0").replace(/0+$/, "").slice(0, At);
1807
+ const t = 10n ** BigInt(Pt), n = s / t, i = (s % t).toString().padStart(Pt, "0").replace(/0+$/, "").slice(0, kt);
1768
1808
  return i ? `${n}.${i}` : `${n}`;
1769
1809
  } catch {
1770
1810
  return "?";
@@ -1789,7 +1829,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
1789
1829
  * const client = createWalletClient({ transport: custom(provider) });
1790
1830
  */
1791
1831
  getProvider(e) {
1792
- return this.ensureAuthenticated(), new $s(this, e);
1832
+ return this.ensureAuthenticated(), new Hs(this, e);
1793
1833
  }
1794
1834
  /**
1795
1835
  * 범용 JSON-RPC 요청 — 노드에 직접 연결.
@@ -1823,7 +1863,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
1823
1863
  try {
1824
1864
  const n = BigInt(e);
1825
1865
  if (n === 0n) return;
1826
- const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0, At).replace(/0+$/, "");
1866
+ const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0, kt).replace(/0+$/, "");
1827
1867
  return `${c ? `${i}.${c}` : `${i}`} ${s}`;
1828
1868
  } catch {
1829
1869
  return;
@@ -1923,12 +1963,12 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
1923
1963
  u.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
1924
1964
  const l = await this.getBaseFeePerGas(s);
1925
1965
  if (l) {
1926
- const d = Et;
1966
+ const d = At;
1927
1967
  c.maxFeePerGas = "0x" + (BigInt(l) + BigInt(d)).toString(16), c.maxPriorityFeePerGas = d, u.log("[CROSSx] Dynamic 체인 감지 — baseFee:", l, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
1928
1968
  } else
1929
1969
  c.gasPrice = Qs, u.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
1930
1970
  }
1931
- return !i && a && (c.maxPriorityFeePerGas = Et, u.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
1971
+ return !i && a && (c.maxPriorityFeePerGas = At, u.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
1932
1972
  }
1933
1973
  /**
1934
1974
  * EIP-712 signTypedData 호출 시 chainId와 typedData.domain.chainId 정합성 검증.
@@ -1975,10 +2015,10 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
1975
2015
  const s = e.startsWith("0x") ? e.slice(2) : e;
1976
2016
  if (!/^[0-9a-fA-F]+$/.test(s))
1977
2017
  throw new g(p.SIGNATURE_FAILED, "유효하지 않은 서명: 올바른 hex 문자열이 아닙니다");
1978
- if (s.length !== Tt)
2018
+ if (s.length !== Rt)
1979
2019
  throw new g(
1980
2020
  p.SIGNATURE_FAILED,
1981
- `서명 길이가 유효하지 않습니다: ${Tt} hex 문자(65 바이트) 예상, 현재 ${s.length}`
2021
+ `서명 길이가 유효하지 않습니다: ${Rt} hex 문자(65 바이트) 예상, 현재 ${s.length}`
1982
2022
  );
1983
2023
  }
1984
2024
  /** RLP-encoded signed transaction 형식 검증 */
@@ -2250,11 +2290,11 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
2250
2290
  * dispose 후 SDK 인스턴스는 더 이상 사용할 수 없습니다.
2251
2291
  */
2252
2292
  dispose() {
2253
- this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), vt(null);
2293
+ this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), bt(null);
2254
2294
  }
2255
2295
  };
2256
2296
  re.OFFCHAIN_CHAIN_ID = "0";
2257
- let it = re;
2297
+ let ot = re;
2258
2298
  class sr {
2259
2299
  constructor() {
2260
2300
  this.prefix = "crossx_";
@@ -2292,21 +2332,21 @@ class sr {
2292
2332
  }
2293
2333
  }
2294
2334
  }
2295
- const rr = "crossx-sdk", nr = 1, Ie = "data", Be = "keys", Pt = "aes-primary", or = 12;
2296
- class Nt {
2297
- constructor() {
2298
- this.db = null, this.cryptoKey = null, this.initPromise = null;
2335
+ const Je = "crossx-sdk", rr = 1, de = "data", ve = "keys", Me = "aes-primary", nr = 12;
2336
+ class Ct {
2337
+ constructor(e) {
2338
+ this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
2299
2339
  }
2300
2340
  async ensureReady() {
2301
2341
  this.db && this.cryptoKey || (this.initPromise || (this.initPromise = this.init()), await this.initPromise);
2302
2342
  }
2303
- openDB() {
2304
- return new Promise((e, s) => {
2305
- const t = indexedDB.open(rr, nr);
2306
- t.onupgradeneeded = () => {
2307
- const n = t.result;
2308
- n.objectStoreNames.contains(Ie) || n.createObjectStore(Ie), n.objectStoreNames.contains(Be) || n.createObjectStore(Be);
2309
- }, t.onsuccess = () => e(t.result), t.onerror = () => s(t.error);
2343
+ openDB(e = this.dbName) {
2344
+ return new Promise((s, t) => {
2345
+ const n = indexedDB.open(e, rr);
2346
+ n.onupgradeneeded = () => {
2347
+ const o = n.result;
2348
+ o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(ve) || o.createObjectStore(ve);
2349
+ }, n.onsuccess = () => s(n.result), n.onerror = () => t(n.error);
2310
2350
  });
2311
2351
  }
2312
2352
  idbGet(e, s) {
@@ -2335,19 +2375,52 @@ class Nt {
2335
2375
  }
2336
2376
  async init() {
2337
2377
  this.db = await this.openDB();
2338
- const e = await this.idbGet(Be, Pt);
2378
+ const e = await this.idbGet(ve, Me);
2339
2379
  if (e) {
2340
2380
  this.cryptoKey = e;
2341
2381
  return;
2342
2382
  }
2383
+ const s = await this.migrateFromLegacyDB();
2384
+ if (s) {
2385
+ this.cryptoKey = s;
2386
+ return;
2387
+ }
2343
2388
  this.cryptoKey = await crypto.subtle.generateKey(
2344
2389
  { name: "AES-GCM", length: 256 },
2345
2390
  !1,
2346
2391
  ["encrypt", "decrypt"]
2347
- ), await this.idbPut(Be, Pt, this.cryptoKey);
2392
+ ), await this.idbPut(ve, Me, this.cryptoKey);
2393
+ }
2394
+ /**
2395
+ * 레거시 DB('crossx-sdk')에서 projectId 스코프 DB로 암호키·데이터 마이그레이션.
2396
+ * 마이그레이션 성공 시 레거시 DB 삭제.
2397
+ */
2398
+ async migrateFromLegacyDB() {
2399
+ if (this.dbName === Je) return null;
2400
+ try {
2401
+ const e = await this.openDB(Je), s = e.transaction([ve, de], "readonly"), t = s.objectStore(ve).get(Me), n = await new Promise((l, d) => {
2402
+ t.onsuccess = () => l(t.result), t.onerror = () => d(t.error);
2403
+ });
2404
+ if (!n)
2405
+ return e.close(), null;
2406
+ const o = s.objectStore(de).getAll(), i = s.objectStore(de).getAllKeys(), [a, c] = await Promise.all([
2407
+ new Promise((l, d) => {
2408
+ o.onsuccess = () => l(o.result), o.onerror = () => d(o.error);
2409
+ }),
2410
+ new Promise((l, d) => {
2411
+ i.onsuccess = () => l(i.result), i.onerror = () => d(i.error);
2412
+ })
2413
+ ]);
2414
+ e.close(), await this.idbPut(ve, Me, n);
2415
+ for (let l = 0; l < c.length; l++)
2416
+ await this.idbPut(de, String(c[l]), a[l]);
2417
+ return indexedDB.deleteDatabase(Je), u.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), n;
2418
+ } catch (e) {
2419
+ return u.warn("[CROSSx] IndexedDB 레거시 DB 마이그레이션 실패:", e), null;
2420
+ }
2348
2421
  }
2349
2422
  async encrypt(e) {
2350
- const s = new Uint8Array(or);
2423
+ const s = new Uint8Array(nr);
2351
2424
  crypto.getRandomValues(s);
2352
2425
  const t = new TextEncoder().encode(e), n = await crypto.subtle.encrypt(
2353
2426
  { name: "AES-GCM", iv: s },
@@ -2368,7 +2441,7 @@ class Nt {
2368
2441
  try {
2369
2442
  await this.ensureReady();
2370
2443
  const t = JSON.stringify(s), n = await this.encrypt(t);
2371
- await this.idbPut(Ie, e, n);
2444
+ await this.idbPut(de, e, n);
2372
2445
  } catch (t) {
2373
2446
  throw u.error("[CROSSx] IndexedDB set error:", t), t;
2374
2447
  }
@@ -2376,7 +2449,7 @@ class Nt {
2376
2449
  async get(e) {
2377
2450
  try {
2378
2451
  await this.ensureReady();
2379
- const s = await this.idbGet(Ie, e);
2452
+ const s = await this.idbGet(de, e);
2380
2453
  if (!s) return null;
2381
2454
  const t = await this.decrypt(s);
2382
2455
  return JSON.parse(t);
@@ -2386,14 +2459,14 @@ class Nt {
2386
2459
  }
2387
2460
  async remove(e) {
2388
2461
  try {
2389
- await this.ensureReady(), await this.idbDelete(Ie, e);
2462
+ await this.ensureReady(), await this.idbDelete(de, e);
2390
2463
  } catch (s) {
2391
2464
  throw u.error("[CROSSx] IndexedDB remove error:", s), s;
2392
2465
  }
2393
2466
  }
2394
2467
  async clear() {
2395
2468
  try {
2396
- await this.ensureReady(), await this.idbClear(Ie);
2469
+ await this.ensureReady(), await this.idbClear(de);
2397
2470
  } catch (e) {
2398
2471
  throw u.error("[CROSSx] IndexedDB clear error:", e), e;
2399
2472
  }
@@ -2406,91 +2479,91 @@ class Nt {
2406
2479
  }
2407
2480
  }
2408
2481
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2409
- function ut(r) {
2482
+ function dt(r) {
2410
2483
  return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
2411
2484
  }
2412
- function _e(r, e = "") {
2485
+ function xe(r, e = "") {
2413
2486
  if (!Number.isSafeInteger(r) || r < 0) {
2414
2487
  const s = e && `"${e}" `;
2415
2488
  throw new Error(`${s}expected integer >= 0, got ${r}`);
2416
2489
  }
2417
2490
  }
2418
- function z(r, e, s = "") {
2419
- const t = ut(r), n = r == null ? void 0 : r.length, o = e !== void 0;
2491
+ function V(r, e, s = "") {
2492
+ const t = dt(r), n = r == null ? void 0 : r.length, o = e !== void 0;
2420
2493
  if (!t || o && n !== e) {
2421
2494
  const i = s && `"${s}" `, a = o ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
2422
2495
  throw new Error(i + "expected Uint8Array" + a + ", got " + c);
2423
2496
  }
2424
2497
  return r;
2425
2498
  }
2426
- function Qt(r) {
2499
+ function es(r) {
2427
2500
  if (typeof r != "function" || typeof r.create != "function")
2428
2501
  throw new Error("Hash must wrapped by utils.createHasher");
2429
- _e(r.outputLen), _e(r.blockLen);
2502
+ xe(r.outputLen), xe(r.blockLen);
2430
2503
  }
2431
- function Ae(r, e = !0) {
2504
+ function Re(r, e = !0) {
2432
2505
  if (r.destroyed)
2433
2506
  throw new Error("Hash instance has been destroyed");
2434
2507
  if (e && r.finished)
2435
2508
  throw new Error("Hash#digest() has already been called");
2436
2509
  }
2437
- function es(r, e) {
2438
- z(r, void 0, "digestInto() output");
2510
+ function ts(r, e) {
2511
+ V(r, void 0, "digestInto() output");
2439
2512
  const s = e.outputLen;
2440
2513
  if (r.length < s)
2441
2514
  throw new Error('"digestInto() output" expected to be of length >=' + s);
2442
2515
  }
2443
- function ir(r) {
2516
+ function or(r) {
2444
2517
  return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
2445
2518
  }
2446
2519
  function ke(...r) {
2447
2520
  for (let e = 0; e < r.length; e++)
2448
2521
  r[e].fill(0);
2449
2522
  }
2450
- function Xe(r) {
2523
+ function Ze(r) {
2451
2524
  return new DataView(r.buffer, r.byteOffset, r.byteLength);
2452
2525
  }
2453
- function de(r, e) {
2526
+ function ue(r, e) {
2454
2527
  return r << 32 - e | r >>> e;
2455
2528
  }
2456
- const ar = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2457
- function cr(r) {
2529
+ const ir = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2530
+ function ar(r) {
2458
2531
  return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
2459
2532
  }
2460
- function lr(r) {
2533
+ function cr(r) {
2461
2534
  for (let e = 0; e < r.length; e++)
2462
- r[e] = cr(r[e]);
2535
+ r[e] = ar(r[e]);
2463
2536
  return r;
2464
2537
  }
2465
- const Rt = ar ? (r) => r : lr, ts = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", dr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
2466
- function Me(r) {
2467
- if (z(r), ts)
2538
+ const Nt = ir ? (r) => r : cr, ss = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", lr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
2539
+ function De(r) {
2540
+ if (V(r), ss)
2468
2541
  return r.toHex();
2469
2542
  let e = "";
2470
2543
  for (let s = 0; s < r.length; s++)
2471
- e += dr[r[s]];
2544
+ e += lr[r[s]];
2472
2545
  return e;
2473
2546
  }
2474
- const he = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
2475
- function Ct(r) {
2476
- if (r >= he._0 && r <= he._9)
2477
- return r - he._0;
2478
- if (r >= he.A && r <= he.F)
2479
- return r - (he.A - 10);
2480
- if (r >= he.a && r <= he.f)
2481
- return r - (he.a - 10);
2547
+ const pe = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
2548
+ function Ot(r) {
2549
+ if (r >= pe._0 && r <= pe._9)
2550
+ return r - pe._0;
2551
+ if (r >= pe.A && r <= pe.F)
2552
+ return r - (pe.A - 10);
2553
+ if (r >= pe.a && r <= pe.f)
2554
+ return r - (pe.a - 10);
2482
2555
  }
2483
- function qe(r) {
2556
+ function Ge(r) {
2484
2557
  if (typeof r != "string")
2485
2558
  throw new Error("hex string expected, got " + typeof r);
2486
- if (ts)
2559
+ if (ss)
2487
2560
  return Uint8Array.fromHex(r);
2488
2561
  const e = r.length, s = e / 2;
2489
2562
  if (e % 2)
2490
2563
  throw new Error("hex string expected, got unpadded hex of length " + e);
2491
2564
  const t = new Uint8Array(s);
2492
2565
  for (let n = 0, o = 0; n < s; n++, o += 2) {
2493
- const i = Ct(r.charCodeAt(o)), a = Ct(r.charCodeAt(o + 1));
2566
+ const i = Ot(r.charCodeAt(o)), a = Ot(r.charCodeAt(o + 1));
2494
2567
  if (i === void 0 || a === void 0) {
2495
2568
  const c = r[o] + r[o + 1];
2496
2569
  throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + o);
@@ -2499,11 +2572,11 @@ function qe(r) {
2499
2572
  }
2500
2573
  return t;
2501
2574
  }
2502
- function we(...r) {
2575
+ function be(...r) {
2503
2576
  let e = 0;
2504
2577
  for (let t = 0; t < r.length; t++) {
2505
2578
  const n = r[t];
2506
- z(n), e += n.length;
2579
+ V(n), e += n.length;
2507
2580
  }
2508
2581
  const s = new Uint8Array(e);
2509
2582
  for (let t = 0, n = 0; t < r.length; t++) {
@@ -2512,47 +2585,47 @@ function we(...r) {
2512
2585
  }
2513
2586
  return s;
2514
2587
  }
2515
- function ss(r, e = {}) {
2588
+ function rs(r, e = {}) {
2516
2589
  const s = (n, o) => r(o).update(n).digest(), t = r(void 0);
2517
2590
  return s.outputLen = t.outputLen, s.blockLen = t.blockLen, s.create = (n) => r(n), Object.assign(s, e), Object.freeze(s);
2518
2591
  }
2519
- function rs(r = 32) {
2592
+ function ns(r = 32) {
2520
2593
  const e = typeof globalThis == "object" ? globalThis.crypto : null;
2521
2594
  if (typeof (e == null ? void 0 : e.getRandomValues) != "function")
2522
2595
  throw new Error("crypto.getRandomValues must be defined");
2523
2596
  return e.getRandomValues(new Uint8Array(r));
2524
2597
  }
2525
- const ur = (r) => ({
2598
+ const dr = (r) => ({
2526
2599
  oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, r])
2527
2600
  });
2528
- function hr(r, e, s) {
2601
+ function ur(r, e, s) {
2529
2602
  return r & e ^ ~r & s;
2530
2603
  }
2531
- function pr(r, e, s) {
2604
+ function hr(r, e, s) {
2532
2605
  return r & e ^ r & s ^ e & s;
2533
2606
  }
2534
- class fr {
2607
+ class pr {
2535
2608
  constructor(e, s, t, n) {
2536
- I(this, "blockLen");
2537
- I(this, "outputLen");
2538
- I(this, "padOffset");
2539
- I(this, "isLE");
2609
+ T(this, "blockLen");
2610
+ T(this, "outputLen");
2611
+ T(this, "padOffset");
2612
+ T(this, "isLE");
2540
2613
  // For partial updates less than block size
2541
- I(this, "buffer");
2542
- I(this, "view");
2543
- I(this, "finished", !1);
2544
- I(this, "length", 0);
2545
- I(this, "pos", 0);
2546
- I(this, "destroyed", !1);
2547
- this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Xe(this.buffer);
2614
+ T(this, "buffer");
2615
+ T(this, "view");
2616
+ T(this, "finished", !1);
2617
+ T(this, "length", 0);
2618
+ T(this, "pos", 0);
2619
+ T(this, "destroyed", !1);
2620
+ this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Ze(this.buffer);
2548
2621
  }
2549
2622
  update(e) {
2550
- Ae(this), z(e);
2623
+ Re(this), V(e);
2551
2624
  const { view: s, buffer: t, blockLen: n } = this, o = e.length;
2552
2625
  for (let i = 0; i < o; ) {
2553
2626
  const a = Math.min(n - this.pos, o - i);
2554
2627
  if (a === n) {
2555
- const c = Xe(e);
2628
+ const c = Ze(e);
2556
2629
  for (; n <= o - i; i += n)
2557
2630
  this.process(c, i);
2558
2631
  continue;
@@ -2562,14 +2635,14 @@ class fr {
2562
2635
  return this.length += e.length, this.roundClean(), this;
2563
2636
  }
2564
2637
  digestInto(e) {
2565
- Ae(this), es(e, this), this.finished = !0;
2638
+ Re(this), ts(e, this), this.finished = !0;
2566
2639
  const { buffer: s, view: t, blockLen: n, isLE: o } = this;
2567
2640
  let { pos: i } = this;
2568
2641
  s[i++] = 128, ke(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
2569
2642
  for (let h = i; h < n; h++)
2570
2643
  s[h] = 0;
2571
2644
  t.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(t, 0);
2572
- const a = Xe(e), c = this.outputLen;
2645
+ const a = Ze(e), c = this.outputLen;
2573
2646
  if (c % 4)
2574
2647
  throw new Error("_sha2: outputLen must be aligned to 32bit");
2575
2648
  const l = c / 4, d = this.get();
@@ -2593,7 +2666,7 @@ class fr {
2593
2666
  return this._cloneInto();
2594
2667
  }
2595
2668
  }
2596
- const xe = /* @__PURE__ */ Uint32Array.from([
2669
+ const ge = /* @__PURE__ */ Uint32Array.from([
2597
2670
  1779033703,
2598
2671
  3144134277,
2599
2672
  1013904242,
@@ -2602,20 +2675,20 @@ const xe = /* @__PURE__ */ Uint32Array.from([
2602
2675
  2600822924,
2603
2676
  528734635,
2604
2677
  1541459225
2605
- ]), Ue = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ot = /* @__PURE__ */ BigInt(32);
2606
- function _r(r, e = !1) {
2607
- return e ? { h: Number(r & Ue), l: Number(r >> Ot & Ue) } : { h: Number(r >> Ot & Ue) | 0, l: Number(r & Ue) | 0 };
2678
+ ]), $e = /* @__PURE__ */ BigInt(2 ** 32 - 1), Lt = /* @__PURE__ */ BigInt(32);
2679
+ function fr(r, e = !1) {
2680
+ return e ? { h: Number(r & $e), l: Number(r >> Lt & $e) } : { h: Number(r >> Lt & $e) | 0, l: Number(r & $e) | 0 };
2608
2681
  }
2609
- function xr(r, e = !1) {
2682
+ function _r(r, e = !1) {
2610
2683
  const s = r.length;
2611
2684
  let t = new Uint32Array(s), n = new Uint32Array(s);
2612
2685
  for (let o = 0; o < s; o++) {
2613
- const { h: i, l: a } = _r(r[o], e);
2686
+ const { h: i, l: a } = fr(r[o], e);
2614
2687
  [t[o], n[o]] = [i, a];
2615
2688
  }
2616
2689
  return [t, n];
2617
2690
  }
2618
- const gr = (r, e, s) => r << s | e >>> 32 - s, mr = (r, e, s) => e << s | r >>> 32 - s, wr = (r, e, s) => e << s - 32 | r >>> 64 - s, yr = (r, e, s) => r << s - 32 | e >>> 64 - s, br = /* @__PURE__ */ Uint32Array.from([
2691
+ const xr = (r, e, s) => r << s | e >>> 32 - s, gr = (r, e, s) => e << s | r >>> 32 - s, mr = (r, e, s) => e << s - 32 | r >>> 64 - s, wr = (r, e, s) => r << s - 32 | e >>> 64 - s, yr = /* @__PURE__ */ Uint32Array.from([
2619
2692
  1116352408,
2620
2693
  1899447441,
2621
2694
  3049323471,
@@ -2680,8 +2753,8 @@ const gr = (r, e, s) => r << s | e >>> 32 - s, mr = (r, e, s) => e << s | r >>>
2680
2753
  2756734187,
2681
2754
  3204031479,
2682
2755
  3329325298
2683
- ]), ge = /* @__PURE__ */ new Uint32Array(64);
2684
- class vr extends fr {
2756
+ ]), me = /* @__PURE__ */ new Uint32Array(64);
2757
+ class br extends pr {
2685
2758
  constructor(e) {
2686
2759
  super(64, e, 8, !1);
2687
2760
  }
@@ -2695,112 +2768,112 @@ class vr extends fr {
2695
2768
  }
2696
2769
  process(e, s) {
2697
2770
  for (let h = 0; h < 16; h++, s += 4)
2698
- ge[h] = e.getUint32(s, !1);
2771
+ me[h] = e.getUint32(s, !1);
2699
2772
  for (let h = 16; h < 64; h++) {
2700
- const m = ge[h - 15], x = ge[h - 2], w = de(m, 7) ^ de(m, 18) ^ m >>> 3, E = de(x, 17) ^ de(x, 19) ^ x >>> 10;
2701
- ge[h] = E + ge[h - 7] + w + ge[h - 16] | 0;
2773
+ const m = me[h - 15], x = me[h - 2], w = ue(m, 7) ^ ue(m, 18) ^ m >>> 3, E = ue(x, 17) ^ ue(x, 19) ^ x >>> 10;
2774
+ me[h] = E + me[h - 7] + w + me[h - 16] | 0;
2702
2775
  }
2703
2776
  let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: d } = this;
2704
2777
  for (let h = 0; h < 64; h++) {
2705
- const m = de(a, 6) ^ de(a, 11) ^ de(a, 25), x = d + m + hr(a, c, l) + br[h] + ge[h] | 0, E = (de(t, 2) ^ de(t, 13) ^ de(t, 22)) + pr(t, n, o) | 0;
2778
+ const m = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), x = d + m + ur(a, c, l) + yr[h] + me[h] | 0, E = (ue(t, 2) ^ ue(t, 13) ^ ue(t, 22)) + hr(t, n, o) | 0;
2706
2779
  d = l, l = c, c = a, a = i + x | 0, i = o, o = n, n = t, t = x + E | 0;
2707
2780
  }
2708
2781
  t = t + this.A | 0, n = n + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, d = d + this.H | 0, this.set(t, n, o, i, a, c, l, d);
2709
2782
  }
2710
2783
  roundClean() {
2711
- ke(ge);
2784
+ ke(me);
2712
2785
  }
2713
2786
  destroy() {
2714
2787
  this.set(0, 0, 0, 0, 0, 0, 0, 0), ke(this.buffer);
2715
2788
  }
2716
2789
  }
2717
- class Sr extends vr {
2790
+ class vr extends br {
2718
2791
  constructor() {
2719
2792
  super(32);
2720
2793
  // We cannot use array here since array allows indexing by variable
2721
2794
  // which means optimizer/compiler cannot use registers.
2722
- I(this, "A", xe[0] | 0);
2723
- I(this, "B", xe[1] | 0);
2724
- I(this, "C", xe[2] | 0);
2725
- I(this, "D", xe[3] | 0);
2726
- I(this, "E", xe[4] | 0);
2727
- I(this, "F", xe[5] | 0);
2728
- I(this, "G", xe[6] | 0);
2729
- I(this, "H", xe[7] | 0);
2730
- }
2731
- }
2732
- const Ir = /* @__PURE__ */ ss(
2733
- () => new Sr(),
2734
- /* @__PURE__ */ ur(1)
2795
+ T(this, "A", ge[0] | 0);
2796
+ T(this, "B", ge[1] | 0);
2797
+ T(this, "C", ge[2] | 0);
2798
+ T(this, "D", ge[3] | 0);
2799
+ T(this, "E", ge[4] | 0);
2800
+ T(this, "F", ge[5] | 0);
2801
+ T(this, "G", ge[6] | 0);
2802
+ T(this, "H", ge[7] | 0);
2803
+ }
2804
+ }
2805
+ const Sr = /* @__PURE__ */ rs(
2806
+ () => new vr(),
2807
+ /* @__PURE__ */ dr(1)
2735
2808
  );
2736
2809
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2737
- const ht = /* @__PURE__ */ BigInt(0), at = /* @__PURE__ */ BigInt(1);
2738
- function Ve(r, e = "") {
2810
+ const ut = /* @__PURE__ */ BigInt(0), it = /* @__PURE__ */ BigInt(1);
2811
+ function We(r, e = "") {
2739
2812
  if (typeof r != "boolean") {
2740
2813
  const s = e && `"${e}" `;
2741
2814
  throw new Error(s + "expected boolean, got type=" + typeof r);
2742
2815
  }
2743
2816
  return r;
2744
2817
  }
2745
- function ns(r) {
2818
+ function os(r) {
2746
2819
  if (typeof r == "bigint") {
2747
- if (!Ge(r))
2820
+ if (!He(r))
2748
2821
  throw new Error("positive bigint expected, got " + r);
2749
2822
  } else
2750
- _e(r);
2823
+ xe(r);
2751
2824
  return r;
2752
2825
  }
2753
- function He(r) {
2754
- const e = ns(r).toString(16);
2826
+ function Be(r) {
2827
+ const e = os(r).toString(16);
2755
2828
  return e.length & 1 ? "0" + e : e;
2756
2829
  }
2757
- function os(r) {
2830
+ function is(r) {
2758
2831
  if (typeof r != "string")
2759
2832
  throw new Error("hex string expected, got " + typeof r);
2760
- return r === "" ? ht : BigInt("0x" + r);
2833
+ return r === "" ? ut : BigInt("0x" + r);
2761
2834
  }
2762
- function je(r) {
2763
- return os(Me(r));
2835
+ function Ve(r) {
2836
+ return is(De(r));
2764
2837
  }
2765
- function is(r) {
2766
- return os(Me(Er(z(r)).reverse()));
2838
+ function as(r) {
2839
+ return is(De(Er(V(r)).reverse()));
2767
2840
  }
2768
- function pt(r, e) {
2769
- _e(e), r = ns(r);
2770
- const s = qe(r.toString(16).padStart(e * 2, "0"));
2841
+ function ht(r, e) {
2842
+ xe(e), r = os(r);
2843
+ const s = Ge(r.toString(16).padStart(e * 2, "0"));
2771
2844
  if (s.length !== e)
2772
2845
  throw new Error("number too large");
2773
2846
  return s;
2774
2847
  }
2775
- function as(r, e) {
2776
- return pt(r, e).reverse();
2848
+ function cs(r, e) {
2849
+ return ht(r, e).reverse();
2777
2850
  }
2778
2851
  function Er(r) {
2779
2852
  return Uint8Array.from(r);
2780
2853
  }
2781
- const Ge = (r) => typeof r == "bigint" && ht <= r;
2782
- function Tr(r, e, s) {
2783
- return Ge(r) && Ge(e) && Ge(s) && e <= r && r < s;
2854
+ const He = (r) => typeof r == "bigint" && ut <= r;
2855
+ function Ir(r, e, s) {
2856
+ return He(r) && He(e) && He(s) && e <= r && r < s;
2784
2857
  }
2785
- function Ar(r, e, s, t) {
2786
- if (!Tr(e, s, t))
2858
+ function Tr(r, e, s, t) {
2859
+ if (!Ir(e, s, t))
2787
2860
  throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
2788
2861
  }
2789
- function kr(r) {
2862
+ function Ar(r) {
2790
2863
  let e;
2791
- for (e = 0; r > ht; r >>= at, e += 1)
2864
+ for (e = 0; r > ut; r >>= it, e += 1)
2792
2865
  ;
2793
2866
  return e;
2794
2867
  }
2795
- const ft = (r) => (at << BigInt(r)) - at;
2796
- function Pr(r, e, s) {
2797
- if (_e(r, "hashLen"), _e(e, "qByteLen"), typeof s != "function")
2868
+ const pt = (r) => (it << BigInt(r)) - it;
2869
+ function Rr(r, e, s) {
2870
+ if (xe(r, "hashLen"), xe(e, "qByteLen"), typeof s != "function")
2798
2871
  throw new Error("hmacFn must be a function");
2799
2872
  const t = (y) => new Uint8Array(y), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
2800
2873
  let c = t(r), l = t(r), d = 0;
2801
2874
  const h = () => {
2802
2875
  c.fill(1), l.fill(0), d = 0;
2803
- }, m = (...y) => s(l, we(c, ...y)), x = (y = n) => {
2876
+ }, m = (...y) => s(l, be(c, ...y)), x = (y = n) => {
2804
2877
  l = m(o, y), c = m(), y.length !== 0 && (l = m(i, y), c = m());
2805
2878
  }, w = () => {
2806
2879
  if (d++ >= a)
@@ -2812,7 +2885,7 @@ function Pr(r, e, s) {
2812
2885
  const O = c.slice();
2813
2886
  S.push(O), y += c.length;
2814
2887
  }
2815
- return we(...S);
2888
+ return be(...S);
2816
2889
  };
2817
2890
  return (y, S) => {
2818
2891
  h(), x(y);
@@ -2822,7 +2895,7 @@ function Pr(r, e, s) {
2822
2895
  return h(), O;
2823
2896
  };
2824
2897
  }
2825
- function _t(r, e = {}, s = {}) {
2898
+ function ft(r, e = {}, s = {}) {
2826
2899
  if (!r || typeof r != "object")
2827
2900
  throw new Error("expected valid options object");
2828
2901
  function t(o, i, a) {
@@ -2836,7 +2909,7 @@ function _t(r, e = {}, s = {}) {
2836
2909
  const n = (o, i) => Object.entries(o).forEach(([a, c]) => t(a, c, i));
2837
2910
  n(e, !1), n(s, !0);
2838
2911
  }
2839
- function Lt(r) {
2912
+ function Dt(r) {
2840
2913
  const e = /* @__PURE__ */ new WeakMap();
2841
2914
  return (s, ...t) => {
2842
2915
  const n = e.get(s);
@@ -2847,7 +2920,7 @@ function Lt(r) {
2847
2920
  };
2848
2921
  }
2849
2922
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2850
- const ne = /* @__PURE__ */ BigInt(0), ee = /* @__PURE__ */ BigInt(1), ve = /* @__PURE__ */ BigInt(2), cs = /* @__PURE__ */ BigInt(3), ls = /* @__PURE__ */ BigInt(4), ds = /* @__PURE__ */ BigInt(5), Nr = /* @__PURE__ */ BigInt(7), us = /* @__PURE__ */ BigInt(8), Rr = /* @__PURE__ */ BigInt(9), hs = /* @__PURE__ */ BigInt(16);
2923
+ const ne = /* @__PURE__ */ BigInt(0), ee = /* @__PURE__ */ BigInt(1), Ee = /* @__PURE__ */ BigInt(2), ls = /* @__PURE__ */ BigInt(3), ds = /* @__PURE__ */ BigInt(4), us = /* @__PURE__ */ BigInt(5), kr = /* @__PURE__ */ BigInt(7), hs = /* @__PURE__ */ BigInt(8), Pr = /* @__PURE__ */ BigInt(9), ps = /* @__PURE__ */ BigInt(16);
2851
2924
  function le(r, e) {
2852
2925
  const s = r % e;
2853
2926
  return s >= ne ? s : e + s;
@@ -2858,7 +2931,7 @@ function ae(r, e, s) {
2858
2931
  t *= t, t %= s;
2859
2932
  return t;
2860
2933
  }
2861
- function Dt(r, e) {
2934
+ function Mt(r, e) {
2862
2935
  if (r === ne)
2863
2936
  throw new Error("invert: expected non-zero number");
2864
2937
  if (e <= ne)
@@ -2872,47 +2945,47 @@ function Dt(r, e) {
2872
2945
  throw new Error("invert: does not exist");
2873
2946
  return le(n, e);
2874
2947
  }
2875
- function xt(r, e, s) {
2948
+ function _t(r, e, s) {
2876
2949
  if (!r.eql(r.sqr(e), s))
2877
2950
  throw new Error("Cannot find square root");
2878
2951
  }
2879
- function ps(r, e) {
2880
- const s = (r.ORDER + ee) / ls, t = r.pow(e, s);
2881
- return xt(r, t, e), t;
2952
+ function fs(r, e) {
2953
+ const s = (r.ORDER + ee) / ds, t = r.pow(e, s);
2954
+ return _t(r, t, e), t;
2882
2955
  }
2883
2956
  function Cr(r, e) {
2884
- const s = (r.ORDER - ds) / us, t = r.mul(e, ve), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, ve), n), a = r.mul(o, r.sub(i, r.ONE));
2885
- return xt(r, a, e), a;
2957
+ const s = (r.ORDER - us) / hs, t = r.mul(e, Ee), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, Ee), n), a = r.mul(o, r.sub(i, r.ONE));
2958
+ return _t(r, a, e), a;
2886
2959
  }
2887
- function Or(r) {
2888
- const e = Ye(r), s = fs(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + Nr) / hs;
2960
+ function Nr(r) {
2961
+ const e = ze(r), s = _s(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + kr) / ps;
2889
2962
  return (a, c) => {
2890
2963
  let l = a.pow(c, i), d = a.mul(l, t);
2891
2964
  const h = a.mul(l, n), m = a.mul(l, o), x = a.eql(a.sqr(d), c), w = a.eql(a.sqr(h), c);
2892
2965
  l = a.cmov(l, d, x), d = a.cmov(m, h, w);
2893
2966
  const E = a.eql(a.sqr(d), c), y = a.cmov(l, d, E);
2894
- return xt(a, y, c), y;
2967
+ return _t(a, y, c), y;
2895
2968
  };
2896
2969
  }
2897
- function fs(r) {
2898
- if (r < cs)
2970
+ function _s(r) {
2971
+ if (r < ls)
2899
2972
  throw new Error("sqrt is not defined for small field");
2900
2973
  let e = r - ee, s = 0;
2901
- for (; e % ve === ne; )
2902
- e /= ve, s++;
2903
- let t = ve;
2904
- const n = Ye(r);
2905
- for (; Mt(n, t) === 1; )
2974
+ for (; e % Ee === ne; )
2975
+ e /= Ee, s++;
2976
+ let t = Ee;
2977
+ const n = ze(r);
2978
+ for (; $t(n, t) === 1; )
2906
2979
  if (t++ > 1e3)
2907
2980
  throw new Error("Cannot find square root: probably non-prime P");
2908
2981
  if (s === 1)
2909
- return ps;
2982
+ return fs;
2910
2983
  let o = n.pow(t, e);
2911
- const i = (e + ee) / ve;
2984
+ const i = (e + ee) / Ee;
2912
2985
  return function(c, l) {
2913
2986
  if (c.is0(l))
2914
2987
  return l;
2915
- if (Mt(c, l) !== 1)
2988
+ if ($t(c, l) !== 1)
2916
2989
  throw new Error("Cannot find square root");
2917
2990
  let d = s, h = c.mul(c.ONE, o), m = c.pow(l, e), x = c.pow(l, i);
2918
2991
  for (; !c.eql(m, c.ONE); ) {
@@ -2928,10 +3001,10 @@ function fs(r) {
2928
3001
  return x;
2929
3002
  };
2930
3003
  }
2931
- function Lr(r) {
2932
- return r % ls === cs ? ps : r % us === ds ? Cr : r % hs === Rr ? Or(r) : fs(r);
3004
+ function Or(r) {
3005
+ return r % ds === ls ? fs : r % hs === us ? Cr : r % ps === Pr ? Nr(r) : _s(r);
2933
3006
  }
2934
- const Dr = [
3007
+ const Lr = [
2935
3008
  "create",
2936
3009
  "isValid",
2937
3010
  "is0",
@@ -2950,15 +3023,15 @@ const Dr = [
2950
3023
  "mulN",
2951
3024
  "sqrN"
2952
3025
  ];
2953
- function Mr(r) {
3026
+ function Dr(r) {
2954
3027
  const e = {
2955
3028
  ORDER: "bigint",
2956
3029
  BYTES: "number",
2957
3030
  BITS: "number"
2958
- }, s = Dr.reduce((t, n) => (t[n] = "function", t), e);
2959
- return _t(r, s), r;
3031
+ }, s = Lr.reduce((t, n) => (t[n] = "function", t), e);
3032
+ return ft(r, s), r;
2960
3033
  }
2961
- function $r(r, e, s) {
3034
+ function Mr(r, e, s) {
2962
3035
  if (s < ne)
2963
3036
  throw new Error("invalid exponent, negatives unsupported");
2964
3037
  if (s === ne)
@@ -2970,39 +3043,39 @@ function $r(r, e, s) {
2970
3043
  s & ee && (t = r.mul(t, n)), n = r.sqr(n), s >>= ee;
2971
3044
  return t;
2972
3045
  }
2973
- function _s(r, e, s = !1) {
3046
+ function xs(r, e, s = !1) {
2974
3047
  const t = new Array(e.length).fill(s ? r.ZERO : void 0), n = e.reduce((i, a, c) => r.is0(a) ? i : (t[c] = i, r.mul(i, a)), r.ONE), o = r.inv(n);
2975
3048
  return e.reduceRight((i, a, c) => r.is0(a) ? i : (t[c] = r.mul(i, t[c]), r.mul(i, a)), o), t;
2976
3049
  }
2977
- function Mt(r, e) {
2978
- const s = (r.ORDER - ee) / ve, t = r.pow(e, s), n = r.eql(t, r.ONE), o = r.eql(t, r.ZERO), i = r.eql(t, r.neg(r.ONE));
3050
+ function $t(r, e) {
3051
+ const s = (r.ORDER - ee) / Ee, t = r.pow(e, s), n = r.eql(t, r.ONE), o = r.eql(t, r.ZERO), i = r.eql(t, r.neg(r.ONE));
2979
3052
  if (!n && !o && !i)
2980
3053
  throw new Error("invalid Legendre symbol result");
2981
3054
  return n ? 1 : o ? 0 : -1;
2982
3055
  }
2983
- function Br(r, e) {
2984
- e !== void 0 && _e(e);
3056
+ function $r(r, e) {
3057
+ e !== void 0 && xe(e);
2985
3058
  const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
2986
3059
  return { nBitLength: s, nByteLength: t };
2987
3060
  }
2988
- class Ur {
3061
+ class Br {
2989
3062
  constructor(e, s = {}) {
2990
- I(this, "ORDER");
2991
- I(this, "BITS");
2992
- I(this, "BYTES");
2993
- I(this, "isLE");
2994
- I(this, "ZERO", ne);
2995
- I(this, "ONE", ee);
2996
- I(this, "_lengths");
2997
- I(this, "_sqrt");
3063
+ T(this, "ORDER");
3064
+ T(this, "BITS");
3065
+ T(this, "BYTES");
3066
+ T(this, "isLE");
3067
+ T(this, "ZERO", ne);
3068
+ T(this, "ONE", ee);
3069
+ T(this, "_lengths");
3070
+ T(this, "_sqrt");
2998
3071
  // cached sqrt
2999
- I(this, "_mod");
3072
+ T(this, "_mod");
3000
3073
  var i;
3001
3074
  if (e <= ne)
3002
3075
  throw new Error("invalid field: expected ORDER > 0, got " + e);
3003
3076
  let t;
3004
3077
  this.isLE = !1, s != null && typeof s == "object" && (typeof s.BITS == "number" && (t = s.BITS), typeof s.sqrt == "function" && (this.sqrt = s.sqrt), typeof s.isLE == "boolean" && (this.isLE = s.isLE), s.allowedLengths && (this._lengths = (i = s.allowedLengths) == null ? void 0 : i.slice()), typeof s.modFromBytes == "boolean" && (this._mod = s.modFromBytes));
3005
- const { nBitLength: n, nByteLength: o } = Br(e, t);
3078
+ const { nBitLength: n, nByteLength: o } = $r(e, t);
3006
3079
  if (o > 2048)
3007
3080
  throw new Error("invalid field: expected ORDER of <= 2048 bytes");
3008
3081
  this.ORDER = e, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
@@ -3044,10 +3117,10 @@ class Ur {
3044
3117
  return le(e * s, this.ORDER);
3045
3118
  }
3046
3119
  pow(e, s) {
3047
- return $r(this, e, s);
3120
+ return Mr(this, e, s);
3048
3121
  }
3049
3122
  div(e, s) {
3050
- return le(e * Dt(s, this.ORDER), this.ORDER);
3123
+ return le(e * Mt(s, this.ORDER), this.ORDER);
3051
3124
  }
3052
3125
  // Same as above, but doesn't normalize
3053
3126
  sqrN(e) {
@@ -3063,16 +3136,16 @@ class Ur {
3063
3136
  return e * s;
3064
3137
  }
3065
3138
  inv(e) {
3066
- return Dt(e, this.ORDER);
3139
+ return Mt(e, this.ORDER);
3067
3140
  }
3068
3141
  sqrt(e) {
3069
- return this._sqrt || (this._sqrt = Lr(this.ORDER)), this._sqrt(this, e);
3142
+ return this._sqrt || (this._sqrt = Or(this.ORDER)), this._sqrt(this, e);
3070
3143
  }
3071
3144
  toBytes(e) {
3072
- return this.isLE ? as(e, this.BYTES) : pt(e, this.BYTES);
3145
+ return this.isLE ? cs(e, this.BYTES) : ht(e, this.BYTES);
3073
3146
  }
3074
3147
  fromBytes(e, s = !1) {
3075
- z(e);
3148
+ V(e);
3076
3149
  const { _lengths: t, BYTES: n, isLE: o, ORDER: i, _mod: a } = this;
3077
3150
  if (t) {
3078
3151
  if (!t.includes(e.length) || e.length > n)
@@ -3082,14 +3155,14 @@ class Ur {
3082
3155
  }
3083
3156
  if (e.length !== n)
3084
3157
  throw new Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
3085
- let c = o ? is(e) : je(e);
3158
+ let c = o ? as(e) : Ve(e);
3086
3159
  if (a && (c = le(c, i)), !s && !this.isValid(c))
3087
3160
  throw new Error("invalid field element: outside of range 0..ORDER");
3088
3161
  return c;
3089
3162
  }
3090
3163
  // TODO: we don't need it here, move out to separate fn
3091
3164
  invertBatch(e) {
3092
- return _s(this, e);
3165
+ return xs(this, e);
3093
3166
  }
3094
3167
  // We can't move this out because Fp6, Fp12 implement it
3095
3168
  // and it's unclear what to return in there.
@@ -3097,75 +3170,75 @@ class Ur {
3097
3170
  return t ? s : e;
3098
3171
  }
3099
3172
  }
3100
- function Ye(r, e = {}) {
3101
- return new Ur(r, e);
3173
+ function ze(r, e = {}) {
3174
+ return new Br(r, e);
3102
3175
  }
3103
- function xs(r) {
3176
+ function gs(r) {
3104
3177
  if (typeof r != "bigint")
3105
3178
  throw new Error("field order must be bigint");
3106
3179
  const e = r.toString(2).length;
3107
3180
  return Math.ceil(e / 8);
3108
3181
  }
3109
- function gs(r) {
3110
- const e = xs(r);
3182
+ function ms(r) {
3183
+ const e = gs(r);
3111
3184
  return e + Math.ceil(e / 2);
3112
3185
  }
3113
- function Hr(r, e, s = !1) {
3114
- z(r);
3115
- const t = r.length, n = xs(e), o = gs(e);
3186
+ function Ur(r, e, s = !1) {
3187
+ V(r);
3188
+ const t = r.length, n = gs(e), o = ms(e);
3116
3189
  if (t < 16 || t < o || t > 1024)
3117
3190
  throw new Error("expected " + o + "-1024 bytes of input, got " + t);
3118
- const i = s ? is(r) : je(r), a = le(i, e - ee) + ee;
3119
- return s ? as(a, n) : pt(a, n);
3191
+ const i = s ? as(r) : Ve(r), a = le(i, e - ee) + ee;
3192
+ return s ? cs(a, n) : ht(a, n);
3120
3193
  }
3121
3194
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3122
- const Pe = /* @__PURE__ */ BigInt(0), Se = /* @__PURE__ */ BigInt(1);
3123
- function ze(r, e) {
3195
+ const Pe = /* @__PURE__ */ BigInt(0), Ie = /* @__PURE__ */ BigInt(1);
3196
+ function qe(r, e) {
3124
3197
  const s = e.negate();
3125
3198
  return r ? s : e;
3126
3199
  }
3127
- function $t(r, e) {
3128
- const s = _s(r.Fp, e.map((t) => t.Z));
3200
+ function Bt(r, e) {
3201
+ const s = xs(r.Fp, e.map((t) => t.Z));
3129
3202
  return e.map((t, n) => r.fromAffine(t.toAffine(s[n])));
3130
3203
  }
3131
- function ms(r, e) {
3204
+ function ws(r, e) {
3132
3205
  if (!Number.isSafeInteger(r) || r <= 0 || r > e)
3133
3206
  throw new Error("invalid window size, expected [1.." + e + "], got W=" + r);
3134
3207
  }
3135
- function Qe(r, e) {
3136
- ms(r, e);
3137
- const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = ft(r), i = BigInt(r);
3208
+ function Xe(r, e) {
3209
+ ws(r, e);
3210
+ const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = pt(r), i = BigInt(r);
3138
3211
  return { windows: s, windowSize: t, mask: o, maxNumber: n, shiftBy: i };
3139
3212
  }
3140
- function Bt(r, e, s) {
3213
+ function Ut(r, e, s) {
3141
3214
  const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
3142
3215
  let a = Number(r & n), c = r >> i;
3143
- a > t && (a -= o, c += Se);
3216
+ a > t && (a -= o, c += Ie);
3144
3217
  const l = e * t, d = l + Math.abs(a) - 1, h = a === 0, m = a < 0, x = e % 2 !== 0;
3145
3218
  return { nextN: c, offset: d, isZero: h, isNeg: m, isNegF: x, offsetF: l };
3146
3219
  }
3147
- const et = /* @__PURE__ */ new WeakMap(), ws = /* @__PURE__ */ new WeakMap();
3148
- function tt(r) {
3149
- return ws.get(r) || 1;
3220
+ const Qe = /* @__PURE__ */ new WeakMap(), ys = /* @__PURE__ */ new WeakMap();
3221
+ function et(r) {
3222
+ return ys.get(r) || 1;
3150
3223
  }
3151
- function Ut(r) {
3224
+ function Ht(r) {
3152
3225
  if (r !== Pe)
3153
3226
  throw new Error("invalid wNAF");
3154
3227
  }
3155
- class Fr {
3228
+ class Hr {
3156
3229
  // Parametrized with a given Point class (not individual point)
3157
3230
  constructor(e, s) {
3158
- I(this, "BASE");
3159
- I(this, "ZERO");
3160
- I(this, "Fn");
3161
- I(this, "bits");
3231
+ T(this, "BASE");
3232
+ T(this, "ZERO");
3233
+ T(this, "Fn");
3234
+ T(this, "bits");
3162
3235
  this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = s;
3163
3236
  }
3164
3237
  // non-const time multiplication ladder
3165
3238
  _unsafeLadder(e, s, t = this.ZERO) {
3166
3239
  let n = e;
3167
3240
  for (; s > Pe; )
3168
- s & Se && (t = t.add(n)), n = n.double(), s >>= Se;
3241
+ s & Ie && (t = t.add(n)), n = n.double(), s >>= Ie;
3169
3242
  return t;
3170
3243
  }
3171
3244
  /**
@@ -3181,7 +3254,7 @@ class Fr {
3181
3254
  * @returns precomputed point tables flattened to a single array
3182
3255
  */
3183
3256
  precomputeWindow(e, s) {
3184
- const { windows: t, windowSize: n } = Qe(s, this.bits), o = [];
3257
+ const { windows: t, windowSize: n } = Xe(s, this.bits), o = [];
3185
3258
  let i = e, a = i;
3186
3259
  for (let c = 0; c < t; c++) {
3187
3260
  a = i, o.push(a);
@@ -3201,12 +3274,12 @@ class Fr {
3201
3274
  if (!this.Fn.isValid(t))
3202
3275
  throw new Error("invalid scalar");
3203
3276
  let n = this.ZERO, o = this.BASE;
3204
- const i = Qe(e, this.bits);
3277
+ const i = Xe(e, this.bits);
3205
3278
  for (let a = 0; a < i.windows; a++) {
3206
- const { nextN: c, offset: l, isZero: d, isNeg: h, isNegF: m, offsetF: x } = Bt(t, a, i);
3207
- t = c, d ? o = o.add(ze(m, s[x])) : n = n.add(ze(h, s[l]));
3279
+ const { nextN: c, offset: l, isZero: d, isNeg: h, isNegF: m, offsetF: x } = Ut(t, a, i);
3280
+ t = c, d ? o = o.add(qe(m, s[x])) : n = n.add(qe(h, s[l]));
3208
3281
  }
3209
- return Ut(t), { p: n, f: o };
3282
+ return Ht(t), { p: n, f: o };
3210
3283
  }
3211
3284
  /**
3212
3285
  * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
@@ -3214,53 +3287,53 @@ class Fr {
3214
3287
  * @returns point
3215
3288
  */
3216
3289
  wNAFUnsafe(e, s, t, n = this.ZERO) {
3217
- const o = Qe(e, this.bits);
3290
+ const o = Xe(e, this.bits);
3218
3291
  for (let i = 0; i < o.windows && t !== Pe; i++) {
3219
- const { nextN: a, offset: c, isZero: l, isNeg: d } = Bt(t, i, o);
3292
+ const { nextN: a, offset: c, isZero: l, isNeg: d } = Ut(t, i, o);
3220
3293
  if (t = a, !l) {
3221
3294
  const h = s[c];
3222
3295
  n = n.add(d ? h.negate() : h);
3223
3296
  }
3224
3297
  }
3225
- return Ut(t), n;
3298
+ return Ht(t), n;
3226
3299
  }
3227
3300
  getPrecomputes(e, s, t) {
3228
- let n = et.get(s);
3229
- return n || (n = this.precomputeWindow(s, e), e !== 1 && (typeof t == "function" && (n = t(n)), et.set(s, n))), n;
3301
+ let n = Qe.get(s);
3302
+ return n || (n = this.precomputeWindow(s, e), e !== 1 && (typeof t == "function" && (n = t(n)), Qe.set(s, n))), n;
3230
3303
  }
3231
3304
  cached(e, s, t) {
3232
- const n = tt(e);
3305
+ const n = et(e);
3233
3306
  return this.wNAF(n, this.getPrecomputes(n, e, t), s);
3234
3307
  }
3235
3308
  unsafe(e, s, t, n) {
3236
- const o = tt(e);
3309
+ const o = et(e);
3237
3310
  return o === 1 ? this._unsafeLadder(e, s, n) : this.wNAFUnsafe(o, this.getPrecomputes(o, e, t), s, n);
3238
3311
  }
3239
3312
  // We calculate precomputes for elliptic curve point multiplication
3240
3313
  // using windowed method. This specifies window size and
3241
3314
  // stores precomputed values. Usually only base point would be precomputed.
3242
3315
  createCache(e, s) {
3243
- ms(s, this.bits), ws.set(e, s), et.delete(e);
3316
+ ws(s, this.bits), ys.set(e, s), Qe.delete(e);
3244
3317
  }
3245
3318
  hasCache(e) {
3246
- return tt(e) !== 1;
3319
+ return et(e) !== 1;
3247
3320
  }
3248
3321
  }
3249
- function Gr(r, e, s, t) {
3322
+ function Fr(r, e, s, t) {
3250
3323
  let n = e, o = r.ZERO, i = r.ZERO;
3251
3324
  for (; s > Pe || t > Pe; )
3252
- s & Se && (o = o.add(n)), t & Se && (i = i.add(n)), n = n.double(), s >>= Se, t >>= Se;
3325
+ s & Ie && (o = o.add(n)), t & Ie && (i = i.add(n)), n = n.double(), s >>= Ie, t >>= Ie;
3253
3326
  return { p1: o, p2: i };
3254
3327
  }
3255
- function Ht(r, e, s) {
3328
+ function Ft(r, e, s) {
3256
3329
  if (e) {
3257
3330
  if (e.ORDER !== r)
3258
3331
  throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
3259
- return Mr(e), e;
3332
+ return Dr(e), e;
3260
3333
  } else
3261
- return Ye(r, { isLE: s });
3334
+ return ze(r, { isLE: s });
3262
3335
  }
3263
- function Wr(r, e, s = {}, t) {
3336
+ function Gr(r, e, s = {}, t) {
3264
3337
  if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
3265
3338
  throw new Error(`expected valid ${r} CURVE object`);
3266
3339
  for (const c of ["p", "n", "h"]) {
@@ -3268,27 +3341,27 @@ function Wr(r, e, s = {}, t) {
3268
3341
  if (!(typeof l == "bigint" && l > Pe))
3269
3342
  throw new Error(`CURVE.${c} must be positive bigint`);
3270
3343
  }
3271
- const n = Ht(e.p, s.Fp, t), o = Ht(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
3344
+ const n = Ft(e.p, s.Fp, t), o = Ft(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
3272
3345
  for (const c of a)
3273
3346
  if (!n.isValid(e[c]))
3274
3347
  throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
3275
3348
  return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: n, Fn: o };
3276
3349
  }
3277
- function qr(r, e) {
3350
+ function Wr(r, e) {
3278
3351
  return function(t) {
3279
3352
  const n = r(t);
3280
3353
  return { secretKey: n, publicKey: e(n) };
3281
3354
  };
3282
3355
  }
3283
- class ys {
3356
+ class bs {
3284
3357
  constructor(e, s) {
3285
- I(this, "oHash");
3286
- I(this, "iHash");
3287
- I(this, "blockLen");
3288
- I(this, "outputLen");
3289
- I(this, "finished", !1);
3290
- I(this, "destroyed", !1);
3291
- if (Qt(e), z(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
3358
+ T(this, "oHash");
3359
+ T(this, "iHash");
3360
+ T(this, "blockLen");
3361
+ T(this, "outputLen");
3362
+ T(this, "finished", !1);
3363
+ T(this, "destroyed", !1);
3364
+ if (es(e), V(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
3292
3365
  throw new Error("Expected instance of class which extends utils.Hash");
3293
3366
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
3294
3367
  const t = this.blockLen, n = new Uint8Array(t);
@@ -3301,10 +3374,10 @@ class ys {
3301
3374
  this.oHash.update(n), ke(n);
3302
3375
  }
3303
3376
  update(e) {
3304
- return Ae(this), this.iHash.update(e), this;
3377
+ return Re(this), this.iHash.update(e), this;
3305
3378
  }
3306
3379
  digestInto(e) {
3307
- Ae(this), z(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
3380
+ Re(this), V(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
3308
3381
  }
3309
3382
  digest() {
3310
3383
  const e = new Uint8Array(this.oHash.outputLen);
@@ -3322,56 +3395,56 @@ class ys {
3322
3395
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
3323
3396
  }
3324
3397
  }
3325
- const bs = (r, e, s) => new ys(r, e).update(s).digest();
3326
- bs.create = (r, e) => new ys(r, e);
3398
+ const vs = (r, e, s) => new bs(r, e).update(s).digest();
3399
+ vs.create = (r, e) => new bs(r, e);
3327
3400
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3328
- const Ft = (r, e) => (r + (r >= 0 ? e : -e) / vs) / e;
3329
- function Vr(r, e, s) {
3330
- const [[t, n], [o, i]] = e, a = Ft(i * r, s), c = Ft(-n * r, s);
3401
+ const Gt = (r, e) => (r + (r >= 0 ? e : -e) / Ss) / e;
3402
+ function qr(r, e, s) {
3403
+ const [[t, n], [o, i]] = e, a = Gt(i * r, s), c = Gt(-n * r, s);
3331
3404
  let l = r - a * t - c * o, d = -a * n - c * i;
3332
- const h = l < pe, m = d < pe;
3405
+ const h = l < fe, m = d < fe;
3333
3406
  h && (l = -l), m && (d = -d);
3334
- const x = ft(Math.ceil(kr(s) / 2)) + Te;
3335
- if (l < pe || l >= x || d < pe || d >= x)
3407
+ const x = pt(Math.ceil(Ar(s) / 2)) + Ae;
3408
+ if (l < fe || l >= x || d < fe || d >= x)
3336
3409
  throw new Error("splitScalar (endomorphism): failed, k=" + r);
3337
3410
  return { k1neg: h, k1: l, k2neg: m, k2: d };
3338
3411
  }
3339
- function ct(r) {
3412
+ function at(r) {
3340
3413
  if (!["compact", "recovered", "der"].includes(r))
3341
3414
  throw new Error('Signature format must be "compact", "recovered", or "der"');
3342
3415
  return r;
3343
3416
  }
3344
- function st(r, e) {
3417
+ function tt(r, e) {
3345
3418
  const s = {};
3346
3419
  for (let t of Object.keys(e))
3347
3420
  s[t] = r[t] === void 0 ? e[t] : r[t];
3348
- return Ve(s.lowS, "lowS"), Ve(s.prehash, "prehash"), s.format !== void 0 && ct(s.format), s;
3421
+ return We(s.lowS, "lowS"), We(s.prehash, "prehash"), s.format !== void 0 && at(s.format), s;
3349
3422
  }
3350
- class zr extends Error {
3423
+ class Kr extends Error {
3351
3424
  constructor(e = "") {
3352
3425
  super(e);
3353
3426
  }
3354
3427
  }
3355
- const me = {
3428
+ const we = {
3356
3429
  // asn.1 DER encoding utils
3357
- Err: zr,
3430
+ Err: Kr,
3358
3431
  // Basic building block is TLV (Tag-Length-Value)
3359
3432
  _tlv: {
3360
3433
  encode: (r, e) => {
3361
- const { Err: s } = me;
3434
+ const { Err: s } = we;
3362
3435
  if (r < 0 || r > 256)
3363
3436
  throw new s("tlv.encode: wrong tag");
3364
3437
  if (e.length & 1)
3365
3438
  throw new s("tlv.encode: unpadded data");
3366
- const t = e.length / 2, n = He(t);
3439
+ const t = e.length / 2, n = Be(t);
3367
3440
  if (n.length / 2 & 128)
3368
3441
  throw new s("tlv.encode: long form length too big");
3369
- const o = t > 127 ? He(n.length / 2 | 128) : "";
3370
- return He(r) + o + n + e;
3442
+ const o = t > 127 ? Be(n.length / 2 | 128) : "";
3443
+ return Be(r) + o + n + e;
3371
3444
  },
3372
3445
  // v - value, l - left bytes (unparsed)
3373
3446
  decode(r, e) {
3374
- const { Err: s } = me;
3447
+ const { Err: s } = we;
3375
3448
  let t = 0;
3376
3449
  if (r < 0 || r > 256)
3377
3450
  throw new s("tlv.encode: wrong tag");
@@ -3409,25 +3482,25 @@ const me = {
3409
3482
  // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
3410
3483
  _int: {
3411
3484
  encode(r) {
3412
- const { Err: e } = me;
3413
- if (r < pe)
3485
+ const { Err: e } = we;
3486
+ if (r < fe)
3414
3487
  throw new e("integer: negative integers are not allowed");
3415
- let s = He(r);
3488
+ let s = Be(r);
3416
3489
  if (Number.parseInt(s[0], 16) & 8 && (s = "00" + s), s.length & 1)
3417
3490
  throw new e("unexpected DER parsing assertion: unpadded hex");
3418
3491
  return s;
3419
3492
  },
3420
3493
  decode(r) {
3421
- const { Err: e } = me;
3494
+ const { Err: e } = we;
3422
3495
  if (r[0] & 128)
3423
3496
  throw new e("invalid signature integer: negative");
3424
3497
  if (r[0] === 0 && !(r[1] & 128))
3425
3498
  throw new e("invalid signature integer: unnecessary leading zero");
3426
- return je(r);
3499
+ return Ve(r);
3427
3500
  }
3428
3501
  },
3429
3502
  toSig(r) {
3430
- const { Err: e, _int: s, _tlv: t } = me, n = z(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
3503
+ const { Err: e, _int: s, _tlv: t } = we, n = V(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
3431
3504
  if (i.length)
3432
3505
  throw new e("invalid signature: left bytes after parsing");
3433
3506
  const { v: a, l: c } = t.decode(2, o), { v: l, l: d } = t.decode(2, c);
@@ -3436,15 +3509,15 @@ const me = {
3436
3509
  return { r: s.decode(a), s: s.decode(l) };
3437
3510
  },
3438
3511
  hexFromSig(r) {
3439
- const { _tlv: e, _int: s } = me, t = e.encode(2, s.encode(r.r)), n = e.encode(2, s.encode(r.s)), o = t + n;
3512
+ const { _tlv: e, _int: s } = we, t = e.encode(2, s.encode(r.r)), n = e.encode(2, s.encode(r.s)), o = t + n;
3440
3513
  return e.encode(48, o);
3441
3514
  }
3442
- }, pe = BigInt(0), Te = BigInt(1), vs = BigInt(2), Fe = BigInt(3), Kr = BigInt(4);
3443
- function jr(r, e = {}) {
3444
- const s = Wr("weierstrass", r, e), { Fp: t, Fn: n } = s;
3515
+ }, fe = BigInt(0), Ae = BigInt(1), Ss = BigInt(2), Ue = BigInt(3), Vr = BigInt(4);
3516
+ function zr(r, e = {}) {
3517
+ const s = Gr("weierstrass", r, e), { Fp: t, Fn: n } = s;
3445
3518
  let o = s.CURVE;
3446
3519
  const { h: i, n: a } = o;
3447
- _t(e, {}, {
3520
+ ft(e, {}, {
3448
3521
  allowInfinityPoint: "boolean",
3449
3522
  clearCofactor: "function",
3450
3523
  isTorsionFree: "function",
@@ -3460,105 +3533,105 @@ function jr(r, e = {}) {
3460
3533
  if (!t.isOdd)
3461
3534
  throw new Error("compression is not supported: Field does not have .isOdd()");
3462
3535
  }
3463
- function h(R, f, _) {
3464
- const { x: v, y: A } = f.toAffine(), L = t.toBytes(v);
3465
- if (Ve(_, "isCompressed"), _) {
3536
+ function h(C, f, _) {
3537
+ const { x: v, y: I } = f.toAffine(), L = t.toBytes(v);
3538
+ if (We(_, "isCompressed"), _) {
3466
3539
  d();
3467
- const C = !t.isOdd(A);
3468
- return we(Ss(C), L);
3540
+ const N = !t.isOdd(I);
3541
+ return be(Es(N), L);
3469
3542
  } else
3470
- return we(Uint8Array.of(4), L, t.toBytes(A));
3471
- }
3472
- function m(R) {
3473
- z(R, void 0, "Point");
3474
- const { publicKey: f, publicKeyUncompressed: _ } = l, v = R.length, A = R[0], L = R.subarray(1);
3475
- if (v === f && (A === 2 || A === 3)) {
3476
- const C = t.fromBytes(L);
3477
- if (!t.isValid(C))
3543
+ return be(Uint8Array.of(4), L, t.toBytes(I));
3544
+ }
3545
+ function m(C) {
3546
+ V(C, void 0, "Point");
3547
+ const { publicKey: f, publicKeyUncompressed: _ } = l, v = C.length, I = C[0], L = C.subarray(1);
3548
+ if (v === f && (I === 2 || I === 3)) {
3549
+ const N = t.fromBytes(L);
3550
+ if (!t.isValid(N))
3478
3551
  throw new Error("bad point: is not on curve, wrong x");
3479
- const M = E(C);
3480
- let T;
3552
+ const M = E(N);
3553
+ let A;
3481
3554
  try {
3482
- T = t.sqrt(M);
3555
+ A = t.sqrt(M);
3483
3556
  } catch (J) {
3484
- const V = J instanceof Error ? ": " + J.message : "";
3485
- throw new Error("bad point: is not on curve, sqrt error" + V);
3557
+ const K = J instanceof Error ? ": " + J.message : "";
3558
+ throw new Error("bad point: is not on curve, sqrt error" + K);
3486
3559
  }
3487
3560
  d();
3488
- const $ = t.isOdd(T);
3489
- return (A & 1) === 1 !== $ && (T = t.neg(T)), { x: C, y: T };
3490
- } else if (v === _ && A === 4) {
3491
- const C = t.BYTES, M = t.fromBytes(L.subarray(0, C)), T = t.fromBytes(L.subarray(C, C * 2));
3492
- if (!y(M, T))
3561
+ const $ = t.isOdd(A);
3562
+ return (I & 1) === 1 !== $ && (A = t.neg(A)), { x: N, y: A };
3563
+ } else if (v === _ && I === 4) {
3564
+ const N = t.BYTES, M = t.fromBytes(L.subarray(0, N)), A = t.fromBytes(L.subarray(N, N * 2));
3565
+ if (!y(M, A))
3493
3566
  throw new Error("bad point: is not on curve");
3494
- return { x: M, y: T };
3567
+ return { x: M, y: A };
3495
3568
  } else
3496
3569
  throw new Error(`bad point: got length ${v}, expected compressed=${f} or uncompressed=${_}`);
3497
3570
  }
3498
3571
  const x = e.toBytes || h, w = e.fromBytes || m;
3499
- function E(R) {
3500
- const f = t.sqr(R), _ = t.mul(f, R);
3501
- return t.add(t.add(_, t.mul(R, o.a)), o.b);
3572
+ function E(C) {
3573
+ const f = t.sqr(C), _ = t.mul(f, C);
3574
+ return t.add(t.add(_, t.mul(C, o.a)), o.b);
3502
3575
  }
3503
- function y(R, f) {
3504
- const _ = t.sqr(f), v = E(R);
3576
+ function y(C, f) {
3577
+ const _ = t.sqr(f), v = E(C);
3505
3578
  return t.eql(_, v);
3506
3579
  }
3507
3580
  if (!y(o.Gx, o.Gy))
3508
3581
  throw new Error("bad curve params: generator point");
3509
- const S = t.mul(t.pow(o.a, Fe), Kr), O = t.mul(t.sqr(o.b), BigInt(27));
3582
+ const S = t.mul(t.pow(o.a, Ue), Vr), O = t.mul(t.sqr(o.b), BigInt(27));
3510
3583
  if (t.is0(t.add(S, O)))
3511
3584
  throw new Error("bad curve params: a or b");
3512
- function B(R, f, _ = !1) {
3585
+ function B(C, f, _ = !1) {
3513
3586
  if (!t.isValid(f) || _ && t.is0(f))
3514
- throw new Error(`bad point coordinate ${R}`);
3587
+ throw new Error(`bad point coordinate ${C}`);
3515
3588
  return f;
3516
3589
  }
3517
- function b(R) {
3518
- if (!(R instanceof W))
3590
+ function b(C) {
3591
+ if (!(C instanceof W))
3519
3592
  throw new Error("Weierstrass Point expected");
3520
3593
  }
3521
- function P(R) {
3594
+ function k(C) {
3522
3595
  if (!c || !c.basises)
3523
3596
  throw new Error("no endo");
3524
- return Vr(R, c.basises, n.ORDER);
3597
+ return qr(C, c.basises, n.ORDER);
3525
3598
  }
3526
- const N = Lt((R, f) => {
3527
- const { X: _, Y: v, Z: A } = R;
3528
- if (t.eql(A, t.ONE))
3599
+ const P = Dt((C, f) => {
3600
+ const { X: _, Y: v, Z: I } = C;
3601
+ if (t.eql(I, t.ONE))
3529
3602
  return { x: _, y: v };
3530
- const L = R.is0();
3531
- f == null && (f = L ? t.ONE : t.inv(A));
3532
- const C = t.mul(_, f), M = t.mul(v, f), T = t.mul(A, f);
3603
+ const L = C.is0();
3604
+ f == null && (f = L ? t.ONE : t.inv(I));
3605
+ const N = t.mul(_, f), M = t.mul(v, f), A = t.mul(I, f);
3533
3606
  if (L)
3534
3607
  return { x: t.ZERO, y: t.ZERO };
3535
- if (!t.eql(T, t.ONE))
3608
+ if (!t.eql(A, t.ONE))
3536
3609
  throw new Error("invZ was invalid");
3537
- return { x: C, y: M };
3538
- }), G = Lt((R) => {
3539
- if (R.is0()) {
3540
- if (e.allowInfinityPoint && !t.is0(R.Y))
3610
+ return { x: N, y: M };
3611
+ }), G = Dt((C) => {
3612
+ if (C.is0()) {
3613
+ if (e.allowInfinityPoint && !t.is0(C.Y))
3541
3614
  return;
3542
3615
  throw new Error("bad point: ZERO");
3543
3616
  }
3544
- const { x: f, y: _ } = R.toAffine();
3617
+ const { x: f, y: _ } = C.toAffine();
3545
3618
  if (!t.isValid(f) || !t.isValid(_))
3546
3619
  throw new Error("bad point: x or y not field elements");
3547
3620
  if (!y(f, _))
3548
3621
  throw new Error("bad point: equation left != right");
3549
- if (!R.isTorsionFree())
3622
+ if (!C.isTorsionFree())
3550
3623
  throw new Error("bad point: not in prime-order subgroup");
3551
3624
  return !0;
3552
3625
  });
3553
- function K(R, f, _, v, A) {
3554
- return _ = new W(t.mul(_.X, R), _.Y, _.Z), f = ze(v, f), _ = ze(A, _), f.add(_);
3626
+ function z(C, f, _, v, I) {
3627
+ return _ = new W(t.mul(_.X, C), _.Y, _.Z), f = qe(v, f), _ = qe(I, _), f.add(_);
3555
3628
  }
3556
- const k = class k {
3629
+ const R = class R {
3557
3630
  /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
3558
3631
  constructor(f, _, v) {
3559
- I(this, "X");
3560
- I(this, "Y");
3561
- I(this, "Z");
3632
+ T(this, "X");
3633
+ T(this, "Y");
3634
+ T(this, "Z");
3562
3635
  this.X = B("x", f), this.Y = B("y", _, !0), this.Z = B("z", v), Object.freeze(this);
3563
3636
  }
3564
3637
  static CURVE() {
@@ -3569,16 +3642,16 @@ function jr(r, e = {}) {
3569
3642
  const { x: _, y: v } = f || {};
3570
3643
  if (!f || !t.isValid(_) || !t.isValid(v))
3571
3644
  throw new Error("invalid affine point");
3572
- if (f instanceof k)
3645
+ if (f instanceof R)
3573
3646
  throw new Error("projective point not allowed");
3574
- return t.is0(_) && t.is0(v) ? k.ZERO : new k(_, v, t.ONE);
3647
+ return t.is0(_) && t.is0(v) ? R.ZERO : new R(_, v, t.ONE);
3575
3648
  }
3576
3649
  static fromBytes(f) {
3577
- const _ = k.fromAffine(w(z(f, void 0, "point")));
3650
+ const _ = R.fromAffine(w(V(f, void 0, "point")));
3578
3651
  return _.assertValidity(), _;
3579
3652
  }
3580
3653
  static fromHex(f) {
3581
- return k.fromBytes(qe(f));
3654
+ return R.fromBytes(Ge(f));
3582
3655
  }
3583
3656
  get x() {
3584
3657
  return this.toAffine().x;
@@ -3593,7 +3666,7 @@ function jr(r, e = {}) {
3593
3666
  * @returns
3594
3667
  */
3595
3668
  precompute(f = 8, _ = !0) {
3596
- return D.createCache(this, f), _ || this.multiply(Fe), this;
3669
+ return D.createCache(this, f), _ || this.multiply(Ue), this;
3597
3670
  }
3598
3671
  // TODO: return `this`
3599
3672
  /** A point on curve is valid if it conforms to equation. */
@@ -3609,21 +3682,21 @@ function jr(r, e = {}) {
3609
3682
  /** Compare one point to another. */
3610
3683
  equals(f) {
3611
3684
  b(f);
3612
- const { X: _, Y: v, Z: A } = this, { X: L, Y: C, Z: M } = f, T = t.eql(t.mul(_, M), t.mul(L, A)), $ = t.eql(t.mul(v, M), t.mul(C, A));
3613
- return T && $;
3685
+ const { X: _, Y: v, Z: I } = this, { X: L, Y: N, Z: M } = f, A = t.eql(t.mul(_, M), t.mul(L, I)), $ = t.eql(t.mul(v, M), t.mul(N, I));
3686
+ return A && $;
3614
3687
  }
3615
3688
  /** Flips point to one corresponding to (x, -y) in Affine coordinates. */
3616
3689
  negate() {
3617
- return new k(this.X, t.neg(this.Y), this.Z);
3690
+ return new R(this.X, t.neg(this.Y), this.Z);
3618
3691
  }
3619
3692
  // Renes-Costello-Batina exception-free doubling formula.
3620
3693
  // There is 30% faster Jacobian formula, but it is not complete.
3621
3694
  // https://eprint.iacr.org/2015/1060, algorithm 3
3622
3695
  // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
3623
3696
  double() {
3624
- const { a: f, b: _ } = o, v = t.mul(_, Fe), { X: A, Y: L, Z: C } = this;
3625
- let M = t.ZERO, T = t.ZERO, $ = t.ZERO, F = t.mul(A, A), J = t.mul(L, L), V = t.mul(C, C), H = t.mul(A, L);
3626
- return H = t.add(H, H), $ = t.mul(A, C), $ = t.add($, $), M = t.mul(f, $), T = t.mul(v, V), T = t.add(M, T), M = t.sub(J, T), T = t.add(J, T), T = t.mul(M, T), M = t.mul(H, M), $ = t.mul(v, $), V = t.mul(f, V), H = t.sub(F, V), H = t.mul(f, H), H = t.add(H, $), $ = t.add(F, F), F = t.add($, F), F = t.add(F, V), F = t.mul(F, H), T = t.add(T, F), V = t.mul(L, C), V = t.add(V, V), F = t.mul(V, H), M = t.sub(M, F), $ = t.mul(V, J), $ = t.add($, $), $ = t.add($, $), new k(M, T, $);
3697
+ const { a: f, b: _ } = o, v = t.mul(_, Ue), { X: I, Y: L, Z: N } = this;
3698
+ let M = t.ZERO, A = t.ZERO, $ = t.ZERO, F = t.mul(I, I), J = t.mul(L, L), K = t.mul(N, N), H = t.mul(I, L);
3699
+ return H = t.add(H, H), $ = t.mul(I, N), $ = t.add($, $), M = t.mul(f, $), A = t.mul(v, K), A = t.add(M, A), M = t.sub(J, A), A = t.add(J, A), A = t.mul(M, A), M = t.mul(H, M), $ = t.mul(v, $), K = t.mul(f, K), H = t.sub(F, K), H = t.mul(f, H), H = t.add(H, $), $ = t.add(F, F), F = t.add($, F), F = t.add(F, K), F = t.mul(F, H), A = t.add(A, F), K = t.mul(L, N), K = t.add(K, K), F = t.mul(K, H), M = t.sub(M, F), $ = t.mul(K, J), $ = t.add($, $), $ = t.add($, $), new R(M, A, $);
3627
3700
  }
3628
3701
  // Renes-Costello-Batina exception-free addition formula.
3629
3702
  // There is 30% faster Jacobian formula, but it is not complete.
@@ -3631,19 +3704,19 @@ function jr(r, e = {}) {
3631
3704
  // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
3632
3705
  add(f) {
3633
3706
  b(f);
3634
- const { X: _, Y: v, Z: A } = this, { X: L, Y: C, Z: M } = f;
3635
- let T = t.ZERO, $ = t.ZERO, F = t.ZERO;
3636
- const J = o.a, V = t.mul(o.b, Fe);
3637
- let H = t.mul(_, L), Z = t.mul(v, C), X = t.mul(A, M), oe = t.add(_, v), j = t.add(L, C);
3638
- oe = t.mul(oe, j), j = t.add(H, Z), oe = t.sub(oe, j), j = t.add(_, A);
3707
+ const { X: _, Y: v, Z: I } = this, { X: L, Y: N, Z: M } = f;
3708
+ let A = t.ZERO, $ = t.ZERO, F = t.ZERO;
3709
+ const J = o.a, K = t.mul(o.b, Ue);
3710
+ let H = t.mul(_, L), Z = t.mul(v, N), X = t.mul(I, M), oe = t.add(_, v), j = t.add(L, N);
3711
+ oe = t.mul(oe, j), j = t.add(H, Z), oe = t.sub(oe, j), j = t.add(_, I);
3639
3712
  let Q = t.add(L, M);
3640
- return j = t.mul(j, Q), Q = t.add(H, X), j = t.sub(j, Q), Q = t.add(v, A), T = t.add(C, M), Q = t.mul(Q, T), T = t.add(Z, X), Q = t.sub(Q, T), F = t.mul(J, j), T = t.mul(V, X), F = t.add(T, F), T = t.sub(Z, F), F = t.add(Z, F), $ = t.mul(T, F), Z = t.add(H, H), Z = t.add(Z, H), X = t.mul(J, X), j = t.mul(V, j), Z = t.add(Z, X), X = t.sub(H, X), X = t.mul(J, X), j = t.add(j, X), H = t.mul(Z, j), $ = t.add($, H), H = t.mul(Q, j), T = t.mul(oe, T), T = t.sub(T, H), H = t.mul(oe, Z), F = t.mul(Q, F), F = t.add(F, H), new k(T, $, F);
3713
+ return j = t.mul(j, Q), Q = t.add(H, X), j = t.sub(j, Q), Q = t.add(v, I), A = t.add(N, M), Q = t.mul(Q, A), A = t.add(Z, X), Q = t.sub(Q, A), F = t.mul(J, j), A = t.mul(K, X), F = t.add(A, F), A = t.sub(Z, F), F = t.add(Z, F), $ = t.mul(A, F), Z = t.add(H, H), Z = t.add(Z, H), X = t.mul(J, X), j = t.mul(K, j), Z = t.add(Z, X), X = t.sub(H, X), X = t.mul(J, X), j = t.add(j, X), H = t.mul(Z, j), $ = t.add($, H), H = t.mul(Q, j), A = t.mul(oe, A), A = t.sub(A, H), H = t.mul(oe, Z), F = t.mul(Q, F), F = t.add(F, H), new R(A, $, F);
3641
3714
  }
3642
3715
  subtract(f) {
3643
3716
  return this.add(f.negate());
3644
3717
  }
3645
3718
  is0() {
3646
- return this.equals(k.ZERO);
3719
+ return this.equals(R.ZERO);
3647
3720
  }
3648
3721
  /**
3649
3722
  * Constant time multiplication.
@@ -3658,16 +3731,16 @@ function jr(r, e = {}) {
3658
3731
  const { endo: _ } = e;
3659
3732
  if (!n.isValidNot0(f))
3660
3733
  throw new Error("invalid scalar: out of range");
3661
- let v, A;
3662
- const L = (C) => D.cached(this, C, (M) => $t(k, M));
3734
+ let v, I;
3735
+ const L = (N) => D.cached(this, N, (M) => Bt(R, M));
3663
3736
  if (_) {
3664
- const { k1neg: C, k1: M, k2neg: T, k2: $ } = P(f), { p: F, f: J } = L(M), { p: V, f: H } = L($);
3665
- A = J.add(H), v = K(_.beta, F, V, C, T);
3737
+ const { k1neg: N, k1: M, k2neg: A, k2: $ } = k(f), { p: F, f: J } = L(M), { p: K, f: H } = L($);
3738
+ I = J.add(H), v = z(_.beta, F, K, N, A);
3666
3739
  } else {
3667
- const { p: C, f: M } = L(f);
3668
- v = C, A = M;
3740
+ const { p: N, f: M } = L(f);
3741
+ v = N, I = M;
3669
3742
  }
3670
- return $t(k, [v, A])[0];
3743
+ return Bt(R, [v, I])[0];
3671
3744
  }
3672
3745
  /**
3673
3746
  * Non-constant-time multiplication. Uses double-and-add algorithm.
@@ -3678,15 +3751,15 @@ function jr(r, e = {}) {
3678
3751
  const { endo: _ } = e, v = this;
3679
3752
  if (!n.isValid(f))
3680
3753
  throw new Error("invalid scalar: out of range");
3681
- if (f === pe || v.is0())
3682
- return k.ZERO;
3683
- if (f === Te)
3754
+ if (f === fe || v.is0())
3755
+ return R.ZERO;
3756
+ if (f === Ae)
3684
3757
  return v;
3685
3758
  if (D.hasCache(this))
3686
3759
  return this.multiply(f);
3687
3760
  if (_) {
3688
- const { k1neg: A, k1: L, k2neg: C, k2: M } = P(f), { p1: T, p2: $ } = Gr(k, v, L, M);
3689
- return K(_.beta, T, $, A, C);
3761
+ const { k1neg: I, k1: L, k2neg: N, k2: M } = k(f), { p1: A, p2: $ } = Fr(R, v, L, M);
3762
+ return z(_.beta, A, $, I, N);
3690
3763
  } else
3691
3764
  return D.unsafe(v, f);
3692
3765
  }
@@ -3695,7 +3768,7 @@ function jr(r, e = {}) {
3695
3768
  * @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
3696
3769
  */
3697
3770
  toAffine(f) {
3698
- return N(this, f);
3771
+ return P(this, f);
3699
3772
  }
3700
3773
  /**
3701
3774
  * Checks whether Point is free of torsion elements (is in prime subgroup).
@@ -3703,36 +3776,36 @@ function jr(r, e = {}) {
3703
3776
  */
3704
3777
  isTorsionFree() {
3705
3778
  const { isTorsionFree: f } = e;
3706
- return i === Te ? !0 : f ? f(k, this) : D.unsafe(this, a).is0();
3779
+ return i === Ae ? !0 : f ? f(R, this) : D.unsafe(this, a).is0();
3707
3780
  }
3708
3781
  clearCofactor() {
3709
3782
  const { clearCofactor: f } = e;
3710
- return i === Te ? this : f ? f(k, this) : this.multiplyUnsafe(i);
3783
+ return i === Ae ? this : f ? f(R, this) : this.multiplyUnsafe(i);
3711
3784
  }
3712
3785
  isSmallOrder() {
3713
3786
  return this.multiplyUnsafe(i).is0();
3714
3787
  }
3715
3788
  toBytes(f = !0) {
3716
- return Ve(f, "isCompressed"), this.assertValidity(), x(k, this, f);
3789
+ return We(f, "isCompressed"), this.assertValidity(), x(R, this, f);
3717
3790
  }
3718
3791
  toHex(f = !0) {
3719
- return Me(this.toBytes(f));
3792
+ return De(this.toBytes(f));
3720
3793
  }
3721
3794
  toString() {
3722
3795
  return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
3723
3796
  }
3724
3797
  };
3725
3798
  // base / generator point
3726
- I(k, "BASE", new k(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
3727
- I(k, "ZERO", new k(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
3799
+ T(R, "BASE", new R(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
3800
+ T(R, "ZERO", new R(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
3728
3801
  // math field
3729
- I(k, "Fp", t), // scalar field
3730
- I(k, "Fn", n);
3731
- let W = k;
3732
- const q = n.BITS, D = new Fr(W, e.endo ? Math.ceil(q / 2) : q);
3802
+ T(R, "Fp", t), // scalar field
3803
+ T(R, "Fn", n);
3804
+ let W = R;
3805
+ const q = n.BITS, D = new Hr(W, e.endo ? Math.ceil(q / 2) : q);
3733
3806
  return W.BASE.precompute(8), W;
3734
3807
  }
3735
- function Ss(r) {
3808
+ function Es(r) {
3736
3809
  return Uint8Array.of(r ? 2 : 3);
3737
3810
  }
3738
3811
  function Is(r, e) {
@@ -3744,8 +3817,8 @@ function Is(r, e) {
3744
3817
  signature: 2 * e.BYTES
3745
3818
  };
3746
3819
  }
3747
- function Yr(r, e = {}) {
3748
- const { Fn: s } = r, t = e.randomBytes || rs, n = Object.assign(Is(r.Fp, s), { seed: gs(s.ORDER) });
3820
+ function jr(r, e = {}) {
3821
+ const { Fn: s } = r, t = e.randomBytes || ns, n = Object.assign(Is(r.Fp, s), { seed: ms(s.ORDER) });
3749
3822
  function o(x) {
3750
3823
  try {
3751
3824
  const w = s.fromBytes(x);
@@ -3764,16 +3837,16 @@ function Yr(r, e = {}) {
3764
3837
  }
3765
3838
  }
3766
3839
  function a(x = t(n.seed)) {
3767
- return Hr(z(x, n.seed, "seed"), s.ORDER);
3840
+ return Ur(V(x, n.seed, "seed"), s.ORDER);
3768
3841
  }
3769
3842
  function c(x, w = !0) {
3770
3843
  return r.BASE.multiply(s.fromBytes(x)).toBytes(w);
3771
3844
  }
3772
3845
  function l(x) {
3773
3846
  const { secretKey: w, publicKey: E, publicKeyUncompressed: y } = n;
3774
- if (!ut(x) || "_lengths" in s && s._lengths || w === E)
3847
+ if (!dt(x) || "_lengths" in s && s._lengths || w === E)
3775
3848
  return;
3776
- const S = z(x, void 0, "key").length;
3849
+ const S = V(x, void 0, "key").length;
3777
3850
  return S === E || S === y;
3778
3851
  }
3779
3852
  function d(x, w, E = !0) {
@@ -3788,25 +3861,25 @@ function Yr(r, e = {}) {
3788
3861
  isValidSecretKey: o,
3789
3862
  isValidPublicKey: i,
3790
3863
  randomSecretKey: a
3791
- }, m = qr(a, c);
3864
+ }, m = Wr(a, c);
3792
3865
  return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: m, Point: r, utils: h, lengths: n });
3793
3866
  }
3794
- function Jr(r, e, s = {}) {
3795
- Qt(e), _t(s, {}, {
3867
+ function Yr(r, e, s = {}) {
3868
+ es(e), ft(s, {}, {
3796
3869
  hmac: "function",
3797
3870
  lowS: "boolean",
3798
3871
  randomBytes: "function",
3799
3872
  bits2int: "function",
3800
3873
  bits2int_modN: "function"
3801
3874
  }), s = Object.assign({}, s);
3802
- const t = s.randomBytes || rs, n = s.hmac || ((f, _) => bs(e, f, _)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: d, getSharedSecret: h, utils: m, lengths: x } = Yr(r, s), w = {
3875
+ const t = s.randomBytes || ns, n = s.hmac || ((f, _) => vs(e, f, _)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: d, getSharedSecret: h, utils: m, lengths: x } = jr(r, s), w = {
3803
3876
  prehash: !0,
3804
3877
  lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
3805
3878
  format: "compact",
3806
3879
  extraEntropy: !1
3807
- }, E = a * vs < o.ORDER;
3880
+ }, E = a * Ss < o.ORDER;
3808
3881
  function y(f) {
3809
- const _ = a >> Te;
3882
+ const _ = a >> Ae;
3810
3883
  return f > _;
3811
3884
  }
3812
3885
  function S(f, _) {
@@ -3819,35 +3892,35 @@ function Jr(r, e, s = {}) {
3819
3892
  throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
3820
3893
  }
3821
3894
  function B(f, _) {
3822
- ct(_);
3823
- const v = x.signature, A = _ === "compact" ? v : _ === "recovered" ? v + 1 : void 0;
3824
- return z(f, A);
3895
+ at(_);
3896
+ const v = x.signature, I = _ === "compact" ? v : _ === "recovered" ? v + 1 : void 0;
3897
+ return V(f, I);
3825
3898
  }
3826
3899
  class b {
3827
- constructor(_, v, A) {
3828
- I(this, "r");
3829
- I(this, "s");
3830
- I(this, "recovery");
3831
- if (this.r = S("r", _), this.s = S("s", v), A != null) {
3832
- if (O(), ![0, 1, 2, 3].includes(A))
3900
+ constructor(_, v, I) {
3901
+ T(this, "r");
3902
+ T(this, "s");
3903
+ T(this, "recovery");
3904
+ if (this.r = S("r", _), this.s = S("s", v), I != null) {
3905
+ if (O(), ![0, 1, 2, 3].includes(I))
3833
3906
  throw new Error("invalid recovery id");
3834
- this.recovery = A;
3907
+ this.recovery = I;
3835
3908
  }
3836
3909
  Object.freeze(this);
3837
3910
  }
3838
3911
  static fromBytes(_, v = w.format) {
3839
3912
  B(_, v);
3840
- let A;
3913
+ let I;
3841
3914
  if (v === "der") {
3842
- const { r: T, s: $ } = me.toSig(z(_));
3843
- return new b(T, $);
3915
+ const { r: A, s: $ } = we.toSig(V(_));
3916
+ return new b(A, $);
3844
3917
  }
3845
- v === "recovered" && (A = _[0], v = "compact", _ = _.subarray(1));
3846
- const L = x.signature / 2, C = _.subarray(0, L), M = _.subarray(L, L * 2);
3847
- return new b(i.fromBytes(C), i.fromBytes(M), A);
3918
+ v === "recovered" && (I = _[0], v = "compact", _ = _.subarray(1));
3919
+ const L = x.signature / 2, N = _.subarray(0, L), M = _.subarray(L, L * 2);
3920
+ return new b(i.fromBytes(N), i.fromBytes(M), I);
3848
3921
  }
3849
3922
  static fromHex(_, v) {
3850
- return this.fromBytes(qe(_), v);
3923
+ return this.fromBytes(Ge(_), v);
3851
3924
  }
3852
3925
  assertRecovery() {
3853
3926
  const { recovery: _ } = this;
@@ -3859,10 +3932,10 @@ function Jr(r, e, s = {}) {
3859
3932
  return new b(this.r, this.s, _);
3860
3933
  }
3861
3934
  recoverPublicKey(_) {
3862
- const { r: v, s: A } = this, L = this.assertRecovery(), C = L === 2 || L === 3 ? v + a : v;
3863
- if (!o.isValid(C))
3935
+ const { r: v, s: I } = this, L = this.assertRecovery(), N = L === 2 || L === 3 ? v + a : v;
3936
+ if (!o.isValid(N))
3864
3937
  throw new Error("invalid recovery id: sig.r+curve.n != R.x");
3865
- const M = o.toBytes(C), T = r.fromBytes(we(Ss((L & 1) === 0), M)), $ = i.inv(C), F = N(z(_, void 0, "msgHash")), J = i.create(-F * $), V = i.create(A * $), H = r.BASE.multiplyUnsafe(J).add(T.multiplyUnsafe(V));
3938
+ const M = o.toBytes(N), A = r.fromBytes(be(Es((L & 1) === 0), M)), $ = i.inv(N), F = P(V(_, void 0, "msgHash")), J = i.create(-F * $), K = i.create(I * $), H = r.BASE.multiplyUnsafe(J).add(A.multiplyUnsafe(K));
3866
3939
  if (H.is0())
3867
3940
  throw new Error("invalid recovery: point at infinify");
3868
3941
  return H.assertValidity(), H;
@@ -3872,80 +3945,80 @@ function Jr(r, e, s = {}) {
3872
3945
  return y(this.s);
3873
3946
  }
3874
3947
  toBytes(_ = w.format) {
3875
- if (ct(_), _ === "der")
3876
- return qe(me.hexFromSig(this));
3877
- const { r: v, s: A } = this, L = i.toBytes(v), C = i.toBytes(A);
3878
- return _ === "recovered" ? (O(), we(Uint8Array.of(this.assertRecovery()), L, C)) : we(L, C);
3948
+ if (at(_), _ === "der")
3949
+ return Ge(we.hexFromSig(this));
3950
+ const { r: v, s: I } = this, L = i.toBytes(v), N = i.toBytes(I);
3951
+ return _ === "recovered" ? (O(), be(Uint8Array.of(this.assertRecovery()), L, N)) : be(L, N);
3879
3952
  }
3880
3953
  toHex(_) {
3881
- return Me(this.toBytes(_));
3954
+ return De(this.toBytes(_));
3882
3955
  }
3883
3956
  }
3884
- const P = s.bits2int || function(_) {
3957
+ const k = s.bits2int || function(_) {
3885
3958
  if (_.length > 8192)
3886
3959
  throw new Error("input is too large");
3887
- const v = je(_), A = _.length * 8 - c;
3888
- return A > 0 ? v >> BigInt(A) : v;
3889
- }, N = s.bits2int_modN || function(_) {
3890
- return i.create(P(_));
3891
- }, G = ft(c);
3892
- function K(f) {
3893
- return Ar("num < 2^" + c, f, pe, G), i.toBytes(f);
3960
+ const v = Ve(_), I = _.length * 8 - c;
3961
+ return I > 0 ? v >> BigInt(I) : v;
3962
+ }, P = s.bits2int_modN || function(_) {
3963
+ return i.create(k(_));
3964
+ }, G = pt(c);
3965
+ function z(f) {
3966
+ return Tr("num < 2^" + c, f, fe, G), i.toBytes(f);
3894
3967
  }
3895
3968
  function W(f, _) {
3896
- return z(f, void 0, "message"), _ ? z(e(f), void 0, "prehashed message") : f;
3969
+ return V(f, void 0, "message"), _ ? V(e(f), void 0, "prehashed message") : f;
3897
3970
  }
3898
3971
  function q(f, _, v) {
3899
- const { lowS: A, prehash: L, extraEntropy: C } = st(v, w);
3972
+ const { lowS: I, prehash: L, extraEntropy: N } = tt(v, w);
3900
3973
  f = W(f, L);
3901
- const M = N(f), T = i.fromBytes(_);
3902
- if (!i.isValidNot0(T))
3974
+ const M = P(f), A = i.fromBytes(_);
3975
+ if (!i.isValidNot0(A))
3903
3976
  throw new Error("invalid private key");
3904
- const $ = [K(T), K(M)];
3905
- if (C != null && C !== !1) {
3906
- const H = C === !0 ? t(x.secretKey) : C;
3907
- $.push(z(H, void 0, "extraEntropy"));
3908
- }
3909
- const F = we(...$), J = M;
3910
- function V(H) {
3911
- const Z = P(H);
3977
+ const $ = [z(A), z(M)];
3978
+ if (N != null && N !== !1) {
3979
+ const H = N === !0 ? t(x.secretKey) : N;
3980
+ $.push(V(H, void 0, "extraEntropy"));
3981
+ }
3982
+ const F = be(...$), J = M;
3983
+ function K(H) {
3984
+ const Z = k(H);
3912
3985
  if (!i.isValidNot0(Z))
3913
3986
  return;
3914
3987
  const X = i.inv(Z), oe = r.BASE.multiply(Z).toAffine(), j = i.create(oe.x);
3915
- if (j === pe)
3988
+ if (j === fe)
3916
3989
  return;
3917
- const Q = i.create(X * i.create(J + j * T));
3918
- if (Q === pe)
3990
+ const Q = i.create(X * i.create(J + j * A));
3991
+ if (Q === fe)
3919
3992
  return;
3920
- let yt = (oe.x === j ? 0 : 2) | Number(oe.y & Te), bt = Q;
3921
- return A && y(Q) && (bt = i.neg(Q), yt ^= 1), new b(j, bt, E ? void 0 : yt);
3993
+ let wt = (oe.x === j ? 0 : 2) | Number(oe.y & Ae), yt = Q;
3994
+ return I && y(Q) && (yt = i.neg(Q), wt ^= 1), new b(j, yt, E ? void 0 : wt);
3922
3995
  }
3923
- return { seed: F, k2sig: V };
3996
+ return { seed: F, k2sig: K };
3924
3997
  }
3925
3998
  function D(f, _, v = {}) {
3926
- const { seed: A, k2sig: L } = q(f, _, v);
3927
- return Pr(e.outputLen, i.BYTES, n)(A, L).toBytes(v.format);
3999
+ const { seed: I, k2sig: L } = q(f, _, v);
4000
+ return Rr(e.outputLen, i.BYTES, n)(I, L).toBytes(v.format);
3928
4001
  }
3929
- function k(f, _, v, A = {}) {
3930
- const { lowS: L, prehash: C, format: M } = st(A, w);
3931
- if (v = z(v, void 0, "publicKey"), _ = W(_, C), !ut(f)) {
3932
- const T = f instanceof b ? ", use sig.toBytes()" : "";
3933
- throw new Error("verify expects Uint8Array signature" + T);
4002
+ function R(f, _, v, I = {}) {
4003
+ const { lowS: L, prehash: N, format: M } = tt(I, w);
4004
+ if (v = V(v, void 0, "publicKey"), _ = W(_, N), !dt(f)) {
4005
+ const A = f instanceof b ? ", use sig.toBytes()" : "";
4006
+ throw new Error("verify expects Uint8Array signature" + A);
3934
4007
  }
3935
4008
  B(f, M);
3936
4009
  try {
3937
- const T = b.fromBytes(f, M), $ = r.fromBytes(v);
3938
- if (L && T.hasHighS())
4010
+ const A = b.fromBytes(f, M), $ = r.fromBytes(v);
4011
+ if (L && A.hasHighS())
3939
4012
  return !1;
3940
- const { r: F, s: J } = T, V = N(_), H = i.inv(J), Z = i.create(V * H), X = i.create(F * H), oe = r.BASE.multiplyUnsafe(Z).add($.multiplyUnsafe(X));
4013
+ const { r: F, s: J } = A, K = P(_), H = i.inv(J), Z = i.create(K * H), X = i.create(F * H), oe = r.BASE.multiplyUnsafe(Z).add($.multiplyUnsafe(X));
3941
4014
  return oe.is0() ? !1 : i.create(oe.x) === F;
3942
4015
  } catch {
3943
4016
  return !1;
3944
4017
  }
3945
4018
  }
3946
- function R(f, _, v = {}) {
3947
- const { prehash: A } = st(v, w);
3948
- return _ = W(_, A), b.fromBytes(f, "recovered").recoverPublicKey(_).toBytes();
4019
+ function C(f, _, v = {}) {
4020
+ const { prehash: I } = tt(v, w);
4021
+ return _ = W(_, I), b.fromBytes(f, "recovered").recoverPublicKey(_).toBytes();
3949
4022
  }
3950
4023
  return Object.freeze({
3951
4024
  keygen: l,
@@ -3955,14 +4028,14 @@ function Jr(r, e, s = {}) {
3955
4028
  lengths: x,
3956
4029
  Point: r,
3957
4030
  sign: D,
3958
- verify: k,
3959
- recoverPublicKey: R,
4031
+ verify: R,
4032
+ recoverPublicKey: C,
3960
4033
  Signature: b,
3961
4034
  hash: e
3962
4035
  });
3963
4036
  }
3964
4037
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3965
- const gt = {
4038
+ const xt = {
3966
4039
  p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
3967
4040
  n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
3968
4041
  h: BigInt(1),
@@ -3970,44 +4043,44 @@ const gt = {
3970
4043
  b: BigInt(7),
3971
4044
  Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
3972
4045
  Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
3973
- }, Zr = {
4046
+ }, Jr = {
3974
4047
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
3975
4048
  basises: [
3976
4049
  [BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
3977
4050
  [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
3978
4051
  ]
3979
- }, Gt = /* @__PURE__ */ BigInt(2);
3980
- function Xr(r) {
3981
- const e = gt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, h = ae(d, s, e) * d % e, m = ae(h, s, e) * d % e, x = ae(m, Gt, e) * l % e, w = ae(x, n, e) * x % e, E = ae(w, o, e) * w % e, y = ae(E, a, e) * E % e, S = ae(y, c, e) * y % e, O = ae(S, a, e) * E % e, B = ae(O, s, e) * d % e, b = ae(B, i, e) * w % e, P = ae(b, t, e) * l % e, N = ae(P, Gt, e);
3982
- if (!lt.eql(lt.sqr(N), r))
4052
+ }, Wt = /* @__PURE__ */ BigInt(2);
4053
+ function Zr(r) {
4054
+ const e = xt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, h = ae(d, s, e) * d % e, m = ae(h, s, e) * d % e, x = ae(m, Wt, e) * l % e, w = ae(x, n, e) * x % e, E = ae(w, o, e) * w % e, y = ae(E, a, e) * E % e, S = ae(y, c, e) * y % e, O = ae(S, a, e) * E % e, B = ae(O, s, e) * d % e, b = ae(B, i, e) * w % e, k = ae(b, t, e) * l % e, P = ae(k, Wt, e);
4055
+ if (!ct.eql(ct.sqr(P), r))
3983
4056
  throw new Error("Cannot find square root");
3984
- return N;
4057
+ return P;
3985
4058
  }
3986
- const lt = Ye(gt.p, { sqrt: Xr }), Qr = /* @__PURE__ */ jr(gt, {
3987
- Fp: lt,
3988
- endo: Zr
3989
- }), en = /* @__PURE__ */ Jr(Qr, Ir), tn = BigInt(0), Ce = BigInt(1), sn = BigInt(2), rn = BigInt(7), nn = BigInt(256), on = BigInt(113), Es = [], Ts = [], As = [];
4059
+ const ct = ze(xt.p, { sqrt: Zr }), Xr = /* @__PURE__ */ zr(xt, {
4060
+ Fp: ct,
4061
+ endo: Jr
4062
+ }), Qr = /* @__PURE__ */ Yr(Xr, Sr), en = BigInt(0), Ce = BigInt(1), tn = BigInt(2), sn = BigInt(7), rn = BigInt(256), nn = BigInt(113), Ts = [], As = [], Rs = [];
3990
4063
  for (let r = 0, e = Ce, s = 1, t = 0; r < 24; r++) {
3991
- [s, t] = [t, (2 * s + 3 * t) % 5], Es.push(2 * (5 * t + s)), Ts.push((r + 1) * (r + 2) / 2 % 64);
3992
- let n = tn;
4064
+ [s, t] = [t, (2 * s + 3 * t) % 5], Ts.push(2 * (5 * t + s)), As.push((r + 1) * (r + 2) / 2 % 64);
4065
+ let n = en;
3993
4066
  for (let o = 0; o < 7; o++)
3994
- e = (e << Ce ^ (e >> rn) * on) % nn, e & sn && (n ^= Ce << (Ce << BigInt(o)) - Ce);
3995
- As.push(n);
4067
+ e = (e << Ce ^ (e >> sn) * nn) % rn, e & tn && (n ^= Ce << (Ce << BigInt(o)) - Ce);
4068
+ Rs.push(n);
3996
4069
  }
3997
- const ks = xr(As, !0), an = ks[0], cn = ks[1], Wt = (r, e, s) => s > 32 ? wr(r, e, s) : gr(r, e, s), qt = (r, e, s) => s > 32 ? yr(r, e, s) : mr(r, e, s);
3998
- function ln(r, e = 24) {
4070
+ const ks = _r(Rs, !0), on = ks[0], an = ks[1], qt = (r, e, s) => s > 32 ? mr(r, e, s) : xr(r, e, s), Kt = (r, e, s) => s > 32 ? wr(r, e, s) : gr(r, e, s);
4071
+ function cn(r, e = 24) {
3999
4072
  const s = new Uint32Array(10);
4000
4073
  for (let t = 24 - e; t < 24; t++) {
4001
4074
  for (let i = 0; i < 10; i++)
4002
4075
  s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
4003
4076
  for (let i = 0; i < 10; i += 2) {
4004
- const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], h = Wt(l, d, 1) ^ s[a], m = qt(l, d, 1) ^ s[a + 1];
4077
+ const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], h = qt(l, d, 1) ^ s[a], m = Kt(l, d, 1) ^ s[a + 1];
4005
4078
  for (let x = 0; x < 50; x += 10)
4006
4079
  r[i + x] ^= h, r[i + x + 1] ^= m;
4007
4080
  }
4008
4081
  let n = r[2], o = r[3];
4009
4082
  for (let i = 0; i < 24; i++) {
4010
- const a = Ts[i], c = Wt(n, o, a), l = qt(n, o, a), d = Es[i];
4083
+ const a = As[i], c = qt(n, o, a), l = Kt(n, o, a), d = Ts[i];
4011
4084
  n = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
4012
4085
  }
4013
4086
  for (let i = 0; i < 50; i += 10) {
@@ -4016,36 +4089,36 @@ function ln(r, e = 24) {
4016
4089
  for (let a = 0; a < 10; a++)
4017
4090
  r[i + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
4018
4091
  }
4019
- r[0] ^= an[t], r[1] ^= cn[t];
4092
+ r[0] ^= on[t], r[1] ^= an[t];
4020
4093
  }
4021
4094
  ke(s);
4022
4095
  }
4023
- class mt {
4096
+ class gt {
4024
4097
  // NOTE: we accept arguments in bytes instead of bits here.
4025
4098
  constructor(e, s, t, n = !1, o = 24) {
4026
- I(this, "state");
4027
- I(this, "pos", 0);
4028
- I(this, "posOut", 0);
4029
- I(this, "finished", !1);
4030
- I(this, "state32");
4031
- I(this, "destroyed", !1);
4032
- I(this, "blockLen");
4033
- I(this, "suffix");
4034
- I(this, "outputLen");
4035
- I(this, "enableXOF", !1);
4036
- I(this, "rounds");
4037
- if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, _e(t, "outputLen"), !(0 < e && e < 200))
4099
+ T(this, "state");
4100
+ T(this, "pos", 0);
4101
+ T(this, "posOut", 0);
4102
+ T(this, "finished", !1);
4103
+ T(this, "state32");
4104
+ T(this, "destroyed", !1);
4105
+ T(this, "blockLen");
4106
+ T(this, "suffix");
4107
+ T(this, "outputLen");
4108
+ T(this, "enableXOF", !1);
4109
+ T(this, "rounds");
4110
+ if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, xe(t, "outputLen"), !(0 < e && e < 200))
4038
4111
  throw new Error("only keccak-f1600 function is supported");
4039
- this.state = new Uint8Array(200), this.state32 = ir(this.state);
4112
+ this.state = new Uint8Array(200), this.state32 = or(this.state);
4040
4113
  }
4041
4114
  clone() {
4042
4115
  return this._cloneInto();
4043
4116
  }
4044
4117
  keccak() {
4045
- Rt(this.state32), ln(this.state32, this.rounds), Rt(this.state32), this.posOut = 0, this.pos = 0;
4118
+ Nt(this.state32), cn(this.state32, this.rounds), Nt(this.state32), this.posOut = 0, this.pos = 0;
4046
4119
  }
4047
4120
  update(e) {
4048
- Ae(this), z(e);
4121
+ Re(this), V(e);
4049
4122
  const { blockLen: s, state: t } = this, n = e.length;
4050
4123
  for (let o = 0; o < n; ) {
4051
4124
  const i = Math.min(s - this.pos, n - o);
@@ -4063,7 +4136,7 @@ class mt {
4063
4136
  e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
4064
4137
  }
4065
4138
  writeInto(e) {
4066
- Ae(this, !1), z(e), this.finish();
4139
+ Re(this, !1), V(e), this.finish();
4067
4140
  const s = this.state, { blockLen: t } = this;
4068
4141
  for (let n = 0, o = e.length; n < o; ) {
4069
4142
  this.posOut >= t && this.keccak();
@@ -4078,10 +4151,10 @@ class mt {
4078
4151
  return this.writeInto(e);
4079
4152
  }
4080
4153
  xof(e) {
4081
- return _e(e), this.xofInto(new Uint8Array(e));
4154
+ return xe(e), this.xofInto(new Uint8Array(e));
4082
4155
  }
4083
4156
  digestInto(e) {
4084
- if (es(e, this), this.finished)
4157
+ if (ts(e, this), this.finished)
4085
4158
  throw new Error("digest() was already called");
4086
4159
  return this.writeInto(e), this.destroy(), e;
4087
4160
  }
@@ -4093,32 +4166,60 @@ class mt {
4093
4166
  }
4094
4167
  _cloneInto(e) {
4095
4168
  const { blockLen: s, suffix: t, outputLen: n, rounds: o, enableXOF: i } = this;
4096
- return e || (e = new mt(s, t, n, i, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = t, e.outputLen = n, e.enableXOF = i, e.destroyed = this.destroyed, e;
4169
+ return e || (e = new gt(s, t, n, i, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = t, e.outputLen = n, e.enableXOF = i, e.destroyed = this.destroyed, e;
4097
4170
  }
4098
4171
  }
4099
- const dn = (r, e, s, t = {}) => ss(() => new mt(e, r, s), t), Vt = /* @__PURE__ */ dn(1, 136, 32);
4172
+ const ln = (r, e, s, t = {}) => rs(() => new gt(e, r, s), t), Vt = /* @__PURE__ */ ln(1, 136, 32), dn = 60;
4100
4173
  class un {
4174
+ constructor() {
4175
+ this.jwks = null;
4176
+ }
4177
+ setJWKSEndpoint(e) {
4178
+ try {
4179
+ this.jwks = Ds(new URL(e)), u.log("[CROSSx] JWKS 엔드포인트 설정:", e);
4180
+ } catch (s) {
4181
+ u.warn("[CROSSx] JWKS 엔드포인트 URL 파싱 실패:", s);
4182
+ }
4183
+ }
4101
4184
  async verifyJWT(e, s) {
4102
4185
  try {
4103
4186
  const t = this.decodeJWT(e);
4104
4187
  u.log("[CROSSx] JWT 디코딩 성공:", {
4105
4188
  sub: t.sub,
4106
4189
  exp: t.exp,
4107
- iat: t.iat,
4108
- "현재 시간": Math.floor(Date.now() / 1e3)
4190
+ iat: t.iat
4109
4191
  });
4110
4192
  const n = Math.floor(Date.now() / 1e3);
4111
- return t.exp && t.exp < n ? (u.warn("[CROSSx] 토큰 만료:", {
4112
- exp: t.exp,
4113
- now: n,
4114
- 만료시간: new Date(t.exp * 1e3).toISOString()
4115
- }), { payload: t, valid: !1, signatureVerified: !1 }) : t.sub ? (u.log("[CROSSx] JWT 검증 성공 (서명 미검증 — JWKS 미구현)"), { payload: t, valid: !0, signatureVerified: !1 }) : (u.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 });
4193
+ if (t.exp && t.exp + dn < n)
4194
+ return u.warn("[CROSSx] 토큰 만료:", {
4195
+ exp: t.exp,
4196
+ now: n,
4197
+ 만료시간: new Date(t.exp * 1e3).toISOString()
4198
+ }), { payload: t, valid: !1, signatureVerified: !1 };
4199
+ if (!t.sub)
4200
+ return u.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 };
4201
+ if (this.jwks)
4202
+ try {
4203
+ const { payload: o } = await Ms(e, this.jwks, {
4204
+ algorithms: ["RS256", "ES256"]
4205
+ });
4206
+ return u.log("[CROSSx] JWT 서명 검증 성공"), {
4207
+ payload: o,
4208
+ valid: !0,
4209
+ signatureVerified: !0
4210
+ };
4211
+ } catch (o) {
4212
+ if (o instanceof Error && (o.name === "JWSSignatureVerificationFailed" || o.name === "JWTClaimValidationFailed"))
4213
+ return u.error("[CROSSx] JWT 서명 검증 실패:", o), { payload: t, valid: !1, signatureVerified: !1 };
4214
+ u.warn("[CROSSx] JWKS 엔드포인트 접근 불가 — 서명 미검증 모드로 전환");
4215
+ }
4216
+ return u.log("[CROSSx] JWT 검증 성공 (서명 미검증 — JWKS 미설정 또는 접근 불가)"), { payload: t, valid: !0, signatureVerified: !1 };
4116
4217
  } catch (t) {
4117
4218
  throw u.error("[CROSSx] JWT 검증 중 에러:", t), t;
4118
4219
  }
4119
4220
  }
4120
4221
  decodeJWT(e) {
4121
- return Ls(e);
4222
+ return $s(e);
4122
4223
  }
4123
4224
  /**
4124
4225
  * EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
@@ -4136,11 +4237,11 @@ ${t.length}`
4136
4237
  const i = Vt(o), a = s.startsWith("0x") ? s.slice(2) : s;
4137
4238
  if (a.length !== 130)
4138
4239
  throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
4139
- const c = hn(a), l = c.slice(0, 32), d = c.slice(32, 64), h = c[64], m = h >= 27 ? h - 27 : h, E = new en.Signature(
4240
+ const c = hn(a), l = c.slice(0, 32), d = c.slice(32, 64), h = c[64], m = h >= 27 ? h - 27 : h, E = new Qr.Signature(
4140
4241
  zt(l),
4141
4242
  zt(d)
4142
4243
  ).addRecoveryBit(m).recoverPublicKey(i).toBytes(!1).slice(1), y = Vt(E);
4143
- return "0x" + Me(y.slice(12));
4244
+ return "0x" + De(y.slice(12));
4144
4245
  }
4145
4246
  }
4146
4247
  function hn(r) {
@@ -4154,10 +4255,24 @@ function zt(r) {
4154
4255
  for (const s of r) e += s.toString(16).padStart(2, "0");
4155
4256
  return BigInt(e);
4156
4257
  }
4157
- const pn = 3e4;
4158
- class fn {
4258
+ const pn = 3e4, fn = 1e3;
4259
+ class _n {
4159
4260
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4160
4261
  async request(e) {
4262
+ const s = e.retries ?? 0;
4263
+ for (let t = 0; t <= s; t++) {
4264
+ try {
4265
+ const n = await this._doRequest(e);
4266
+ if (n.status < 500 || t === s) return n;
4267
+ } catch (n) {
4268
+ if (t === s) throw n;
4269
+ }
4270
+ await new Promise((n) => setTimeout(n, fn * 2 ** t));
4271
+ }
4272
+ throw new Error("Unexpected: retry loop exited without result");
4273
+ }
4274
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4275
+ async _doRequest(e) {
4161
4276
  const s = new AbortController(), t = setTimeout(
4162
4277
  () => s.abort(),
4163
4278
  e.timeoutMs ?? pn
@@ -4187,7 +4302,12 @@ class fn {
4187
4302
  }
4188
4303
  }
4189
4304
  }
4190
- class be {
4305
+ const xn = /* @__PURE__ */ new Set([
4306
+ "https://cross-wallet-oauth.crosstoken.io",
4307
+ "https://stg-cross-wallet-oauth.crosstoken.io",
4308
+ "https://dev-cross-wallet-oauth.crosstoken.io"
4309
+ ]);
4310
+ class ye {
4191
4311
  static generateRandom16Hex() {
4192
4312
  const e = new Uint8Array(16);
4193
4313
  return crypto.getRandomValues(e), Array.from(e, (s) => s.toString(16).padStart(2, "0")).join("");
@@ -4211,7 +4331,7 @@ class be {
4211
4331
  * - Google 및 기타: originalNonce === jwt.nonce
4212
4332
  */
4213
4333
  static async verifyIdTokenNonce(e, s) {
4214
- const t = be.parseJwtPayload(e), n = t.nonce, o = typeof t.iss == "string" ? t.iss : "(unknown)";
4334
+ const t = ye.parseJwtPayload(e), n = t.nonce, o = typeof t.iss == "string" ? t.iss : "(unknown)";
4215
4335
  if (u.log("[CROSSx] nonce 검증 시작 —", {
4216
4336
  iss: o,
4217
4337
  nonceClaimType: typeof n,
@@ -4233,7 +4353,7 @@ class be {
4233
4353
  "ID Token에 nonce claim이 없습니다 — OAuth 서버 설정을 확인해 주세요"
4234
4354
  );
4235
4355
  if (o.includes("appleid.apple.com")) {
4236
- const i = await be.sha256Hex(s);
4356
+ const i = await ye.sha256Hex(s);
4237
4357
  if (u.log("[CROSSx] Apple nonce 검증 —", {
4238
4358
  expectedHashLength: i.length,
4239
4359
  receivedHashLength: n.length,
@@ -4250,7 +4370,7 @@ class be {
4250
4370
  }
4251
4371
  openAuth(e) {
4252
4372
  return new Promise((s, t) => {
4253
- const n = Math.max(e.width ?? 500, 500), o = Math.max(e.height ?? 700, 700), i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = be.generateRandom16Hex(), l = be.generateRandom16Hex(), d = e.authUrl.includes("?") ? "&" : "?", h = `${e.authUrl}${d}state=${c}&nonce=${l}`;
4373
+ const n = Math.max(e.width ?? 500, 500), o = Math.max(e.height ?? 700, 700), i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = ye.generateRandom16Hex(), l = ye.generateRandom16Hex(), d = e.authUrl.includes("?") ? "&" : "?", h = `${e.authUrl}${d}state=${c}&nonce=${l}`;
4254
4374
  u.log("[CROSSx] OAuth 팝업 열기 — state, nonce 생성 완료:", {
4255
4375
  stateLength: c.length,
4256
4376
  nonceLength: l.length,
@@ -4283,37 +4403,46 @@ class be {
4283
4403
  O();
4284
4404
  }
4285
4405
  }, 1e3), b = () => {
4286
- clearTimeout(x), clearInterval(B), S && clearTimeout(S), window.removeEventListener("message", P);
4287
- }, P = (N) => {
4288
- var K, W, q, D, k;
4289
- if (N.origin !== e.expectedOrigin) return;
4290
- b(), u.log("[CROSSx] OAuth postMessage 수신 — status:", N.data.status);
4291
- const G = N.data.state ?? ((K = N.data.data) == null ? void 0 : K.state);
4406
+ clearTimeout(x), clearInterval(B), S && clearTimeout(S), window.removeEventListener("message", k);
4407
+ }, k = (P) => {
4408
+ var z, W, q, D, R;
4409
+ if (P.origin !== e.expectedOrigin) return;
4410
+ if (!xn.has(P.origin)) {
4411
+ u.error("[CROSSx] postMessage origin이 허용 목록에 없음:", P.origin), b(), t(new Error("Unauthorized OAuth origin"));
4412
+ return;
4413
+ }
4414
+ b(), u.log("[CROSSx] OAuth postMessage 수신 — status:", P.data.status);
4415
+ const G = P.data.state ?? ((z = P.data.data) == null ? void 0 : z.state);
4292
4416
  if (!G || G !== c) {
4293
4417
  t(new Error("OAuth state mismatch — possible CSRF attack"));
4294
4418
  return;
4295
4419
  }
4296
- if (N.data.status === "success") {
4297
- const R = (W = N.data.data) == null ? void 0 : W.idToken, f = (q = N.data.data) == null ? void 0 : q.accessToken, _ = f ?? R;
4420
+ if (P.data.status === "success") {
4421
+ const C = (W = P.data.data) == null ? void 0 : W.idToken, f = (q = P.data.data) == null ? void 0 : q.accessToken, _ = f ?? C;
4298
4422
  if (u.log("[CROSSx] OAuth 토큰 수신:", {
4299
4423
  hasAccessToken: !!f,
4300
- hasIdToken: !!R
4424
+ hasIdToken: !!C
4301
4425
  }), !_) {
4302
- u.error("[CROSSx] 토큰을 찾을 수 없음:", N.data), t(new Error("Token not found in response"));
4426
+ u.error("[CROSSx] 토큰을 찾을 수 없음:", P.data), t(new Error("Token not found in response"));
4303
4427
  return;
4304
4428
  }
4305
- R ? be.verifyIdTokenNonce(R, l).then(() => s(_)).catch((v) => {
4429
+ C ? ye.verifyIdTokenNonce(C, l).then(() => s(_)).catch((v) => {
4306
4430
  u.error("[CROSSx] nonce 검증 실패:", v), t(v instanceof Error ? v : new Error("nonce verification failed"));
4307
- }) : s(_);
4431
+ }) : f ? f.split(".").length === 3 ? ye.verifyIdTokenNonce(f, l).then(() => s(_)).catch((I) => {
4432
+ u.error("[CROSSx] accessToken nonce 검증 실패:", I), t(I instanceof Error ? I : new Error("nonce verification failed"));
4433
+ }) : (u.warn(
4434
+ "[CROSSx] opaque accessToken만 수신 (idToken 없음) — nonce 검증 불가.",
4435
+ "서버 측 nonce 검증이 필요합니다."
4436
+ ), s(_)) : t(new Error("Token not found in response"));
4308
4437
  } else
4309
- u.error("[CROSSx] OAuth 실패:", (D = N.data.data) == null ? void 0 : D.error), t(new Error(((k = N.data.data) == null ? void 0 : k.error) || "Authentication failed"));
4438
+ u.error("[CROSSx] OAuth 실패:", (D = P.data.data) == null ? void 0 : D.error), t(new Error(((R = P.data.data) == null ? void 0 : R.error) || "Authentication failed"));
4310
4439
  };
4311
- window.addEventListener("message", P);
4440
+ window.addEventListener("message", k);
4312
4441
  });
4313
4442
  }
4314
4443
  }
4315
- const Oe = "crossx_wallet_data", Ee = "crossx_mock_pin_hash";
4316
- class _n {
4444
+ const Ne = "crossx_wallet_data", Te = "crossx_mock_pin_hash";
4445
+ class gn {
4317
4446
  constructor(e, s) {
4318
4447
  this.storage = e, this.pinStore = s ?? null;
4319
4448
  }
@@ -4326,13 +4455,13 @@ class _n {
4326
4455
  async checkWallet() {
4327
4456
  if (this.migrateScenario !== void 0)
4328
4457
  return u.log("[Mock] checkWallet → migration_required"), "migration_required";
4329
- const s = await this.storage.get(Oe) ? "exists" : "not_found";
4458
+ const s = await this.storage.get(Ne) ? "exists" : "not_found";
4330
4459
  return u.log(`[Mock] checkWallet → ${s}`), s;
4331
4460
  }
4332
4461
  async getOrCreateWallet(e) {
4333
4462
  var s;
4334
4463
  try {
4335
- const t = await this.storage.get(Oe);
4464
+ const t = await this.storage.get(Ne);
4336
4465
  if (t) return t;
4337
4466
  const n = {
4338
4467
  id: e,
@@ -4340,16 +4469,16 @@ class _n {
4340
4469
  derivationPath: "m/44'/60'/0'/0/0",
4341
4470
  createdAt: Date.now()
4342
4471
  };
4343
- await this.storage.set(Oe, n);
4472
+ await this.storage.set(Ne, n);
4344
4473
  const o = (s = this.pinStore) == null ? void 0 : s.get();
4345
- return o && (await this.storage.set(Ee, o), u.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
4474
+ return o && (await this.storage.set(Te, o), u.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
4346
4475
  } catch (t) {
4347
4476
  throw new g(p.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", t);
4348
4477
  }
4349
4478
  }
4350
4479
  /** GET /mnemonic/addresses 모킹 — PIN 불필요, 캐시된 주소 반환 */
4351
4480
  async getAddresses(e) {
4352
- const s = await this.storage.get(Oe);
4481
+ const s = await this.storage.get(Ne);
4353
4482
  return s ? [{ address: s.address, index: 0 }] : [];
4354
4483
  }
4355
4484
  async getAddress(e, s) {
@@ -4384,8 +4513,8 @@ class _n {
4384
4513
  var t;
4385
4514
  if (u.log("[Mock] verifyPin"), this.pinScenario === "wrong")
4386
4515
  return !1;
4387
- const s = await this.storage.get(Ee);
4388
- return s && s !== e ? !1 : (s || await this.storage.set(Ee, e), (t = this.pinStore) == null || t.set(e), u.log("[Mock] verifyPin → 성공"), !0);
4516
+ const s = await this.storage.get(Te);
4517
+ return s && s !== e ? !1 : (s || await this.storage.set(Te, e), (t = this.pinStore) == null || t.set(e), u.log("[Mock] verifyPin → 성공"), !0);
4389
4518
  }
4390
4519
  /**
4391
4520
  * POST /mnemonic/change-password 모킹
@@ -4395,10 +4524,10 @@ class _n {
4395
4524
  var o;
4396
4525
  if (u.log("[Mock] changePin"), this.pinScenario === "wrong")
4397
4526
  throw new g(p.PIN_WRONG, "Incorrect PIN.");
4398
- const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Ee);
4527
+ const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Te);
4399
4528
  if (n && t && n !== t)
4400
4529
  throw new g(p.PIN_WRONG, "Incorrect PIN.");
4401
- await this.storage.set(Ee, s), u.log("[Mock] changePin 완료");
4530
+ await this.storage.set(Te, s), u.log("[Mock] changePin 완료");
4402
4531
  }
4403
4532
  async migrateWallet(e, s) {
4404
4533
  var o;
@@ -4429,9 +4558,9 @@ class _n {
4429
4558
  derivationPath: "m/44'/60'/0'/0/0",
4430
4559
  createdAt: Date.now()
4431
4560
  };
4432
- await this.storage.set(Oe, t);
4561
+ await this.storage.set(Ne, t);
4433
4562
  const n = (o = this.pinStore) == null ? void 0 : o.get();
4434
- return n && (await this.storage.set(Ee, n), u.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
4563
+ return n && (await this.storage.set(Te, n), u.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
4435
4564
  }
4436
4565
  /**
4437
4566
  * POST /mnemonic/share-c 모킹
@@ -4458,7 +4587,7 @@ class _n {
4458
4587
  ).join("");
4459
4588
  }
4460
4589
  }
4461
- class Le {
4590
+ class Oe {
4462
4591
  constructor(e, s, t, n, o) {
4463
4592
  this._walletStatusCache = null, this.adapterConfig = e, this.projectId = e.projectId, this.storage = s, this.transport = t, this.tokenStore = n, this.pinStore = o ?? null;
4464
4593
  }
@@ -4504,8 +4633,8 @@ class Le {
4504
4633
  url: o,
4505
4634
  method: e
4506
4635
  });
4507
- const m = Le.mapGatewayError(d.code, d.data), x = Le.getGatewayErrorMessage(d.code, h), w = d.data, E = m === p.PIN_LOCKED ? Le.extractLockDetails(w) : w ?? void 0, y = new g(m, x, E);
4508
- throw y.gatewayCode = d.code, y.gatewayMessage = h, m === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (u.warn("[CROSSx] Gateway -10002 감지 — 강제 로그아웃 실행"), this._onUnauthorized()), y;
4636
+ const m = Oe.mapGatewayError(d.code, d.data), x = Oe.getGatewayErrorMessage(d.code, h), w = d.data, E = m === p.PIN_LOCKED ? Oe.extractLockDetails(w) : w ?? void 0, y = new g(m, x, E);
4637
+ throw m === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (u.warn("[CROSSx] Gateway -10002 감지 — 강제 로그아웃 실행"), this._onUnauthorized()), y;
4509
4638
  }
4510
4639
  return u.log("[CROSSx] Wallet Gateway API 성공:", { code: d.code, url: o, method: e }), d.data ?? d;
4511
4640
  }
@@ -4808,7 +4937,7 @@ class Le {
4808
4937
  }
4809
4938
  }
4810
4939
  }
4811
- class De {
4940
+ class Le {
4812
4941
  constructor(e, s) {
4813
4942
  this.cache = /* @__PURE__ */ new Map(), this.loadedAt = 0, this.usingFallback = !1, this.adapterConfig = e, this.projectId = e.projectId, this.transport = s;
4814
4943
  }
@@ -4826,7 +4955,7 @@ class De {
4826
4955
  const s = e.data.chains;
4827
4956
  return this.populateCache(s, !1), s;
4828
4957
  } catch {
4829
- const e = De.fallbackChains();
4958
+ const e = Le.fallbackChains();
4830
4959
  return this.populateCache(e, !0), e;
4831
4960
  }
4832
4961
  }
@@ -4862,13 +4991,13 @@ class De {
4862
4991
  if (e.code < 0) {
4863
4992
  const s = typeof e.data == "string" ? e.data : e.message ?? "체인 레지스트리 요청에 실패했습니다";
4864
4993
  throw new g(
4865
- De.mapErrorCode(e.code),
4994
+ Le.mapErrorCode(e.code),
4866
4995
  s
4867
4996
  );
4868
4997
  }
4869
4998
  }
4870
4999
  fallbackOrThrow(e) {
4871
- const s = De.fallbackChains().find(
5000
+ const s = Le.fallbackChains().find(
4872
5001
  (t) => t.chainId === e
4873
5002
  );
4874
5003
  if (s) return s;
@@ -4902,7 +5031,7 @@ class De {
4902
5031
  }
4903
5032
  }
4904
5033
  }
4905
- const Kt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", xn = {
5034
+ const jt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", mn = {
4906
5035
  light: {
4907
5036
  bg: "#FFFFFF",
4908
5037
  border: "rgba(18,18,18,0.05)",
@@ -4958,8 +5087,8 @@ const Kt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", xn = {
4958
5087
  onPrimary: "#FFFFFF"
4959
5088
  }
4960
5089
  };
4961
- function jt(r, e) {
4962
- const s = xn[r], t = e == null ? void 0 : e[r];
5090
+ function Yt(r, e) {
5091
+ const s = mn[r], t = e == null ? void 0 : e[r];
4963
5092
  return t ? {
4964
5093
  ...s,
4965
5094
  // ── Brand
@@ -4991,7 +5120,7 @@ function jt(r, e) {
4991
5120
  ...t.error !== void 0 && { errorColor: t.error }
4992
5121
  } : s;
4993
5122
  }
4994
- const gn = `
5123
+ const wn = `
4995
5124
  @import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
4996
5125
 
4997
5126
  #${te} {
@@ -6643,25 +6772,25 @@ const gn = `
6643
6772
  cursor: default;
6644
6773
  }
6645
6774
  `;
6646
- function ue() {
6647
- let r = document.getElementById(Kt);
6648
- r || (r = document.createElement("style"), r.id = Kt, document.head.appendChild(r)), r.textContent = gn;
6775
+ function he() {
6776
+ let r = document.getElementById(jt);
6777
+ r || (r = document.createElement("style"), r.id = jt, document.head.appendChild(r)), r.textContent = wn;
6649
6778
  }
6650
6779
  function se(r) {
6651
6780
  return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
6652
6781
  }
6653
- function mn(r, e = "CROSS", s = 18) {
6782
+ function yn(r, e = "CROSS", s = 18) {
6654
6783
  if (!r || r === "0x" || r === "0x0") return null;
6655
6784
  try {
6656
6785
  const t = BigInt(r);
6657
6786
  if (t === 0n) return null;
6658
- const n = dt(t, s);
6787
+ const n = lt(t, s);
6659
6788
  return n === "0" ? null : `${n} ${e}`;
6660
6789
  } catch {
6661
6790
  return null;
6662
6791
  }
6663
6792
  }
6664
- const Yt = {
6793
+ const Jt = {
6665
6794
  1: "Ethereum Mainnet",
6666
6795
  5: "Goerli Testnet",
6667
6796
  11155111: "Ethereum Sepolia",
@@ -6686,14 +6815,14 @@ const Yt = {
6686
6815
  };
6687
6816
  function Ps(r) {
6688
6817
  const e = parseInt(r.split(":")[1] ?? "", 10);
6689
- return !isNaN(e) && Yt[e] ? Yt[e] : r;
6818
+ return !isNaN(e) && Jt[e] ? Jt[e] : r;
6690
6819
  }
6691
- function dt(r, e) {
6820
+ function lt(r, e) {
6692
6821
  if (r === 0n) return "0";
6693
6822
  const s = 10n ** BigInt(e), t = r / s, i = (r % s).toString().padStart(e, "0").slice(0, 6).replace(/0+$/, "");
6694
6823
  return i ? `${t}.${i}` : `${t}`;
6695
6824
  }
6696
- function rt(r) {
6825
+ function st(r) {
6697
6826
  try {
6698
6827
  const e = BigInt(r), s = e / 1000000000n, n = (e % 1000000000n).toString().padStart(9, "0").slice(0, 2).replace(/0+$/, "");
6699
6828
  return n ? `${s}.${n}` : `${s}`;
@@ -6701,25 +6830,25 @@ function rt(r) {
6701
6830
  return r;
6702
6831
  }
6703
6832
  }
6704
- function wn(r) {
6833
+ function bn(r) {
6705
6834
  try {
6706
6835
  return BigInt(r).toLocaleString();
6707
6836
  } catch {
6708
6837
  return r;
6709
6838
  }
6710
6839
  }
6711
- function yn(r) {
6840
+ function vn(r) {
6712
6841
  const { gasLimit: e, gasPrice: s, maxFeePerGas: t, maxPriorityFeePerGas: n, nativeSymbol: o = "ETH", nativeDecimals: i = 18 } = r;
6713
6842
  if (!e) return null;
6714
6843
  try {
6715
- const a = BigInt(e), c = wn(e);
6844
+ const a = BigInt(e), c = bn(e);
6716
6845
  if (t) {
6717
6846
  const l = a * BigInt(t);
6718
6847
  return {
6719
6848
  isDynamic: !0,
6720
- estTxFee: `${dt(l, i)} ${o}`,
6721
- maxFeeGwei: rt(t),
6722
- maxPriorityFeeGwei: n ? rt(n) : void 0,
6849
+ estTxFee: `${lt(l, i)} ${o}`,
6850
+ maxFeeGwei: st(t),
6851
+ maxPriorityFeeGwei: n ? st(n) : void 0,
6723
6852
  gasLimitFormatted: c
6724
6853
  };
6725
6854
  }
@@ -6727,8 +6856,8 @@ function yn(r) {
6727
6856
  const l = a * BigInt(s);
6728
6857
  return {
6729
6858
  isDynamic: !1,
6730
- estTxFee: `${dt(l, i)} ${o}`,
6731
- gasPriceGwei: rt(s),
6859
+ estTxFee: `${lt(l, i)} ${o}`,
6860
+ gasPriceGwei: st(s),
6732
6861
  gasLimitFormatted: c
6733
6862
  };
6734
6863
  }
@@ -6737,28 +6866,28 @@ function yn(r) {
6737
6866
  return null;
6738
6867
  }
6739
6868
  }
6740
- function Ns(r) {
6741
- const e = yn(r);
6869
+ function Cs(r) {
6870
+ const e = vn(r);
6742
6871
  if (!e) return Y("Estimated fee", "<span>—</span>");
6743
6872
  let s = Y("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
6744
6873
  return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s += Y("Max Priority Fee", `<span>${e.maxPriorityFeeGwei} Gwei</span>`)), e.maxFeeGwei !== void 0 && (s += Y("Max Gas Fee", `<span>${e.maxFeeGwei} Gwei</span>`))) : e.gasPriceGwei !== void 0 && (s += Y("Gas Price", `<span>${e.gasPriceGwei} Gwei</span>`)), e.gasLimitFormatted && (s += Y("Gas Limit", `<span>${e.gasLimitFormatted}</span>`)), s;
6745
6874
  }
6746
- const fe = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
6875
+ const _e = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
6747
6876
  <rect x="9" y="9" width="13" height="13" rx="2"/>
6748
6877
  <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
6749
6878
  </svg>`, ie = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
6750
6879
  <line x1="18" y1="6" x2="6" y2="18"/>
6751
6880
  <line x1="6" y1="6" x2="18" y2="18"/>
6752
- </svg>`, bn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
6881
+ </svg>`, Sn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
6753
6882
  <circle cx="20" cy="20" r="20" fill="#00D5AA"/>
6754
6883
  <path fill-rule="evenodd" clip-rule="evenodd" d="M20.3225 2.85742L23.7249 6.25982V11.8301L28.1175 7.43757L32.9292 12.2493L28.5806 16.5979H20.3225C18.4435 16.5979 16.9201 18.1212 16.9201 20.0003C16.9201 21.8794 18.4434 23.4027 20.3225 23.4027H28.5372L32.9293 27.7948L28.1176 32.6066L23.7249 28.2139V33.7407L20.3225 37.1431L16.9201 33.7407V28.2584L12.5719 32.6066L7.76022 27.7948L12.1524 23.4027H6.58209L3.17969 20.0003L6.58209 16.5979H12.1089L7.76035 12.2493L12.5721 7.43757L16.9201 11.7857V6.25982L20.3225 2.85742Z" fill="#121212"/>
6755
- </svg>`, wt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
6884
+ </svg>`, mt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
6756
6885
  <rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
6757
6886
  <path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
6758
6887
  <rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
6759
- </svg>`, vn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
6888
+ </svg>`, En = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
6760
6889
  <path d="M12 0C18.6274 0 24 5.37258 24 12C23.9999 18.6273 18.6274 24 12 24C5.37264 24 9.89594e-05 18.6273 0 12C0 5.37258 5.37258 0 12 0ZM10.875 15.127V17.377H13.125V15.127H10.875ZM10.875 6.62207V13.627H13.125V6.62207H10.875Z" fill="var(--cx-error)"/>
6761
- </svg>`, Sn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
6890
+ </svg>`, In = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
6762
6891
  <circle cx="12" cy="12" r="12" fill="var(--cx-error)"/>
6763
6892
  <circle cx="12" cy="12" r="5.5" stroke="white" stroke-width="1.5"/>
6764
6893
  <path d="M12 9.5v3l2 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
@@ -6796,9 +6925,9 @@ function Y(r, e) {
6796
6925
  <div class="__crossx-row-value">${e}</div>
6797
6926
  </div>`;
6798
6927
  }
6799
- function In(r, e) {
6800
- const s = e, t = Je(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
6801
- <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${fe}</button>` : "<span>—</span>", o = Ns(r), i = r.data ?? "0x", a = document.createElement("div");
6928
+ function Tn(r, e) {
6929
+ const s = e, t = je(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
6930
+ <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${_e}</button>` : "<span>—</span>", o = Cs(r), i = r.data ?? "0x", a = document.createElement("div");
6802
6931
  return a.id = te, a.innerHTML = `
6803
6932
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
6804
6933
  <div class="__crossx-header">
@@ -6813,7 +6942,7 @@ function In(r, e) {
6813
6942
  <span class="__crossx-sig-origin">${U(t)} </span>is requesting a Signature
6814
6943
  </p>
6815
6944
  <div class="__crossx-addr-pill">
6816
- ${wt}
6945
+ ${mt}
6817
6946
  <span class="__crossx-addr-pill-text">${se(r.from)}</span>
6818
6947
  </div>
6819
6948
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
@@ -6836,9 +6965,9 @@ function In(r, e) {
6836
6965
  </div>
6837
6966
  `, a;
6838
6967
  }
6839
- function En(r, e) {
6840
- const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Je(r.dappName), i = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
6841
- <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${fe}</button>` : "<span>—</span>", a = Ns(r), l = mn(r.value, t, n) ?? "—", d = document.createElement("div");
6968
+ function An(r, e) {
6969
+ const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = je(r.dappName), i = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
6970
+ <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${_e}</button>` : "<span>—</span>", a = Cs(r), l = yn(r.value, t, n) ?? "—", d = document.createElement("div");
6842
6971
  return d.id = te, d.innerHTML = `
6843
6972
  <div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
6844
6973
  <div class="__crossx-header">
@@ -6866,7 +6995,7 @@ function En(r, e) {
6866
6995
  </div>
6867
6996
  `, d;
6868
6997
  }
6869
- function Je(r) {
6998
+ function je(r) {
6870
6999
  var e;
6871
7000
  if (r) return r;
6872
7001
  try {
@@ -6878,10 +7007,10 @@ function Je(r) {
6878
7007
  function U(r) {
6879
7008
  return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
6880
7009
  }
6881
- function Tn(r) {
7010
+ function Rn(r) {
6882
7011
  return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
6883
7012
  }
6884
- function An(r) {
7013
+ function kn(r) {
6885
7014
  if (typeof r == "string") return U(r);
6886
7015
  if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
6887
7016
  try {
@@ -6890,14 +7019,14 @@ function An(r) {
6890
7019
  return String(r);
6891
7020
  }
6892
7021
  }
6893
- function kn(r, e) {
7022
+ function Pn(r, e) {
6894
7023
  const s = Y(
6895
7024
  "From",
6896
7025
  `<span class="__crossx-addr-text">${se(r.from)}</span>
6897
- <button class="__crossx-copy-btn" data-copy="${U(r.from)}" title="Copy address">${fe}</button>`
7026
+ <button class="__crossx-copy-btn" data-copy="${U(r.from)}" title="Copy address">${_e}</button>`
6898
7027
  ), t = r.to ? Y("To", `<span class="__crossx-addr-text">${se(r.to)}</span>
6899
- <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${fe}</button>`) : "", n = r.amount ? Y("Transfer", `<span>${U(r.amount)}</span>`) : "", o = r.fees ? Y("Tx Fee", `<span>${U(r.fees)}</span>`) : "", i = r.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(r.txHash)}</span>
6900
- <button class="__crossx-copy-btn" data-copy="${U(r.txHash)}" title="Copy hash">${fe}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
7028
+ <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${_e}</button>`) : "", n = r.amount ? Y("Transfer", `<span>${U(r.amount)}</span>`) : "", o = r.fees ? Y("Tx Fee", `<span>${U(r.fees)}</span>`) : "", i = r.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(r.txHash)}</span>
7029
+ <button class="__crossx-copy-btn" data-copy="${U(r.txHash)}" title="Copy hash">${_e}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
6901
7030
  <span class="__crossx-total-label">Total<br>(including fees)</span>
6902
7031
  <span class="__crossx-total-amount">${U(r.total)}</span>
6903
7032
  </div>` : "", c = document.createElement("div");
@@ -6922,7 +7051,7 @@ function kn(r, e) {
6922
7051
  </div>
6923
7052
  `, c;
6924
7053
  }
6925
- function Pn(r, e) {
7054
+ function Cn(r, e) {
6926
7055
  const s = document.createElement("div");
6927
7056
  return s.id = te, s.innerHTML = `
6928
7057
  <div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
@@ -6942,7 +7071,7 @@ function Pn(r, e) {
6942
7071
  function Nn(r, e, s) {
6943
7072
  const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
6944
7073
  if (o) {
6945
- const w = n ? Sn : t ? "" : vn, E = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
7074
+ const w = n ? In : t ? "" : En, E = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
6946
7075
  w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${E}</span>`) : o.textContent = E;
6947
7076
  }
6948
7077
  if (i && !r.querySelector("#__crossx-close-btn")) {
@@ -6952,9 +7081,9 @@ function Nn(r, e, s) {
6952
7081
  const a = r.querySelector("#__crossx-progress-body");
6953
7082
  if (!a) return;
6954
7083
  const c = e.from ? Y("From", `<span class="__crossx-addr-text">${se(e.from)}</span>
6955
- <button class="__crossx-copy-btn" data-copy="${U(e.from)}" title="Copy address">${fe}</button>`) : "", l = e.to ? Y("To", `<span class="__crossx-addr-text">${se(e.to)}</span>
6956
- <button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${fe}</button>`) : "", d = e.amount ? Y("Transfer", `<span>${U(e.amount)}</span>`) : "", h = e.fees ? Y("Tx Fee", `<span>${U(e.fees)}</span>`) : "", m = e.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(e.txHash)}</span>
6957
- <button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${fe}</button>`) : "", x = e.total ? `<div class="__crossx-total-pill">
7084
+ <button class="__crossx-copy-btn" data-copy="${U(e.from)}" title="Copy address">${_e}</button>`) : "", l = e.to ? Y("To", `<span class="__crossx-addr-text">${se(e.to)}</span>
7085
+ <button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${_e}</button>`) : "", d = e.amount ? Y("Transfer", `<span>${U(e.amount)}</span>`) : "", h = e.fees ? Y("Tx Fee", `<span>${U(e.fees)}</span>`) : "", m = e.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(e.txHash)}</span>
7086
+ <button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${_e}</button>`) : "", x = e.total ? `<div class="__crossx-total-pill">
6958
7087
  <span class="__crossx-total-label">Total<br>(including fees)</span>
6959
7088
  <span class="__crossx-total-amount">${U(e.total)}</span>
6960
7089
  </div>` : "";
@@ -6978,8 +7107,8 @@ function Nn(r, e, s) {
6978
7107
  });
6979
7108
  });
6980
7109
  }
6981
- function Rn(r, e) {
6982
- const s = e, t = Je(r.dappName), n = U(r.message), o = document.createElement("div");
7110
+ function On(r, e) {
7111
+ const s = e, t = je(r.dappName), n = U(r.message), o = document.createElement("div");
6983
7112
  return o.id = te, o.innerHTML = `
6984
7113
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
6985
7114
  <div class="__crossx-header">
@@ -6994,7 +7123,7 @@ function Rn(r, e) {
6994
7123
  <span class="__crossx-sig-origin">${U(t)} </span>is requesting a Signature
6995
7124
  </p>
6996
7125
  <div class="__crossx-addr-pill">
6997
- ${wt}
7126
+ ${mt}
6998
7127
  <span class="__crossx-addr-pill-text">${se(r.from)}</span>
6999
7128
  </div>
7000
7129
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
@@ -7010,8 +7139,8 @@ function Rn(r, e) {
7010
7139
  </div>
7011
7140
  `, o;
7012
7141
  }
7013
- function Cn(r, e) {
7014
- const s = e, t = Je(r.dappName);
7142
+ function Ln(r, e) {
7143
+ const s = e, t = je(r.dappName);
7015
7144
  let n = {};
7016
7145
  if (typeof r.typedData == "string")
7017
7146
  try {
@@ -7026,8 +7155,8 @@ function Cn(r, e) {
7026
7155
  <span class="__crossx-td-value">${U(o)}</span>
7027
7156
  </div>`;
7028
7157
  for (const [l, d] of Object.entries(i)) {
7029
- const h = An(d), x = Tn(d) ? `<span class="__crossx-addr-text">${se(d)}</span>
7030
- <button class="__crossx-copy-btn" data-copy="${U(String(d))}" title="Copy">${fe}</button>` : `<span>${h}</span>`;
7158
+ const h = kn(d), x = Rn(d) ? `<span class="__crossx-addr-text">${se(d)}</span>
7159
+ <button class="__crossx-copy-btn" data-copy="${U(String(d))}" title="Copy">${_e}</button>` : `<span>${h}</span>`;
7031
7160
  a += `
7032
7161
  <div class="__crossx-td-row">
7033
7162
  <span class="__crossx-td-label">${U(l)}</span>
@@ -7049,7 +7178,7 @@ function Cn(r, e) {
7049
7178
  <span class="__crossx-sig-origin">${U(t)} </span>is requesting a Signature
7050
7179
  </p>
7051
7180
  <div class="__crossx-addr-pill">
7052
- ${wt}
7181
+ ${mt}
7053
7182
  <span class="__crossx-addr-pill-text">${se(r.from)}</span>
7054
7183
  </div>
7055
7184
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
@@ -7065,11 +7194,11 @@ function Cn(r, e) {
7065
7194
  </div>
7066
7195
  `, c;
7067
7196
  }
7068
- const On = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
7197
+ const Dn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
7069
7198
  <line x1="12" y1="5" x2="12" y2="19"/>
7070
7199
  <line x1="5" y1="12" x2="19" y2="12"/>
7071
7200
  </svg>`;
7072
- function Ln(r, e, s) {
7201
+ function Mn(r, e, s) {
7073
7202
  const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
7074
7203
  const a = t && i.address.toLowerCase() === t;
7075
7204
  return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${U(i.address)}">
@@ -7100,7 +7229,7 @@ function Ln(r, e, s) {
7100
7229
  ${n}
7101
7230
  </div>
7102
7231
  <button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
7103
- <span class="__crossx-wallet-add-icon">${On}</span>
7232
+ <span class="__crossx-wallet-add-icon">${Dn}</span>
7104
7233
  <span class="__crossx-wallet-add-label">add a wallet</span>
7105
7234
  </button>
7106
7235
  </div>
@@ -7109,16 +7238,16 @@ function Ln(r, e, s) {
7109
7238
  </div>
7110
7239
  `, o;
7111
7240
  }
7112
- const Dn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7241
+ const $n = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7113
7242
  <path d="M26.693 21.193c-.028-3.168 2.587-4.712 2.706-4.786-1.477-2.16-3.77-2.454-4.58-2.484-1.944-.197-3.804 1.148-4.793 1.148-.992 0-2.52-1.12-4.147-1.09-2.13.032-4.1 1.239-5.198 3.133-2.222 3.855-.569 9.562 1.593 12.69 1.061 1.535 2.318 3.258 3.975 3.196 1.6-.064 2.2-1.03 4.133-1.03 1.928 0 2.48 1.03 4.172.997 1.72-.03 2.806-1.56 3.862-3.1 1.211-1.779 1.713-3.495 1.74-3.583-.037-.017-3.427-1.316-3.463-5.09z" fill="currentColor"/>
7114
7243
  <path d="M23.527 11.876c.877-1.065 1.471-2.545 1.31-4.024-1.266.053-2.807.845-3.718 1.907-.813.946-1.53 2.468-1.34 3.915 1.41.107 2.852-.716 3.748-1.798z" fill="currentColor"/>
7115
- </svg>`, Mn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7244
+ </svg>`, Bn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7116
7245
  <path d="M38.06 20.44c0-1.34-.12-2.63-.34-3.87H20.5v7.32h9.84c-.42 2.28-1.71 4.21-3.65 5.51v4.57h5.91c3.46-3.19 5.46-7.88 5.46-13.53z" fill="#4285F4"/>
7117
7246
  <path d="M20.5 38.5c4.94 0 9.09-1.64 12.12-4.44l-5.91-4.57c-1.64 1.1-3.73 1.75-6.21 1.75-4.77 0-8.82-3.22-10.26-7.55H4.16v4.72A18.49 18.49 0 0 0 20.5 38.5z" fill="#34A853"/>
7118
7247
  <path d="M10.24 23.69A11.16 11.16 0 0 1 9.66 20c0-1.28.22-2.52.58-3.69v-4.72H4.16A18.49 18.49 0 0 0 2 20c0 2.97.71 5.78 1.97 8.28l6.27-4.59z" fill="#FBBC05"/>
7119
7248
  <path d="M20.5 8.76c2.69 0 5.1.92 7 2.73l5.24-5.24C29.58 3.36 25.43 1.5 20.5 1.5A18.49 18.49 0 0 0 4.16 11.59l6.08 4.72C11.68 11.98 15.73 8.76 20.5 8.76z" fill="#EA4335"/>
7120
7249
  </svg>`;
7121
- function $n(r) {
7250
+ function Un(r) {
7122
7251
  const e = r, s = document.createElement("div");
7123
7252
  return s.id = te, s.innerHTML = `
7124
7253
  <div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
@@ -7133,11 +7262,11 @@ function $n(r) {
7133
7262
  <div class="__crossx-body">
7134
7263
  <div class="__crossx-login-btn-row">
7135
7264
  <button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
7136
- <span class="__crossx-login-icon" style="color:var(--cx-value);">${Dn}</span>
7265
+ <span class="__crossx-login-icon" style="color:var(--cx-value);">${$n}</span>
7137
7266
  <span class="__crossx-login-btn-label">Sign in with&nbsp;&nbsp;Apple</span>
7138
7267
  </button>
7139
7268
  <button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
7140
- <span class="__crossx-login-icon">${Mn}</span>
7269
+ <span class="__crossx-login-icon">${Bn}</span>
7141
7270
  <span class="__crossx-login-btn-label">Sign in with&nbsp;&nbsp;Google</span>
7142
7271
  </button>
7143
7272
  </div>
@@ -7149,7 +7278,7 @@ function $n(r) {
7149
7278
  </div>
7150
7279
  `, s;
7151
7280
  }
7152
- function Bn(r) {
7281
+ function Hn(r) {
7153
7282
  const e = r, s = document.createElement("div");
7154
7283
  return s.id = te, s.innerHTML = `
7155
7284
  <div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
@@ -7165,7 +7294,7 @@ function Bn(r) {
7165
7294
  <p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
7166
7295
  </div>
7167
7296
  <button class="__crossx-recover-btn" id="__crossx-recover-btn">
7168
- <span class="__crossx-recover-icon">${bn}</span>
7297
+ <span class="__crossx-recover-icon">${Sn}</span>
7169
7298
  <span class="__crossx-recover-label">Import from Social Backup</span>
7170
7299
  </button>
7171
7300
  <button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>
@@ -7173,7 +7302,7 @@ function Bn(r) {
7173
7302
  </div>
7174
7303
  `, s;
7175
7304
  }
7176
- function Un(r, e) {
7305
+ function Fn(r, e) {
7177
7306
  const s = r, { errorMessage: t, attemptCount: n, maxAttempts: o = 5 } = e ?? {}, i = !!t, a = i ? " --error" : "", c = n != null && n > 0 ? `<p class="__crossx-pin-attempt">${n}/${o}</p>` : "", l = n != null && n >= 3 ? '<p class="__crossx-pin-warning">Your account will be locked after further failures.</p>' : "", d = i ? `<p class="__crossx-pin-error-text">${t}</p>` : "", h = document.createElement("div");
7178
7307
  return h.id = te, h.innerHTML = `
7179
7308
  <div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
@@ -7197,12 +7326,12 @@ function Un(r, e) {
7197
7326
  </div>
7198
7327
  `, h;
7199
7328
  }
7200
- function Hn(r) {
7329
+ function Gn(r) {
7201
7330
  const e = new Date(r), s = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], t = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], n = s[e.getDay()], o = t[e.getMonth()], i = e.getDate(), a = String(e.getHours()).padStart(2, "0"), c = String(e.getMinutes()).padStart(2, "0");
7202
7331
  return `${n}, ${o} ${i} ${a}:${c}`;
7203
7332
  }
7204
- function Fn(r, e, s) {
7205
- const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ? Hn(o) : null, a = document.createElement("div");
7333
+ function Wn(r, e, s) {
7334
+ const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ? Gn(o) : null, a = document.createElement("div");
7206
7335
  return a.id = te, a.innerHTML = `
7207
7336
  <div class="__crossx-card __crossx-card--migration" style="${ce(t)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7208
7337
  <div class="__crossx-header">
@@ -7232,10 +7361,10 @@ function Fn(r, e, s) {
7232
7361
  return () => clearInterval(h);
7233
7362
  } };
7234
7363
  }
7235
- function Gn(r) {
7364
+ function qn(r) {
7236
7365
  const s = [r.check1, r.check2].map((t, n) => `
7237
7366
  <div class="__crossx-pw-notice-item" data-check-index="${n}" role="checkbox" aria-checked="false" tabindex="0">
7238
- <div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${Vn}</div>
7367
+ <div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${zn}</div>
7239
7368
  <span class="__crossx-pw-notice-item-text">${U(t)}</span>
7240
7369
  </div>
7241
7370
  `).join("");
@@ -7250,7 +7379,7 @@ function Gn(r) {
7250
7379
  <div class="__crossx-pw-fields __crossx-pw-fields--notice">
7251
7380
  <div class="__crossx-pw-notice-header">
7252
7381
  <div class="__crossx-pw-notice-title-row">
7253
- <span class="__crossx-pw-notice-icon">${zn}</span>
7382
+ <span class="__crossx-pw-notice-icon">${jn}</span>
7254
7383
  <p class="__crossx-pw-notice-title">${U(r.noticeTitle)}</p>
7255
7384
  </div>
7256
7385
  <p class="__crossx-pw-notice-desc">${U(r.noticeDesc)}</p>
@@ -7268,9 +7397,9 @@ function Gn(r) {
7268
7397
  <div class="__crossx-home-indicator"></div>
7269
7398
  `;
7270
7399
  }
7271
- function nt(r) {
7400
+ function rt(r) {
7272
7401
  const e = !!r.lockExpiresAt && r.lockExpiresAt > Date.now(), s = r.lockExpiresAt ? ` data-lock-expires="${r.lockExpiresAt}"` : "", t = r.headerSubtitle ? `<p class="__crossx-pin6-header-sub">${U(r.headerSubtitle)}</p>` : "", n = r.subtitle ? `<p class="__crossx-pin6-subtitle">${U(r.subtitle)}</p>` : "", o = r.errorMessage ? `<p class="__crossx-pin6-error" id="__crossx-pin6-error">${U(r.errorMessage)}</p>` : '<p class="__crossx-pin6-error" id="__crossx-pin6-error"></p>', i = e ? `<p class="__crossx-pin6-lock-msg" id="__crossx-pin6-lock-msg">
7273
- ${Rs}
7402
+ ${Ns}
7274
7403
  <span id="__crossx-pin6-lock-countdown"></span>
7275
7404
  </p>` : "", a = e ? " --locked" : "", c = Array.from(
7276
7405
  { length: 6 },
@@ -7294,7 +7423,7 @@ function nt(r) {
7294
7423
  <div class="__crossx-home-indicator"></div>
7295
7424
  `;
7296
7425
  }
7297
- function Jt(r, e) {
7426
+ function Zt(r, e) {
7298
7427
  const s = document.createElement("div");
7299
7428
  return s.id = te, s.innerHTML = `
7300
7429
  <div class="__crossx-card __crossx-card--pin6" style="${ce(r)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
@@ -7302,31 +7431,31 @@ function Jt(r, e) {
7302
7431
  </div>
7303
7432
  `, s;
7304
7433
  }
7305
- function Wn(r, e) {
7434
+ function Kn(r, e) {
7306
7435
  if (r.length !== 6) return e.tooShort;
7307
7436
  if (!/^\d+$/.test(r)) return e.numbersOnly;
7308
7437
  if (/(.)\1{2}/.test(r)) return e.repeatingDigit;
7309
7438
  const s = r.split("").map(Number), t = s.every((o, i) => i === 0 || o === (s[i - 1] + 1) % 10), n = s.every((o, i) => i === 0 || o === (s[i - 1] + 9) % 10);
7310
7439
  return t || n ? e.sequential : r[0] !== r[1] && r === r.slice(0, 2).repeat(3) ? e.alternatingPattern : null;
7311
7440
  }
7312
- function qn(r) {
7441
+ function Vn(r) {
7313
7442
  const e = Math.max(0, Math.ceil(r / 1e3)), s = Math.floor(e / 3600), t = Math.floor(e % 3600 / 60), n = e % 60;
7314
7443
  return s > 0 ? `${s}h ${String(t).padStart(2, "0")}m` : `${String(t).padStart(2, "0")}:${String(n).padStart(2, "0")}`;
7315
7444
  }
7316
- function ot(r, e, s, t, n, o) {
7445
+ function nt(r, e, s, t, n, o) {
7317
7446
  let i = !!(o && o > Date.now()), a = !1;
7318
7447
  const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), d = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), m = () => r.querySelector("#__crossx-pin6-lock-countdown"), x = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((b) => b.value).join(""), E = (b) => {
7319
- i = b, c().forEach((P) => {
7320
- P.disabled = b, P.classList.toggle("--locked", b);
7448
+ i = b, c().forEach((k) => {
7449
+ k.disabled = b, k.classList.toggle("--locked", b);
7321
7450
  });
7322
7451
  }, y = () => {
7323
7452
  const b = d();
7324
7453
  b && (b.textContent = "");
7325
7454
  }, S = (b) => {
7326
- const P = d();
7327
- P && (P.textContent = b);
7328
- const N = l();
7329
- N == null || N.classList.add("--shake"), setTimeout(() => N == null ? void 0 : N.classList.remove("--shake"), 500), c().forEach((G) => {
7455
+ const k = d();
7456
+ k && (k.textContent = b);
7457
+ const P = l();
7458
+ P == null || P.classList.add("--shake"), setTimeout(() => P == null ? void 0 : P.classList.remove("--shake"), 500), c().forEach((G) => {
7330
7459
  G.value = "";
7331
7460
  }), setTimeout(() => {
7332
7461
  var G;
@@ -7337,44 +7466,44 @@ function ot(r, e, s, t, n, o) {
7337
7466
  E(!0), c().forEach((q) => {
7338
7467
  q.value = "";
7339
7468
  });
7340
- const P = d();
7341
- if (P && (P.textContent = "Too many failed attempts. Please wait."), !h()) {
7469
+ const k = d();
7470
+ if (k && (k.textContent = "Too many failed attempts. Please wait."), !h()) {
7342
7471
  const q = document.createElement("p");
7343
- q.className = "__crossx-pin6-lock-msg", q.id = "__crossx-pin6-lock-msg", q.innerHTML = `${Rs}<span id="__crossx-pin6-lock-countdown"></span>`;
7472
+ q.className = "__crossx-pin6-lock-msg", q.id = "__crossx-pin6-lock-msg", q.innerHTML = `${Ns}<span id="__crossx-pin6-lock-countdown"></span>`;
7344
7473
  const D = d();
7345
7474
  D ? D.insertAdjacentElement("afterend", q) : (W = x()) == null || W.appendChild(q);
7346
7475
  }
7347
- const N = () => {
7348
- var k;
7476
+ const P = () => {
7477
+ var R;
7349
7478
  const q = b - Date.now(), D = m();
7350
- q <= 0 ? (clearInterval(G), E(!1), (k = h()) == null || k.remove(), P && (P.textContent = ""), setTimeout(() => {
7351
- var R;
7352
- return (R = c()[0]) == null ? void 0 : R.focus();
7353
- }, 50)) : D && (D.textContent = ` ${qn(q)}`);
7354
- }, G = setInterval(N, 1e3);
7355
- N();
7356
- const K = new MutationObserver(() => {
7357
- document.contains(r) || (clearInterval(G), K.disconnect());
7479
+ q <= 0 ? (clearInterval(G), E(!1), (R = h()) == null || R.remove(), k && (k.textContent = ""), setTimeout(() => {
7480
+ var C;
7481
+ return (C = c()[0]) == null ? void 0 : C.focus();
7482
+ }, 50)) : D && (D.textContent = ` ${Vn(q)}`);
7483
+ }, G = setInterval(P, 1e3);
7484
+ P();
7485
+ const z = new MutationObserver(() => {
7486
+ document.contains(r) || (clearInterval(G), z.disconnect());
7358
7487
  });
7359
- K.observe(document.body, { childList: !0, subtree: !1 });
7488
+ z.observe(document.body, { childList: !0, subtree: !1 });
7360
7489
  }, B = async () => {
7361
7490
  if (i || a) return;
7362
7491
  const b = w();
7363
7492
  if (b.length === 6) {
7364
- a = !0, c().forEach((P) => {
7365
- P.disabled = !0;
7493
+ a = !0, c().forEach((k) => {
7494
+ k.disabled = !0;
7366
7495
  });
7367
7496
  try {
7368
7497
  if (n) {
7369
- const P = await n(b);
7370
- P.ok ? e(b) : P.lockExpiresAt ? O(P.lockExpiresAt) : S(P.error ?? "Incorrect PIN. Please try again.");
7498
+ const k = await n(b);
7499
+ k.ok ? e(b) : k.lockExpiresAt ? O(k.lockExpiresAt) : S(k.error ?? "Incorrect PIN. Please try again.");
7371
7500
  } else
7372
7501
  e(b);
7373
- } catch (P) {
7374
- t && t(P);
7502
+ } catch (k) {
7503
+ t && t(k);
7375
7504
  } finally {
7376
- a = !1, i || c().forEach((P) => {
7377
- P.disabled = !1;
7505
+ a = !1, i || c().forEach((k) => {
7506
+ k.disabled = !1;
7378
7507
  });
7379
7508
  }
7380
7509
  }
@@ -7382,41 +7511,41 @@ function ot(r, e, s, t, n, o) {
7382
7511
  o && o > Date.now() ? O(o) : setTimeout(() => {
7383
7512
  var b;
7384
7513
  return (b = c()[0]) == null ? void 0 : b.focus();
7385
- }, 100), c().forEach((b, P) => {
7514
+ }, 100), c().forEach((b, k) => {
7386
7515
  b.addEventListener("input", () => {
7387
7516
  var G;
7388
- const N = b.value.replace(/\D/g, "").slice(-1);
7389
- b.value = N, y(), N && P < 5 && ((G = c()[P + 1]) == null || G.focus()), w().length === 6 && setTimeout(B, 80);
7390
- }), b.addEventListener("keydown", (N) => {
7391
- var G, K;
7392
- if (N.key === "Backspace") {
7393
- if (N.preventDefault(), b.value)
7517
+ const P = b.value.replace(/\D/g, "").slice(-1);
7518
+ b.value = P, y(), P && k < 5 && ((G = c()[k + 1]) == null || G.focus()), w().length === 6 && setTimeout(B, 80);
7519
+ }), b.addEventListener("keydown", (P) => {
7520
+ var G, z;
7521
+ if (P.key === "Backspace") {
7522
+ if (P.preventDefault(), b.value)
7394
7523
  b.value = "";
7395
- else if (P > 0) {
7396
- const W = c()[P - 1];
7524
+ else if (k > 0) {
7525
+ const W = c()[k - 1];
7397
7526
  W.value = "", W.focus();
7398
7527
  }
7399
- } else N.key === "ArrowLeft" && P > 0 ? (N.preventDefault(), (G = c()[P - 1]) == null || G.focus()) : N.key === "ArrowRight" && P < 5 ? (N.preventDefault(), (K = c()[P + 1]) == null || K.focus()) : N.key === "Escape" && s();
7400
- }), b.addEventListener("paste", (N) => {
7528
+ } else P.key === "ArrowLeft" && k > 0 ? (P.preventDefault(), (G = c()[k - 1]) == null || G.focus()) : P.key === "ArrowRight" && k < 5 ? (P.preventDefault(), (z = c()[k + 1]) == null || z.focus()) : P.key === "Escape" && s();
7529
+ }), b.addEventListener("paste", (P) => {
7401
7530
  var W, q;
7402
- N.preventDefault();
7403
- const G = (((W = N.clipboardData) == null ? void 0 : W.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
7531
+ P.preventDefault();
7532
+ const G = (((W = P.clipboardData) == null ? void 0 : W.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
7404
7533
  if (!G) return;
7405
- const K = c();
7406
- G.split("").forEach((D, k) => {
7407
- K[k] && (K[k].value = D);
7408
- }), (q = K[Math.min(G.length - 1, 5)]) == null || q.focus(), y(), w().length === 6 && setTimeout(B, 80);
7534
+ const z = c();
7535
+ G.split("").forEach((D, R) => {
7536
+ z[R] && (z[R].value = D);
7537
+ }), (q = z[Math.min(G.length - 1, 5)]) == null || q.focus(), y(), w().length === 6 && setTimeout(B, 80);
7409
7538
  }), b.addEventListener("focus", () => b.select());
7410
7539
  });
7411
7540
  }
7412
- const Rs = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
7541
+ const Ns = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
7413
7542
  <path d="M14.5 8.5H14V6.5C14 4.015 11.985 2 9.5 2C7.015 2 5 4.015 5 6.5V8.5H4.5C3.672 8.5 3 9.172 3 10V16.5C3 17.328 3.672 18 4.5 18H14.5C15.328 18 16 17.328 16 16.5V10C16 9.172 15.328 8.5 14.5 8.5ZM10.5 13.415V15C10.5 15.276 10.276 15.5 10 15.5H9C8.724 15.5 8.5 15.276 8.5 15V13.415C8.187 13.196 8 12.847 8 12.5C8 11.672 8.672 11 9.5 11C10.328 11 11 11.672 11 12.5C11 12.847 10.813 13.196 10.5 13.415ZM12.5 8.5H6.5V6.5C6.5 4.843 7.843 3.5 9.5 3.5C11.157 3.5 12.5 4.843 12.5 6.5V8.5Z" fill="currentColor"/>
7414
- </svg>`, Vn = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
7543
+ </svg>`, zn = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
7415
7544
  <path d="M1 4.5L4 7.5L10 1" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
7416
- </svg>`, zn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
7545
+ </svg>`, jn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
7417
7546
  <path d="M12 0C18.6274 0 24 5.37258 24 12C23.9999 18.6273 18.6274 24 12 24C5.37264 24 9.89594e-05 18.6273 0 12C0 5.37258 5.37258 0 12 0ZM10.875 15.127V17.377H13.125V15.127H10.875ZM10.875 6.62207V13.627H13.125V6.62207H10.875Z" fill="currentColor"/>
7418
7547
  </svg>`;
7419
- function Kn(r, e, s) {
7548
+ function Yn(r, e, s) {
7420
7549
  var n;
7421
7550
  const t = r.querySelectorAll(".__crossx-pin-input");
7422
7551
  t.forEach((o, i) => {
@@ -7442,12 +7571,12 @@ function Kn(r, e, s) {
7442
7571
  });
7443
7572
  }), (n = t[0]) == null || n.focus();
7444
7573
  }
7445
- class jn {
7574
+ class Jn {
7446
7575
  constructor(e = "light", s) {
7447
- this.theme = e, this.overrides = s, this.tokens = jt(e, s);
7576
+ this.theme = e, this.overrides = s, this.tokens = Yt(e, s);
7448
7577
  }
7449
7578
  setTheme(e, s) {
7450
- this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = jt(e, this.overrides);
7579
+ this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = Yt(e, this.overrides);
7451
7580
  }
7452
7581
  setMessages(e) {
7453
7582
  this.messages = e;
@@ -7463,8 +7592,8 @@ class jn {
7463
7592
  showWalletSelector(e, s, t) {
7464
7593
  return new Promise((n) => {
7465
7594
  var E;
7466
- ue();
7467
- const o = [...e], i = Ln(o, this.tokens, t), a = document.body.style.overflow;
7595
+ he();
7596
+ const o = [...e], i = Mn(o, this.tokens, t), a = document.body.style.overflow;
7468
7597
  document.body.style.overflow = "hidden", document.body.appendChild(i);
7469
7598
  let c = !1;
7470
7599
  const l = () => {
@@ -7514,8 +7643,8 @@ class jn {
7514
7643
  showLoginSelector() {
7515
7644
  return new Promise((e) => {
7516
7645
  var a, c, l;
7517
- ue();
7518
- const s = $n(this.tokens);
7646
+ he();
7647
+ const s = Un(this.tokens);
7519
7648
  document.body.appendChild(s);
7520
7649
  const t = () => s.remove(), n = (d) => {
7521
7650
  t(), e(d);
@@ -7540,8 +7669,8 @@ class jn {
7540
7669
  showMigrationFoundPrompt() {
7541
7670
  return new Promise((e) => {
7542
7671
  var a, c, l;
7543
- ue();
7544
- const s = Bn(this.tokens);
7672
+ he();
7673
+ const s = Hn(this.tokens);
7545
7674
  document.body.appendChild(s);
7546
7675
  const t = () => s.remove(), n = () => {
7547
7676
  t(), e("recover");
@@ -7566,7 +7695,7 @@ class jn {
7566
7695
  */
7567
7696
  showPinSetupPrompt(e) {
7568
7697
  return new Promise((s) => {
7569
- ue();
7698
+ he();
7570
7699
  const t = this.messages, n = {
7571
7700
  title: (t == null ? void 0 : t.pinSetup_title) ?? "Create PIN",
7572
7701
  headerSubtitle: (t == null ? void 0 : t.pinNotice_headerSubtitle) ?? "Required for transactions, PK/mnemonic export & account deletion.",
@@ -7584,7 +7713,7 @@ class jn {
7584
7713
  }, i = {
7585
7714
  title: (t == null ? void 0 : t.pinSetup_confirmTitle) ?? "Confirm PIN",
7586
7715
  headerSubtitle: (t == null ? void 0 : t.pinSetup_confirmSubtitle) ?? "Enter your PIN again to confirm."
7587
- }, a = Jt(this.tokens, Gn(n)), c = document.body.style.overflow;
7716
+ }, a = Zt(this.tokens, qn(n)), c = document.body.style.overflow;
7588
7717
  document.body.style.overflow = "hidden", document.body.appendChild(a);
7589
7718
  let l = !1;
7590
7719
  const d = () => {
@@ -7601,60 +7730,60 @@ class jn {
7601
7730
  alternatingPattern: (t == null ? void 0 : t.pinValidation_alternatingPattern) ?? "Repeating patterns (e.g., 121212) are not allowed."
7602
7731
  }, E = (O) => {
7603
7732
  var B;
7604
- x.innerHTML = nt({
7733
+ x.innerHTML = rt({
7605
7734
  title: i.title,
7606
7735
  headerSubtitle: i.headerSubtitle
7607
- }), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), ot(x, (b) => {
7736
+ }), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), nt(x, (b) => {
7608
7737
  b === O ? h(O) : y(o.mismatchError);
7609
7738
  }, m);
7610
7739
  }, y = (O) => {
7611
7740
  var B;
7612
- x.innerHTML = nt({
7741
+ x.innerHTML = rt({
7613
7742
  title: o.title,
7614
7743
  headerSubtitle: o.headerSubtitle,
7615
7744
  subtitle: o.subtitle,
7616
7745
  errorMessage: O
7617
- }), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), ot(x, (b) => {
7618
- const P = Wn(b, w);
7619
- P ? y(P) : E(b);
7746
+ }), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), nt(x, (b) => {
7747
+ const k = Kn(b, w);
7748
+ k ? y(k) : E(b);
7620
7749
  }, m);
7621
7750
  };
7622
7751
  (() => {
7623
7752
  var q;
7624
7753
  const O = Array.from(x.querySelectorAll(".__crossx-pw-notice-item")), B = x.querySelector("#__crossx-pin-notice-next"), b = /* @__PURE__ */ new Set();
7625
7754
  B.removeAttribute("disabled");
7626
- const P = B.dataset.nextLabel ?? "Next", N = B.dataset.submitLabel ?? "I Understand", G = () => {
7755
+ const k = B.dataset.nextLabel ?? "Next", P = B.dataset.submitLabel ?? "I Understand", G = () => {
7627
7756
  const D = b.size === O.length;
7628
- B.classList.toggle("--disabled", !D), B.textContent = D ? N : P;
7629
- }, K = (D, k) => {
7630
- if (b.has(k)) return;
7631
- const R = D.querySelector(`#__crossx-notice-check-${k}`);
7632
- b.add(k), R.classList.add("--checked"), D.setAttribute("aria-checked", "true"), G();
7633
- }, W = (D, k) => {
7634
- if (!b.has(k)) return;
7635
- const R = D.querySelector(`#__crossx-notice-check-${k}`);
7636
- b.delete(k), R.classList.remove("--checked"), D.setAttribute("aria-checked", "false"), G();
7757
+ B.classList.toggle("--disabled", !D), B.textContent = D ? P : k;
7758
+ }, z = (D, R) => {
7759
+ if (b.has(R)) return;
7760
+ const C = D.querySelector(`#__crossx-notice-check-${R}`);
7761
+ b.add(R), C.classList.add("--checked"), D.setAttribute("aria-checked", "true"), G();
7762
+ }, W = (D, R) => {
7763
+ if (!b.has(R)) return;
7764
+ const C = D.querySelector(`#__crossx-notice-check-${R}`);
7765
+ b.delete(R), C.classList.remove("--checked"), D.setAttribute("aria-checked", "false"), G();
7637
7766
  };
7638
7767
  O.forEach((D) => {
7639
- const k = parseInt(D.dataset.checkIndex ?? "0", 10);
7768
+ const R = parseInt(D.dataset.checkIndex ?? "0", 10);
7640
7769
  D.addEventListener("click", () => {
7641
- b.has(k) ? W(D, k) : K(D, k);
7642
- }), D.addEventListener("keydown", (R) => {
7643
- (R.key === " " || R.key === "Enter") && (R.preventDefault(), b.has(k) ? W(D, k) : K(D, k));
7770
+ b.has(R) ? W(D, R) : z(D, R);
7771
+ }), D.addEventListener("keydown", (C) => {
7772
+ (C.key === " " || C.key === "Enter") && (C.preventDefault(), b.has(R) ? W(D, R) : z(D, R));
7644
7773
  });
7645
7774
  }), B.addEventListener("click", () => {
7646
7775
  if (b.size === O.length) {
7647
7776
  y(e == null ? void 0 : e.errorMessage);
7648
7777
  return;
7649
7778
  }
7650
- const D = O.find((R) => {
7651
- const f = parseInt(R.dataset.checkIndex ?? "0", 10);
7779
+ const D = O.find((C) => {
7780
+ const f = parseInt(C.dataset.checkIndex ?? "0", 10);
7652
7781
  return !b.has(f);
7653
7782
  });
7654
7783
  if (!D) return;
7655
- const k = parseInt(D.dataset.checkIndex ?? "0", 10);
7784
+ const R = parseInt(D.dataset.checkIndex ?? "0", 10);
7656
7785
  D.scrollIntoView({ behavior: "smooth", block: "nearest" }), D.classList.add("--highlight"), setTimeout(() => {
7657
- D.classList.remove("--highlight"), K(D, k);
7786
+ D.classList.remove("--highlight"), z(D, R);
7658
7787
  }, 400);
7659
7788
  }), (q = x.querySelector("#__crossx-close-btn")) == null || q.addEventListener("click", m);
7660
7789
  })(), a.addEventListener("click", (O) => {
@@ -7670,10 +7799,10 @@ class jn {
7670
7799
  showPinInputPrompt(e) {
7671
7800
  return new Promise((s, t) => {
7672
7801
  var y;
7673
- ue();
7674
- const n = this.messages, o = (e == null ? void 0 : e.verifyMode) === !0, i = o ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = o ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c = Jt(
7802
+ he();
7803
+ const n = this.messages, o = (e == null ? void 0 : e.verifyMode) === !0, i = o ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = o ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c = Zt(
7675
7804
  this.tokens,
7676
- nt({
7805
+ rt({
7677
7806
  title: i,
7678
7807
  headerSubtitle: a,
7679
7808
  errorMessage: e == null ? void 0 : e.errorMessage,
@@ -7691,7 +7820,7 @@ class jn {
7691
7820
  }, w = (S) => {
7692
7821
  h(), t(S);
7693
7822
  }, E = c.querySelector(".__crossx-card");
7694
- (y = E.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", x), ot(E, m, x, w, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt), c.addEventListener("click", (S) => {
7823
+ (y = E.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", x), nt(E, m, x, w, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt), c.addEventListener("click", (S) => {
7695
7824
  S.target === c && x();
7696
7825
  });
7697
7826
  });
@@ -7706,15 +7835,15 @@ class jn {
7706
7835
  showRecoveryPinInputPrompt(e) {
7707
7836
  return new Promise((s) => {
7708
7837
  var a;
7709
- ue();
7710
- const t = Un(this.tokens, e);
7838
+ he();
7839
+ const t = Fn(this.tokens, e);
7711
7840
  document.body.appendChild(t);
7712
7841
  const n = () => t.remove(), o = (c) => {
7713
7842
  n(), s(c);
7714
7843
  }, i = () => {
7715
7844
  n(), s(null);
7716
7845
  };
7717
- Kn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
7846
+ Yn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
7718
7847
  c.target === t && i();
7719
7848
  });
7720
7849
  });
@@ -7728,8 +7857,8 @@ class jn {
7728
7857
  showRecoveryPinLockedPrompt(e, s) {
7729
7858
  return new Promise((t) => {
7730
7859
  var l;
7731
- ue();
7732
- const { overlay: n, startCountdown: o } = Fn(this.tokens, e, s);
7860
+ he();
7861
+ const { overlay: n, startCountdown: o } = Wn(this.tokens, e, s);
7733
7862
  document.body.appendChild(n);
7734
7863
  const i = () => {
7735
7864
  c(), n.remove();
@@ -7748,8 +7877,8 @@ class jn {
7748
7877
  showTransactionComplete(e) {
7749
7878
  return new Promise((s) => {
7750
7879
  var a, c;
7751
- ue();
7752
- const t = kn(e, this.tokens);
7880
+ he();
7881
+ const t = Pn(e, this.tokens);
7753
7882
  document.body.appendChild(t);
7754
7883
  const n = () => t.remove(), o = () => {
7755
7884
  n(), s();
@@ -7777,8 +7906,8 @@ class jn {
7777
7906
  */
7778
7907
  showTransactionProgress(e, s) {
7779
7908
  return new Promise((t) => {
7780
- ue();
7781
- const n = Pn(e, this.tokens);
7909
+ he();
7910
+ const n = Cn(e, this.tokens);
7782
7911
  document.body.appendChild(n);
7783
7912
  const o = () => n.remove();
7784
7913
  let i = !1;
@@ -7802,9 +7931,9 @@ class jn {
7802
7931
  requestConfirmation(e) {
7803
7932
  return new Promise((s) => {
7804
7933
  var c, l, d;
7805
- ue();
7934
+ he();
7806
7935
  let t;
7807
- e.type === "sign-message" ? t = Rn(e, this.tokens) : e.type === "sign-typed-data" ? t = Cn(e, this.tokens) : e.type === "sign" ? t = In(e, this.tokens) : t = En(e, this.tokens), document.body.appendChild(t);
7936
+ e.type === "sign-message" ? t = On(e, this.tokens) : e.type === "sign-typed-data" ? t = Ln(e, this.tokens) : e.type === "sign" ? t = Tn(e, this.tokens) : t = An(e, this.tokens), document.body.appendChild(t);
7808
7937
  const n = () => t.remove(), o = () => {
7809
7938
  n(), s(!0);
7810
7939
  }, i = () => {
@@ -7828,26 +7957,32 @@ class jn {
7828
7957
  });
7829
7958
  }
7830
7959
  }
7831
- class Yn {
7960
+ class Zn {
7832
7961
  constructor() {
7833
- this._accessToken = null;
7962
+ this._accessToken = null, this._expiresAt = 0;
7834
7963
  }
7835
7964
  set(e) {
7836
7965
  this._accessToken = e;
7966
+ try {
7967
+ const s = JSON.parse(atob(e.split(".")[1]));
7968
+ this._expiresAt = typeof s.exp == "number" ? s.exp * 1e3 : 0;
7969
+ } catch {
7970
+ this._expiresAt = 0;
7971
+ }
7837
7972
  }
7838
7973
  get() {
7839
- return this._accessToken;
7974
+ return this._accessToken && this._expiresAt > 0 && Date.now() >= this._expiresAt ? (this.clear(), null) : this._accessToken;
7840
7975
  }
7841
7976
  clear() {
7842
- this._accessToken = null;
7977
+ this._accessToken = null, this._expiresAt = 0;
7843
7978
  }
7844
7979
  has() {
7845
- return this._accessToken !== null;
7980
+ return this.get() !== null;
7846
7981
  }
7847
7982
  }
7848
- function Qn(r, e) {
7983
+ function to(r, e) {
7849
7984
  r.debug;
7850
- const s = We.production, t = {
7985
+ const s = Fe.production, t = {
7851
7986
  ...r,
7852
7987
  oauthServiceUrl: s.oauthServiceUrl,
7853
7988
  authApiUrl: s.authApiUrl,
@@ -7855,17 +7990,23 @@ function Qn(r, e) {
7855
7990
  }, n = {
7856
7991
  gatewayUrl: s.walletGatewayUrl,
7857
7992
  projectId: r.projectId
7858
- }, i = t.authMode !== "cookie" && Nt.isAvailable() ? new Nt() : new sr(), a = new un(), c = new fn(), l = new be(), d = new Yn(), h = new Xt();
7993
+ }, o = t.authMode !== "cookie" && Ct.isAvailable();
7994
+ !o && t.authMode !== "cookie" && u.warn(
7995
+ "[CROSSx] IndexedDB 사용 불가 — LocalStorage fallback 사용 중.",
7996
+ "refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
7997
+ "IndexedDB를 지원하는 브라우저 사용을 권장합니다."
7998
+ ), t.secureStorageAvailable = o;
7999
+ const i = o ? new Ct(r.projectId) : new sr(), a = new un(), c = new _n(), l = new ye(), d = new Zn(), h = new Qt();
7859
8000
  let m;
7860
- r.useMockWallet ? (u.log("[CROSSx] Mock Wallet Provider 사용"), m = new _n(i, h)) : (u.log("[CROSSx] Remote Wallet Provider 사용"), m = new Le(
8001
+ r.useMockWallet ? (u.log("[CROSSx] Mock Wallet Provider 사용"), m = new gn(i, h)) : (u.log("[CROSSx] Remote Wallet Provider 사용"), m = new Oe(
7861
8002
  n,
7862
8003
  i,
7863
8004
  c,
7864
8005
  d,
7865
8006
  h
7866
8007
  ));
7867
- const x = new De(n, c), w = new jn(r.theme ?? "light", r.themeTokens), E = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w;
7868
- return new it(
8008
+ const x = new Le(n, c), w = new Jn(r.theme ?? "light", r.themeTokens), E = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w;
8009
+ return new ot(
7869
8010
  t,
7870
8011
  n,
7871
8012
  i,
@@ -7881,9 +8022,9 @@ function Qn(r, e) {
7881
8022
  }
7882
8023
  export {
7883
8024
  g as CROSSxError,
7884
- $s as CROSSxEthereumProvider,
7885
- it as CROSSxSDK,
7886
- Xn as ChainId,
8025
+ Hs as CROSSxEthereumProvider,
8026
+ ot as CROSSxSDK,
8027
+ eo as ChainId,
7887
8028
  p as ErrorCode,
7888
- Qn as createCROSSxSDK
8029
+ to as createCROSSxSDK
7889
8030
  };