@nexus-cross/crossx-sdk-core 1.3.9 → 1.3.10

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,8 +1,8 @@
1
- var Ls = Object.defineProperty;
2
- var Ds = (r, e, s) => e in r ? Ls(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
- var E = (r, e, s) => Ds(r, typeof e != "symbol" ? e + "" : e, s);
4
- import { createRemoteJWKSet as Ms, jwtVerify as $s, decodeJwt as Bs } from "jose";
5
- var p = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.ALREADY_AUTHENTICATED = "ALREADY_AUTHENTICATED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.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.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(p || {});
1
+ var Ms = Object.defineProperty;
2
+ var $s = (r, e, s) => e in r ? Ms(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
+ var T = (r, e, s) => $s(r, typeof e != "symbol" ? e + "" : e, s);
4
+ import { createRemoteJWKSet as Bs, jwtVerify as Us, decodeJwt as Hs } from "jose";
5
+ var p = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.ALREADY_AUTHENTICATED = "ALREADY_AUTHENTICATED", r.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.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(p || {});
6
6
  class m extends Error {
7
7
  constructor(e, s, t) {
8
8
  super(s), this.code = e, this.details = t, this.name = "CROSSxError", Object.setPrototypeOf(this, m.prototype);
@@ -16,7 +16,7 @@ class m extends Error {
16
16
  };
17
17
  }
18
18
  }
19
- const Ve = {
19
+ const ze = {
20
20
  // ─── CROSS ────────────────────────────────────────────
21
21
  CROSS_MAINNET: {
22
22
  caipId: "eip155:612055",
@@ -65,20 +65,20 @@ const Ve = {
65
65
  rpcUrl: "https://saigon-testnet.roninchain.com/rpc",
66
66
  testnet: !0
67
67
  }
68
- }, io = Object.fromEntries(
69
- Object.entries(Ve).map(([r, e]) => [r, e.caipId])
70
- ), Us = new Map(
71
- Object.values(Ve).map((r) => [r.caipId, r])
68
+ }, co = Object.fromEntries(
69
+ Object.entries(ze).map(([r, e]) => [r, e.caipId])
70
+ ), Fs = new Map(
71
+ Object.values(ze).map((r) => [r.caipId, r])
72
72
  );
73
73
  new Map(
74
- Object.values(Ve).map((r) => [r.chainId, r])
74
+ Object.values(ze).map((r) => [r.chainId, r])
75
75
  );
76
- const Hs = { symbol: "", decimals: 18 };
76
+ const Gs = { symbol: "", decimals: 18 };
77
77
  function Je(r) {
78
78
  var e;
79
- return ((e = Us.get(r)) == null ? void 0 : e.nativeCurrency) ?? Hs;
79
+ return ((e = Fs.get(r)) == null ? void 0 : e.nativeCurrency) ?? Gs;
80
80
  }
81
- class Fs {
81
+ class Ws {
82
82
  constructor(e, s) {
83
83
  this.sdk = e, this.chainId = s, this._listeners = /* @__PURE__ */ new Map();
84
84
  }
@@ -168,7 +168,7 @@ class Fs {
168
168
  }
169
169
  }
170
170
  let _e = null;
171
- function St(r) {
171
+ function Et(r) {
172
172
  _e = r;
173
173
  }
174
174
  const d = {
@@ -198,7 +198,7 @@ const d = {
198
198
  return;
199
199
  }
200
200
  }
201
- }, Gs = {
201
+ }, qs = {
202
202
  // ── 공통 버튼 ────────────────────────────────────────────────
203
203
  confirm: "확인",
204
204
  cancel: "취소",
@@ -265,8 +265,18 @@ const d = {
265
265
  // ── PIN 잠금 안내 ─────────────────────────────────────────────
266
266
  pinLocked_message: "잠금이 해제된 후 다시 시도해 주세요.",
267
267
  pinLocked_availableFrom: "이용 가능 시간",
268
- alert_sessionExpired: "인증이 만료되었습니다. 확인을 누른 다시 로그인해 주세요."
269
- }, Qt = {
268
+ pinLocked_failureWarning: "PIN이 올바르지 않습니다. 추가 실패 계정이 잠금됩니다.",
269
+ pinLocked_permanent: "너무 많은 시도 실패로 계정이 영구 잠금되었습니다.",
270
+ alert_sessionExpired: "인증이 만료되었습니다. 확인을 누른 뒤 다시 로그인해 주세요.",
271
+ alert_accountWithdrawn: "계정이 탈퇴 처리되었거나 더 이상 사용할 수 없습니다. 확인 후 다시 로그인해 주세요.",
272
+ alert_walletNotFound: "지갑 정보를 찾을 수 없습니다. 확인 후 다시 로그인해 주세요.",
273
+ alert_differentAccount: `이전에 사용하던 계정이 아닌 다른 계정으로 로그인되었습니다.
274
+
275
+ 보안을 위해 동일한 Google/Apple 계정으로만 이어서 사용할 수 있습니다.
276
+
277
+ [확인] 이전과 같은 계정으로 다시 로그인 시도
278
+ [취소] 로그아웃하고 닫기`
279
+ }, ts = {
270
280
  // ── Common buttons ───────────────────────────────────────────
271
281
  confirm: "Confirm",
272
282
  cancel: "Cancel",
@@ -333,16 +343,26 @@ const d = {
333
343
  // ── PIN lock message ─────────────────────────────────────────
334
344
  pinLocked_message: "Please try again after the lock expires.",
335
345
  pinLocked_availableFrom: "Available from",
336
- alert_sessionExpired: "Your session has expired. Tap OK and sign in again."
337
- }, Ws = {
338
- ko: Gs,
339
- en: Qt
346
+ pinLocked_failureWarning: "Incorrect PIN. Your account will be locked after further failures.",
347
+ pinLocked_permanent: "Your account has been permanently locked due to too many failed attempts.",
348
+ alert_sessionExpired: "Your session has expired. Tap OK and sign in again.",
349
+ alert_accountWithdrawn: "This account is no longer available or has been withdrawn. Tap OK and sign in again.",
350
+ alert_walletNotFound: "Wallet data could not be found. Tap OK and sign in again.",
351
+ alert_differentAccount: `You signed in with a different Google/Apple account than before.
352
+
353
+ For security, you must continue with the same account.
354
+
355
+ OK → Try signing in again with the correct account
356
+ Cancel → Sign out and close`
357
+ }, Ks = {
358
+ ko: qs,
359
+ en: ts
340
360
  };
341
- function Xe(r = "en", e) {
342
- return Ws[r] ?? Qt;
361
+ function ve(r = "en", e) {
362
+ return Ks[r] ?? ts;
343
363
  }
344
- const Et = "crossx_access_token", It = "crossx_refresh_token", Tt = "crossx_user_info";
345
- class qs {
364
+ const It = "crossx_access_token", At = "crossx_refresh_token", Tt = "crossx_user_info";
365
+ class Vs {
346
366
  constructor(e, s, t, n, o, i, a) {
347
367
  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;
348
368
  const c = e.projectId;
@@ -384,10 +404,12 @@ class qs {
384
404
  expectedOrigin: new URL(o).origin
385
405
  }), d.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", s.length, ")");
386
406
  } catch (t) {
387
- return d.error("[CROSSx] SignIn 에러 (OAuth 단계):", t), {
388
- success: !1,
389
- error: t instanceof Error ? t.message : "Sign in failed"
390
- };
407
+ d.error("[CROSSx] SignIn 에러 (OAuth 단계):", t);
408
+ const n = t instanceof Error ? t.message : "Sign in failed";
409
+ throw /팝업|popup/i.test(n) ? new m(
410
+ p.OAUTH_POPUP_BLOCKED,
411
+ n
412
+ ) : new m(p.AUTH_FAILED, n);
391
413
  }
392
414
  return this.processFirebaseToken(s);
393
415
  }
@@ -416,18 +438,18 @@ class qs {
416
438
  try {
417
439
  const w = this.crypto.decodeJWT(e);
418
440
  _ = (n = w.firebase) == null ? void 0 : n.sign_in_provider;
419
- const b = ((o = w.firebase) == null ? void 0 : o.identities) ?? {};
420
- _ === "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);
441
+ const E = ((o = w.firebase) == null ? void 0 : o.identities) ?? {};
442
+ _ === "google.com" ? h = (i = E["google.com"]) == null ? void 0 : i[0] : _ === "apple.com" && (h = (a = E["apple.com"]) == null ? void 0 : a[0]), d.log("[CROSSx] OAuth provider sub 추출 — provider:", _, "hasProviderSub:", !!h);
421
443
  } catch {
422
444
  d.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
423
445
  }
424
446
  if (l) {
425
447
  const w = this.crypto.decodeJWT(l);
426
448
  d.log("[CROSSx] access_token 디코딩 — sub:", w.sub, "exp:", w.exp);
427
- const b = await this.crypto.verifyJWT(l);
428
- if (t = b.signatureVerified ?? !1, !b.valid)
449
+ const E = await this.crypto.verifyJWT(l);
450
+ if (t = E.signatureVerified ?? !1, !E.valid)
429
451
  throw d.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
430
- const y = b.payload;
452
+ const y = E.payload;
431
453
  s = {
432
454
  id: y.sub,
433
455
  email: y.email,
@@ -678,10 +700,10 @@ class qs {
678
700
  const e = await this.storage.get(Tt);
679
701
  if (!e || await this.storage.get(this.STORAGE_KEY_USER)) return;
680
702
  await this.storage.set(this.STORAGE_KEY_USER, e);
681
- const t = await this.storage.get(Et);
703
+ const t = await this.storage.get(It);
682
704
  t && await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, t);
683
- const n = await this.storage.get(It);
684
- 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 스코프)");
705
+ const n = await this.storage.get(At);
706
+ n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(Tt), await this.storage.remove(It), await this.storage.remove(At), d.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
685
707
  } catch (e) {
686
708
  d.warn("[CROSSx] 스토리지 키 마이그레이션 실패:", e);
687
709
  }
@@ -716,7 +738,7 @@ class qs {
716
738
  return d.log("[CROSSx] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
717
739
  }
718
740
  }
719
- class Ks {
741
+ class zs {
720
742
  constructor(e, s, t) {
721
743
  this.config = e, this.storage = s, this.tokenStore = t;
722
744
  const n = e.projectId;
@@ -726,7 +748,7 @@ class Ks {
726
748
  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();
727
749
  }
728
750
  }
729
- class Vs {
751
+ class js {
730
752
  constructor(e, s) {
731
753
  this.storage = e, this.walletProvider = s;
732
754
  }
@@ -743,7 +765,7 @@ class Vs {
743
765
  };
744
766
  }
745
767
  }
746
- class es {
768
+ class ss {
747
769
  constructor() {
748
770
  this.encryptedBytes = null, this.xorKey = null;
749
771
  }
@@ -784,7 +806,7 @@ class es {
784
806
  return this.encryptedBytes !== null;
785
807
  }
786
808
  }
787
- class zs {
809
+ class Ys {
788
810
  constructor(e, s) {
789
811
  this.chainRegistry = e, this.transport = s, this._nextId = 1;
790
812
  }
@@ -816,7 +838,7 @@ class zs {
816
838
  return a == null ? void 0 : a.result;
817
839
  }
818
840
  }
819
- class js {
841
+ class Xs {
820
842
  constructor() {
821
843
  this.listeners = /* @__PURE__ */ new Map();
822
844
  }
@@ -839,7 +861,7 @@ class js {
839
861
  this.listeners.clear();
840
862
  }
841
863
  }
842
- const Ge = {
864
+ const We = {
843
865
  // TODO(v2.0.0-BEFORE-RELEASE): 아래 블록으로 교체
844
866
  // production: {
845
867
  // oauthServiceUrl: 'https://cross-wallet-oauth.crosstoken.io',
@@ -862,24 +884,24 @@ const Ge = {
862
884
  walletGatewayUrl: "https://dev-embedded-wallet-gateway.crosstoken.io/api/v1"
863
885
  }
864
886
  };
865
- function Ys(r) {
887
+ function Js(r) {
866
888
  const e = r.environment;
867
- return e && e in Ge ? Ge[e] : null;
889
+ return e && e in We ? We[e] : null;
868
890
  }
869
- function Js() {
891
+ function Zs() {
870
892
  try {
871
893
  if (typeof __CROSSX_CONFIG__ < "u") {
872
- const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e = Ys(r);
894
+ const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e = Js(r);
873
895
  if (e) return e;
874
896
  }
875
897
  } catch {
876
898
  }
877
- return Ge.production;
899
+ return We.production;
878
900
  }
879
- 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 {
901
+ const Qs = 2e3, Rt = 6e4, er = 1e3, tr = 1e4, sr = "0x77359400", kt = "0x3B9ACA00", Pt = 130, Ot = 6, Ct = 18, Nt = 3e4, rr = 5 * 60 * 1e3, nr = 30 * 1e3, ee = class ee extends Xs {
880
902
  constructor(e, s, t, n, o, i, a, c, l, u, h) {
881
903
  var _, f;
882
- 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 && St(e.logger), this.confirmation = l, this.pinStore = h ?? new es(), this.chainRegistry = u, this.jsonRpc = new zs(u, o), this.signInUseCase = new qs(
904
+ 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 && Et(e.logger), this.confirmation = l, this.pinStore = h ?? new ss(), this.chainRegistry = u, this.jsonRpc = new Ys(u, o), this.signInUseCase = new Vs(
883
905
  this.internalConfig,
884
906
  t,
885
907
  n,
@@ -887,7 +909,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
887
909
  o,
888
910
  a,
889
911
  c
890
- ), 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(
912
+ ), this.signOutUseCase = new zs(this.internalConfig, t, c), this.migrateWalletUseCase = new js(t, a), (_ = a.setOnUnauthorized) == null || _.call(a, () => this.forceLogout()), (f = a.setTokenRefresher) == null || f.call(
891
913
  a,
892
914
  () => this.signInUseCase.refreshAccessToken()
893
915
  ), e.autoDetectTheme && this._setupAutoDetectTheme();
@@ -916,9 +938,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
916
938
  }
917
939
  async _doInitialize(e) {
918
940
  var s, t;
919
- d.log("[CROSSx SDK] v1.3.9 초기화 중..."), this.confirmation.setMessages(Xe(this._config.locale));
941
+ d.log("[CROSSx SDK] v1.3.10 초기화 중..."), this.confirmation.setMessages(ve(this._config.locale));
920
942
  try {
921
- const n = Js();
943
+ const n = Zs();
922
944
  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`);
923
945
  const o = await this.signInUseCase.restoreSession();
924
946
  if (o != null && o.success) {
@@ -931,7 +953,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
931
953
  d.log("[CROSSx] initialize: 비밀번호 입력 취소 — 지갑 미로드 상태로 계속");
932
954
  }
933
955
  }
934
- return this.initialized = !0, d.info("[CROSSx SDK] v1.3.9 초기화 완료"), this.emit("initialized", { restored: !!(o != null && o.success) }), o ?? null;
956
+ return this.initialized = !0, d.info("[CROSSx SDK] v1.3.10 초기화 완료"), this.emit("initialized", { restored: !!(o != null && o.success) }), o ?? null;
935
957
  } catch (n) {
936
958
  throw new m(p.AUTH_NOT_INITIALIZED, "SDK 초기화에 실패했습니다", n);
937
959
  }
@@ -960,7 +982,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
960
982
  const t = await this.signInUseCase.execute(s);
961
983
  return t.success && this.applyAuthResult(t), t;
962
984
  } catch (t) {
963
- throw new m(p.AUTH_FAILED, "로그인에 실패했습니다", t);
985
+ throw t instanceof m ? t : new m(p.AUTH_FAILED, "로그인에 실패했습니다", t);
964
986
  }
965
987
  }
966
988
  /**
@@ -1207,7 +1229,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1207
1229
  */
1208
1230
  async getAddresses() {
1209
1231
  if (this.ensureAuthenticated(), !this.userId) return [];
1210
- const e = await this.walletProvider.getAddresses(this.userId);
1232
+ const e = await this.withSessionRecovery(
1233
+ () => this.walletProvider.getAddresses(this.userId)
1234
+ );
1211
1235
  return e.length === 0 && this.address ? [{ address: this.address, index: 0 }] : e;
1212
1236
  }
1213
1237
  /**
@@ -1232,14 +1256,18 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1232
1256
  async selectWallet(e) {
1233
1257
  if (this.ensureAuthenticated(), !this.userId)
1234
1258
  throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
1235
- let s = await this.walletProvider.getAddresses(this.userId);
1259
+ let s = await this.withSessionRecovery(
1260
+ () => this.walletProvider.getAddresses(this.userId)
1261
+ );
1236
1262
  s.length === 0 && this.address && (s = [{ address: this.address, index: 0 }]);
1237
1263
  const t = await this.confirmation.showWalletSelector(
1238
1264
  s,
1239
1265
  async () => {
1240
1266
  await this.ensurePinForSigning();
1241
1267
  const n = s.length, i = { address: (await this.withPinRetry(
1242
- () => this.walletProvider.getAddress(this.userId, n)
1268
+ () => this.withSessionRecovery(
1269
+ () => this.walletProvider.getAddress(this.userId, n)
1270
+ )
1243
1271
  )).address, index: n };
1244
1272
  return s.push(i), i;
1245
1273
  },
@@ -1339,7 +1367,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1339
1367
  * sdk.applyLocale('ko');
1340
1368
  */
1341
1369
  applyLocale(e = this._config.locale ?? "en") {
1342
- this._config = Object.freeze({ ...this._config, locale: e }), this.confirmation.setMessages(Xe(e));
1370
+ this._config = Object.freeze({ ...this._config, locale: e }), this.confirmation.setMessages(ve(e));
1343
1371
  }
1344
1372
  /**
1345
1373
  * 지갑 생성/로드 (로그인 후 address가 없는 경우)
@@ -1348,6 +1376,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1348
1376
  * - migration_required: 마이그레이션 플로우 실행
1349
1377
  */
1350
1378
  async createWallet() {
1379
+ return this.withSessionRecovery(() => this._createWallet());
1380
+ }
1381
+ async _createWallet() {
1351
1382
  if (this.ensureAuthenticated(), !this.userId)
1352
1383
  throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
1353
1384
  d.log("[CROSSx] createWallet 시작");
@@ -1425,6 +1456,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1425
1456
  * @todo 백엔드 메시지 서명 전용 엔드포인트 추가 후 구현
1426
1457
  */
1427
1458
  async signMessage(e, s, t) {
1459
+ return this.withSessionRecovery(() => this._signMessage(e, s, t));
1460
+ }
1461
+ async _signMessage(e, s, t) {
1428
1462
  if (this.ensureAuthenticated(), !this.userId)
1429
1463
  throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
1430
1464
  const n = await this.resolveAddress(t == null ? void 0 : t.index);
@@ -1481,11 +1515,14 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1481
1515
  * });
1482
1516
  */
1483
1517
  async signTypedData(e, s, t) {
1518
+ return this.withSessionRecovery(() => this._signTypedData(e, s, t));
1519
+ }
1520
+ async _signTypedData(e, s, t) {
1484
1521
  if (this.ensureAuthenticated(), !this.userId)
1485
1522
  throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
1486
1523
  if (!this.walletProvider.signTypedData)
1487
1524
  throw new m(p.NOT_IMPLEMENTED, "signTypedData가 구현되어 있지 않습니다");
1488
- re.validateTypedDataChainId(e, s);
1525
+ ee.validateTypedDataChainId(e, s);
1489
1526
  const n = await this.resolveAddress(t == null ? void 0 : t.index);
1490
1527
  if (!await this.confirmation.requestConfirmation({
1491
1528
  type: "sign-typed-data",
@@ -1508,7 +1545,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1508
1545
  n.address
1509
1546
  );
1510
1547
  });
1511
- return re.validateSignatureFormat(i.signature), {
1548
+ return ee.validateSignatureFormat(i.signature), {
1512
1549
  chainId: e,
1513
1550
  signature: i.signature,
1514
1551
  address: n.address
@@ -1537,7 +1574,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1537
1574
  * });
1538
1575
  */
1539
1576
  async signTypedDataOffchain(e, s) {
1540
- return this.signTypedData(re.OFFCHAIN_CHAIN_ID, e, s);
1577
+ return this.signTypedData(ee.OFFCHAIN_CHAIN_ID, e, s);
1541
1578
  }
1542
1579
  // ============================================================================
1543
1580
  // 트랜잭션
@@ -1549,6 +1586,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1549
1586
  * @param opts 서명 옵션 (index, dappName, accountName)
1550
1587
  */
1551
1588
  async signTransaction(e, s, t) {
1589
+ return this.withSessionRecovery(() => this._signTransaction(e, s, t));
1590
+ }
1591
+ async _signTransaction(e, s, t) {
1552
1592
  if (this.ensureAuthenticated(), !this.userId)
1553
1593
  throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
1554
1594
  const n = await this.withResolvedGasAndFee(s, e);
@@ -1582,7 +1622,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1582
1622
  c
1583
1623
  );
1584
1624
  });
1585
- return re.validateSignedTxFormat(a.signature), {
1625
+ return ee.validateSignedTxFormat(a.signature), {
1586
1626
  chainId: e,
1587
1627
  signedTx: a.signature,
1588
1628
  txHash: a.txHash ?? ""
@@ -1604,6 +1644,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1604
1644
  * @param opts 서명 옵션 (index, dappName, accountName)
1605
1645
  */
1606
1646
  async sendTransaction(e, s, t) {
1647
+ return this.withSessionRecovery(() => this._sendTransaction(e, s, t));
1648
+ }
1649
+ async _sendTransaction(e, s, t) {
1607
1650
  if (this.ensureAuthenticated(), !this.userId)
1608
1651
  throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
1609
1652
  const n = await this.withResolvedGasAndFee(s, e);
@@ -1675,7 +1718,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1675
1718
  * @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
1676
1719
  */
1677
1720
  async waitForTxAndGetReceipt(e, s, t = {}) {
1678
- const n = t.intervalMs ?? Zs, o = Qs, i = t.timeoutMs ?? At, a = Date.now() + i;
1721
+ const n = t.intervalMs ?? er, o = tr, i = t.timeoutMs ?? Rt, a = Date.now() + i;
1679
1722
  let c = n;
1680
1723
  for (; Date.now() < a; ) {
1681
1724
  const l = await this.getTransactionReceipt(e, s);
@@ -1703,29 +1746,29 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1703
1746
  * logger.log(receipt.status); // '0x1' | '0x0'
1704
1747
  */
1705
1748
  async sendTransactionWithWaitForReceipt(e, s, t = {}) {
1706
- var b, y;
1707
- 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 ?? "";
1749
+ var E, y;
1750
+ 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) ?? Qs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? Rt, u = Je(e), h = s.from ?? "";
1708
1751
  let _, f;
1709
- const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((T) => {
1710
- _ = T;
1711
- 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);
1752
+ const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((R) => {
1753
+ _ = R;
1754
+ const N = BigInt(R.gasUsed) * BigInt(R.effectiveGasPrice), F = s.value ? BigInt(s.value) : 0n, M = ee.formatTxAmount(s.value, u.symbol, u.decimals), V = ee.formatTxAmount("0x" + N.toString(16), u.symbol, u.decimals), G = ee.formatTxAmount("0x" + (F + N).toString(16), u.symbol, u.decimals);
1712
1755
  return {
1713
1756
  chainId: e,
1714
1757
  txHash: a,
1715
- from: T.from,
1716
- to: T.to ?? s.to,
1717
- amount: B,
1718
- fees: j,
1719
- total: q,
1758
+ from: R.from,
1759
+ to: R.to ?? s.to,
1760
+ amount: M,
1761
+ fees: V,
1762
+ total: G,
1720
1763
  nativeSymbol: u.symbol,
1721
- status: T.status === "0x1" ? "success" : "reverted"
1764
+ status: R.status === "0x1" ? "success" : "reverted"
1722
1765
  };
1723
- }).catch((T) => (f = T instanceof Error ? T : new Error(String(T)), {
1766
+ }).catch((R) => (f = R instanceof Error ? R : new Error(String(R)), {
1724
1767
  chainId: e,
1725
1768
  txHash: a,
1726
1769
  from: h,
1727
1770
  to: s.to,
1728
- amount: re.formatTxAmount(s.value, u.symbol, u.decimals),
1771
+ amount: ee.formatTxAmount(s.value, u.symbol, u.decimals),
1729
1772
  nativeSymbol: u.symbol,
1730
1773
  status: "timeout"
1731
1774
  }));
@@ -1903,7 +1946,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1903
1946
  return { wei: "0x0", formatted: "0", chainId: e };
1904
1947
  try {
1905
1948
  const n = await this.jsonRpc.call("eth_getBalance", [s, "latest"], e) ?? "0x0";
1906
- return { wei: n, formatted: re.formatWei(n), chainId: e };
1949
+ return { wei: n, formatted: ee.formatWei(n), chainId: e };
1907
1950
  } catch (t) {
1908
1951
  if (t instanceof m) throw t;
1909
1952
  const n = t instanceof Error ? t.message : String(t);
@@ -1915,7 +1958,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1915
1958
  try {
1916
1959
  const s = BigInt(e);
1917
1960
  if (s === 0n) return "0";
1918
- const t = 10n ** BigInt(Ot), n = s / t, i = (s % t).toString().padStart(Ot, "0").replace(/0+$/, "").slice(0, Pt);
1961
+ const t = 10n ** BigInt(Ct), n = s / t, i = (s % t).toString().padStart(Ct, "0").replace(/0+$/, "").slice(0, Ot);
1919
1962
  return i ? `${n}.${i}` : `${n}`;
1920
1963
  } catch {
1921
1964
  return "?";
@@ -1940,7 +1983,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1940
1983
  * const client = createWalletClient({ transport: custom(provider) });
1941
1984
  */
1942
1985
  getProvider(e) {
1943
- return this.ensureAuthenticated(), new Fs(this, e);
1986
+ return this.ensureAuthenticated(), new Ws(this, e);
1944
1987
  }
1945
1988
  /**
1946
1989
  * 범용 JSON-RPC 요청 — 노드에 직접 연결.
@@ -1974,7 +2017,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1974
2017
  try {
1975
2018
  const n = BigInt(e);
1976
2019
  if (n === 0n) return;
1977
- const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0, Pt).replace(/0+$/, "");
2020
+ const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0, Ot).replace(/0+$/, "");
1978
2021
  return `${c ? `${i}.${c}` : `${i}`} ${s}`;
1979
2022
  } catch {
1980
2023
  return;
@@ -2019,8 +2062,8 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2019
2062
  }
2020
2063
  const f = _.pinStatus;
2021
2064
  if (i = f.maxAttempts, o = i - f.remainingAttempts, f.remainingAttempts === 0 && f.lockExpiresAt) {
2022
- 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.";
2023
- 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.";
2065
+ const w = f.lockExpiresAt * 1e3, E = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = E <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
2066
+ d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${E}초, 메시지: ${y}`), await this.confirmation.showRecoveryPinLockedPrompt(E, y), o = 0, n = "Your account lock has been lifted. You may try again.";
2024
2067
  } else
2025
2068
  d.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 ${o}/${i})`), n = "Incorrect PIN.";
2026
2069
  } catch (_) {
@@ -2029,8 +2072,8 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2029
2072
  const f = _.details;
2030
2073
  if (i = (f == null ? void 0 : f.maxAttempts) ?? 5, (f == null ? void 0 : f.permanent) === !0)
2031
2074
  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;
2032
- 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.";
2033
- 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.";
2075
+ const w = ((f == null ? void 0 : f.lockExpiresAt) ?? 0) * 1e3, E = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = E <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
2076
+ d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${E}초`), await this.confirmation.showRecoveryPinLockedPrompt(E, y), o = 0, n = "Your account lock has been lifted. You may try again.";
2034
2077
  } else
2035
2078
  throw d.error("[CROSSx][Migration Phase 4] verify-recovery-pin 실패 (복구 불가):", _), _;
2036
2079
  }
@@ -2071,12 +2114,12 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2071
2114
  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) {
2072
2115
  const f = _;
2073
2116
  if (f) {
2074
- const w = Rt;
2117
+ const w = kt;
2075
2118
  c.maxFeePerGas = "0x" + (BigInt(f) + BigInt(w)).toString(16), c.maxPriorityFeePerGas = w, d.log("[CROSSx] Dynamic 체인 감지 — baseFee:", f, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
2076
2119
  } else
2077
- c.gasPrice = er, d.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
2120
+ c.gasPrice = sr, d.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
2078
2121
  }
2079
- return !i && a && (c.maxPriorityFeePerGas = Rt, d.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
2122
+ return !i && a && (c.maxPriorityFeePerGas = kt, d.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
2080
2123
  }
2081
2124
  /**
2082
2125
  * EIP-712 signTypedData 호출 시 chainId와 typedData.domain.chainId 정합성 검증.
@@ -2085,7 +2128,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2085
2128
  * - chainId가 '0' → domain.chainId가 없거나 0이어야 함
2086
2129
  */
2087
2130
  static validateTypedDataChainId(e, s) {
2088
- const t = re.extractDomainChainId(s);
2131
+ const t = ee.extractDomainChainId(s);
2089
2132
  if (e === "0") {
2090
2133
  if (t !== void 0 && t !== 0)
2091
2134
  throw new m(
@@ -2123,10 +2166,10 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2123
2166
  const s = e.startsWith("0x") ? e.slice(2) : e;
2124
2167
  if (!/^[0-9a-fA-F]+$/.test(s))
2125
2168
  throw new m(p.SIGNATURE_FAILED, "유효하지 않은 서명: 올바른 hex 문자열이 아닙니다");
2126
- if (s.length !== kt)
2169
+ if (s.length !== Pt)
2127
2170
  throw new m(
2128
2171
  p.SIGNATURE_FAILED,
2129
- `서명 길이가 유효하지 않습니다: ${kt} hex 문자(65 바이트) 예상, 현재 ${s.length}`
2172
+ `서명 길이가 유효하지 않습니다: ${Pt} hex 문자(65 바이트) 예상, 현재 ${s.length}`
2130
2173
  );
2131
2174
  }
2132
2175
  /** RLP-encoded signed transaction 형식 검증 */
@@ -2164,7 +2207,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2164
2207
  /** AuthResult를 내부 상태에 반영합니다. */
2165
2208
  applyAuthResult(e) {
2166
2209
  var s, t, n, o;
2167
- 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 = re.normalizeLoginType((o = e.user) == null ? void 0 : o.signInProvider), this.tokenSignatureVerified = e.tokenSignatureVerified ?? !1, this.emit("authChanged", {
2210
+ 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 = ee.normalizeLoginType((o = e.user) == null ? void 0 : o.signInProvider), this.tokenSignatureVerified = e.tokenSignatureVerified ?? !1, this._isRecoveringSession || this.emit("authChanged", {
2168
2211
  isAuthenticated: this.authenticated,
2169
2212
  address: this.address,
2170
2213
  userId: this.userId
@@ -2172,7 +2215,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2172
2215
  }
2173
2216
  /** 인증 상태를 초기화합니다. */
2174
2217
  clearAuthState() {
2175
- 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.emit("authChanged", {
2218
+ 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", {
2176
2219
  isAuthenticated: !1,
2177
2220
  address: null,
2178
2221
  userId: null
@@ -2186,6 +2229,80 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2186
2229
  forceLogout() {
2187
2230
  this.authenticated && (d.warn("[CROSSx] 인증 만료(Gateway -10002) — 강제 로그아웃"), this.clearAuthState());
2188
2231
  }
2232
+ /**
2233
+ * 세션 만료 시 동일 계정으로 재인증합니다.
2234
+ *
2235
+ * OAuth를 다시 열고, 로그인 직전에 보관해 둔 식별자와 비교합니다.
2236
+ * - `providerSub`(Firebase identities의 Google UID / Apple sub)가 있으면 **그 값이 같을 때만** 성공 처리합니다.
2237
+ * - 없으면(레거시) `userId`로 동일 여부를 판단합니다.
2238
+ *
2239
+ * 다른 계정이면 서버 `signOut` 후 `confirm()`으로 안내합니다.
2240
+ * - **확인(OK)**: 같은 계정으로 다시 `signInAgain()` 재시도
2241
+ * - **취소**: 로컬 인증 상태 정리(로그아웃)
2242
+ *
2243
+ * @returns 재인증 성공 시 AuthResult, 실패 시 { success: false }
2244
+ */
2245
+ async signInAgain() {
2246
+ var n, o;
2247
+ this.ensureInitialized();
2248
+ const e = this.providerSub, s = this.userId, t = this.loginType;
2249
+ this._isRecoveringSession = !0;
2250
+ try {
2251
+ this.authenticated = !1, this.tokenStore.clear();
2252
+ const i = t ? { provider: t } : void 0;
2253
+ let a;
2254
+ try {
2255
+ a = await this.signInUseCase.execute(i);
2256
+ } catch (h) {
2257
+ throw this.clearAuthState(), h;
2258
+ }
2259
+ if (!a.success)
2260
+ return this.clearAuthState(), a;
2261
+ const c = ((n = a.user) == null ? void 0 : n.providerSub) ?? null, l = ((o = a.user) == null ? void 0 : o.id) ?? null;
2262
+ if (!(e ? !!c && c === e : s ? !!l && s === l : !0)) {
2263
+ d.warn("[CROSSx] signInAgain: providerSub/userId 불일치 — 잘못된 계정으로 로그인됨"), await this.signOutUseCase.execute().catch(() => {
2264
+ });
2265
+ const h = ve(this._config.locale ?? "en");
2266
+ return (typeof globalThis.confirm == "function" ? globalThis.confirm(h.alert_differentAccount) : !1) ? (this._isRecoveringSession = !1, this.signInAgain()) : (this.clearAuthState(), { success: !1, error: "Different account signed in" });
2267
+ }
2268
+ this.applyAuthResult(a);
2269
+ try {
2270
+ await this.loadWalletAfterAuth();
2271
+ } catch {
2272
+ d.warn("[CROSSx] signInAgain: loadWalletAfterAuth 실패 (로그인은 유지)");
2273
+ }
2274
+ return d.log("[CROSSx] signInAgain: 세션 복구 성공"), a;
2275
+ } finally {
2276
+ this._isRecoveringSession = !1;
2277
+ }
2278
+ }
2279
+ /**
2280
+ * SESSION_EXPIRED 에러 발생 시 자동 재인증 후 재시도합니다.
2281
+ *
2282
+ * @param fn 실행할 비동기 함수
2283
+ * @returns fn의 결과 또는 재시도 후 결과
2284
+ */
2285
+ async withSessionRecovery(e) {
2286
+ try {
2287
+ return await e();
2288
+ } catch (s) {
2289
+ const t = ve(this._config.locale ?? "en");
2290
+ if (s instanceof m && s.code === p.WITHDRAW_FAILED)
2291
+ throw d.warn("[CROSSx] WITHDRAW_FAILED — 로컬 인증 초기화"), typeof globalThis.alert == "function" && globalThis.alert(t.alert_accountWithdrawn), this.clearAuthState(), s;
2292
+ if (s instanceof m && s.code === p.WALLET_NOT_FOUND)
2293
+ throw d.warn("[CROSSx] WALLET_NOT_FOUND — 로컬 인증 초기화"), typeof globalThis.alert == "function" && globalThis.alert(t.alert_walletNotFound), this.clearAuthState(), s;
2294
+ if (!(s instanceof m) || s.code !== p.SESSION_EXPIRED)
2295
+ throw s;
2296
+ d.warn("[CROSSx] SESSION_EXPIRED 감지 — 자동 재인증 시도"), typeof globalThis.alert == "function" && globalThis.alert(t.alert_sessionExpired);
2297
+ const n = await this.signInAgain();
2298
+ if (!n.success)
2299
+ throw new m(
2300
+ p.SESSION_EXPIRED,
2301
+ n.error ?? "세션이 만료되었습니다. 다시 로그인해 주세요."
2302
+ );
2303
+ return e();
2304
+ }
2305
+ }
2189
2306
  /**
2190
2307
  * Firebase sign_in_provider 값을 정규화합니다.
2191
2308
  * 'google.com' → 'google', 'apple.com' → 'apple'
@@ -2227,11 +2344,13 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2227
2344
  *
2228
2345
  * @param initialErrorMessage 모달을 열 때 처음부터 표시할 에러 메시지.
2229
2346
  * @param lockExpiresAt PIN 잠금 만료 시각 (Unix ms). 제공 시 잠금 UI를 표시합니다.
2347
+ * @param attemptCount 현재 시도 횟수 (1~maxAttempts). X/maxAttempts 형태로 표시.
2348
+ * @param maxAttempts 최대 시도 허용 횟수.
2230
2349
  *
2231
2350
  * 뮤텍스: 동시에 여러 곳에서 호출되어도 모달은 하나만 표시됩니다.
2232
2351
  * (initialErrorMessage가 없을 때만 공유, 에러 재시도 시에는 항상 새로 열림)
2233
2352
  */
2234
- async ensureVerifiedPin(e, s) {
2353
+ async ensureVerifiedPin(e, s, t, n) {
2235
2354
  if (e)
2236
2355
  this.pinStore.clear();
2237
2356
  else if (this.pinStore.has())
@@ -2240,57 +2359,87 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2240
2359
  d.log("[CROSSx] ensureVerifiedPin: 진행 중인 검증 대기"), await this._verifyPinMutex;
2241
2360
  return;
2242
2361
  }
2243
- let t, n;
2244
- this._verifyPinMutex = new Promise((o, i) => {
2245
- t = o, n = i;
2362
+ let o, i;
2363
+ this._verifyPinMutex = new Promise((c, l) => {
2364
+ o = c, i = l;
2246
2365
  });
2366
+ const a = ve(this._config.locale ?? "en");
2247
2367
  try {
2248
2368
  if (typeof this.walletProvider.verifyPin != "function") {
2249
- const i = await this.confirmation.showPinInputPrompt({
2369
+ const l = await this.confirmation.showPinInputPrompt({
2250
2370
  verifyMode: !0,
2251
2371
  errorMessage: e,
2252
- lockExpiresAt: s
2372
+ lockExpiresAt: s,
2373
+ attemptCount: t,
2374
+ maxAttempts: n
2253
2375
  });
2254
- if (!i)
2376
+ if (!l)
2255
2377
  throw new m(p.PIN_CANCELLED, "사용자가 PIN 입력을 취소했습니다");
2256
- this.pinStore.set(i), d.log("[CROSSx] PIN 캐시 완료 (verifyPin 미지원, 로컬 전용)"), t();
2378
+ this.pinStore.set(l), d.log("[CROSSx] PIN 캐시 완료 (verifyPin 미지원, 로컬 전용)"), o();
2257
2379
  return;
2258
2380
  }
2259
- const o = await this.confirmation.showPinInputPrompt({
2381
+ const c = await this.confirmation.showPinInputPrompt({
2260
2382
  verifyMode: !0,
2261
2383
  errorMessage: e,
2262
2384
  lockExpiresAt: s,
2263
- onSubmit: async (i) => {
2264
- var a;
2265
- this.pinStore.set(i);
2385
+ attemptCount: t,
2386
+ maxAttempts: n,
2387
+ onSubmit: async (l) => {
2388
+ this.pinStore.set(l);
2266
2389
  try {
2267
- return await this.walletProvider.verifyPin(i) ? (d.log("[CROSSx] PIN 서버 검증 완료 (verify-password)"), { ok: !0 }) : (this.pinStore.clear(), { ok: !1, error: "Incorrect PIN. Please try again." });
2268
- } catch (c) {
2269
- if (this.pinStore.clear(), c instanceof m) {
2270
- if (c.code === p.PIN_WRONG)
2271
- return { ok: !1, error: "Incorrect PIN. Please try again." };
2272
- if (c.code === p.PIN_INVALID)
2273
- return { ok: !1, error: c.message };
2274
- if (c.code === p.PIN_LOCKED)
2275
- return { ok: !1, error: "Too many failed attempts. Your account is temporarily locked.", lockExpiresAt: (a = c.details) == null ? void 0 : a.lockExpiresAt };
2390
+ return await this.walletProvider.verifyPin(l) ? (d.log("[CROSSx] PIN 서버 검증 완료 (verify-password)"), { ok: !0 }) : (this.pinStore.clear(), { ok: !1, error: a.pinInput_error });
2391
+ } catch (u) {
2392
+ if (this.pinStore.clear(), u instanceof m) {
2393
+ if (u.code === p.PIN_WRONG)
2394
+ return { ok: !1, error: a.pinInput_error };
2395
+ if (u.code === p.PIN_INVALID)
2396
+ return { ok: !1, error: u.message };
2397
+ if (u.code === p.PIN_LOCKED)
2398
+ return ee.buildPinLockedResult(u, a);
2276
2399
  }
2277
- throw c;
2400
+ throw u;
2278
2401
  }
2279
2402
  }
2280
2403
  });
2281
- if (!o)
2404
+ if (!c)
2282
2405
  throw new m(p.PIN_CANCELLED, "사용자가 PIN 입력을 취소했습니다");
2283
- this.pinStore.set(o), d.log("[CROSSx] PIN 갱신 완료 (verify 모달 닫힘)"), t();
2284
- } catch (o) {
2285
- if (o instanceof m && (o.code === p.AUTH_NOT_AUTHENTICATED || o.code === p.AUTH_TOKEN_EXPIRED)) {
2286
- const { alert_sessionExpired: i } = Xe(this._config.locale ?? "en");
2287
- typeof globalThis.alert == "function" && globalThis.alert(i);
2406
+ this.pinStore.set(c), d.log("[CROSSx] PIN 갱신 완료 (verify 모달 닫힘)"), o();
2407
+ } catch (c) {
2408
+ if (c instanceof m && (c.code === p.AUTH_NOT_AUTHENTICATED || c.code === p.AUTH_TOKEN_EXPIRED || c.code === p.SESSION_EXPIRED) && c.code !== p.SESSION_EXPIRED) {
2409
+ const { alert_sessionExpired: l } = ve(this._config.locale ?? "en");
2410
+ typeof globalThis.alert == "function" && globalThis.alert(l);
2288
2411
  }
2289
- throw n(o), o;
2412
+ throw i(c), c;
2290
2413
  } finally {
2291
2414
  this._verifyPinMutex = null;
2292
2415
  }
2293
2416
  }
2417
+ /**
2418
+ * PIN_LOCKED 에러에서 잠금 상태를 분석하여 onSubmit 결과를 구성합니다.
2419
+ * iOS의 passwordLocked(PinLockInfo) 분기와 동일한 로직:
2420
+ * - remainingAttempts > 0: 경고 + 시도 횟수
2421
+ * - remainingAttempts == 0: 잠금 + 카운트다운
2422
+ * - permanent: 영구 잠금
2423
+ */
2424
+ static buildPinLockedResult(e, s) {
2425
+ const t = e.details;
2426
+ if (t != null && t.permanent)
2427
+ return { ok: !1, error: s.pinLocked_permanent };
2428
+ if ((t == null ? void 0 : t.remainingAttempts) != null && t.remainingAttempts > 0 && t.maxAttempts) {
2429
+ const n = t.maxAttempts - t.remainingAttempts;
2430
+ return {
2431
+ ok: !1,
2432
+ error: s.pinLocked_failureWarning,
2433
+ attemptCount: n,
2434
+ maxAttempts: t.maxAttempts
2435
+ };
2436
+ }
2437
+ return {
2438
+ ok: !1,
2439
+ error: "Too many failed attempts. Your account is temporarily locked.",
2440
+ lockExpiresAt: t == null ? void 0 : t.lockExpiresAt
2441
+ };
2442
+ }
2294
2443
  /**
2295
2444
  * 세션 복원(refresh) 후 지갑 상태를 확인하고 주소를 로드합니다.
2296
2445
  *
@@ -2326,44 +2475,32 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2326
2475
  * PIN_WRONG이 계속 발생하는 경우(verifyPin 미지원 환경 등) 취소할 때까지 무한 루프.
2327
2476
  */
2328
2477
  async withPinRetry(e) {
2329
- let s, t;
2478
+ const s = ve(this._config.locale ?? "en");
2479
+ let t, n, o, i;
2480
+ const a = (c) => {
2481
+ if (c.code === p.PIN_WRONG)
2482
+ return t = s.pinInput_error, n = void 0, o = void 0, i = void 0, !0;
2483
+ if (c.code === p.PIN_INVALID)
2484
+ return t = c.message, n = void 0, o = void 0, i = void 0, !0;
2485
+ if (c.code === p.PIN_LOCKED) {
2486
+ const l = c.details;
2487
+ return l != null && l.permanent ? (t = s.pinLocked_permanent, n = void 0, o = void 0, i = void 0) : (l == null ? void 0 : l.remainingAttempts) != null && l.remainingAttempts > 0 && l.maxAttempts ? (t = s.pinLocked_failureWarning, n = void 0, o = l.maxAttempts - l.remainingAttempts, i = l.maxAttempts) : (t = "Too many failed attempts. Your account is temporarily locked.", n = l == null ? void 0 : l.lockExpiresAt, o = void 0, i = void 0), !0;
2488
+ }
2489
+ return !1;
2490
+ };
2330
2491
  try {
2331
2492
  return await e();
2332
- } catch (n) {
2333
- if (n instanceof m)
2334
- if (n.code === p.PIN_WRONG)
2335
- s = "Incorrect PIN. Please enter your current PIN.";
2336
- else if (n.code === p.PIN_INVALID)
2337
- s = n.message;
2338
- else if (n.code === p.PIN_LOCKED) {
2339
- const o = n.details;
2340
- t = o == null ? void 0 : o.lockExpiresAt, s = "Too many failed attempts. Your account is temporarily locked.";
2341
- } else
2342
- throw n;
2343
- else
2344
- throw n;
2493
+ } catch (c) {
2494
+ if (!(c instanceof m && a(c))) throw c;
2345
2495
  }
2346
2496
  for (; ; ) {
2347
- d.warn("[CROSSx] PIN 불일치/잠금 — 재입력 요청:", s), this.pinStore.clear(), await this.ensureVerifiedPin(s, t), t = void 0;
2497
+ d.warn("[CROSSx] PIN 불일치/잠금 — 재입력 요청:", t), this.pinStore.clear(), await this.ensureVerifiedPin(t, n, o, i), n = void 0, o = void 0, i = void 0;
2348
2498
  try {
2349
2499
  return await e();
2350
- } catch (n) {
2351
- if (n instanceof m) {
2352
- if (n.code === p.PIN_WRONG) {
2353
- s = "Incorrect PIN. Please try again.";
2354
- continue;
2355
- }
2356
- if (n.code === p.PIN_INVALID) {
2357
- s = n.message;
2358
- continue;
2359
- }
2360
- if (n.code === p.PIN_LOCKED) {
2361
- const o = n.details;
2362
- t = o == null ? void 0 : o.lockExpiresAt, s = "Too many failed attempts. Your account is temporarily locked.";
2363
- continue;
2364
- }
2365
- }
2366
- throw n;
2500
+ } catch (c) {
2501
+ if (c instanceof m && a(c))
2502
+ continue;
2503
+ throw c;
2367
2504
  }
2368
2505
  }
2369
2506
  }
@@ -2403,7 +2540,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2403
2540
  */
2404
2541
  dispose() {
2405
2542
  var e;
2406
- (e = this._themeMediaCleanup) == null || e.call(this), this._themeMediaCleanup = null, this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), St(null);
2543
+ (e = this._themeMediaCleanup) == null || e.call(this), this._themeMediaCleanup = null, this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), Et(null);
2407
2544
  }
2408
2545
  /**
2409
2546
  * @internal internal 패키지 전용 — 공개 문서에 기재하지 않음
@@ -2423,9 +2560,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2423
2560
  };
2424
2561
  }
2425
2562
  };
2426
- re.OFFCHAIN_CHAIN_ID = "0";
2427
- let at = re;
2428
- class nr {
2563
+ ee.OFFCHAIN_CHAIN_ID = "0";
2564
+ let ct = ee;
2565
+ class or {
2429
2566
  constructor() {
2430
2567
  this.prefix = "crossx_";
2431
2568
  }
@@ -2462,8 +2599,8 @@ class nr {
2462
2599
  }
2463
2600
  }
2464
2601
  }
2465
- const Ze = "crossx-sdk", or = 1, de = "data", Se = "keys", $e = "aes-primary", ir = 12;
2466
- class Ct {
2602
+ const Ze = "crossx-sdk", ir = 1, de = "data", Ee = "keys", Be = "aes-primary", ar = 12;
2603
+ class Lt {
2467
2604
  constructor(e) {
2468
2605
  this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
2469
2606
  }
@@ -2472,10 +2609,10 @@ class Ct {
2472
2609
  }
2473
2610
  openDB(e = this.dbName) {
2474
2611
  return new Promise((s, t) => {
2475
- const n = indexedDB.open(e, or);
2612
+ const n = indexedDB.open(e, ir);
2476
2613
  n.onupgradeneeded = () => {
2477
2614
  const o = n.result;
2478
- o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(Se) || o.createObjectStore(Se);
2615
+ o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(Ee) || o.createObjectStore(Ee);
2479
2616
  }, n.onsuccess = () => s(n.result), n.onerror = () => t(n.error);
2480
2617
  });
2481
2618
  }
@@ -2505,7 +2642,7 @@ class Ct {
2505
2642
  }
2506
2643
  async init() {
2507
2644
  this.db = await this.openDB();
2508
- const e = await this.idbGet(Se, $e);
2645
+ const e = await this.idbGet(Ee, Be);
2509
2646
  if (e) {
2510
2647
  this.cryptoKey = e;
2511
2648
  return;
@@ -2519,7 +2656,7 @@ class Ct {
2519
2656
  { name: "AES-GCM", length: 256 },
2520
2657
  !1,
2521
2658
  ["encrypt", "decrypt"]
2522
- ), await this.idbPut(Se, $e, this.cryptoKey);
2659
+ ), await this.idbPut(Ee, Be, this.cryptoKey);
2523
2660
  }
2524
2661
  /**
2525
2662
  * 레거시 DB('crossx-sdk')에서 projectId 스코프 DB로 암호키·데이터 마이그레이션.
@@ -2528,7 +2665,7 @@ class Ct {
2528
2665
  async migrateFromLegacyDB() {
2529
2666
  if (this.dbName === Ze) return null;
2530
2667
  try {
2531
- const e = await this.openDB(Ze), s = e.transaction([Se, de], "readonly"), t = s.objectStore(Se).get($e), n = await new Promise((l, u) => {
2668
+ const e = await this.openDB(Ze), s = e.transaction([Ee, de], "readonly"), t = s.objectStore(Ee).get(Be), n = await new Promise((l, u) => {
2532
2669
  t.onsuccess = () => l(t.result), t.onerror = () => u(t.error);
2533
2670
  });
2534
2671
  if (!n)
@@ -2541,7 +2678,7 @@ class Ct {
2541
2678
  i.onsuccess = () => l(i.result), i.onerror = () => u(i.error);
2542
2679
  })
2543
2680
  ]);
2544
- e.close(), await this.idbPut(Se, $e, n);
2681
+ e.close(), await this.idbPut(Ee, Be, n);
2545
2682
  for (let l = 0; l < c.length; l++)
2546
2683
  await this.idbPut(de, String(c[l]), a[l]);
2547
2684
  return indexedDB.deleteDatabase(Ze), d.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), n;
@@ -2550,7 +2687,7 @@ class Ct {
2550
2687
  }
2551
2688
  }
2552
2689
  async encrypt(e) {
2553
- const s = new Uint8Array(ir);
2690
+ const s = new Uint8Array(ar);
2554
2691
  crypto.getRandomValues(s);
2555
2692
  const t = new TextEncoder().encode(e), n = await crypto.subtle.encrypt(
2556
2693
  { name: "AES-GCM", iv: s },
@@ -2609,7 +2746,7 @@ class Ct {
2609
2746
  }
2610
2747
  }
2611
2748
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2612
- function ht(r) {
2749
+ function pt(r) {
2613
2750
  return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
2614
2751
  }
2615
2752
  function me(r, e = "") {
@@ -2618,35 +2755,35 @@ function me(r, e = "") {
2618
2755
  throw new Error(`${s}expected integer >= 0, got ${r}`);
2619
2756
  }
2620
2757
  }
2621
- function V(r, e, s = "") {
2622
- const t = ht(r), n = r == null ? void 0 : r.length, o = e !== void 0;
2758
+ function q(r, e, s = "") {
2759
+ const t = pt(r), n = r == null ? void 0 : r.length, o = e !== void 0;
2623
2760
  if (!t || o && n !== e) {
2624
2761
  const i = s && `"${s}" `, a = o ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
2625
2762
  throw new Error(i + "expected Uint8Array" + a + ", got " + c);
2626
2763
  }
2627
2764
  return r;
2628
2765
  }
2629
- function ts(r) {
2766
+ function rs(r) {
2630
2767
  if (typeof r != "function" || typeof r.create != "function")
2631
2768
  throw new Error("Hash must wrapped by utils.createHasher");
2632
2769
  me(r.outputLen), me(r.blockLen);
2633
2770
  }
2634
- function ke(r, e = !0) {
2771
+ function Oe(r, e = !0) {
2635
2772
  if (r.destroyed)
2636
2773
  throw new Error("Hash instance has been destroyed");
2637
2774
  if (e && r.finished)
2638
2775
  throw new Error("Hash#digest() has already been called");
2639
2776
  }
2640
- function ss(r, e) {
2641
- V(r, void 0, "digestInto() output");
2777
+ function ns(r, e) {
2778
+ q(r, void 0, "digestInto() output");
2642
2779
  const s = e.outputLen;
2643
2780
  if (r.length < s)
2644
2781
  throw new Error('"digestInto() output" expected to be of length >=' + s);
2645
2782
  }
2646
- function ar(r) {
2783
+ function cr(r) {
2647
2784
  return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
2648
2785
  }
2649
- function Pe(...r) {
2786
+ function Ce(...r) {
2650
2787
  for (let e = 0; e < r.length; e++)
2651
2788
  r[e].fill(0);
2652
2789
  }
@@ -2656,26 +2793,26 @@ function Qe(r) {
2656
2793
  function ue(r, e) {
2657
2794
  return r << 32 - e | r >>> e;
2658
2795
  }
2659
- const cr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2660
- function lr(r) {
2796
+ const lr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2797
+ function dr(r) {
2661
2798
  return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
2662
2799
  }
2663
- function dr(r) {
2800
+ function ur(r) {
2664
2801
  for (let e = 0; e < r.length; e++)
2665
- r[e] = lr(r[e]);
2802
+ r[e] = dr(r[e]);
2666
2803
  return r;
2667
2804
  }
2668
- 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"));
2669
- function Me(r) {
2670
- if (V(r), rs)
2805
+ const Dt = lr ? (r) => r : ur, os = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", hr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
2806
+ function $e(r) {
2807
+ if (q(r), os)
2671
2808
  return r.toHex();
2672
2809
  let e = "";
2673
2810
  for (let s = 0; s < r.length; s++)
2674
- e += ur[r[s]];
2811
+ e += hr[r[s]];
2675
2812
  return e;
2676
2813
  }
2677
2814
  const fe = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
2678
- function Lt(r) {
2815
+ function Mt(r) {
2679
2816
  if (r >= fe._0 && r <= fe._9)
2680
2817
  return r - fe._0;
2681
2818
  if (r >= fe.A && r <= fe.F)
@@ -2683,17 +2820,17 @@ function Lt(r) {
2683
2820
  if (r >= fe.a && r <= fe.f)
2684
2821
  return r - (fe.a - 10);
2685
2822
  }
2686
- function We(r) {
2823
+ function qe(r) {
2687
2824
  if (typeof r != "string")
2688
2825
  throw new Error("hex string expected, got " + typeof r);
2689
- if (rs)
2826
+ if (os)
2690
2827
  return Uint8Array.fromHex(r);
2691
2828
  const e = r.length, s = e / 2;
2692
2829
  if (e % 2)
2693
2830
  throw new Error("hex string expected, got unpadded hex of length " + e);
2694
2831
  const t = new Uint8Array(s);
2695
2832
  for (let n = 0, o = 0; n < s; n++, o += 2) {
2696
- const i = Lt(r.charCodeAt(o)), a = Lt(r.charCodeAt(o + 1));
2833
+ const i = Mt(r.charCodeAt(o)), a = Mt(r.charCodeAt(o + 1));
2697
2834
  if (i === void 0 || a === void 0) {
2698
2835
  const c = r[o] + r[o + 1];
2699
2836
  throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + o);
@@ -2702,11 +2839,11 @@ function We(r) {
2702
2839
  }
2703
2840
  return t;
2704
2841
  }
2705
- function ve(...r) {
2842
+ function Se(...r) {
2706
2843
  let e = 0;
2707
2844
  for (let t = 0; t < r.length; t++) {
2708
2845
  const n = r[t];
2709
- V(n), e += n.length;
2846
+ q(n), e += n.length;
2710
2847
  }
2711
2848
  const s = new Uint8Array(e);
2712
2849
  for (let t = 0, n = 0; t < r.length; t++) {
@@ -2715,42 +2852,42 @@ function ve(...r) {
2715
2852
  }
2716
2853
  return s;
2717
2854
  }
2718
- function ns(r, e = {}) {
2855
+ function is(r, e = {}) {
2719
2856
  const s = (n, o) => r(o).update(n).digest(), t = r(void 0);
2720
2857
  return s.outputLen = t.outputLen, s.blockLen = t.blockLen, s.create = (n) => r(n), Object.assign(s, e), Object.freeze(s);
2721
2858
  }
2722
- function os(r = 32) {
2859
+ function as(r = 32) {
2723
2860
  const e = typeof globalThis == "object" ? globalThis.crypto : null;
2724
2861
  if (typeof (e == null ? void 0 : e.getRandomValues) != "function")
2725
2862
  throw new Error("crypto.getRandomValues must be defined");
2726
2863
  return e.getRandomValues(new Uint8Array(r));
2727
2864
  }
2728
- const hr = (r) => ({
2865
+ const pr = (r) => ({
2729
2866
  oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, r])
2730
2867
  });
2731
- function pr(r, e, s) {
2868
+ function fr(r, e, s) {
2732
2869
  return r & e ^ ~r & s;
2733
2870
  }
2734
- function fr(r, e, s) {
2871
+ function _r(r, e, s) {
2735
2872
  return r & e ^ r & s ^ e & s;
2736
2873
  }
2737
- class _r {
2874
+ class xr {
2738
2875
  constructor(e, s, t, n) {
2739
- E(this, "blockLen");
2740
- E(this, "outputLen");
2741
- E(this, "padOffset");
2742
- E(this, "isLE");
2876
+ T(this, "blockLen");
2877
+ T(this, "outputLen");
2878
+ T(this, "padOffset");
2879
+ T(this, "isLE");
2743
2880
  // For partial updates less than block size
2744
- E(this, "buffer");
2745
- E(this, "view");
2746
- E(this, "finished", !1);
2747
- E(this, "length", 0);
2748
- E(this, "pos", 0);
2749
- E(this, "destroyed", !1);
2881
+ T(this, "buffer");
2882
+ T(this, "view");
2883
+ T(this, "finished", !1);
2884
+ T(this, "length", 0);
2885
+ T(this, "pos", 0);
2886
+ T(this, "destroyed", !1);
2750
2887
  this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Qe(this.buffer);
2751
2888
  }
2752
2889
  update(e) {
2753
- ke(this), V(e);
2890
+ Oe(this), q(e);
2754
2891
  const { view: s, buffer: t, blockLen: n } = this, o = e.length;
2755
2892
  for (let i = 0; i < o; ) {
2756
2893
  const a = Math.min(n - this.pos, o - i);
@@ -2765,10 +2902,10 @@ class _r {
2765
2902
  return this.length += e.length, this.roundClean(), this;
2766
2903
  }
2767
2904
  digestInto(e) {
2768
- ke(this), ss(e, this), this.finished = !0;
2905
+ Oe(this), ns(e, this), this.finished = !0;
2769
2906
  const { buffer: s, view: t, blockLen: n, isLE: o } = this;
2770
2907
  let { pos: i } = this;
2771
- s[i++] = 128, Pe(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
2908
+ s[i++] = 128, Ce(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
2772
2909
  for (let h = i; h < n; h++)
2773
2910
  s[h] = 0;
2774
2911
  t.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(t, 0);
@@ -2805,20 +2942,20 @@ const we = /* @__PURE__ */ Uint32Array.from([
2805
2942
  2600822924,
2806
2943
  528734635,
2807
2944
  1541459225
2808
- ]), Be = /* @__PURE__ */ BigInt(2 ** 32 - 1), Dt = /* @__PURE__ */ BigInt(32);
2809
- function xr(r, e = !1) {
2810
- return e ? { h: Number(r & Be), l: Number(r >> Dt & Be) } : { h: Number(r >> Dt & Be) | 0, l: Number(r & Be) | 0 };
2811
- }
2945
+ ]), Ue = /* @__PURE__ */ BigInt(2 ** 32 - 1), $t = /* @__PURE__ */ BigInt(32);
2812
2946
  function gr(r, e = !1) {
2947
+ return e ? { h: Number(r & Ue), l: Number(r >> $t & Ue) } : { h: Number(r >> $t & Ue) | 0, l: Number(r & Ue) | 0 };
2948
+ }
2949
+ function mr(r, e = !1) {
2813
2950
  const s = r.length;
2814
2951
  let t = new Uint32Array(s), n = new Uint32Array(s);
2815
2952
  for (let o = 0; o < s; o++) {
2816
- const { h: i, l: a } = xr(r[o], e);
2953
+ const { h: i, l: a } = gr(r[o], e);
2817
2954
  [t[o], n[o]] = [i, a];
2818
2955
  }
2819
2956
  return [t, n];
2820
2957
  }
2821
- 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([
2958
+ const wr = (r, e, s) => r << s | e >>> 32 - s, yr = (r, e, s) => e << s | r >>> 32 - s, br = (r, e, s) => e << s - 32 | r >>> 64 - s, Sr = (r, e, s) => r << s - 32 | e >>> 64 - s, vr = /* @__PURE__ */ Uint32Array.from([
2822
2959
  1116352408,
2823
2960
  1899447441,
2824
2961
  3049323471,
@@ -2884,7 +3021,7 @@ const mr = (r, e, s) => r << s | e >>> 32 - s, wr = (r, e, s) => e << s | r >>>
2884
3021
  3204031479,
2885
3022
  3329325298
2886
3023
  ]), ye = /* @__PURE__ */ new Uint32Array(64);
2887
- class Sr extends _r {
3024
+ class Er extends xr {
2888
3025
  constructor(e) {
2889
3026
  super(64, e, 8, !1);
2890
3027
  }
@@ -2900,132 +3037,132 @@ class Sr extends _r {
2900
3037
  for (let h = 0; h < 16; h++, s += 4)
2901
3038
  ye[h] = e.getUint32(s, !1);
2902
3039
  for (let h = 16; h < 64; h++) {
2903
- const _ = ye[h - 15], f = ye[h - 2], w = ue(_, 7) ^ ue(_, 18) ^ _ >>> 3, b = ue(f, 17) ^ ue(f, 19) ^ f >>> 10;
2904
- ye[h] = b + ye[h - 7] + w + ye[h - 16] | 0;
3040
+ const _ = ye[h - 15], f = ye[h - 2], w = ue(_, 7) ^ ue(_, 18) ^ _ >>> 3, E = ue(f, 17) ^ ue(f, 19) ^ f >>> 10;
3041
+ ye[h] = E + ye[h - 7] + w + ye[h - 16] | 0;
2905
3042
  }
2906
3043
  let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: u } = this;
2907
3044
  for (let h = 0; h < 64; h++) {
2908
- 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;
2909
- u = l, l = c, c = a, a = i + f | 0, i = o, o = n, n = t, t = f + b | 0;
3045
+ const _ = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), f = u + _ + fr(a, c, l) + vr[h] + ye[h] | 0, E = (ue(t, 2) ^ ue(t, 13) ^ ue(t, 22)) + _r(t, n, o) | 0;
3046
+ u = l, l = c, c = a, a = i + f | 0, i = o, o = n, n = t, t = f + E | 0;
2910
3047
  }
2911
3048
  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);
2912
3049
  }
2913
3050
  roundClean() {
2914
- Pe(ye);
3051
+ Ce(ye);
2915
3052
  }
2916
3053
  destroy() {
2917
- this.set(0, 0, 0, 0, 0, 0, 0, 0), Pe(this.buffer);
3054
+ this.set(0, 0, 0, 0, 0, 0, 0, 0), Ce(this.buffer);
2918
3055
  }
2919
3056
  }
2920
- class Er extends Sr {
3057
+ class Ir extends Er {
2921
3058
  constructor() {
2922
3059
  super(32);
2923
3060
  // We cannot use array here since array allows indexing by variable
2924
3061
  // which means optimizer/compiler cannot use registers.
2925
- E(this, "A", we[0] | 0);
2926
- E(this, "B", we[1] | 0);
2927
- E(this, "C", we[2] | 0);
2928
- E(this, "D", we[3] | 0);
2929
- E(this, "E", we[4] | 0);
2930
- E(this, "F", we[5] | 0);
2931
- E(this, "G", we[6] | 0);
2932
- E(this, "H", we[7] | 0);
2933
- }
2934
- }
2935
- const Ir = /* @__PURE__ */ ns(
2936
- () => new Er(),
2937
- /* @__PURE__ */ hr(1)
3062
+ T(this, "A", we[0] | 0);
3063
+ T(this, "B", we[1] | 0);
3064
+ T(this, "C", we[2] | 0);
3065
+ T(this, "D", we[3] | 0);
3066
+ T(this, "E", we[4] | 0);
3067
+ T(this, "F", we[5] | 0);
3068
+ T(this, "G", we[6] | 0);
3069
+ T(this, "H", we[7] | 0);
3070
+ }
3071
+ }
3072
+ const Ar = /* @__PURE__ */ is(
3073
+ () => new Ir(),
3074
+ /* @__PURE__ */ pr(1)
2938
3075
  );
2939
3076
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2940
- const pt = /* @__PURE__ */ BigInt(0), ct = /* @__PURE__ */ BigInt(1);
2941
- function qe(r, e = "") {
3077
+ const ft = /* @__PURE__ */ BigInt(0), lt = /* @__PURE__ */ BigInt(1);
3078
+ function Ke(r, e = "") {
2942
3079
  if (typeof r != "boolean") {
2943
3080
  const s = e && `"${e}" `;
2944
3081
  throw new Error(s + "expected boolean, got type=" + typeof r);
2945
3082
  }
2946
3083
  return r;
2947
3084
  }
2948
- function is(r) {
3085
+ function cs(r) {
2949
3086
  if (typeof r == "bigint") {
2950
- if (!Fe(r))
3087
+ if (!Ge(r))
2951
3088
  throw new Error("positive bigint expected, got " + r);
2952
3089
  } else
2953
3090
  me(r);
2954
3091
  return r;
2955
3092
  }
2956
- function Ue(r) {
2957
- const e = is(r).toString(16);
3093
+ function He(r) {
3094
+ const e = cs(r).toString(16);
2958
3095
  return e.length & 1 ? "0" + e : e;
2959
3096
  }
2960
- function as(r) {
3097
+ function ls(r) {
2961
3098
  if (typeof r != "string")
2962
3099
  throw new Error("hex string expected, got " + typeof r);
2963
- return r === "" ? pt : BigInt("0x" + r);
3100
+ return r === "" ? ft : BigInt("0x" + r);
2964
3101
  }
2965
- function ze(r) {
2966
- return as(Me(r));
3102
+ function je(r) {
3103
+ return ls($e(r));
2967
3104
  }
2968
- function cs(r) {
2969
- return as(Me(Tr(V(r)).reverse()));
3105
+ function ds(r) {
3106
+ return ls($e(Tr(q(r)).reverse()));
2970
3107
  }
2971
- function ft(r, e) {
2972
- me(e), r = is(r);
2973
- const s = We(r.toString(16).padStart(e * 2, "0"));
3108
+ function _t(r, e) {
3109
+ me(e), r = cs(r);
3110
+ const s = qe(r.toString(16).padStart(e * 2, "0"));
2974
3111
  if (s.length !== e)
2975
3112
  throw new Error("number too large");
2976
3113
  return s;
2977
3114
  }
2978
- function ls(r, e) {
2979
- return ft(r, e).reverse();
3115
+ function us(r, e) {
3116
+ return _t(r, e).reverse();
2980
3117
  }
2981
3118
  function Tr(r) {
2982
3119
  return Uint8Array.from(r);
2983
3120
  }
2984
- const Fe = (r) => typeof r == "bigint" && pt <= r;
2985
- function Ar(r, e, s) {
2986
- return Fe(r) && Fe(e) && Fe(s) && e <= r && r < s;
3121
+ const Ge = (r) => typeof r == "bigint" && ft <= r;
3122
+ function Rr(r, e, s) {
3123
+ return Ge(r) && Ge(e) && Ge(s) && e <= r && r < s;
2987
3124
  }
2988
- function Rr(r, e, s, t) {
2989
- if (!Ar(e, s, t))
3125
+ function kr(r, e, s, t) {
3126
+ if (!Rr(e, s, t))
2990
3127
  throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
2991
3128
  }
2992
- function kr(r) {
3129
+ function Pr(r) {
2993
3130
  let e;
2994
- for (e = 0; r > pt; r >>= ct, e += 1)
3131
+ for (e = 0; r > ft; r >>= lt, e += 1)
2995
3132
  ;
2996
3133
  return e;
2997
3134
  }
2998
- const _t = (r) => (ct << BigInt(r)) - ct;
2999
- function Pr(r, e, s) {
3135
+ const xt = (r) => (lt << BigInt(r)) - lt;
3136
+ function Or(r, e, s) {
3000
3137
  if (me(r, "hashLen"), me(e, "qByteLen"), typeof s != "function")
3001
3138
  throw new Error("hmacFn must be a function");
3002
3139
  const t = (y) => new Uint8Array(y), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
3003
3140
  let c = t(r), l = t(r), u = 0;
3004
3141
  const h = () => {
3005
3142
  c.fill(1), l.fill(0), u = 0;
3006
- }, _ = (...y) => s(l, ve(c, ...y)), f = (y = n) => {
3143
+ }, _ = (...y) => s(l, Se(c, ...y)), f = (y = n) => {
3007
3144
  l = _(o, y), c = _(), y.length !== 0 && (l = _(i, y), c = _());
3008
3145
  }, w = () => {
3009
3146
  if (u++ >= a)
3010
3147
  throw new Error("drbg: tried max amount of iterations");
3011
3148
  let y = 0;
3012
- const T = [];
3149
+ const R = [];
3013
3150
  for (; y < e; ) {
3014
3151
  c = _();
3015
3152
  const N = c.slice();
3016
- T.push(N), y += c.length;
3153
+ R.push(N), y += c.length;
3017
3154
  }
3018
- return ve(...T);
3155
+ return Se(...R);
3019
3156
  };
3020
- return (y, T) => {
3157
+ return (y, R) => {
3021
3158
  h(), f(y);
3022
3159
  let N;
3023
- for (; !(N = T(w())); )
3160
+ for (; !(N = R(w())); )
3024
3161
  f();
3025
3162
  return h(), N;
3026
3163
  };
3027
3164
  }
3028
- function xt(r, e = {}, s = {}) {
3165
+ function gt(r, e = {}, s = {}) {
3029
3166
  if (!r || typeof r != "object")
3030
3167
  throw new Error("expected valid options object");
3031
3168
  function t(o, i, a) {
@@ -3039,7 +3176,7 @@ function xt(r, e = {}, s = {}) {
3039
3176
  const n = (o, i) => Object.entries(o).forEach(([a, c]) => t(a, c, i));
3040
3177
  n(e, !1), n(s, !0);
3041
3178
  }
3042
- function Mt(r) {
3179
+ function Bt(r) {
3043
3180
  const e = /* @__PURE__ */ new WeakMap();
3044
3181
  return (s, ...t) => {
3045
3182
  const n = e.get(s);
@@ -3050,7 +3187,7 @@ function Mt(r) {
3050
3187
  };
3051
3188
  }
3052
3189
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3053
- 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);
3190
+ const ne = /* @__PURE__ */ BigInt(0), te = /* @__PURE__ */ BigInt(1), Ae = /* @__PURE__ */ BigInt(2), hs = /* @__PURE__ */ BigInt(3), ps = /* @__PURE__ */ BigInt(4), fs = /* @__PURE__ */ BigInt(5), Cr = /* @__PURE__ */ BigInt(7), _s = /* @__PURE__ */ BigInt(8), Nr = /* @__PURE__ */ BigInt(9), xs = /* @__PURE__ */ BigInt(16);
3054
3191
  function le(r, e) {
3055
3192
  const s = r % e;
3056
3193
  return s >= ne ? s : e + s;
@@ -3061,80 +3198,80 @@ function ae(r, e, s) {
3061
3198
  t *= t, t %= s;
3062
3199
  return t;
3063
3200
  }
3064
- function $t(r, e) {
3201
+ function Ut(r, e) {
3065
3202
  if (r === ne)
3066
3203
  throw new Error("invert: expected non-zero number");
3067
3204
  if (e <= ne)
3068
3205
  throw new Error("invert: expected positive modulus, got " + e);
3069
- let s = le(r, e), t = e, n = ne, o = ee;
3206
+ let s = le(r, e), t = e, n = ne, o = te;
3070
3207
  for (; s !== ne; ) {
3071
3208
  const a = t / s, c = t % s, l = n - o * a;
3072
3209
  t = s, s = c, n = o, o = l;
3073
3210
  }
3074
- if (t !== ee)
3211
+ if (t !== te)
3075
3212
  throw new Error("invert: does not exist");
3076
3213
  return le(n, e);
3077
3214
  }
3078
- function gt(r, e, s) {
3215
+ function mt(r, e, s) {
3079
3216
  if (!r.eql(r.sqr(e), s))
3080
3217
  throw new Error("Cannot find square root");
3081
3218
  }
3082
- function _s(r, e) {
3083
- const s = (r.ORDER + ee) / us, t = r.pow(e, s);
3084
- return gt(r, t, e), t;
3219
+ function gs(r, e) {
3220
+ const s = (r.ORDER + te) / ps, t = r.pow(e, s);
3221
+ return mt(r, t, e), t;
3085
3222
  }
3086
- function Nr(r, e) {
3087
- 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));
3088
- return gt(r, a, e), a;
3223
+ function Lr(r, e) {
3224
+ const s = (r.ORDER - fs) / _s, t = r.mul(e, Ae), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, Ae), n), a = r.mul(o, r.sub(i, r.ONE));
3225
+ return mt(r, a, e), a;
3089
3226
  }
3090
- function Lr(r) {
3091
- 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;
3227
+ function Dr(r) {
3228
+ const e = Ye(r), s = ms(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + Cr) / xs;
3092
3229
  return (a, c) => {
3093
3230
  let l = a.pow(c, i), u = a.mul(l, t);
3094
3231
  const h = a.mul(l, n), _ = a.mul(l, o), f = a.eql(a.sqr(u), c), w = a.eql(a.sqr(h), c);
3095
3232
  l = a.cmov(l, u, f), u = a.cmov(_, h, w);
3096
- const b = a.eql(a.sqr(u), c), y = a.cmov(l, u, b);
3097
- return gt(a, y, c), y;
3233
+ const E = a.eql(a.sqr(u), c), y = a.cmov(l, u, E);
3234
+ return mt(a, y, c), y;
3098
3235
  };
3099
3236
  }
3100
- function xs(r) {
3101
- if (r < ds)
3237
+ function ms(r) {
3238
+ if (r < hs)
3102
3239
  throw new Error("sqrt is not defined for small field");
3103
- let e = r - ee, s = 0;
3104
- for (; e % Ie === ne; )
3105
- e /= Ie, s++;
3106
- let t = Ie;
3107
- const n = je(r);
3108
- for (; Bt(n, t) === 1; )
3240
+ let e = r - te, s = 0;
3241
+ for (; e % Ae === ne; )
3242
+ e /= Ae, s++;
3243
+ let t = Ae;
3244
+ const n = Ye(r);
3245
+ for (; Ht(n, t) === 1; )
3109
3246
  if (t++ > 1e3)
3110
3247
  throw new Error("Cannot find square root: probably non-prime P");
3111
3248
  if (s === 1)
3112
- return _s;
3249
+ return gs;
3113
3250
  let o = n.pow(t, e);
3114
- const i = (e + ee) / Ie;
3251
+ const i = (e + te) / Ae;
3115
3252
  return function(c, l) {
3116
3253
  if (c.is0(l))
3117
3254
  return l;
3118
- if (Bt(c, l) !== 1)
3255
+ if (Ht(c, l) !== 1)
3119
3256
  throw new Error("Cannot find square root");
3120
3257
  let u = s, h = c.mul(c.ONE, o), _ = c.pow(l, e), f = c.pow(l, i);
3121
3258
  for (; !c.eql(_, c.ONE); ) {
3122
3259
  if (c.is0(_))
3123
3260
  return c.ZERO;
3124
- let w = 1, b = c.sqr(_);
3125
- for (; !c.eql(b, c.ONE); )
3126
- if (w++, b = c.sqr(b), w === u)
3261
+ let w = 1, E = c.sqr(_);
3262
+ for (; !c.eql(E, c.ONE); )
3263
+ if (w++, E = c.sqr(E), w === u)
3127
3264
  throw new Error("Cannot find square root");
3128
- const y = ee << BigInt(u - w - 1), T = c.pow(h, y);
3129
- u = w, h = c.sqr(T), _ = c.mul(_, h), f = c.mul(f, T);
3265
+ const y = te << BigInt(u - w - 1), R = c.pow(h, y);
3266
+ u = w, h = c.sqr(R), _ = c.mul(_, h), f = c.mul(f, R);
3130
3267
  }
3131
3268
  return f;
3132
3269
  };
3133
3270
  }
3134
- function Dr(r) {
3135
- return r % us === ds ? _s : r % ps === hs ? Nr : r % fs === Cr ? Lr(r) : xs(r);
3271
+ function Mr(r) {
3272
+ return r % ps === hs ? gs : r % _s === fs ? Lr : r % xs === Nr ? Dr(r) : ms(r);
3136
3273
  }
3137
- const Mr = [
3274
+ const $r = [
3138
3275
  "create",
3139
3276
  "isValid",
3140
3277
  "is0",
@@ -3153,59 +3290,59 @@ const Mr = [
3153
3290
  "mulN",
3154
3291
  "sqrN"
3155
3292
  ];
3156
- function $r(r) {
3293
+ function Br(r) {
3157
3294
  const e = {
3158
3295
  ORDER: "bigint",
3159
3296
  BYTES: "number",
3160
3297
  BITS: "number"
3161
- }, s = Mr.reduce((t, n) => (t[n] = "function", t), e);
3162
- return xt(r, s), r;
3298
+ }, s = $r.reduce((t, n) => (t[n] = "function", t), e);
3299
+ return gt(r, s), r;
3163
3300
  }
3164
- function Br(r, e, s) {
3301
+ function Ur(r, e, s) {
3165
3302
  if (s < ne)
3166
3303
  throw new Error("invalid exponent, negatives unsupported");
3167
3304
  if (s === ne)
3168
3305
  return r.ONE;
3169
- if (s === ee)
3306
+ if (s === te)
3170
3307
  return e;
3171
3308
  let t = r.ONE, n = e;
3172
3309
  for (; s > ne; )
3173
- s & ee && (t = r.mul(t, n)), n = r.sqr(n), s >>= ee;
3310
+ s & te && (t = r.mul(t, n)), n = r.sqr(n), s >>= te;
3174
3311
  return t;
3175
3312
  }
3176
- function gs(r, e, s = !1) {
3313
+ function ws(r, e, s = !1) {
3177
3314
  const t = new Array(e.length).fill(s ? r.ZERO : void 0), n = e.reduce((i, a, c) => r.is0(a) ? i : (t[c] = i, r.mul(i, a)), r.ONE), o = r.inv(n);
3178
3315
  return e.reduceRight((i, a, c) => r.is0(a) ? i : (t[c] = r.mul(i, t[c]), r.mul(i, a)), o), t;
3179
3316
  }
3180
- function Bt(r, e) {
3181
- const s = (r.ORDER - ee) / Ie, t = r.pow(e, s), n = r.eql(t, r.ONE), o = r.eql(t, r.ZERO), i = r.eql(t, r.neg(r.ONE));
3317
+ function Ht(r, e) {
3318
+ const s = (r.ORDER - te) / Ae, t = r.pow(e, s), n = r.eql(t, r.ONE), o = r.eql(t, r.ZERO), i = r.eql(t, r.neg(r.ONE));
3182
3319
  if (!n && !o && !i)
3183
3320
  throw new Error("invalid Legendre symbol result");
3184
3321
  return n ? 1 : o ? 0 : -1;
3185
3322
  }
3186
- function Ur(r, e) {
3323
+ function Hr(r, e) {
3187
3324
  e !== void 0 && me(e);
3188
3325
  const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
3189
3326
  return { nBitLength: s, nByteLength: t };
3190
3327
  }
3191
- class Hr {
3328
+ class Fr {
3192
3329
  constructor(e, s = {}) {
3193
- E(this, "ORDER");
3194
- E(this, "BITS");
3195
- E(this, "BYTES");
3196
- E(this, "isLE");
3197
- E(this, "ZERO", ne);
3198
- E(this, "ONE", ee);
3199
- E(this, "_lengths");
3200
- E(this, "_sqrt");
3330
+ T(this, "ORDER");
3331
+ T(this, "BITS");
3332
+ T(this, "BYTES");
3333
+ T(this, "isLE");
3334
+ T(this, "ZERO", ne);
3335
+ T(this, "ONE", te);
3336
+ T(this, "_lengths");
3337
+ T(this, "_sqrt");
3201
3338
  // cached sqrt
3202
- E(this, "_mod");
3339
+ T(this, "_mod");
3203
3340
  var i;
3204
3341
  if (e <= ne)
3205
3342
  throw new Error("invalid field: expected ORDER > 0, got " + e);
3206
3343
  let t;
3207
3344
  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));
3208
- const { nBitLength: n, nByteLength: o } = Ur(e, t);
3345
+ const { nBitLength: n, nByteLength: o } = Hr(e, t);
3209
3346
  if (o > 2048)
3210
3347
  throw new Error("invalid field: expected ORDER of <= 2048 bytes");
3211
3348
  this.ORDER = e, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
@@ -3226,7 +3363,7 @@ class Hr {
3226
3363
  return !this.is0(e) && this.isValid(e);
3227
3364
  }
3228
3365
  isOdd(e) {
3229
- return (e & ee) === ee;
3366
+ return (e & te) === te;
3230
3367
  }
3231
3368
  neg(e) {
3232
3369
  return le(-e, this.ORDER);
@@ -3247,10 +3384,10 @@ class Hr {
3247
3384
  return le(e * s, this.ORDER);
3248
3385
  }
3249
3386
  pow(e, s) {
3250
- return Br(this, e, s);
3387
+ return Ur(this, e, s);
3251
3388
  }
3252
3389
  div(e, s) {
3253
- return le(e * $t(s, this.ORDER), this.ORDER);
3390
+ return le(e * Ut(s, this.ORDER), this.ORDER);
3254
3391
  }
3255
3392
  // Same as above, but doesn't normalize
3256
3393
  sqrN(e) {
@@ -3266,16 +3403,16 @@ class Hr {
3266
3403
  return e * s;
3267
3404
  }
3268
3405
  inv(e) {
3269
- return $t(e, this.ORDER);
3406
+ return Ut(e, this.ORDER);
3270
3407
  }
3271
3408
  sqrt(e) {
3272
- return this._sqrt || (this._sqrt = Dr(this.ORDER)), this._sqrt(this, e);
3409
+ return this._sqrt || (this._sqrt = Mr(this.ORDER)), this._sqrt(this, e);
3273
3410
  }
3274
3411
  toBytes(e) {
3275
- return this.isLE ? ls(e, this.BYTES) : ft(e, this.BYTES);
3412
+ return this.isLE ? us(e, this.BYTES) : _t(e, this.BYTES);
3276
3413
  }
3277
3414
  fromBytes(e, s = !1) {
3278
- V(e);
3415
+ q(e);
3279
3416
  const { _lengths: t, BYTES: n, isLE: o, ORDER: i, _mod: a } = this;
3280
3417
  if (t) {
3281
3418
  if (!t.includes(e.length) || e.length > n)
@@ -3285,14 +3422,14 @@ class Hr {
3285
3422
  }
3286
3423
  if (e.length !== n)
3287
3424
  throw new Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
3288
- let c = o ? cs(e) : ze(e);
3425
+ let c = o ? ds(e) : je(e);
3289
3426
  if (a && (c = le(c, i)), !s && !this.isValid(c))
3290
3427
  throw new Error("invalid field element: outside of range 0..ORDER");
3291
3428
  return c;
3292
3429
  }
3293
3430
  // TODO: we don't need it here, move out to separate fn
3294
3431
  invertBatch(e) {
3295
- return gs(this, e);
3432
+ return ws(this, e);
3296
3433
  }
3297
3434
  // We can't move this out because Fp6, Fp12 implement it
3298
3435
  // and it's unclear what to return in there.
@@ -3300,74 +3437,74 @@ class Hr {
3300
3437
  return t ? s : e;
3301
3438
  }
3302
3439
  }
3303
- function je(r, e = {}) {
3304
- return new Hr(r, e);
3440
+ function Ye(r, e = {}) {
3441
+ return new Fr(r, e);
3305
3442
  }
3306
- function ms(r) {
3443
+ function ys(r) {
3307
3444
  if (typeof r != "bigint")
3308
3445
  throw new Error("field order must be bigint");
3309
3446
  const e = r.toString(2).length;
3310
3447
  return Math.ceil(e / 8);
3311
3448
  }
3312
- function ws(r) {
3313
- const e = ms(r);
3449
+ function bs(r) {
3450
+ const e = ys(r);
3314
3451
  return e + Math.ceil(e / 2);
3315
3452
  }
3316
- function Fr(r, e, s = !1) {
3317
- V(r);
3318
- const t = r.length, n = ms(e), o = ws(e);
3453
+ function Gr(r, e, s = !1) {
3454
+ q(r);
3455
+ const t = r.length, n = ys(e), o = bs(e);
3319
3456
  if (t < 16 || t < o || t > 1024)
3320
3457
  throw new Error("expected " + o + "-1024 bytes of input, got " + t);
3321
- const i = s ? cs(r) : ze(r), a = le(i, e - ee) + ee;
3322
- return s ? ls(a, n) : ft(a, n);
3458
+ const i = s ? ds(r) : je(r), a = le(i, e - te) + te;
3459
+ return s ? us(a, n) : _t(a, n);
3323
3460
  }
3324
3461
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3325
- const Oe = /* @__PURE__ */ BigInt(0), Te = /* @__PURE__ */ BigInt(1);
3326
- function Ke(r, e) {
3462
+ const Ne = /* @__PURE__ */ BigInt(0), Te = /* @__PURE__ */ BigInt(1);
3463
+ function Ve(r, e) {
3327
3464
  const s = e.negate();
3328
3465
  return r ? s : e;
3329
3466
  }
3330
- function Ut(r, e) {
3331
- const s = gs(r.Fp, e.map((t) => t.Z));
3467
+ function Ft(r, e) {
3468
+ const s = ws(r.Fp, e.map((t) => t.Z));
3332
3469
  return e.map((t, n) => r.fromAffine(t.toAffine(s[n])));
3333
3470
  }
3334
- function ys(r, e) {
3471
+ function Ss(r, e) {
3335
3472
  if (!Number.isSafeInteger(r) || r <= 0 || r > e)
3336
3473
  throw new Error("invalid window size, expected [1.." + e + "], got W=" + r);
3337
3474
  }
3338
3475
  function et(r, e) {
3339
- ys(r, e);
3340
- const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = _t(r), i = BigInt(r);
3476
+ Ss(r, e);
3477
+ const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = xt(r), i = BigInt(r);
3341
3478
  return { windows: s, windowSize: t, mask: o, maxNumber: n, shiftBy: i };
3342
3479
  }
3343
- function Ht(r, e, s) {
3480
+ function Gt(r, e, s) {
3344
3481
  const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
3345
3482
  let a = Number(r & n), c = r >> i;
3346
3483
  a > t && (a -= o, c += Te);
3347
3484
  const l = e * t, u = l + Math.abs(a) - 1, h = a === 0, _ = a < 0, f = e % 2 !== 0;
3348
3485
  return { nextN: c, offset: u, isZero: h, isNeg: _, isNegF: f, offsetF: l };
3349
3486
  }
3350
- const tt = /* @__PURE__ */ new WeakMap(), bs = /* @__PURE__ */ new WeakMap();
3487
+ const tt = /* @__PURE__ */ new WeakMap(), vs = /* @__PURE__ */ new WeakMap();
3351
3488
  function st(r) {
3352
- return bs.get(r) || 1;
3489
+ return vs.get(r) || 1;
3353
3490
  }
3354
- function Ft(r) {
3355
- if (r !== Oe)
3491
+ function Wt(r) {
3492
+ if (r !== Ne)
3356
3493
  throw new Error("invalid wNAF");
3357
3494
  }
3358
- class Gr {
3495
+ class Wr {
3359
3496
  // Parametrized with a given Point class (not individual point)
3360
3497
  constructor(e, s) {
3361
- E(this, "BASE");
3362
- E(this, "ZERO");
3363
- E(this, "Fn");
3364
- E(this, "bits");
3498
+ T(this, "BASE");
3499
+ T(this, "ZERO");
3500
+ T(this, "Fn");
3501
+ T(this, "bits");
3365
3502
  this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = s;
3366
3503
  }
3367
3504
  // non-const time multiplication ladder
3368
3505
  _unsafeLadder(e, s, t = this.ZERO) {
3369
3506
  let n = e;
3370
- for (; s > Oe; )
3507
+ for (; s > Ne; )
3371
3508
  s & Te && (t = t.add(n)), n = n.double(), s >>= Te;
3372
3509
  return t;
3373
3510
  }
@@ -3406,10 +3543,10 @@ class Gr {
3406
3543
  let n = this.ZERO, o = this.BASE;
3407
3544
  const i = et(e, this.bits);
3408
3545
  for (let a = 0; a < i.windows; a++) {
3409
- const { nextN: c, offset: l, isZero: u, isNeg: h, isNegF: _, offsetF: f } = Ht(t, a, i);
3410
- t = c, u ? o = o.add(Ke(_, s[f])) : n = n.add(Ke(h, s[l]));
3546
+ const { nextN: c, offset: l, isZero: u, isNeg: h, isNegF: _, offsetF: f } = Gt(t, a, i);
3547
+ t = c, u ? o = o.add(Ve(_, s[f])) : n = n.add(Ve(h, s[l]));
3411
3548
  }
3412
- return Ft(t), { p: n, f: o };
3549
+ return Wt(t), { p: n, f: o };
3413
3550
  }
3414
3551
  /**
3415
3552
  * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
@@ -3418,14 +3555,14 @@ class Gr {
3418
3555
  */
3419
3556
  wNAFUnsafe(e, s, t, n = this.ZERO) {
3420
3557
  const o = et(e, this.bits);
3421
- for (let i = 0; i < o.windows && t !== Oe; i++) {
3422
- const { nextN: a, offset: c, isZero: l, isNeg: u } = Ht(t, i, o);
3558
+ for (let i = 0; i < o.windows && t !== Ne; i++) {
3559
+ const { nextN: a, offset: c, isZero: l, isNeg: u } = Gt(t, i, o);
3423
3560
  if (t = a, !l) {
3424
3561
  const h = s[c];
3425
3562
  n = n.add(u ? h.negate() : h);
3426
3563
  }
3427
3564
  }
3428
- return Ft(t), n;
3565
+ return Wt(t), n;
3429
3566
  }
3430
3567
  getPrecomputes(e, s, t) {
3431
3568
  let n = tt.get(s);
@@ -3443,55 +3580,55 @@ class Gr {
3443
3580
  // using windowed method. This specifies window size and
3444
3581
  // stores precomputed values. Usually only base point would be precomputed.
3445
3582
  createCache(e, s) {
3446
- ys(s, this.bits), bs.set(e, s), tt.delete(e);
3583
+ Ss(s, this.bits), vs.set(e, s), tt.delete(e);
3447
3584
  }
3448
3585
  hasCache(e) {
3449
3586
  return st(e) !== 1;
3450
3587
  }
3451
3588
  }
3452
- function Wr(r, e, s, t) {
3589
+ function qr(r, e, s, t) {
3453
3590
  let n = e, o = r.ZERO, i = r.ZERO;
3454
- for (; s > Oe || t > Oe; )
3591
+ for (; s > Ne || t > Ne; )
3455
3592
  s & Te && (o = o.add(n)), t & Te && (i = i.add(n)), n = n.double(), s >>= Te, t >>= Te;
3456
3593
  return { p1: o, p2: i };
3457
3594
  }
3458
- function Gt(r, e, s) {
3595
+ function qt(r, e, s) {
3459
3596
  if (e) {
3460
3597
  if (e.ORDER !== r)
3461
3598
  throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
3462
- return $r(e), e;
3599
+ return Br(e), e;
3463
3600
  } else
3464
- return je(r, { isLE: s });
3601
+ return Ye(r, { isLE: s });
3465
3602
  }
3466
- function qr(r, e, s = {}, t) {
3603
+ function Kr(r, e, s = {}, t) {
3467
3604
  if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
3468
3605
  throw new Error(`expected valid ${r} CURVE object`);
3469
3606
  for (const c of ["p", "n", "h"]) {
3470
3607
  const l = e[c];
3471
- if (!(typeof l == "bigint" && l > Oe))
3608
+ if (!(typeof l == "bigint" && l > Ne))
3472
3609
  throw new Error(`CURVE.${c} must be positive bigint`);
3473
3610
  }
3474
- const n = Gt(e.p, s.Fp, t), o = Gt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
3611
+ const n = qt(e.p, s.Fp, t), o = qt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
3475
3612
  for (const c of a)
3476
3613
  if (!n.isValid(e[c]))
3477
3614
  throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
3478
3615
  return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: n, Fn: o };
3479
3616
  }
3480
- function Kr(r, e) {
3617
+ function Vr(r, e) {
3481
3618
  return function(t) {
3482
3619
  const n = r(t);
3483
3620
  return { secretKey: n, publicKey: e(n) };
3484
3621
  };
3485
3622
  }
3486
- class vs {
3623
+ class Es {
3487
3624
  constructor(e, s) {
3488
- E(this, "oHash");
3489
- E(this, "iHash");
3490
- E(this, "blockLen");
3491
- E(this, "outputLen");
3492
- E(this, "finished", !1);
3493
- E(this, "destroyed", !1);
3494
- if (ts(e), V(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
3625
+ T(this, "oHash");
3626
+ T(this, "iHash");
3627
+ T(this, "blockLen");
3628
+ T(this, "outputLen");
3629
+ T(this, "finished", !1);
3630
+ T(this, "destroyed", !1);
3631
+ if (rs(e), q(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
3495
3632
  throw new Error("Expected instance of class which extends utils.Hash");
3496
3633
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
3497
3634
  const t = this.blockLen, n = new Uint8Array(t);
@@ -3501,13 +3638,13 @@ class vs {
3501
3638
  this.iHash.update(n), this.oHash = e.create();
3502
3639
  for (let o = 0; o < n.length; o++)
3503
3640
  n[o] ^= 106;
3504
- this.oHash.update(n), Pe(n);
3641
+ this.oHash.update(n), Ce(n);
3505
3642
  }
3506
3643
  update(e) {
3507
- return ke(this), this.iHash.update(e), this;
3644
+ return Oe(this), this.iHash.update(e), this;
3508
3645
  }
3509
3646
  digestInto(e) {
3510
- ke(this), V(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
3647
+ Oe(this), q(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
3511
3648
  }
3512
3649
  digest() {
3513
3650
  const e = new Uint8Array(this.oHash.outputLen);
@@ -3525,21 +3662,21 @@ class vs {
3525
3662
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
3526
3663
  }
3527
3664
  }
3528
- const Ss = (r, e, s) => new vs(r, e).update(s).digest();
3529
- Ss.create = (r, e) => new vs(r, e);
3665
+ const Is = (r, e, s) => new Es(r, e).update(s).digest();
3666
+ Is.create = (r, e) => new Es(r, e);
3530
3667
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3531
- const Wt = (r, e) => (r + (r >= 0 ? e : -e) / Es) / e;
3532
- function Vr(r, e, s) {
3533
- const [[t, n], [o, i]] = e, a = Wt(i * r, s), c = Wt(-n * r, s);
3668
+ const Kt = (r, e) => (r + (r >= 0 ? e : -e) / As) / e;
3669
+ function zr(r, e, s) {
3670
+ const [[t, n], [o, i]] = e, a = Kt(i * r, s), c = Kt(-n * r, s);
3534
3671
  let l = r - a * t - c * o, u = -a * n - c * i;
3535
3672
  const h = l < xe, _ = u < xe;
3536
3673
  h && (l = -l), _ && (u = -u);
3537
- const f = _t(Math.ceil(kr(s) / 2)) + Re;
3674
+ const f = xt(Math.ceil(Pr(s) / 2)) + Pe;
3538
3675
  if (l < xe || l >= f || u < xe || u >= f)
3539
3676
  throw new Error("splitScalar (endomorphism): failed, k=" + r);
3540
3677
  return { k1neg: h, k1: l, k2neg: _, k2: u };
3541
3678
  }
3542
- function lt(r) {
3679
+ function dt(r) {
3543
3680
  if (!["compact", "recovered", "der"].includes(r))
3544
3681
  throw new Error('Signature format must be "compact", "recovered", or "der"');
3545
3682
  return r;
@@ -3548,16 +3685,16 @@ function rt(r, e) {
3548
3685
  const s = {};
3549
3686
  for (let t of Object.keys(e))
3550
3687
  s[t] = r[t] === void 0 ? e[t] : r[t];
3551
- return qe(s.lowS, "lowS"), qe(s.prehash, "prehash"), s.format !== void 0 && lt(s.format), s;
3688
+ return Ke(s.lowS, "lowS"), Ke(s.prehash, "prehash"), s.format !== void 0 && dt(s.format), s;
3552
3689
  }
3553
- class zr extends Error {
3690
+ class jr extends Error {
3554
3691
  constructor(e = "") {
3555
3692
  super(e);
3556
3693
  }
3557
3694
  }
3558
3695
  const be = {
3559
3696
  // asn.1 DER encoding utils
3560
- Err: zr,
3697
+ Err: jr,
3561
3698
  // Basic building block is TLV (Tag-Length-Value)
3562
3699
  _tlv: {
3563
3700
  encode: (r, e) => {
@@ -3566,11 +3703,11 @@ const be = {
3566
3703
  throw new s("tlv.encode: wrong tag");
3567
3704
  if (e.length & 1)
3568
3705
  throw new s("tlv.encode: unpadded data");
3569
- const t = e.length / 2, n = Ue(t);
3706
+ const t = e.length / 2, n = He(t);
3570
3707
  if (n.length / 2 & 128)
3571
3708
  throw new s("tlv.encode: long form length too big");
3572
- const o = t > 127 ? Ue(n.length / 2 | 128) : "";
3573
- return Ue(r) + o + n + e;
3709
+ const o = t > 127 ? He(n.length / 2 | 128) : "";
3710
+ return He(r) + o + n + e;
3574
3711
  },
3575
3712
  // v - value, l - left bytes (unparsed)
3576
3713
  decode(r, e) {
@@ -3615,7 +3752,7 @@ const be = {
3615
3752
  const { Err: e } = be;
3616
3753
  if (r < xe)
3617
3754
  throw new e("integer: negative integers are not allowed");
3618
- let s = Ue(r);
3755
+ let s = He(r);
3619
3756
  if (Number.parseInt(s[0], 16) & 8 && (s = "00" + s), s.length & 1)
3620
3757
  throw new e("unexpected DER parsing assertion: unpadded hex");
3621
3758
  return s;
@@ -3626,11 +3763,11 @@ const be = {
3626
3763
  throw new e("invalid signature integer: negative");
3627
3764
  if (r[0] === 0 && !(r[1] & 128))
3628
3765
  throw new e("invalid signature integer: unnecessary leading zero");
3629
- return ze(r);
3766
+ return je(r);
3630
3767
  }
3631
3768
  },
3632
3769
  toSig(r) {
3633
- const { Err: e, _int: s, _tlv: t } = be, n = V(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
3770
+ const { Err: e, _int: s, _tlv: t } = be, n = q(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
3634
3771
  if (i.length)
3635
3772
  throw new e("invalid signature: left bytes after parsing");
3636
3773
  const { v: a, l: c } = t.decode(2, o), { v: l, l: u } = t.decode(2, c);
@@ -3642,12 +3779,12 @@ const be = {
3642
3779
  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;
3643
3780
  return e.encode(48, o);
3644
3781
  }
3645
- }, xe = BigInt(0), Re = BigInt(1), Es = BigInt(2), He = BigInt(3), jr = BigInt(4);
3646
- function Yr(r, e = {}) {
3647
- const s = qr("weierstrass", r, e), { Fp: t, Fn: n } = s;
3782
+ }, xe = BigInt(0), Pe = BigInt(1), As = BigInt(2), Fe = BigInt(3), Yr = BigInt(4);
3783
+ function Xr(r, e = {}) {
3784
+ const s = Kr("weierstrass", r, e), { Fp: t, Fn: n } = s;
3648
3785
  let o = s.CURVE;
3649
3786
  const { h: i, n: a } = o;
3650
- xt(e, {}, {
3787
+ gt(e, {}, {
3651
3788
  allowInfinityPoint: "boolean",
3652
3789
  clearCofactor: "function",
3653
3790
  isTorsionFree: "function",
@@ -3658,87 +3795,87 @@ function Yr(r, e = {}) {
3658
3795
  const { endo: c } = e;
3659
3796
  if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
3660
3797
  throw new Error('invalid endo: expected "beta": bigint and "basises": array');
3661
- const l = Ts(t, n);
3798
+ const l = Rs(t, n);
3662
3799
  function u() {
3663
3800
  if (!t.isOdd)
3664
3801
  throw new Error("compression is not supported: Field does not have .isOdd()");
3665
3802
  }
3666
3803
  function h(I, x, g) {
3667
- const { x: v, y: k } = x.toAffine(), D = t.toBytes(v);
3668
- if (qe(g, "isCompressed"), g) {
3804
+ const { x: v, y: A } = x.toAffine(), C = t.toBytes(v);
3805
+ if (Ke(g, "isCompressed"), g) {
3669
3806
  u();
3670
- const C = !t.isOdd(k);
3671
- return ve(Is(C), D);
3807
+ const O = !t.isOdd(A);
3808
+ return Se(Ts(O), C);
3672
3809
  } else
3673
- return ve(Uint8Array.of(4), D, t.toBytes(k));
3810
+ return Se(Uint8Array.of(4), C, t.toBytes(A));
3674
3811
  }
3675
3812
  function _(I) {
3676
- V(I, void 0, "Point");
3677
- const { publicKey: x, publicKeyUncompressed: g } = l, v = I.length, k = I[0], D = I.subarray(1);
3678
- if (v === x && (k === 2 || k === 3)) {
3679
- const C = t.fromBytes(D);
3680
- if (!t.isValid(C))
3813
+ q(I, void 0, "Point");
3814
+ const { publicKey: x, publicKeyUncompressed: g } = l, v = I.length, A = I[0], C = I.subarray(1);
3815
+ if (v === x && (A === 2 || A === 3)) {
3816
+ const O = t.fromBytes(C);
3817
+ if (!t.isValid(O))
3681
3818
  throw new Error("bad point: is not on curve, wrong x");
3682
- const M = b(C);
3683
- let R;
3819
+ const L = E(O);
3820
+ let P;
3684
3821
  try {
3685
- R = t.sqrt(M);
3686
- } catch (J) {
3687
- const K = J instanceof Error ? ": " + J.message : "";
3688
- throw new Error("bad point: is not on curve, sqrt error" + K);
3822
+ P = t.sqrt(L);
3823
+ } catch (Y) {
3824
+ const W = Y instanceof Error ? ": " + Y.message : "";
3825
+ throw new Error("bad point: is not on curve, sqrt error" + W);
3689
3826
  }
3690
3827
  u();
3691
- const $ = t.isOdd(R);
3692
- return (k & 1) === 1 !== $ && (R = t.neg(R)), { x: C, y: R };
3693
- } else if (v === g && k === 4) {
3694
- const C = t.BYTES, M = t.fromBytes(D.subarray(0, C)), R = t.fromBytes(D.subarray(C, C * 2));
3695
- if (!y(M, R))
3828
+ const D = t.isOdd(P);
3829
+ return (A & 1) === 1 !== D && (P = t.neg(P)), { x: O, y: P };
3830
+ } else if (v === g && A === 4) {
3831
+ const O = t.BYTES, L = t.fromBytes(C.subarray(0, O)), P = t.fromBytes(C.subarray(O, O * 2));
3832
+ if (!y(L, P))
3696
3833
  throw new Error("bad point: is not on curve");
3697
- return { x: M, y: R };
3834
+ return { x: L, y: P };
3698
3835
  } else
3699
3836
  throw new Error(`bad point: got length ${v}, expected compressed=${x} or uncompressed=${g}`);
3700
3837
  }
3701
3838
  const f = e.toBytes || h, w = e.fromBytes || _;
3702
- function b(I) {
3839
+ function E(I) {
3703
3840
  const x = t.sqr(I), g = t.mul(x, I);
3704
3841
  return t.add(t.add(g, t.mul(I, o.a)), o.b);
3705
3842
  }
3706
3843
  function y(I, x) {
3707
- const g = t.sqr(x), v = b(I);
3844
+ const g = t.sqr(x), v = E(I);
3708
3845
  return t.eql(g, v);
3709
3846
  }
3710
3847
  if (!y(o.Gx, o.Gy))
3711
3848
  throw new Error("bad curve params: generator point");
3712
- const T = t.mul(t.pow(o.a, He), jr), N = t.mul(t.sqr(o.b), BigInt(27));
3713
- if (t.is0(t.add(T, N)))
3849
+ const R = t.mul(t.pow(o.a, Fe), Yr), N = t.mul(t.sqr(o.b), BigInt(27));
3850
+ if (t.is0(t.add(R, N)))
3714
3851
  throw new Error("bad curve params: a or b");
3715
- function W(I, x, g = !1) {
3852
+ function F(I, x, g = !1) {
3716
3853
  if (!t.isValid(x) || g && t.is0(x))
3717
3854
  throw new Error(`bad point coordinate ${I}`);
3718
3855
  return x;
3719
3856
  }
3720
- function B(I) {
3721
- if (!(I instanceof L))
3857
+ function M(I) {
3858
+ if (!(I instanceof z))
3722
3859
  throw new Error("Weierstrass Point expected");
3723
3860
  }
3724
- function j(I) {
3861
+ function V(I) {
3725
3862
  if (!c || !c.basises)
3726
3863
  throw new Error("no endo");
3727
- return Vr(I, c.basises, n.ORDER);
3864
+ return zr(I, c.basises, n.ORDER);
3728
3865
  }
3729
- const q = Mt((I, x) => {
3730
- const { X: g, Y: v, Z: k } = I;
3731
- if (t.eql(k, t.ONE))
3866
+ const G = Bt((I, x) => {
3867
+ const { X: g, Y: v, Z: A } = I;
3868
+ if (t.eql(A, t.ONE))
3732
3869
  return { x: g, y: v };
3733
- const D = I.is0();
3734
- x == null && (x = D ? t.ONE : t.inv(k));
3735
- const C = t.mul(g, x), M = t.mul(v, x), R = t.mul(k, x);
3736
- if (D)
3870
+ const C = I.is0();
3871
+ x == null && (x = C ? t.ONE : t.inv(A));
3872
+ const O = t.mul(g, x), L = t.mul(v, x), P = t.mul(A, x);
3873
+ if (C)
3737
3874
  return { x: t.ZERO, y: t.ZERO };
3738
- if (!t.eql(R, t.ONE))
3875
+ if (!t.eql(P, t.ONE))
3739
3876
  throw new Error("invZ was invalid");
3740
- return { x: C, y: M };
3741
- }), P = Mt((I) => {
3877
+ return { x: O, y: L };
3878
+ }), J = Bt((I) => {
3742
3879
  if (I.is0()) {
3743
3880
  if (e.allowInfinityPoint && !t.is0(I.Y))
3744
3881
  return;
@@ -3753,16 +3890,16 @@ function Yr(r, e = {}) {
3753
3890
  throw new Error("bad point: not in prime-order subgroup");
3754
3891
  return !0;
3755
3892
  });
3756
- function S(I, x, g, v, k) {
3757
- return g = new L(t.mul(g.X, I), g.Y, g.Z), x = Ke(v, x), g = Ke(k, g), x.add(g);
3893
+ function H(I, x, g, v, A) {
3894
+ return g = new z(t.mul(g.X, I), g.Y, g.Z), x = Ve(v, x), g = Ve(A, g), x.add(g);
3758
3895
  }
3759
- const A = class A {
3896
+ const S = class S {
3760
3897
  /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
3761
3898
  constructor(x, g, v) {
3762
- E(this, "X");
3763
- E(this, "Y");
3764
- E(this, "Z");
3765
- this.X = W("x", x), this.Y = W("y", g, !0), this.Z = W("z", v), Object.freeze(this);
3899
+ T(this, "X");
3900
+ T(this, "Y");
3901
+ T(this, "Z");
3902
+ this.X = F("x", x), this.Y = F("y", g, !0), this.Z = F("z", v), Object.freeze(this);
3766
3903
  }
3767
3904
  static CURVE() {
3768
3905
  return o;
@@ -3772,16 +3909,16 @@ function Yr(r, e = {}) {
3772
3909
  const { x: g, y: v } = x || {};
3773
3910
  if (!x || !t.isValid(g) || !t.isValid(v))
3774
3911
  throw new Error("invalid affine point");
3775
- if (x instanceof A)
3912
+ if (x instanceof S)
3776
3913
  throw new Error("projective point not allowed");
3777
- return t.is0(g) && t.is0(v) ? A.ZERO : new A(g, v, t.ONE);
3914
+ return t.is0(g) && t.is0(v) ? S.ZERO : new S(g, v, t.ONE);
3778
3915
  }
3779
3916
  static fromBytes(x) {
3780
- const g = A.fromAffine(w(V(x, void 0, "point")));
3917
+ const g = S.fromAffine(w(q(x, void 0, "point")));
3781
3918
  return g.assertValidity(), g;
3782
3919
  }
3783
3920
  static fromHex(x) {
3784
- return A.fromBytes(We(x));
3921
+ return S.fromBytes(qe(x));
3785
3922
  }
3786
3923
  get x() {
3787
3924
  return this.toAffine().x;
@@ -3796,12 +3933,12 @@ function Yr(r, e = {}) {
3796
3933
  * @returns
3797
3934
  */
3798
3935
  precompute(x = 8, g = !0) {
3799
- return O.createCache(this, x), g || this.multiply(He), this;
3936
+ return b.createCache(this, x), g || this.multiply(Fe), this;
3800
3937
  }
3801
3938
  // TODO: return `this`
3802
3939
  /** A point on curve is valid if it conforms to equation. */
3803
3940
  assertValidity() {
3804
- P(this);
3941
+ J(this);
3805
3942
  }
3806
3943
  hasEvenY() {
3807
3944
  const { y: x } = this.toAffine();
@@ -3811,42 +3948,42 @@ function Yr(r, e = {}) {
3811
3948
  }
3812
3949
  /** Compare one point to another. */
3813
3950
  equals(x) {
3814
- B(x);
3815
- 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));
3816
- return R && $;
3951
+ M(x);
3952
+ const { X: g, Y: v, Z: A } = this, { X: C, Y: O, Z: L } = x, P = t.eql(t.mul(g, L), t.mul(C, A)), D = t.eql(t.mul(v, L), t.mul(O, A));
3953
+ return P && D;
3817
3954
  }
3818
3955
  /** Flips point to one corresponding to (x, -y) in Affine coordinates. */
3819
3956
  negate() {
3820
- return new A(this.X, t.neg(this.Y), this.Z);
3957
+ return new S(this.X, t.neg(this.Y), this.Z);
3821
3958
  }
3822
3959
  // Renes-Costello-Batina exception-free doubling formula.
3823
3960
  // There is 30% faster Jacobian formula, but it is not complete.
3824
3961
  // https://eprint.iacr.org/2015/1060, algorithm 3
3825
3962
  // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
3826
3963
  double() {
3827
- const { a: x, b: g } = o, v = t.mul(g, He), { X: k, Y: D, Z: C } = this;
3828
- 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);
3829
- 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, $);
3964
+ const { a: x, b: g } = o, v = t.mul(g, Fe), { X: A, Y: C, Z: O } = this;
3965
+ let L = t.ZERO, P = t.ZERO, D = t.ZERO, U = t.mul(A, A), Y = t.mul(C, C), W = t.mul(O, O), B = t.mul(A, C);
3966
+ return B = t.add(B, B), D = t.mul(A, O), D = t.add(D, D), L = t.mul(x, D), P = t.mul(v, W), P = t.add(L, P), L = t.sub(Y, P), P = t.add(Y, P), P = t.mul(L, P), L = t.mul(B, L), D = t.mul(v, D), W = t.mul(x, W), B = t.sub(U, W), B = t.mul(x, B), B = t.add(B, D), D = t.add(U, U), U = t.add(D, U), U = t.add(U, W), U = t.mul(U, B), P = t.add(P, U), W = t.mul(C, O), W = t.add(W, W), U = t.mul(W, B), L = t.sub(L, U), D = t.mul(W, Y), D = t.add(D, D), D = t.add(D, D), new S(L, P, D);
3830
3967
  }
3831
3968
  // Renes-Costello-Batina exception-free addition formula.
3832
3969
  // There is 30% faster Jacobian formula, but it is not complete.
3833
3970
  // https://eprint.iacr.org/2015/1060, algorithm 1
3834
3971
  // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
3835
3972
  add(x) {
3836
- B(x);
3837
- const { X: g, Y: v, Z: k } = this, { X: D, Y: C, Z: M } = x;
3838
- let R = t.ZERO, $ = t.ZERO, F = t.ZERO;
3839
- const J = o.a, K = t.mul(o.b, He);
3840
- 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);
3841
- oe = t.mul(oe, z), z = t.add(H, X), oe = t.sub(oe, z), z = t.add(g, k);
3842
- let Q = t.add(D, M);
3843
- 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);
3973
+ M(x);
3974
+ const { X: g, Y: v, Z: A } = this, { X: C, Y: O, Z: L } = x;
3975
+ let P = t.ZERO, D = t.ZERO, U = t.ZERO;
3976
+ const Y = o.a, W = t.mul(o.b, Fe);
3977
+ let B = t.mul(g, C), X = t.mul(v, O), Z = t.mul(A, L), oe = t.add(g, v), K = t.add(C, O);
3978
+ oe = t.mul(oe, K), K = t.add(B, X), oe = t.sub(oe, K), K = t.add(g, A);
3979
+ let Q = t.add(C, L);
3980
+ return K = t.mul(K, Q), Q = t.add(B, Z), K = t.sub(K, Q), Q = t.add(v, A), P = t.add(O, L), Q = t.mul(Q, P), P = t.add(X, Z), Q = t.sub(Q, P), U = t.mul(Y, K), P = t.mul(W, Z), U = t.add(P, U), P = t.sub(X, U), U = t.add(X, U), D = t.mul(P, U), X = t.add(B, B), X = t.add(X, B), Z = t.mul(Y, Z), K = t.mul(W, K), X = t.add(X, Z), Z = t.sub(B, Z), Z = t.mul(Y, Z), K = t.add(K, Z), B = t.mul(X, K), D = t.add(D, B), B = t.mul(Q, K), P = t.mul(oe, P), P = t.sub(P, B), B = t.mul(oe, X), U = t.mul(Q, U), U = t.add(U, B), new S(P, D, U);
3844
3981
  }
3845
3982
  subtract(x) {
3846
3983
  return this.add(x.negate());
3847
3984
  }
3848
3985
  is0() {
3849
- return this.equals(A.ZERO);
3986
+ return this.equals(S.ZERO);
3850
3987
  }
3851
3988
  /**
3852
3989
  * Constant time multiplication.
@@ -3861,16 +3998,16 @@ function Yr(r, e = {}) {
3861
3998
  const { endo: g } = e;
3862
3999
  if (!n.isValidNot0(x))
3863
4000
  throw new Error("invalid scalar: out of range");
3864
- let v, k;
3865
- const D = (C) => O.cached(this, C, (M) => Ut(A, M));
4001
+ let v, A;
4002
+ const C = (O) => b.cached(this, O, (L) => Ft(S, L));
3866
4003
  if (g) {
3867
- const { k1neg: C, k1: M, k2neg: R, k2: $ } = j(x), { p: F, f: J } = D(M), { p: K, f: H } = D($);
3868
- k = J.add(H), v = S(g.beta, F, K, C, R);
4004
+ const { k1neg: O, k1: L, k2neg: P, k2: D } = V(x), { p: U, f: Y } = C(L), { p: W, f: B } = C(D);
4005
+ A = Y.add(B), v = H(g.beta, U, W, O, P);
3869
4006
  } else {
3870
- const { p: C, f: M } = D(x);
3871
- v = C, k = M;
4007
+ const { p: O, f: L } = C(x);
4008
+ v = O, A = L;
3872
4009
  }
3873
- return Ut(A, [v, k])[0];
4010
+ return Ft(S, [v, A])[0];
3874
4011
  }
3875
4012
  /**
3876
4013
  * Non-constant-time multiplication. Uses double-and-add algorithm.
@@ -3882,23 +4019,23 @@ function Yr(r, e = {}) {
3882
4019
  if (!n.isValid(x))
3883
4020
  throw new Error("invalid scalar: out of range");
3884
4021
  if (x === xe || v.is0())
3885
- return A.ZERO;
3886
- if (x === Re)
4022
+ return S.ZERO;
4023
+ if (x === Pe)
3887
4024
  return v;
3888
- if (O.hasCache(this))
4025
+ if (b.hasCache(this))
3889
4026
  return this.multiply(x);
3890
4027
  if (g) {
3891
- const { k1neg: k, k1: D, k2neg: C, k2: M } = j(x), { p1: R, p2: $ } = Wr(A, v, D, M);
3892
- return S(g.beta, R, $, k, C);
4028
+ const { k1neg: A, k1: C, k2neg: O, k2: L } = V(x), { p1: P, p2: D } = qr(S, v, C, L);
4029
+ return H(g.beta, P, D, A, O);
3893
4030
  } else
3894
- return O.unsafe(v, x);
4031
+ return b.unsafe(v, x);
3895
4032
  }
3896
4033
  /**
3897
4034
  * Converts Projective point to affine (x, y) coordinates.
3898
4035
  * @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
3899
4036
  */
3900
4037
  toAffine(x) {
3901
- return q(this, x);
4038
+ return G(this, x);
3902
4039
  }
3903
4040
  /**
3904
4041
  * Checks whether Point is free of torsion elements (is in prime subgroup).
@@ -3906,39 +4043,39 @@ function Yr(r, e = {}) {
3906
4043
  */
3907
4044
  isTorsionFree() {
3908
4045
  const { isTorsionFree: x } = e;
3909
- return i === Re ? !0 : x ? x(A, this) : O.unsafe(this, a).is0();
4046
+ return i === Pe ? !0 : x ? x(S, this) : b.unsafe(this, a).is0();
3910
4047
  }
3911
4048
  clearCofactor() {
3912
4049
  const { clearCofactor: x } = e;
3913
- return i === Re ? this : x ? x(A, this) : this.multiplyUnsafe(i);
4050
+ return i === Pe ? this : x ? x(S, this) : this.multiplyUnsafe(i);
3914
4051
  }
3915
4052
  isSmallOrder() {
3916
4053
  return this.multiplyUnsafe(i).is0();
3917
4054
  }
3918
4055
  toBytes(x = !0) {
3919
- return qe(x, "isCompressed"), this.assertValidity(), f(A, this, x);
4056
+ return Ke(x, "isCompressed"), this.assertValidity(), f(S, this, x);
3920
4057
  }
3921
4058
  toHex(x = !0) {
3922
- return Me(this.toBytes(x));
4059
+ return $e(this.toBytes(x));
3923
4060
  }
3924
4061
  toString() {
3925
4062
  return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
3926
4063
  }
3927
4064
  };
3928
4065
  // base / generator point
3929
- E(A, "BASE", new A(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
3930
- E(A, "ZERO", new A(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
4066
+ T(S, "BASE", new S(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
4067
+ T(S, "ZERO", new S(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
3931
4068
  // math field
3932
- E(A, "Fp", t), // scalar field
3933
- E(A, "Fn", n);
3934
- let L = A;
3935
- const G = n.BITS, O = new Gr(L, e.endo ? Math.ceil(G / 2) : G);
3936
- return L.BASE.precompute(8), L;
4069
+ T(S, "Fp", t), // scalar field
4070
+ T(S, "Fn", n);
4071
+ let z = S;
4072
+ const k = n.BITS, b = new Wr(z, e.endo ? Math.ceil(k / 2) : k);
4073
+ return z.BASE.precompute(8), z;
3937
4074
  }
3938
- function Is(r) {
4075
+ function Ts(r) {
3939
4076
  return Uint8Array.of(r ? 2 : 3);
3940
4077
  }
3941
- function Ts(r, e) {
4078
+ function Rs(r, e) {
3942
4079
  return {
3943
4080
  secretKey: e.BYTES,
3944
4081
  publicKey: 1 + r.BYTES,
@@ -3948,7 +4085,7 @@ function Ts(r, e) {
3948
4085
  };
3949
4086
  }
3950
4087
  function Jr(r, e = {}) {
3951
- const { Fn: s } = r, t = e.randomBytes || os, n = Object.assign(Ts(r.Fp, s), { seed: ws(s.ORDER) });
4088
+ const { Fn: s } = r, t = e.randomBytes || as, n = Object.assign(Rs(r.Fp, s), { seed: bs(s.ORDER) });
3952
4089
  function o(f) {
3953
4090
  try {
3954
4091
  const w = s.fromBytes(f);
@@ -3958,99 +4095,99 @@ function Jr(r, e = {}) {
3958
4095
  }
3959
4096
  }
3960
4097
  function i(f, w) {
3961
- const { publicKey: b, publicKeyUncompressed: y } = n;
4098
+ const { publicKey: E, publicKeyUncompressed: y } = n;
3962
4099
  try {
3963
- const T = f.length;
3964
- return w === !0 && T !== b || w === !1 && T !== y ? !1 : !!r.fromBytes(f);
4100
+ const R = f.length;
4101
+ return w === !0 && R !== E || w === !1 && R !== y ? !1 : !!r.fromBytes(f);
3965
4102
  } catch {
3966
4103
  return !1;
3967
4104
  }
3968
4105
  }
3969
4106
  function a(f = t(n.seed)) {
3970
- return Fr(V(f, n.seed, "seed"), s.ORDER);
4107
+ return Gr(q(f, n.seed, "seed"), s.ORDER);
3971
4108
  }
3972
4109
  function c(f, w = !0) {
3973
4110
  return r.BASE.multiply(s.fromBytes(f)).toBytes(w);
3974
4111
  }
3975
4112
  function l(f) {
3976
- const { secretKey: w, publicKey: b, publicKeyUncompressed: y } = n;
3977
- if (!ht(f) || "_lengths" in s && s._lengths || w === b)
4113
+ const { secretKey: w, publicKey: E, publicKeyUncompressed: y } = n;
4114
+ if (!pt(f) || "_lengths" in s && s._lengths || w === E)
3978
4115
  return;
3979
- const T = V(f, void 0, "key").length;
3980
- return T === b || T === y;
4116
+ const R = q(f, void 0, "key").length;
4117
+ return R === E || R === y;
3981
4118
  }
3982
- function u(f, w, b = !0) {
4119
+ function u(f, w, E = !0) {
3983
4120
  if (l(f) === !0)
3984
4121
  throw new Error("first arg must be private key");
3985
4122
  if (l(w) === !1)
3986
4123
  throw new Error("second arg must be public key");
3987
4124
  const y = s.fromBytes(f);
3988
- return r.fromBytes(w).multiply(y).toBytes(b);
4125
+ return r.fromBytes(w).multiply(y).toBytes(E);
3989
4126
  }
3990
4127
  const h = {
3991
4128
  isValidSecretKey: o,
3992
4129
  isValidPublicKey: i,
3993
4130
  randomSecretKey: a
3994
- }, _ = Kr(a, c);
4131
+ }, _ = Vr(a, c);
3995
4132
  return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen: _, Point: r, utils: h, lengths: n });
3996
4133
  }
3997
- function Xr(r, e, s = {}) {
3998
- ts(e), xt(s, {}, {
4134
+ function Zr(r, e, s = {}) {
4135
+ rs(e), gt(s, {}, {
3999
4136
  hmac: "function",
4000
4137
  lowS: "boolean",
4001
4138
  randomBytes: "function",
4002
4139
  bits2int: "function",
4003
4140
  bits2int_modN: "function"
4004
4141
  }), s = Object.assign({}, s);
4005
- 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 = {
4142
+ const t = s.randomBytes || as, n = s.hmac || ((x, g) => Is(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 = {
4006
4143
  prehash: !0,
4007
4144
  lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
4008
4145
  format: "compact",
4009
4146
  extraEntropy: !1
4010
- }, b = a * Es < o.ORDER;
4147
+ }, E = a * As < o.ORDER;
4011
4148
  function y(x) {
4012
- const g = a >> Re;
4149
+ const g = a >> Pe;
4013
4150
  return x > g;
4014
4151
  }
4015
- function T(x, g) {
4152
+ function R(x, g) {
4016
4153
  if (!i.isValidNot0(g))
4017
4154
  throw new Error(`invalid signature ${x}: out of range 1..Point.Fn.ORDER`);
4018
4155
  return g;
4019
4156
  }
4020
4157
  function N() {
4021
- if (b)
4158
+ if (E)
4022
4159
  throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
4023
4160
  }
4024
- function W(x, g) {
4025
- lt(g);
4026
- const v = f.signature, k = g === "compact" ? v : g === "recovered" ? v + 1 : void 0;
4027
- return V(x, k);
4028
- }
4029
- class B {
4030
- constructor(g, v, k) {
4031
- E(this, "r");
4032
- E(this, "s");
4033
- E(this, "recovery");
4034
- if (this.r = T("r", g), this.s = T("s", v), k != null) {
4035
- if (N(), ![0, 1, 2, 3].includes(k))
4161
+ function F(x, g) {
4162
+ dt(g);
4163
+ const v = f.signature, A = g === "compact" ? v : g === "recovered" ? v + 1 : void 0;
4164
+ return q(x, A);
4165
+ }
4166
+ class M {
4167
+ constructor(g, v, A) {
4168
+ T(this, "r");
4169
+ T(this, "s");
4170
+ T(this, "recovery");
4171
+ if (this.r = R("r", g), this.s = R("s", v), A != null) {
4172
+ if (N(), ![0, 1, 2, 3].includes(A))
4036
4173
  throw new Error("invalid recovery id");
4037
- this.recovery = k;
4174
+ this.recovery = A;
4038
4175
  }
4039
4176
  Object.freeze(this);
4040
4177
  }
4041
4178
  static fromBytes(g, v = w.format) {
4042
- W(g, v);
4043
- let k;
4179
+ F(g, v);
4180
+ let A;
4044
4181
  if (v === "der") {
4045
- const { r: R, s: $ } = be.toSig(V(g));
4046
- return new B(R, $);
4182
+ const { r: P, s: D } = be.toSig(q(g));
4183
+ return new M(P, D);
4047
4184
  }
4048
- v === "recovered" && (k = g[0], v = "compact", g = g.subarray(1));
4049
- const D = f.signature / 2, C = g.subarray(0, D), M = g.subarray(D, D * 2);
4050
- return new B(i.fromBytes(C), i.fromBytes(M), k);
4185
+ v === "recovered" && (A = g[0], v = "compact", g = g.subarray(1));
4186
+ const C = f.signature / 2, O = g.subarray(0, C), L = g.subarray(C, C * 2);
4187
+ return new M(i.fromBytes(O), i.fromBytes(L), A);
4051
4188
  }
4052
4189
  static fromHex(g, v) {
4053
- return this.fromBytes(We(g), v);
4190
+ return this.fromBytes(qe(g), v);
4054
4191
  }
4055
4192
  assertRecovery() {
4056
4193
  const { recovery: g } = this;
@@ -4059,96 +4196,96 @@ function Xr(r, e, s = {}) {
4059
4196
  return g;
4060
4197
  }
4061
4198
  addRecoveryBit(g) {
4062
- return new B(this.r, this.s, g);
4199
+ return new M(this.r, this.s, g);
4063
4200
  }
4064
4201
  recoverPublicKey(g) {
4065
- const { r: v, s: k } = this, D = this.assertRecovery(), C = D === 2 || D === 3 ? v + a : v;
4066
- if (!o.isValid(C))
4202
+ const { r: v, s: A } = this, C = this.assertRecovery(), O = C === 2 || C === 3 ? v + a : v;
4203
+ if (!o.isValid(O))
4067
4204
  throw new Error("invalid recovery id: sig.r+curve.n != R.x");
4068
- 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));
4069
- if (H.is0())
4205
+ const L = o.toBytes(O), P = r.fromBytes(Se(Ts((C & 1) === 0), L)), D = i.inv(O), U = G(q(g, void 0, "msgHash")), Y = i.create(-U * D), W = i.create(A * D), B = r.BASE.multiplyUnsafe(Y).add(P.multiplyUnsafe(W));
4206
+ if (B.is0())
4070
4207
  throw new Error("invalid recovery: point at infinify");
4071
- return H.assertValidity(), H;
4208
+ return B.assertValidity(), B;
4072
4209
  }
4073
4210
  // Signatures should be low-s, to prevent malleability.
4074
4211
  hasHighS() {
4075
4212
  return y(this.s);
4076
4213
  }
4077
4214
  toBytes(g = w.format) {
4078
- if (lt(g), g === "der")
4079
- return We(be.hexFromSig(this));
4080
- const { r: v, s: k } = this, D = i.toBytes(v), C = i.toBytes(k);
4081
- return g === "recovered" ? (N(), ve(Uint8Array.of(this.assertRecovery()), D, C)) : ve(D, C);
4215
+ if (dt(g), g === "der")
4216
+ return qe(be.hexFromSig(this));
4217
+ const { r: v, s: A } = this, C = i.toBytes(v), O = i.toBytes(A);
4218
+ return g === "recovered" ? (N(), Se(Uint8Array.of(this.assertRecovery()), C, O)) : Se(C, O);
4082
4219
  }
4083
4220
  toHex(g) {
4084
- return Me(this.toBytes(g));
4221
+ return $e(this.toBytes(g));
4085
4222
  }
4086
4223
  }
4087
- const j = s.bits2int || function(g) {
4224
+ const V = s.bits2int || function(g) {
4088
4225
  if (g.length > 8192)
4089
4226
  throw new Error("input is too large");
4090
- const v = ze(g), k = g.length * 8 - c;
4091
- return k > 0 ? v >> BigInt(k) : v;
4092
- }, q = s.bits2int_modN || function(g) {
4093
- return i.create(j(g));
4094
- }, P = _t(c);
4095
- function S(x) {
4096
- return Rr("num < 2^" + c, x, xe, P), i.toBytes(x);
4097
- }
4098
- function L(x, g) {
4099
- return V(x, void 0, "message"), g ? V(e(x), void 0, "prehashed message") : x;
4100
- }
4101
- function G(x, g, v) {
4102
- const { lowS: k, prehash: D, extraEntropy: C } = rt(v, w);
4103
- x = L(x, D);
4104
- const M = q(x), R = i.fromBytes(g);
4105
- if (!i.isValidNot0(R))
4227
+ const v = je(g), A = g.length * 8 - c;
4228
+ return A > 0 ? v >> BigInt(A) : v;
4229
+ }, G = s.bits2int_modN || function(g) {
4230
+ return i.create(V(g));
4231
+ }, J = xt(c);
4232
+ function H(x) {
4233
+ return kr("num < 2^" + c, x, xe, J), i.toBytes(x);
4234
+ }
4235
+ function z(x, g) {
4236
+ return q(x, void 0, "message"), g ? q(e(x), void 0, "prehashed message") : x;
4237
+ }
4238
+ function k(x, g, v) {
4239
+ const { lowS: A, prehash: C, extraEntropy: O } = rt(v, w);
4240
+ x = z(x, C);
4241
+ const L = G(x), P = i.fromBytes(g);
4242
+ if (!i.isValidNot0(P))
4106
4243
  throw new Error("invalid private key");
4107
- const $ = [S(R), S(M)];
4108
- if (C != null && C !== !1) {
4109
- const H = C === !0 ? t(f.secretKey) : C;
4110
- $.push(V(H, void 0, "extraEntropy"));
4111
- }
4112
- const F = ve(...$), J = M;
4113
- function K(H) {
4114
- const X = j(H);
4244
+ const D = [H(P), H(L)];
4245
+ if (O != null && O !== !1) {
4246
+ const B = O === !0 ? t(f.secretKey) : O;
4247
+ D.push(q(B, void 0, "extraEntropy"));
4248
+ }
4249
+ const U = Se(...D), Y = L;
4250
+ function W(B) {
4251
+ const X = V(B);
4115
4252
  if (!i.isValidNot0(X))
4116
4253
  return;
4117
- const Z = i.inv(X), oe = r.BASE.multiply(X).toAffine(), z = i.create(oe.x);
4118
- if (z === xe)
4254
+ const Z = i.inv(X), oe = r.BASE.multiply(X).toAffine(), K = i.create(oe.x);
4255
+ if (K === xe)
4119
4256
  return;
4120
- const Q = i.create(Z * i.create(J + z * R));
4257
+ const Q = i.create(Z * i.create(Y + K * P));
4121
4258
  if (Q === xe)
4122
4259
  return;
4123
- let bt = (oe.x === z ? 0 : 2) | Number(oe.y & Re), vt = Q;
4124
- return k && y(Q) && (vt = i.neg(Q), bt ^= 1), new B(z, vt, b ? void 0 : bt);
4260
+ let St = (oe.x === K ? 0 : 2) | Number(oe.y & Pe), vt = Q;
4261
+ return A && y(Q) && (vt = i.neg(Q), St ^= 1), new M(K, vt, E ? void 0 : St);
4125
4262
  }
4126
- return { seed: F, k2sig: K };
4263
+ return { seed: U, k2sig: W };
4127
4264
  }
4128
- function O(x, g, v = {}) {
4129
- const { seed: k, k2sig: D } = G(x, g, v);
4130
- return Pr(e.outputLen, i.BYTES, n)(k, D).toBytes(v.format);
4265
+ function b(x, g, v = {}) {
4266
+ const { seed: A, k2sig: C } = k(x, g, v);
4267
+ return Or(e.outputLen, i.BYTES, n)(A, C).toBytes(v.format);
4131
4268
  }
4132
- function A(x, g, v, k = {}) {
4133
- const { lowS: D, prehash: C, format: M } = rt(k, w);
4134
- if (v = V(v, void 0, "publicKey"), g = L(g, C), !ht(x)) {
4135
- const R = x instanceof B ? ", use sig.toBytes()" : "";
4136
- throw new Error("verify expects Uint8Array signature" + R);
4269
+ function S(x, g, v, A = {}) {
4270
+ const { lowS: C, prehash: O, format: L } = rt(A, w);
4271
+ if (v = q(v, void 0, "publicKey"), g = z(g, O), !pt(x)) {
4272
+ const P = x instanceof M ? ", use sig.toBytes()" : "";
4273
+ throw new Error("verify expects Uint8Array signature" + P);
4137
4274
  }
4138
- W(x, M);
4275
+ F(x, L);
4139
4276
  try {
4140
- const R = B.fromBytes(x, M), $ = r.fromBytes(v);
4141
- if (D && R.hasHighS())
4277
+ const P = M.fromBytes(x, L), D = r.fromBytes(v);
4278
+ if (C && P.hasHighS())
4142
4279
  return !1;
4143
- 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));
4144
- return oe.is0() ? !1 : i.create(oe.x) === F;
4280
+ const { r: U, s: Y } = P, W = G(g), B = i.inv(Y), X = i.create(W * B), Z = i.create(U * B), oe = r.BASE.multiplyUnsafe(X).add(D.multiplyUnsafe(Z));
4281
+ return oe.is0() ? !1 : i.create(oe.x) === U;
4145
4282
  } catch {
4146
4283
  return !1;
4147
4284
  }
4148
4285
  }
4149
4286
  function I(x, g, v = {}) {
4150
- const { prehash: k } = rt(v, w);
4151
- return g = L(g, k), B.fromBytes(x, "recovered").recoverPublicKey(g).toBytes();
4287
+ const { prehash: A } = rt(v, w);
4288
+ return g = z(g, A), M.fromBytes(x, "recovered").recoverPublicKey(g).toBytes();
4152
4289
  }
4153
4290
  return Object.freeze({
4154
4291
  keygen: l,
@@ -4157,15 +4294,15 @@ function Xr(r, e, s = {}) {
4157
4294
  utils: _,
4158
4295
  lengths: f,
4159
4296
  Point: r,
4160
- sign: O,
4161
- verify: A,
4297
+ sign: b,
4298
+ verify: S,
4162
4299
  recoverPublicKey: I,
4163
- Signature: B,
4300
+ Signature: M,
4164
4301
  hash: e
4165
4302
  });
4166
4303
  }
4167
4304
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4168
- const mt = {
4305
+ const wt = {
4169
4306
  p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
4170
4307
  n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
4171
4308
  h: BigInt(1),
@@ -4173,44 +4310,44 @@ const mt = {
4173
4310
  b: BigInt(7),
4174
4311
  Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
4175
4312
  Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
4176
- }, Zr = {
4313
+ }, Qr = {
4177
4314
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
4178
4315
  basises: [
4179
4316
  [BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
4180
4317
  [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
4181
4318
  ]
4182
- }, qt = /* @__PURE__ */ BigInt(2);
4183
- function Qr(r) {
4184
- const e = mt.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);
4185
- if (!dt.eql(dt.sqr(q), r))
4319
+ }, Vt = /* @__PURE__ */ BigInt(2);
4320
+ function en(r) {
4321
+ const e = wt.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(_, Vt, e) * l % e, w = ae(f, n, e) * f % e, E = ae(w, o, e) * w % e, y = ae(E, a, e) * E % e, R = ae(y, c, e) * y % e, N = ae(R, a, e) * E % e, F = ae(N, s, e) * u % e, M = ae(F, i, e) * w % e, V = ae(M, t, e) * l % e, G = ae(V, Vt, e);
4322
+ if (!ut.eql(ut.sqr(G), r))
4186
4323
  throw new Error("Cannot find square root");
4187
- return q;
4188
- }
4189
- const dt = je(mt.p, { sqrt: Qr }), en = /* @__PURE__ */ Yr(mt, {
4190
- Fp: dt,
4191
- endo: Zr
4192
- }), 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 = [];
4193
- for (let r = 0, e = Ce, s = 1, t = 0; r < 24; r++) {
4194
- [s, t] = [t, (2 * s + 3 * t) % 5], As.push(2 * (5 * t + s)), Rs.push((r + 1) * (r + 2) / 2 % 64);
4195
- let n = sn;
4324
+ return G;
4325
+ }
4326
+ const ut = Ye(wt.p, { sqrt: en }), tn = /* @__PURE__ */ Xr(wt, {
4327
+ Fp: ut,
4328
+ endo: Qr
4329
+ }), sn = /* @__PURE__ */ Zr(tn, Ar), rn = BigInt(0), Le = BigInt(1), nn = BigInt(2), on = BigInt(7), an = BigInt(256), cn = BigInt(113), ks = [], Ps = [], Os = [];
4330
+ for (let r = 0, e = Le, s = 1, t = 0; r < 24; r++) {
4331
+ [s, t] = [t, (2 * s + 3 * t) % 5], ks.push(2 * (5 * t + s)), Ps.push((r + 1) * (r + 2) / 2 % 64);
4332
+ let n = rn;
4196
4333
  for (let o = 0; o < 7; o++)
4197
- e = (e << Ce ^ (e >> nn) * an) % on, e & rn && (n ^= Ce << (Ce << BigInt(o)) - Ce);
4198
- ks.push(n);
4334
+ e = (e << Le ^ (e >> on) * cn) % an, e & nn && (n ^= Le << (Le << BigInt(o)) - Le);
4335
+ Os.push(n);
4199
4336
  }
4200
- 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);
4201
- function dn(r, e = 24) {
4337
+ const Cs = mr(Os, !0), ln = Cs[0], dn = Cs[1], zt = (r, e, s) => s > 32 ? br(r, e, s) : wr(r, e, s), jt = (r, e, s) => s > 32 ? Sr(r, e, s) : yr(r, e, s);
4338
+ function un(r, e = 24) {
4202
4339
  const s = new Uint32Array(10);
4203
4340
  for (let t = 24 - e; t < 24; t++) {
4204
4341
  for (let i = 0; i < 10; i++)
4205
4342
  s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
4206
4343
  for (let i = 0; i < 10; i += 2) {
4207
- 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];
4344
+ const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], u = s[c + 1], h = zt(l, u, 1) ^ s[a], _ = jt(l, u, 1) ^ s[a + 1];
4208
4345
  for (let f = 0; f < 50; f += 10)
4209
4346
  r[i + f] ^= h, r[i + f + 1] ^= _;
4210
4347
  }
4211
4348
  let n = r[2], o = r[3];
4212
4349
  for (let i = 0; i < 24; i++) {
4213
- const a = Rs[i], c = Kt(n, o, a), l = Vt(n, o, a), u = As[i];
4350
+ const a = Ps[i], c = zt(n, o, a), l = jt(n, o, a), u = ks[i];
4214
4351
  n = r[u], o = r[u + 1], r[u] = c, r[u + 1] = l;
4215
4352
  }
4216
4353
  for (let i = 0; i < 50; i += 10) {
@@ -4219,36 +4356,36 @@ function dn(r, e = 24) {
4219
4356
  for (let a = 0; a < 10; a++)
4220
4357
  r[i + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
4221
4358
  }
4222
- r[0] ^= cn[t], r[1] ^= ln[t];
4359
+ r[0] ^= ln[t], r[1] ^= dn[t];
4223
4360
  }
4224
- Pe(s);
4361
+ Ce(s);
4225
4362
  }
4226
- class wt {
4363
+ class yt {
4227
4364
  // NOTE: we accept arguments in bytes instead of bits here.
4228
4365
  constructor(e, s, t, n = !1, o = 24) {
4229
- E(this, "state");
4230
- E(this, "pos", 0);
4231
- E(this, "posOut", 0);
4232
- E(this, "finished", !1);
4233
- E(this, "state32");
4234
- E(this, "destroyed", !1);
4235
- E(this, "blockLen");
4236
- E(this, "suffix");
4237
- E(this, "outputLen");
4238
- E(this, "enableXOF", !1);
4239
- E(this, "rounds");
4366
+ T(this, "state");
4367
+ T(this, "pos", 0);
4368
+ T(this, "posOut", 0);
4369
+ T(this, "finished", !1);
4370
+ T(this, "state32");
4371
+ T(this, "destroyed", !1);
4372
+ T(this, "blockLen");
4373
+ T(this, "suffix");
4374
+ T(this, "outputLen");
4375
+ T(this, "enableXOF", !1);
4376
+ T(this, "rounds");
4240
4377
  if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, me(t, "outputLen"), !(0 < e && e < 200))
4241
4378
  throw new Error("only keccak-f1600 function is supported");
4242
- this.state = new Uint8Array(200), this.state32 = ar(this.state);
4379
+ this.state = new Uint8Array(200), this.state32 = cr(this.state);
4243
4380
  }
4244
4381
  clone() {
4245
4382
  return this._cloneInto();
4246
4383
  }
4247
4384
  keccak() {
4248
- Nt(this.state32), dn(this.state32, this.rounds), Nt(this.state32), this.posOut = 0, this.pos = 0;
4385
+ Dt(this.state32), un(this.state32, this.rounds), Dt(this.state32), this.posOut = 0, this.pos = 0;
4249
4386
  }
4250
4387
  update(e) {
4251
- ke(this), V(e);
4388
+ Oe(this), q(e);
4252
4389
  const { blockLen: s, state: t } = this, n = e.length;
4253
4390
  for (let o = 0; o < n; ) {
4254
4391
  const i = Math.min(s - this.pos, n - o);
@@ -4266,7 +4403,7 @@ class wt {
4266
4403
  e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
4267
4404
  }
4268
4405
  writeInto(e) {
4269
- ke(this, !1), V(e), this.finish();
4406
+ Oe(this, !1), q(e), this.finish();
4270
4407
  const s = this.state, { blockLen: t } = this;
4271
4408
  for (let n = 0, o = e.length; n < o; ) {
4272
4409
  this.posOut >= t && this.keccak();
@@ -4284,7 +4421,7 @@ class wt {
4284
4421
  return me(e), this.xofInto(new Uint8Array(e));
4285
4422
  }
4286
4423
  digestInto(e) {
4287
- if (ss(e, this), this.finished)
4424
+ if (ns(e, this), this.finished)
4288
4425
  throw new Error("digest() was already called");
4289
4426
  return this.writeInto(e), this.destroy(), e;
4290
4427
  }
@@ -4292,21 +4429,21 @@ class wt {
4292
4429
  return this.digestInto(new Uint8Array(this.outputLen));
4293
4430
  }
4294
4431
  destroy() {
4295
- this.destroyed = !0, Pe(this.state);
4432
+ this.destroyed = !0, Ce(this.state);
4296
4433
  }
4297
4434
  _cloneInto(e) {
4298
4435
  const { blockLen: s, suffix: t, outputLen: n, rounds: o, enableXOF: i } = this;
4299
- return e || (e = new wt(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;
4436
+ return e || (e = new yt(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;
4300
4437
  }
4301
4438
  }
4302
- const un = (r, e, s, t = {}) => ns(() => new wt(e, r, s), t), zt = /* @__PURE__ */ un(1, 136, 32), hn = 60;
4303
- class pn {
4439
+ const hn = (r, e, s, t = {}) => is(() => new yt(e, r, s), t), Yt = /* @__PURE__ */ hn(1, 136, 32), pn = 60;
4440
+ class fn {
4304
4441
  constructor() {
4305
4442
  this.jwks = null;
4306
4443
  }
4307
4444
  setJWKSEndpoint(e) {
4308
4445
  try {
4309
- this.jwks = Ms(new URL(e)), d.log("[CROSSx] JWKS 엔드포인트 설정:", e);
4446
+ this.jwks = Bs(new URL(e)), d.log("[CROSSx] JWKS 엔드포인트 설정:", e);
4310
4447
  } catch (s) {
4311
4448
  d.warn("[CROSSx] JWKS 엔드포인트 URL 파싱 실패:", s);
4312
4449
  }
@@ -4320,7 +4457,7 @@ class pn {
4320
4457
  iat: t.iat
4321
4458
  });
4322
4459
  const n = Math.floor(Date.now() / 1e3);
4323
- if (t.exp && t.exp + hn < n)
4460
+ if (t.exp && t.exp + pn < n)
4324
4461
  return d.warn("[CROSSx] 토큰 만료:", {
4325
4462
  exp: t.exp,
4326
4463
  now: n,
@@ -4330,7 +4467,7 @@ class pn {
4330
4467
  return d.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 };
4331
4468
  if (this.jwks)
4332
4469
  try {
4333
- const { payload: o } = await $s(e, this.jwks, {
4470
+ const { payload: o } = await Us(e, this.jwks, {
4334
4471
  algorithms: ["RS256", "ES256"]
4335
4472
  });
4336
4473
  return d.log("[CROSSx] JWT 서명 검증 성공"), {
@@ -4349,7 +4486,7 @@ class pn {
4349
4486
  }
4350
4487
  }
4351
4488
  decodeJWT(e) {
4352
- return Bs(e);
4489
+ return Hs(e);
4353
4490
  }
4354
4491
  /**
4355
4492
  * EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
@@ -4364,29 +4501,29 @@ class pn {
4364
4501
  ${t.length}`
4365
4502
  ), o = new Uint8Array(n.length + t.length);
4366
4503
  o.set(n, 0), o.set(t, n.length);
4367
- const i = zt(o), a = s.startsWith("0x") ? s.slice(2) : s;
4504
+ const i = Yt(o), a = s.startsWith("0x") ? s.slice(2) : s;
4368
4505
  if (a.length !== 130)
4369
4506
  throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
4370
- 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(
4371
- jt(l),
4372
- jt(u)
4373
- ).addRecoveryBit(_).recoverPublicKey(i).toBytes(!1).slice(1), y = zt(b);
4374
- return "0x" + Me(y.slice(12));
4507
+ const c = _n(a), l = c.slice(0, 32), u = c.slice(32, 64), h = c[64], _ = h >= 27 ? h - 27 : h, E = new sn.Signature(
4508
+ Xt(l),
4509
+ Xt(u)
4510
+ ).addRecoveryBit(_).recoverPublicKey(i).toBytes(!1).slice(1), y = Yt(E);
4511
+ return "0x" + $e(y.slice(12));
4375
4512
  }
4376
4513
  }
4377
- function fn(r) {
4514
+ function _n(r) {
4378
4515
  const e = new Uint8Array(r.length / 2);
4379
4516
  for (let s = 0; s < e.length; s++)
4380
4517
  e[s] = parseInt(r.substring(s * 2, s * 2 + 2), 16);
4381
4518
  return e;
4382
4519
  }
4383
- function jt(r) {
4520
+ function Xt(r) {
4384
4521
  let e = "0x";
4385
4522
  for (const s of r) e += s.toString(16).padStart(2, "0");
4386
4523
  return BigInt(e);
4387
4524
  }
4388
- const _n = 3e4, xn = 1e3;
4389
- class gn {
4525
+ const xn = 3e4, gn = 1e3;
4526
+ class mn {
4390
4527
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4391
4528
  async request(e) {
4392
4529
  const s = e.retries ?? 0;
@@ -4397,7 +4534,7 @@ class gn {
4397
4534
  } catch (n) {
4398
4535
  if (t === s) throw n;
4399
4536
  }
4400
- await new Promise((n) => setTimeout(n, xn * 2 ** t));
4537
+ await new Promise((n) => setTimeout(n, gn * 2 ** t));
4401
4538
  }
4402
4539
  throw new Error("Unexpected: retry loop exited without result");
4403
4540
  }
@@ -4405,7 +4542,7 @@ class gn {
4405
4542
  async _doRequest(e) {
4406
4543
  const s = new AbortController(), t = setTimeout(
4407
4544
  () => s.abort(),
4408
- e.timeoutMs ?? _n
4545
+ e.timeoutMs ?? xn
4409
4546
  );
4410
4547
  try {
4411
4548
  const n = await fetch(e.url, {
@@ -4432,12 +4569,12 @@ class gn {
4432
4569
  }
4433
4570
  }
4434
4571
  }
4435
- const mn = /* @__PURE__ */ new Set([
4572
+ const wn = /* @__PURE__ */ new Set([
4436
4573
  "https://cross-wallet-oauth.crosstoken.io",
4437
4574
  "https://stg-cross-wallet-oauth.crosstoken.io",
4438
4575
  "https://dev-cross-wallet-oauth.crosstoken.io"
4439
4576
  ]);
4440
- class Ee {
4577
+ class Ie {
4441
4578
  static generateRandom16Hex() {
4442
4579
  const e = new Uint8Array(16);
4443
4580
  return crypto.getRandomValues(e), Array.from(e, (s) => s.toString(16).padStart(2, "0")).join("");
@@ -4461,7 +4598,7 @@ class Ee {
4461
4598
  * - Google 및 기타: originalNonce === jwt.nonce
4462
4599
  */
4463
4600
  static async verifyIdTokenNonce(e, s) {
4464
- const t = Ee.parseJwtPayload(e), n = t.nonce, o = typeof t.iss == "string" ? t.iss : "(unknown)";
4601
+ const t = Ie.parseJwtPayload(e), n = t.nonce, o = typeof t.iss == "string" ? t.iss : "(unknown)";
4465
4602
  if (d.log("[CROSSx] nonce 검증 시작 —", {
4466
4603
  iss: o,
4467
4604
  nonceClaimType: typeof n,
@@ -4483,7 +4620,7 @@ class Ee {
4483
4620
  return;
4484
4621
  }
4485
4622
  if (o.includes("appleid.apple.com")) {
4486
- const i = await Ee.sha256Hex(s);
4623
+ const i = await Ie.sha256Hex(s);
4487
4624
  if (d.log("[CROSSx] Apple nonce 검증 —", {
4488
4625
  expectedHashLength: i.length,
4489
4626
  receivedHashLength: n.length,
@@ -4500,7 +4637,7 @@ class Ee {
4500
4637
  }
4501
4638
  openAuth(e) {
4502
4639
  return new Promise((s, t) => {
4503
- const n = Math.max(e.width ?? 500, 500), o = Math.max(e.height ?? 700, 700), i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = Ee.generateRandom16Hex(), l = Ee.generateRandom16Hex(), u = e.authUrl.includes("?") ? "&" : "?", h = `${e.authUrl}${u}state=${c}&nonce=${l}`;
4640
+ const n = Math.max(e.width ?? 500, 500), o = Math.max(e.height ?? 700, 700), i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = Ie.generateRandom16Hex(), l = Ie.generateRandom16Hex(), u = e.authUrl.includes("?") ? "&" : "?", h = `${e.authUrl}${u}state=${c}&nonce=${l}`;
4504
4641
  d.log("[CROSSx] OAuth 팝업 열기 — state, nonce 생성 완료:", {
4505
4642
  stateLength: c.length,
4506
4643
  nonceLength: l.length,
@@ -4516,73 +4653,73 @@ class Ee {
4516
4653
  return;
4517
4654
  }
4518
4655
  const f = setTimeout(() => {
4519
- d.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), B(), t(new Error("Authentication timeout"));
4520
- }, 5 * 60 * 1e3), w = 10, b = 30;
4521
- let y = 0, T = null;
4656
+ d.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), M(), t(new Error("Authentication timeout"));
4657
+ }, 5 * 60 * 1e3), w = 10, E = 30;
4658
+ let y = 0, R = null;
4522
4659
  const N = () => {
4523
- clearInterval(W), d.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + b + "초간 대기합니다"), T = setTimeout(() => {
4524
- B(), t(new Error(
4660
+ clearInterval(F), d.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + E + "초간 대기합니다"), R = setTimeout(() => {
4661
+ M(), t(new Error(
4525
4662
  "OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
4526
4663
  ));
4527
- }, b * 1e3);
4528
- }, W = setInterval(() => {
4664
+ }, E * 1e3);
4665
+ }, F = setInterval(() => {
4529
4666
  y++;
4530
4667
  try {
4531
- _.closed && (y <= w ? N() : (B(), t(new Error("로그인이 취소되었습니다"))));
4668
+ _.closed && (y <= w ? N() : (M(), t(new Error("로그인이 취소되었습니다"))));
4532
4669
  } catch {
4533
4670
  N();
4534
4671
  }
4535
- }, 1e3), B = () => {
4536
- clearTimeout(f), clearInterval(W), T && clearTimeout(T), window.removeEventListener("message", j);
4537
- }, j = (q) => {
4538
- if (q.origin !== e.expectedOrigin) return;
4539
- if (!mn.has(q.origin)) {
4540
- d.error("[CROSSx] postMessage origin이 허용 목록에 없음:", q.origin), B(), t(new Error("Unauthorized OAuth origin"));
4672
+ }, 1e3), M = () => {
4673
+ clearTimeout(f), clearInterval(F), R && clearTimeout(R), window.removeEventListener("message", V);
4674
+ }, V = (G) => {
4675
+ if (G.origin !== e.expectedOrigin) return;
4676
+ if (!wn.has(G.origin)) {
4677
+ d.error("[CROSSx] postMessage origin이 허용 목록에 없음:", G.origin), M(), t(new Error("Unauthorized OAuth origin"));
4541
4678
  return;
4542
4679
  }
4543
- B();
4544
- const P = typeof q.data.status == "string", S = P ? q.data.data ?? {} : q.data;
4680
+ M();
4681
+ const J = typeof G.data.status == "string", H = J ? G.data.data ?? {} : G.data;
4545
4682
  d.log("[CROSSx] OAuth postMessage 수신 —", {
4546
- format: P ? "wrapped" : "flat",
4547
- status: P ? q.data.status : "(flat)"
4683
+ format: J ? "wrapped" : "flat",
4684
+ status: J ? G.data.status : "(flat)"
4548
4685
  });
4549
- const L = (S == null ? void 0 : S.state) ?? q.data.state;
4550
- if (!L || L !== c) {
4686
+ const z = (H == null ? void 0 : H.state) ?? G.data.state;
4687
+ if (!z || z !== c) {
4551
4688
  t(new Error("OAuth state mismatch — possible CSRF attack"));
4552
4689
  return;
4553
4690
  }
4554
- if (P && q.data.status !== "success") {
4555
- d.error("[CROSSx] OAuth 실패:", S == null ? void 0 : S.error), t(new Error((S == null ? void 0 : S.error) || "Authentication failed"));
4691
+ if (J && G.data.status !== "success") {
4692
+ d.error("[CROSSx] OAuth 실패:", H == null ? void 0 : H.error), t(new Error((H == null ? void 0 : H.error) || "Authentication failed"));
4556
4693
  return;
4557
4694
  }
4558
- if (!P && (S != null && S.error)) {
4559
- d.error("[CROSSx] OAuth 실패:", S.error), t(new Error(S.error || "Authentication failed"));
4695
+ if (!J && (H != null && H.error)) {
4696
+ d.error("[CROSSx] OAuth 실패:", H.error), t(new Error(H.error || "Authentication failed"));
4560
4697
  return;
4561
4698
  }
4562
- const G = S == null ? void 0 : S.idToken, O = S == null ? void 0 : S.accessToken, A = O ?? G;
4699
+ const k = H == null ? void 0 : H.idToken, b = H == null ? void 0 : H.accessToken, S = b ?? k;
4563
4700
  if (d.log("[CROSSx] OAuth 토큰 수신:", {
4564
- hasAccessToken: !!O,
4565
- hasIdToken: !!G
4566
- }), !A) {
4567
- d.error("[CROSSx] 토큰을 찾을 수 없음:", q.data), t(new Error("Token not found in response"));
4701
+ hasAccessToken: !!b,
4702
+ hasIdToken: !!k
4703
+ }), !S) {
4704
+ d.error("[CROSSx] 토큰을 찾을 수 없음:", G.data), t(new Error("Token not found in response"));
4568
4705
  return;
4569
4706
  }
4570
4707
  const I = (x) => {
4571
- Ee.verifyIdTokenNonce(x, l).then(() => s(A)).catch((g) => {
4708
+ Ie.verifyIdTokenNonce(x, l).then(() => s(S)).catch((g) => {
4572
4709
  d.error("[CROSSx] nonce 검증 실패:", g), t(g instanceof Error ? g : new Error("nonce verification failed"));
4573
4710
  });
4574
4711
  };
4575
- O ? O.split(".").length === 3 ? I(O) : G ? I(G) : (d.warn(
4712
+ b ? b.split(".").length === 3 ? I(b) : k ? I(k) : (d.warn(
4576
4713
  "[CROSSx] opaque accessToken만 수신 (idToken 없음) — nonce 검증 불가.",
4577
4714
  "서버 측 nonce 검증이 필요합니다."
4578
- ), s(A)) : G ? I(G) : t(new Error("Token not found in response"));
4715
+ ), s(S)) : k ? I(k) : t(new Error("Token not found in response"));
4579
4716
  };
4580
- window.addEventListener("message", j);
4717
+ window.addEventListener("message", V);
4581
4718
  });
4582
4719
  }
4583
4720
  }
4584
- const Ne = "crossx_wallet_data", Ae = "crossx_mock_pin_hash";
4585
- class wn {
4721
+ const De = "crossx_wallet_data", Re = "crossx_mock_pin_hash";
4722
+ class yn {
4586
4723
  constructor(e, s) {
4587
4724
  this.storage = e, this.pinStore = s ?? null;
4588
4725
  }
@@ -4595,13 +4732,13 @@ class wn {
4595
4732
  async checkWallet() {
4596
4733
  if (this.migrateScenario !== void 0)
4597
4734
  return d.log("[Mock] checkWallet → migration_required"), "migration_required";
4598
- const s = await this.storage.get(Ne) ? "exists" : "not_found";
4735
+ const s = await this.storage.get(De) ? "exists" : "not_found";
4599
4736
  return d.log(`[Mock] checkWallet → ${s}`), s;
4600
4737
  }
4601
4738
  async getOrCreateWallet(e) {
4602
4739
  var s;
4603
4740
  try {
4604
- const t = await this.storage.get(Ne);
4741
+ const t = await this.storage.get(De);
4605
4742
  if (t) return t;
4606
4743
  const n = {
4607
4744
  id: e,
@@ -4609,16 +4746,16 @@ class wn {
4609
4746
  derivationPath: "m/44'/60'/0'/0/0",
4610
4747
  createdAt: Date.now()
4611
4748
  };
4612
- await this.storage.set(Ne, n);
4749
+ await this.storage.set(De, n);
4613
4750
  const o = (s = this.pinStore) == null ? void 0 : s.get();
4614
- return o && (await this.storage.set(Ae, o), d.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
4751
+ return o && (await this.storage.set(Re, o), d.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
4615
4752
  } catch (t) {
4616
4753
  throw new m(p.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", t);
4617
4754
  }
4618
4755
  }
4619
4756
  /** GET /mnemonic/addresses 모킹 — PIN 불필요, 캐시된 주소 반환 */
4620
4757
  async getAddresses(e) {
4621
- const s = await this.storage.get(Ne);
4758
+ const s = await this.storage.get(De);
4622
4759
  return s ? [{ address: s.address, index: 0 }] : [];
4623
4760
  }
4624
4761
  async getAddress(e, s) {
@@ -4653,8 +4790,8 @@ class wn {
4653
4790
  var t;
4654
4791
  if (d.log("[Mock] verifyPin"), this.pinScenario === "wrong")
4655
4792
  return !1;
4656
- const s = await this.storage.get(Ae);
4657
- return s && s !== e ? !1 : (s || await this.storage.set(Ae, e), (t = this.pinStore) == null || t.set(e), d.log("[Mock] verifyPin → 성공"), !0);
4793
+ const s = await this.storage.get(Re);
4794
+ return s && s !== e ? !1 : (s || await this.storage.set(Re, e), (t = this.pinStore) == null || t.set(e), d.log("[Mock] verifyPin → 성공"), !0);
4658
4795
  }
4659
4796
  /**
4660
4797
  * POST /mnemonic/change-password 모킹
@@ -4664,10 +4801,10 @@ class wn {
4664
4801
  var o;
4665
4802
  if (d.log("[Mock] changePin"), this.pinScenario === "wrong")
4666
4803
  throw new m(p.PIN_WRONG, "Incorrect PIN.");
4667
- const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Ae);
4804
+ const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Re);
4668
4805
  if (n && t && n !== t)
4669
4806
  throw new m(p.PIN_WRONG, "Incorrect PIN.");
4670
- await this.storage.set(Ae, s), d.log("[Mock] changePin 완료");
4807
+ await this.storage.set(Re, s), d.log("[Mock] changePin 완료");
4671
4808
  }
4672
4809
  async migrateWallet(e, s) {
4673
4810
  var o;
@@ -4698,9 +4835,9 @@ class wn {
4698
4835
  derivationPath: "m/44'/60'/0'/0/0",
4699
4836
  createdAt: Date.now()
4700
4837
  };
4701
- await this.storage.set(Ne, t);
4838
+ await this.storage.set(De, t);
4702
4839
  const n = (o = this.pinStore) == null ? void 0 : o.get();
4703
- return n && (await this.storage.set(Ae, n), d.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
4840
+ return n && (await this.storage.set(Re, n), d.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
4704
4841
  }
4705
4842
  /**
4706
4843
  * POST /mnemonic/share-c 모킹
@@ -4727,7 +4864,7 @@ class wn {
4727
4864
  ).join("");
4728
4865
  }
4729
4866
  }
4730
- class Le {
4867
+ class ke {
4731
4868
  constructor(e, s, t, n, o) {
4732
4869
  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;
4733
4870
  }
@@ -4749,22 +4886,30 @@ class Le {
4749
4886
  *
4750
4887
  * 1. 토큰이 있고 만료 임박하지 않으면 즉시 반환
4751
4888
  * 2. 만료 임박/만료 시 → 자동 갱신 시도 (동시 호출 deduplicate)
4752
- * 3. 갱신 실패 기존 토큰이라도 있으면 반환 (서버가 최종 판단)
4753
- * 4. 토큰 자체가 없으면 AUTH_NOT_AUTHENTICATED throw
4889
+ * 3. 만료 임박·만료 상태에서 갱신에 실패하면 SESSION_EXPIRED (stale access로 호출하지 않음)
4890
+ * 4. refresher 미등록 등으로 갱신을 시도하지 않은 경우에만 기존 토큰 사용
4754
4891
  */
4755
4892
  async ensureValidToken() {
4756
4893
  const e = this.tokenStore.get();
4757
- if (e && !this.tokenStore.isExpiringSoon(tr))
4894
+ if (e && !this.tokenStore.isExpiringSoon(Nt))
4758
4895
  return e;
4759
- if (this._onTokenRefresh && await this.deduplicatedRefresh()) {
4760
- const t = this.tokenStore.get();
4761
- if (t) return t;
4896
+ const s = !e || this.tokenStore.isExpiringSoon(Nt);
4897
+ if (this._onTokenRefresh) {
4898
+ if (await this.deduplicatedRefresh()) {
4899
+ const n = this.tokenStore.get();
4900
+ if (n) return n;
4901
+ }
4902
+ if (s)
4903
+ throw new m(
4904
+ p.SESSION_EXPIRED,
4905
+ "인증 세션이 만료되었습니다. 다시 로그인해 주세요."
4906
+ );
4762
4907
  }
4763
4908
  if (e)
4764
4909
  return d.warn("[CROSSx] 토큰 갱신 실패 — 기존 토큰으로 요청 시도"), e;
4765
4910
  throw new m(
4766
- p.AUTH_NOT_AUTHENTICATED,
4767
- "인증 토큰을 찾을 없습니다. 먼저 로그인해 주세요."
4911
+ p.SESSION_EXPIRED,
4912
+ "인증 세션이 만료되었습니다. 다시 로그인해 주세요."
4768
4913
  );
4769
4914
  }
4770
4915
  /** 동시 갱신 요청을 단일 Promise로 합칩니다. */
@@ -4796,11 +4941,14 @@ class Le {
4796
4941
  url: i,
4797
4942
  method: e
4798
4943
  });
4799
- const w = Le.mapGatewayError(_.code, _.data);
4800
- if (w === p.AUTH_NOT_AUTHENTICATED && !n && this._onTokenRefresh && (d.warn("[CROSSx] Gateway -10002 감지 — 토큰 갱신 후 재시도"), await this.deduplicatedRefresh()))
4801
- return this.request(e, s, t, !0);
4802
- 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);
4803
- throw w === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (d.warn("[CROSSx] Gateway -10002 갱신 재시도 실패 — 강제 로그아웃 실행"), this._onUnauthorized()), N;
4944
+ const w = ke.mapGatewayError(_.code, _.data);
4945
+ if (w === p.AUTH_NOT_AUTHENTICATED && !n && this._onTokenRefresh) {
4946
+ if (d.warn("[CROSSx] Gateway -10002 감지 — 토큰 갱신 후 재시도"), await this.deduplicatedRefresh())
4947
+ return this.request(e, s, t, !0);
4948
+ throw new m(p.SESSION_EXPIRED, "인증 세션이 만료되었습니다. 다시 로그인해 주세요.");
4949
+ }
4950
+ const E = w === p.AUTH_NOT_AUTHENTICATED ? p.SESSION_EXPIRED : w, y = E === p.SESSION_EXPIRED ? "인증 세션이 만료되었습니다. 다시 로그인해 주세요." : ke.getGatewayErrorMessage(_.code, f), R = _.data, N = w === p.PIN_LOCKED ? ke.extractLockDetails(R) : R ?? void 0;
4951
+ throw new m(E, y, N);
4804
4952
  }
4805
4953
  return d.log("[CROSSx] Wallet Gateway API 성공:", { code: _.code, url: i, method: e }), _.data ?? _;
4806
4954
  }
@@ -4808,19 +4956,25 @@ class Le {
4808
4956
  } catch (h) {
4809
4957
  if (h instanceof m) throw h;
4810
4958
  const _ = ((c = h.response) == null ? void 0 : c.status) ?? h.status;
4811
- if ((_ === 401 || _ === 403) && !n && this._onTokenRefresh && (d.warn(`[CROSSx] HTTP ${_} 감지 — 토큰 갱신 후 재시도`), await this.deduplicatedRefresh()))
4812
- return this.request(e, s, t, !0);
4959
+ if ((_ === 401 || _ === 403) && !n && this._onTokenRefresh) {
4960
+ if (d.warn(`[CROSSx] HTTP ${_} 감지 — 토큰 갱신 후 재시도`), await this.deduplicatedRefresh())
4961
+ return this.request(e, s, t, !0);
4962
+ throw new m(
4963
+ p.SESSION_EXPIRED,
4964
+ "인증 세션이 만료되었습니다. 다시 로그인해 주세요."
4965
+ );
4966
+ }
4813
4967
  if ((l = h.response) != null && l.data) {
4814
- const f = h.response.data, w = f.message || f.data || "API 요청에 실패했습니다", b = f.code || "UNKNOWN";
4968
+ const f = h.response.data, w = f.message || f.data || "API 요청에 실패했습니다", E = f.code || "UNKNOWN";
4815
4969
  throw d.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
4816
- code: b,
4970
+ code: E,
4817
4971
  message: w,
4818
4972
  url: i,
4819
4973
  method: e,
4820
4974
  status: (u = h.response) == null ? void 0 : u.status
4821
4975
  }), new m(
4822
4976
  p.UNKNOWN_ERROR,
4823
- `Wallet Gateway 오류 (${b}): ${w}`
4977
+ `Wallet Gateway 오류 (${E}): ${w}`
4824
4978
  );
4825
4979
  }
4826
4980
  throw h;
@@ -5019,14 +5173,29 @@ class Le {
5019
5173
  return e;
5020
5174
  }
5021
5175
  /**
5022
- * -10031 응답의 data 필드에서 lockExpiresAt(Unix ms)을 추출합니다.
5176
+ * -10028/-10031 응답의 data 필드에서 잠금 상세 정보를 추출합니다.
5023
5177
  * 서버는 lockStatus.lockExpiresAt을 초(Unix seconds) 또는 ms로 반환할 수 있습니다.
5024
5178
  * 일반적으로 seconds 단위이므로 > 1e10 이면 ms로 간주합니다.
5179
+ *
5180
+ * iOS의 PinLockInfo와 동일한 필드: permanent, lockExpiresAt, maxAttempts, remainingAttempts
5025
5181
  */
5026
5182
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5027
5183
  static extractLockDetails(e) {
5028
- const s = (e == null ? void 0 : e.lockStatus) ?? e, t = (s == null ? void 0 : s.lockExpiresAt) ?? (s == null ? void 0 : s.lock_expires_at);
5029
- return t ? { lockExpiresAt: t > 1e10 ? t : t * 1e3 } : {};
5184
+ const s = (e == null ? void 0 : e.lockStatus) ?? (e == null ? void 0 : e.lock_status) ?? e, t = {}, n = (s == null ? void 0 : s.lockExpiresAt) ?? (s == null ? void 0 : s.lock_expires_at);
5185
+ n && (t.lockExpiresAt = n > 1e10 ? n : n * 1e3);
5186
+ const o = (s == null ? void 0 : s.remainingAttempts) ?? (s == null ? void 0 : s.remaining_attempts);
5187
+ typeof o == "number" && (t.remainingAttempts = o);
5188
+ const i = (s == null ? void 0 : s.maxAttempts) ?? (s == null ? void 0 : s.max_attempts);
5189
+ return typeof i == "number" && (t.maxAttempts = i), typeof (s == null ? void 0 : s.permanent) == "boolean" && (t.permanent = s.permanent), t;
5190
+ }
5191
+ /**
5192
+ * -10028 응답의 data에 lockStatus 정보가 포함되어 있는지 확인합니다.
5193
+ * iOS SDK와 동일하게, -10028에 lockStatus가 있으면 PIN_LOCKED로 승격 처리합니다.
5194
+ */
5195
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5196
+ static hasLockInfo(e) {
5197
+ const s = (e == null ? void 0 : e.lockStatus) ?? (e == null ? void 0 : e.lock_status) ?? e;
5198
+ return !s || typeof s != "object" ? !1 : typeof s.remainingAttempts == "number" || typeof s.remaining_attempts == "number" || typeof s.maxAttempts == "number" || typeof s.max_attempts == "number";
5030
5199
  }
5031
5200
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5032
5201
  static mapGatewayError(e, s) {
@@ -5066,7 +5235,7 @@ class Le {
5066
5235
  case -10025:
5067
5236
  return p.INVALID_APP_TYPE;
5068
5237
  case -10028:
5069
- return p.PIN_WRONG;
5238
+ return ke.hasLockInfo(s) ? p.PIN_LOCKED : p.PIN_WRONG;
5070
5239
  case -10029:
5071
5240
  return p.PIN_INVALID;
5072
5241
  case -10031:
@@ -5143,7 +5312,7 @@ class Le {
5143
5312
  }
5144
5313
  }
5145
5314
  }
5146
- class De {
5315
+ class Me {
5147
5316
  constructor(e, s) {
5148
5317
  this.cache = /* @__PURE__ */ new Map(), this.loadedAt = 0, this.usingFallback = !1, this.adapterConfig = e, this.projectId = e.projectId, this.transport = s;
5149
5318
  }
@@ -5161,7 +5330,7 @@ class De {
5161
5330
  const s = e.data.chains;
5162
5331
  return this.populateCache(s, !1), s;
5163
5332
  } catch {
5164
- const e = De.fallbackChains();
5333
+ const e = Me.fallbackChains();
5165
5334
  return this.populateCache(e, !0), e;
5166
5335
  }
5167
5336
  }
@@ -5175,7 +5344,7 @@ class De {
5175
5344
  }
5176
5345
  isCacheValid() {
5177
5346
  if (this.loadedAt === 0) return !1;
5178
- const e = this.usingFallback ? rr : sr;
5347
+ const e = this.usingFallback ? nr : rr;
5179
5348
  return e === 0 ? !0 : Date.now() - this.loadedAt < e;
5180
5349
  }
5181
5350
  populateCache(e, s) {
@@ -5197,13 +5366,13 @@ class De {
5197
5366
  if (e.code < 0) {
5198
5367
  const s = typeof e.data == "string" ? e.data : e.message ?? "체인 레지스트리 요청에 실패했습니다";
5199
5368
  throw new m(
5200
- De.mapErrorCode(e.code),
5369
+ Me.mapErrorCode(e.code),
5201
5370
  s
5202
5371
  );
5203
5372
  }
5204
5373
  }
5205
5374
  fallbackOrThrow(e) {
5206
- const s = De.fallbackChains().find(
5375
+ const s = Me.fallbackChains().find(
5207
5376
  (t) => t.chainId === e
5208
5377
  );
5209
5378
  if (s) return s;
@@ -5213,7 +5382,7 @@ class De {
5213
5382
  );
5214
5383
  }
5215
5384
  static fallbackChains() {
5216
- return Object.values(Ve).map((e) => ({
5385
+ return Object.values(ze).map((e) => ({
5217
5386
  chainId: e.caipId,
5218
5387
  rpcUrl: e.rpcUrl
5219
5388
  }));
@@ -5237,7 +5406,7 @@ class De {
5237
5406
  }
5238
5407
  }
5239
5408
  }
5240
- const Yt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", yn = {
5409
+ const Jt = "__crossx-confirm-style", se = "__crossx-confirm-overlay", bn = {
5241
5410
  light: {
5242
5411
  bg: "#FFFFFF",
5243
5412
  border: "rgba(18,18,18,0.05)",
@@ -5293,8 +5462,8 @@ const Yt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", yn = {
5293
5462
  onPrimary: "#FFFFFF"
5294
5463
  }
5295
5464
  };
5296
- function Jt(r, e) {
5297
- const s = yn[r], t = e == null ? void 0 : e[r];
5465
+ function Zt(r, e) {
5466
+ const s = bn[r], t = e == null ? void 0 : e[r];
5298
5467
  return t ? {
5299
5468
  ...s,
5300
5469
  // ── Brand
@@ -5326,10 +5495,10 @@ function Jt(r, e) {
5326
5495
  ...t.error !== void 0 && { errorColor: t.error }
5327
5496
  } : s;
5328
5497
  }
5329
- const bn = `
5498
+ const Sn = `
5330
5499
  @import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
5331
5500
 
5332
- #${te} {
5501
+ #${se} {
5333
5502
  position: fixed;
5334
5503
  inset: 0;
5335
5504
  z-index: 2147483647;
@@ -6493,6 +6662,8 @@ const bn = `
6493
6662
  max-height: 320px;
6494
6663
  overflow-y: auto;
6495
6664
  -webkit-overflow-scrolling: touch;
6665
+ overscroll-behavior: contain;
6666
+ touch-action: pan-y;
6496
6667
  scrollbar-width: thin;
6497
6668
  }
6498
6669
  .__crossx-wallet-list::-webkit-scrollbar {
@@ -6595,7 +6766,7 @@ const bn = `
6595
6766
 
6596
6767
  /* ── Mobile bottom sheet ───────────────────────────────────── */
6597
6768
  @media (max-width: 480px) {
6598
- #${te} { align-items: flex-end; }
6769
+ #${se} { align-items: flex-end; }
6599
6770
  .__crossx-card {
6600
6771
  width: 100%;
6601
6772
  max-width: 100%;
@@ -6607,6 +6778,18 @@ const bn = `
6607
6778
  }
6608
6779
  .__crossx-card--wallet-selector {
6609
6780
  overflow: hidden !important;
6781
+ display: flex !important;
6782
+ flex-direction: column !important;
6783
+ }
6784
+ .__crossx-card--wallet-selector .__crossx-body {
6785
+ flex: 1;
6786
+ min-height: 0;
6787
+ overflow: hidden;
6788
+ display: flex;
6789
+ flex-direction: column;
6790
+ }
6791
+ .__crossx-card--wallet-selector .__crossx-col-right-ws {
6792
+ min-height: 0;
6610
6793
  }
6611
6794
  .__crossx-card--wallet-selector .__crossx-wallet-list { max-height: 203px; }
6612
6795
  .__crossx-card--send-tx,
@@ -6734,7 +6917,7 @@ const bn = `
6734
6917
 
6735
6918
  /* ── Landscape for signing/transaction modals ──────────── */
6736
6919
  @media (orientation: landscape) and (max-height: 500px) {
6737
- #${te} { align-items: center !important; overflow: hidden; }
6920
+ #${se} { align-items: center !important; overflow: hidden; }
6738
6921
  .__crossx-card--send-tx,
6739
6922
  .__crossx-card--sign-tx,
6740
6923
  .__crossx-card--sign-msg,
@@ -7031,6 +7214,24 @@ const bn = `
7031
7214
  flex-shrink: 0;
7032
7215
  color: var(--cx-error);
7033
7216
  }
7217
+ /* 시도 횟수 카운트 (X/Y) */
7218
+ .__crossx-pin6-attempt {
7219
+ font-size: 16px;
7220
+ font-weight: 500;
7221
+ line-height: 1.5;
7222
+ color: var(--cx-error);
7223
+ text-align: center;
7224
+ letter-spacing: -0.16px;
7225
+ margin: 0;
7226
+ }
7227
+ .__crossx-pin6-warning {
7228
+ font-size: 14px;
7229
+ font-weight: 500;
7230
+ line-height: 1.5;
7231
+ color: var(--cx-error);
7232
+ text-align: center;
7233
+ margin: 0;
7234
+ }
7034
7235
  /* Next 버튼 */
7035
7236
  .__crossx-pin6-next {
7036
7237
  width: 100%;
@@ -7053,30 +7254,45 @@ const bn = `
7053
7254
  }
7054
7255
  `;
7055
7256
  function he() {
7056
- let r = document.getElementById(Yt);
7057
- r || (r = document.createElement("style"), r.id = Yt, document.head.appendChild(r)), r.textContent = bn;
7257
+ let r = document.getElementById(Jt);
7258
+ r || (r = document.createElement("style"), r.id = Jt, document.head.appendChild(r)), r.textContent = Sn;
7058
7259
  }
7059
7260
  function pe(r) {
7060
7261
  const e = (s) => s.stopPropagation();
7061
- for (const s of ["pointerdown", "pointerup", "mousedown", "mouseup", "click", "touchstart", "touchend"])
7262
+ for (const s of ["pointerdown", "pointerup", "mousedown", "mouseup", "click"])
7062
7263
  r.addEventListener(s, e);
7264
+ for (const s of ["touchstart", "touchend"])
7265
+ r.addEventListener(s, e, { passive: !0 });
7063
7266
  document.body.appendChild(r);
7064
7267
  }
7065
- function se(r) {
7268
+ const vn = () => /iPad|iPhone|iPod/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
7269
+ function nt() {
7270
+ if (vn()) {
7271
+ const e = window.scrollY;
7272
+ return document.body.style.position = "fixed", document.body.style.top = `-${e}px`, document.body.style.left = "0", document.body.style.right = "0", () => {
7273
+ document.body.style.position = "", document.body.style.top = "", document.body.style.left = "", document.body.style.right = "", window.scrollTo(0, e);
7274
+ };
7275
+ }
7276
+ const r = document.body.style.overflow;
7277
+ return document.body.style.overflow = "hidden", () => {
7278
+ document.body.style.overflow = r;
7279
+ };
7280
+ }
7281
+ function re(r) {
7066
7282
  return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
7067
7283
  }
7068
- function vn(r, e = "CROSS", s = 18) {
7284
+ function En(r, e = "CROSS", s = 18) {
7069
7285
  if (!r || r === "0x" || r === "0x0") return null;
7070
7286
  try {
7071
7287
  const t = BigInt(r);
7072
7288
  if (t === 0n) return null;
7073
- const n = ut(t, s);
7289
+ const n = ht(t, s);
7074
7290
  return n === "0" ? null : `${n} ${e}`;
7075
7291
  } catch {
7076
7292
  return null;
7077
7293
  }
7078
7294
  }
7079
- const Xt = {
7295
+ const Qt = {
7080
7296
  1: "Ethereum Mainnet",
7081
7297
  5: "Goerli Testnet",
7082
7298
  11155111: "Ethereum Sepolia",
@@ -7099,16 +7315,16 @@ const Xt = {
7099
7315
  612044: "CROSS Testnet",
7100
7316
  612055: "CROSS Mainnet"
7101
7317
  };
7102
- function Os(r) {
7318
+ function Ns(r) {
7103
7319
  const e = parseInt(r.split(":")[1] ?? "", 10);
7104
- return !isNaN(e) && Xt[e] ? Xt[e] : r;
7320
+ return !isNaN(e) && Qt[e] ? Qt[e] : r;
7105
7321
  }
7106
- function ut(r, e) {
7322
+ function ht(r, e) {
7107
7323
  if (r === 0n) return "0";
7108
7324
  const s = 10n ** BigInt(e), t = r / s, i = (r % s).toString().padStart(e, "0").slice(0, 6).replace(/0+$/, "");
7109
7325
  return i ? `${t}.${i}` : `${t}`;
7110
7326
  }
7111
- function nt(r) {
7327
+ function ot(r) {
7112
7328
  try {
7113
7329
  const e = BigInt(r), s = e / 1000000000n, n = (e % 1000000000n).toString().padStart(9, "0").slice(0, 2).replace(/0+$/, "");
7114
7330
  return n ? `${s}.${n}` : `${s}`;
@@ -7116,25 +7332,25 @@ function nt(r) {
7116
7332
  return r;
7117
7333
  }
7118
7334
  }
7119
- function Sn(r) {
7335
+ function In(r) {
7120
7336
  try {
7121
7337
  return BigInt(r).toLocaleString();
7122
7338
  } catch {
7123
7339
  return r;
7124
7340
  }
7125
7341
  }
7126
- function En(r) {
7342
+ function An(r) {
7127
7343
  const { gasLimit: e, gasPrice: s, maxFeePerGas: t, maxPriorityFeePerGas: n, nativeSymbol: o = "ETH", nativeDecimals: i = 18 } = r;
7128
7344
  if (!e) return null;
7129
7345
  try {
7130
- const a = BigInt(e), c = Sn(e);
7346
+ const a = BigInt(e), c = In(e);
7131
7347
  if (t) {
7132
7348
  const l = a * BigInt(t);
7133
7349
  return {
7134
7350
  isDynamic: !0,
7135
- estTxFee: `${ut(l, i)} ${o}`,
7136
- maxFeeGwei: nt(t),
7137
- maxPriorityFeeGwei: n ? nt(n) : void 0,
7351
+ estTxFee: `${ht(l, i)} ${o}`,
7352
+ maxFeeGwei: ot(t),
7353
+ maxPriorityFeeGwei: n ? ot(n) : void 0,
7138
7354
  gasLimitFormatted: c
7139
7355
  };
7140
7356
  }
@@ -7142,8 +7358,8 @@ function En(r) {
7142
7358
  const l = a * BigInt(s);
7143
7359
  return {
7144
7360
  isDynamic: !1,
7145
- estTxFee: `${ut(l, i)} ${o}`,
7146
- gasPriceGwei: nt(s),
7361
+ estTxFee: `${ht(l, i)} ${o}`,
7362
+ gasPriceGwei: ot(s),
7147
7363
  gasLimitFormatted: c
7148
7364
  };
7149
7365
  }
@@ -7152,11 +7368,11 @@ function En(r) {
7152
7368
  return null;
7153
7369
  }
7154
7370
  }
7155
- function Cs(r) {
7156
- const e = En(r);
7157
- if (!e) return Y("Estimated fee", "<span>—</span>");
7158
- let s = Y("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
7159
- 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;
7371
+ function Ls(r) {
7372
+ const e = An(r);
7373
+ if (!e) return j("Estimated fee", "<span>—</span>");
7374
+ let s = j("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
7375
+ return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s += j("Max Priority Fee", `<span>${e.maxPriorityFeeGwei} Gwei</span>`)), e.maxFeeGwei !== void 0 && (s += j("Max Gas Fee", `<span>${e.maxFeeGwei} Gwei</span>`))) : e.gasPriceGwei !== void 0 && (s += j("Gas Price", `<span>${e.gasPriceGwei} Gwei</span>`)), e.gasLimitFormatted && (s += j("Gas Limit", `<span>${e.gasLimitFormatted}</span>`)), s;
7160
7376
  }
7161
7377
  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">
7162
7378
  <rect x="9" y="9" width="13" height="13" rx="2"/>
@@ -7164,16 +7380,16 @@ const ge = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="
7164
7380
  </svg>`, ie = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
7165
7381
  <line x1="18" y1="6" x2="6" y2="18"/>
7166
7382
  <line x1="6" y1="6" x2="18" y2="18"/>
7167
- </svg>`, In = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7383
+ </svg>`, Tn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7168
7384
  <circle cx="20" cy="20" r="20" fill="#00D5AA"/>
7169
7385
  <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"/>
7170
- </svg>`, yt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
7386
+ </svg>`, bt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
7171
7387
  <rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
7172
7388
  <path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
7173
7389
  <rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
7174
- </svg>`, Tn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
7390
+ </svg>`, Rn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
7175
7391
  <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)"/>
7176
- </svg>`, An = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
7392
+ </svg>`, kn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
7177
7393
  <circle cx="12" cy="12" r="12" fill="var(--cx-error)"/>
7178
7394
  <circle cx="12" cy="12" r="5.5" stroke="white" stroke-width="1.5"/>
7179
7395
  <path d="M12 9.5v3l2 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
@@ -7204,17 +7420,17 @@ function ce(r) {
7204
7420
  `--cx-on-primary:${r.onPrimary}`
7205
7421
  ].join(";");
7206
7422
  }
7207
- function Y(r, e) {
7423
+ function j(r, e) {
7208
7424
  return `
7209
7425
  <div class="__crossx-row">
7210
7426
  <span class="__crossx-row-label">${r}</span>
7211
7427
  <div class="__crossx-row-value">${e}</div>
7212
7428
  </div>`;
7213
7429
  }
7214
- function Rn(r, e) {
7215
- const s = e, t = Ye(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
7216
- <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");
7217
- return a.id = te, a.innerHTML = `
7430
+ function Pn(r, e) {
7431
+ const s = e, t = Xe(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${re(r.to)}</span>
7432
+ <button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${ge}</button>` : "<span>—</span>", o = Ls(r), i = r.data ?? "0x", a = document.createElement("div");
7433
+ return a.id = se, a.innerHTML = `
7218
7434
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7219
7435
  <div class="__crossx-header">
7220
7436
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
@@ -7225,22 +7441,22 @@ function Rn(r, e) {
7225
7441
  <div class="__crossx-body-cols">
7226
7442
  <div class="__crossx-col-left">
7227
7443
  <p class="__crossx-sig-subtitle">
7228
- <span class="__crossx-sig-origin">${U(t)} </span>is requesting a Signature
7444
+ <span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
7229
7445
  </p>
7230
7446
  <div class="__crossx-addr-pill">
7231
- ${yt}
7232
- <span class="__crossx-addr-pill-text">${se(r.from)}</span>
7447
+ ${bt}
7448
+ <span class="__crossx-addr-pill-text">${re(r.from)}</span>
7233
7449
  </div>
7234
7450
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
7235
7451
  </div>
7236
7452
  <hr class="__crossx-divider __crossx-divider--cols">
7237
7453
  <div class="__crossx-col-right-sign">
7238
7454
  <div class="__crossx-rows">
7239
- ${Y("To", n)}
7240
- ${Y("Network", `<span>${Os(r.chainId)}</span>`)}
7455
+ ${j("To", n)}
7456
+ ${j("Network", `<span>${Ns(r.chainId)}</span>`)}
7241
7457
  ${o}
7242
7458
  </div>
7243
- <pre class="__crossx-raw-tx">${U(i)}</pre>
7459
+ <pre class="__crossx-raw-tx">${$(i)}</pre>
7244
7460
  </div>
7245
7461
  </div>
7246
7462
  <div class="__crossx-btn-row">
@@ -7251,10 +7467,10 @@ function Rn(r, e) {
7251
7467
  </div>
7252
7468
  `, a;
7253
7469
  }
7254
- function kn(r, e) {
7255
- 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>
7256
- <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");
7257
- return u.id = te, u.innerHTML = `
7470
+ function On(r, e) {
7471
+ const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Xe(r.dappName), i = r.to ? `<span class="__crossx-addr-text">${re(r.to)}</span>
7472
+ <button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${ge}</button>` : "<span>—</span>", a = Ls(r), l = En(r.value, t, n) ?? "—", u = document.createElement("div");
7473
+ return u.id = se, u.innerHTML = `
7258
7474
  <div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7259
7475
  <div class="__crossx-header">
7260
7476
  <p class="__crossx-title" id="__crossx-ttl">Approve transaction</p>
@@ -7263,16 +7479,16 @@ function kn(r, e) {
7263
7479
  <hr class="__crossx-divider">
7264
7480
  <div class="__crossx-body">
7265
7481
  <p class="__crossx-tx-subtitle">
7266
- <span class="__crossx-sig-origin">${U(o)}</span> wants your permission to approve the following transaction.
7482
+ <span class="__crossx-sig-origin">${$(o)}</span> wants your permission to approve the following transaction.
7267
7483
  </p>
7268
7484
  <div class="__crossx-body-cols">
7269
7485
  <div class="__crossx-rows">
7270
- ${Y("To", i)}
7271
- ${Y("Network", `<span>${Os(r.chainId)}</span>`)}
7486
+ ${j("To", i)}
7487
+ ${j("Network", `<span>${Ns(r.chainId)}</span>`)}
7272
7488
  ${a}
7273
7489
  </div>
7274
7490
  <div class="__crossx-pill">
7275
- <span class="__crossx-pill-from">${se(r.from)}</span>
7491
+ <span class="__crossx-pill-from">${re(r.from)}</span>
7276
7492
  <span class="__crossx-pill-amount">${l}</span>
7277
7493
  </div>
7278
7494
  </div>
@@ -7281,7 +7497,7 @@ function kn(r, e) {
7281
7497
  </div>
7282
7498
  `, u;
7283
7499
  }
7284
- function Ye(r) {
7500
+ function Xe(r) {
7285
7501
  var e;
7286
7502
  if (r) return r;
7287
7503
  try {
@@ -7290,33 +7506,33 @@ function Ye(r) {
7290
7506
  return "This site";
7291
7507
  }
7292
7508
  }
7293
- function U(r) {
7509
+ function $(r) {
7294
7510
  return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
7295
7511
  }
7296
- function Pn(r) {
7512
+ function Cn(r) {
7297
7513
  return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
7298
7514
  }
7299
- function On(r) {
7300
- if (typeof r == "string") return U(r);
7515
+ function Nn(r) {
7516
+ if (typeof r == "string") return $(r);
7301
7517
  if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
7302
7518
  try {
7303
- return U(JSON.stringify(r));
7519
+ return $(JSON.stringify(r));
7304
7520
  } catch {
7305
7521
  return String(r);
7306
7522
  }
7307
7523
  }
7308
- function Cn(r, e) {
7309
- const s = Y(
7524
+ function Ln(r, e) {
7525
+ const s = j(
7310
7526
  "From",
7311
- `<span class="__crossx-addr-text">${se(r.from)}</span>
7312
- <button class="__crossx-copy-btn" data-copy="${U(r.from)}" title="Copy address">${ge}</button>`
7313
- ), t = r.to ? Y("To", `<span class="__crossx-addr-text">${se(r.to)}</span>
7314
- <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>
7315
- <button class="__crossx-copy-btn" data-copy="${U(r.txHash)}" title="Copy hash">${ge}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
7527
+ `<span class="__crossx-addr-text">${re(r.from)}</span>
7528
+ <button class="__crossx-copy-btn" data-copy="${$(r.from)}" title="Copy address">${ge}</button>`
7529
+ ), t = r.to ? j("To", `<span class="__crossx-addr-text">${re(r.to)}</span>
7530
+ <button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${ge}</button>`) : "", n = r.amount ? j("Transfer", `<span>${$(r.amount)}</span>`) : "", o = r.fees ? j("Tx Fee", `<span>${$(r.fees)}</span>`) : "", i = r.txHash ? j("Tx Hash", `<span class="__crossx-addr-text">${re(r.txHash)}</span>
7531
+ <button class="__crossx-copy-btn" data-copy="${$(r.txHash)}" title="Copy hash">${ge}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
7316
7532
  <span class="__crossx-total-label">Total<br>(including fees)</span>
7317
- <span class="__crossx-total-amount">${U(r.total)}</span>
7533
+ <span class="__crossx-total-amount">${$(r.total)}</span>
7318
7534
  </div>` : "", c = document.createElement("div");
7319
- return c.id = te, c.innerHTML = `
7535
+ return c.id = se, c.innerHTML = `
7320
7536
  <div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7321
7537
  <div class="__crossx-header">
7322
7538
  <p class="__crossx-title" id="__crossx-ttl">Transaction complete</p>
@@ -7337,9 +7553,9 @@ function Cn(r, e) {
7337
7553
  </div>
7338
7554
  `, c;
7339
7555
  }
7340
- function Nn(r, e) {
7556
+ function Dn(r, e) {
7341
7557
  const s = document.createElement("div");
7342
- return s.id = te, s.innerHTML = `
7558
+ return s.id = se, s.innerHTML = `
7343
7559
  <div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7344
7560
  <div class="__crossx-header">
7345
7561
  <p class="__crossx-title" id="__crossx-ttl">Waiting for confirmation</p>
@@ -7354,11 +7570,11 @@ function Nn(r, e) {
7354
7570
  </div>
7355
7571
  `, s;
7356
7572
  }
7357
- function Ln(r, e, s) {
7573
+ function Mn(r, e, s) {
7358
7574
  const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
7359
7575
  if (o) {
7360
- const w = n ? An : t ? "" : Tn, b = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
7361
- w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${b}</span>`) : o.textContent = b;
7576
+ const w = n ? kn : t ? "" : Rn, E = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
7577
+ w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${E}</span>`) : o.textContent = E;
7362
7578
  }
7363
7579
  if (i && !r.querySelector("#__crossx-close-btn")) {
7364
7580
  const w = document.createElement("button");
@@ -7366,12 +7582,12 @@ function Ln(r, e, s) {
7366
7582
  }
7367
7583
  const a = r.querySelector("#__crossx-progress-body");
7368
7584
  if (!a) return;
7369
- const c = e.from ? Y("From", `<span class="__crossx-addr-text">${se(e.from)}</span>
7370
- <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>
7371
- <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>
7372
- <button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${ge}</button>`) : "", f = e.total ? `<div class="__crossx-total-pill">
7585
+ const c = e.from ? j("From", `<span class="__crossx-addr-text">${re(e.from)}</span>
7586
+ <button class="__crossx-copy-btn" data-copy="${$(e.from)}" title="Copy address">${ge}</button>`) : "", l = e.to ? j("To", `<span class="__crossx-addr-text">${re(e.to)}</span>
7587
+ <button class="__crossx-copy-btn" data-copy="${$(e.to)}" title="Copy address">${ge}</button>`) : "", u = e.amount ? j("Transfer", `<span>${$(e.amount)}</span>`) : "", h = e.fees ? j("Tx Fee", `<span>${$(e.fees)}</span>`) : "", _ = e.txHash ? j("Tx Hash", `<span class="__crossx-addr-text">${re(e.txHash)}</span>
7588
+ <button class="__crossx-copy-btn" data-copy="${$(e.txHash)}" title="Copy hash">${ge}</button>`) : "", f = e.total ? `<div class="__crossx-total-pill">
7373
7589
  <span class="__crossx-total-label">Total<br>(including fees)</span>
7374
- <span class="__crossx-total-amount">${U(e.total)}</span>
7590
+ <span class="__crossx-total-amount">${$(e.total)}</span>
7375
7591
  </div>` : "";
7376
7592
  a.innerHTML = `
7377
7593
  <div class="__crossx-rows">
@@ -7384,18 +7600,18 @@ function Ln(r, e, s) {
7384
7600
  ${f}
7385
7601
  <button class="__crossx-approve-btn" id="__crossx-done-btn">${t ? "All Done" : "Done"}</button>
7386
7602
  `, a.querySelectorAll(".__crossx-copy-btn").forEach((w) => {
7387
- w.addEventListener("click", (b) => {
7388
- var T;
7389
- b.stopPropagation();
7603
+ w.addEventListener("click", (E) => {
7604
+ var R;
7605
+ E.stopPropagation();
7390
7606
  const y = w.dataset.copy;
7391
- y && ((T = navigator.clipboard) == null || T.writeText(y).catch(() => {
7607
+ y && ((R = navigator.clipboard) == null || R.writeText(y).catch(() => {
7392
7608
  }));
7393
7609
  });
7394
7610
  });
7395
7611
  }
7396
- function Dn(r, e) {
7397
- const s = e, t = Ye(r.dappName), n = U(r.message), o = document.createElement("div");
7398
- return o.id = te, o.innerHTML = `
7612
+ function $n(r, e) {
7613
+ const s = e, t = Xe(r.dappName), n = $(r.message), o = document.createElement("div");
7614
+ return o.id = se, o.innerHTML = `
7399
7615
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7400
7616
  <div class="__crossx-header">
7401
7617
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
@@ -7406,11 +7622,11 @@ function Dn(r, e) {
7406
7622
  <div class="__crossx-body-cols">
7407
7623
  <div class="__crossx-col-left">
7408
7624
  <p class="__crossx-sig-subtitle">
7409
- <span class="__crossx-sig-origin">${U(t)} </span>is requesting a Signature
7625
+ <span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
7410
7626
  </p>
7411
7627
  <div class="__crossx-addr-pill">
7412
- ${yt}
7413
- <span class="__crossx-addr-pill-text">${se(r.from)}</span>
7628
+ ${bt}
7629
+ <span class="__crossx-addr-pill-text">${re(r.from)}</span>
7414
7630
  </div>
7415
7631
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
7416
7632
  </div>
@@ -7425,8 +7641,8 @@ function Dn(r, e) {
7425
7641
  </div>
7426
7642
  `, o;
7427
7643
  }
7428
- function Mn(r, e) {
7429
- const s = e, t = Ye(r.dappName);
7644
+ function Bn(r, e) {
7645
+ const s = e, t = Xe(r.dappName);
7430
7646
  let n = {};
7431
7647
  if (typeof r.typedData == "string")
7432
7648
  try {
@@ -7438,19 +7654,19 @@ function Mn(r, e) {
7438
7654
  let a = `
7439
7655
  <div class="__crossx-td-row">
7440
7656
  <span class="__crossx-td-label">Primary Type</span>
7441
- <span class="__crossx-td-value">${U(o)}</span>
7657
+ <span class="__crossx-td-value">${$(o)}</span>
7442
7658
  </div>`;
7443
7659
  for (const [l, u] of Object.entries(i)) {
7444
- const h = On(u), f = Pn(u) ? `<span class="__crossx-addr-text">${se(u)}</span>
7445
- <button class="__crossx-copy-btn" data-copy="${U(String(u))}" title="Copy">${ge}</button>` : `<span>${h}</span>`;
7660
+ const h = Nn(u), f = Cn(u) ? `<span class="__crossx-addr-text">${re(u)}</span>
7661
+ <button class="__crossx-copy-btn" data-copy="${$(String(u))}" title="Copy">${ge}</button>` : `<span>${h}</span>`;
7446
7662
  a += `
7447
7663
  <div class="__crossx-td-row">
7448
- <span class="__crossx-td-label">${U(l)}</span>
7664
+ <span class="__crossx-td-label">${$(l)}</span>
7449
7665
  <div class="__crossx-td-value">${f}</div>
7450
7666
  </div>`;
7451
7667
  }
7452
7668
  const c = document.createElement("div");
7453
- return c.id = te, c.innerHTML = `
7669
+ return c.id = se, c.innerHTML = `
7454
7670
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-typed" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7455
7671
  <div class="__crossx-header">
7456
7672
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
@@ -7461,11 +7677,11 @@ function Mn(r, e) {
7461
7677
  <div class="__crossx-body-cols">
7462
7678
  <div class="__crossx-col-left">
7463
7679
  <p class="__crossx-sig-subtitle">
7464
- <span class="__crossx-sig-origin">${U(t)} </span>is requesting a Signature
7680
+ <span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
7465
7681
  </p>
7466
7682
  <div class="__crossx-addr-pill">
7467
- ${yt}
7468
- <span class="__crossx-addr-pill-text">${se(r.from)}</span>
7683
+ ${bt}
7684
+ <span class="__crossx-addr-pill-text">${re(r.from)}</span>
7469
7685
  </div>
7470
7686
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
7471
7687
  </div>
@@ -7480,18 +7696,18 @@ function Mn(r, e) {
7480
7696
  </div>
7481
7697
  `, c;
7482
7698
  }
7483
- const $n = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
7699
+ const Un = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
7484
7700
  <line x1="12" y1="5" x2="12" y2="19"/>
7485
7701
  <line x1="5" y1="12" x2="19" y2="12"/>
7486
7702
  </svg>`;
7487
- function Bn(r, e, s) {
7703
+ function Hn(r, e, s) {
7488
7704
  const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
7489
7705
  const a = t && i.address.toLowerCase() === t;
7490
- return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${U(i.address)}">
7491
- <span class="__crossx-wallet-addr">${se(i.address)}</span>${a ? '<span class="__crossx-wallet-selected">selected</span>' : ""}
7706
+ return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${$(i.address)}">
7707
+ <span class="__crossx-wallet-addr">${re(i.address)}</span>${a ? '<span class="__crossx-wallet-selected">selected</span>' : ""}
7492
7708
  </button>`;
7493
7709
  }).join(""), o = document.createElement("div");
7494
- return o.id = te, o.innerHTML = `
7710
+ return o.id = se, o.innerHTML = `
7495
7711
  <div class="__crossx-card __crossx-card--migration __crossx-card--wallet-selector" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7496
7712
  <div class="__crossx-header">
7497
7713
  <div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
@@ -7515,7 +7731,7 @@ function Bn(r, e, s) {
7515
7731
  ${n}
7516
7732
  </div>
7517
7733
  <button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
7518
- <span class="__crossx-wallet-add-icon">${$n}</span>
7734
+ <span class="__crossx-wallet-add-icon">${Un}</span>
7519
7735
  <span class="__crossx-wallet-add-label">add a wallet</span>
7520
7736
  </button>
7521
7737
  </div>
@@ -7524,16 +7740,16 @@ function Bn(r, e, s) {
7524
7740
  </div>
7525
7741
  `, o;
7526
7742
  }
7527
- const Un = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7743
+ const Fn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7528
7744
  <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"/>
7529
7745
  <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"/>
7530
- </svg>`, Hn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7746
+ </svg>`, Gn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
7531
7747
  <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"/>
7532
7748
  <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"/>
7533
7749
  <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"/>
7534
7750
  <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"/>
7535
7751
  </svg>`;
7536
- function Fn(r, e = !1) {
7752
+ function Wn(r, e = !1) {
7537
7753
  const s = r, t = e ? `
7538
7754
  <div class="__crossx-login-or-divider">
7539
7755
  <hr><span>or</span><hr>
@@ -7544,7 +7760,7 @@ function Fn(r, e = !1) {
7544
7760
  <span class="__crossx-connect-other-desc">Connect your existing Web3 wallet to manage your assets.</span>
7545
7761
  </div>
7546
7762
  </button>` : "", n = document.createElement("div");
7547
- return n.id = te, n.innerHTML = `
7763
+ return n.id = se, n.innerHTML = `
7548
7764
  <div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7549
7765
  <div class="__crossx-header">
7550
7766
  <div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
@@ -7557,11 +7773,11 @@ function Fn(r, e = !1) {
7557
7773
  <div class="__crossx-body">
7558
7774
  <div class="__crossx-login-btn-row">
7559
7775
  <button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
7560
- <span class="__crossx-login-icon" style="color:var(--cx-value);">${Un}</span>
7776
+ <span class="__crossx-login-icon" style="color:var(--cx-value);">${Fn}</span>
7561
7777
  <span class="__crossx-login-btn-label">Sign in with&nbsp;&nbsp;Apple</span>
7562
7778
  </button>
7563
7779
  <button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
7564
- <span class="__crossx-login-icon">${Hn}</span>
7780
+ <span class="__crossx-login-icon">${Gn}</span>
7565
7781
  <span class="__crossx-login-btn-label">Sign in with&nbsp;&nbsp;Google</span>
7566
7782
  </button>
7567
7783
  </div>${t}
@@ -7572,9 +7788,9 @@ function Fn(r, e = !1) {
7572
7788
  </div>
7573
7789
  `, n;
7574
7790
  }
7575
- function Gn(r, e = !0) {
7791
+ function qn(r, e = !0) {
7576
7792
  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");
7577
- return o.id = te, o.innerHTML = `
7793
+ return o.id = se, o.innerHTML = `
7578
7794
  <div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7579
7795
  <div class="__crossx-header">
7580
7796
  <p class="__crossx-title" id="__crossx-ttl">Wallet Found on Social Account 🎉</p>
@@ -7588,7 +7804,7 @@ function Gn(r, e = !0) {
7588
7804
  <p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
7589
7805
  </div>
7590
7806
  <button class="__crossx-recover-btn" id="__crossx-recover-btn">
7591
- <span class="__crossx-recover-icon">${In}</span>
7807
+ <span class="__crossx-recover-icon">${Tn}</span>
7592
7808
  <span class="__crossx-recover-label">Import from Social Backup</span>
7593
7809
  </button>
7594
7810
  ${n}
@@ -7596,9 +7812,9 @@ function Gn(r, e = !0) {
7596
7812
  </div>
7597
7813
  `, o;
7598
7814
  }
7599
- function Wn(r, e) {
7815
+ function Kn(r, e) {
7600
7816
  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");
7601
- return h.id = te, h.innerHTML = `
7817
+ return h.id = se, h.innerHTML = `
7602
7818
  <div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7603
7819
  <div class="__crossx-header">
7604
7820
  <p class="__crossx-title" id="__crossx-ttl">Import from Social Backup</p>
@@ -7620,13 +7836,13 @@ function Wn(r, e) {
7620
7836
  </div>
7621
7837
  `, h;
7622
7838
  }
7623
- function qn(r) {
7839
+ function Vn(r) {
7624
7840
  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");
7625
7841
  return `${n}, ${o} ${i} ${a}:${c}`;
7626
7842
  }
7627
- function Kn(r, e, s) {
7628
- const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ? qn(o) : null, a = document.createElement("div");
7629
- return a.id = te, a.innerHTML = `
7843
+ function zn(r, e, s) {
7844
+ const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ? Vn(o) : null, a = document.createElement("div");
7845
+ return a.id = se, a.innerHTML = `
7630
7846
  <div class="__crossx-card __crossx-card--migration" style="${ce(t)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7631
7847
  <div class="__crossx-header">
7632
7848
  <p class="__crossx-title" id="__crossx-ttl">Import from Social Backup</p>
@@ -7655,17 +7871,17 @@ function Kn(r, e, s) {
7655
7871
  return () => clearInterval(h);
7656
7872
  } };
7657
7873
  }
7658
- function Vn(r) {
7874
+ function jn(r) {
7659
7875
  const s = [r.check1, r.check2].map((t, n) => `
7660
7876
  <div class="__crossx-pw-notice-item" data-check-index="${n}" role="checkbox" aria-checked="false" tabindex="0">
7661
- <div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${Yn}</div>
7662
- <span class="__crossx-pw-notice-item-text">${U(t)}</span>
7877
+ <div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${Jn}</div>
7878
+ <span class="__crossx-pw-notice-item-text">${$(t)}</span>
7663
7879
  </div>
7664
7880
  `).join("");
7665
7881
  return `
7666
7882
  <div class="__crossx-header">
7667
- <p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${U(r.title)}</p>
7668
- <p class="__crossx-pw-subtitle">${U(r.headerSubtitle)}</p>
7883
+ <p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${$(r.title)}</p>
7884
+ <p class="__crossx-pw-subtitle">${$(r.headerSubtitle)}</p>
7669
7885
  <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
7670
7886
  </div>
7671
7887
  <hr class="__crossx-divider">
@@ -7673,35 +7889,35 @@ function Vn(r) {
7673
7889
  <div class="__crossx-pw-fields __crossx-pw-fields--notice">
7674
7890
  <div class="__crossx-pw-notice-header">
7675
7891
  <div class="__crossx-pw-notice-title-row">
7676
- <span class="__crossx-pw-notice-icon">${Jn}</span>
7677
- <p class="__crossx-pw-notice-title">${U(r.noticeTitle)}</p>
7892
+ <span class="__crossx-pw-notice-icon">${Zn}</span>
7893
+ <p class="__crossx-pw-notice-title">${$(r.noticeTitle)}</p>
7678
7894
  </div>
7679
- <p class="__crossx-pw-notice-desc">${U(r.noticeDesc)}</p>
7895
+ <p class="__crossx-pw-notice-desc">${$(r.noticeDesc)}</p>
7680
7896
  </div>
7681
7897
  <div class="__crossx-pw-notice-checks" id="__crossx-notice-checks">
7682
7898
  ${s}
7683
7899
  </div>
7684
7900
  </div>
7685
7901
  <button class="__crossx-pw-btn --disabled" id="__crossx-pin-notice-next"
7686
- data-next-label="${U(r.nextButton)}"
7687
- data-submit-label="${U(r.submitButton)}">
7688
- ${U(r.nextButton)}
7902
+ data-next-label="${$(r.nextButton)}"
7903
+ data-submit-label="${$(r.submitButton)}">
7904
+ ${$(r.nextButton)}
7689
7905
  </button>
7690
7906
  </div>
7691
7907
  <div class="__crossx-home-indicator"></div>
7692
7908
  `;
7693
7909
  }
7694
- function ot(r) {
7695
- 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">
7696
- ${Ns}
7910
+ function it(r) {
7911
+ 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">${$(r.headerSubtitle)}</p>` : "", n = r.subtitle ? `<p class="__crossx-pin6-subtitle">${$(r.subtitle)}</p>` : "", o = r.errorMessage ? `<p class="__crossx-pin6-error" id="__crossx-pin6-error">${$(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">
7912
+ ${Ds}
7697
7913
  <span id="__crossx-pin6-lock-countdown"></span>
7698
- </p>` : "", a = e ? " --locked" : "", c = Array.from(
7914
+ </p>` : "", a = 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>', c = e ? " --locked" : "", l = Array.from(
7699
7915
  { length: 6 },
7700
- (l, u) => `<input class="__crossx-pin6-box${a}" type="password" maxlength="1" inputmode="numeric" pattern="[0-9]" autocomplete="off" aria-label="PIN digit ${u + 1}"${e ? " disabled" : ""}>`
7916
+ (u, h) => `<input class="__crossx-pin6-box${c}" type="password" maxlength="1" inputmode="numeric" pattern="[0-9]" autocomplete="off" aria-label="PIN digit ${h + 1}"${e ? " disabled" : ""}>`
7701
7917
  ).join("");
7702
7918
  return `
7703
7919
  <div class="__crossx-header">
7704
- <p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${U(r.title)}</p>
7920
+ <p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${$(r.title)}</p>
7705
7921
  ${t}
7706
7922
  <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
7707
7923
  </div>
@@ -7709,149 +7925,162 @@ function ot(r) {
7709
7925
  <div class="__crossx-pin6-body"${s}>
7710
7926
  ${n}
7711
7927
  <div class="__crossx-pin6-boxes" id="__crossx-pin6-boxes">
7712
- ${c}
7928
+ ${l}
7713
7929
  </div>
7714
7930
  ${o}
7931
+ ${a}
7715
7932
  ${i}
7716
7933
  </div>
7717
7934
  <div class="__crossx-home-indicator"></div>
7718
7935
  `;
7719
7936
  }
7720
- function Zt(r, e) {
7937
+ function es(r, e) {
7721
7938
  const s = document.createElement("div");
7722
- return s.id = te, s.innerHTML = `
7939
+ return s.id = se, s.innerHTML = `
7723
7940
  <div class="__crossx-card __crossx-card--pin6" style="${ce(r)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
7724
7941
  ${e}
7725
7942
  </div>
7726
7943
  `, s;
7727
7944
  }
7728
- function zn(r, e) {
7945
+ function Yn(r, e) {
7729
7946
  if (r.length !== 6) return e.tooShort;
7730
7947
  if (!/^\d+$/.test(r)) return e.numbersOnly;
7731
7948
  if (/(.)\1{2}/.test(r)) return e.repeatingDigit;
7732
7949
  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);
7733
7950
  return t || n ? e.sequential : r[0] !== r[1] && r === r.slice(0, 2).repeat(3) ? e.alternatingPattern : null;
7734
7951
  }
7735
- function jn(r) {
7952
+ function Xn(r) {
7736
7953
  const e = Math.max(0, Math.ceil(r / 1e3)), s = Math.floor(e / 3600), t = Math.floor(e % 3600 / 60), n = e % 60;
7737
7954
  return s > 0 ? `${s}h ${String(t).padStart(2, "0")}m` : `${String(t).padStart(2, "0")}:${String(n).padStart(2, "0")}`;
7738
7955
  }
7739
- function it(r, e, s, t, n, o) {
7740
- var j, q;
7956
+ function at(r, e, s, t, n, o) {
7957
+ var H, z;
7741
7958
  let i = !!(o && o > Date.now()), a = !1;
7742
- 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) => {
7743
- i = P, c().forEach((S) => {
7744
- S.disabled = P, S.classList.toggle("--locked", P);
7959
+ 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((k) => k.value).join(""), E = (k) => {
7960
+ i = k, c().forEach((b) => {
7961
+ b.disabled = k, b.classList.toggle("--locked", k);
7745
7962
  });
7746
- }, y = () => {
7747
- const P = u();
7748
- P && (P.textContent = "");
7749
- }, T = (P) => {
7750
- const S = u();
7751
- S && (S.textContent = P);
7752
- const L = l();
7753
- L == null || L.classList.add("--shake"), setTimeout(() => L == null ? void 0 : L.classList.remove("--shake"), 500), c().forEach((G) => {
7754
- G.value = "";
7963
+ }, y = () => r.querySelector("#__crossx-pin6-attempt"), R = () => {
7964
+ const k = u();
7965
+ k && (k.textContent = "");
7966
+ }, N = (k, b) => {
7967
+ var I;
7968
+ let S = y();
7969
+ if (!S) {
7970
+ S = document.createElement("p"), S.className = "__crossx-pin6-attempt", S.id = "__crossx-pin6-attempt";
7971
+ const x = u();
7972
+ x ? x.insertAdjacentElement("afterend", S) : (I = f()) == null || I.appendChild(S);
7973
+ }
7974
+ S.textContent = `${k}/${b}`;
7975
+ }, F = () => {
7976
+ const k = y();
7977
+ k && (k.textContent = "");
7978
+ }, M = (k) => {
7979
+ const b = u();
7980
+ b && (b.textContent = k);
7981
+ const S = l();
7982
+ S == null || S.classList.add("--shake"), setTimeout(() => S == null ? void 0 : S.classList.remove("--shake"), 500), c().forEach((I) => {
7983
+ I.value = "";
7755
7984
  }), setTimeout(() => {
7756
- var G;
7757
- return (G = c()[0]) == null ? void 0 : G.focus();
7985
+ var I;
7986
+ return (I = c()[0]) == null ? void 0 : I.focus();
7758
7987
  }, 50);
7759
- }, N = (P) => {
7760
- var A;
7761
- b(!0), c().forEach((I) => {
7762
- I.value = "";
7988
+ }, V = (k) => {
7989
+ var g;
7990
+ E(!0), c().forEach((v) => {
7991
+ v.value = "";
7763
7992
  });
7764
- const S = u();
7765
- if (S && (S.textContent = "Too many failed attempts. Please wait."), !h()) {
7766
- const I = document.createElement("p");
7767
- I.className = "__crossx-pin6-lock-msg", I.id = "__crossx-pin6-lock-msg", I.innerHTML = `${Ns}<span id="__crossx-pin6-lock-countdown"></span>`;
7768
- const x = u();
7769
- x ? x.insertAdjacentElement("afterend", I) : (A = f()) == null || A.appendChild(I);
7770
- }
7771
- const L = () => {
7772
- var g;
7773
- const I = P - Date.now(), x = _();
7774
- I <= 0 ? (clearInterval(G), b(!1), (g = h()) == null || g.remove(), S && (S.textContent = ""), setTimeout(() => {
7775
- var v;
7776
- return (v = c()[0]) == null ? void 0 : v.focus();
7777
- }, 50)) : x && (x.textContent = ` ${jn(I)}`);
7778
- }, G = setInterval(L, 1e3);
7779
- L();
7780
- const O = new MutationObserver(() => {
7781
- document.contains(r) || (clearInterval(G), O.disconnect());
7993
+ const b = u();
7994
+ if (b && (b.textContent = "Too many failed attempts. Please wait."), !h()) {
7995
+ const v = document.createElement("p");
7996
+ v.className = "__crossx-pin6-lock-msg", v.id = "__crossx-pin6-lock-msg", v.innerHTML = `${Ds}<span id="__crossx-pin6-lock-countdown"></span>`;
7997
+ const A = u();
7998
+ A ? A.insertAdjacentElement("afterend", v) : (g = f()) == null || g.appendChild(v);
7999
+ }
8000
+ const S = () => {
8001
+ var C;
8002
+ const v = k - Date.now(), A = _();
8003
+ v <= 0 ? (clearInterval(I), E(!1), (C = h()) == null || C.remove(), b && (b.textContent = ""), setTimeout(() => {
8004
+ var O;
8005
+ return (O = c()[0]) == null ? void 0 : O.focus();
8006
+ }, 50)) : A && (A.textContent = ` ${Xn(v)}`);
8007
+ }, I = setInterval(S, 1e3);
8008
+ S();
8009
+ const x = new MutationObserver(() => {
8010
+ document.contains(r) || (clearInterval(I), x.disconnect());
7782
8011
  });
7783
- O.observe(document.body, { childList: !0, subtree: !1 });
7784
- }, W = async () => {
8012
+ x.observe(document.body, { childList: !0, subtree: !1 });
8013
+ }, G = async () => {
7785
8014
  if (i || a) return;
7786
- const P = w();
7787
- if (P.length === 6) {
7788
- a = !0, c().forEach((S) => {
7789
- S.disabled = !0;
8015
+ const k = w();
8016
+ if (k.length === 6) {
8017
+ a = !0, c().forEach((b) => {
8018
+ b.disabled = !0;
7790
8019
  });
7791
8020
  try {
7792
8021
  if (n) {
7793
- const S = await n(P);
7794
- S.ok ? e(P) : S.lockExpiresAt ? N(S.lockExpiresAt) : T(S.error ?? "Incorrect PIN. Please try again.");
8022
+ const b = await n(k);
8023
+ b.ok ? e(k) : b.lockExpiresAt ? (F(), V(b.lockExpiresAt)) : (M(b.error ?? "Incorrect PIN. Please try again."), b.attemptCount != null && b.maxAttempts != null ? N(b.attemptCount, b.maxAttempts) : F());
7795
8024
  } else
7796
- e(P);
7797
- } catch (S) {
7798
- t && t(S);
8025
+ e(k);
8026
+ } catch (b) {
8027
+ t && t(b);
7799
8028
  } finally {
7800
- a = !1, i || c().forEach((S) => {
7801
- S.disabled = !1;
8029
+ a = !1, i || c().forEach((b) => {
8030
+ b.disabled = !1;
7802
8031
  });
7803
8032
  }
7804
8033
  }
7805
8034
  };
7806
- o && o > Date.now() ? N(o) : setTimeout(() => {
7807
- var P;
7808
- return (P = c()[0]) == null ? void 0 : P.focus();
8035
+ o && o > Date.now() ? V(o) : setTimeout(() => {
8036
+ var k;
8037
+ return (k = c()[0]) == null ? void 0 : k.focus();
7809
8038
  }, 100);
7810
- const B = () => {
8039
+ const J = () => {
7811
8040
  if (i || a) return;
7812
- const P = c(), S = P.find((L) => !L.value) ?? P[P.length - 1];
7813
- S == null || S.focus();
8041
+ const k = c(), b = k.find((S) => !S.value) ?? k[k.length - 1];
8042
+ b == null || b.focus();
7814
8043
  };
7815
- (j = l()) == null || j.addEventListener("click", (P) => {
7816
- P.target.classList.contains("__crossx-pin6-box") || B();
7817
- }), (q = f()) == null || q.addEventListener("click", (P) => {
7818
- const S = P.target;
7819
- S.classList.contains("__crossx-pin6-box") || S.closest("button") || B();
7820
- }), c().forEach((P, S) => {
7821
- P.addEventListener("input", () => {
7822
- var G;
7823
- const L = P.value.replace(/\D/g, "").slice(-1);
7824
- P.value = L, y(), L && S < 5 && ((G = c()[S + 1]) == null || G.focus()), w().length === 6 && setTimeout(W, 80);
7825
- }), P.addEventListener("keydown", (L) => {
7826
- var G, O;
7827
- if (L.key === "Backspace") {
7828
- if (L.preventDefault(), P.value)
7829
- P.value = "";
7830
- else if (S > 0) {
7831
- const A = c()[S - 1];
7832
- A.value = "", A.focus();
8044
+ (H = l()) == null || H.addEventListener("click", (k) => {
8045
+ k.target.classList.contains("__crossx-pin6-box") || J();
8046
+ }), (z = f()) == null || z.addEventListener("click", (k) => {
8047
+ const b = k.target;
8048
+ b.classList.contains("__crossx-pin6-box") || b.closest("button") || J();
8049
+ }), c().forEach((k, b) => {
8050
+ k.addEventListener("input", () => {
8051
+ var I;
8052
+ const S = k.value.replace(/\D/g, "").slice(-1);
8053
+ k.value = S, R(), S && b < 5 && ((I = c()[b + 1]) == null || I.focus()), w().length === 6 && setTimeout(G, 80);
8054
+ }), k.addEventListener("keydown", (S) => {
8055
+ var I, x;
8056
+ if (S.key === "Backspace") {
8057
+ if (S.preventDefault(), k.value)
8058
+ k.value = "";
8059
+ else if (b > 0) {
8060
+ const g = c()[b - 1];
8061
+ g.value = "", g.focus();
7833
8062
  }
7834
- } else L.key === "ArrowLeft" && S > 0 ? (L.preventDefault(), (G = c()[S - 1]) == null || G.focus()) : L.key === "ArrowRight" && S < 5 ? (L.preventDefault(), (O = c()[S + 1]) == null || O.focus()) : L.key === "Escape" && s();
7835
- }), P.addEventListener("paste", (L) => {
7836
- var A, I;
7837
- L.preventDefault();
7838
- const G = (((A = L.clipboardData) == null ? void 0 : A.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
7839
- if (!G) return;
7840
- const O = c();
7841
- G.split("").forEach((x, g) => {
7842
- O[g] && (O[g].value = x);
7843
- }), (I = O[Math.min(G.length - 1, 5)]) == null || I.focus(), y(), w().length === 6 && setTimeout(W, 80);
7844
- }), P.addEventListener("focus", () => P.select());
8063
+ } else S.key === "ArrowLeft" && b > 0 ? (S.preventDefault(), (I = c()[b - 1]) == null || I.focus()) : S.key === "ArrowRight" && b < 5 ? (S.preventDefault(), (x = c()[b + 1]) == null || x.focus()) : S.key === "Escape" && s();
8064
+ }), k.addEventListener("paste", (S) => {
8065
+ var g, v;
8066
+ S.preventDefault();
8067
+ const I = (((g = S.clipboardData) == null ? void 0 : g.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
8068
+ if (!I) return;
8069
+ const x = c();
8070
+ I.split("").forEach((A, C) => {
8071
+ x[C] && (x[C].value = A);
8072
+ }), (v = x[Math.min(I.length - 1, 5)]) == null || v.focus(), R(), w().length === 6 && setTimeout(G, 80);
8073
+ }), k.addEventListener("focus", () => k.select());
7845
8074
  });
7846
8075
  }
7847
- const Ns = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
8076
+ const Ds = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
7848
8077
  <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"/>
7849
- </svg>`, Yn = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
8078
+ </svg>`, Jn = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
7850
8079
  <path d="M1 4.5L4 7.5L10 1" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
7851
- </svg>`, Jn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
8080
+ </svg>`, Zn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
7852
8081
  <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"/>
7853
8082
  </svg>`;
7854
- function Xn(r, e, s) {
8083
+ function Qn(r, e, s) {
7855
8084
  var o;
7856
8085
  const t = r.querySelectorAll(".__crossx-pin-input");
7857
8086
  t.forEach((i, a) => {
@@ -7884,12 +8113,12 @@ function Xn(r, e, s) {
7884
8113
  }
7885
8114
  }), (o = t[0]) == null || o.focus();
7886
8115
  }
7887
- class Zn {
8116
+ class eo {
7888
8117
  constructor(e = "light", s) {
7889
- this.theme = e, this.overrides = s, this.tokens = Jt(e, s);
8118
+ this.theme = e, this.overrides = s, this.tokens = Zt(e, s);
7890
8119
  }
7891
8120
  setTheme(e, s) {
7892
- this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = Jt(e, this.overrides);
8121
+ this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = Zt(e, this.overrides);
7893
8122
  }
7894
8123
  setMessages(e) {
7895
8124
  this.messages = e;
@@ -7904,13 +8133,13 @@ class Zn {
7904
8133
  */
7905
8134
  showWalletSelector(e, s, t) {
7906
8135
  return new Promise((n) => {
7907
- var b;
8136
+ var E;
7908
8137
  he();
7909
- const o = [...e], i = Bn(o, this.tokens, t), a = document.body.style.overflow;
7910
- document.body.style.overflow = "hidden", pe(i);
8138
+ const o = [...e], i = Hn(o, this.tokens, t), a = nt();
8139
+ pe(i);
7911
8140
  let c = !1;
7912
8141
  const l = () => {
7913
- c || (c = !0, i.remove(), document.body.style.overflow = a);
8142
+ c || (c = !0, i.remove(), a());
7914
8143
  }, u = (y) => {
7915
8144
  l(), n(y);
7916
8145
  }, h = () => {
@@ -7919,8 +8148,8 @@ class Zn {
7919
8148
  (() => {
7920
8149
  i.querySelectorAll(".__crossx-wallet-item").forEach((y) => {
7921
8150
  y.addEventListener("click", () => {
7922
- const T = y.dataset.walletAddress ?? "", N = parseInt(y.dataset.walletIndex ?? "0", 10);
7923
- u({ address: T, index: N });
8151
+ const R = y.dataset.walletAddress ?? "", N = parseInt(y.dataset.walletIndex ?? "0", 10);
8152
+ u({ address: R, index: N });
7924
8153
  });
7925
8154
  });
7926
8155
  })();
@@ -7930,16 +8159,16 @@ class Zn {
7930
8159
  try {
7931
8160
  const y = await s();
7932
8161
  o.push(y);
7933
- const T = i.querySelector("#__crossx-wallet-list");
7934
- if (T) {
8162
+ const R = i.querySelector("#__crossx-wallet-list");
8163
+ if (R) {
7935
8164
  const N = document.createElement("button");
7936
- 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" });
8165
+ N.className = "__crossx-wallet-item", N.dataset.walletIndex = String(y.index), N.dataset.walletAddress = y.address, N.innerHTML = `<span class="__crossx-wallet-addr">${re(y.address)}</span>`, N.addEventListener("click", () => u(y)), R.appendChild(N), N.scrollIntoView({ behavior: "smooth", block: "nearest" });
7937
8166
  }
7938
8167
  } catch {
7939
8168
  } finally {
7940
8169
  f.disabled = !1;
7941
8170
  }
7942
- }), (b = i.querySelector("#__crossx-close-btn")) == null || b.addEventListener("click", h), i.addEventListener("click", (y) => {
8171
+ }), (E = i.querySelector("#__crossx-close-btn")) == null || E.addEventListener("click", h), i.addEventListener("click", (y) => {
7943
8172
  y.target === i && h();
7944
8173
  });
7945
8174
  const w = (y) => {
@@ -7958,7 +8187,7 @@ class Zn {
7958
8187
  return new Promise((s) => {
7959
8188
  var c, l, u, h;
7960
8189
  he();
7961
- const t = Fn(this.tokens, e == null ? void 0 : e.showConnectOtherWallets);
8190
+ const t = Wn(this.tokens, e == null ? void 0 : e.showConnectOtherWallets);
7962
8191
  pe(t);
7963
8192
  const n = () => t.remove(), o = (_) => {
7964
8193
  n(), s(_);
@@ -7986,7 +8215,7 @@ class Zn {
7986
8215
  return new Promise((t) => {
7987
8216
  var a, c, l;
7988
8217
  he();
7989
- const n = Gn(this.tokens, s);
8218
+ const n = qn(this.tokens, s);
7990
8219
  pe(n);
7991
8220
  const o = () => n.remove(), i = () => {
7992
8221
  o(), t("recover");
@@ -8032,11 +8261,11 @@ class Zn {
8032
8261
  }, i = {
8033
8262
  title: (t == null ? void 0 : t.pinSetup_confirmTitle) ?? "Confirm PIN",
8034
8263
  headerSubtitle: (t == null ? void 0 : t.pinSetup_confirmSubtitle) ?? "Enter your PIN again to confirm."
8035
- }, a = Zt(this.tokens, Vn(n)), c = document.body.style.overflow;
8036
- document.body.style.overflow = "hidden", pe(a);
8264
+ }, a = es(this.tokens, jn(n)), c = nt();
8265
+ pe(a);
8037
8266
  let l = !1;
8038
8267
  const u = () => {
8039
- l || (l = !0, a.remove(), document.body.style.overflow = c);
8268
+ l || (l = !0, a.remove(), c());
8040
8269
  }, h = (N) => {
8041
8270
  u(), s(N);
8042
8271
  }, _ = () => {
@@ -8047,64 +8276,64 @@ class Zn {
8047
8276
  repeatingDigit: (t == null ? void 0 : t.pinValidation_repeatingDigit) ?? "Cannot use the same number 3+ times in a row.",
8048
8277
  sequential: (t == null ? void 0 : t.pinValidation_sequential) ?? "Sequential numbers (e.g., 123456) are not allowed.",
8049
8278
  alternatingPattern: (t == null ? void 0 : t.pinValidation_alternatingPattern) ?? "Repeating patterns (e.g., 121212) are not allowed."
8050
- }, b = (N) => {
8051
- var W;
8052
- f.innerHTML = ot({
8279
+ }, E = (N) => {
8280
+ var F;
8281
+ f.innerHTML = it({
8053
8282
  title: i.title,
8054
8283
  headerSubtitle: i.headerSubtitle
8055
- }), (W = f.querySelector("#__crossx-close-btn")) == null || W.addEventListener("click", _), it(f, (B) => {
8056
- B === N ? h(N) : y(o.mismatchError);
8284
+ }), (F = f.querySelector("#__crossx-close-btn")) == null || F.addEventListener("click", _), at(f, (M) => {
8285
+ M === N ? h(N) : y(o.mismatchError);
8057
8286
  }, _);
8058
8287
  }, y = (N) => {
8059
- var W;
8060
- f.innerHTML = ot({
8288
+ var F;
8289
+ f.innerHTML = it({
8061
8290
  title: o.title,
8062
8291
  headerSubtitle: o.headerSubtitle,
8063
8292
  subtitle: o.subtitle,
8064
8293
  errorMessage: N
8065
- }), (W = f.querySelector("#__crossx-close-btn")) == null || W.addEventListener("click", _), it(f, (B) => {
8066
- const j = zn(B, w);
8067
- j ? y(j) : b(B);
8294
+ }), (F = f.querySelector("#__crossx-close-btn")) == null || F.addEventListener("click", _), at(f, (M) => {
8295
+ const V = Yn(M, w);
8296
+ V ? y(V) : E(M);
8068
8297
  }, _);
8069
8298
  };
8070
8299
  (() => {
8071
- var G;
8072
- const N = Array.from(f.querySelectorAll(".__crossx-pw-notice-item")), W = f.querySelector("#__crossx-pin-notice-next"), B = /* @__PURE__ */ new Set();
8073
- W.removeAttribute("disabled");
8074
- const j = W.dataset.nextLabel ?? "Next", q = W.dataset.submitLabel ?? "I Understand", P = () => {
8075
- const O = B.size === N.length;
8076
- W.classList.toggle("--disabled", !O), W.textContent = O ? q : j;
8077
- }, S = (O, A) => {
8078
- if (B.has(A)) return;
8079
- const I = O.querySelector(`#__crossx-notice-check-${A}`);
8080
- B.add(A), I.classList.add("--checked"), O.setAttribute("aria-checked", "true"), P();
8081
- }, L = (O, A) => {
8082
- if (!B.has(A)) return;
8083
- const I = O.querySelector(`#__crossx-notice-check-${A}`);
8084
- B.delete(A), I.classList.remove("--checked"), O.setAttribute("aria-checked", "false"), P();
8300
+ var k;
8301
+ const N = Array.from(f.querySelectorAll(".__crossx-pw-notice-item")), F = f.querySelector("#__crossx-pin-notice-next"), M = /* @__PURE__ */ new Set();
8302
+ F.removeAttribute("disabled");
8303
+ const V = F.dataset.nextLabel ?? "Next", G = F.dataset.submitLabel ?? "I Understand", J = () => {
8304
+ const b = M.size === N.length;
8305
+ F.classList.toggle("--disabled", !b), F.textContent = b ? G : V;
8306
+ }, H = (b, S) => {
8307
+ if (M.has(S)) return;
8308
+ const I = b.querySelector(`#__crossx-notice-check-${S}`);
8309
+ M.add(S), I.classList.add("--checked"), b.setAttribute("aria-checked", "true"), J();
8310
+ }, z = (b, S) => {
8311
+ if (!M.has(S)) return;
8312
+ const I = b.querySelector(`#__crossx-notice-check-${S}`);
8313
+ M.delete(S), I.classList.remove("--checked"), b.setAttribute("aria-checked", "false"), J();
8085
8314
  };
8086
- N.forEach((O) => {
8087
- const A = parseInt(O.dataset.checkIndex ?? "0", 10);
8088
- O.addEventListener("click", () => {
8089
- B.has(A) ? L(O, A) : S(O, A);
8090
- }), O.addEventListener("keydown", (I) => {
8091
- (I.key === " " || I.key === "Enter") && (I.preventDefault(), B.has(A) ? L(O, A) : S(O, A));
8315
+ N.forEach((b) => {
8316
+ const S = parseInt(b.dataset.checkIndex ?? "0", 10);
8317
+ b.addEventListener("click", () => {
8318
+ M.has(S) ? z(b, S) : H(b, S);
8319
+ }), b.addEventListener("keydown", (I) => {
8320
+ (I.key === " " || I.key === "Enter") && (I.preventDefault(), M.has(S) ? z(b, S) : H(b, S));
8092
8321
  });
8093
- }), W.addEventListener("click", () => {
8094
- if (B.size === N.length) {
8322
+ }), F.addEventListener("click", () => {
8323
+ if (M.size === N.length) {
8095
8324
  y(e == null ? void 0 : e.errorMessage);
8096
8325
  return;
8097
8326
  }
8098
- const O = N.find((I) => {
8327
+ const b = N.find((I) => {
8099
8328
  const x = parseInt(I.dataset.checkIndex ?? "0", 10);
8100
- return !B.has(x);
8329
+ return !M.has(x);
8101
8330
  });
8102
- if (!O) return;
8103
- const A = parseInt(O.dataset.checkIndex ?? "0", 10);
8104
- O.scrollIntoView({ behavior: "smooth", block: "nearest" }), O.classList.add("--highlight"), setTimeout(() => {
8105
- O.classList.remove("--highlight"), S(O, A);
8331
+ if (!b) return;
8332
+ const S = parseInt(b.dataset.checkIndex ?? "0", 10);
8333
+ b.scrollIntoView({ behavior: "smooth", block: "nearest" }), b.classList.add("--highlight"), setTimeout(() => {
8334
+ b.classList.remove("--highlight"), H(b, S);
8106
8335
  }, 400);
8107
- }), (G = f.querySelector("#__crossx-close-btn")) == null || G.addEventListener("click", _);
8336
+ }), (k = f.querySelector("#__crossx-close-btn")) == null || k.addEventListener("click", _);
8108
8337
  })(), a.addEventListener("click", (N) => {
8109
8338
  N.target === a && _();
8110
8339
  });
@@ -8119,28 +8348,30 @@ class Zn {
8119
8348
  return new Promise((s, t) => {
8120
8349
  var y;
8121
8350
  he();
8122
- const n = this.messages, o = (e == null ? void 0 : e.verifyMode) === !0, i = o ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = o ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c = Zt(
8351
+ const n = this.messages, o = (e == null ? void 0 : e.verifyMode) === !0, i = o ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = o ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c = es(
8123
8352
  this.tokens,
8124
- ot({
8353
+ it({
8125
8354
  title: i,
8126
8355
  headerSubtitle: a,
8127
8356
  errorMessage: e == null ? void 0 : e.errorMessage,
8128
- lockExpiresAt: e == null ? void 0 : e.lockExpiresAt
8357
+ lockExpiresAt: e == null ? void 0 : e.lockExpiresAt,
8358
+ attemptCount: e == null ? void 0 : e.attemptCount,
8359
+ maxAttempts: e == null ? void 0 : e.maxAttempts
8129
8360
  })
8130
- ), l = document.body.style.overflow;
8131
- document.body.style.overflow = "hidden", pe(c);
8361
+ ), l = nt();
8362
+ pe(c);
8132
8363
  let u = !1;
8133
8364
  const h = () => {
8134
- u || (u = !0, c.remove(), document.body.style.overflow = l);
8135
- }, _ = (T) => {
8136
- h(), s(T);
8365
+ u || (u = !0, c.remove(), l());
8366
+ }, _ = (R) => {
8367
+ h(), s(R);
8137
8368
  }, f = () => {
8138
8369
  h(), s(null);
8139
- }, w = (T) => {
8140
- h(), t(T);
8141
- }, b = c.querySelector(".__crossx-card");
8142
- (y = b.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", f), it(b, _, f, w, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt), c.addEventListener("click", (T) => {
8143
- T.target === c && f();
8370
+ }, w = (R) => {
8371
+ h(), t(R);
8372
+ }, E = c.querySelector(".__crossx-card");
8373
+ (y = E.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", f), at(E, _, f, w, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt), c.addEventListener("click", (R) => {
8374
+ R.target === c && f();
8144
8375
  });
8145
8376
  });
8146
8377
  }
@@ -8155,14 +8386,14 @@ class Zn {
8155
8386
  return new Promise((s) => {
8156
8387
  var a;
8157
8388
  he();
8158
- const t = Wn(this.tokens, e);
8389
+ const t = Kn(this.tokens, e);
8159
8390
  pe(t);
8160
8391
  const n = () => t.remove(), o = (c) => {
8161
8392
  n(), s(c);
8162
8393
  }, i = () => {
8163
8394
  n(), s(null);
8164
8395
  };
8165
- Xn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
8396
+ Qn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
8166
8397
  c.target === t && i();
8167
8398
  });
8168
8399
  });
@@ -8177,7 +8408,7 @@ class Zn {
8177
8408
  return new Promise((t) => {
8178
8409
  var l;
8179
8410
  he();
8180
- const { overlay: n, startCountdown: o } = Kn(this.tokens, e, s);
8411
+ const { overlay: n, startCountdown: o } = zn(this.tokens, e, s);
8181
8412
  pe(n);
8182
8413
  const i = () => {
8183
8414
  c(), n.remove();
@@ -8197,7 +8428,7 @@ class Zn {
8197
8428
  return new Promise((s) => {
8198
8429
  var a, c;
8199
8430
  he();
8200
- const t = Cn(e, this.tokens);
8431
+ const t = Ln(e, this.tokens);
8201
8432
  pe(t);
8202
8433
  const n = () => t.remove(), o = () => {
8203
8434
  n(), s();
@@ -8226,7 +8457,7 @@ class Zn {
8226
8457
  showTransactionProgress(e, s) {
8227
8458
  return new Promise((t) => {
8228
8459
  he();
8229
- const n = Nn(e, this.tokens);
8460
+ const n = Dn(e, this.tokens);
8230
8461
  pe(n);
8231
8462
  const o = () => n.remove();
8232
8463
  let i = !1;
@@ -8243,7 +8474,7 @@ class Zn {
8243
8474
  document.addEventListener("keydown", l);
8244
8475
  };
8245
8476
  s.then((l) => {
8246
- i || (Ln(n, l, this.tokens), c());
8477
+ i || (Mn(n, l, this.tokens), c());
8247
8478
  });
8248
8479
  });
8249
8480
  }
@@ -8252,7 +8483,7 @@ class Zn {
8252
8483
  var c, l, u;
8253
8484
  he();
8254
8485
  let t;
8255
- 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);
8486
+ e.type === "sign-message" ? t = $n(e, this.tokens) : e.type === "sign-typed-data" ? t = Bn(e, this.tokens) : e.type === "sign" ? t = Pn(e, this.tokens) : t = On(e, this.tokens), pe(t);
8256
8487
  const n = () => t.remove(), o = () => {
8257
8488
  n(), s(!0);
8258
8489
  }, i = () => {
@@ -8276,7 +8507,7 @@ class Zn {
8276
8507
  });
8277
8508
  }
8278
8509
  }
8279
- class Qn {
8510
+ class to {
8280
8511
  constructor() {
8281
8512
  this._accessToken = null, this._expiresAt = 0;
8282
8513
  }
@@ -8308,9 +8539,9 @@ class Qn {
8308
8539
  return !this._accessToken || this._expiresAt <= 0 ? !0 : Date.now() >= this._expiresAt - e;
8309
8540
  }
8310
8541
  }
8311
- function ao(r, e) {
8542
+ function lo(r, e) {
8312
8543
  r.debug;
8313
- const s = Ge.production, t = {
8544
+ const s = We.production, t = {
8314
8545
  ...r,
8315
8546
  oauthServiceUrl: s.oauthServiceUrl,
8316
8547
  authApiUrl: s.authApiUrl,
@@ -8318,22 +8549,22 @@ function ao(r, e) {
8318
8549
  }, n = {
8319
8550
  gatewayUrl: s.walletGatewayUrl,
8320
8551
  projectId: r.projectId
8321
- }, o = t.authMode !== "cookie" && Ct.isAvailable();
8552
+ }, o = t.authMode !== "cookie" && Lt.isAvailable();
8322
8553
  !o && t.authMode !== "cookie" && d.warn(
8323
8554
  "[CROSSx] IndexedDB 사용 불가 — LocalStorage fallback 사용 중.",
8324
8555
  "refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
8325
8556
  "IndexedDB를 지원하는 브라우저 사용을 권장합니다."
8326
8557
  ), t.secureStorageAvailable = o;
8327
- const i = o ? new Ct(r.projectId) : new nr(), a = new pn(), c = new gn(), l = new Ee(), u = new Qn(), h = new es();
8558
+ const i = o ? new Lt(r.projectId) : new or(), a = new fn(), c = new mn(), l = new Ie(), u = new to(), h = new ss();
8328
8559
  let _;
8329
- r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), _ = new wn(i, h)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), _ = new Le(
8560
+ r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), _ = new yn(i, h)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), _ = new ke(
8330
8561
  n,
8331
8562
  i,
8332
8563
  c,
8333
8564
  u,
8334
8565
  h
8335
8566
  ));
8336
- 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 at(
8567
+ const f = new Me(n, c), w = new eo(r.theme ?? "light", r.themeTokens), E = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w, y = new ct(
8337
8568
  t,
8338
8569
  n,
8339
8570
  i,
@@ -8342,15 +8573,15 @@ function ao(r, e) {
8342
8573
  l,
8343
8574
  _,
8344
8575
  u,
8345
- b,
8576
+ E,
8346
8577
  f,
8347
8578
  h
8348
8579
  );
8349
8580
  return typeof window < "u" && (window.__crossxSDK = y), y;
8350
8581
  }
8351
- function co(r) {
8352
- const e = eo(r), s = to(e), t = JSON.parse(s);
8353
- ro(t);
8582
+ function uo(r) {
8583
+ const e = so(r), s = ro(e), t = JSON.parse(s);
8584
+ oo(t);
8354
8585
  const { data: n } = t;
8355
8586
  return {
8356
8587
  status: t.status,
@@ -8364,7 +8595,7 @@ function co(r) {
8364
8595
  raw: t
8365
8596
  };
8366
8597
  }
8367
- function eo(r) {
8598
+ function so(r) {
8368
8599
  if (r.includes("://") && r.includes("?")) {
8369
8600
  const e = new URL(r), s = e.searchParams.get("crossx_oauth_result");
8370
8601
  if (s) return s;
@@ -8374,22 +8605,22 @@ function eo(r) {
8374
8605
  }
8375
8606
  return r;
8376
8607
  }
8377
- function to(r) {
8608
+ function ro(r) {
8378
8609
  if (r.startsWith("{"))
8379
8610
  return r;
8380
8611
  if (r.startsWith("%7B") || r.startsWith("%7b"))
8381
8612
  return decodeURIComponent(r);
8382
- const e = so(r);
8613
+ const e = no(r);
8383
8614
  return decodeURIComponent(e);
8384
8615
  }
8385
- function so(r) {
8616
+ function no(r) {
8386
8617
  if (typeof atob == "function")
8387
8618
  return atob(r);
8388
8619
  if (typeof Buffer < "u")
8389
8620
  return Buffer.from(r, "base64").toString("utf-8");
8390
8621
  throw new Error("Base64 디코딩을 지원하는 환경이 아닙니다");
8391
8622
  }
8392
- function ro(r) {
8623
+ function oo(r) {
8393
8624
  if (typeof r != "object" || r === null)
8394
8625
  throw new Error("Deeplink payload가 유효한 객체가 아닙니다");
8395
8626
  const e = r;
@@ -8407,12 +8638,12 @@ function ro(r) {
8407
8638
  }
8408
8639
  export {
8409
8640
  m as CROSSxError,
8410
- Fs as CROSSxEthereumProvider,
8411
- at as CROSSxSDK,
8412
- io as ChainId,
8641
+ Ws as CROSSxEthereumProvider,
8642
+ ct as CROSSxSDK,
8643
+ co as ChainId,
8413
8644
  p as ErrorCode,
8414
- es as PinMemoryStore,
8415
- Qn as TokenMemoryStore,
8416
- ao as createCROSSxSDK,
8417
- co as parseOAuthDeeplink
8645
+ ss as PinMemoryStore,
8646
+ to as TokenMemoryStore,
8647
+ lo as createCROSSxSDK,
8648
+ uo as parseOAuthDeeplink
8418
8649
  };