@nexus-cross/crossx-sdk-core 2.0.1 → 2.0.2-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- var Hs = Object.defineProperty;
2
- var Fs = (r, e, s) => e in r ? Hs(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
- var P = (r, e, s) => Fs(r, typeof e != "symbol" ? e + "" : e, s);
4
- import { createRemoteJWKSet as Ws, jwtVerify as Gs, decodeJwt as qs } from "jose";
1
+ var Fs = Object.defineProperty;
2
+ var Ws = (r, e, s) => e in r ? Fs(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
+ var P = (r, e, s) => Ws(r, typeof e != "symbol" ? e + "" : e, s);
4
+ import { createRemoteJWKSet as Gs, jwtVerify as qs, decodeJwt as Ks } from "jose";
5
5
  var h = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.ALREADY_AUTHENTICATED = "ALREADY_AUTHENTICATED", r.SESSION_EXPIRED = "SESSION_EXPIRED", r.OAUTH_POPUP_BLOCKED = "OAUTH_POPUP_BLOCKED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.WALLET_ALREADY_EXISTS = "WALLET_ALREADY_EXISTS", r.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", r.BROADCAST_FAILED = "BROADCAST_FAILED", r.USER_REJECTED = "USER_REJECTED", r.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", r.NETWORK_ERROR = "NETWORK_ERROR", r.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", r.INVALID_CHAIN = "INVALID_CHAIN", r.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", r.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.SIGNATURE_FAILED = "SIGNATURE_FAILED", r.TRANSACTION_FAILED = "TRANSACTION_FAILED", r.PREPARE_FAILED = "PREPARE_FAILED", r.PREPARE_EXPIRED = "PREPARE_EXPIRED", r.PREPARE_MISMATCH = "PREPARE_MISMATCH", r.MIGRATION_FAILED = "MIGRATION_FAILED", r.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", r.MIGRATION_PIN_LOCKED = "MIGRATION_PIN_LOCKED", r.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", r.WALLET_INCONSISTENT_STATE = "WALLET_INCONSISTENT_STATE", r.PROJECT_ID_MISSING = "PROJECT_ID_MISSING", r.ORIGIN_NOT_ALLOWED = "ORIGIN_NOT_ALLOWED", r.APP_IDENTIFIER_MISSING = "APP_IDENTIFIER_MISSING", r.INVALID_APP_TYPE = "INVALID_APP_TYPE", r.PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED", r.SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH", r.GAS_ESTIMATION_FAILED = "GAS_ESTIMATION_FAILED", r.TYPED_DATA_CHAIN_ID_MISMATCH = "TYPED_DATA_CHAIN_ID_MISMATCH", r.PIN_NOT_SET = "PIN_NOT_SET", r.PIN_WRONG = "PIN_WRONG", r.PIN_INVALID = "PIN_INVALID", r.PIN_REPEATED_PATTERN = "PIN_REPEATED_PATTERN", r.PIN_CANCELLED = "PIN_CANCELLED", r.EXTERNAL_WALLET_REQUESTED = "EXTERNAL_WALLET_REQUESTED", r.PIN_LOCKED = "PIN_LOCKED", r.HMAC_REQUIRED = "HMAC_REQUIRED", r.HMAC_VERIFICATION_FAILED = "HMAC_VERIFICATION_FAILED", r.WITHDRAW_FAILED = "WITHDRAW_FAILED", r.USER_NOT_FOUND = "USER_NOT_FOUND", r.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(h || {});
6
6
  class x extends Error {
7
7
  constructor(e, s, t) {
@@ -17,21 +17,21 @@ class x extends Error {
17
17
  }
18
18
  }
19
19
  var Ue = /* @__PURE__ */ ((r) => (r.MetaMask = "io.metamask", r.Binance = "com.binance.wallet", r.CROSSx = "crossx", r))(Ue || {});
20
- const Ks = {
20
+ const zs = {
21
21
  "io.metamask": "MetaMask",
22
22
  "com.binance.wallet": "Binance Wallet",
23
23
  crossx: "CROSSx"
24
- }, zs = [
24
+ }, Vs = [
25
25
  "crossx",
26
26
  "io.metamask",
27
27
  "com.binance.wallet"
28
28
  /* Binance */
29
29
  ];
30
- function Vs(r) {
31
- return Ks[r] ?? r;
32
- }
33
30
  function js(r) {
34
- return Array.isArray(r.connectOtherWallets) && r.connectOtherWallets.length > 0 ? [...r.connectOtherWallets] : r.showConnectOtherWallets === !0 ? [...zs] : [];
31
+ return zs[r] ?? r;
32
+ }
33
+ function Ys(r) {
34
+ return Array.isArray(r.connectOtherWallets) && r.connectOtherWallets.length > 0 ? [...r.connectOtherWallets] : r.showConnectOtherWallets === !0 ? [...Vs] : [];
35
35
  }
36
36
  const Je = {
37
37
  // ─── CROSS ────────────────────────────────────────────
@@ -84,18 +84,18 @@ const Je = {
84
84
  }
85
85
  }, Eo = Object.fromEntries(
86
86
  Object.entries(Je).map(([r, e]) => [r, e.caipId])
87
- ), Ys = new Map(
87
+ ), Xs = new Map(
88
88
  Object.values(Je).map((r) => [r.caipId, r])
89
89
  );
90
90
  new Map(
91
91
  Object.values(Je).map((r) => [r.chainId, r])
92
92
  );
93
- const Xs = { symbol: "", decimals: 18 };
93
+ const Js = { symbol: "", decimals: 18 };
94
94
  function tt(r) {
95
95
  var e;
96
- return ((e = Ys.get(r)) == null ? void 0 : e.nativeCurrency) ?? Xs;
96
+ return ((e = Xs.get(r)) == null ? void 0 : e.nativeCurrency) ?? Js;
97
97
  }
98
- class Js {
98
+ class Zs {
99
99
  constructor(e, s) {
100
100
  this.sdk = e, this.chainId = s, this._listeners = /* @__PURE__ */ new Map();
101
101
  }
@@ -215,7 +215,7 @@ const d = {
215
215
  return;
216
216
  }
217
217
  }
218
- }, Zs = {
218
+ }, Qs = {
219
219
  // ── 공통 버튼 ────────────────────────────────────────────────
220
220
  confirm: "확인",
221
221
  cancel: "취소",
@@ -377,12 +377,12 @@ For security, you must continue with the same account.`,
377
377
  sessionAlert_appleAccount: "Apple account",
378
378
  sessionAlert_signOutButton: "Sign out",
379
379
  sessionAlert_signInAgainButton: "Sign in again"
380
- }, Qs = {
381
- ko: Zs,
380
+ }, er = {
381
+ ko: Qs,
382
382
  en: os
383
383
  };
384
384
  function fe(r = "en", e) {
385
- return Qs[r] ?? os;
385
+ return er[r] ?? os;
386
386
  }
387
387
  const Rt = "crossx_access_token", Ot = "crossx_refresh_token", Pt = "crossx_user_info", Xe = class Xe {
388
388
  constructor(e, s, t, n, o, i, a) {
@@ -790,7 +790,7 @@ const Rt = "crossx_access_token", Ot = "crossx_refresh_token", Pt = "crossx_user
790
790
  };
791
791
  Xe.REFRESH_RELOGIN_CODES = /* @__PURE__ */ new Set([1007, 1008]);
792
792
  let ut = Xe;
793
- class er {
793
+ class tr {
794
794
  constructor(e, s, t) {
795
795
  this.config = e, this.storage = s, this.tokenStore = t;
796
796
  const n = e.projectId;
@@ -800,7 +800,7 @@ class er {
800
800
  this.tokenStore.clear(), this.config.authMode !== "cookie" && (await this.storage.remove(this.STORAGE_KEY_ACCESS_TOKEN), await this.storage.remove(this.STORAGE_KEY_REFRESH_TOKEN)), await this.storage.remove(this.STORAGE_KEY_USER), await this.storage.clear();
801
801
  }
802
802
  }
803
- class tr {
803
+ class sr {
804
804
  constructor(e, s) {
805
805
  this.storage = e, this.walletProvider = s;
806
806
  }
@@ -858,7 +858,7 @@ class is {
858
858
  return this.encryptedBytes !== null;
859
859
  }
860
860
  }
861
- class sr {
861
+ class rr {
862
862
  constructor(e, s) {
863
863
  this.chainRegistry = e, this.transport = s, this._nextId = 1;
864
864
  }
@@ -890,7 +890,7 @@ class sr {
890
890
  return a == null ? void 0 : a.result;
891
891
  }
892
892
  }
893
- class rr {
893
+ class nr {
894
894
  constructor() {
895
895
  this.listeners = /* @__PURE__ */ new Map();
896
896
  }
@@ -930,14 +930,14 @@ const Pe = {
930
930
  walletGatewayUrl: "https://dev-embedded-wallet-gateway.crosstoken.io/api/v1"
931
931
  }
932
932
  };
933
- function nr(r) {
933
+ function or(r) {
934
934
  const e = r.environment;
935
935
  return e && e in Pe ? Pe[e] : null;
936
936
  }
937
- function or() {
937
+ function ir() {
938
938
  try {
939
939
  if (typeof __CROSSX_CONFIG__ < "u") {
940
- const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e = nr(r);
940
+ const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e = or(r);
941
941
  if (e) return e;
942
942
  }
943
943
  } catch {
@@ -950,7 +950,7 @@ function or() {
950
950
  }
951
951
  return Pe.production;
952
952
  }
953
- const ir = 2e3, Ct = 6e4, ar = 1e3, cr = 1e4, lr = "0x77359400", Nt = "0x3B9ACA00", Lt = 130, Dt = 6, $t = 18, Mt = 3e4, dr = 5 * 60 * 1e3, ur = 30 * 1e3;
953
+ const ar = 2e3, Ct = 6e4, cr = 1e3, lr = 1e4, dr = "0x77359400", Nt = "0x3B9ACA00", Lt = 130, Dt = 6, $t = 18, Mt = 3e4, ur = 5 * 60 * 1e3, hr = 30 * 1e3;
954
954
  function $e(r, e = "Apple account") {
955
955
  if (r.endsWith("@privaterelay.appleid.com")) return e;
956
956
  const s = r.indexOf("@");
@@ -958,10 +958,10 @@ function $e(r, e = "Apple account") {
958
958
  const t = r.substring(0, s), n = r.substring(s);
959
959
  return t.length <= 1 ? `${t}${"*".repeat(Math.max(t.length, 1))}${n}` : `${t[0]}${"*".repeat(t.length - 1)}${n}`;
960
960
  }
961
- const J = class J extends rr {
961
+ const V = class V extends nr {
962
962
  constructor(e, s, t, n, o, i, a, c, l, u, f) {
963
963
  var _, p;
964
- 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._isRecoveringSession = !1, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && kt(e.logger), this.confirmation = l, this.pinStore = f ?? new is(), this.chainRegistry = u, this.jsonRpc = new sr(u, o), this.signInUseCase = new ut(
964
+ 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._isRecoveringSession = !1, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && kt(e.logger), this.confirmation = l, this.pinStore = f ?? new is(), this.chainRegistry = u, this.jsonRpc = new rr(u, o), this.signInUseCase = new ut(
965
965
  this.internalConfig,
966
966
  t,
967
967
  n,
@@ -969,7 +969,7 @@ const J = class J extends rr {
969
969
  o,
970
970
  a,
971
971
  c
972
- ), this.signOutUseCase = new er(this.internalConfig, t, c), this.migrateWalletUseCase = new tr(t, a), (_ = a.setOnUnauthorized) == null || _.call(a, () => this.forceLogout()), (p = a.setTokenRefresher) == null || p.call(
972
+ ), this.signOutUseCase = new tr(this.internalConfig, t, c), this.migrateWalletUseCase = new sr(t, a), (_ = a.setOnUnauthorized) == null || _.call(a, () => this.forceLogout()), (p = a.setTokenRefresher) == null || p.call(
973
973
  a,
974
974
  () => this.signInUseCase.refreshAccessToken()
975
975
  ), e.autoDetectTheme && this._setupAutoDetectTheme();
@@ -998,22 +998,24 @@ const J = class J extends rr {
998
998
  }
999
999
  async _doInitialize(e) {
1000
1000
  var s, t;
1001
- d.log("[CROSSx SDK] v2.0.1 초기화 중..."), this.confirmation.setMessages(fe(this._config.locale));
1001
+ d.log("[CROSSx SDK] v2.0.2 초기화 중..."), this.confirmation.setMessages(fe(this._config.locale));
1002
1002
  try {
1003
- const n = or();
1003
+ const n = ir();
1004
1004
  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`);
1005
- const o = await this.signInUseCase.restoreSession();
1006
- if (o != null && o.success) {
1007
- this.applyAuthResult(o);
1008
- try {
1009
- await this.loadWalletAfterAuth(e == null ? void 0 : e.preferredWalletIndex);
1010
- } catch (i) {
1011
- if (!(i instanceof x && i.code === h.PIN_CANCELLED))
1012
- throw i;
1005
+ const o = this._config.persistWalletPreference !== !1 ? await this.storage.get(
1006
+ V.WALLET_PREF_KEY
1007
+ ).catch(() => null) : null, i = (e == null ? void 0 : e.preferredWalletIndex) ?? (o == null ? void 0 : o.index), a = (e == null ? void 0 : e.preferredWalletAddress) ?? (o == null ? void 0 : o.address), c = await this.signInUseCase.restoreSession();
1008
+ if (c != null && c.success)
1009
+ if (this.applyAuthResult(c), this.address && (!a || this.address.toLowerCase() === a.toLowerCase()))
1010
+ this.address && this.setActiveWallet(this.address, i ?? this.activeWalletIndex);
1011
+ else try {
1012
+ await this.loadWalletAfterAuth(i, a);
1013
+ } catch (u) {
1014
+ if (!(u instanceof x && u.code === h.PIN_CANCELLED))
1015
+ throw u;
1013
1016
  d.log("[CROSSx] initialize: 비밀번호 입력 취소 — 지갑 미로드 상태로 계속");
1014
1017
  }
1015
- }
1016
- return this.initialized = !0, d.info("[CROSSx SDK] v2.0.1 초기화 완료"), this.emit("initialized", { restored: !!(o != null && o.success) }), o ?? null;
1018
+ return this.initialized = !0, d.info("[CROSSx SDK] v2.0.2 초기화 완료"), this.emit("initialized", { restored: !!(c != null && c.success) }), c ?? null;
1017
1019
  } catch (n) {
1018
1020
  throw new x(h.AUTH_NOT_INITIALIZED, "SDK 초기화에 실패했습니다", n);
1019
1021
  }
@@ -1027,7 +1029,7 @@ const J = class J extends rr {
1027
1029
  let s = e;
1028
1030
  if (!(e != null && e.provider)) {
1029
1031
  const t = await this.confirmation.showLoginSelector({
1030
- connectOtherWallets: js(this._config)
1032
+ connectOtherWallets: Ys(this._config)
1031
1033
  });
1032
1034
  if (t === null)
1033
1035
  return { success: !1, error: "User cancelled login" };
@@ -1063,19 +1065,19 @@ const J = class J extends rr {
1063
1065
  * console.log(result.addresses); // [{ address: '0x...', index: 0 }]
1064
1066
  */
1065
1067
  async signInWithCreate(e) {
1066
- const s = await this.signIn(e);
1067
- if (!s.success) return { ...s, addresses: [] };
1068
+ const { preferredWalletAddress: s, ...t } = e ?? {}, n = await this.signIn(t);
1069
+ if (!n.success) return { ...n, addresses: [] };
1068
1070
  try {
1069
- if (s.needsMigration || !s.address) {
1070
- const { address: o } = await this.createWallet(), i = await this.getAddresses(), a = await this.selectWalletIfMultiple(i);
1071
- return { ...s, address: (a == null ? void 0 : a.address) ?? o, needsMigration: !1, addresses: i };
1071
+ if (n.needsMigration || !n.address) {
1072
+ const { address: a } = await this.createWallet(), c = await this.getAddresses(), l = await this.selectWalletIfMultiple(c, s);
1073
+ return { ...n, address: (l == null ? void 0 : l.address) ?? a, needsMigration: !1, addresses: c };
1072
1074
  }
1073
- const t = await this.getAddresses(), n = await this.selectWalletIfMultiple(t);
1074
- return { ...s, address: (n == null ? void 0 : n.address) ?? s.address, addresses: t };
1075
- } catch (t) {
1076
- throw t instanceof x && t.code === h.PIN_CANCELLED && (d.log("[CROSSx] signInWithCreate: 비밀번호 설정 취소 — 자동 로그아웃 진행"), await this.signOut().catch(
1077
- (n) => d.warn("[CROSSx] signInWithCreate: 자동 로그아웃 실패", n)
1078
- )), t;
1075
+ const o = await this.getAddresses(), i = await this.selectWalletIfMultiple(o, s);
1076
+ return { ...n, address: (i == null ? void 0 : i.address) ?? n.address, addresses: o };
1077
+ } catch (o) {
1078
+ throw o instanceof x && o.code === h.PIN_CANCELLED && (d.log("[CROSSx] signInWithCreate: 비밀번호 설정 취소 — 자동 로그아웃 진행"), await this.signOut().catch(
1079
+ (i) => d.warn("[CROSSx] signInWithCreate: 자동 로그아웃 실패", i)
1080
+ )), o;
1079
1081
  }
1080
1082
  }
1081
1083
  /**
@@ -1105,7 +1107,7 @@ const J = class J extends rr {
1105
1107
  const s = await this.signInUseCase.executeWithOAuthToken(e);
1106
1108
  return s.success && this.applyAuthResult(s), s;
1107
1109
  } catch (s) {
1108
- throw new x(h.AUTH_FAILED, "OAuth 토큰 로그인에 실패했습니다", s);
1110
+ throw s instanceof x ? s : new x(h.AUTH_FAILED, "OAuth 토큰 로그인에 실패했습니다", s);
1109
1111
  }
1110
1112
  }
1111
1113
  /**
@@ -1133,7 +1135,7 @@ const J = class J extends rr {
1133
1135
  const t = await this.signInUseCase.executeWithJWT(e, s);
1134
1136
  return t.success && this.applyAuthResult(t), t;
1135
1137
  } catch (t) {
1136
- throw new x(h.AUTH_FAILED, "JWT 로그인에 실패했습니다", t);
1138
+ throw t instanceof x ? t : new x(h.AUTH_FAILED, "JWT 로그인에 실패했습니다", t);
1137
1139
  }
1138
1140
  }
1139
1141
  async signOut() {
@@ -1249,7 +1251,7 @@ const J = class J extends rr {
1249
1251
  throw new x(h.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
1250
1252
  try {
1251
1253
  const s = await this.migrateWalletUseCase.execute(e, this.userId);
1252
- return this.address = s.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: s.address, index: 0 }), d.log("[CROSSx] migrateWallet 완료 — address:", s.address), s;
1254
+ return this.setActiveWallet(s.address, 0), d.log("[CROSSx] migrateWallet 완료 — address:", s.address), s;
1253
1255
  } catch (s) {
1254
1256
  throw s instanceof x ? s : new x(
1255
1257
  h.MIGRATION_FAILED,
@@ -1333,15 +1335,26 @@ const J = class J extends rr {
1333
1335
  },
1334
1336
  e
1335
1337
  );
1336
- return t && (this.address = t.address, this.activeWalletIndex = t.index, this.emit("addressChanged", { address: t.address, index: t.index })), t;
1338
+ return t && this.setActiveWallet(t.address, t.index), t;
1337
1339
  }
1338
1340
  /**
1339
1341
  * 지갑이 2개 이상이면 selectWallet()을 호출합니다.
1340
1342
  * selectWallet() 내부에서 this.address 설정 및 addressChanged 이벤트를 처리합니다.
1341
1343
  * 지갑이 1개 이하이거나 사용자가 취소하면 null을 반환합니다.
1344
+ *
1345
+ * @param addresses 전체 지갑 목록
1346
+ * @param preferredWalletAddress 지정 시, 해당 주소의 지갑이 목록에 있으면 모달 없이 자동 선택
1342
1347
  */
1343
- async selectWalletIfMultiple(e) {
1344
- return e.length < 2 ? null : this.selectWallet();
1348
+ async selectWalletIfMultiple(e, s) {
1349
+ if (e.length < 2) return null;
1350
+ if (s) {
1351
+ const t = e.find(
1352
+ (n) => n.address.toLowerCase() === s.toLowerCase()
1353
+ );
1354
+ if (t)
1355
+ return this.setActiveWallet(t.address, t.index), t;
1356
+ }
1357
+ return this.selectWallet();
1345
1358
  }
1346
1359
  // ============================================================================
1347
1360
  // 체인 조회
@@ -1448,7 +1461,7 @@ const J = class J extends rr {
1448
1461
  d.log("[CROSSx] migration_required → 마이그레이션 UI 시작 — sub:", s);
1449
1462
  const t = await this.handleMigrationFlow(s);
1450
1463
  if (t)
1451
- return this.address = t.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: t.address, index: 0 }), { address: t.address };
1464
+ return this.setActiveWallet(t.address, 0), { address: t.address };
1452
1465
  throw new x(
1453
1466
  h.MIGRATION_FAILED,
1454
1467
  "사용자가 마이그레이션을 건너뛰었습니다"
@@ -1460,14 +1473,14 @@ const J = class J extends rr {
1460
1473
  const s = await this.withPinRetry(
1461
1474
  () => this.walletProvider.getOrCreateWallet(this.userId)
1462
1475
  );
1463
- return this.address = s.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: s.address, index: 0 }), d.log("[CROSSx] 지갑 준비 완료:", s.address), { address: s.address };
1476
+ return this.setActiveWallet(s.address, 0), d.log("[CROSSx] 지갑 준비 완료:", s.address), { address: s.address };
1464
1477
  } catch (s) {
1465
1478
  if (s instanceof x && s.code === h.MIGRATION_BACKUP_EXISTS) {
1466
1479
  const t = this.providerSub ?? this.userId;
1467
1480
  d.log("[CROSSx] MIGRATION_BACKUP_EXISTS (폴백) → 마이그레이션 UI 시작");
1468
1481
  const n = await this.handleMigrationFlow(t);
1469
1482
  if (n)
1470
- return this.address = n.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: n.address, index: 0 }), { address: n.address };
1483
+ return this.setActiveWallet(n.address, 0), { address: n.address };
1471
1484
  throw new x(
1472
1485
  h.MIGRATION_FAILED,
1473
1486
  "사용자가 마이그레이션을 건너뛰었습니다"
@@ -1479,14 +1492,14 @@ const J = class J extends rr {
1479
1492
  await this.ensurePinSetup();
1480
1493
  try {
1481
1494
  const s = await this.walletProvider.getOrCreateWallet(this.userId);
1482
- return this.address = s.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: s.address, index: 0 }), d.log("[CROSSx] 지갑 준비 완료:", s.address), { address: s.address };
1495
+ return this.setActiveWallet(s.address, 0), d.log("[CROSSx] 지갑 준비 완료:", s.address), { address: s.address };
1483
1496
  } catch (s) {
1484
1497
  if (s instanceof x && s.code === h.MIGRATION_BACKUP_EXISTS) {
1485
1498
  const t = this.providerSub ?? this.userId;
1486
1499
  d.log("[CROSSx] MIGRATION_BACKUP_EXISTS (폴백) → 마이그레이션 UI 시작");
1487
1500
  const n = await this.handleMigrationFlow(t);
1488
1501
  if (n)
1489
- return this.address = n.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: n.address, index: 0 }), { address: n.address };
1502
+ return this.setActiveWallet(n.address, 0), { address: n.address };
1490
1503
  throw new x(
1491
1504
  h.MIGRATION_FAILED,
1492
1505
  "사용자가 마이그레이션을 건너뛰었습니다"
@@ -1582,7 +1595,7 @@ const J = class J extends rr {
1582
1595
  throw new x(h.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
1583
1596
  if (!this.walletProvider.signTypedData)
1584
1597
  throw new x(h.NOT_IMPLEMENTED, "signTypedData가 구현되어 있지 않습니다");
1585
- J.validateTypedDataChainId(e, s);
1598
+ V.validateTypedDataChainId(e, s);
1586
1599
  const n = await this.resolveAddress(t == null ? void 0 : t.index);
1587
1600
  if (!await this.confirmation.requestConfirmation({
1588
1601
  type: "sign-typed-data",
@@ -1605,7 +1618,7 @@ const J = class J extends rr {
1605
1618
  n.address
1606
1619
  );
1607
1620
  });
1608
- return J.validateSignatureFormat(i.signature), {
1621
+ return V.validateSignatureFormat(i.signature), {
1609
1622
  chainId: e,
1610
1623
  signature: i.signature,
1611
1624
  address: n.address
@@ -1634,7 +1647,7 @@ const J = class J extends rr {
1634
1647
  * });
1635
1648
  */
1636
1649
  async signTypedDataOffchain(e, s) {
1637
- return this.signTypedData(J.OFFCHAIN_CHAIN_ID, e, s);
1650
+ return this.signTypedData(V.OFFCHAIN_CHAIN_ID, e, s);
1638
1651
  }
1639
1652
  // ============================================================================
1640
1653
  // 트랜잭션
@@ -1682,7 +1695,7 @@ const J = class J extends rr {
1682
1695
  c
1683
1696
  );
1684
1697
  });
1685
- return J.validateSignedTxFormat(a.signature), {
1698
+ return V.validateSignedTxFormat(a.signature), {
1686
1699
  chainId: e,
1687
1700
  signedTx: a.signature,
1688
1701
  txHash: a.txHash ?? ""
@@ -1778,7 +1791,7 @@ const J = class J extends rr {
1778
1791
  * @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
1779
1792
  */
1780
1793
  async waitForTxAndGetReceipt(e, s, t = {}) {
1781
- const n = t.intervalMs ?? ar, o = cr, i = t.timeoutMs ?? Ct, a = Date.now() + i;
1794
+ const n = t.intervalMs ?? cr, o = lr, i = t.timeoutMs ?? Ct, a = Date.now() + i;
1782
1795
  let c = n;
1783
1796
  for (; Date.now() < a; ) {
1784
1797
  const l = await this.getTransactionReceipt(e, s);
@@ -1807,11 +1820,11 @@ const J = class J extends rr {
1807
1820
  */
1808
1821
  async sendTransactionWithWaitForReceipt(e, s, t = {}) {
1809
1822
  var E, S;
1810
- const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((E = this._config.receiptPolling) == null ? void 0 : E.intervalMs) ?? ir, l = o ?? ((S = this._config.receiptPolling) == null ? void 0 : S.timeoutMs) ?? Ct, u = tt(e), f = s.from ?? "";
1823
+ const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((E = this._config.receiptPolling) == null ? void 0 : E.intervalMs) ?? ar, l = o ?? ((S = this._config.receiptPolling) == null ? void 0 : S.timeoutMs) ?? Ct, u = tt(e), f = s.from ?? "";
1811
1824
  let _, p;
1812
1825
  const b = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((A) => {
1813
1826
  _ = A;
1814
- const k = BigInt(A.gasUsed) * BigInt(A.effectiveGasPrice), F = s.value ? BigInt(s.value) : 0n, M = J.formatTxAmount(s.value, u.symbol, u.decimals), K = J.formatTxAmount("0x" + k.toString(16), u.symbol, u.decimals), q = J.formatTxAmount("0x" + (F + k).toString(16), u.symbol, u.decimals);
1827
+ const k = BigInt(A.gasUsed) * BigInt(A.effectiveGasPrice), F = s.value ? BigInt(s.value) : 0n, M = V.formatTxAmount(s.value, u.symbol, u.decimals), K = V.formatTxAmount("0x" + k.toString(16), u.symbol, u.decimals), q = V.formatTxAmount("0x" + (F + k).toString(16), u.symbol, u.decimals);
1815
1828
  return {
1816
1829
  chainId: e,
1817
1830
  txHash: a,
@@ -1828,7 +1841,7 @@ const J = class J extends rr {
1828
1841
  txHash: a,
1829
1842
  from: f,
1830
1843
  to: s.to,
1831
- amount: J.formatTxAmount(s.value, u.symbol, u.decimals),
1844
+ amount: V.formatTxAmount(s.value, u.symbol, u.decimals),
1832
1845
  nativeSymbol: u.symbol,
1833
1846
  status: "timeout"
1834
1847
  }));
@@ -2006,7 +2019,7 @@ const J = class J extends rr {
2006
2019
  return { wei: "0x0", formatted: "0", chainId: e };
2007
2020
  try {
2008
2021
  const n = await this.jsonRpc.call("eth_getBalance", [s, "latest"], e) ?? "0x0";
2009
- return { wei: n, formatted: J.formatWei(n), chainId: e };
2022
+ return { wei: n, formatted: V.formatWei(n), chainId: e };
2010
2023
  } catch (t) {
2011
2024
  if (t instanceof x) throw t;
2012
2025
  const n = t instanceof Error ? t.message : String(t);
@@ -2043,7 +2056,7 @@ const J = class J extends rr {
2043
2056
  * const client = createWalletClient({ transport: custom(provider) });
2044
2057
  */
2045
2058
  getProvider(e) {
2046
- return this.ensureAuthenticated(), new Js(this, e);
2059
+ return this.ensureAuthenticated(), new Zs(this, e);
2047
2060
  }
2048
2061
  /**
2049
2062
  * 범용 JSON-RPC 요청 — 노드에 직접 연결.
@@ -2208,7 +2221,7 @@ const J = class J extends rr {
2208
2221
  const b = Nt;
2209
2222
  c.maxFeePerGas = "0x" + (BigInt(p) + BigInt(b)).toString(16), c.maxPriorityFeePerGas = b, d.log("[CROSSx] Dynamic 체인 감지 — baseFee:", p, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
2210
2223
  } else
2211
- c.gasPrice = lr, d.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
2224
+ c.gasPrice = dr, d.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
2212
2225
  }
2213
2226
  return !i && a && (c.maxPriorityFeePerGas = Nt, d.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
2214
2227
  }
@@ -2219,7 +2232,7 @@ const J = class J extends rr {
2219
2232
  * - chainId가 '0' → domain.chainId가 없거나 0이어야 함
2220
2233
  */
2221
2234
  static validateTypedDataChainId(e, s) {
2222
- const t = J.extractDomainChainId(s);
2235
+ const t = V.extractDomainChainId(s);
2223
2236
  if (e === "0") {
2224
2237
  if (t !== void 0 && t !== 0)
2225
2238
  throw new x(
@@ -2295,10 +2308,18 @@ const J = class J extends rr {
2295
2308
  d.warn("[CROSSx] ecrecover 검증 중 예외 (무시):", n);
2296
2309
  }
2297
2310
  }
2311
+ /**
2312
+ * 활성 지갑을 설정하고 addressChanged를 발행한 뒤
2313
+ * StoragePort에 선호 지갑 정보를 영속화합니다.
2314
+ */
2315
+ setActiveWallet(e, s) {
2316
+ this.address = e, this.activeWalletIndex = s, this.emit("addressChanged", { address: e, index: s }), this._config.persistWalletPreference !== !1 && this.storage.set(V.WALLET_PREF_KEY, { index: s, address: e }).catch(() => {
2317
+ });
2318
+ }
2298
2319
  /** AuthResult를 내부 상태에 반영합니다. */
2299
2320
  applyAuthResult(e) {
2300
2321
  var s, t, n, o;
2301
- this.authenticated = e.success, this.userId = ((s = e.user) == null ? void 0 : s.id) ?? null, this.address = e.address ?? null, this.activeWalletIndex = 0, this.userEmail = ((t = e.user) == null ? void 0 : t.email) ?? null, this.providerSub = ((n = e.user) == null ? void 0 : n.providerSub) ?? null, this.loginType = J.normalizeLoginType((o = e.user) == null ? void 0 : o.signInProvider), this.tokenSignatureVerified = e.tokenSignatureVerified ?? !1, this._isRecoveringSession || this.emit("authChanged", {
2322
+ this.authenticated = e.success, this.userId = ((s = e.user) == null ? void 0 : s.id) ?? null, this.address = e.address ?? null, this.activeWalletIndex = 0, this.userEmail = ((t = e.user) == null ? void 0 : t.email) ?? null, this.providerSub = ((n = e.user) == null ? void 0 : n.providerSub) ?? null, this.loginType = V.normalizeLoginType((o = e.user) == null ? void 0 : o.signInProvider), this.tokenSignatureVerified = e.tokenSignatureVerified ?? !1, this._isRecoveringSession || this.emit("authChanged", {
2302
2323
  isAuthenticated: this.authenticated,
2303
2324
  address: this.address,
2304
2325
  userId: this.userId
@@ -2306,7 +2327,8 @@ const J = class J extends rr {
2306
2327
  }
2307
2328
  /** 인증 상태를 초기화합니다. */
2308
2329
  clearAuthState() {
2309
- this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.providerSub = null, this.loginType = null, this.tokenSignatureVerified = !1, this.pinStore.clear(), this._isRecoveringSession || this.emit("authChanged", {
2330
+ this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.providerSub = null, this.loginType = null, this.tokenSignatureVerified = !1, this.pinStore.clear(), this._config.persistWalletPreference !== !1 && this.storage.remove(V.WALLET_PREF_KEY).catch(() => {
2331
+ }), this._isRecoveringSession || this.emit("authChanged", {
2310
2332
  isAuthenticated: !1,
2311
2333
  address: null,
2312
2334
  userId: null
@@ -2512,7 +2534,7 @@ const J = class J extends rr {
2512
2534
  if (u.code === h.PIN_INVALID)
2513
2535
  return { ok: !1, error: u.message };
2514
2536
  if (u.code === h.PIN_LOCKED)
2515
- return J.buildPinLockedResult(u, a);
2537
+ return V.buildPinLockedResult(u, a);
2516
2538
  }
2517
2539
  throw u;
2518
2540
  }
@@ -2566,7 +2588,7 @@ const J = class J extends rr {
2566
2588
  return null;
2567
2589
  }
2568
2590
  static buildPinLockedResult(e, s) {
2569
- const t = J.parsePinError(e, s);
2591
+ const t = V.parsePinError(e, s);
2570
2592
  if (!t) return { ok: !1, error: e.message };
2571
2593
  const { errorMessage: n, ...o } = t;
2572
2594
  return { ok: !1, error: n, ...o };
@@ -2578,19 +2600,19 @@ const J = class J extends rr {
2578
2600
  * 2. GET /mnemonic/addresses (비밀번호 불필요) → 캐시된 주소가 있으면 바로 사용
2579
2601
  * 3. 빈 배열인 경우 → 비밀번호 확인(메모리 없으면 모달) → POST /mnemonic/address(0)
2580
2602
  */
2581
- async loadWalletAfterAuth(e) {
2603
+ async loadWalletAfterAuth(e, s) {
2582
2604
  if (!this.userId) return;
2583
- const s = await this.fetchWalletStatus();
2584
- if (d.log("[CROSSx] loadWalletAfterAuth 지갑 상태:", s), s !== "exists") return;
2585
- const t = await this.walletProvider.getAddresses(this.userId);
2586
- if (t.length > 0) {
2587
- const o = e !== void 0 ? t.find((i) => i.index === e) ?? t[0] : t[0];
2588
- this.address = o.address, this.activeWalletIndex = o.index, d.log("[CROSSx] 캐시된 주소 로드 완료 (비밀번호 불필요):", this.address), this.emit("addressChanged", { address: o.address, index: o.index });
2605
+ const t = await this.fetchWalletStatus();
2606
+ if (d.log("[CROSSx] loadWalletAfterAuth 지갑 상태:", t), t !== "exists") return;
2607
+ const n = await this.walletProvider.getAddresses(this.userId);
2608
+ if (n.length > 0) {
2609
+ const i = s ? n.find((l) => l.address.toLowerCase() === s.toLowerCase()) : void 0, a = e !== void 0 ? n.find((l) => l.index === e) : void 0, c = i ?? a ?? n[0];
2610
+ d.log("[CROSSx] 캐시된 주소 로드 완료 (비밀번호 불필요):", c.address), this.setActiveWallet(c.address, c.index);
2589
2611
  return;
2590
2612
  }
2591
2613
  d.log("[CROSSx] 주소 캐시 없음 — 비밀번호 확인 후 address(0) 조회"), await this.ensureVerifiedPin();
2592
- const n = await this.walletProvider.getAddress(this.userId, 0);
2593
- this.address = n.address, this.activeWalletIndex = 0, d.log("[CROSSx] 세션 복원 후 지갑 주소 로드 완료:", this.address), this.emit("addressChanged", { address: n.address, index: 0 });
2614
+ const o = await this.walletProvider.getAddress(this.userId, 0);
2615
+ d.log("[CROSSx] 세션 복원 후 지갑 주소 로드 완료:", o.address), this.setActiveWallet(o.address, 0);
2594
2616
  }
2595
2617
  /**
2596
2618
  * PIN_WRONG 에러 시 서버 검증 포함 PIN 재입력 모달을 표시하고 재시도합니다.
@@ -2612,7 +2634,7 @@ const J = class J extends rr {
2612
2634
  return await e();
2613
2635
  } catch (n) {
2614
2636
  if (n instanceof x) {
2615
- if (t = J.parsePinError(n, s), !t) throw n;
2637
+ if (t = V.parsePinError(n, s), !t) throw n;
2616
2638
  } else
2617
2639
  throw n;
2618
2640
  }
@@ -2626,7 +2648,7 @@ const J = class J extends rr {
2626
2648
  try {
2627
2649
  return await e();
2628
2650
  } catch (n) {
2629
- if (n instanceof x && (t = J.parsePinError(n, s), t))
2651
+ if (n instanceof x && (t = V.parsePinError(n, s), t))
2630
2652
  continue;
2631
2653
  throw n;
2632
2654
  }
@@ -2688,9 +2710,9 @@ const J = class J extends rr {
2688
2710
  };
2689
2711
  }
2690
2712
  };
2691
- J.OFFCHAIN_CHAIN_ID = "0";
2692
- let ht = J;
2693
- class hr {
2713
+ V.WALLET_PREF_KEY = "wallet_preference", V.OFFCHAIN_CHAIN_ID = "0";
2714
+ let ht = V;
2715
+ class pr {
2694
2716
  constructor() {
2695
2717
  this.prefix = "crossx_";
2696
2718
  }
@@ -2727,7 +2749,7 @@ class hr {
2727
2749
  }
2728
2750
  }
2729
2751
  }
2730
- const st = "crossx-sdk", pr = 1, he = "data", Ee = "keys", We = "aes-primary", fr = 12;
2752
+ const st = "crossx-sdk", fr = 1, he = "data", Ee = "keys", We = "aes-primary", _r = 12;
2731
2753
  class Bt {
2732
2754
  constructor(e) {
2733
2755
  this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
@@ -2737,7 +2759,7 @@ class Bt {
2737
2759
  }
2738
2760
  openDB(e = this.dbName) {
2739
2761
  return new Promise((s, t) => {
2740
- const n = indexedDB.open(e, pr);
2762
+ const n = indexedDB.open(e, fr);
2741
2763
  n.onupgradeneeded = () => {
2742
2764
  const o = n.result;
2743
2765
  o.objectStoreNames.contains(he) || o.createObjectStore(he), o.objectStoreNames.contains(Ee) || o.createObjectStore(Ee);
@@ -2815,7 +2837,7 @@ class Bt {
2815
2837
  }
2816
2838
  }
2817
2839
  async encrypt(e) {
2818
- const s = new Uint8Array(fr);
2840
+ const s = new Uint8Array(_r);
2819
2841
  crypto.getRandomValues(s);
2820
2842
  const t = new TextEncoder().encode(e), n = await crypto.subtle.encrypt(
2821
2843
  { name: "AES-GCM", iv: s },
@@ -2908,7 +2930,7 @@ function cs(r, e) {
2908
2930
  if (r.length < s)
2909
2931
  throw new Error('"digestInto() output" expected to be of length >=' + s);
2910
2932
  }
2911
- function _r(r) {
2933
+ function xr(r) {
2912
2934
  return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
2913
2935
  }
2914
2936
  function Le(...r) {
@@ -2921,22 +2943,22 @@ function rt(r) {
2921
2943
  function pe(r, e) {
2922
2944
  return r << 32 - e | r >>> e;
2923
2945
  }
2924
- const xr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2925
- function gr(r) {
2946
+ const gr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2947
+ function mr(r) {
2926
2948
  return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
2927
2949
  }
2928
- function mr(r) {
2950
+ function wr(r) {
2929
2951
  for (let e = 0; e < r.length; e++)
2930
- r[e] = gr(r[e]);
2952
+ r[e] = mr(r[e]);
2931
2953
  return r;
2932
2954
  }
2933
- const Ut = xr ? (r) => r : mr, ls = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", wr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
2955
+ const Ut = gr ? (r) => r : wr, ls = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", yr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
2934
2956
  function Fe(r) {
2935
2957
  if (z(r), ls)
2936
2958
  return r.toHex();
2937
2959
  let e = "";
2938
2960
  for (let s = 0; s < r.length; s++)
2939
- e += wr[r[s]];
2961
+ e += yr[r[s]];
2940
2962
  return e;
2941
2963
  }
2942
2964
  const _e = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
@@ -2990,16 +3012,16 @@ function us(r = 32) {
2990
3012
  throw new Error("crypto.getRandomValues must be defined");
2991
3013
  return e.getRandomValues(new Uint8Array(r));
2992
3014
  }
2993
- const yr = (r) => ({
3015
+ const br = (r) => ({
2994
3016
  oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, r])
2995
3017
  });
2996
- function br(r, e, s) {
3018
+ function Sr(r, e, s) {
2997
3019
  return r & e ^ ~r & s;
2998
3020
  }
2999
- function Sr(r, e, s) {
3021
+ function vr(r, e, s) {
3000
3022
  return r & e ^ r & s ^ e & s;
3001
3023
  }
3002
- class vr {
3024
+ class Er {
3003
3025
  constructor(e, s, t, n) {
3004
3026
  P(this, "blockLen");
3005
3027
  P(this, "outputLen");
@@ -3071,19 +3093,19 @@ const ye = /* @__PURE__ */ Uint32Array.from([
3071
3093
  528734635,
3072
3094
  1541459225
3073
3095
  ]), Ge = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ft = /* @__PURE__ */ BigInt(32);
3074
- function Er(r, e = !1) {
3096
+ function Ir(r, e = !1) {
3075
3097
  return e ? { h: Number(r & Ge), l: Number(r >> Ft & Ge) } : { h: Number(r >> Ft & Ge) | 0, l: Number(r & Ge) | 0 };
3076
3098
  }
3077
- function Ir(r, e = !1) {
3099
+ function Ar(r, e = !1) {
3078
3100
  const s = r.length;
3079
3101
  let t = new Uint32Array(s), n = new Uint32Array(s);
3080
3102
  for (let o = 0; o < s; o++) {
3081
- const { h: i, l: a } = Er(r[o], e);
3103
+ const { h: i, l: a } = Ir(r[o], e);
3082
3104
  [t[o], n[o]] = [i, a];
3083
3105
  }
3084
3106
  return [t, n];
3085
3107
  }
3086
- const Ar = (r, e, s) => r << s | e >>> 32 - s, Tr = (r, e, s) => e << s | r >>> 32 - s, kr = (r, e, s) => e << s - 32 | r >>> 64 - s, Rr = (r, e, s) => r << s - 32 | e >>> 64 - s, Or = /* @__PURE__ */ Uint32Array.from([
3108
+ const Tr = (r, e, s) => r << s | e >>> 32 - s, kr = (r, e, s) => e << s | r >>> 32 - s, Rr = (r, e, s) => e << s - 32 | r >>> 64 - s, Or = (r, e, s) => r << s - 32 | e >>> 64 - s, Pr = /* @__PURE__ */ Uint32Array.from([
3087
3109
  1116352408,
3088
3110
  1899447441,
3089
3111
  3049323471,
@@ -3149,7 +3171,7 @@ const Ar = (r, e, s) => r << s | e >>> 32 - s, Tr = (r, e, s) => e << s | r >>>
3149
3171
  3204031479,
3150
3172
  3329325298
3151
3173
  ]), be = /* @__PURE__ */ new Uint32Array(64);
3152
- class Pr extends vr {
3174
+ class Cr extends Er {
3153
3175
  constructor(e) {
3154
3176
  super(64, e, 8, !1);
3155
3177
  }
@@ -3170,7 +3192,7 @@ class Pr extends vr {
3170
3192
  }
3171
3193
  let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: u } = this;
3172
3194
  for (let f = 0; f < 64; f++) {
3173
- const _ = pe(a, 6) ^ pe(a, 11) ^ pe(a, 25), p = u + _ + br(a, c, l) + Or[f] + be[f] | 0, E = (pe(t, 2) ^ pe(t, 13) ^ pe(t, 22)) + Sr(t, n, o) | 0;
3195
+ const _ = pe(a, 6) ^ pe(a, 11) ^ pe(a, 25), p = u + _ + Sr(a, c, l) + Pr[f] + be[f] | 0, E = (pe(t, 2) ^ pe(t, 13) ^ pe(t, 22)) + vr(t, n, o) | 0;
3174
3196
  u = l, l = c, c = a, a = i + p | 0, i = o, o = n, n = t, t = p + E | 0;
3175
3197
  }
3176
3198
  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);
@@ -3182,7 +3204,7 @@ class Pr extends vr {
3182
3204
  this.set(0, 0, 0, 0, 0, 0, 0, 0), Le(this.buffer);
3183
3205
  }
3184
3206
  }
3185
- class Cr extends Pr {
3207
+ class Nr extends Cr {
3186
3208
  constructor() {
3187
3209
  super(32);
3188
3210
  // We cannot use array here since array allows indexing by variable
@@ -3197,9 +3219,9 @@ class Cr extends Pr {
3197
3219
  P(this, "H", ye[7] | 0);
3198
3220
  }
3199
3221
  }
3200
- const Nr = /* @__PURE__ */ ds(
3201
- () => new Cr(),
3202
- /* @__PURE__ */ yr(1)
3222
+ const Lr = /* @__PURE__ */ ds(
3223
+ () => new Nr(),
3224
+ /* @__PURE__ */ br(1)
3203
3225
  );
3204
3226
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3205
3227
  const mt = /* @__PURE__ */ BigInt(0), pt = /* @__PURE__ */ BigInt(1);
@@ -3231,7 +3253,7 @@ function Ze(r) {
3231
3253
  return ps(Fe(r));
3232
3254
  }
3233
3255
  function fs(r) {
3234
- return ps(Fe(Lr(z(r)).reverse()));
3256
+ return ps(Fe(Dr(z(r)).reverse()));
3235
3257
  }
3236
3258
  function wt(r, e) {
3237
3259
  we(e), r = hs(r);
@@ -3243,25 +3265,25 @@ function wt(r, e) {
3243
3265
  function _s(r, e) {
3244
3266
  return wt(r, e).reverse();
3245
3267
  }
3246
- function Lr(r) {
3268
+ function Dr(r) {
3247
3269
  return Uint8Array.from(r);
3248
3270
  }
3249
3271
  const ze = (r) => typeof r == "bigint" && mt <= r;
3250
- function Dr(r, e, s) {
3272
+ function $r(r, e, s) {
3251
3273
  return ze(r) && ze(e) && ze(s) && e <= r && r < s;
3252
3274
  }
3253
- function $r(r, e, s, t) {
3254
- if (!Dr(e, s, t))
3275
+ function Mr(r, e, s, t) {
3276
+ if (!$r(e, s, t))
3255
3277
  throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
3256
3278
  }
3257
- function Mr(r) {
3279
+ function Br(r) {
3258
3280
  let e;
3259
3281
  for (e = 0; r > mt; r >>= pt, e += 1)
3260
3282
  ;
3261
3283
  return e;
3262
3284
  }
3263
3285
  const yt = (r) => (pt << BigInt(r)) - pt;
3264
- function Br(r, e, s) {
3286
+ function Ur(r, e, s) {
3265
3287
  if (we(r, "hashLen"), we(e, "qByteLen"), typeof s != "function")
3266
3288
  throw new Error("hmacFn must be a function");
3267
3289
  const t = (S) => new Uint8Array(S), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
@@ -3315,7 +3337,7 @@ function Wt(r) {
3315
3337
  };
3316
3338
  }
3317
3339
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3318
- const ne = /* @__PURE__ */ BigInt(0), se = /* @__PURE__ */ BigInt(1), Te = /* @__PURE__ */ BigInt(2), xs = /* @__PURE__ */ BigInt(3), gs = /* @__PURE__ */ BigInt(4), ms = /* @__PURE__ */ BigInt(5), Ur = /* @__PURE__ */ BigInt(7), ws = /* @__PURE__ */ BigInt(8), Hr = /* @__PURE__ */ BigInt(9), ys = /* @__PURE__ */ BigInt(16);
3340
+ const ne = /* @__PURE__ */ BigInt(0), se = /* @__PURE__ */ BigInt(1), Te = /* @__PURE__ */ BigInt(2), xs = /* @__PURE__ */ BigInt(3), gs = /* @__PURE__ */ BigInt(4), ms = /* @__PURE__ */ BigInt(5), Hr = /* @__PURE__ */ BigInt(7), ws = /* @__PURE__ */ BigInt(8), Fr = /* @__PURE__ */ BigInt(9), ys = /* @__PURE__ */ BigInt(16);
3319
3341
  function ue(r, e) {
3320
3342
  const s = r % e;
3321
3343
  return s >= ne ? s : e + s;
@@ -3348,12 +3370,12 @@ function bs(r, e) {
3348
3370
  const s = (r.ORDER + se) / gs, t = r.pow(e, s);
3349
3371
  return St(r, t, e), t;
3350
3372
  }
3351
- function Fr(r, e) {
3373
+ function Wr(r, e) {
3352
3374
  const s = (r.ORDER - ms) / ws, t = r.mul(e, Te), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, Te), n), a = r.mul(o, r.sub(i, r.ONE));
3353
3375
  return St(r, a, e), a;
3354
3376
  }
3355
- function Wr(r) {
3356
- const e = Qe(r), s = Ss(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + Ur) / ys;
3377
+ function Gr(r) {
3378
+ const e = Qe(r), s = Ss(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + Hr) / ys;
3357
3379
  return (a, c) => {
3358
3380
  let l = a.pow(c, i), u = a.mul(l, t);
3359
3381
  const f = a.mul(l, n), _ = a.mul(l, o), p = a.eql(a.sqr(u), c), b = a.eql(a.sqr(f), c);
@@ -3396,10 +3418,10 @@ function Ss(r) {
3396
3418
  return p;
3397
3419
  };
3398
3420
  }
3399
- function Gr(r) {
3400
- return r % gs === xs ? bs : r % ws === ms ? Fr : r % ys === Hr ? Wr(r) : Ss(r);
3421
+ function qr(r) {
3422
+ return r % gs === xs ? bs : r % ws === ms ? Wr : r % ys === Fr ? Gr(r) : Ss(r);
3401
3423
  }
3402
- const qr = [
3424
+ const Kr = [
3403
3425
  "create",
3404
3426
  "isValid",
3405
3427
  "is0",
@@ -3418,15 +3440,15 @@ const qr = [
3418
3440
  "mulN",
3419
3441
  "sqrN"
3420
3442
  ];
3421
- function Kr(r) {
3443
+ function zr(r) {
3422
3444
  const e = {
3423
3445
  ORDER: "bigint",
3424
3446
  BYTES: "number",
3425
3447
  BITS: "number"
3426
- }, s = qr.reduce((t, n) => (t[n] = "function", t), e);
3448
+ }, s = Kr.reduce((t, n) => (t[n] = "function", t), e);
3427
3449
  return bt(r, s), r;
3428
3450
  }
3429
- function zr(r, e, s) {
3451
+ function Vr(r, e, s) {
3430
3452
  if (s < ne)
3431
3453
  throw new Error("invalid exponent, negatives unsupported");
3432
3454
  if (s === ne)
@@ -3448,12 +3470,12 @@ function qt(r, e) {
3448
3470
  throw new Error("invalid Legendre symbol result");
3449
3471
  return n ? 1 : o ? 0 : -1;
3450
3472
  }
3451
- function Vr(r, e) {
3473
+ function jr(r, e) {
3452
3474
  e !== void 0 && we(e);
3453
3475
  const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
3454
3476
  return { nBitLength: s, nByteLength: t };
3455
3477
  }
3456
- class jr {
3478
+ class Yr {
3457
3479
  constructor(e, s = {}) {
3458
3480
  P(this, "ORDER");
3459
3481
  P(this, "BITS");
@@ -3470,7 +3492,7 @@ class jr {
3470
3492
  throw new Error("invalid field: expected ORDER > 0, got " + e);
3471
3493
  let t;
3472
3494
  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));
3473
- const { nBitLength: n, nByteLength: o } = Vr(e, t);
3495
+ const { nBitLength: n, nByteLength: o } = jr(e, t);
3474
3496
  if (o > 2048)
3475
3497
  throw new Error("invalid field: expected ORDER of <= 2048 bytes");
3476
3498
  this.ORDER = e, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
@@ -3512,7 +3534,7 @@ class jr {
3512
3534
  return ue(e * s, this.ORDER);
3513
3535
  }
3514
3536
  pow(e, s) {
3515
- return zr(this, e, s);
3537
+ return Vr(this, e, s);
3516
3538
  }
3517
3539
  div(e, s) {
3518
3540
  return ue(e * Gt(s, this.ORDER), this.ORDER);
@@ -3534,7 +3556,7 @@ class jr {
3534
3556
  return Gt(e, this.ORDER);
3535
3557
  }
3536
3558
  sqrt(e) {
3537
- return this._sqrt || (this._sqrt = Gr(this.ORDER)), this._sqrt(this, e);
3559
+ return this._sqrt || (this._sqrt = qr(this.ORDER)), this._sqrt(this, e);
3538
3560
  }
3539
3561
  toBytes(e) {
3540
3562
  return this.isLE ? _s(e, this.BYTES) : wt(e, this.BYTES);
@@ -3566,7 +3588,7 @@ class jr {
3566
3588
  }
3567
3589
  }
3568
3590
  function Qe(r, e = {}) {
3569
- return new jr(r, e);
3591
+ return new Yr(r, e);
3570
3592
  }
3571
3593
  function Es(r) {
3572
3594
  if (typeof r != "bigint")
@@ -3578,7 +3600,7 @@ function Is(r) {
3578
3600
  const e = Es(r);
3579
3601
  return e + Math.ceil(e / 2);
3580
3602
  }
3581
- function Yr(r, e, s = !1) {
3603
+ function Xr(r, e, s = !1) {
3582
3604
  z(r);
3583
3605
  const t = r.length, n = Es(e), o = Is(e);
3584
3606
  if (t < 16 || t < o || t > 1024)
@@ -3620,7 +3642,7 @@ function Vt(r) {
3620
3642
  if (r !== De)
3621
3643
  throw new Error("invalid wNAF");
3622
3644
  }
3623
- class Xr {
3645
+ class Jr {
3624
3646
  // Parametrized with a given Point class (not individual point)
3625
3647
  constructor(e, s) {
3626
3648
  P(this, "BASE");
@@ -3714,7 +3736,7 @@ class Xr {
3714
3736
  return it(e) !== 1;
3715
3737
  }
3716
3738
  }
3717
- function Jr(r, e, s, t) {
3739
+ function Zr(r, e, s, t) {
3718
3740
  let n = e, o = r.ZERO, i = r.ZERO;
3719
3741
  for (; s > De || t > De; )
3720
3742
  s & ke && (o = o.add(n)), t & ke && (i = i.add(n)), n = n.double(), s >>= ke, t >>= ke;
@@ -3724,11 +3746,11 @@ function jt(r, e, s) {
3724
3746
  if (e) {
3725
3747
  if (e.ORDER !== r)
3726
3748
  throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
3727
- return Kr(e), e;
3749
+ return zr(e), e;
3728
3750
  } else
3729
3751
  return Qe(r, { isLE: s });
3730
3752
  }
3731
- function Zr(r, e, s = {}, t) {
3753
+ function Qr(r, e, s = {}, t) {
3732
3754
  if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
3733
3755
  throw new Error(`expected valid ${r} CURVE object`);
3734
3756
  for (const c of ["p", "n", "h"]) {
@@ -3742,7 +3764,7 @@ function Zr(r, e, s = {}, t) {
3742
3764
  throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
3743
3765
  return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: n, Fn: o };
3744
3766
  }
3745
- function Qr(r, e) {
3767
+ function en(r, e) {
3746
3768
  return function(t) {
3747
3769
  const n = r(t);
3748
3770
  return { secretKey: n, publicKey: e(n) };
@@ -3794,12 +3816,12 @@ const Rs = (r, e, s) => new ks(r, e).update(s).digest();
3794
3816
  Rs.create = (r, e) => new ks(r, e);
3795
3817
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3796
3818
  const Yt = (r, e) => (r + (r >= 0 ? e : -e) / Os) / e;
3797
- function en(r, e, s) {
3819
+ function tn(r, e, s) {
3798
3820
  const [[t, n], [o, i]] = e, a = Yt(i * r, s), c = Yt(-n * r, s);
3799
3821
  let l = r - a * t - c * o, u = -a * n - c * i;
3800
3822
  const f = l < ge, _ = u < ge;
3801
3823
  f && (l = -l), _ && (u = -u);
3802
- const p = yt(Math.ceil(Mr(s) / 2)) + Ce;
3824
+ const p = yt(Math.ceil(Br(s) / 2)) + Ce;
3803
3825
  if (l < ge || l >= p || u < ge || u >= p)
3804
3826
  throw new Error("splitScalar (endomorphism): failed, k=" + r);
3805
3827
  return { k1neg: f, k1: l, k2neg: _, k2: u };
@@ -3815,14 +3837,14 @@ function at(r, e) {
3815
3837
  s[t] = r[t] === void 0 ? e[t] : r[t];
3816
3838
  return je(s.lowS, "lowS"), je(s.prehash, "prehash"), s.format !== void 0 && ft(s.format), s;
3817
3839
  }
3818
- class tn extends Error {
3840
+ class sn extends Error {
3819
3841
  constructor(e = "") {
3820
3842
  super(e);
3821
3843
  }
3822
3844
  }
3823
3845
  const Se = {
3824
3846
  // asn.1 DER encoding utils
3825
- Err: tn,
3847
+ Err: sn,
3826
3848
  // Basic building block is TLV (Tag-Length-Value)
3827
3849
  _tlv: {
3828
3850
  encode: (r, e) => {
@@ -3907,9 +3929,9 @@ const Se = {
3907
3929
  const { _tlv: e, _int: s } = Se, t = e.encode(2, s.encode(r.r)), n = e.encode(2, s.encode(r.s)), o = t + n;
3908
3930
  return e.encode(48, o);
3909
3931
  }
3910
- }, ge = BigInt(0), Ce = BigInt(1), Os = BigInt(2), Ke = BigInt(3), sn = BigInt(4);
3911
- function rn(r, e = {}) {
3912
- const s = Zr("weierstrass", r, e), { Fp: t, Fn: n } = s;
3932
+ }, ge = BigInt(0), Ce = BigInt(1), Os = BigInt(2), Ke = BigInt(3), rn = BigInt(4);
3933
+ function nn(r, e = {}) {
3934
+ const s = Qr("weierstrass", r, e), { Fp: t, Fn: n } = s;
3913
3935
  let o = s.CURVE;
3914
3936
  const { h: i, n: a } = o;
3915
3937
  bt(e, {}, {
@@ -3974,7 +3996,7 @@ function rn(r, e = {}) {
3974
3996
  }
3975
3997
  if (!S(o.Gx, o.Gy))
3976
3998
  throw new Error("bad curve params: generator point");
3977
- const A = t.mul(t.pow(o.a, Ke), sn), k = t.mul(t.sqr(o.b), BigInt(27));
3999
+ const A = t.mul(t.pow(o.a, Ke), rn), k = t.mul(t.sqr(o.b), BigInt(27));
3978
4000
  if (t.is0(t.add(A, k)))
3979
4001
  throw new Error("bad curve params: a or b");
3980
4002
  function F($, g, m = !1) {
@@ -3983,13 +4005,13 @@ function rn(r, e = {}) {
3983
4005
  return g;
3984
4006
  }
3985
4007
  function M($) {
3986
- if (!($ instanceof X))
4008
+ if (!($ instanceof J))
3987
4009
  throw new Error("Weierstrass Point expected");
3988
4010
  }
3989
4011
  function K($) {
3990
4012
  if (!c || !c.basises)
3991
4013
  throw new Error("no endo");
3992
- return en($, c.basises, n.ORDER);
4014
+ return tn($, c.basises, n.ORDER);
3993
4015
  }
3994
4016
  const q = Wt(($, g) => {
3995
4017
  const { X: m, Y: T, Z: O } = $;
@@ -4019,7 +4041,7 @@ function rn(r, e = {}) {
4019
4041
  return !0;
4020
4042
  });
4021
4043
  function W($, g, m, T, O) {
4022
- return m = new X(t.mul(m.X, $), m.Y, m.Z), g = Ye(T, g), m = Ye(O, m), g.add(m);
4044
+ return m = new J(t.mul(m.X, $), m.Y, m.Z), g = Ye(T, g), m = Ye(O, m), g.add(m);
4023
4045
  }
4024
4046
  const C = class C {
4025
4047
  /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
@@ -4102,10 +4124,10 @@ function rn(r, e = {}) {
4102
4124
  const { X: m, Y: T, Z: O } = this, { X: D, Y: w, Z: y } = g;
4103
4125
  let v = t.ZERO, I = t.ZERO, R = t.ZERO;
4104
4126
  const H = o.a, B = t.mul(o.b, Ke);
4105
- let N = t.mul(m, D), G = t.mul(T, w), j = t.mul(O, y), ie = t.add(m, T), V = t.add(D, w);
4106
- ie = t.mul(ie, V), V = t.add(N, G), ie = t.sub(ie, V), V = t.add(m, O);
4127
+ let N = t.mul(m, D), G = t.mul(T, w), X = t.mul(O, y), ie = t.add(m, T), j = t.add(D, w);
4128
+ ie = t.mul(ie, j), j = t.add(N, G), ie = t.sub(ie, j), j = t.add(m, O);
4107
4129
  let te = t.add(D, y);
4108
- return V = t.mul(V, te), te = t.add(N, j), V = t.sub(V, te), te = t.add(T, O), v = t.add(w, y), te = t.mul(te, v), v = t.add(G, j), te = t.sub(te, v), R = t.mul(H, V), v = t.mul(B, j), R = t.add(v, R), v = t.sub(G, R), R = t.add(G, R), I = t.mul(v, R), G = t.add(N, N), G = t.add(G, N), j = t.mul(H, j), V = t.mul(B, V), G = t.add(G, j), j = t.sub(N, j), j = t.mul(H, j), V = t.add(V, j), N = t.mul(G, V), I = t.add(I, N), N = t.mul(te, V), v = t.mul(ie, v), v = t.sub(v, N), N = t.mul(ie, G), R = t.mul(te, R), R = t.add(R, N), new C(v, I, R);
4130
+ return j = t.mul(j, te), te = t.add(N, X), j = t.sub(j, te), te = t.add(T, O), v = t.add(w, y), te = t.mul(te, v), v = t.add(G, X), te = t.sub(te, v), R = t.mul(H, j), v = t.mul(B, X), R = t.add(v, R), v = t.sub(G, R), R = t.add(G, R), I = t.mul(v, R), G = t.add(N, N), G = t.add(G, N), X = t.mul(H, X), j = t.mul(B, j), G = t.add(G, X), X = t.sub(N, X), X = t.mul(H, X), j = t.add(j, X), N = t.mul(G, j), I = t.add(I, N), N = t.mul(te, j), v = t.mul(ie, v), v = t.sub(v, N), N = t.mul(ie, G), R = t.mul(te, R), R = t.add(R, N), new C(v, I, R);
4109
4131
  }
4110
4132
  subtract(g) {
4111
4133
  return this.add(g.negate());
@@ -4153,7 +4175,7 @@ function rn(r, e = {}) {
4153
4175
  if (U.hasCache(this))
4154
4176
  return this.multiply(g);
4155
4177
  if (m) {
4156
- const { k1neg: O, k1: D, k2neg: w, k2: y } = K(g), { p1: v, p2: I } = Jr(C, T, D, y);
4178
+ const { k1neg: O, k1: D, k2neg: w, k2: y } = K(g), { p1: v, p2: I } = Zr(C, T, D, y);
4157
4179
  return W(m.beta, v, I, O, w);
4158
4180
  } else
4159
4181
  return U.unsafe(T, g);
@@ -4196,9 +4218,9 @@ function rn(r, e = {}) {
4196
4218
  // math field
4197
4219
  P(C, "Fp", t), // scalar field
4198
4220
  P(C, "Fn", n);
4199
- let X = C;
4200
- const Q = n.BITS, U = new Xr(X, e.endo ? Math.ceil(Q / 2) : Q);
4201
- return X.BASE.precompute(8), X;
4221
+ let J = C;
4222
+ const Q = n.BITS, U = new Jr(J, e.endo ? Math.ceil(Q / 2) : Q);
4223
+ return J.BASE.precompute(8), J;
4202
4224
  }
4203
4225
  function Ps(r) {
4204
4226
  return Uint8Array.of(r ? 2 : 3);
@@ -4212,7 +4234,7 @@ function Cs(r, e) {
4212
4234
  signature: 2 * e.BYTES
4213
4235
  };
4214
4236
  }
4215
- function nn(r, e = {}) {
4237
+ function on(r, e = {}) {
4216
4238
  const { Fn: s } = r, t = e.randomBytes || us, n = Object.assign(Cs(r.Fp, s), { seed: Is(s.ORDER) });
4217
4239
  function o(p) {
4218
4240
  try {
@@ -4232,7 +4254,7 @@ function nn(r, e = {}) {
4232
4254
  }
4233
4255
  }
4234
4256
  function a(p = t(n.seed)) {
4235
- return Yr(z(p, n.seed, "seed"), s.ORDER);
4257
+ return Xr(z(p, n.seed, "seed"), s.ORDER);
4236
4258
  }
4237
4259
  function c(p, b = !0) {
4238
4260
  return r.BASE.multiply(s.fromBytes(p)).toBytes(b);
@@ -4256,10 +4278,10 @@ function nn(r, e = {}) {
4256
4278
  isValidSecretKey: o,
4257
4279
  isValidPublicKey: i,
4258
4280
  randomSecretKey: a
4259
- }, _ = Qr(a, c);
4281
+ }, _ = en(a, c);
4260
4282
  return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen: _, Point: r, utils: f, lengths: n });
4261
4283
  }
4262
- function on(r, e, s = {}) {
4284
+ function an(r, e, s = {}) {
4263
4285
  as(e), bt(s, {}, {
4264
4286
  hmac: "function",
4265
4287
  lowS: "boolean",
@@ -4267,7 +4289,7 @@ function on(r, e, s = {}) {
4267
4289
  bits2int: "function",
4268
4290
  bits2int_modN: "function"
4269
4291
  }), s = Object.assign({}, s);
4270
- const t = s.randomBytes || us, n = s.hmac || ((g, m) => Rs(e, g, m)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: u, getSharedSecret: f, utils: _, lengths: p } = nn(r, s), b = {
4292
+ const t = s.randomBytes || us, n = s.hmac || ((g, m) => Rs(e, g, m)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: u, getSharedSecret: f, utils: _, lengths: p } = on(r, s), b = {
4271
4293
  prehash: !0,
4272
4294
  lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
4273
4295
  format: "compact",
@@ -4358,14 +4380,14 @@ function on(r, e, s = {}) {
4358
4380
  return i.create(K(m));
4359
4381
  }, Z = yt(c);
4360
4382
  function W(g) {
4361
- return $r("num < 2^" + c, g, ge, Z), i.toBytes(g);
4383
+ return Mr("num < 2^" + c, g, ge, Z), i.toBytes(g);
4362
4384
  }
4363
- function X(g, m) {
4385
+ function J(g, m) {
4364
4386
  return z(g, void 0, "message"), m ? z(e(g), void 0, "prehashed message") : g;
4365
4387
  }
4366
4388
  function Q(g, m, T) {
4367
4389
  const { lowS: O, prehash: D, extraEntropy: w } = at(T, b);
4368
- g = X(g, D);
4390
+ g = J(g, D);
4369
4391
  const y = q(g), v = i.fromBytes(m);
4370
4392
  if (!i.isValidNot0(v))
4371
4393
  throw new Error("invalid private key");
@@ -4379,24 +4401,24 @@ function on(r, e, s = {}) {
4379
4401
  const G = K(N);
4380
4402
  if (!i.isValidNot0(G))
4381
4403
  return;
4382
- const j = i.inv(G), ie = r.BASE.multiply(G).toAffine(), V = i.create(ie.x);
4383
- if (V === ge)
4404
+ const X = i.inv(G), ie = r.BASE.multiply(G).toAffine(), j = i.create(ie.x);
4405
+ if (j === ge)
4384
4406
  return;
4385
- const te = i.create(j * i.create(H + V * v));
4407
+ const te = i.create(X * i.create(H + j * v));
4386
4408
  if (te === ge)
4387
4409
  return;
4388
- let At = (ie.x === V ? 0 : 2) | Number(ie.y & Ce), Tt = te;
4389
- return O && S(te) && (Tt = i.neg(te), At ^= 1), new M(V, Tt, E ? void 0 : At);
4410
+ let At = (ie.x === j ? 0 : 2) | Number(ie.y & Ce), Tt = te;
4411
+ return O && S(te) && (Tt = i.neg(te), At ^= 1), new M(j, Tt, E ? void 0 : At);
4390
4412
  }
4391
4413
  return { seed: R, k2sig: B };
4392
4414
  }
4393
4415
  function U(g, m, T = {}) {
4394
4416
  const { seed: O, k2sig: D } = Q(g, m, T);
4395
- return Br(e.outputLen, i.BYTES, n)(O, D).toBytes(T.format);
4417
+ return Ur(e.outputLen, i.BYTES, n)(O, D).toBytes(T.format);
4396
4418
  }
4397
4419
  function C(g, m, T, O = {}) {
4398
4420
  const { lowS: D, prehash: w, format: y } = at(O, b);
4399
- if (T = z(T, void 0, "publicKey"), m = X(m, w), !gt(g)) {
4421
+ if (T = z(T, void 0, "publicKey"), m = J(m, w), !gt(g)) {
4400
4422
  const v = g instanceof M ? ", use sig.toBytes()" : "";
4401
4423
  throw new Error("verify expects Uint8Array signature" + v);
4402
4424
  }
@@ -4405,7 +4427,7 @@ function on(r, e, s = {}) {
4405
4427
  const v = M.fromBytes(g, y), I = r.fromBytes(T);
4406
4428
  if (D && v.hasHighS())
4407
4429
  return !1;
4408
- const { r: R, s: H } = v, B = q(m), N = i.inv(H), G = i.create(B * N), j = i.create(R * N), ie = r.BASE.multiplyUnsafe(G).add(I.multiplyUnsafe(j));
4430
+ const { r: R, s: H } = v, B = q(m), N = i.inv(H), G = i.create(B * N), X = i.create(R * N), ie = r.BASE.multiplyUnsafe(G).add(I.multiplyUnsafe(X));
4409
4431
  return ie.is0() ? !1 : i.create(ie.x) === R;
4410
4432
  } catch {
4411
4433
  return !1;
@@ -4413,7 +4435,7 @@ function on(r, e, s = {}) {
4413
4435
  }
4414
4436
  function $(g, m, T = {}) {
4415
4437
  const { prehash: O } = at(T, b);
4416
- return m = X(m, O), M.fromBytes(g, "recovered").recoverPublicKey(m).toBytes();
4438
+ return m = J(m, O), M.fromBytes(g, "recovered").recoverPublicKey(m).toBytes();
4417
4439
  }
4418
4440
  return Object.freeze({
4419
4441
  keygen: l,
@@ -4438,32 +4460,32 @@ const vt = {
4438
4460
  b: BigInt(7),
4439
4461
  Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
4440
4462
  Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
4441
- }, an = {
4463
+ }, cn = {
4442
4464
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
4443
4465
  basises: [
4444
4466
  [BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
4445
4467
  [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
4446
4468
  ]
4447
4469
  }, Xt = /* @__PURE__ */ BigInt(2);
4448
- function cn(r) {
4470
+ function ln(r) {
4449
4471
  const e = vt.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, f = ce(u, s, e) * u % e, _ = ce(f, s, e) * u % e, p = ce(_, Xt, e) * l % e, b = ce(p, n, e) * p % e, E = ce(b, o, e) * b % e, S = ce(E, a, e) * E % e, A = ce(S, c, e) * S % e, k = ce(A, a, e) * E % e, F = ce(k, s, e) * u % e, M = ce(F, i, e) * b % e, K = ce(M, t, e) * l % e, q = ce(K, Xt, e);
4450
4472
  if (!_t.eql(_t.sqr(q), r))
4451
4473
  throw new Error("Cannot find square root");
4452
4474
  return q;
4453
4475
  }
4454
- const _t = Qe(vt.p, { sqrt: cn }), ln = /* @__PURE__ */ rn(vt, {
4476
+ const _t = Qe(vt.p, { sqrt: ln }), dn = /* @__PURE__ */ nn(vt, {
4455
4477
  Fp: _t,
4456
- endo: an
4457
- }), dn = /* @__PURE__ */ on(ln, Nr), un = BigInt(0), Me = BigInt(1), hn = BigInt(2), pn = BigInt(7), fn = BigInt(256), _n = BigInt(113), Ns = [], Ls = [], Ds = [];
4478
+ endo: cn
4479
+ }), un = /* @__PURE__ */ an(dn, Lr), hn = BigInt(0), Me = BigInt(1), pn = BigInt(2), fn = BigInt(7), _n = BigInt(256), xn = BigInt(113), Ns = [], Ls = [], Ds = [];
4458
4480
  for (let r = 0, e = Me, s = 1, t = 0; r < 24; r++) {
4459
4481
  [s, t] = [t, (2 * s + 3 * t) % 5], Ns.push(2 * (5 * t + s)), Ls.push((r + 1) * (r + 2) / 2 % 64);
4460
- let n = un;
4482
+ let n = hn;
4461
4483
  for (let o = 0; o < 7; o++)
4462
- e = (e << Me ^ (e >> pn) * _n) % fn, e & hn && (n ^= Me << (Me << BigInt(o)) - Me);
4484
+ e = (e << Me ^ (e >> fn) * xn) % _n, e & pn && (n ^= Me << (Me << BigInt(o)) - Me);
4463
4485
  Ds.push(n);
4464
4486
  }
4465
- const $s = Ir(Ds, !0), xn = $s[0], gn = $s[1], Jt = (r, e, s) => s > 32 ? kr(r, e, s) : Ar(r, e, s), Zt = (r, e, s) => s > 32 ? Rr(r, e, s) : Tr(r, e, s);
4466
- function mn(r, e = 24) {
4487
+ const $s = Ar(Ds, !0), gn = $s[0], mn = $s[1], Jt = (r, e, s) => s > 32 ? Rr(r, e, s) : Tr(r, e, s), Zt = (r, e, s) => s > 32 ? Or(r, e, s) : kr(r, e, s);
4488
+ function wn(r, e = 24) {
4467
4489
  const s = new Uint32Array(10);
4468
4490
  for (let t = 24 - e; t < 24; t++) {
4469
4491
  for (let i = 0; i < 10; i++)
@@ -4484,7 +4506,7 @@ function mn(r, e = 24) {
4484
4506
  for (let a = 0; a < 10; a++)
4485
4507
  r[i + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
4486
4508
  }
4487
- r[0] ^= xn[t], r[1] ^= gn[t];
4509
+ r[0] ^= gn[t], r[1] ^= mn[t];
4488
4510
  }
4489
4511
  Le(s);
4490
4512
  }
@@ -4504,13 +4526,13 @@ class Et {
4504
4526
  P(this, "rounds");
4505
4527
  if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, we(t, "outputLen"), !(0 < e && e < 200))
4506
4528
  throw new Error("only keccak-f1600 function is supported");
4507
- this.state = new Uint8Array(200), this.state32 = _r(this.state);
4529
+ this.state = new Uint8Array(200), this.state32 = xr(this.state);
4508
4530
  }
4509
4531
  clone() {
4510
4532
  return this._cloneInto();
4511
4533
  }
4512
4534
  keccak() {
4513
- Ut(this.state32), mn(this.state32, this.rounds), Ut(this.state32), this.posOut = 0, this.pos = 0;
4535
+ Ut(this.state32), wn(this.state32, this.rounds), Ut(this.state32), this.posOut = 0, this.pos = 0;
4514
4536
  }
4515
4537
  update(e) {
4516
4538
  Ne(this), z(e);
@@ -4564,14 +4586,14 @@ class Et {
4564
4586
  return e || (e = new Et(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;
4565
4587
  }
4566
4588
  }
4567
- const wn = (r, e, s, t = {}) => ds(() => new Et(e, r, s), t), Qt = /* @__PURE__ */ wn(1, 136, 32), yn = 60;
4568
- class bn {
4589
+ const yn = (r, e, s, t = {}) => ds(() => new Et(e, r, s), t), Qt = /* @__PURE__ */ yn(1, 136, 32), bn = 60;
4590
+ class Sn {
4569
4591
  constructor() {
4570
4592
  this.jwks = null;
4571
4593
  }
4572
4594
  setJWKSEndpoint(e) {
4573
4595
  try {
4574
- this.jwks = Ws(new URL(e)), d.log("[CROSSx] JWKS 엔드포인트 설정:", e);
4596
+ this.jwks = Gs(new URL(e)), d.log("[CROSSx] JWKS 엔드포인트 설정:", e);
4575
4597
  } catch (s) {
4576
4598
  d.warn("[CROSSx] JWKS 엔드포인트 URL 파싱 실패:", s);
4577
4599
  }
@@ -4585,7 +4607,7 @@ class bn {
4585
4607
  iat: t.iat
4586
4608
  });
4587
4609
  const n = Math.floor(Date.now() / 1e3);
4588
- if (t.exp && t.exp + yn < n)
4610
+ if (t.exp && t.exp + bn < n)
4589
4611
  return d.warn("[CROSSx] 토큰 만료:", {
4590
4612
  exp: t.exp,
4591
4613
  now: n,
@@ -4595,7 +4617,7 @@ class bn {
4595
4617
  return d.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 };
4596
4618
  if (this.jwks)
4597
4619
  try {
4598
- const { payload: o } = await Gs(e, this.jwks, {
4620
+ const { payload: o } = await qs(e, this.jwks, {
4599
4621
  algorithms: ["RS256", "ES256"]
4600
4622
  });
4601
4623
  return d.log("[CROSSx] JWT 서명 검증 성공"), {
@@ -4614,7 +4636,7 @@ class bn {
4614
4636
  }
4615
4637
  }
4616
4638
  decodeJWT(e) {
4617
- return qs(e);
4639
+ return Ks(e);
4618
4640
  }
4619
4641
  /**
4620
4642
  * EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
@@ -4632,14 +4654,14 @@ ${t.length}`
4632
4654
  const i = Qt(o), a = s.startsWith("0x") ? s.slice(2) : s;
4633
4655
  if (a.length !== 130)
4634
4656
  throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
4635
- const c = Sn(a), l = c.slice(0, 32), u = c.slice(32, 64), f = c[64], _ = f >= 27 ? f - 27 : f, E = new dn.Signature(
4657
+ const c = vn(a), l = c.slice(0, 32), u = c.slice(32, 64), f = c[64], _ = f >= 27 ? f - 27 : f, E = new un.Signature(
4636
4658
  es(l),
4637
4659
  es(u)
4638
4660
  ).addRecoveryBit(_).recoverPublicKey(i).toBytes(!1).slice(1), S = Qt(E);
4639
4661
  return "0x" + Fe(S.slice(12));
4640
4662
  }
4641
4663
  }
4642
- function Sn(r) {
4664
+ function vn(r) {
4643
4665
  const e = new Uint8Array(r.length / 2);
4644
4666
  for (let s = 0; s < e.length; s++)
4645
4667
  e[s] = parseInt(r.substring(s * 2, s * 2 + 2), 16);
@@ -4650,8 +4672,8 @@ function es(r) {
4650
4672
  for (const s of r) e += s.toString(16).padStart(2, "0");
4651
4673
  return BigInt(e);
4652
4674
  }
4653
- const vn = 3e4, En = 1e3;
4654
- class In {
4675
+ const En = 3e4, In = 1e3;
4676
+ class An {
4655
4677
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4656
4678
  async request(e) {
4657
4679
  const s = e.retries ?? 0;
@@ -4662,7 +4684,7 @@ class In {
4662
4684
  } catch (n) {
4663
4685
  if (t === s) throw n;
4664
4686
  }
4665
- await new Promise((n) => setTimeout(n, En * 2 ** t));
4687
+ await new Promise((n) => setTimeout(n, In * 2 ** t));
4666
4688
  }
4667
4689
  throw new Error("Unexpected: retry loop exited without result");
4668
4690
  }
@@ -4670,7 +4692,7 @@ class In {
4670
4692
  async _doRequest(e) {
4671
4693
  const s = new AbortController(), t = setTimeout(
4672
4694
  () => s.abort(),
4673
- e.timeoutMs ?? vn
4695
+ e.timeoutMs ?? En
4674
4696
  );
4675
4697
  try {
4676
4698
  const n = await fetch(e.url, {
@@ -4697,7 +4719,7 @@ class In {
4697
4719
  }
4698
4720
  }
4699
4721
  }
4700
- const An = /* @__PURE__ */ new Set([
4722
+ const Tn = /* @__PURE__ */ new Set([
4701
4723
  "https://cross-wallet-oauth.crosstoken.io",
4702
4724
  "https://stg-cross-wallet-oauth.crosstoken.io",
4703
4725
  "https://dev-cross-wallet-oauth.crosstoken.io"
@@ -4801,7 +4823,7 @@ class Ie {
4801
4823
  clearTimeout(p), clearInterval(F), A && clearTimeout(A), window.removeEventListener("message", K);
4802
4824
  }, K = (q) => {
4803
4825
  if (q.origin !== e.expectedOrigin) return;
4804
- if (!An.has(q.origin)) {
4826
+ if (!Tn.has(q.origin)) {
4805
4827
  d.error("[CROSSx] postMessage origin이 허용 목록에 없음:", q.origin), M(), t(new Error("Unauthorized OAuth origin"));
4806
4828
  return;
4807
4829
  }
@@ -4811,8 +4833,8 @@ class Ie {
4811
4833
  format: Z ? "wrapped" : "flat",
4812
4834
  status: Z ? q.data.status : "(flat)"
4813
4835
  });
4814
- const X = (W == null ? void 0 : W.state) ?? q.data.state;
4815
- if (!X || X !== c) {
4836
+ const J = (W == null ? void 0 : W.state) ?? q.data.state;
4837
+ if (!J || J !== c) {
4816
4838
  t(new Error("OAuth state mismatch — possible CSRF attack"));
4817
4839
  return;
4818
4840
  }
@@ -4848,7 +4870,7 @@ class Ie {
4848
4870
  }
4849
4871
  }
4850
4872
  const Be = "crossx_wallet_data", Re = "crossx_mock_pin_hash";
4851
- class Tn {
4873
+ class kn {
4852
4874
  constructor(e, s) {
4853
4875
  this.storage = e, this.pinStore = s ?? null;
4854
4876
  }
@@ -5438,7 +5460,7 @@ class Ae {
5438
5460
  case -10006:
5439
5461
  return "Internal server error. Please try again later.";
5440
5462
  case -10007:
5441
- return "Transaction broadcast failed. Please try again.";
5463
+ return `Transaction broadcast failed (${s}). Please try again.`;
5442
5464
  case -10008:
5443
5465
  return "Another operation is in progress. Please try again later.";
5444
5466
  case -10013:
@@ -5478,14 +5500,17 @@ class Ae {
5478
5500
  }
5479
5501
  class He {
5480
5502
  constructor(e, s) {
5481
- this.cache = /* @__PURE__ */ new Map(), this.loadedAt = 0, this.usingFallback = !1, this.adapterConfig = e, this.projectId = e.projectId, this.transport = s;
5503
+ this.cache = /* @__PURE__ */ new Map(), this.loadedAt = 0, this.usingFallback = !1, this._fetchPromise = null, this.adapterConfig = e, this.projectId = e.projectId, this.transport = s;
5482
5504
  }
5483
5505
  get baseUrl() {
5484
5506
  return this.adapterConfig.gatewayUrl;
5485
5507
  }
5486
5508
  async getChains() {
5487
- if (this.isCacheValid())
5488
- return Array.from(this.cache.values());
5509
+ return this.isCacheValid() ? Array.from(this.cache.values()) : this._fetchPromise ? this._fetchPromise : (this._fetchPromise = this._doFetchChains().finally(() => {
5510
+ this._fetchPromise = null;
5511
+ }), this._fetchPromise);
5512
+ }
5513
+ async _doFetchChains() {
5489
5514
  try {
5490
5515
  const e = await this.request(
5491
5516
  "/chains"
@@ -5508,7 +5533,7 @@ class He {
5508
5533
  }
5509
5534
  isCacheValid() {
5510
5535
  if (this.loadedAt === 0) return !1;
5511
- const e = this.usingFallback ? ur : dr;
5536
+ const e = this.usingFallback ? hr : ur;
5512
5537
  return e === 0 ? !0 : Date.now() - this.loadedAt < e;
5513
5538
  }
5514
5539
  populateCache(e, s) {
@@ -5570,7 +5595,7 @@ class He {
5570
5595
  }
5571
5596
  }
5572
5597
  }
5573
- const ts = "__crossx-confirm-style", ee = "__crossx-confirm-overlay", kn = {
5598
+ const ts = "__crossx-confirm-style", ee = "__crossx-confirm-overlay", Rn = {
5574
5599
  light: {
5575
5600
  bg: "#FFFFFF",
5576
5601
  border: "rgba(18,18,18,0.05)",
@@ -5627,7 +5652,7 @@ const ts = "__crossx-confirm-style", ee = "__crossx-confirm-overlay", kn = {
5627
5652
  }
5628
5653
  };
5629
5654
  function ss(r, e) {
5630
- const s = kn[r], t = e == null ? void 0 : e[r];
5655
+ const s = Rn[r], t = e == null ? void 0 : e[r];
5631
5656
  return t ? {
5632
5657
  ...s,
5633
5658
  // ── Brand
@@ -5659,7 +5684,7 @@ function ss(r, e) {
5659
5684
  ...t.error !== void 0 && { errorColor: t.error }
5660
5685
  } : s;
5661
5686
  }
5662
- const Rn = `
5687
+ const On = `
5663
5688
  @import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
5664
5689
 
5665
5690
  #${ee} {
@@ -7689,7 +7714,7 @@ button.__crossx-connect-other-block:active {
7689
7714
  `;
7690
7715
  function le() {
7691
7716
  let r = document.getElementById(ts);
7692
- r || (r = document.createElement("style"), r.id = ts, document.head.appendChild(r)), r.textContent = Rn;
7717
+ r || (r = document.createElement("style"), r.id = ts, document.head.appendChild(r)), r.textContent = On;
7693
7718
  }
7694
7719
  function de(r) {
7695
7720
  const e = r.querySelector(".__crossx-card");
@@ -7718,11 +7743,14 @@ function de(r) {
7718
7743
  n = n.parentElement;
7719
7744
  }
7720
7745
  t.preventDefault();
7721
- }, { passive: !1 }), document.body.appendChild(r);
7746
+ }, { passive: !1 });
7747
+ for (const t of ["focusin", "focusout"])
7748
+ r.addEventListener(t, s);
7749
+ document.body.appendChild(r);
7722
7750
  }
7723
- const On = () => /iPad|iPhone|iPod/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
7751
+ const Pn = () => /iPad|iPhone|iPod/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
7724
7752
  function Oe() {
7725
- if (On()) {
7753
+ if (Pn()) {
7726
7754
  const e = window.scrollY;
7727
7755
  return document.body.style.position = "fixed", document.body.style.top = `-${e}px`, document.body.style.left = "0", document.body.style.right = "0", () => {
7728
7756
  document.body.style.position = "", document.body.style.top = "", document.body.style.left = "", document.body.style.right = "", window.scrollTo(0, e);
@@ -7736,7 +7764,7 @@ function Oe() {
7736
7764
  function re(r) {
7737
7765
  return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
7738
7766
  }
7739
- function Pn(r, e = "CROSS", s = 18) {
7767
+ function Ms(r, e = "CROSS", s = 18) {
7740
7768
  if (!r || r === "0x" || r === "0x0") return null;
7741
7769
  try {
7742
7770
  const t = BigInt(r);
@@ -7770,7 +7798,7 @@ const rs = {
7770
7798
  612044: "CROSS Testnet",
7771
7799
  612055: "CROSS Mainnet"
7772
7800
  };
7773
- function Ms(r) {
7801
+ function Bs(r) {
7774
7802
  const e = parseInt(r.split(":")[1] ?? "", 10);
7775
7803
  return !isNaN(e) && rs[e] ? rs[e] : r;
7776
7804
  }
@@ -7823,7 +7851,7 @@ function Nn(r) {
7823
7851
  return null;
7824
7852
  }
7825
7853
  }
7826
- function Bs(r) {
7854
+ function Us(r) {
7827
7855
  const e = Nn(r);
7828
7856
  if (!e) return Y("Estimated fee", "<span>—</span>");
7829
7857
  let s = Y("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
@@ -7887,9 +7915,9 @@ function Y(r, e) {
7887
7915
  </div>`;
7888
7916
  }
7889
7917
  function Fn(r, e) {
7890
- const s = e, t = et(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${re(r.to)}</span>
7891
- <button class="__crossx-copy-btn" data-copy="${L(r.to)}" title="Copy address">${me}</button>` : "<span>—</span>", o = Bs(r), i = r.data ?? "0x", a = document.createElement("div");
7892
- return a.id = ee, a.innerHTML = `
7918
+ const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = et(r.dappName), i = r.to ? `<span class="__crossx-addr-text">${re(r.to)}</span>
7919
+ <button class="__crossx-copy-btn" data-copy="${L(r.to)}" title="Copy address">${me}</button>` : "<span>—</span>", a = Us(r), c = Ms(r.value, t, n), l = c ? Y("Value", `<span>${c}</span>`) : "", u = r.data ?? "0x", f = document.createElement("div");
7920
+ return f.id = ee, f.innerHTML = `
7893
7921
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7894
7922
  <div class="__crossx-header">
7895
7923
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
@@ -7900,7 +7928,7 @@ function Fn(r, e) {
7900
7928
  <div class="__crossx-body-cols">
7901
7929
  <div class="__crossx-col-left">
7902
7930
  <p class="__crossx-sig-subtitle">
7903
- <span class="__crossx-sig-origin">${L(t)} </span>is requesting a Signature
7931
+ <span class="__crossx-sig-origin">${L(o)} </span>is requesting a Signature
7904
7932
  </p>
7905
7933
  <div class="__crossx-addr-pill">
7906
7934
  ${It}
@@ -7911,11 +7939,12 @@ function Fn(r, e) {
7911
7939
  <hr class="__crossx-divider __crossx-divider--cols">
7912
7940
  <div class="__crossx-col-right-sign">
7913
7941
  <div class="__crossx-rows">
7914
- ${Y("To", n)}
7915
- ${Y("Network", `<span>${Ms(r.chainId)}</span>`)}
7916
- ${o}
7942
+ ${Y("To", i)}
7943
+ ${Y("Network", `<span>${Bs(r.chainId)}</span>`)}
7944
+ ${l}
7945
+ ${a}
7917
7946
  </div>
7918
- <pre class="__crossx-raw-tx">${L(i)}</pre>
7947
+ <pre class="__crossx-raw-tx">${L(u)}</pre>
7919
7948
  </div>
7920
7949
  </div>
7921
7950
  <div class="__crossx-btn-row">
@@ -7924,11 +7953,11 @@ function Fn(r, e) {
7924
7953
  </div>
7925
7954
  </div>
7926
7955
  </div>
7927
- `, a;
7956
+ `, f;
7928
7957
  }
7929
7958
  function Wn(r, e) {
7930
7959
  const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = et(r.dappName), i = r.to ? `<span class="__crossx-addr-text">${re(r.to)}</span>
7931
- <button class="__crossx-copy-btn" data-copy="${L(r.to)}" title="Copy address">${me}</button>` : "<span>—</span>", a = Bs(r), l = Pn(r.value, t, n) ?? "—", u = document.createElement("div");
7960
+ <button class="__crossx-copy-btn" data-copy="${L(r.to)}" title="Copy address">${me}</button>` : "<span>—</span>", a = Us(r), l = Ms(r.value, t, n) ?? "—", u = document.createElement("div");
7932
7961
  return u.id = ee, u.innerHTML = `
7933
7962
  <div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7934
7963
  <div class="__crossx-header">
@@ -7943,7 +7972,7 @@ function Wn(r, e) {
7943
7972
  <div class="__crossx-body-cols">
7944
7973
  <div class="__crossx-rows">
7945
7974
  ${Y("To", i)}
7946
- ${Y("Network", `<span>${Ms(r.chainId)}</span>`)}
7975
+ ${Y("Network", `<span>${Bs(r.chainId)}</span>`)}
7947
7976
  ${a}
7948
7977
  </div>
7949
7978
  <div class="__crossx-pill">
@@ -8209,7 +8238,7 @@ const Zn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="h
8209
8238
  <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"/>
8210
8239
  </svg>`;
8211
8240
  function eo(r) {
8212
- const e = Vs(r);
8241
+ const e = js(r);
8213
8242
  return `<span class="__crossx-connect-other-wallet-desc-part"><span class="__crossx-connect-other-wallet-icon" aria-hidden="true">${Bn[r] ?? ""}</span><span class="__crossx-connect-other-wallet-name">${L(e)}</span></span>`;
8214
8243
  }
8215
8244
  function to(r) {
@@ -8412,7 +8441,7 @@ function co(r) {
8412
8441
  }
8413
8442
  function lt(r) {
8414
8443
  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">${L(r.headerSubtitle)}</p>` : "", n = r.subtitle ? `<p class="__crossx-pin6-subtitle">${L(r.subtitle)}</p>` : "", o = r.errorMessage ? `<p class="__crossx-pin6-error" id="__crossx-pin6-error">${L(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">
8415
- ${Us}
8444
+ ${Hs}
8416
8445
  <span id="__crossx-pin6-lock-countdown"></span>
8417
8446
  </p>` : "", a = r.warningMessage && r.attemptCount != null && r.attemptCount > 0 ? `<p class="__crossx-pin6-warning" id="__crossx-pin6-warning">${L(r.warningMessage)}</p>` : '<p class="__crossx-pin6-warning" id="__crossx-pin6-warning"></p>', c = r.attemptCount != null && r.attemptCount > 0 ? `<p class="__crossx-pin6-attempt" id="__crossx-pin6-attempt">${r.attemptCount}/${r.maxAttempts ?? "?"}</p>` : '<p class="__crossx-pin6-attempt" id="__crossx-pin6-attempt"></p>', l = e ? " --locked" : "", u = Array.from(
8418
8447
  { length: 6 },
@@ -8516,7 +8545,7 @@ function dt(r, e, s, t, n, o, i) {
8516
8545
  I ? I.insertAdjacentElement("afterend", y) : (v = b()) == null || v.appendChild(y);
8517
8546
  }
8518
8547
  y.textContent = w;
8519
- }, X = () => {
8548
+ }, J = () => {
8520
8549
  const w = Z();
8521
8550
  w && (w.textContent = "");
8522
8551
  }, Q = (w, y) => {
@@ -8549,7 +8578,7 @@ function dt(r, e, s, t, n, o, i) {
8549
8578
  const y = f();
8550
8579
  if (y && (y.textContent = "Too many failed attempts. Please wait."), !_()) {
8551
8580
  const B = document.createElement("p");
8552
- B.className = "__crossx-pin6-lock-msg", B.id = "__crossx-pin6-lock-msg", B.innerHTML = `${Us}<span id="__crossx-pin6-lock-countdown"></span>`;
8581
+ B.className = "__crossx-pin6-lock-msg", B.id = "__crossx-pin6-lock-msg", B.innerHTML = `${Hs}<span id="__crossx-pin6-lock-countdown"></span>`;
8553
8582
  const N = f();
8554
8583
  N ? N.insertAdjacentElement("afterend", B) : (H = b()) == null || H.appendChild(B);
8555
8584
  }
@@ -8557,8 +8586,8 @@ function dt(r, e, s, t, n, o, i) {
8557
8586
  var G;
8558
8587
  const B = w - Date.now(), N = p();
8559
8588
  B <= 0 ? (clearInterval(I), F(!1), (G = _()) == null || G.remove(), y && (y.textContent = ""), k(), setTimeout(() => {
8560
- var j;
8561
- return (j = l()[0]) == null ? void 0 : j.focus();
8589
+ var X;
8590
+ return (X = l()[0]) == null ? void 0 : X.focus();
8562
8591
  }, 50)) : N && (N.textContent = ` ${uo(B)}`);
8563
8592
  }, I = setInterval(v, 1e3);
8564
8593
  v();
@@ -8576,7 +8605,7 @@ function dt(r, e, s, t, n, o, i) {
8576
8605
  try {
8577
8606
  if (n) {
8578
8607
  const y = await n(w);
8579
- y.ok ? e(w) : y.lockExpiresAt ? (U(), $(y.lockExpiresAt)) : (C(y.error ?? "Incorrect PIN. Please try again."), y.attemptCount != null && y.maxAttempts != null ? (W(q()), Q(y.attemptCount, y.maxAttempts)) : (X(), U()));
8608
+ y.ok ? e(w) : y.lockExpiresAt ? (U(), $(y.lockExpiresAt)) : (C(y.error ?? "Incorrect PIN. Please try again."), y.attemptCount != null && y.maxAttempts != null ? (W(q()), Q(y.attemptCount, y.maxAttempts)) : (J(), U()));
8580
8609
  } else
8581
8610
  e(w);
8582
8611
  } catch (y) {
@@ -8643,7 +8672,7 @@ function dt(r, e, s, t, n, o, i) {
8643
8672
  const R = I.dataset.key;
8644
8673
  if (!R) return;
8645
8674
  if (R === "backspace") {
8646
- const G = [...l()].reverse().find((j) => j.value);
8675
+ const G = [...l()].reverse().find((X) => X.value);
8647
8676
  G && (G.value = "", K()), A();
8648
8677
  return;
8649
8678
  }
@@ -8664,7 +8693,7 @@ const ho = `<svg width="22" height="17" viewBox="0 0 22 17" fill="none" xmlns="h
8664
8693
  <path d="M7.36 0.5H19.5C20.6046 0.5 21.5 1.39543 21.5 2.5V14.5C21.5 15.6046 20.6046 16.5 19.5 16.5H7.36C6.76 16.5 6.19 16.24 5.8 15.79L0.94 10.02C0.35 9.32 0.35 8.3 0.94 7.6L5.8 1.71C6.19 1.26 6.76 0.5 7.36 0.5Z" stroke="currentColor" stroke-width="1.2" fill="none"/>
8665
8694
  <line x1="10" y1="5.5" x2="16" y2="11.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
8666
8695
  <line x1="16" y1="5.5" x2="10" y2="11.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
8667
- </svg>`, Us = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
8696
+ </svg>`, Hs = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
8668
8697
  <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"/>
8669
8698
  </svg>`, po = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
8670
8699
  <path d="M1 4.5L4 7.5L10 1" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
@@ -8932,7 +8961,7 @@ class xo {
8932
8961
  if (M.has(C)) return;
8933
8962
  const $ = U.querySelector(`#__crossx-notice-check-${C}`);
8934
8963
  M.add(C), $.classList.add("--checked"), U.setAttribute("aria-checked", "true"), Z();
8935
- }, X = (U, C) => {
8964
+ }, J = (U, C) => {
8936
8965
  if (!M.has(C)) return;
8937
8966
  const $ = U.querySelector(`#__crossx-notice-check-${C}`);
8938
8967
  M.delete(C), $.classList.remove("--checked"), U.setAttribute("aria-checked", "false"), Z();
@@ -8940,9 +8969,9 @@ class xo {
8940
8969
  k.forEach((U) => {
8941
8970
  const C = parseInt(U.dataset.checkIndex ?? "0", 10);
8942
8971
  U.addEventListener("click", () => {
8943
- M.has(C) ? X(U, C) : W(U, C);
8972
+ M.has(C) ? J(U, C) : W(U, C);
8944
8973
  }), U.addEventListener("keydown", ($) => {
8945
- ($.key === " " || $.key === "Enter") && ($.preventDefault(), M.has(C) ? X(U, C) : W(U, C));
8974
+ ($.key === " " || $.key === "Enter") && ($.preventDefault(), M.has(C) ? J(U, C) : W(U, C));
8946
8975
  });
8947
8976
  }), F.addEventListener("click", () => {
8948
8977
  if (M.size === k.length) {
@@ -9185,9 +9214,9 @@ function Io(r, e) {
9185
9214
  "refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
9186
9215
  "IndexedDB를 지원하는 브라우저 사용을 권장합니다."
9187
9216
  ), t.secureStorageAvailable = o;
9188
- const i = o ? new Bt(r.projectId) : new hr(), a = new bn(), c = new In(), l = new Ie(), u = new go(), f = new is();
9217
+ const i = o ? new Bt(r.projectId) : new pr(), a = new Sn(), c = new An(), l = new Ie(), u = new go(), f = new is();
9189
9218
  let _;
9190
- r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), _ = new Tn(i, f)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), _ = new Ae(
9219
+ r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), _ = new kn(i, f)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), _ = new Ae(
9191
9220
  n,
9192
9221
  i,
9193
9222
  c,
@@ -9267,9 +9296,9 @@ function bo(r) {
9267
9296
  throw new Error("Deeplink data에 accessToken 필드가 없습니다");
9268
9297
  }
9269
9298
  export {
9270
- zs as CONNECT_OTHER_WALLET_DISPLAY_ORDER,
9299
+ Vs as CONNECT_OTHER_WALLET_DISPLAY_ORDER,
9271
9300
  x as CROSSxError,
9272
- Js as CROSSxEthereumProvider,
9301
+ Zs as CROSSxEthereumProvider,
9273
9302
  ht as CROSSxSDK,
9274
9303
  Eo as ChainId,
9275
9304
  Ue as ConnectOtherWalletItem,
@@ -9277,6 +9306,6 @@ export {
9277
9306
  is as PinMemoryStore,
9278
9307
  go as TokenMemoryStore,
9279
9308
  Io as createCROSSxSDK,
9280
- Vs as getConnectOtherWalletLabel,
9309
+ js as getConnectOtherWalletLabel,
9281
9310
  Ao as parseOAuthDeeplink
9282
9311
  };