@nexus-cross/crossx-sdk-core 1.3.6 → 1.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -65,7 +65,7 @@ const Ve = {
65
65
  rpcUrl: "https://saigon-testnet.roninchain.com/rpc",
66
66
  testnet: !0
67
67
  }
68
- }, oo = Object.fromEntries(
68
+ }, io = Object.fromEntries(
69
69
  Object.entries(Ve).map(([r, e]) => [r, e.caipId])
70
70
  ), Us = new Map(
71
71
  Object.values(Ve).map((r) => [r.caipId, r])
@@ -167,26 +167,34 @@ class Fs {
167
167
  };
168
168
  }
169
169
  }
170
- let Se = null;
170
+ let _e = null;
171
171
  function vt(r) {
172
- Se = r;
172
+ _e = r;
173
173
  }
174
174
  const d = {
175
+ /** 빌드 모드와 무관하게 항상 출력되는 정보성 로그 (SDK 수명주기 등) */
176
+ info(...r) {
177
+ if (_e) {
178
+ _e.log(...r);
179
+ return;
180
+ }
181
+ console.log(...r);
182
+ },
175
183
  log(...r) {
176
- if (Se) {
177
- Se.log(...r);
184
+ if (_e) {
185
+ _e.log(...r);
178
186
  return;
179
187
  }
180
188
  },
181
189
  warn(...r) {
182
- if (Se) {
183
- Se.warn(...r);
190
+ if (_e) {
191
+ _e.warn(...r);
184
192
  return;
185
193
  }
186
194
  },
187
195
  error(...r) {
188
- if (Se) {
189
- Se.error(...r);
196
+ if (_e) {
197
+ _e.error(...r);
190
198
  return;
191
199
  }
192
200
  }
@@ -331,7 +339,7 @@ const d = {
331
339
  function St(r = "en", e) {
332
340
  return Ws[r] ?? Qt;
333
341
  }
334
- const Et = "crossx_access_token", It = "crossx_refresh_token", At = "crossx_user_info";
342
+ const Et = "crossx_access_token", It = "crossx_refresh_token", Tt = "crossx_user_info";
335
343
  class qs {
336
344
  constructor(e, s, t, n, o, i, a) {
337
345
  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;
@@ -402,12 +410,12 @@ class qs {
402
410
  let s, t = !1;
403
411
  try {
404
412
  const { authApiUrl: c } = this.config, { accessToken: l, refreshToken: u } = await this.exchangeFirebaseToken(e, c);
405
- let h, x;
413
+ let h, _;
406
414
  try {
407
415
  const w = this.crypto.decodeJWT(e);
408
- x = (n = w.firebase) == null ? void 0 : n.sign_in_provider;
416
+ _ = (n = w.firebase) == null ? void 0 : n.sign_in_provider;
409
417
  const b = ((o = w.firebase) == null ? void 0 : o.identities) ?? {};
410
- x === "google.com" ? h = (i = b["google.com"]) == null ? void 0 : i[0] : x === "apple.com" && (h = (a = b["apple.com"]) == null ? void 0 : a[0]), d.log("[CROSSx] OAuth provider sub 추출 — provider:", x, "hasProviderSub:", !!h);
418
+ _ === "google.com" ? h = (i = b["google.com"]) == null ? void 0 : i[0] : _ === "apple.com" && (h = (a = b["apple.com"]) == null ? void 0 : a[0]), d.log("[CROSSx] OAuth provider sub 추출 — provider:", _, "hasProviderSub:", !!h);
411
419
  } catch {
412
420
  d.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
413
421
  }
@@ -421,7 +429,7 @@ class qs {
421
429
  s = {
422
430
  id: y.sub,
423
431
  email: y.email,
424
- signInProvider: x,
432
+ signInProvider: _,
425
433
  providerSub: h
426
434
  }, this.tokenStore.set(l), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, l), u && this.config.secureStorageAvailable !== !1 ? await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, u) : u && d.warn("[CROSSx] 안전한 스토리지 미사용 — refresh_token 영속 저장을 건너뜁니다"));
427
435
  } else {
@@ -429,7 +437,7 @@ class qs {
429
437
  s = {
430
438
  id: w.sub,
431
439
  email: w.email,
432
- signInProvider: x,
440
+ signInProvider: _,
433
441
  providerSub: h
434
442
  }, d.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
435
443
  }
@@ -602,6 +610,24 @@ class qs {
602
610
  }
603
611
  return d.log("[CROSSx] silentRefresh 성공"), c;
604
612
  }
613
+ /**
614
+ * access_token을 자동 갱신합니다.
615
+ *
616
+ * Gateway 요청 전 토큰이 만료되었거나 곧 만료될 때 호출됩니다.
617
+ * 내부적으로 silentRefresh를 실행하고, 새 토큰을 TokenMemoryStore에 저장합니다.
618
+ *
619
+ * @returns 갱신 성공 시 true, 실패 시 false
620
+ */
621
+ async refreshAccessToken() {
622
+ try {
623
+ if (this.useCookieAuth)
624
+ return !!await this.silentRefresh() || this.tokenStore.has();
625
+ const e = await this.storage.get(this.STORAGE_KEY_REFRESH_TOKEN);
626
+ return e ? !!await this.silentRefresh(e) : (d.warn("[CROSSx] refreshAccessToken: refresh_token 없음 — 갱신 불가"), !1);
627
+ } catch (e) {
628
+ return d.warn("[CROSSx] refreshAccessToken 실패:", e), !1;
629
+ }
630
+ }
605
631
  /**
606
632
  * 외부에서 발급된 CROSSx JWT를 직접 주입하여 로그인합니다.
607
633
  *
@@ -647,13 +673,13 @@ class qs {
647
673
  if (!this._migrated) {
648
674
  this._migrated = !0;
649
675
  try {
650
- const e = await this.storage.get(At);
676
+ const e = await this.storage.get(Tt);
651
677
  if (!e || await this.storage.get(this.STORAGE_KEY_USER)) return;
652
678
  await this.storage.set(this.STORAGE_KEY_USER, e);
653
679
  const t = await this.storage.get(Et);
654
680
  t && await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, t);
655
681
  const n = await this.storage.get(It);
656
- n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(At), await this.storage.remove(Et), await this.storage.remove(It), d.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
682
+ n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(Tt), await this.storage.remove(Et), await this.storage.remove(It), d.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
657
683
  } catch (e) {
658
684
  d.warn("[CROSSx] 스토리지 키 마이그레이션 실패:", e);
659
685
  }
@@ -848,10 +874,10 @@ function Js() {
848
874
  }
849
875
  return Ge.production;
850
876
  }
851
- const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA00", kt = 130, Pt = 6, Ot = 18, tr = 5 * 60 * 1e3, sr = 30 * 1e3, re = class re extends js {
877
+ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA00", kt = 130, Pt = 6, Ot = 18, tr = 3e4, sr = 5 * 60 * 1e3, rr = 30 * 1e3, re = class re extends js {
852
878
  constructor(e, s, t, n, o, i, a, c, l, u, h) {
853
- var x;
854
- 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 es(), this.chainRegistry = u, this.jsonRpc = new zs(u, o), this.signInUseCase = new qs(
879
+ var _, f;
880
+ 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._themeMediaCleanup = null, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && vt(e.logger), this.confirmation = l, this.pinStore = h ?? new es(), this.chainRegistry = u, this.jsonRpc = new zs(u, o), this.signInUseCase = new qs(
855
881
  this.internalConfig,
856
882
  t,
857
883
  n,
@@ -859,7 +885,10 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
859
885
  o,
860
886
  a,
861
887
  c
862
- ), this.signOutUseCase = new Ks(this.internalConfig, t, c), this.migrateWalletUseCase = new Vs(t, a), (x = a.setOnUnauthorized) == null || x.call(a, () => this.forceLogout());
888
+ ), this.signOutUseCase = new Ks(this.internalConfig, t, c), this.migrateWalletUseCase = new Vs(t, a), (_ = a.setOnUnauthorized) == null || _.call(a, () => this.forceLogout()), (f = a.setTokenRefresher) == null || f.call(
889
+ a,
890
+ () => this.signInUseCase.refreshAccessToken()
891
+ ), e.autoDetectTheme && this._setupAutoDetectTheme();
863
892
  }
864
893
  get config() {
865
894
  return this._config;
@@ -885,7 +914,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
885
914
  }
886
915
  async _doInitialize(e) {
887
916
  var s, t;
888
- d.log("[CROSSx SDK] v1.3.6 초기화 중..."), this.confirmation.setMessages(St(this._config.locale));
917
+ d.log("[CROSSx SDK] v1.3.8 초기화 중..."), this.confirmation.setMessages(St(this._config.locale));
889
918
  try {
890
919
  const n = Js();
891
920
  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`);
@@ -900,7 +929,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
900
929
  d.log("[CROSSx] initialize: 비밀번호 입력 취소 — 지갑 미로드 상태로 계속");
901
930
  }
902
931
  }
903
- return this.initialized = !0, this.emit("initialized", { restored: !!(o != null && o.success) }), o ?? null;
932
+ return this.initialized = !0, d.info("[CROSSx SDK] v1.3.8 초기화 완료"), this.emit("initialized", { restored: !!(o != null && o.success) }), o ?? null;
904
933
  } catch (n) {
905
934
  throw new m(p.AUTH_NOT_INITIALIZED, "SDK 초기화에 실패했습니다", n);
906
935
  }
@@ -1269,6 +1298,20 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1269
1298
  // ============================================================================
1270
1299
  // 테마
1271
1300
  // ============================================================================
1301
+ /**
1302
+ * `prefers-color-scheme` 미디어 쿼리를 감시하여
1303
+ * 시스템 다크모드 변경 시 자동으로 테마를 전환합니다.
1304
+ */
1305
+ _setupAutoDetectTheme() {
1306
+ if (typeof window > "u" || !window.matchMedia) return;
1307
+ const e = window.matchMedia("(prefers-color-scheme: dark)"), s = (n) => {
1308
+ const o = n ? "dark" : "light";
1309
+ this.applyTheme(o, this._config.themeTokens ?? {});
1310
+ };
1311
+ s(e.matches);
1312
+ const t = (n) => s(n.matches);
1313
+ e.addEventListener("change", t), this._themeMediaCleanup = () => e.removeEventListener("change", t);
1314
+ }
1272
1315
  /**
1273
1316
  * 컨펌 모달 테마를 런타임에 변경합니다.
1274
1317
  * 다음 모달이 열릴 때부터 적용됩니다.
@@ -1630,7 +1673,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1630
1673
  * @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
1631
1674
  */
1632
1675
  async waitForTxAndGetReceipt(e, s, t = {}) {
1633
- const n = t.intervalMs ?? Zs, o = Qs, i = t.timeoutMs ?? Tt, a = Date.now() + i;
1676
+ const n = t.intervalMs ?? Zs, o = Qs, i = t.timeoutMs ?? At, a = Date.now() + i;
1634
1677
  let c = n;
1635
1678
  for (; Date.now() < a; ) {
1636
1679
  const l = await this.getTransactionReceipt(e, s);
@@ -1659,23 +1702,23 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1659
1702
  */
1660
1703
  async sendTransactionWithWaitForReceipt(e, s, t = {}) {
1661
1704
  var b, y;
1662
- const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((b = this._config.receiptPolling) == null ? void 0 : b.intervalMs) ?? Xs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? Tt, u = Je(e), h = s.from ?? "";
1663
- let x, f;
1664
- const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((k) => {
1665
- x = k;
1666
- const C = BigInt(k.gasUsed) * BigInt(k.effectiveGasPrice), W = s.value ? BigInt(s.value) : 0n, B = re.formatTxAmount(s.value, u.symbol, u.decimals), j = re.formatTxAmount("0x" + C.toString(16), u.symbol, u.decimals), q = re.formatTxAmount("0x" + (W + C).toString(16), u.symbol, u.decimals);
1705
+ const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((b = this._config.receiptPolling) == null ? void 0 : b.intervalMs) ?? Xs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? At, u = Je(e), h = s.from ?? "";
1706
+ let _, f;
1707
+ const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((T) => {
1708
+ _ = T;
1709
+ const N = BigInt(T.gasUsed) * BigInt(T.effectiveGasPrice), W = s.value ? BigInt(s.value) : 0n, B = re.formatTxAmount(s.value, u.symbol, u.decimals), j = re.formatTxAmount("0x" + N.toString(16), u.symbol, u.decimals), q = re.formatTxAmount("0x" + (W + N).toString(16), u.symbol, u.decimals);
1667
1710
  return {
1668
1711
  chainId: e,
1669
1712
  txHash: a,
1670
- from: k.from,
1671
- to: k.to ?? s.to,
1713
+ from: T.from,
1714
+ to: T.to ?? s.to,
1672
1715
  amount: B,
1673
1716
  fees: j,
1674
1717
  total: q,
1675
1718
  nativeSymbol: u.symbol,
1676
- status: k.status === "0x1" ? "success" : "reverted"
1719
+ status: T.status === "0x1" ? "success" : "reverted"
1677
1720
  };
1678
- }).catch((k) => (f = k instanceof Error ? k : new Error(String(k)), {
1721
+ }).catch((T) => (f = T instanceof Error ? T : new Error(String(T)), {
1679
1722
  chainId: e,
1680
1723
  txHash: a,
1681
1724
  from: h,
@@ -1688,7 +1731,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1688
1731
  { chainId: e, txHash: a, from: h, to: s.to },
1689
1732
  w
1690
1733
  ), f) throw f;
1691
- return { chainId: e, txHash: a, receipt: x };
1734
+ return { chainId: e, txHash: a, receipt: _ };
1692
1735
  }
1693
1736
  // ============================================================================
1694
1737
  // PIN 관리 (공개 API)
@@ -1963,31 +2006,31 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1963
2006
  return d.log("[CROSSx][Migration Phase 4] 사용자가 PIN 입력을 취소함 → 종료"), null;
1964
2007
  d.log("[CROSSx][Migration Phase 4] PIN 입력 완료 — verify-recovery-pin API 호출"), n = void 0;
1965
2008
  try {
1966
- const x = await ((u = (l = this.walletProvider).verifyRecoveryPin) == null ? void 0 : u.call(l, h, e));
1967
- if (!x) {
2009
+ const _ = await ((u = (l = this.walletProvider).verifyRecoveryPin) == null ? void 0 : u.call(l, h, e));
2010
+ if (!_) {
1968
2011
  d.log("[CROSSx][Migration Phase 4] verifyRecoveryPin 미지원 — PIN 검증 생략"), a = h;
1969
2012
  break;
1970
2013
  }
1971
- if (x.valid) {
2014
+ if (_.valid) {
1972
2015
  d.log("[CROSSx][Migration Phase 4] PIN 검증 성공"), a = h;
1973
2016
  break;
1974
2017
  }
1975
- const f = x.pinStatus;
2018
+ const f = _.pinStatus;
1976
2019
  if (i = f.maxAttempts, o = i - f.remainingAttempts, f.remainingAttempts === 0 && f.lockExpiresAt) {
1977
2020
  const w = f.lockExpiresAt * 1e3, b = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = b <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
1978
2021
  d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${b}초, 메시지: ${y}`), await this.confirmation.showRecoveryPinLockedPrompt(b, y), o = 0, n = "Your account lock has been lifted. You may try again.";
1979
2022
  } else
1980
2023
  d.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 ${o}/${i})`), n = "Incorrect PIN.";
1981
- } catch (x) {
1982
- if (!(x instanceof m)) throw x;
1983
- if (x.code === p.MIGRATION_PIN_LOCKED) {
1984
- const f = x.details;
2024
+ } catch (_) {
2025
+ if (!(_ instanceof m)) throw _;
2026
+ if (_.code === p.MIGRATION_PIN_LOCKED) {
2027
+ const f = _.details;
1985
2028
  if (i = (f == null ? void 0 : f.maxAttempts) ?? 5, (f == null ? void 0 : f.permanent) === !0)
1986
2029
  return d.warn("[CROSSx][Migration Phase 4] PIN 영구 잠금 (verify-recovery-pin)"), await this.confirmation.showRecoveryPinLockedPrompt(0, "Your account has been permanently locked due to too many failed attempts."), null;
1987
2030
  const w = ((f == null ? void 0 : f.lockExpiresAt) ?? 0) * 1e3, b = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = b <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
1988
2031
  d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${b}초`), await this.confirmation.showRecoveryPinLockedPrompt(b, y), o = 0, n = "Your account lock has been lifted. You may try again.";
1989
2032
  } else
1990
- throw d.error("[CROSSx][Migration Phase 4] verify-recovery-pin 실패 (복구 불가):", x), x;
2033
+ throw d.error("[CROSSx][Migration Phase 4] verify-recovery-pin 실패 (복구 불가):", _), _;
1991
2034
  }
1992
2035
  }
1993
2036
  d.log("[CROSSx][Migration Phase 5] PIN 검증 완료 — 비밀번호 설정 및 마이그레이션 진행");
@@ -2018,13 +2061,13 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2018
2061
  if (!n && !o && !i && !a) return e;
2019
2062
  const c = { ...e }, l = n ? c.from ?? this.address : void 0;
2020
2063
  l && d.log("[CROSSx] nonce 비어있음 → eth_getTransactionCount 호출 (from:", l, ")"), o && d.log("[CROSSx] gasLimit 비어있음 → eth_estimateGas 호출"), i && d.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
2021
- const [u, h, x] = await Promise.all([
2064
+ const [u, h, _] = await Promise.all([
2022
2065
  l ? this.jsonRpc.call("eth_getTransactionCount", [l, "pending"], s) : null,
2023
2066
  o ? this.estimateGas(e, s) : null,
2024
2067
  i ? this.getBaseFeePerGas(s) : null
2025
2068
  ]);
2026
2069
  if (l && (c.nonce = parseInt(u ?? "0x0", 16), d.log("[CROSSx] nonce 결과:", c.nonce)), o && (c.gasLimit = h, d.log("[CROSSx] estimateGas 결과:", c.gasLimit)), i) {
2027
- const f = x;
2070
+ const f = _;
2028
2071
  if (f) {
2029
2072
  const w = Rt;
2030
2073
  c.maxFeePerGas = "0x" + (BigInt(f) + BigInt(w)).toString(16), c.maxPriorityFeePerGas = w, d.log("[CROSSx] Dynamic 체인 감지 — baseFee:", f, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
@@ -2353,7 +2396,8 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2353
2396
  * dispose 후 SDK 인스턴스는 더 이상 사용할 수 없습니다.
2354
2397
  */
2355
2398
  dispose() {
2356
- this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), vt(null);
2399
+ var e;
2400
+ (e = this._themeMediaCleanup) == null || e.call(this), this._themeMediaCleanup = null, this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), vt(null);
2357
2401
  }
2358
2402
  /**
2359
2403
  * @internal internal 패키지 전용 — 공개 문서에 기재하지 않음
@@ -2375,7 +2419,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2375
2419
  };
2376
2420
  re.OFFCHAIN_CHAIN_ID = "0";
2377
2421
  let it = re;
2378
- class rr {
2422
+ class nr {
2379
2423
  constructor() {
2380
2424
  this.prefix = "crossx_";
2381
2425
  }
@@ -2412,8 +2456,8 @@ class rr {
2412
2456
  }
2413
2457
  }
2414
2458
  }
2415
- const Xe = "crossx-sdk", nr = 1, de = "data", ve = "keys", $e = "aes-primary", or = 12;
2416
- class Nt {
2459
+ const Xe = "crossx-sdk", or = 1, de = "data", Se = "keys", $e = "aes-primary", ir = 12;
2460
+ class Ct {
2417
2461
  constructor(e) {
2418
2462
  this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
2419
2463
  }
@@ -2422,10 +2466,10 @@ class Nt {
2422
2466
  }
2423
2467
  openDB(e = this.dbName) {
2424
2468
  return new Promise((s, t) => {
2425
- const n = indexedDB.open(e, nr);
2469
+ const n = indexedDB.open(e, or);
2426
2470
  n.onupgradeneeded = () => {
2427
2471
  const o = n.result;
2428
- o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(ve) || o.createObjectStore(ve);
2472
+ o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(Se) || o.createObjectStore(Se);
2429
2473
  }, n.onsuccess = () => s(n.result), n.onerror = () => t(n.error);
2430
2474
  });
2431
2475
  }
@@ -2455,7 +2499,7 @@ class Nt {
2455
2499
  }
2456
2500
  async init() {
2457
2501
  this.db = await this.openDB();
2458
- const e = await this.idbGet(ve, $e);
2502
+ const e = await this.idbGet(Se, $e);
2459
2503
  if (e) {
2460
2504
  this.cryptoKey = e;
2461
2505
  return;
@@ -2469,7 +2513,7 @@ class Nt {
2469
2513
  { name: "AES-GCM", length: 256 },
2470
2514
  !1,
2471
2515
  ["encrypt", "decrypt"]
2472
- ), await this.idbPut(ve, $e, this.cryptoKey);
2516
+ ), await this.idbPut(Se, $e, this.cryptoKey);
2473
2517
  }
2474
2518
  /**
2475
2519
  * 레거시 DB('crossx-sdk')에서 projectId 스코프 DB로 암호키·데이터 마이그레이션.
@@ -2478,7 +2522,7 @@ class Nt {
2478
2522
  async migrateFromLegacyDB() {
2479
2523
  if (this.dbName === Xe) return null;
2480
2524
  try {
2481
- const e = await this.openDB(Xe), s = e.transaction([ve, de], "readonly"), t = s.objectStore(ve).get($e), n = await new Promise((l, u) => {
2525
+ const e = await this.openDB(Xe), s = e.transaction([Se, de], "readonly"), t = s.objectStore(Se).get($e), n = await new Promise((l, u) => {
2482
2526
  t.onsuccess = () => l(t.result), t.onerror = () => u(t.error);
2483
2527
  });
2484
2528
  if (!n)
@@ -2491,7 +2535,7 @@ class Nt {
2491
2535
  i.onsuccess = () => l(i.result), i.onerror = () => u(i.error);
2492
2536
  })
2493
2537
  ]);
2494
- e.close(), await this.idbPut(ve, $e, n);
2538
+ e.close(), await this.idbPut(Se, $e, n);
2495
2539
  for (let l = 0; l < c.length; l++)
2496
2540
  await this.idbPut(de, String(c[l]), a[l]);
2497
2541
  return indexedDB.deleteDatabase(Xe), d.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), n;
@@ -2500,7 +2544,7 @@ class Nt {
2500
2544
  }
2501
2545
  }
2502
2546
  async encrypt(e) {
2503
- const s = new Uint8Array(or);
2547
+ const s = new Uint8Array(ir);
2504
2548
  crypto.getRandomValues(s);
2505
2549
  const t = new TextEncoder().encode(e), n = await crypto.subtle.encrypt(
2506
2550
  { name: "AES-GCM", iv: s },
@@ -2562,7 +2606,7 @@ class Nt {
2562
2606
  function ut(r) {
2563
2607
  return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
2564
2608
  }
2565
- function ge(r, e = "") {
2609
+ function me(r, e = "") {
2566
2610
  if (!Number.isSafeInteger(r) || r < 0) {
2567
2611
  const s = e && `"${e}" `;
2568
2612
  throw new Error(`${s}expected integer >= 0, got ${r}`);
@@ -2579,7 +2623,7 @@ function V(r, e, s = "") {
2579
2623
  function ts(r) {
2580
2624
  if (typeof r != "function" || typeof r.create != "function")
2581
2625
  throw new Error("Hash must wrapped by utils.createHasher");
2582
- ge(r.outputLen), ge(r.blockLen);
2626
+ me(r.outputLen), me(r.blockLen);
2583
2627
  }
2584
2628
  function ke(r, e = !0) {
2585
2629
  if (r.destroyed)
@@ -2593,7 +2637,7 @@ function ss(r, e) {
2593
2637
  if (r.length < s)
2594
2638
  throw new Error('"digestInto() output" expected to be of length >=' + s);
2595
2639
  }
2596
- function ir(r) {
2640
+ function ar(r) {
2597
2641
  return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
2598
2642
  }
2599
2643
  function Pe(...r) {
@@ -2606,22 +2650,22 @@ function Ze(r) {
2606
2650
  function ue(r, e) {
2607
2651
  return r << 32 - e | r >>> e;
2608
2652
  }
2609
- const ar = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2610
- function cr(r) {
2653
+ const cr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2654
+ function lr(r) {
2611
2655
  return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
2612
2656
  }
2613
- function lr(r) {
2657
+ function dr(r) {
2614
2658
  for (let e = 0; e < r.length; e++)
2615
- r[e] = cr(r[e]);
2659
+ r[e] = lr(r[e]);
2616
2660
  return r;
2617
2661
  }
2618
- const Ct = ar ? (r) => r : lr, rs = /* @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"));
2662
+ const Nt = cr ? (r) => r : dr, rs = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", ur = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
2619
2663
  function Me(r) {
2620
2664
  if (V(r), rs)
2621
2665
  return r.toHex();
2622
2666
  let e = "";
2623
2667
  for (let s = 0; s < r.length; s++)
2624
- e += dr[r[s]];
2668
+ e += ur[r[s]];
2625
2669
  return e;
2626
2670
  }
2627
2671
  const fe = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
@@ -2652,7 +2696,7 @@ function We(r) {
2652
2696
  }
2653
2697
  return t;
2654
2698
  }
2655
- function be(...r) {
2699
+ function ve(...r) {
2656
2700
  let e = 0;
2657
2701
  for (let t = 0; t < r.length; t++) {
2658
2702
  const n = r[t];
@@ -2675,16 +2719,16 @@ function os(r = 32) {
2675
2719
  throw new Error("crypto.getRandomValues must be defined");
2676
2720
  return e.getRandomValues(new Uint8Array(r));
2677
2721
  }
2678
- const ur = (r) => ({
2722
+ const hr = (r) => ({
2679
2723
  oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, r])
2680
2724
  });
2681
- function hr(r, e, s) {
2725
+ function pr(r, e, s) {
2682
2726
  return r & e ^ ~r & s;
2683
2727
  }
2684
- function pr(r, e, s) {
2728
+ function fr(r, e, s) {
2685
2729
  return r & e ^ r & s ^ e & s;
2686
2730
  }
2687
- class fr {
2731
+ class _r {
2688
2732
  constructor(e, s, t, n) {
2689
2733
  E(this, "blockLen");
2690
2734
  E(this, "outputLen");
@@ -2746,7 +2790,7 @@ class fr {
2746
2790
  return this._cloneInto();
2747
2791
  }
2748
2792
  }
2749
- const me = /* @__PURE__ */ Uint32Array.from([
2793
+ const we = /* @__PURE__ */ Uint32Array.from([
2750
2794
  1779033703,
2751
2795
  3144134277,
2752
2796
  1013904242,
@@ -2756,19 +2800,19 @@ const me = /* @__PURE__ */ Uint32Array.from([
2756
2800
  528734635,
2757
2801
  1541459225
2758
2802
  ]), Be = /* @__PURE__ */ BigInt(2 ** 32 - 1), Dt = /* @__PURE__ */ BigInt(32);
2759
- function _r(r, e = !1) {
2803
+ function xr(r, e = !1) {
2760
2804
  return e ? { h: Number(r & Be), l: Number(r >> Dt & Be) } : { h: Number(r >> Dt & Be) | 0, l: Number(r & Be) | 0 };
2761
2805
  }
2762
- function xr(r, e = !1) {
2806
+ function gr(r, e = !1) {
2763
2807
  const s = r.length;
2764
2808
  let t = new Uint32Array(s), n = new Uint32Array(s);
2765
2809
  for (let o = 0; o < s; o++) {
2766
- const { h: i, l: a } = _r(r[o], e);
2810
+ const { h: i, l: a } = xr(r[o], e);
2767
2811
  [t[o], n[o]] = [i, a];
2768
2812
  }
2769
2813
  return [t, n];
2770
2814
  }
2771
- 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([
2815
+ const mr = (r, e, s) => r << s | e >>> 32 - s, wr = (r, e, s) => e << s | r >>> 32 - s, yr = (r, e, s) => e << s - 32 | r >>> 64 - s, br = (r, e, s) => r << s - 32 | e >>> 64 - s, vr = /* @__PURE__ */ Uint32Array.from([
2772
2816
  1116352408,
2773
2817
  1899447441,
2774
2818
  3049323471,
@@ -2833,8 +2877,8 @@ const gr = (r, e, s) => r << s | e >>> 32 - s, mr = (r, e, s) => e << s | r >>>
2833
2877
  2756734187,
2834
2878
  3204031479,
2835
2879
  3329325298
2836
- ]), we = /* @__PURE__ */ new Uint32Array(64);
2837
- class vr extends fr {
2880
+ ]), ye = /* @__PURE__ */ new Uint32Array(64);
2881
+ class Sr extends _r {
2838
2882
  constructor(e) {
2839
2883
  super(64, e, 8, !1);
2840
2884
  }
@@ -2848,43 +2892,43 @@ class vr extends fr {
2848
2892
  }
2849
2893
  process(e, s) {
2850
2894
  for (let h = 0; h < 16; h++, s += 4)
2851
- we[h] = e.getUint32(s, !1);
2895
+ ye[h] = e.getUint32(s, !1);
2852
2896
  for (let h = 16; h < 64; h++) {
2853
- const x = we[h - 15], f = we[h - 2], w = ue(x, 7) ^ ue(x, 18) ^ x >>> 3, b = ue(f, 17) ^ ue(f, 19) ^ f >>> 10;
2854
- we[h] = b + we[h - 7] + w + we[h - 16] | 0;
2897
+ const _ = ye[h - 15], f = ye[h - 2], w = ue(_, 7) ^ ue(_, 18) ^ _ >>> 3, b = ue(f, 17) ^ ue(f, 19) ^ f >>> 10;
2898
+ ye[h] = b + ye[h - 7] + w + ye[h - 16] | 0;
2855
2899
  }
2856
2900
  let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: u } = this;
2857
2901
  for (let h = 0; h < 64; h++) {
2858
- const x = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), f = u + x + hr(a, c, l) + br[h] + we[h] | 0, b = (ue(t, 2) ^ ue(t, 13) ^ ue(t, 22)) + pr(t, n, o) | 0;
2902
+ const _ = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), f = u + _ + pr(a, c, l) + vr[h] + ye[h] | 0, b = (ue(t, 2) ^ ue(t, 13) ^ ue(t, 22)) + fr(t, n, o) | 0;
2859
2903
  u = l, l = c, c = a, a = i + f | 0, i = o, o = n, n = t, t = f + b | 0;
2860
2904
  }
2861
2905
  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, u = u + this.H | 0, this.set(t, n, o, i, a, c, l, u);
2862
2906
  }
2863
2907
  roundClean() {
2864
- Pe(we);
2908
+ Pe(ye);
2865
2909
  }
2866
2910
  destroy() {
2867
2911
  this.set(0, 0, 0, 0, 0, 0, 0, 0), Pe(this.buffer);
2868
2912
  }
2869
2913
  }
2870
- class Sr extends vr {
2914
+ class Er extends Sr {
2871
2915
  constructor() {
2872
2916
  super(32);
2873
2917
  // We cannot use array here since array allows indexing by variable
2874
2918
  // which means optimizer/compiler cannot use registers.
2875
- E(this, "A", me[0] | 0);
2876
- E(this, "B", me[1] | 0);
2877
- E(this, "C", me[2] | 0);
2878
- E(this, "D", me[3] | 0);
2879
- E(this, "E", me[4] | 0);
2880
- E(this, "F", me[5] | 0);
2881
- E(this, "G", me[6] | 0);
2882
- E(this, "H", me[7] | 0);
2883
- }
2884
- }
2885
- const Er = /* @__PURE__ */ ns(
2886
- () => new Sr(),
2887
- /* @__PURE__ */ ur(1)
2919
+ E(this, "A", we[0] | 0);
2920
+ E(this, "B", we[1] | 0);
2921
+ E(this, "C", we[2] | 0);
2922
+ E(this, "D", we[3] | 0);
2923
+ E(this, "E", we[4] | 0);
2924
+ E(this, "F", we[5] | 0);
2925
+ E(this, "G", we[6] | 0);
2926
+ E(this, "H", we[7] | 0);
2927
+ }
2928
+ }
2929
+ const Ir = /* @__PURE__ */ ns(
2930
+ () => new Er(),
2931
+ /* @__PURE__ */ hr(1)
2888
2932
  );
2889
2933
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2890
2934
  const ht = /* @__PURE__ */ BigInt(0), at = /* @__PURE__ */ BigInt(1);
@@ -2900,7 +2944,7 @@ function is(r) {
2900
2944
  if (!Fe(r))
2901
2945
  throw new Error("positive bigint expected, got " + r);
2902
2946
  } else
2903
- ge(r);
2947
+ me(r);
2904
2948
  return r;
2905
2949
  }
2906
2950
  function Ue(r) {
@@ -2916,10 +2960,10 @@ function ze(r) {
2916
2960
  return as(Me(r));
2917
2961
  }
2918
2962
  function cs(r) {
2919
- return as(Me(Ir(V(r)).reverse()));
2963
+ return as(Me(Tr(V(r)).reverse()));
2920
2964
  }
2921
2965
  function pt(r, e) {
2922
- ge(e), r = is(r);
2966
+ me(e), r = is(r);
2923
2967
  const s = We(r.toString(16).padStart(e * 2, "0"));
2924
2968
  if (s.length !== e)
2925
2969
  throw new Error("number too large");
@@ -2928,51 +2972,51 @@ function pt(r, e) {
2928
2972
  function ls(r, e) {
2929
2973
  return pt(r, e).reverse();
2930
2974
  }
2931
- function Ir(r) {
2975
+ function Tr(r) {
2932
2976
  return Uint8Array.from(r);
2933
2977
  }
2934
2978
  const Fe = (r) => typeof r == "bigint" && ht <= r;
2935
2979
  function Ar(r, e, s) {
2936
2980
  return Fe(r) && Fe(e) && Fe(s) && e <= r && r < s;
2937
2981
  }
2938
- function Tr(r, e, s, t) {
2982
+ function Rr(r, e, s, t) {
2939
2983
  if (!Ar(e, s, t))
2940
2984
  throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
2941
2985
  }
2942
- function Rr(r) {
2986
+ function kr(r) {
2943
2987
  let e;
2944
2988
  for (e = 0; r > ht; r >>= at, e += 1)
2945
2989
  ;
2946
2990
  return e;
2947
2991
  }
2948
2992
  const ft = (r) => (at << BigInt(r)) - at;
2949
- function kr(r, e, s) {
2950
- if (ge(r, "hashLen"), ge(e, "qByteLen"), typeof s != "function")
2993
+ function Pr(r, e, s) {
2994
+ if (me(r, "hashLen"), me(e, "qByteLen"), typeof s != "function")
2951
2995
  throw new Error("hmacFn must be a function");
2952
2996
  const t = (y) => new Uint8Array(y), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
2953
2997
  let c = t(r), l = t(r), u = 0;
2954
2998
  const h = () => {
2955
2999
  c.fill(1), l.fill(0), u = 0;
2956
- }, x = (...y) => s(l, be(c, ...y)), f = (y = n) => {
2957
- l = x(o, y), c = x(), y.length !== 0 && (l = x(i, y), c = x());
3000
+ }, _ = (...y) => s(l, ve(c, ...y)), f = (y = n) => {
3001
+ l = _(o, y), c = _(), y.length !== 0 && (l = _(i, y), c = _());
2958
3002
  }, w = () => {
2959
3003
  if (u++ >= a)
2960
3004
  throw new Error("drbg: tried max amount of iterations");
2961
3005
  let y = 0;
2962
- const k = [];
3006
+ const T = [];
2963
3007
  for (; y < e; ) {
2964
- c = x();
2965
- const C = c.slice();
2966
- k.push(C), y += c.length;
3008
+ c = _();
3009
+ const N = c.slice();
3010
+ T.push(N), y += c.length;
2967
3011
  }
2968
- return be(...k);
3012
+ return ve(...T);
2969
3013
  };
2970
- return (y, k) => {
3014
+ return (y, T) => {
2971
3015
  h(), f(y);
2972
- let C;
2973
- for (; !(C = k(w())); )
3016
+ let N;
3017
+ for (; !(N = T(w())); )
2974
3018
  f();
2975
- return h(), C;
3019
+ return h(), N;
2976
3020
  };
2977
3021
  }
2978
3022
  function _t(r, e = {}, s = {}) {
@@ -3000,7 +3044,7 @@ function Mt(r) {
3000
3044
  };
3001
3045
  }
3002
3046
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3003
- const ne = /* @__PURE__ */ BigInt(0), ee = /* @__PURE__ */ BigInt(1), Ie = /* @__PURE__ */ BigInt(2), ds = /* @__PURE__ */ BigInt(3), us = /* @__PURE__ */ BigInt(4), hs = /* @__PURE__ */ BigInt(5), Pr = /* @__PURE__ */ BigInt(7), ps = /* @__PURE__ */ BigInt(8), Or = /* @__PURE__ */ BigInt(9), fs = /* @__PURE__ */ BigInt(16);
3047
+ const ne = /* @__PURE__ */ BigInt(0), ee = /* @__PURE__ */ BigInt(1), Ie = /* @__PURE__ */ BigInt(2), ds = /* @__PURE__ */ BigInt(3), us = /* @__PURE__ */ BigInt(4), hs = /* @__PURE__ */ BigInt(5), Or = /* @__PURE__ */ BigInt(7), ps = /* @__PURE__ */ BigInt(8), Cr = /* @__PURE__ */ BigInt(9), fs = /* @__PURE__ */ BigInt(16);
3004
3048
  function le(r, e) {
3005
3049
  const s = r % e;
3006
3050
  return s >= ne ? s : e + s;
@@ -3037,12 +3081,12 @@ function Nr(r, e) {
3037
3081
  const s = (r.ORDER - hs) / ps, t = r.mul(e, Ie), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, Ie), n), a = r.mul(o, r.sub(i, r.ONE));
3038
3082
  return xt(r, a, e), a;
3039
3083
  }
3040
- function Cr(r) {
3041
- const e = je(r), s = xs(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + Pr) / fs;
3084
+ function Lr(r) {
3085
+ const e = je(r), s = xs(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + Or) / fs;
3042
3086
  return (a, c) => {
3043
3087
  let l = a.pow(c, i), u = a.mul(l, t);
3044
- const h = a.mul(l, n), x = a.mul(l, o), f = a.eql(a.sqr(u), c), w = a.eql(a.sqr(h), c);
3045
- l = a.cmov(l, u, f), u = a.cmov(x, h, w);
3088
+ const h = a.mul(l, n), _ = a.mul(l, o), f = a.eql(a.sqr(u), c), w = a.eql(a.sqr(h), c);
3089
+ l = a.cmov(l, u, f), u = a.cmov(_, h, w);
3046
3090
  const b = a.eql(a.sqr(u), c), y = a.cmov(l, u, b);
3047
3091
  return xt(a, y, c), y;
3048
3092
  };
@@ -3067,24 +3111,24 @@ function xs(r) {
3067
3111
  return l;
3068
3112
  if (Bt(c, l) !== 1)
3069
3113
  throw new Error("Cannot find square root");
3070
- let u = s, h = c.mul(c.ONE, o), x = c.pow(l, e), f = c.pow(l, i);
3071
- for (; !c.eql(x, c.ONE); ) {
3072
- if (c.is0(x))
3114
+ let u = s, h = c.mul(c.ONE, o), _ = c.pow(l, e), f = c.pow(l, i);
3115
+ for (; !c.eql(_, c.ONE); ) {
3116
+ if (c.is0(_))
3073
3117
  return c.ZERO;
3074
- let w = 1, b = c.sqr(x);
3118
+ let w = 1, b = c.sqr(_);
3075
3119
  for (; !c.eql(b, c.ONE); )
3076
3120
  if (w++, b = c.sqr(b), w === u)
3077
3121
  throw new Error("Cannot find square root");
3078
- const y = ee << BigInt(u - w - 1), k = c.pow(h, y);
3079
- u = w, h = c.sqr(k), x = c.mul(x, h), f = c.mul(f, k);
3122
+ const y = ee << BigInt(u - w - 1), T = c.pow(h, y);
3123
+ u = w, h = c.sqr(T), _ = c.mul(_, h), f = c.mul(f, T);
3080
3124
  }
3081
3125
  return f;
3082
3126
  };
3083
3127
  }
3084
- function Lr(r) {
3085
- return r % us === ds ? _s : r % ps === hs ? Nr : r % fs === Or ? Cr(r) : xs(r);
3128
+ function Dr(r) {
3129
+ return r % us === ds ? _s : r % ps === hs ? Nr : r % fs === Cr ? Lr(r) : xs(r);
3086
3130
  }
3087
- const Dr = [
3131
+ const Mr = [
3088
3132
  "create",
3089
3133
  "isValid",
3090
3134
  "is0",
@@ -3103,15 +3147,15 @@ const Dr = [
3103
3147
  "mulN",
3104
3148
  "sqrN"
3105
3149
  ];
3106
- function Mr(r) {
3150
+ function $r(r) {
3107
3151
  const e = {
3108
3152
  ORDER: "bigint",
3109
3153
  BYTES: "number",
3110
3154
  BITS: "number"
3111
- }, s = Dr.reduce((t, n) => (t[n] = "function", t), e);
3155
+ }, s = Mr.reduce((t, n) => (t[n] = "function", t), e);
3112
3156
  return _t(r, s), r;
3113
3157
  }
3114
- function $r(r, e, s) {
3158
+ function Br(r, e, s) {
3115
3159
  if (s < ne)
3116
3160
  throw new Error("invalid exponent, negatives unsupported");
3117
3161
  if (s === ne)
@@ -3133,12 +3177,12 @@ function Bt(r, e) {
3133
3177
  throw new Error("invalid Legendre symbol result");
3134
3178
  return n ? 1 : o ? 0 : -1;
3135
3179
  }
3136
- function Br(r, e) {
3137
- e !== void 0 && ge(e);
3180
+ function Ur(r, e) {
3181
+ e !== void 0 && me(e);
3138
3182
  const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
3139
3183
  return { nBitLength: s, nByteLength: t };
3140
3184
  }
3141
- class Ur {
3185
+ class Hr {
3142
3186
  constructor(e, s = {}) {
3143
3187
  E(this, "ORDER");
3144
3188
  E(this, "BITS");
@@ -3155,7 +3199,7 @@ class Ur {
3155
3199
  throw new Error("invalid field: expected ORDER > 0, got " + e);
3156
3200
  let t;
3157
3201
  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));
3158
- const { nBitLength: n, nByteLength: o } = Br(e, t);
3202
+ const { nBitLength: n, nByteLength: o } = Ur(e, t);
3159
3203
  if (o > 2048)
3160
3204
  throw new Error("invalid field: expected ORDER of <= 2048 bytes");
3161
3205
  this.ORDER = e, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
@@ -3197,7 +3241,7 @@ class Ur {
3197
3241
  return le(e * s, this.ORDER);
3198
3242
  }
3199
3243
  pow(e, s) {
3200
- return $r(this, e, s);
3244
+ return Br(this, e, s);
3201
3245
  }
3202
3246
  div(e, s) {
3203
3247
  return le(e * $t(s, this.ORDER), this.ORDER);
@@ -3219,7 +3263,7 @@ class Ur {
3219
3263
  return $t(e, this.ORDER);
3220
3264
  }
3221
3265
  sqrt(e) {
3222
- return this._sqrt || (this._sqrt = Lr(this.ORDER)), this._sqrt(this, e);
3266
+ return this._sqrt || (this._sqrt = Dr(this.ORDER)), this._sqrt(this, e);
3223
3267
  }
3224
3268
  toBytes(e) {
3225
3269
  return this.isLE ? ls(e, this.BYTES) : pt(e, this.BYTES);
@@ -3251,7 +3295,7 @@ class Ur {
3251
3295
  }
3252
3296
  }
3253
3297
  function je(r, e = {}) {
3254
- return new Ur(r, e);
3298
+ return new Hr(r, e);
3255
3299
  }
3256
3300
  function ms(r) {
3257
3301
  if (typeof r != "bigint")
@@ -3263,7 +3307,7 @@ function ws(r) {
3263
3307
  const e = ms(r);
3264
3308
  return e + Math.ceil(e / 2);
3265
3309
  }
3266
- function Hr(r, e, s = !1) {
3310
+ function Fr(r, e, s = !1) {
3267
3311
  V(r);
3268
3312
  const t = r.length, n = ms(e), o = ws(e);
3269
3313
  if (t < 16 || t < o || t > 1024)
@@ -3272,7 +3316,7 @@ function Hr(r, e, s = !1) {
3272
3316
  return s ? ls(a, n) : pt(a, n);
3273
3317
  }
3274
3318
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3275
- const Oe = /* @__PURE__ */ BigInt(0), Ae = /* @__PURE__ */ BigInt(1);
3319
+ const Oe = /* @__PURE__ */ BigInt(0), Te = /* @__PURE__ */ BigInt(1);
3276
3320
  function Ke(r, e) {
3277
3321
  const s = e.negate();
3278
3322
  return r ? s : e;
@@ -3293,9 +3337,9 @@ function Qe(r, e) {
3293
3337
  function Ht(r, e, s) {
3294
3338
  const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
3295
3339
  let a = Number(r & n), c = r >> i;
3296
- a > t && (a -= o, c += Ae);
3297
- const l = e * t, u = l + Math.abs(a) - 1, h = a === 0, x = a < 0, f = e % 2 !== 0;
3298
- return { nextN: c, offset: u, isZero: h, isNeg: x, isNegF: f, offsetF: l };
3340
+ a > t && (a -= o, c += Te);
3341
+ const l = e * t, u = l + Math.abs(a) - 1, h = a === 0, _ = a < 0, f = e % 2 !== 0;
3342
+ return { nextN: c, offset: u, isZero: h, isNeg: _, isNegF: f, offsetF: l };
3299
3343
  }
3300
3344
  const et = /* @__PURE__ */ new WeakMap(), bs = /* @__PURE__ */ new WeakMap();
3301
3345
  function tt(r) {
@@ -3305,7 +3349,7 @@ function Ft(r) {
3305
3349
  if (r !== Oe)
3306
3350
  throw new Error("invalid wNAF");
3307
3351
  }
3308
- class Fr {
3352
+ class Gr {
3309
3353
  // Parametrized with a given Point class (not individual point)
3310
3354
  constructor(e, s) {
3311
3355
  E(this, "BASE");
@@ -3318,7 +3362,7 @@ class Fr {
3318
3362
  _unsafeLadder(e, s, t = this.ZERO) {
3319
3363
  let n = e;
3320
3364
  for (; s > Oe; )
3321
- s & Ae && (t = t.add(n)), n = n.double(), s >>= Ae;
3365
+ s & Te && (t = t.add(n)), n = n.double(), s >>= Te;
3322
3366
  return t;
3323
3367
  }
3324
3368
  /**
@@ -3356,8 +3400,8 @@ class Fr {
3356
3400
  let n = this.ZERO, o = this.BASE;
3357
3401
  const i = Qe(e, this.bits);
3358
3402
  for (let a = 0; a < i.windows; a++) {
3359
- const { nextN: c, offset: l, isZero: u, isNeg: h, isNegF: x, offsetF: f } = Ht(t, a, i);
3360
- t = c, u ? o = o.add(Ke(x, s[f])) : n = n.add(Ke(h, s[l]));
3403
+ const { nextN: c, offset: l, isZero: u, isNeg: h, isNegF: _, offsetF: f } = Ht(t, a, i);
3404
+ t = c, u ? o = o.add(Ke(_, s[f])) : n = n.add(Ke(h, s[l]));
3361
3405
  }
3362
3406
  return Ft(t), { p: n, f: o };
3363
3407
  }
@@ -3399,21 +3443,21 @@ class Fr {
3399
3443
  return tt(e) !== 1;
3400
3444
  }
3401
3445
  }
3402
- function Gr(r, e, s, t) {
3446
+ function Wr(r, e, s, t) {
3403
3447
  let n = e, o = r.ZERO, i = r.ZERO;
3404
3448
  for (; s > Oe || t > Oe; )
3405
- s & Ae && (o = o.add(n)), t & Ae && (i = i.add(n)), n = n.double(), s >>= Ae, t >>= Ae;
3449
+ s & Te && (o = o.add(n)), t & Te && (i = i.add(n)), n = n.double(), s >>= Te, t >>= Te;
3406
3450
  return { p1: o, p2: i };
3407
3451
  }
3408
3452
  function Gt(r, e, s) {
3409
3453
  if (e) {
3410
3454
  if (e.ORDER !== r)
3411
3455
  throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
3412
- return Mr(e), e;
3456
+ return $r(e), e;
3413
3457
  } else
3414
3458
  return je(r, { isLE: s });
3415
3459
  }
3416
- function Wr(r, e, s = {}, t) {
3460
+ function qr(r, e, s = {}, t) {
3417
3461
  if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
3418
3462
  throw new Error(`expected valid ${r} CURVE object`);
3419
3463
  for (const c of ["p", "n", "h"]) {
@@ -3427,7 +3471,7 @@ function Wr(r, e, s = {}, t) {
3427
3471
  throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
3428
3472
  return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: n, Fn: o };
3429
3473
  }
3430
- function qr(r, e) {
3474
+ function Kr(r, e) {
3431
3475
  return function(t) {
3432
3476
  const n = r(t);
3433
3477
  return { secretKey: n, publicKey: e(n) };
@@ -3479,15 +3523,15 @@ const Ss = (r, e, s) => new vs(r, e).update(s).digest();
3479
3523
  Ss.create = (r, e) => new vs(r, e);
3480
3524
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3481
3525
  const Wt = (r, e) => (r + (r >= 0 ? e : -e) / Es) / e;
3482
- function Kr(r, e, s) {
3526
+ function Vr(r, e, s) {
3483
3527
  const [[t, n], [o, i]] = e, a = Wt(i * r, s), c = Wt(-n * r, s);
3484
3528
  let l = r - a * t - c * o, u = -a * n - c * i;
3485
- const h = l < _e, x = u < _e;
3486
- h && (l = -l), x && (u = -u);
3487
- const f = ft(Math.ceil(Rr(s) / 2)) + Re;
3488
- if (l < _e || l >= f || u < _e || u >= f)
3529
+ const h = l < xe, _ = u < xe;
3530
+ h && (l = -l), _ && (u = -u);
3531
+ const f = ft(Math.ceil(kr(s) / 2)) + Re;
3532
+ if (l < xe || l >= f || u < xe || u >= f)
3489
3533
  throw new Error("splitScalar (endomorphism): failed, k=" + r);
3490
- return { k1neg: h, k1: l, k2neg: x, k2: u };
3534
+ return { k1neg: h, k1: l, k2neg: _, k2: u };
3491
3535
  }
3492
3536
  function ct(r) {
3493
3537
  if (!["compact", "recovered", "der"].includes(r))
@@ -3500,18 +3544,18 @@ function st(r, e) {
3500
3544
  s[t] = r[t] === void 0 ? e[t] : r[t];
3501
3545
  return qe(s.lowS, "lowS"), qe(s.prehash, "prehash"), s.format !== void 0 && ct(s.format), s;
3502
3546
  }
3503
- class Vr extends Error {
3547
+ class zr extends Error {
3504
3548
  constructor(e = "") {
3505
3549
  super(e);
3506
3550
  }
3507
3551
  }
3508
- const ye = {
3552
+ const be = {
3509
3553
  // asn.1 DER encoding utils
3510
- Err: Vr,
3554
+ Err: zr,
3511
3555
  // Basic building block is TLV (Tag-Length-Value)
3512
3556
  _tlv: {
3513
3557
  encode: (r, e) => {
3514
- const { Err: s } = ye;
3558
+ const { Err: s } = be;
3515
3559
  if (r < 0 || r > 256)
3516
3560
  throw new s("tlv.encode: wrong tag");
3517
3561
  if (e.length & 1)
@@ -3524,7 +3568,7 @@ const ye = {
3524
3568
  },
3525
3569
  // v - value, l - left bytes (unparsed)
3526
3570
  decode(r, e) {
3527
- const { Err: s } = ye;
3571
+ const { Err: s } = be;
3528
3572
  let t = 0;
3529
3573
  if (r < 0 || r > 256)
3530
3574
  throw new s("tlv.encode: wrong tag");
@@ -3562,8 +3606,8 @@ const ye = {
3562
3606
  // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
3563
3607
  _int: {
3564
3608
  encode(r) {
3565
- const { Err: e } = ye;
3566
- if (r < _e)
3609
+ const { Err: e } = be;
3610
+ if (r < xe)
3567
3611
  throw new e("integer: negative integers are not allowed");
3568
3612
  let s = Ue(r);
3569
3613
  if (Number.parseInt(s[0], 16) & 8 && (s = "00" + s), s.length & 1)
@@ -3571,7 +3615,7 @@ const ye = {
3571
3615
  return s;
3572
3616
  },
3573
3617
  decode(r) {
3574
- const { Err: e } = ye;
3618
+ const { Err: e } = be;
3575
3619
  if (r[0] & 128)
3576
3620
  throw new e("invalid signature integer: negative");
3577
3621
  if (r[0] === 0 && !(r[1] & 128))
@@ -3580,7 +3624,7 @@ const ye = {
3580
3624
  }
3581
3625
  },
3582
3626
  toSig(r) {
3583
- const { Err: e, _int: s, _tlv: t } = ye, n = V(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
3627
+ const { Err: e, _int: s, _tlv: t } = be, n = V(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
3584
3628
  if (i.length)
3585
3629
  throw new e("invalid signature: left bytes after parsing");
3586
3630
  const { v: a, l: c } = t.decode(2, o), { v: l, l: u } = t.decode(2, c);
@@ -3589,12 +3633,12 @@ const ye = {
3589
3633
  return { r: s.decode(a), s: s.decode(l) };
3590
3634
  },
3591
3635
  hexFromSig(r) {
3592
- const { _tlv: e, _int: s } = ye, t = e.encode(2, s.encode(r.r)), n = e.encode(2, s.encode(r.s)), o = t + n;
3636
+ const { _tlv: e, _int: s } = be, t = e.encode(2, s.encode(r.r)), n = e.encode(2, s.encode(r.s)), o = t + n;
3593
3637
  return e.encode(48, o);
3594
3638
  }
3595
- }, _e = BigInt(0), Re = BigInt(1), Es = BigInt(2), He = BigInt(3), zr = BigInt(4);
3596
- function jr(r, e = {}) {
3597
- const s = Wr("weierstrass", r, e), { Fp: t, Fn: n } = s;
3639
+ }, xe = BigInt(0), Re = BigInt(1), Es = BigInt(2), He = BigInt(3), jr = BigInt(4);
3640
+ function Yr(r, e = {}) {
3641
+ const s = qr("weierstrass", r, e), { Fp: t, Fn: n } = s;
3598
3642
  let o = s.CURVE;
3599
3643
  const { h: i, n: a } = o;
3600
3644
  _t(e, {}, {
@@ -3608,64 +3652,64 @@ function jr(r, e = {}) {
3608
3652
  const { endo: c } = e;
3609
3653
  if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
3610
3654
  throw new Error('invalid endo: expected "beta": bigint and "basises": array');
3611
- const l = As(t, n);
3655
+ const l = Ts(t, n);
3612
3656
  function u() {
3613
3657
  if (!t.isOdd)
3614
3658
  throw new Error("compression is not supported: Field does not have .isOdd()");
3615
3659
  }
3616
- function h(I, _, g) {
3617
- const { x: v, y: R } = _.toAffine(), D = t.toBytes(v);
3660
+ function h(I, x, g) {
3661
+ const { x: v, y: k } = x.toAffine(), D = t.toBytes(v);
3618
3662
  if (qe(g, "isCompressed"), g) {
3619
3663
  u();
3620
- const N = !t.isOdd(R);
3621
- return be(Is(N), D);
3664
+ const C = !t.isOdd(k);
3665
+ return ve(Is(C), D);
3622
3666
  } else
3623
- return be(Uint8Array.of(4), D, t.toBytes(R));
3667
+ return ve(Uint8Array.of(4), D, t.toBytes(k));
3624
3668
  }
3625
- function x(I) {
3669
+ function _(I) {
3626
3670
  V(I, void 0, "Point");
3627
- const { publicKey: _, publicKeyUncompressed: g } = l, v = I.length, R = I[0], D = I.subarray(1);
3628
- if (v === _ && (R === 2 || R === 3)) {
3629
- const N = t.fromBytes(D);
3630
- if (!t.isValid(N))
3671
+ const { publicKey: x, publicKeyUncompressed: g } = l, v = I.length, k = I[0], D = I.subarray(1);
3672
+ if (v === x && (k === 2 || k === 3)) {
3673
+ const C = t.fromBytes(D);
3674
+ if (!t.isValid(C))
3631
3675
  throw new Error("bad point: is not on curve, wrong x");
3632
- const M = b(N);
3633
- let T;
3676
+ const M = b(C);
3677
+ let R;
3634
3678
  try {
3635
- T = t.sqrt(M);
3679
+ R = t.sqrt(M);
3636
3680
  } catch (J) {
3637
3681
  const K = J instanceof Error ? ": " + J.message : "";
3638
3682
  throw new Error("bad point: is not on curve, sqrt error" + K);
3639
3683
  }
3640
3684
  u();
3641
- const $ = t.isOdd(T);
3642
- return (R & 1) === 1 !== $ && (T = t.neg(T)), { x: N, y: T };
3643
- } else if (v === g && R === 4) {
3644
- const N = t.BYTES, M = t.fromBytes(D.subarray(0, N)), T = t.fromBytes(D.subarray(N, N * 2));
3645
- if (!y(M, T))
3685
+ const $ = t.isOdd(R);
3686
+ return (k & 1) === 1 !== $ && (R = t.neg(R)), { x: C, y: R };
3687
+ } else if (v === g && k === 4) {
3688
+ const C = t.BYTES, M = t.fromBytes(D.subarray(0, C)), R = t.fromBytes(D.subarray(C, C * 2));
3689
+ if (!y(M, R))
3646
3690
  throw new Error("bad point: is not on curve");
3647
- return { x: M, y: T };
3691
+ return { x: M, y: R };
3648
3692
  } else
3649
- throw new Error(`bad point: got length ${v}, expected compressed=${_} or uncompressed=${g}`);
3693
+ throw new Error(`bad point: got length ${v}, expected compressed=${x} or uncompressed=${g}`);
3650
3694
  }
3651
- const f = e.toBytes || h, w = e.fromBytes || x;
3695
+ const f = e.toBytes || h, w = e.fromBytes || _;
3652
3696
  function b(I) {
3653
- const _ = t.sqr(I), g = t.mul(_, I);
3697
+ const x = t.sqr(I), g = t.mul(x, I);
3654
3698
  return t.add(t.add(g, t.mul(I, o.a)), o.b);
3655
3699
  }
3656
- function y(I, _) {
3657
- const g = t.sqr(_), v = b(I);
3700
+ function y(I, x) {
3701
+ const g = t.sqr(x), v = b(I);
3658
3702
  return t.eql(g, v);
3659
3703
  }
3660
3704
  if (!y(o.Gx, o.Gy))
3661
3705
  throw new Error("bad curve params: generator point");
3662
- const k = t.mul(t.pow(o.a, He), zr), C = t.mul(t.sqr(o.b), BigInt(27));
3663
- if (t.is0(t.add(k, C)))
3706
+ const T = t.mul(t.pow(o.a, He), jr), N = t.mul(t.sqr(o.b), BigInt(27));
3707
+ if (t.is0(t.add(T, N)))
3664
3708
  throw new Error("bad curve params: a or b");
3665
- function W(I, _, g = !1) {
3666
- if (!t.isValid(_) || g && t.is0(_))
3709
+ function W(I, x, g = !1) {
3710
+ if (!t.isValid(x) || g && t.is0(x))
3667
3711
  throw new Error(`bad point coordinate ${I}`);
3668
- return _;
3712
+ return x;
3669
3713
  }
3670
3714
  function B(I) {
3671
3715
  if (!(I instanceof L))
@@ -3674,64 +3718,64 @@ function jr(r, e = {}) {
3674
3718
  function j(I) {
3675
3719
  if (!c || !c.basises)
3676
3720
  throw new Error("no endo");
3677
- return Kr(I, c.basises, n.ORDER);
3721
+ return Vr(I, c.basises, n.ORDER);
3678
3722
  }
3679
- const q = Mt((I, _) => {
3680
- const { X: g, Y: v, Z: R } = I;
3681
- if (t.eql(R, t.ONE))
3723
+ const q = Mt((I, x) => {
3724
+ const { X: g, Y: v, Z: k } = I;
3725
+ if (t.eql(k, t.ONE))
3682
3726
  return { x: g, y: v };
3683
3727
  const D = I.is0();
3684
- _ == null && (_ = D ? t.ONE : t.inv(R));
3685
- const N = t.mul(g, _), M = t.mul(v, _), T = t.mul(R, _);
3728
+ x == null && (x = D ? t.ONE : t.inv(k));
3729
+ const C = t.mul(g, x), M = t.mul(v, x), R = t.mul(k, x);
3686
3730
  if (D)
3687
3731
  return { x: t.ZERO, y: t.ZERO };
3688
- if (!t.eql(T, t.ONE))
3732
+ if (!t.eql(R, t.ONE))
3689
3733
  throw new Error("invZ was invalid");
3690
- return { x: N, y: M };
3734
+ return { x: C, y: M };
3691
3735
  }), P = Mt((I) => {
3692
3736
  if (I.is0()) {
3693
3737
  if (e.allowInfinityPoint && !t.is0(I.Y))
3694
3738
  return;
3695
3739
  throw new Error("bad point: ZERO");
3696
3740
  }
3697
- const { x: _, y: g } = I.toAffine();
3698
- if (!t.isValid(_) || !t.isValid(g))
3741
+ const { x, y: g } = I.toAffine();
3742
+ if (!t.isValid(x) || !t.isValid(g))
3699
3743
  throw new Error("bad point: x or y not field elements");
3700
- if (!y(_, g))
3744
+ if (!y(x, g))
3701
3745
  throw new Error("bad point: equation left != right");
3702
3746
  if (!I.isTorsionFree())
3703
3747
  throw new Error("bad point: not in prime-order subgroup");
3704
3748
  return !0;
3705
3749
  });
3706
- function S(I, _, g, v, R) {
3707
- return g = new L(t.mul(g.X, I), g.Y, g.Z), _ = Ke(v, _), g = Ke(R, g), _.add(g);
3750
+ function S(I, x, g, v, k) {
3751
+ return g = new L(t.mul(g.X, I), g.Y, g.Z), x = Ke(v, x), g = Ke(k, g), x.add(g);
3708
3752
  }
3709
3753
  const A = class A {
3710
3754
  /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
3711
- constructor(_, g, v) {
3755
+ constructor(x, g, v) {
3712
3756
  E(this, "X");
3713
3757
  E(this, "Y");
3714
3758
  E(this, "Z");
3715
- this.X = W("x", _), this.Y = W("y", g, !0), this.Z = W("z", v), Object.freeze(this);
3759
+ this.X = W("x", x), this.Y = W("y", g, !0), this.Z = W("z", v), Object.freeze(this);
3716
3760
  }
3717
3761
  static CURVE() {
3718
3762
  return o;
3719
3763
  }
3720
3764
  /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
3721
- static fromAffine(_) {
3722
- const { x: g, y: v } = _ || {};
3723
- if (!_ || !t.isValid(g) || !t.isValid(v))
3765
+ static fromAffine(x) {
3766
+ const { x: g, y: v } = x || {};
3767
+ if (!x || !t.isValid(g) || !t.isValid(v))
3724
3768
  throw new Error("invalid affine point");
3725
- if (_ instanceof A)
3769
+ if (x instanceof A)
3726
3770
  throw new Error("projective point not allowed");
3727
3771
  return t.is0(g) && t.is0(v) ? A.ZERO : new A(g, v, t.ONE);
3728
3772
  }
3729
- static fromBytes(_) {
3730
- const g = A.fromAffine(w(V(_, void 0, "point")));
3773
+ static fromBytes(x) {
3774
+ const g = A.fromAffine(w(V(x, void 0, "point")));
3731
3775
  return g.assertValidity(), g;
3732
3776
  }
3733
- static fromHex(_) {
3734
- return A.fromBytes(We(_));
3777
+ static fromHex(x) {
3778
+ return A.fromBytes(We(x));
3735
3779
  }
3736
3780
  get x() {
3737
3781
  return this.toAffine().x;
@@ -3745,8 +3789,8 @@ function jr(r, e = {}) {
3745
3789
  * @param isLazy true will defer table computation until the first multiplication
3746
3790
  * @returns
3747
3791
  */
3748
- precompute(_ = 8, g = !0) {
3749
- return O.createCache(this, _), g || this.multiply(He), this;
3792
+ precompute(x = 8, g = !0) {
3793
+ return O.createCache(this, x), g || this.multiply(He), this;
3750
3794
  }
3751
3795
  // TODO: return `this`
3752
3796
  /** A point on curve is valid if it conforms to equation. */
@@ -3754,16 +3798,16 @@ function jr(r, e = {}) {
3754
3798
  P(this);
3755
3799
  }
3756
3800
  hasEvenY() {
3757
- const { y: _ } = this.toAffine();
3801
+ const { y: x } = this.toAffine();
3758
3802
  if (!t.isOdd)
3759
3803
  throw new Error("Field doesn't support isOdd");
3760
- return !t.isOdd(_);
3804
+ return !t.isOdd(x);
3761
3805
  }
3762
3806
  /** Compare one point to another. */
3763
- equals(_) {
3764
- B(_);
3765
- const { X: g, Y: v, Z: R } = this, { X: D, Y: N, Z: M } = _, T = t.eql(t.mul(g, M), t.mul(D, R)), $ = t.eql(t.mul(v, M), t.mul(N, R));
3766
- return T && $;
3807
+ equals(x) {
3808
+ B(x);
3809
+ const { X: g, Y: v, Z: k } = this, { X: D, Y: C, Z: M } = x, R = t.eql(t.mul(g, M), t.mul(D, k)), $ = t.eql(t.mul(v, M), t.mul(C, k));
3810
+ return R && $;
3767
3811
  }
3768
3812
  /** Flips point to one corresponding to (x, -y) in Affine coordinates. */
3769
3813
  negate() {
@@ -3774,26 +3818,26 @@ function jr(r, e = {}) {
3774
3818
  // https://eprint.iacr.org/2015/1060, algorithm 3
3775
3819
  // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
3776
3820
  double() {
3777
- const { a: _, b: g } = o, v = t.mul(g, He), { X: R, Y: D, Z: N } = this;
3778
- let M = t.ZERO, T = t.ZERO, $ = t.ZERO, F = t.mul(R, R), J = t.mul(D, D), K = t.mul(N, N), H = t.mul(R, D);
3779
- return H = t.add(H, H), $ = t.mul(R, N), $ = t.add($, $), M = t.mul(_, $), T = t.mul(v, K), 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, $), K = t.mul(_, K), H = t.sub(F, K), H = t.mul(_, H), H = t.add(H, $), $ = t.add(F, F), F = t.add($, F), F = t.add(F, K), F = t.mul(F, H), T = t.add(T, F), K = t.mul(D, 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 A(M, T, $);
3821
+ const { a: x, b: g } = o, v = t.mul(g, He), { X: k, Y: D, Z: C } = this;
3822
+ let M = t.ZERO, R = t.ZERO, $ = t.ZERO, F = t.mul(k, k), J = t.mul(D, D), K = t.mul(C, C), H = t.mul(k, D);
3823
+ return H = t.add(H, H), $ = t.mul(k, C), $ = t.add($, $), M = t.mul(x, $), R = t.mul(v, K), R = t.add(M, R), M = t.sub(J, R), R = t.add(J, R), R = t.mul(M, R), M = t.mul(H, M), $ = t.mul(v, $), K = t.mul(x, K), H = t.sub(F, K), H = t.mul(x, H), H = t.add(H, $), $ = t.add(F, F), F = t.add($, F), F = t.add(F, K), F = t.mul(F, H), R = t.add(R, F), K = t.mul(D, C), K = t.add(K, K), F = t.mul(K, H), M = t.sub(M, F), $ = t.mul(K, J), $ = t.add($, $), $ = t.add($, $), new A(M, R, $);
3780
3824
  }
3781
3825
  // Renes-Costello-Batina exception-free addition formula.
3782
3826
  // There is 30% faster Jacobian formula, but it is not complete.
3783
3827
  // https://eprint.iacr.org/2015/1060, algorithm 1
3784
3828
  // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
3785
- add(_) {
3786
- B(_);
3787
- const { X: g, Y: v, Z: R } = this, { X: D, Y: N, Z: M } = _;
3788
- let T = t.ZERO, $ = t.ZERO, F = t.ZERO;
3829
+ add(x) {
3830
+ B(x);
3831
+ const { X: g, Y: v, Z: k } = this, { X: D, Y: C, Z: M } = x;
3832
+ let R = t.ZERO, $ = t.ZERO, F = t.ZERO;
3789
3833
  const J = o.a, K = t.mul(o.b, He);
3790
- let H = t.mul(g, D), X = t.mul(v, N), Z = t.mul(R, M), oe = t.add(g, v), z = t.add(D, N);
3791
- oe = t.mul(oe, z), z = t.add(H, X), oe = t.sub(oe, z), z = t.add(g, R);
3834
+ let H = t.mul(g, D), X = t.mul(v, C), Z = t.mul(k, M), oe = t.add(g, v), z = t.add(D, C);
3835
+ oe = t.mul(oe, z), z = t.add(H, X), oe = t.sub(oe, z), z = t.add(g, k);
3792
3836
  let Q = t.add(D, M);
3793
- return z = t.mul(z, Q), Q = t.add(H, Z), z = t.sub(z, Q), Q = t.add(v, R), T = t.add(N, M), Q = t.mul(Q, T), T = t.add(X, Z), Q = t.sub(Q, T), F = t.mul(J, z), T = t.mul(K, Z), F = t.add(T, F), T = t.sub(X, F), F = t.add(X, F), $ = t.mul(T, F), X = t.add(H, H), X = t.add(X, H), Z = t.mul(J, Z), z = t.mul(K, z), X = t.add(X, Z), Z = t.sub(H, Z), Z = t.mul(J, Z), z = t.add(z, Z), H = t.mul(X, z), $ = t.add($, H), H = t.mul(Q, z), T = t.mul(oe, T), T = t.sub(T, H), H = t.mul(oe, X), F = t.mul(Q, F), F = t.add(F, H), new A(T, $, F);
3837
+ return z = t.mul(z, Q), Q = t.add(H, Z), z = t.sub(z, Q), Q = t.add(v, k), R = t.add(C, M), Q = t.mul(Q, R), R = t.add(X, Z), Q = t.sub(Q, R), F = t.mul(J, z), R = t.mul(K, Z), F = t.add(R, F), R = t.sub(X, F), F = t.add(X, F), $ = t.mul(R, F), X = t.add(H, H), X = t.add(X, H), Z = t.mul(J, Z), z = t.mul(K, z), X = t.add(X, Z), Z = t.sub(H, Z), Z = t.mul(J, Z), z = t.add(z, Z), H = t.mul(X, z), $ = t.add($, H), H = t.mul(Q, z), R = t.mul(oe, R), R = t.sub(R, H), H = t.mul(oe, X), F = t.mul(Q, F), F = t.add(F, H), new A(R, $, F);
3794
3838
  }
3795
- subtract(_) {
3796
- return this.add(_.negate());
3839
+ subtract(x) {
3840
+ return this.add(x.negate());
3797
3841
  }
3798
3842
  is0() {
3799
3843
  return this.equals(A.ZERO);
@@ -3807,69 +3851,69 @@ function jr(r, e = {}) {
3807
3851
  * @param scalar by which the point would be multiplied
3808
3852
  * @returns New point
3809
3853
  */
3810
- multiply(_) {
3854
+ multiply(x) {
3811
3855
  const { endo: g } = e;
3812
- if (!n.isValidNot0(_))
3856
+ if (!n.isValidNot0(x))
3813
3857
  throw new Error("invalid scalar: out of range");
3814
- let v, R;
3815
- const D = (N) => O.cached(this, N, (M) => Ut(A, M));
3858
+ let v, k;
3859
+ const D = (C) => O.cached(this, C, (M) => Ut(A, M));
3816
3860
  if (g) {
3817
- const { k1neg: N, k1: M, k2neg: T, k2: $ } = j(_), { p: F, f: J } = D(M), { p: K, f: H } = D($);
3818
- R = J.add(H), v = S(g.beta, F, K, N, T);
3861
+ const { k1neg: C, k1: M, k2neg: R, k2: $ } = j(x), { p: F, f: J } = D(M), { p: K, f: H } = D($);
3862
+ k = J.add(H), v = S(g.beta, F, K, C, R);
3819
3863
  } else {
3820
- const { p: N, f: M } = D(_);
3821
- v = N, R = M;
3864
+ const { p: C, f: M } = D(x);
3865
+ v = C, k = M;
3822
3866
  }
3823
- return Ut(A, [v, R])[0];
3867
+ return Ut(A, [v, k])[0];
3824
3868
  }
3825
3869
  /**
3826
3870
  * Non-constant-time multiplication. Uses double-and-add algorithm.
3827
3871
  * It's faster, but should only be used when you don't care about
3828
3872
  * an exposed secret key e.g. sig verification, which works over *public* keys.
3829
3873
  */
3830
- multiplyUnsafe(_) {
3874
+ multiplyUnsafe(x) {
3831
3875
  const { endo: g } = e, v = this;
3832
- if (!n.isValid(_))
3876
+ if (!n.isValid(x))
3833
3877
  throw new Error("invalid scalar: out of range");
3834
- if (_ === _e || v.is0())
3878
+ if (x === xe || v.is0())
3835
3879
  return A.ZERO;
3836
- if (_ === Re)
3880
+ if (x === Re)
3837
3881
  return v;
3838
3882
  if (O.hasCache(this))
3839
- return this.multiply(_);
3883
+ return this.multiply(x);
3840
3884
  if (g) {
3841
- const { k1neg: R, k1: D, k2neg: N, k2: M } = j(_), { p1: T, p2: $ } = Gr(A, v, D, M);
3842
- return S(g.beta, T, $, R, N);
3885
+ const { k1neg: k, k1: D, k2neg: C, k2: M } = j(x), { p1: R, p2: $ } = Wr(A, v, D, M);
3886
+ return S(g.beta, R, $, k, C);
3843
3887
  } else
3844
- return O.unsafe(v, _);
3888
+ return O.unsafe(v, x);
3845
3889
  }
3846
3890
  /**
3847
3891
  * Converts Projective point to affine (x, y) coordinates.
3848
3892
  * @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
3849
3893
  */
3850
- toAffine(_) {
3851
- return q(this, _);
3894
+ toAffine(x) {
3895
+ return q(this, x);
3852
3896
  }
3853
3897
  /**
3854
3898
  * Checks whether Point is free of torsion elements (is in prime subgroup).
3855
3899
  * Always torsion-free for cofactor=1 curves.
3856
3900
  */
3857
3901
  isTorsionFree() {
3858
- const { isTorsionFree: _ } = e;
3859
- return i === Re ? !0 : _ ? _(A, this) : O.unsafe(this, a).is0();
3902
+ const { isTorsionFree: x } = e;
3903
+ return i === Re ? !0 : x ? x(A, this) : O.unsafe(this, a).is0();
3860
3904
  }
3861
3905
  clearCofactor() {
3862
- const { clearCofactor: _ } = e;
3863
- return i === Re ? this : _ ? _(A, this) : this.multiplyUnsafe(i);
3906
+ const { clearCofactor: x } = e;
3907
+ return i === Re ? this : x ? x(A, this) : this.multiplyUnsafe(i);
3864
3908
  }
3865
3909
  isSmallOrder() {
3866
3910
  return this.multiplyUnsafe(i).is0();
3867
3911
  }
3868
- toBytes(_ = !0) {
3869
- return qe(_, "isCompressed"), this.assertValidity(), f(A, this, _);
3912
+ toBytes(x = !0) {
3913
+ return qe(x, "isCompressed"), this.assertValidity(), f(A, this, x);
3870
3914
  }
3871
- toHex(_ = !0) {
3872
- return Me(this.toBytes(_));
3915
+ toHex(x = !0) {
3916
+ return Me(this.toBytes(x));
3873
3917
  }
3874
3918
  toString() {
3875
3919
  return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
@@ -3882,13 +3926,13 @@ function jr(r, e = {}) {
3882
3926
  E(A, "Fp", t), // scalar field
3883
3927
  E(A, "Fn", n);
3884
3928
  let L = A;
3885
- const G = n.BITS, O = new Fr(L, e.endo ? Math.ceil(G / 2) : G);
3929
+ const G = n.BITS, O = new Gr(L, e.endo ? Math.ceil(G / 2) : G);
3886
3930
  return L.BASE.precompute(8), L;
3887
3931
  }
3888
3932
  function Is(r) {
3889
3933
  return Uint8Array.of(r ? 2 : 3);
3890
3934
  }
3891
- function As(r, e) {
3935
+ function Ts(r, e) {
3892
3936
  return {
3893
3937
  secretKey: e.BYTES,
3894
3938
  publicKey: 1 + r.BYTES,
@@ -3897,8 +3941,8 @@ function As(r, e) {
3897
3941
  signature: 2 * e.BYTES
3898
3942
  };
3899
3943
  }
3900
- function Yr(r, e = {}) {
3901
- const { Fn: s } = r, t = e.randomBytes || os, n = Object.assign(As(r.Fp, s), { seed: ws(s.ORDER) });
3944
+ function Jr(r, e = {}) {
3945
+ const { Fn: s } = r, t = e.randomBytes || os, n = Object.assign(Ts(r.Fp, s), { seed: ws(s.ORDER) });
3902
3946
  function o(f) {
3903
3947
  try {
3904
3948
  const w = s.fromBytes(f);
@@ -3910,14 +3954,14 @@ function Yr(r, e = {}) {
3910
3954
  function i(f, w) {
3911
3955
  const { publicKey: b, publicKeyUncompressed: y } = n;
3912
3956
  try {
3913
- const k = f.length;
3914
- return w === !0 && k !== b || w === !1 && k !== y ? !1 : !!r.fromBytes(f);
3957
+ const T = f.length;
3958
+ return w === !0 && T !== b || w === !1 && T !== y ? !1 : !!r.fromBytes(f);
3915
3959
  } catch {
3916
3960
  return !1;
3917
3961
  }
3918
3962
  }
3919
3963
  function a(f = t(n.seed)) {
3920
- return Hr(V(f, n.seed, "seed"), s.ORDER);
3964
+ return Fr(V(f, n.seed, "seed"), s.ORDER);
3921
3965
  }
3922
3966
  function c(f, w = !0) {
3923
3967
  return r.BASE.multiply(s.fromBytes(f)).toBytes(w);
@@ -3926,8 +3970,8 @@ function Yr(r, e = {}) {
3926
3970
  const { secretKey: w, publicKey: b, publicKeyUncompressed: y } = n;
3927
3971
  if (!ut(f) || "_lengths" in s && s._lengths || w === b)
3928
3972
  return;
3929
- const k = V(f, void 0, "key").length;
3930
- return k === b || k === y;
3973
+ const T = V(f, void 0, "key").length;
3974
+ return T === b || T === y;
3931
3975
  }
3932
3976
  function u(f, w, b = !0) {
3933
3977
  if (l(f) === !0)
@@ -3941,10 +3985,10 @@ function Yr(r, e = {}) {
3941
3985
  isValidSecretKey: o,
3942
3986
  isValidPublicKey: i,
3943
3987
  randomSecretKey: a
3944
- }, x = qr(a, c);
3945
- return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen: x, Point: r, utils: h, lengths: n });
3988
+ }, _ = Kr(a, c);
3989
+ return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen: _, Point: r, utils: h, lengths: n });
3946
3990
  }
3947
- function Jr(r, e, s = {}) {
3991
+ function Xr(r, e, s = {}) {
3948
3992
  ts(e), _t(s, {}, {
3949
3993
  hmac: "function",
3950
3994
  lowS: "boolean",
@@ -3952,52 +3996,52 @@ function Jr(r, e, s = {}) {
3952
3996
  bits2int: "function",
3953
3997
  bits2int_modN: "function"
3954
3998
  }), s = Object.assign({}, s);
3955
- const t = s.randomBytes || os, n = s.hmac || ((_, g) => Ss(e, _, g)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: u, getSharedSecret: h, utils: x, lengths: f } = Yr(r, s), w = {
3999
+ const t = s.randomBytes || os, n = s.hmac || ((x, g) => Ss(e, x, g)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: u, getSharedSecret: h, utils: _, lengths: f } = Jr(r, s), w = {
3956
4000
  prehash: !0,
3957
4001
  lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
3958
4002
  format: "compact",
3959
4003
  extraEntropy: !1
3960
4004
  }, b = a * Es < o.ORDER;
3961
- function y(_) {
4005
+ function y(x) {
3962
4006
  const g = a >> Re;
3963
- return _ > g;
4007
+ return x > g;
3964
4008
  }
3965
- function k(_, g) {
4009
+ function T(x, g) {
3966
4010
  if (!i.isValidNot0(g))
3967
- throw new Error(`invalid signature ${_}: out of range 1..Point.Fn.ORDER`);
4011
+ throw new Error(`invalid signature ${x}: out of range 1..Point.Fn.ORDER`);
3968
4012
  return g;
3969
4013
  }
3970
- function C() {
4014
+ function N() {
3971
4015
  if (b)
3972
4016
  throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
3973
4017
  }
3974
- function W(_, g) {
4018
+ function W(x, g) {
3975
4019
  ct(g);
3976
- const v = f.signature, R = g === "compact" ? v : g === "recovered" ? v + 1 : void 0;
3977
- return V(_, R);
4020
+ const v = f.signature, k = g === "compact" ? v : g === "recovered" ? v + 1 : void 0;
4021
+ return V(x, k);
3978
4022
  }
3979
4023
  class B {
3980
- constructor(g, v, R) {
4024
+ constructor(g, v, k) {
3981
4025
  E(this, "r");
3982
4026
  E(this, "s");
3983
4027
  E(this, "recovery");
3984
- if (this.r = k("r", g), this.s = k("s", v), R != null) {
3985
- if (C(), ![0, 1, 2, 3].includes(R))
4028
+ if (this.r = T("r", g), this.s = T("s", v), k != null) {
4029
+ if (N(), ![0, 1, 2, 3].includes(k))
3986
4030
  throw new Error("invalid recovery id");
3987
- this.recovery = R;
4031
+ this.recovery = k;
3988
4032
  }
3989
4033
  Object.freeze(this);
3990
4034
  }
3991
4035
  static fromBytes(g, v = w.format) {
3992
4036
  W(g, v);
3993
- let R;
4037
+ let k;
3994
4038
  if (v === "der") {
3995
- const { r: T, s: $ } = ye.toSig(V(g));
3996
- return new B(T, $);
4039
+ const { r: R, s: $ } = be.toSig(V(g));
4040
+ return new B(R, $);
3997
4041
  }
3998
- v === "recovered" && (R = g[0], v = "compact", g = g.subarray(1));
3999
- const D = f.signature / 2, N = g.subarray(0, D), M = g.subarray(D, D * 2);
4000
- return new B(i.fromBytes(N), i.fromBytes(M), R);
4042
+ v === "recovered" && (k = g[0], v = "compact", g = g.subarray(1));
4043
+ const D = f.signature / 2, C = g.subarray(0, D), M = g.subarray(D, D * 2);
4044
+ return new B(i.fromBytes(C), i.fromBytes(M), k);
4001
4045
  }
4002
4046
  static fromHex(g, v) {
4003
4047
  return this.fromBytes(We(g), v);
@@ -4012,10 +4056,10 @@ function Jr(r, e, s = {}) {
4012
4056
  return new B(this.r, this.s, g);
4013
4057
  }
4014
4058
  recoverPublicKey(g) {
4015
- const { r: v, s: R } = this, D = this.assertRecovery(), N = D === 2 || D === 3 ? v + a : v;
4016
- if (!o.isValid(N))
4059
+ const { r: v, s: k } = this, D = this.assertRecovery(), C = D === 2 || D === 3 ? v + a : v;
4060
+ if (!o.isValid(C))
4017
4061
  throw new Error("invalid recovery id: sig.r+curve.n != R.x");
4018
- const M = o.toBytes(N), T = r.fromBytes(be(Is((D & 1) === 0), M)), $ = i.inv(N), F = q(V(g, void 0, "msgHash")), J = i.create(-F * $), K = i.create(R * $), H = r.BASE.multiplyUnsafe(J).add(T.multiplyUnsafe(K));
4062
+ const M = o.toBytes(C), R = r.fromBytes(ve(Is((D & 1) === 0), M)), $ = i.inv(C), F = q(V(g, void 0, "msgHash")), J = i.create(-F * $), K = i.create(k * $), H = r.BASE.multiplyUnsafe(J).add(R.multiplyUnsafe(K));
4019
4063
  if (H.is0())
4020
4064
  throw new Error("invalid recovery: point at infinify");
4021
4065
  return H.assertValidity(), H;
@@ -4026,9 +4070,9 @@ function Jr(r, e, s = {}) {
4026
4070
  }
4027
4071
  toBytes(g = w.format) {
4028
4072
  if (ct(g), g === "der")
4029
- return We(ye.hexFromSig(this));
4030
- const { r: v, s: R } = this, D = i.toBytes(v), N = i.toBytes(R);
4031
- return g === "recovered" ? (C(), be(Uint8Array.of(this.assertRecovery()), D, N)) : be(D, N);
4073
+ return We(be.hexFromSig(this));
4074
+ const { r: v, s: k } = this, D = i.toBytes(v), C = i.toBytes(k);
4075
+ return g === "recovered" ? (N(), ve(Uint8Array.of(this.assertRecovery()), D, C)) : ve(D, C);
4032
4076
  }
4033
4077
  toHex(g) {
4034
4078
  return Me(this.toBytes(g));
@@ -4037,74 +4081,74 @@ function Jr(r, e, s = {}) {
4037
4081
  const j = s.bits2int || function(g) {
4038
4082
  if (g.length > 8192)
4039
4083
  throw new Error("input is too large");
4040
- const v = ze(g), R = g.length * 8 - c;
4041
- return R > 0 ? v >> BigInt(R) : v;
4084
+ const v = ze(g), k = g.length * 8 - c;
4085
+ return k > 0 ? v >> BigInt(k) : v;
4042
4086
  }, q = s.bits2int_modN || function(g) {
4043
4087
  return i.create(j(g));
4044
4088
  }, P = ft(c);
4045
- function S(_) {
4046
- return Tr("num < 2^" + c, _, _e, P), i.toBytes(_);
4089
+ function S(x) {
4090
+ return Rr("num < 2^" + c, x, xe, P), i.toBytes(x);
4047
4091
  }
4048
- function L(_, g) {
4049
- return V(_, void 0, "message"), g ? V(e(_), void 0, "prehashed message") : _;
4092
+ function L(x, g) {
4093
+ return V(x, void 0, "message"), g ? V(e(x), void 0, "prehashed message") : x;
4050
4094
  }
4051
- function G(_, g, v) {
4052
- const { lowS: R, prehash: D, extraEntropy: N } = st(v, w);
4053
- _ = L(_, D);
4054
- const M = q(_), T = i.fromBytes(g);
4055
- if (!i.isValidNot0(T))
4095
+ function G(x, g, v) {
4096
+ const { lowS: k, prehash: D, extraEntropy: C } = st(v, w);
4097
+ x = L(x, D);
4098
+ const M = q(x), R = i.fromBytes(g);
4099
+ if (!i.isValidNot0(R))
4056
4100
  throw new Error("invalid private key");
4057
- const $ = [S(T), S(M)];
4058
- if (N != null && N !== !1) {
4059
- const H = N === !0 ? t(f.secretKey) : N;
4101
+ const $ = [S(R), S(M)];
4102
+ if (C != null && C !== !1) {
4103
+ const H = C === !0 ? t(f.secretKey) : C;
4060
4104
  $.push(V(H, void 0, "extraEntropy"));
4061
4105
  }
4062
- const F = be(...$), J = M;
4106
+ const F = ve(...$), J = M;
4063
4107
  function K(H) {
4064
4108
  const X = j(H);
4065
4109
  if (!i.isValidNot0(X))
4066
4110
  return;
4067
4111
  const Z = i.inv(X), oe = r.BASE.multiply(X).toAffine(), z = i.create(oe.x);
4068
- if (z === _e)
4112
+ if (z === xe)
4069
4113
  return;
4070
- const Q = i.create(Z * i.create(J + z * T));
4071
- if (Q === _e)
4114
+ const Q = i.create(Z * i.create(J + z * R));
4115
+ if (Q === xe)
4072
4116
  return;
4073
4117
  let yt = (oe.x === z ? 0 : 2) | Number(oe.y & Re), bt = Q;
4074
- return R && y(Q) && (bt = i.neg(Q), yt ^= 1), new B(z, bt, b ? void 0 : yt);
4118
+ return k && y(Q) && (bt = i.neg(Q), yt ^= 1), new B(z, bt, b ? void 0 : yt);
4075
4119
  }
4076
4120
  return { seed: F, k2sig: K };
4077
4121
  }
4078
- function O(_, g, v = {}) {
4079
- const { seed: R, k2sig: D } = G(_, g, v);
4080
- return kr(e.outputLen, i.BYTES, n)(R, D).toBytes(v.format);
4122
+ function O(x, g, v = {}) {
4123
+ const { seed: k, k2sig: D } = G(x, g, v);
4124
+ return Pr(e.outputLen, i.BYTES, n)(k, D).toBytes(v.format);
4081
4125
  }
4082
- function A(_, g, v, R = {}) {
4083
- const { lowS: D, prehash: N, format: M } = st(R, w);
4084
- if (v = V(v, void 0, "publicKey"), g = L(g, N), !ut(_)) {
4085
- const T = _ instanceof B ? ", use sig.toBytes()" : "";
4086
- throw new Error("verify expects Uint8Array signature" + T);
4126
+ function A(x, g, v, k = {}) {
4127
+ const { lowS: D, prehash: C, format: M } = st(k, w);
4128
+ if (v = V(v, void 0, "publicKey"), g = L(g, C), !ut(x)) {
4129
+ const R = x instanceof B ? ", use sig.toBytes()" : "";
4130
+ throw new Error("verify expects Uint8Array signature" + R);
4087
4131
  }
4088
- W(_, M);
4132
+ W(x, M);
4089
4133
  try {
4090
- const T = B.fromBytes(_, M), $ = r.fromBytes(v);
4091
- if (D && T.hasHighS())
4134
+ const R = B.fromBytes(x, M), $ = r.fromBytes(v);
4135
+ if (D && R.hasHighS())
4092
4136
  return !1;
4093
- const { r: F, s: J } = T, K = q(g), H = i.inv(J), X = i.create(K * H), Z = i.create(F * H), oe = r.BASE.multiplyUnsafe(X).add($.multiplyUnsafe(Z));
4137
+ const { r: F, s: J } = R, K = q(g), H = i.inv(J), X = i.create(K * H), Z = i.create(F * H), oe = r.BASE.multiplyUnsafe(X).add($.multiplyUnsafe(Z));
4094
4138
  return oe.is0() ? !1 : i.create(oe.x) === F;
4095
4139
  } catch {
4096
4140
  return !1;
4097
4141
  }
4098
4142
  }
4099
- function I(_, g, v = {}) {
4100
- const { prehash: R } = st(v, w);
4101
- return g = L(g, R), B.fromBytes(_, "recovered").recoverPublicKey(g).toBytes();
4143
+ function I(x, g, v = {}) {
4144
+ const { prehash: k } = st(v, w);
4145
+ return g = L(g, k), B.fromBytes(x, "recovered").recoverPublicKey(g).toBytes();
4102
4146
  }
4103
4147
  return Object.freeze({
4104
4148
  keygen: l,
4105
4149
  getPublicKey: u,
4106
4150
  getSharedSecret: h,
4107
- utils: x,
4151
+ utils: _,
4108
4152
  lengths: f,
4109
4153
  Point: r,
4110
4154
  sign: O,
@@ -4123,44 +4167,44 @@ const gt = {
4123
4167
  b: BigInt(7),
4124
4168
  Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
4125
4169
  Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
4126
- }, Xr = {
4170
+ }, Zr = {
4127
4171
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
4128
4172
  basises: [
4129
4173
  [BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
4130
4174
  [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
4131
4175
  ]
4132
4176
  }, qt = /* @__PURE__ */ BigInt(2);
4133
- function Zr(r) {
4134
- 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, u = l * l * r % e, h = ae(u, s, e) * u % e, x = ae(h, s, e) * u % e, f = ae(x, qt, e) * l % e, w = ae(f, n, e) * f % e, b = ae(w, o, e) * w % e, y = ae(b, a, e) * b % e, k = ae(y, c, e) * y % e, C = ae(k, a, e) * b % e, W = ae(C, s, e) * u % e, B = ae(W, i, e) * w % e, j = ae(B, t, e) * l % e, q = ae(j, qt, e);
4177
+ function Qr(r) {
4178
+ 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, u = l * l * r % e, h = ae(u, s, e) * u % e, _ = ae(h, s, e) * u % e, f = ae(_, qt, e) * l % e, w = ae(f, n, e) * f % e, b = ae(w, o, e) * w % e, y = ae(b, a, e) * b % e, T = ae(y, c, e) * y % e, N = ae(T, a, e) * b % e, W = ae(N, s, e) * u % e, B = ae(W, i, e) * w % e, j = ae(B, t, e) * l % e, q = ae(j, qt, e);
4135
4179
  if (!lt.eql(lt.sqr(q), r))
4136
4180
  throw new Error("Cannot find square root");
4137
4181
  return q;
4138
4182
  }
4139
- const lt = je(gt.p, { sqrt: Zr }), Qr = /* @__PURE__ */ jr(gt, {
4183
+ const lt = je(gt.p, { sqrt: Qr }), en = /* @__PURE__ */ Yr(gt, {
4140
4184
  Fp: lt,
4141
- endo: Xr
4142
- }), en = /* @__PURE__ */ Jr(Qr, Er), tn = BigInt(0), Ne = BigInt(1), sn = BigInt(2), rn = BigInt(7), nn = BigInt(256), on = BigInt(113), Ts = [], Rs = [], ks = [];
4143
- for (let r = 0, e = Ne, s = 1, t = 0; r < 24; r++) {
4144
- [s, t] = [t, (2 * s + 3 * t) % 5], Ts.push(2 * (5 * t + s)), Rs.push((r + 1) * (r + 2) / 2 % 64);
4145
- let n = tn;
4185
+ endo: Zr
4186
+ }), tn = /* @__PURE__ */ Xr(en, Ir), sn = BigInt(0), Ce = BigInt(1), rn = BigInt(2), nn = BigInt(7), on = BigInt(256), an = BigInt(113), As = [], Rs = [], ks = [];
4187
+ for (let r = 0, e = Ce, s = 1, t = 0; r < 24; r++) {
4188
+ [s, t] = [t, (2 * s + 3 * t) % 5], As.push(2 * (5 * t + s)), Rs.push((r + 1) * (r + 2) / 2 % 64);
4189
+ let n = sn;
4146
4190
  for (let o = 0; o < 7; o++)
4147
- e = (e << Ne ^ (e >> rn) * on) % nn, e & sn && (n ^= Ne << (Ne << BigInt(o)) - Ne);
4191
+ e = (e << Ce ^ (e >> nn) * an) % on, e & rn && (n ^= Ce << (Ce << BigInt(o)) - Ce);
4148
4192
  ks.push(n);
4149
4193
  }
4150
- const Ps = xr(ks, !0), an = Ps[0], cn = Ps[1], Kt = (r, e, s) => s > 32 ? wr(r, e, s) : gr(r, e, s), Vt = (r, e, s) => s > 32 ? yr(r, e, s) : mr(r, e, s);
4151
- function ln(r, e = 24) {
4194
+ const Ps = gr(ks, !0), cn = Ps[0], ln = Ps[1], Kt = (r, e, s) => s > 32 ? yr(r, e, s) : mr(r, e, s), Vt = (r, e, s) => s > 32 ? br(r, e, s) : wr(r, e, s);
4195
+ function dn(r, e = 24) {
4152
4196
  const s = new Uint32Array(10);
4153
4197
  for (let t = 24 - e; t < 24; t++) {
4154
4198
  for (let i = 0; i < 10; i++)
4155
4199
  s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
4156
4200
  for (let i = 0; i < 10; i += 2) {
4157
- const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], u = s[c + 1], h = Kt(l, u, 1) ^ s[a], x = Vt(l, u, 1) ^ s[a + 1];
4201
+ const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], u = s[c + 1], h = Kt(l, u, 1) ^ s[a], _ = Vt(l, u, 1) ^ s[a + 1];
4158
4202
  for (let f = 0; f < 50; f += 10)
4159
- r[i + f] ^= h, r[i + f + 1] ^= x;
4203
+ r[i + f] ^= h, r[i + f + 1] ^= _;
4160
4204
  }
4161
4205
  let n = r[2], o = r[3];
4162
4206
  for (let i = 0; i < 24; i++) {
4163
- const a = Rs[i], c = Kt(n, o, a), l = Vt(n, o, a), u = Ts[i];
4207
+ const a = Rs[i], c = Kt(n, o, a), l = Vt(n, o, a), u = As[i];
4164
4208
  n = r[u], o = r[u + 1], r[u] = c, r[u + 1] = l;
4165
4209
  }
4166
4210
  for (let i = 0; i < 50; i += 10) {
@@ -4169,7 +4213,7 @@ function ln(r, e = 24) {
4169
4213
  for (let a = 0; a < 10; a++)
4170
4214
  r[i + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
4171
4215
  }
4172
- r[0] ^= an[t], r[1] ^= cn[t];
4216
+ r[0] ^= cn[t], r[1] ^= ln[t];
4173
4217
  }
4174
4218
  Pe(s);
4175
4219
  }
@@ -4187,15 +4231,15 @@ class mt {
4187
4231
  E(this, "outputLen");
4188
4232
  E(this, "enableXOF", !1);
4189
4233
  E(this, "rounds");
4190
- if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, ge(t, "outputLen"), !(0 < e && e < 200))
4234
+ if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, me(t, "outputLen"), !(0 < e && e < 200))
4191
4235
  throw new Error("only keccak-f1600 function is supported");
4192
- this.state = new Uint8Array(200), this.state32 = ir(this.state);
4236
+ this.state = new Uint8Array(200), this.state32 = ar(this.state);
4193
4237
  }
4194
4238
  clone() {
4195
4239
  return this._cloneInto();
4196
4240
  }
4197
4241
  keccak() {
4198
- Ct(this.state32), ln(this.state32, this.rounds), Ct(this.state32), this.posOut = 0, this.pos = 0;
4242
+ Nt(this.state32), dn(this.state32, this.rounds), Nt(this.state32), this.posOut = 0, this.pos = 0;
4199
4243
  }
4200
4244
  update(e) {
4201
4245
  ke(this), V(e);
@@ -4231,7 +4275,7 @@ class mt {
4231
4275
  return this.writeInto(e);
4232
4276
  }
4233
4277
  xof(e) {
4234
- return ge(e), this.xofInto(new Uint8Array(e));
4278
+ return me(e), this.xofInto(new Uint8Array(e));
4235
4279
  }
4236
4280
  digestInto(e) {
4237
4281
  if (ss(e, this), this.finished)
@@ -4249,8 +4293,8 @@ class mt {
4249
4293
  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;
4250
4294
  }
4251
4295
  }
4252
- const dn = (r, e, s, t = {}) => ns(() => new mt(e, r, s), t), zt = /* @__PURE__ */ dn(1, 136, 32), un = 60;
4253
- class hn {
4296
+ const un = (r, e, s, t = {}) => ns(() => new mt(e, r, s), t), zt = /* @__PURE__ */ un(1, 136, 32), hn = 60;
4297
+ class pn {
4254
4298
  constructor() {
4255
4299
  this.jwks = null;
4256
4300
  }
@@ -4270,7 +4314,7 @@ class hn {
4270
4314
  iat: t.iat
4271
4315
  });
4272
4316
  const n = Math.floor(Date.now() / 1e3);
4273
- if (t.exp && t.exp + un < n)
4317
+ if (t.exp && t.exp + hn < n)
4274
4318
  return d.warn("[CROSSx] 토큰 만료:", {
4275
4319
  exp: t.exp,
4276
4320
  now: n,
@@ -4317,14 +4361,14 @@ ${t.length}`
4317
4361
  const i = zt(o), a = s.startsWith("0x") ? s.slice(2) : s;
4318
4362
  if (a.length !== 130)
4319
4363
  throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
4320
- const c = pn(a), l = c.slice(0, 32), u = c.slice(32, 64), h = c[64], x = h >= 27 ? h - 27 : h, b = new en.Signature(
4364
+ const c = fn(a), l = c.slice(0, 32), u = c.slice(32, 64), h = c[64], _ = h >= 27 ? h - 27 : h, b = new tn.Signature(
4321
4365
  jt(l),
4322
4366
  jt(u)
4323
- ).addRecoveryBit(x).recoverPublicKey(i).toBytes(!1).slice(1), y = zt(b);
4367
+ ).addRecoveryBit(_).recoverPublicKey(i).toBytes(!1).slice(1), y = zt(b);
4324
4368
  return "0x" + Me(y.slice(12));
4325
4369
  }
4326
4370
  }
4327
- function pn(r) {
4371
+ function fn(r) {
4328
4372
  const e = new Uint8Array(r.length / 2);
4329
4373
  for (let s = 0; s < e.length; s++)
4330
4374
  e[s] = parseInt(r.substring(s * 2, s * 2 + 2), 16);
@@ -4335,8 +4379,8 @@ function jt(r) {
4335
4379
  for (const s of r) e += s.toString(16).padStart(2, "0");
4336
4380
  return BigInt(e);
4337
4381
  }
4338
- const fn = 3e4, _n = 1e3;
4339
- class xn {
4382
+ const _n = 3e4, xn = 1e3;
4383
+ class gn {
4340
4384
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4341
4385
  async request(e) {
4342
4386
  const s = e.retries ?? 0;
@@ -4347,7 +4391,7 @@ class xn {
4347
4391
  } catch (n) {
4348
4392
  if (t === s) throw n;
4349
4393
  }
4350
- await new Promise((n) => setTimeout(n, _n * 2 ** t));
4394
+ await new Promise((n) => setTimeout(n, xn * 2 ** t));
4351
4395
  }
4352
4396
  throw new Error("Unexpected: retry loop exited without result");
4353
4397
  }
@@ -4355,7 +4399,7 @@ class xn {
4355
4399
  async _doRequest(e) {
4356
4400
  const s = new AbortController(), t = setTimeout(
4357
4401
  () => s.abort(),
4358
- e.timeoutMs ?? fn
4402
+ e.timeoutMs ?? _n
4359
4403
  );
4360
4404
  try {
4361
4405
  const n = await fetch(e.url, {
@@ -4382,7 +4426,7 @@ class xn {
4382
4426
  }
4383
4427
  }
4384
4428
  }
4385
- const gn = /* @__PURE__ */ new Set([
4429
+ const mn = /* @__PURE__ */ new Set([
4386
4430
  "https://cross-wallet-oauth.crosstoken.io",
4387
4431
  "https://stg-cross-wallet-oauth.crosstoken.io",
4388
4432
  "https://dev-cross-wallet-oauth.crosstoken.io"
@@ -4456,21 +4500,21 @@ class Ee {
4456
4500
  nonceLength: l.length,
4457
4501
  authUrlBase: e.authUrl
4458
4502
  });
4459
- const x = window.open(
4503
+ const _ = window.open(
4460
4504
  h,
4461
4505
  "CROSSx OAuth",
4462
4506
  `width=${n},height=${o},left=${i},top=${a}`
4463
4507
  );
4464
- if (!x) {
4508
+ if (!_) {
4465
4509
  t(new Error("팝업 창을 열 수 없습니다. 팝업 차단을 해제해 주세요."));
4466
4510
  return;
4467
4511
  }
4468
4512
  const f = setTimeout(() => {
4469
4513
  d.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), B(), t(new Error("Authentication timeout"));
4470
4514
  }, 5 * 60 * 1e3), w = 10, b = 30;
4471
- let y = 0, k = null;
4472
- const C = () => {
4473
- clearInterval(W), d.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + b + "초간 대기합니다"), k = setTimeout(() => {
4515
+ let y = 0, T = null;
4516
+ const N = () => {
4517
+ clearInterval(W), d.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + b + "초간 대기합니다"), T = setTimeout(() => {
4474
4518
  B(), t(new Error(
4475
4519
  "OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
4476
4520
  ));
@@ -4478,15 +4522,15 @@ class Ee {
4478
4522
  }, W = setInterval(() => {
4479
4523
  y++;
4480
4524
  try {
4481
- x.closed && (y <= w ? C() : (B(), t(new Error("로그인이 취소되었습니다"))));
4525
+ _.closed && (y <= w ? N() : (B(), t(new Error("로그인이 취소되었습니다"))));
4482
4526
  } catch {
4483
- C();
4527
+ N();
4484
4528
  }
4485
4529
  }, 1e3), B = () => {
4486
- clearTimeout(f), clearInterval(W), k && clearTimeout(k), window.removeEventListener("message", j);
4530
+ clearTimeout(f), clearInterval(W), T && clearTimeout(T), window.removeEventListener("message", j);
4487
4531
  }, j = (q) => {
4488
4532
  if (q.origin !== e.expectedOrigin) return;
4489
- if (!gn.has(q.origin)) {
4533
+ if (!mn.has(q.origin)) {
4490
4534
  d.error("[CROSSx] postMessage origin이 허용 목록에 없음:", q.origin), B(), t(new Error("Unauthorized OAuth origin"));
4491
4535
  return;
4492
4536
  }
@@ -4517,8 +4561,8 @@ class Ee {
4517
4561
  d.error("[CROSSx] 토큰을 찾을 수 없음:", q.data), t(new Error("Token not found in response"));
4518
4562
  return;
4519
4563
  }
4520
- const I = (_) => {
4521
- Ee.verifyIdTokenNonce(_, l).then(() => s(A)).catch((g) => {
4564
+ const I = (x) => {
4565
+ Ee.verifyIdTokenNonce(x, l).then(() => s(A)).catch((g) => {
4522
4566
  d.error("[CROSSx] nonce 검증 실패:", g), t(g instanceof Error ? g : new Error("nonce verification failed"));
4523
4567
  });
4524
4568
  };
@@ -4531,8 +4575,8 @@ class Ee {
4531
4575
  });
4532
4576
  }
4533
4577
  }
4534
- const Ce = "crossx_wallet_data", Te = "crossx_mock_pin_hash";
4535
- class mn {
4578
+ const Ne = "crossx_wallet_data", Ae = "crossx_mock_pin_hash";
4579
+ class wn {
4536
4580
  constructor(e, s) {
4537
4581
  this.storage = e, this.pinStore = s ?? null;
4538
4582
  }
@@ -4545,13 +4589,13 @@ class mn {
4545
4589
  async checkWallet() {
4546
4590
  if (this.migrateScenario !== void 0)
4547
4591
  return d.log("[Mock] checkWallet → migration_required"), "migration_required";
4548
- const s = await this.storage.get(Ce) ? "exists" : "not_found";
4592
+ const s = await this.storage.get(Ne) ? "exists" : "not_found";
4549
4593
  return d.log(`[Mock] checkWallet → ${s}`), s;
4550
4594
  }
4551
4595
  async getOrCreateWallet(e) {
4552
4596
  var s;
4553
4597
  try {
4554
- const t = await this.storage.get(Ce);
4598
+ const t = await this.storage.get(Ne);
4555
4599
  if (t) return t;
4556
4600
  const n = {
4557
4601
  id: e,
@@ -4559,16 +4603,16 @@ class mn {
4559
4603
  derivationPath: "m/44'/60'/0'/0/0",
4560
4604
  createdAt: Date.now()
4561
4605
  };
4562
- await this.storage.set(Ce, n);
4606
+ await this.storage.set(Ne, n);
4563
4607
  const o = (s = this.pinStore) == null ? void 0 : s.get();
4564
- return o && (await this.storage.set(Te, o), d.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
4608
+ return o && (await this.storage.set(Ae, o), d.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
4565
4609
  } catch (t) {
4566
4610
  throw new m(p.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", t);
4567
4611
  }
4568
4612
  }
4569
4613
  /** GET /mnemonic/addresses 모킹 — PIN 불필요, 캐시된 주소 반환 */
4570
4614
  async getAddresses(e) {
4571
- const s = await this.storage.get(Ce);
4615
+ const s = await this.storage.get(Ne);
4572
4616
  return s ? [{ address: s.address, index: 0 }] : [];
4573
4617
  }
4574
4618
  async getAddress(e, s) {
@@ -4603,8 +4647,8 @@ class mn {
4603
4647
  var t;
4604
4648
  if (d.log("[Mock] verifyPin"), this.pinScenario === "wrong")
4605
4649
  return !1;
4606
- const s = await this.storage.get(Te);
4607
- return s && s !== e ? !1 : (s || await this.storage.set(Te, e), (t = this.pinStore) == null || t.set(e), d.log("[Mock] verifyPin → 성공"), !0);
4650
+ const s = await this.storage.get(Ae);
4651
+ return s && s !== e ? !1 : (s || await this.storage.set(Ae, e), (t = this.pinStore) == null || t.set(e), d.log("[Mock] verifyPin → 성공"), !0);
4608
4652
  }
4609
4653
  /**
4610
4654
  * POST /mnemonic/change-password 모킹
@@ -4614,10 +4658,10 @@ class mn {
4614
4658
  var o;
4615
4659
  if (d.log("[Mock] changePin"), this.pinScenario === "wrong")
4616
4660
  throw new m(p.PIN_WRONG, "Incorrect PIN.");
4617
- const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Te);
4661
+ const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Ae);
4618
4662
  if (n && t && n !== t)
4619
4663
  throw new m(p.PIN_WRONG, "Incorrect PIN.");
4620
- await this.storage.set(Te, s), d.log("[Mock] changePin 완료");
4664
+ await this.storage.set(Ae, s), d.log("[Mock] changePin 완료");
4621
4665
  }
4622
4666
  async migrateWallet(e, s) {
4623
4667
  var o;
@@ -4648,9 +4692,9 @@ class mn {
4648
4692
  derivationPath: "m/44'/60'/0'/0/0",
4649
4693
  createdAt: Date.now()
4650
4694
  };
4651
- await this.storage.set(Ce, t);
4695
+ await this.storage.set(Ne, t);
4652
4696
  const n = (o = this.pinStore) == null ? void 0 : o.get();
4653
- return n && (await this.storage.set(Te, n), d.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
4697
+ return n && (await this.storage.set(Ae, n), d.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
4654
4698
  }
4655
4699
  /**
4656
4700
  * POST /mnemonic/share-c 모킹
@@ -4679,11 +4723,14 @@ class mn {
4679
4723
  }
4680
4724
  class Le {
4681
4725
  constructor(e, s, t, n, o) {
4682
- this._walletStatusCache = null, this.adapterConfig = e, this.projectId = e.projectId, this.storage = s, this.transport = t, this.tokenStore = n, this.pinStore = o ?? null;
4726
+ this._refreshPromise = null, this._walletStatusCache = null, this.adapterConfig = e, this.projectId = e.projectId, this.storage = s, this.transport = t, this.tokenStore = n, this.pinStore = o ?? null;
4683
4727
  }
4684
4728
  setOnUnauthorized(e) {
4685
4729
  this._onUnauthorized = e;
4686
4730
  }
4731
+ setTokenRefresher(e) {
4732
+ this._onTokenRefresh = e;
4733
+ }
4687
4734
  getPin() {
4688
4735
  var e;
4689
4736
  return ((e = this.pinStore) == null ? void 0 : e.get()) ?? void 0;
@@ -4691,60 +4738,86 @@ class Le {
4691
4738
  get baseUrl() {
4692
4739
  return this.adapterConfig.gatewayUrl;
4693
4740
  }
4694
- getAuthToken() {
4741
+ /**
4742
+ * 유효한 access_token을 확보합니다.
4743
+ *
4744
+ * 1. 토큰이 있고 만료 임박하지 않으면 즉시 반환
4745
+ * 2. 만료 임박/만료 시 → 자동 갱신 시도 (동시 호출 deduplicate)
4746
+ * 3. 갱신 실패 시 기존 토큰이라도 있으면 반환 (서버가 최종 판단)
4747
+ * 4. 토큰 자체가 없으면 AUTH_NOT_AUTHENTICATED throw
4748
+ */
4749
+ async ensureValidToken() {
4695
4750
  const e = this.tokenStore.get();
4696
- if (!e)
4697
- throw new m(
4698
- p.AUTH_NOT_AUTHENTICATED,
4699
- "인증 토큰을 찾을 수 없습니다. 먼저 로그인해 주세요."
4700
- );
4701
- return e;
4751
+ if (e && !this.tokenStore.isExpiringSoon(tr))
4752
+ return e;
4753
+ if (this._onTokenRefresh && await this.deduplicatedRefresh()) {
4754
+ const t = this.tokenStore.get();
4755
+ if (t) return t;
4756
+ }
4757
+ if (e)
4758
+ return d.warn("[CROSSx] 토큰 갱신 실패 — 기존 토큰으로 요청 시도"), e;
4759
+ throw new m(
4760
+ p.AUTH_NOT_AUTHENTICATED,
4761
+ "인증 토큰을 찾을 수 없습니다. 먼저 로그인해 주세요."
4762
+ );
4702
4763
  }
4703
- async request(e, s, t) {
4704
- var a, c;
4705
- const n = this.getAuthToken(), o = `${this.baseUrl}${s}`, i = {
4706
- Authorization: `Bearer ${n}`,
4764
+ /** 동시 갱신 요청을 단일 Promise로 합칩니다. */
4765
+ deduplicatedRefresh() {
4766
+ return this._refreshPromise ? this._refreshPromise : (d.log("[CROSSx] 토큰 만료 임박/만료 — 자동 갱신 시도"), this._refreshPromise = this._onTokenRefresh().finally(() => {
4767
+ this._refreshPromise = null;
4768
+ }), this._refreshPromise);
4769
+ }
4770
+ async request(e, s, t, n = !1) {
4771
+ var c, l, u;
4772
+ const o = await this.ensureValidToken(), i = `${this.baseUrl}${s}`, a = {
4773
+ Authorization: `Bearer ${o}`,
4707
4774
  "Content-Type": "application/json",
4708
4775
  "X-Project-Id": this.projectId
4709
4776
  };
4710
4777
  try {
4711
- const u = (await this.transport.request({
4712
- url: o,
4778
+ const _ = (await this.transport.request({
4779
+ url: i,
4713
4780
  method: e,
4714
- headers: i,
4781
+ headers: a,
4715
4782
  body: t ?? void 0
4716
4783
  })).data;
4717
- if (u && typeof u.code == "number") {
4718
- if (u.code < 0 || u.code >= 400) {
4719
- const h = u.message || u.data || "API 요청에 실패했습니다";
4784
+ if (_ && typeof _.code == "number") {
4785
+ if (_.code < 0 || _.code >= 400) {
4786
+ const f = _.message || _.data || "API 요청에 실패했습니다";
4720
4787
  d.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
4721
- code: u.code,
4722
- message: h,
4723
- url: o,
4788
+ code: _.code,
4789
+ message: f,
4790
+ url: i,
4724
4791
  method: e
4725
4792
  });
4726
- const x = Le.mapGatewayError(u.code, u.data), f = Le.getGatewayErrorMessage(u.code, h), w = u.data, b = x === p.PIN_LOCKED ? Le.extractLockDetails(w) : w ?? void 0, y = new m(x, f, b);
4727
- throw x === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (d.warn("[CROSSx] Gateway -10002 감지 — 강제 로그아웃 실행"), this._onUnauthorized()), y;
4793
+ const w = Le.mapGatewayError(_.code, _.data);
4794
+ if (w === p.AUTH_NOT_AUTHENTICATED && !n && this._onTokenRefresh && (d.warn("[CROSSx] Gateway -10002 감지 — 토큰 갱신 후 재시도"), await this.deduplicatedRefresh()))
4795
+ return this.request(e, s, t, !0);
4796
+ const b = Le.getGatewayErrorMessage(_.code, f), y = _.data, T = w === p.PIN_LOCKED ? Le.extractLockDetails(y) : y ?? void 0, N = new m(w, b, T);
4797
+ throw w === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (d.warn("[CROSSx] Gateway -10002 갱신 재시도 실패 — 강제 로그아웃 실행"), this._onUnauthorized()), N;
4728
4798
  }
4729
- return d.log("[CROSSx] Wallet Gateway API 성공:", { code: u.code, url: o, method: e }), u.data ?? u;
4799
+ return d.log("[CROSSx] Wallet Gateway API 성공:", { code: _.code, url: i, method: e }), _.data ?? _;
4730
4800
  }
4731
- return u;
4732
- } catch (l) {
4733
- if (l instanceof m) throw l;
4734
- if ((a = l.response) != null && a.data) {
4735
- const u = l.response.data, h = u.message || u.data || "API 요청에 실패했습니다", x = u.code || "UNKNOWN";
4801
+ return _;
4802
+ } catch (h) {
4803
+ if (h instanceof m) throw h;
4804
+ const _ = ((c = h.response) == null ? void 0 : c.status) ?? h.status;
4805
+ if ((_ === 401 || _ === 403) && !n && this._onTokenRefresh && (d.warn(`[CROSSx] HTTP ${_} 감지 토큰 갱신 재시도`), await this.deduplicatedRefresh()))
4806
+ return this.request(e, s, t, !0);
4807
+ if ((l = h.response) != null && l.data) {
4808
+ const f = h.response.data, w = f.message || f.data || "API 요청에 실패했습니다", b = f.code || "UNKNOWN";
4736
4809
  throw d.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
4737
- code: x,
4738
- message: h,
4739
- url: o,
4810
+ code: b,
4811
+ message: w,
4812
+ url: i,
4740
4813
  method: e,
4741
- status: (c = l.response) == null ? void 0 : c.status
4814
+ status: (u = h.response) == null ? void 0 : u.status
4742
4815
  }), new m(
4743
4816
  p.UNKNOWN_ERROR,
4744
- `Wallet Gateway 오류 (${x}): ${h}`
4817
+ `Wallet Gateway 오류 (${b}): ${w}`
4745
4818
  );
4746
4819
  }
4747
- throw l;
4820
+ throw h;
4748
4821
  }
4749
4822
  }
4750
4823
  /**
@@ -5096,7 +5169,7 @@ class De {
5096
5169
  }
5097
5170
  isCacheValid() {
5098
5171
  if (this.loadedAt === 0) return !1;
5099
- const e = this.usingFallback ? sr : tr;
5172
+ const e = this.usingFallback ? rr : sr;
5100
5173
  return e === 0 ? !0 : Date.now() - this.loadedAt < e;
5101
5174
  }
5102
5175
  populateCache(e, s) {
@@ -5158,7 +5231,7 @@ class De {
5158
5231
  }
5159
5232
  }
5160
5233
  }
5161
- const Yt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", wn = {
5234
+ const Yt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", yn = {
5162
5235
  light: {
5163
5236
  bg: "#FFFFFF",
5164
5237
  border: "rgba(18,18,18,0.05)",
@@ -5215,7 +5288,7 @@ const Yt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", wn = {
5215
5288
  }
5216
5289
  };
5217
5290
  function Jt(r, e) {
5218
- const s = wn[r], t = e == null ? void 0 : e[r];
5291
+ const s = yn[r], t = e == null ? void 0 : e[r];
5219
5292
  return t ? {
5220
5293
  ...s,
5221
5294
  // ── Brand
@@ -5247,7 +5320,7 @@ function Jt(r, e) {
5247
5320
  ...t.error !== void 0 && { errorColor: t.error }
5248
5321
  } : s;
5249
5322
  }
5250
- const yn = `
5323
+ const bn = `
5251
5324
  @import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
5252
5325
 
5253
5326
  #${te} {
@@ -6975,7 +7048,7 @@ const yn = `
6975
7048
  `;
6976
7049
  function he() {
6977
7050
  let r = document.getElementById(Yt);
6978
- r || (r = document.createElement("style"), r.id = Yt, document.head.appendChild(r)), r.textContent = yn;
7051
+ r || (r = document.createElement("style"), r.id = Yt, document.head.appendChild(r)), r.textContent = bn;
6979
7052
  }
6980
7053
  function pe(r) {
6981
7054
  const e = (s) => s.stopPropagation();
@@ -6986,7 +7059,7 @@ function pe(r) {
6986
7059
  function se(r) {
6987
7060
  return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
6988
7061
  }
6989
- function bn(r, e = "CROSS", s = 18) {
7062
+ function vn(r, e = "CROSS", s = 18) {
6990
7063
  if (!r || r === "0x" || r === "0x0") return null;
6991
7064
  try {
6992
7065
  const t = BigInt(r);
@@ -7037,18 +7110,18 @@ function rt(r) {
7037
7110
  return r;
7038
7111
  }
7039
7112
  }
7040
- function vn(r) {
7113
+ function Sn(r) {
7041
7114
  try {
7042
7115
  return BigInt(r).toLocaleString();
7043
7116
  } catch {
7044
7117
  return r;
7045
7118
  }
7046
7119
  }
7047
- function Sn(r) {
7120
+ function En(r) {
7048
7121
  const { gasLimit: e, gasPrice: s, maxFeePerGas: t, maxPriorityFeePerGas: n, nativeSymbol: o = "ETH", nativeDecimals: i = 18 } = r;
7049
7122
  if (!e) return null;
7050
7123
  try {
7051
- const a = BigInt(e), c = vn(e);
7124
+ const a = BigInt(e), c = Sn(e);
7052
7125
  if (t) {
7053
7126
  const l = a * BigInt(t);
7054
7127
  return {
@@ -7073,26 +7146,26 @@ function Sn(r) {
7073
7146
  return null;
7074
7147
  }
7075
7148
  }
7076
- function Ns(r) {
7077
- const e = Sn(r);
7149
+ function Cs(r) {
7150
+ const e = En(r);
7078
7151
  if (!e) return Y("Estimated fee", "<span>—</span>");
7079
7152
  let s = Y("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
7080
7153
  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;
7081
7154
  }
7082
- const xe = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
7155
+ const ge = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
7083
7156
  <rect x="9" y="9" width="13" height="13" rx="2"/>
7084
7157
  <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
7085
7158
  </svg>`, ie = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
7086
7159
  <line x1="18" y1="6" x2="6" y2="18"/>
7087
7160
  <line x1="6" y1="6" x2="18" y2="18"/>
7088
- </svg>`, En = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7161
+ </svg>`, In = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7089
7162
  <circle cx="20" cy="20" r="20" fill="#00D5AA"/>
7090
7163
  <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"/>
7091
7164
  </svg>`, wt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
7092
7165
  <rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
7093
7166
  <path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
7094
7167
  <rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
7095
- </svg>`, In = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
7168
+ </svg>`, Tn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
7096
7169
  <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)"/>
7097
7170
  </svg>`, An = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
7098
7171
  <circle cx="12" cy="12" r="12" fill="var(--cx-error)"/>
@@ -7132,9 +7205,9 @@ function Y(r, e) {
7132
7205
  <div class="__crossx-row-value">${e}</div>
7133
7206
  </div>`;
7134
7207
  }
7135
- function Tn(r, e) {
7208
+ function Rn(r, e) {
7136
7209
  const s = e, t = Ye(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
7137
- <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", o = Ns(r), i = r.data ?? "0x", a = document.createElement("div");
7210
+ <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${ge}</button>` : "<span>—</span>", o = Cs(r), i = r.data ?? "0x", a = document.createElement("div");
7138
7211
  return a.id = te, a.innerHTML = `
7139
7212
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7140
7213
  <div class="__crossx-header">
@@ -7172,9 +7245,9 @@ function Tn(r, e) {
7172
7245
  </div>
7173
7246
  `, a;
7174
7247
  }
7175
- function Rn(r, e) {
7248
+ function kn(r, e) {
7176
7249
  const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Ye(r.dappName), i = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
7177
- <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", a = Ns(r), l = bn(r.value, t, n) ?? "—", u = document.createElement("div");
7250
+ <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${ge}</button>` : "<span>—</span>", a = Cs(r), l = vn(r.value, t, n) ?? "—", u = document.createElement("div");
7178
7251
  return u.id = te, u.innerHTML = `
7179
7252
  <div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7180
7253
  <div class="__crossx-header">
@@ -7214,10 +7287,10 @@ function Ye(r) {
7214
7287
  function U(r) {
7215
7288
  return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
7216
7289
  }
7217
- function kn(r) {
7290
+ function Pn(r) {
7218
7291
  return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
7219
7292
  }
7220
- function Pn(r) {
7293
+ function On(r) {
7221
7294
  if (typeof r == "string") return U(r);
7222
7295
  if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
7223
7296
  try {
@@ -7226,14 +7299,14 @@ function Pn(r) {
7226
7299
  return String(r);
7227
7300
  }
7228
7301
  }
7229
- function On(r, e) {
7302
+ function Cn(r, e) {
7230
7303
  const s = Y(
7231
7304
  "From",
7232
7305
  `<span class="__crossx-addr-text">${se(r.from)}</span>
7233
- <button class="__crossx-copy-btn" data-copy="${U(r.from)}" title="Copy address">${xe}</button>`
7306
+ <button class="__crossx-copy-btn" data-copy="${U(r.from)}" title="Copy address">${ge}</button>`
7234
7307
  ), t = r.to ? Y("To", `<span class="__crossx-addr-text">${se(r.to)}</span>
7235
- <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</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>
7236
- <button class="__crossx-copy-btn" data-copy="${U(r.txHash)}" title="Copy hash">${xe}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
7308
+ <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${ge}</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>
7309
+ <button class="__crossx-copy-btn" data-copy="${U(r.txHash)}" title="Copy hash">${ge}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
7237
7310
  <span class="__crossx-total-label">Total<br>(including fees)</span>
7238
7311
  <span class="__crossx-total-amount">${U(r.total)}</span>
7239
7312
  </div>` : "", c = document.createElement("div");
@@ -7275,10 +7348,10 @@ function Nn(r, e) {
7275
7348
  </div>
7276
7349
  `, s;
7277
7350
  }
7278
- function Cn(r, e, s) {
7351
+ function Ln(r, e, s) {
7279
7352
  const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
7280
7353
  if (o) {
7281
- const w = n ? An : t ? "" : In, b = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
7354
+ const w = n ? An : t ? "" : Tn, b = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
7282
7355
  w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${b}</span>`) : o.textContent = b;
7283
7356
  }
7284
7357
  if (i && !r.querySelector("#__crossx-close-btn")) {
@@ -7288,9 +7361,9 @@ function Cn(r, e, s) {
7288
7361
  const a = r.querySelector("#__crossx-progress-body");
7289
7362
  if (!a) return;
7290
7363
  const c = e.from ? Y("From", `<span class="__crossx-addr-text">${se(e.from)}</span>
7291
- <button class="__crossx-copy-btn" data-copy="${U(e.from)}" title="Copy address">${xe}</button>`) : "", l = e.to ? Y("To", `<span class="__crossx-addr-text">${se(e.to)}</span>
7292
- <button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${xe}</button>`) : "", u = e.amount ? Y("Transfer", `<span>${U(e.amount)}</span>`) : "", h = e.fees ? Y("Tx Fee", `<span>${U(e.fees)}</span>`) : "", x = e.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(e.txHash)}</span>
7293
- <button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${xe}</button>`) : "", f = e.total ? `<div class="__crossx-total-pill">
7364
+ <button class="__crossx-copy-btn" data-copy="${U(e.from)}" title="Copy address">${ge}</button>`) : "", l = e.to ? Y("To", `<span class="__crossx-addr-text">${se(e.to)}</span>
7365
+ <button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${ge}</button>`) : "", u = e.amount ? Y("Transfer", `<span>${U(e.amount)}</span>`) : "", h = e.fees ? Y("Tx Fee", `<span>${U(e.fees)}</span>`) : "", _ = e.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(e.txHash)}</span>
7366
+ <button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${ge}</button>`) : "", f = e.total ? `<div class="__crossx-total-pill">
7294
7367
  <span class="__crossx-total-label">Total<br>(including fees)</span>
7295
7368
  <span class="__crossx-total-amount">${U(e.total)}</span>
7296
7369
  </div>` : "";
@@ -7300,21 +7373,21 @@ function Cn(r, e, s) {
7300
7373
  ${l}
7301
7374
  ${u}
7302
7375
  ${h}
7303
- ${x}
7376
+ ${_}
7304
7377
  </div>
7305
7378
  ${f}
7306
7379
  <button class="__crossx-approve-btn" id="__crossx-done-btn">${t ? "All Done" : "Done"}</button>
7307
7380
  `, a.querySelectorAll(".__crossx-copy-btn").forEach((w) => {
7308
7381
  w.addEventListener("click", (b) => {
7309
- var k;
7382
+ var T;
7310
7383
  b.stopPropagation();
7311
7384
  const y = w.dataset.copy;
7312
- y && ((k = navigator.clipboard) == null || k.writeText(y).catch(() => {
7385
+ y && ((T = navigator.clipboard) == null || T.writeText(y).catch(() => {
7313
7386
  }));
7314
7387
  });
7315
7388
  });
7316
7389
  }
7317
- function Ln(r, e) {
7390
+ function Dn(r, e) {
7318
7391
  const s = e, t = Ye(r.dappName), n = U(r.message), o = document.createElement("div");
7319
7392
  return o.id = te, o.innerHTML = `
7320
7393
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
@@ -7346,7 +7419,7 @@ function Ln(r, e) {
7346
7419
  </div>
7347
7420
  `, o;
7348
7421
  }
7349
- function Dn(r, e) {
7422
+ function Mn(r, e) {
7350
7423
  const s = e, t = Ye(r.dappName);
7351
7424
  let n = {};
7352
7425
  if (typeof r.typedData == "string")
@@ -7362,8 +7435,8 @@ function Dn(r, e) {
7362
7435
  <span class="__crossx-td-value">${U(o)}</span>
7363
7436
  </div>`;
7364
7437
  for (const [l, u] of Object.entries(i)) {
7365
- const h = Pn(u), f = kn(u) ? `<span class="__crossx-addr-text">${se(u)}</span>
7366
- <button class="__crossx-copy-btn" data-copy="${U(String(u))}" title="Copy">${xe}</button>` : `<span>${h}</span>`;
7438
+ const h = On(u), f = Pn(u) ? `<span class="__crossx-addr-text">${se(u)}</span>
7439
+ <button class="__crossx-copy-btn" data-copy="${U(String(u))}" title="Copy">${ge}</button>` : `<span>${h}</span>`;
7367
7440
  a += `
7368
7441
  <div class="__crossx-td-row">
7369
7442
  <span class="__crossx-td-label">${U(l)}</span>
@@ -7401,11 +7474,11 @@ function Dn(r, e) {
7401
7474
  </div>
7402
7475
  `, c;
7403
7476
  }
7404
- const Mn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
7477
+ const $n = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
7405
7478
  <line x1="12" y1="5" x2="12" y2="19"/>
7406
7479
  <line x1="5" y1="12" x2="19" y2="12"/>
7407
7480
  </svg>`;
7408
- function $n(r, e, s) {
7481
+ function Bn(r, e, s) {
7409
7482
  const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
7410
7483
  const a = t && i.address.toLowerCase() === t;
7411
7484
  return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${U(i.address)}">
@@ -7436,7 +7509,7 @@ function $n(r, e, s) {
7436
7509
  ${n}
7437
7510
  </div>
7438
7511
  <button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
7439
- <span class="__crossx-wallet-add-icon">${Mn}</span>
7512
+ <span class="__crossx-wallet-add-icon">${$n}</span>
7440
7513
  <span class="__crossx-wallet-add-label">add a wallet</span>
7441
7514
  </button>
7442
7515
  </div>
@@ -7445,16 +7518,16 @@ function $n(r, e, s) {
7445
7518
  </div>
7446
7519
  `, o;
7447
7520
  }
7448
- const Bn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7521
+ const Un = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7449
7522
  <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"/>
7450
7523
  <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"/>
7451
- </svg>`, Un = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7524
+ </svg>`, Hn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7452
7525
  <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"/>
7453
7526
  <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"/>
7454
7527
  <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"/>
7455
7528
  <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"/>
7456
7529
  </svg>`;
7457
- function Hn(r, e = !1) {
7530
+ function Fn(r, e = !1) {
7458
7531
  const s = r, t = e ? `
7459
7532
  <div class="__crossx-login-or-divider">
7460
7533
  <hr><span>or</span><hr>
@@ -7478,11 +7551,11 @@ function Hn(r, e = !1) {
7478
7551
  <div class="__crossx-body">
7479
7552
  <div class="__crossx-login-btn-row">
7480
7553
  <button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
7481
- <span class="__crossx-login-icon" style="color:var(--cx-value);">${Bn}</span>
7554
+ <span class="__crossx-login-icon" style="color:var(--cx-value);">${Un}</span>
7482
7555
  <span class="__crossx-login-btn-label">Sign in with&nbsp;&nbsp;Apple</span>
7483
7556
  </button>
7484
7557
  <button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
7485
- <span class="__crossx-login-icon">${Un}</span>
7558
+ <span class="__crossx-login-icon">${Hn}</span>
7486
7559
  <span class="__crossx-login-btn-label">Sign in with&nbsp;&nbsp;Google</span>
7487
7560
  </button>
7488
7561
  </div>${t}
@@ -7493,7 +7566,7 @@ function Hn(r, e = !1) {
7493
7566
  </div>
7494
7567
  `, n;
7495
7568
  }
7496
- function Fn(r, e = !0) {
7569
+ function Gn(r, e = !0) {
7497
7570
  const s = r, t = e ? `<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>` : "", n = e ? '<button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>' : "", o = document.createElement("div");
7498
7571
  return o.id = te, o.innerHTML = `
7499
7572
  <div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
@@ -7509,7 +7582,7 @@ function Fn(r, e = !0) {
7509
7582
  <p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
7510
7583
  </div>
7511
7584
  <button class="__crossx-recover-btn" id="__crossx-recover-btn">
7512
- <span class="__crossx-recover-icon">${En}</span>
7585
+ <span class="__crossx-recover-icon">${In}</span>
7513
7586
  <span class="__crossx-recover-label">Import from Social Backup</span>
7514
7587
  </button>
7515
7588
  ${n}
@@ -7517,7 +7590,7 @@ function Fn(r, e = !0) {
7517
7590
  </div>
7518
7591
  `, o;
7519
7592
  }
7520
- function Gn(r, e) {
7593
+ function Wn(r, e) {
7521
7594
  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>' : "", u = i ? `<p class="__crossx-pin-error-text">${t}</p>` : "", h = document.createElement("div");
7522
7595
  return h.id = te, h.innerHTML = `
7523
7596
  <div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
@@ -7541,12 +7614,12 @@ function Gn(r, e) {
7541
7614
  </div>
7542
7615
  `, h;
7543
7616
  }
7544
- function Wn(r) {
7617
+ function qn(r) {
7545
7618
  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");
7546
7619
  return `${n}, ${o} ${i} ${a}:${c}`;
7547
7620
  }
7548
- function qn(r, e, s) {
7549
- const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ? Wn(o) : null, a = document.createElement("div");
7621
+ function Kn(r, e, s) {
7622
+ const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ? qn(o) : null, a = document.createElement("div");
7550
7623
  return a.id = te, a.innerHTML = `
7551
7624
  <div class="__crossx-card __crossx-card--migration" style="${ce(t)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7552
7625
  <div class="__crossx-header">
@@ -7576,10 +7649,10 @@ function qn(r, e, s) {
7576
7649
  return () => clearInterval(h);
7577
7650
  } };
7578
7651
  }
7579
- function Kn(r) {
7652
+ function Vn(r) {
7580
7653
  const s = [r.check1, r.check2].map((t, n) => `
7581
7654
  <div class="__crossx-pw-notice-item" data-check-index="${n}" role="checkbox" aria-checked="false" tabindex="0">
7582
- <div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${jn}</div>
7655
+ <div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${Yn}</div>
7583
7656
  <span class="__crossx-pw-notice-item-text">${U(t)}</span>
7584
7657
  </div>
7585
7658
  `).join("");
@@ -7594,7 +7667,7 @@ function Kn(r) {
7594
7667
  <div class="__crossx-pw-fields __crossx-pw-fields--notice">
7595
7668
  <div class="__crossx-pw-notice-header">
7596
7669
  <div class="__crossx-pw-notice-title-row">
7597
- <span class="__crossx-pw-notice-icon">${Yn}</span>
7670
+ <span class="__crossx-pw-notice-icon">${Jn}</span>
7598
7671
  <p class="__crossx-pw-notice-title">${U(r.noticeTitle)}</p>
7599
7672
  </div>
7600
7673
  <p class="__crossx-pw-notice-desc">${U(r.noticeDesc)}</p>
@@ -7614,7 +7687,7 @@ function Kn(r) {
7614
7687
  }
7615
7688
  function nt(r) {
7616
7689
  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">
7617
- ${Cs}
7690
+ ${Ns}
7618
7691
  <span id="__crossx-pin6-lock-countdown"></span>
7619
7692
  </p>` : "", a = e ? " --locked" : "", c = Array.from(
7620
7693
  { length: 6 },
@@ -7646,28 +7719,28 @@ function Zt(r, e) {
7646
7719
  </div>
7647
7720
  `, s;
7648
7721
  }
7649
- function Vn(r, e) {
7722
+ function zn(r, e) {
7650
7723
  if (r.length !== 6) return e.tooShort;
7651
7724
  if (!/^\d+$/.test(r)) return e.numbersOnly;
7652
7725
  if (/(.)\1{2}/.test(r)) return e.repeatingDigit;
7653
7726
  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);
7654
7727
  return t || n ? e.sequential : r[0] !== r[1] && r === r.slice(0, 2).repeat(3) ? e.alternatingPattern : null;
7655
7728
  }
7656
- function zn(r) {
7729
+ function jn(r) {
7657
7730
  const e = Math.max(0, Math.ceil(r / 1e3)), s = Math.floor(e / 3600), t = Math.floor(e % 3600 / 60), n = e % 60;
7658
7731
  return s > 0 ? `${s}h ${String(t).padStart(2, "0")}m` : `${String(t).padStart(2, "0")}:${String(n).padStart(2, "0")}`;
7659
7732
  }
7660
7733
  function ot(r, e, s, t, n, o) {
7661
7734
  var j, q;
7662
7735
  let i = !!(o && o > Date.now()), a = !1;
7663
- const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), u = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), x = () => r.querySelector("#__crossx-pin6-lock-countdown"), f = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((P) => P.value).join(""), b = (P) => {
7736
+ const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), u = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), _ = () => r.querySelector("#__crossx-pin6-lock-countdown"), f = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((P) => P.value).join(""), b = (P) => {
7664
7737
  i = P, c().forEach((S) => {
7665
7738
  S.disabled = P, S.classList.toggle("--locked", P);
7666
7739
  });
7667
7740
  }, y = () => {
7668
7741
  const P = u();
7669
7742
  P && (P.textContent = "");
7670
- }, k = (P) => {
7743
+ }, T = (P) => {
7671
7744
  const S = u();
7672
7745
  S && (S.textContent = P);
7673
7746
  const L = l();
@@ -7677,7 +7750,7 @@ function ot(r, e, s, t, n, o) {
7677
7750
  var G;
7678
7751
  return (G = c()[0]) == null ? void 0 : G.focus();
7679
7752
  }, 50);
7680
- }, C = (P) => {
7753
+ }, N = (P) => {
7681
7754
  var A;
7682
7755
  b(!0), c().forEach((I) => {
7683
7756
  I.value = "";
@@ -7685,17 +7758,17 @@ function ot(r, e, s, t, n, o) {
7685
7758
  const S = u();
7686
7759
  if (S && (S.textContent = "Too many failed attempts. Please wait."), !h()) {
7687
7760
  const I = document.createElement("p");
7688
- I.className = "__crossx-pin6-lock-msg", I.id = "__crossx-pin6-lock-msg", I.innerHTML = `${Cs}<span id="__crossx-pin6-lock-countdown"></span>`;
7689
- const _ = u();
7690
- _ ? _.insertAdjacentElement("afterend", I) : (A = f()) == null || A.appendChild(I);
7761
+ I.className = "__crossx-pin6-lock-msg", I.id = "__crossx-pin6-lock-msg", I.innerHTML = `${Ns}<span id="__crossx-pin6-lock-countdown"></span>`;
7762
+ const x = u();
7763
+ x ? x.insertAdjacentElement("afterend", I) : (A = f()) == null || A.appendChild(I);
7691
7764
  }
7692
7765
  const L = () => {
7693
7766
  var g;
7694
- const I = P - Date.now(), _ = x();
7767
+ const I = P - Date.now(), x = _();
7695
7768
  I <= 0 ? (clearInterval(G), b(!1), (g = h()) == null || g.remove(), S && (S.textContent = ""), setTimeout(() => {
7696
7769
  var v;
7697
7770
  return (v = c()[0]) == null ? void 0 : v.focus();
7698
- }, 50)) : _ && (_.textContent = ` ${zn(I)}`);
7771
+ }, 50)) : x && (x.textContent = ` ${jn(I)}`);
7699
7772
  }, G = setInterval(L, 1e3);
7700
7773
  L();
7701
7774
  const O = new MutationObserver(() => {
@@ -7712,7 +7785,7 @@ function ot(r, e, s, t, n, o) {
7712
7785
  try {
7713
7786
  if (n) {
7714
7787
  const S = await n(P);
7715
- S.ok ? e(P) : S.lockExpiresAt ? C(S.lockExpiresAt) : k(S.error ?? "Incorrect PIN. Please try again.");
7788
+ S.ok ? e(P) : S.lockExpiresAt ? N(S.lockExpiresAt) : T(S.error ?? "Incorrect PIN. Please try again.");
7716
7789
  } else
7717
7790
  e(P);
7718
7791
  } catch (S) {
@@ -7724,7 +7797,7 @@ function ot(r, e, s, t, n, o) {
7724
7797
  }
7725
7798
  }
7726
7799
  };
7727
- o && o > Date.now() ? C(o) : setTimeout(() => {
7800
+ o && o > Date.now() ? N(o) : setTimeout(() => {
7728
7801
  var P;
7729
7802
  return (P = c()[0]) == null ? void 0 : P.focus();
7730
7803
  }, 100);
@@ -7759,20 +7832,20 @@ function ot(r, e, s, t, n, o) {
7759
7832
  const G = (((A = L.clipboardData) == null ? void 0 : A.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
7760
7833
  if (!G) return;
7761
7834
  const O = c();
7762
- G.split("").forEach((_, g) => {
7763
- O[g] && (O[g].value = _);
7835
+ G.split("").forEach((x, g) => {
7836
+ O[g] && (O[g].value = x);
7764
7837
  }), (I = O[Math.min(G.length - 1, 5)]) == null || I.focus(), y(), w().length === 6 && setTimeout(W, 80);
7765
7838
  }), P.addEventListener("focus", () => P.select());
7766
7839
  });
7767
7840
  }
7768
- const Cs = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
7841
+ const Ns = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
7769
7842
  <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"/>
7770
- </svg>`, jn = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
7843
+ </svg>`, Yn = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
7771
7844
  <path d="M1 4.5L4 7.5L10 1" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
7772
- </svg>`, Yn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
7845
+ </svg>`, Jn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
7773
7846
  <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"/>
7774
7847
  </svg>`;
7775
- function Jn(r, e, s) {
7848
+ function Xn(r, e, s) {
7776
7849
  var o;
7777
7850
  const t = r.querySelectorAll(".__crossx-pin-input");
7778
7851
  t.forEach((i, a) => {
@@ -7790,8 +7863,8 @@ function Jn(r, e, s) {
7790
7863
  c.preventDefault();
7791
7864
  const l = (((h = c.clipboardData) == null ? void 0 : h.getData("text")) ?? "").replace(/\D/g, "").slice(0, 4);
7792
7865
  if (!l) return;
7793
- l.split("").forEach((x, f) => {
7794
- t[f] && (t[f].value = x);
7866
+ l.split("").forEach((_, f) => {
7867
+ t[f] && (t[f].value = _);
7795
7868
  });
7796
7869
  const u = Math.min(l.length, 3);
7797
7870
  t[u].focus(), l.length === 4 && setTimeout(() => e(l), 200);
@@ -7805,7 +7878,7 @@ function Jn(r, e, s) {
7805
7878
  }
7806
7879
  }), (o = t[0]) == null || o.focus();
7807
7880
  }
7808
- class Xn {
7881
+ class Zn {
7809
7882
  constructor(e = "light", s) {
7810
7883
  this.theme = e, this.overrides = s, this.tokens = Jt(e, s);
7811
7884
  }
@@ -7827,7 +7900,7 @@ class Xn {
7827
7900
  return new Promise((n) => {
7828
7901
  var b;
7829
7902
  he();
7830
- const o = [...e], i = $n(o, this.tokens, t), a = document.body.style.overflow;
7903
+ const o = [...e], i = Bn(o, this.tokens, t), a = document.body.style.overflow;
7831
7904
  document.body.style.overflow = "hidden", pe(i);
7832
7905
  let c = !1;
7833
7906
  const l = () => {
@@ -7840,8 +7913,8 @@ class Xn {
7840
7913
  (() => {
7841
7914
  i.querySelectorAll(".__crossx-wallet-item").forEach((y) => {
7842
7915
  y.addEventListener("click", () => {
7843
- const k = y.dataset.walletAddress ?? "", C = parseInt(y.dataset.walletIndex ?? "0", 10);
7844
- u({ address: k, index: C });
7916
+ const T = y.dataset.walletAddress ?? "", N = parseInt(y.dataset.walletIndex ?? "0", 10);
7917
+ u({ address: T, index: N });
7845
7918
  });
7846
7919
  });
7847
7920
  })();
@@ -7851,10 +7924,10 @@ class Xn {
7851
7924
  try {
7852
7925
  const y = await s();
7853
7926
  o.push(y);
7854
- const k = i.querySelector("#__crossx-wallet-list");
7855
- if (k) {
7856
- const C = document.createElement("button");
7857
- C.className = "__crossx-wallet-item", C.dataset.walletIndex = String(y.index), C.dataset.walletAddress = y.address, C.innerHTML = `<span class="__crossx-wallet-addr">${se(y.address)}</span>`, C.addEventListener("click", () => u(y)), k.appendChild(C), C.scrollIntoView({ behavior: "smooth", block: "nearest" });
7927
+ const T = i.querySelector("#__crossx-wallet-list");
7928
+ if (T) {
7929
+ const N = document.createElement("button");
7930
+ N.className = "__crossx-wallet-item", N.dataset.walletIndex = String(y.index), N.dataset.walletAddress = y.address, N.innerHTML = `<span class="__crossx-wallet-addr">${se(y.address)}</span>`, N.addEventListener("click", () => u(y)), T.appendChild(N), N.scrollIntoView({ behavior: "smooth", block: "nearest" });
7858
7931
  }
7859
7932
  } catch {
7860
7933
  } finally {
@@ -7879,20 +7952,20 @@ class Xn {
7879
7952
  return new Promise((s) => {
7880
7953
  var c, l, u, h;
7881
7954
  he();
7882
- const t = Hn(this.tokens, e == null ? void 0 : e.showConnectOtherWallets);
7955
+ const t = Fn(this.tokens, e == null ? void 0 : e.showConnectOtherWallets);
7883
7956
  pe(t);
7884
- const n = () => t.remove(), o = (x) => {
7885
- n(), s(x);
7957
+ const n = () => t.remove(), o = (_) => {
7958
+ n(), s(_);
7886
7959
  }, i = () => {
7887
7960
  n(), s(null);
7888
7961
  };
7889
- (c = t.querySelector("#__crossx-apple-btn")) == null || c.addEventListener("click", () => o("apple")), (l = t.querySelector("#__crossx-google-btn")) == null || l.addEventListener("click", () => o("google")), (u = t.querySelector("#__crossx-connect-btn")) == null || u.addEventListener("click", () => o("external")), (h = t.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", i), t.addEventListener("click", (x) => {
7890
- x.target === t && i();
7891
- }), t.querySelectorAll(".__crossx-login-terms-link").forEach((x) => {
7892
- x.addEventListener("click", (f) => f.stopPropagation());
7962
+ (c = t.querySelector("#__crossx-apple-btn")) == null || c.addEventListener("click", () => o("apple")), (l = t.querySelector("#__crossx-google-btn")) == null || l.addEventListener("click", () => o("google")), (u = t.querySelector("#__crossx-connect-btn")) == null || u.addEventListener("click", () => o("external")), (h = t.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", i), t.addEventListener("click", (_) => {
7963
+ _.target === t && i();
7964
+ }), t.querySelectorAll(".__crossx-login-terms-link").forEach((_) => {
7965
+ _.addEventListener("click", (f) => f.stopPropagation());
7893
7966
  });
7894
- const a = (x) => {
7895
- x.key === "Escape" && (document.removeEventListener("keydown", a), i());
7967
+ const a = (_) => {
7968
+ _.key === "Escape" && (document.removeEventListener("keydown", a), i());
7896
7969
  };
7897
7970
  document.addEventListener("keydown", a);
7898
7971
  });
@@ -7907,7 +7980,7 @@ class Xn {
7907
7980
  return new Promise((t) => {
7908
7981
  var a, c, l;
7909
7982
  he();
7910
- const n = Fn(this.tokens, s);
7983
+ const n = Gn(this.tokens, s);
7911
7984
  pe(n);
7912
7985
  const o = () => n.remove(), i = () => {
7913
7986
  o(), t("recover");
@@ -7916,11 +7989,11 @@ class Xn {
7916
7989
  const u = () => {
7917
7990
  o(), t("skip");
7918
7991
  };
7919
- (c = n.querySelector("#__crossx-skip-btn")) == null || c.addEventListener("click", u), (l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", u), n.addEventListener("click", (x) => {
7920
- x.target === n && u();
7992
+ (c = n.querySelector("#__crossx-skip-btn")) == null || c.addEventListener("click", u), (l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", u), n.addEventListener("click", (_) => {
7993
+ _.target === n && u();
7921
7994
  });
7922
- const h = (x) => {
7923
- x.key === "Escape" && (document.removeEventListener("keydown", h), u());
7995
+ const h = (_) => {
7996
+ _.key === "Escape" && (document.removeEventListener("keydown", h), u());
7924
7997
  };
7925
7998
  document.addEventListener("keydown", h);
7926
7999
  }
@@ -7953,14 +8026,14 @@ class Xn {
7953
8026
  }, i = {
7954
8027
  title: (t == null ? void 0 : t.pinSetup_confirmTitle) ?? "Confirm PIN",
7955
8028
  headerSubtitle: (t == null ? void 0 : t.pinSetup_confirmSubtitle) ?? "Enter your PIN again to confirm."
7956
- }, a = Zt(this.tokens, Kn(n)), c = document.body.style.overflow;
8029
+ }, a = Zt(this.tokens, Vn(n)), c = document.body.style.overflow;
7957
8030
  document.body.style.overflow = "hidden", pe(a);
7958
8031
  let l = !1;
7959
8032
  const u = () => {
7960
8033
  l || (l = !0, a.remove(), document.body.style.overflow = c);
7961
- }, h = (C) => {
7962
- u(), s(C);
7963
- }, x = () => {
8034
+ }, h = (N) => {
8035
+ u(), s(N);
8036
+ }, _ = () => {
7964
8037
  u(), s(null);
7965
8038
  }, f = a.querySelector(".__crossx-card"), w = {
7966
8039
  tooShort: (t == null ? void 0 : t.pinValidation_tooShort) ?? "Please enter a 6-digit PIN.",
@@ -7968,32 +8041,32 @@ class Xn {
7968
8041
  repeatingDigit: (t == null ? void 0 : t.pinValidation_repeatingDigit) ?? "Cannot use the same number 3+ times in a row.",
7969
8042
  sequential: (t == null ? void 0 : t.pinValidation_sequential) ?? "Sequential numbers (e.g., 123456) are not allowed.",
7970
8043
  alternatingPattern: (t == null ? void 0 : t.pinValidation_alternatingPattern) ?? "Repeating patterns (e.g., 121212) are not allowed."
7971
- }, b = (C) => {
8044
+ }, b = (N) => {
7972
8045
  var W;
7973
8046
  f.innerHTML = nt({
7974
8047
  title: i.title,
7975
8048
  headerSubtitle: i.headerSubtitle
7976
- }), (W = f.querySelector("#__crossx-close-btn")) == null || W.addEventListener("click", x), ot(f, (B) => {
7977
- B === C ? h(C) : y(o.mismatchError);
7978
- }, x);
7979
- }, y = (C) => {
8049
+ }), (W = f.querySelector("#__crossx-close-btn")) == null || W.addEventListener("click", _), ot(f, (B) => {
8050
+ B === N ? h(N) : y(o.mismatchError);
8051
+ }, _);
8052
+ }, y = (N) => {
7980
8053
  var W;
7981
8054
  f.innerHTML = nt({
7982
8055
  title: o.title,
7983
8056
  headerSubtitle: o.headerSubtitle,
7984
8057
  subtitle: o.subtitle,
7985
- errorMessage: C
7986
- }), (W = f.querySelector("#__crossx-close-btn")) == null || W.addEventListener("click", x), ot(f, (B) => {
7987
- const j = Vn(B, w);
8058
+ errorMessage: N
8059
+ }), (W = f.querySelector("#__crossx-close-btn")) == null || W.addEventListener("click", _), ot(f, (B) => {
8060
+ const j = zn(B, w);
7988
8061
  j ? y(j) : b(B);
7989
- }, x);
8062
+ }, _);
7990
8063
  };
7991
8064
  (() => {
7992
8065
  var G;
7993
- const C = Array.from(f.querySelectorAll(".__crossx-pw-notice-item")), W = f.querySelector("#__crossx-pin-notice-next"), B = /* @__PURE__ */ new Set();
8066
+ const N = Array.from(f.querySelectorAll(".__crossx-pw-notice-item")), W = f.querySelector("#__crossx-pin-notice-next"), B = /* @__PURE__ */ new Set();
7994
8067
  W.removeAttribute("disabled");
7995
8068
  const j = W.dataset.nextLabel ?? "Next", q = W.dataset.submitLabel ?? "I Understand", P = () => {
7996
- const O = B.size === C.length;
8069
+ const O = B.size === N.length;
7997
8070
  W.classList.toggle("--disabled", !O), W.textContent = O ? q : j;
7998
8071
  }, S = (O, A) => {
7999
8072
  if (B.has(A)) return;
@@ -8004,7 +8077,7 @@ class Xn {
8004
8077
  const I = O.querySelector(`#__crossx-notice-check-${A}`);
8005
8078
  B.delete(A), I.classList.remove("--checked"), O.setAttribute("aria-checked", "false"), P();
8006
8079
  };
8007
- C.forEach((O) => {
8080
+ N.forEach((O) => {
8008
8081
  const A = parseInt(O.dataset.checkIndex ?? "0", 10);
8009
8082
  O.addEventListener("click", () => {
8010
8083
  B.has(A) ? L(O, A) : S(O, A);
@@ -8012,22 +8085,22 @@ class Xn {
8012
8085
  (I.key === " " || I.key === "Enter") && (I.preventDefault(), B.has(A) ? L(O, A) : S(O, A));
8013
8086
  });
8014
8087
  }), W.addEventListener("click", () => {
8015
- if (B.size === C.length) {
8088
+ if (B.size === N.length) {
8016
8089
  y(e == null ? void 0 : e.errorMessage);
8017
8090
  return;
8018
8091
  }
8019
- const O = C.find((I) => {
8020
- const _ = parseInt(I.dataset.checkIndex ?? "0", 10);
8021
- return !B.has(_);
8092
+ const O = N.find((I) => {
8093
+ const x = parseInt(I.dataset.checkIndex ?? "0", 10);
8094
+ return !B.has(x);
8022
8095
  });
8023
8096
  if (!O) return;
8024
8097
  const A = parseInt(O.dataset.checkIndex ?? "0", 10);
8025
8098
  O.scrollIntoView({ behavior: "smooth", block: "nearest" }), O.classList.add("--highlight"), setTimeout(() => {
8026
8099
  O.classList.remove("--highlight"), S(O, A);
8027
8100
  }, 400);
8028
- }), (G = f.querySelector("#__crossx-close-btn")) == null || G.addEventListener("click", x);
8029
- })(), a.addEventListener("click", (C) => {
8030
- C.target === a && x();
8101
+ }), (G = f.querySelector("#__crossx-close-btn")) == null || G.addEventListener("click", _);
8102
+ })(), a.addEventListener("click", (N) => {
8103
+ N.target === a && _();
8031
8104
  });
8032
8105
  });
8033
8106
  }
@@ -8053,15 +8126,15 @@ class Xn {
8053
8126
  let u = !1;
8054
8127
  const h = () => {
8055
8128
  u || (u = !0, c.remove(), document.body.style.overflow = l);
8056
- }, x = (k) => {
8057
- h(), s(k);
8129
+ }, _ = (T) => {
8130
+ h(), s(T);
8058
8131
  }, f = () => {
8059
8132
  h(), s(null);
8060
- }, w = (k) => {
8061
- h(), t(k);
8133
+ }, w = (T) => {
8134
+ h(), t(T);
8062
8135
  }, b = c.querySelector(".__crossx-card");
8063
- (y = b.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", f), ot(b, x, f, w, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt), c.addEventListener("click", (k) => {
8064
- k.target === c && f();
8136
+ (y = b.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", f), ot(b, _, f, w, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt), c.addEventListener("click", (T) => {
8137
+ T.target === c && f();
8065
8138
  });
8066
8139
  });
8067
8140
  }
@@ -8076,14 +8149,14 @@ class Xn {
8076
8149
  return new Promise((s) => {
8077
8150
  var a;
8078
8151
  he();
8079
- const t = Gn(this.tokens, e);
8152
+ const t = Wn(this.tokens, e);
8080
8153
  pe(t);
8081
8154
  const n = () => t.remove(), o = (c) => {
8082
8155
  n(), s(c);
8083
8156
  }, i = () => {
8084
8157
  n(), s(null);
8085
8158
  };
8086
- Jn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
8159
+ Xn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
8087
8160
  c.target === t && i();
8088
8161
  });
8089
8162
  });
@@ -8098,7 +8171,7 @@ class Xn {
8098
8171
  return new Promise((t) => {
8099
8172
  var l;
8100
8173
  he();
8101
- const { overlay: n, startCountdown: o } = qn(this.tokens, e, s);
8174
+ const { overlay: n, startCountdown: o } = Kn(this.tokens, e, s);
8102
8175
  pe(n);
8103
8176
  const i = () => {
8104
8177
  c(), n.remove();
@@ -8118,17 +8191,17 @@ class Xn {
8118
8191
  return new Promise((s) => {
8119
8192
  var a, c;
8120
8193
  he();
8121
- const t = On(e, this.tokens);
8194
+ const t = Cn(e, this.tokens);
8122
8195
  pe(t);
8123
8196
  const n = () => t.remove(), o = () => {
8124
8197
  n(), s();
8125
8198
  };
8126
8199
  (a = t.querySelector("#__crossx-done-btn")) == null || a.addEventListener("click", o), (c = t.querySelector("#__crossx-close-btn")) == null || c.addEventListener("click", o), t.querySelectorAll(".__crossx-copy-btn").forEach((l) => {
8127
8200
  l.addEventListener("click", (u) => {
8128
- var x;
8201
+ var _;
8129
8202
  u.stopPropagation();
8130
8203
  const h = l.dataset.copy;
8131
- h && ((x = navigator.clipboard) == null || x.writeText(h).catch(() => {
8204
+ h && ((_ = navigator.clipboard) == null || _.writeText(h).catch(() => {
8132
8205
  }));
8133
8206
  });
8134
8207
  }), t.addEventListener("click", (l) => {
@@ -8155,16 +8228,16 @@ class Xn {
8155
8228
  i || (i = !0, o(), t());
8156
8229
  }, c = () => {
8157
8230
  var u, h;
8158
- (u = n.querySelector("#__crossx-done-btn")) == null || u.addEventListener("click", a), (h = n.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", a), n.addEventListener("click", (x) => {
8159
- x.target === n && a();
8231
+ (u = n.querySelector("#__crossx-done-btn")) == null || u.addEventListener("click", a), (h = n.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", a), n.addEventListener("click", (_) => {
8232
+ _.target === n && a();
8160
8233
  });
8161
- const l = (x) => {
8162
- x.key === "Escape" && (document.removeEventListener("keydown", l), a());
8234
+ const l = (_) => {
8235
+ _.key === "Escape" && (document.removeEventListener("keydown", l), a());
8163
8236
  };
8164
8237
  document.addEventListener("keydown", l);
8165
8238
  };
8166
8239
  s.then((l) => {
8167
- i || (Cn(n, l, this.tokens), c());
8240
+ i || (Ln(n, l, this.tokens), c());
8168
8241
  });
8169
8242
  });
8170
8243
  }
@@ -8173,16 +8246,16 @@ class Xn {
8173
8246
  var c, l, u;
8174
8247
  he();
8175
8248
  let t;
8176
- e.type === "sign-message" ? t = Ln(e, this.tokens) : e.type === "sign-typed-data" ? t = Dn(e, this.tokens) : e.type === "sign" ? t = Tn(e, this.tokens) : t = Rn(e, this.tokens), pe(t);
8249
+ e.type === "sign-message" ? t = Dn(e, this.tokens) : e.type === "sign-typed-data" ? t = Mn(e, this.tokens) : e.type === "sign" ? t = Rn(e, this.tokens) : t = kn(e, this.tokens), pe(t);
8177
8250
  const n = () => t.remove(), o = () => {
8178
8251
  n(), s(!0);
8179
8252
  }, i = () => {
8180
8253
  n(), s(!1);
8181
8254
  };
8182
8255
  (c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (u = t.querySelector("#__crossx-close-btn")) == null || u.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((h) => {
8183
- h.addEventListener("click", (x) => {
8256
+ h.addEventListener("click", (_) => {
8184
8257
  var w;
8185
- x.stopPropagation();
8258
+ _.stopPropagation();
8186
8259
  const f = h.dataset.copy;
8187
8260
  f && ((w = navigator.clipboard) == null || w.writeText(f).catch(() => {
8188
8261
  }));
@@ -8197,7 +8270,7 @@ class Xn {
8197
8270
  });
8198
8271
  }
8199
8272
  }
8200
- class Zn {
8273
+ class Qn {
8201
8274
  constructor() {
8202
8275
  this._accessToken = null, this._expiresAt = 0;
8203
8276
  }
@@ -8219,8 +8292,17 @@ class Zn {
8219
8292
  has() {
8220
8293
  return this.get() !== null;
8221
8294
  }
8295
+ /**
8296
+ * 토큰이 곧 만료되는지 확인합니다.
8297
+ * 토큰이 없거나 `exp`가 설정되지 않은 경우에도 true를 반환합니다.
8298
+ *
8299
+ * @param bufferMs 만료 전 여유 시간 (ms). 기본 30초.
8300
+ */
8301
+ isExpiringSoon(e = 3e4) {
8302
+ return !this._accessToken || this._expiresAt <= 0 ? !0 : Date.now() >= this._expiresAt - e;
8303
+ }
8222
8304
  }
8223
- function io(r, e) {
8305
+ function ao(r, e) {
8224
8306
  r.debug;
8225
8307
  const s = Ge.production, t = {
8226
8308
  ...r,
@@ -8230,29 +8312,29 @@ function io(r, e) {
8230
8312
  }, n = {
8231
8313
  gatewayUrl: s.walletGatewayUrl,
8232
8314
  projectId: r.projectId
8233
- }, o = t.authMode !== "cookie" && Nt.isAvailable();
8315
+ }, o = t.authMode !== "cookie" && Ct.isAvailable();
8234
8316
  !o && t.authMode !== "cookie" && d.warn(
8235
8317
  "[CROSSx] IndexedDB 사용 불가 — LocalStorage fallback 사용 중.",
8236
8318
  "refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
8237
8319
  "IndexedDB를 지원하는 브라우저 사용을 권장합니다."
8238
8320
  ), t.secureStorageAvailable = o;
8239
- const i = o ? new Nt(r.projectId) : new rr(), a = new hn(), c = new xn(), l = new Ee(), u = new Zn(), h = new es();
8240
- let x;
8241
- r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), x = new mn(i, h)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), x = new Le(
8321
+ const i = o ? new Ct(r.projectId) : new nr(), a = new pn(), c = new gn(), l = new Ee(), u = new Qn(), h = new es();
8322
+ let _;
8323
+ r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), _ = new wn(i, h)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), _ = new Le(
8242
8324
  n,
8243
8325
  i,
8244
8326
  c,
8245
8327
  u,
8246
8328
  h
8247
8329
  ));
8248
- const f = new De(n, c), w = new Xn(r.theme ?? "light", r.themeTokens), b = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w, y = new it(
8330
+ const f = new De(n, c), w = new Zn(r.theme ?? "light", r.themeTokens), b = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w, y = new it(
8249
8331
  t,
8250
8332
  n,
8251
8333
  i,
8252
8334
  a,
8253
8335
  c,
8254
8336
  l,
8255
- x,
8337
+ _,
8256
8338
  u,
8257
8339
  b,
8258
8340
  f,
@@ -8260,9 +8342,9 @@ function io(r, e) {
8260
8342
  );
8261
8343
  return typeof window < "u" && (window.__crossxSDK = y), y;
8262
8344
  }
8263
- function ao(r) {
8264
- const e = Qn(r), s = eo(e), t = JSON.parse(s);
8265
- so(t);
8345
+ function co(r) {
8346
+ const e = eo(r), s = to(e), t = JSON.parse(s);
8347
+ ro(t);
8266
8348
  const { data: n } = t;
8267
8349
  return {
8268
8350
  status: t.status,
@@ -8276,7 +8358,7 @@ function ao(r) {
8276
8358
  raw: t
8277
8359
  };
8278
8360
  }
8279
- function Qn(r) {
8361
+ function eo(r) {
8280
8362
  if (r.includes("://") && r.includes("?")) {
8281
8363
  const e = new URL(r), s = e.searchParams.get("crossx_oauth_result");
8282
8364
  if (s) return s;
@@ -8286,22 +8368,22 @@ function Qn(r) {
8286
8368
  }
8287
8369
  return r;
8288
8370
  }
8289
- function eo(r) {
8371
+ function to(r) {
8290
8372
  if (r.startsWith("{"))
8291
8373
  return r;
8292
8374
  if (r.startsWith("%7B") || r.startsWith("%7b"))
8293
8375
  return decodeURIComponent(r);
8294
- const e = to(r);
8376
+ const e = so(r);
8295
8377
  return decodeURIComponent(e);
8296
8378
  }
8297
- function to(r) {
8379
+ function so(r) {
8298
8380
  if (typeof atob == "function")
8299
8381
  return atob(r);
8300
8382
  if (typeof Buffer < "u")
8301
8383
  return Buffer.from(r, "base64").toString("utf-8");
8302
8384
  throw new Error("Base64 디코딩을 지원하는 환경이 아닙니다");
8303
8385
  }
8304
- function so(r) {
8386
+ function ro(r) {
8305
8387
  if (typeof r != "object" || r === null)
8306
8388
  throw new Error("Deeplink payload가 유효한 객체가 아닙니다");
8307
8389
  const e = r;
@@ -8321,10 +8403,10 @@ export {
8321
8403
  m as CROSSxError,
8322
8404
  Fs as CROSSxEthereumProvider,
8323
8405
  it as CROSSxSDK,
8324
- oo as ChainId,
8406
+ io as ChainId,
8325
8407
  p as ErrorCode,
8326
8408
  es as PinMemoryStore,
8327
- Zn as TokenMemoryStore,
8328
- io as createCROSSxSDK,
8329
- ao as parseOAuthDeeplink
8409
+ Qn as TokenMemoryStore,
8410
+ ao as createCROSSxSDK,
8411
+ co as parseOAuthDeeplink
8330
8412
  };