@nexus-cross/crossx-sdk-core 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +2 -2
  2. package/dist/__tests__/mocks/MockWalletProviderPort.d.ts +4 -0
  3. package/dist/__tests__/mocks/MockWalletProviderPort.d.ts.map +1 -1
  4. package/dist/adapters/chain/RemoteChainRegistryAdapter.d.ts +2 -1
  5. package/dist/adapters/chain/RemoteChainRegistryAdapter.d.ts.map +1 -1
  6. package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts +15 -0
  7. package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts.map +1 -1
  8. package/dist/adapters/wallet/MockWalletProviderAdapter.d.ts +4 -0
  9. package/dist/adapters/wallet/MockWalletProviderAdapter.d.ts.map +1 -1
  10. package/dist/adapters/wallet/RemoteWalletProviderAdapter.d.ts +6 -1
  11. package/dist/adapters/wallet/RemoteWalletProviderAdapter.d.ts.map +1 -1
  12. package/dist/core/config/environments.d.ts +28 -0
  13. package/dist/core/config/environments.d.ts.map +1 -0
  14. package/dist/core/ports/ConfirmationPort.d.ts +19 -0
  15. package/dist/core/ports/ConfirmationPort.d.ts.map +1 -1
  16. package/dist/core/ports/WalletProviderPort.d.ts +7 -0
  17. package/dist/core/ports/WalletProviderPort.d.ts.map +1 -1
  18. package/dist/core/types/index.d.ts +0 -6
  19. package/dist/core/types/index.d.ts.map +1 -1
  20. package/dist/core/types/internal.d.ts +2 -0
  21. package/dist/core/types/internal.d.ts.map +1 -1
  22. package/dist/core/usecases/SignOutUseCase.d.ts +2 -2
  23. package/dist/core/usecases/SignOutUseCase.d.ts.map +1 -1
  24. package/dist/index.cjs +205 -75
  25. package/dist/index.js +1349 -1089
  26. package/dist/sdk/CROSSxSDK.d.ts +31 -2
  27. package/dist/sdk/CROSSxSDK.d.ts.map +1 -1
  28. package/dist/sdk/factory.d.ts.map +1 -1
  29. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- var Ss = Object.defineProperty;
2
- var Es = (r, e, s) => e in r ? Ss(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
- var b = (r, e, s) => Es(r, typeof e != "symbol" ? e + "" : e, s);
4
- import { decodeJwt as Ts } from "jose";
1
+ var Ts = Object.defineProperty;
2
+ var Is = (r, e, s) => e in r ? Ts(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
+ var v = (r, e, s) => Is(r, typeof e != "symbol" ? e + "" : e, s);
4
+ import { decodeJwt as As } from "jose";
5
5
  var p = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", r.USER_REJECTED = "USER_REJECTED", r.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", r.NETWORK_ERROR = "NETWORK_ERROR", r.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", r.INVALID_CHAIN = "INVALID_CHAIN", r.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", r.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.SIGNATURE_FAILED = "SIGNATURE_FAILED", r.TRANSACTION_FAILED = "TRANSACTION_FAILED", r.PREPARE_FAILED = "PREPARE_FAILED", r.PREPARE_EXPIRED = "PREPARE_EXPIRED", r.PREPARE_MISMATCH = "PREPARE_MISMATCH", r.MIGRATION_FAILED = "MIGRATION_FAILED", r.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", r.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", 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.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(p || {});
6
- class _ extends Error {
6
+ class x extends Error {
7
7
  constructor(e, s, t) {
8
- super(s), this.code = e, this.details = t, this.name = "CROSSxError", Object.setPrototypeOf(this, _.prototype);
8
+ super(s), this.code = e, this.details = t, this.name = "CROSSxError", Object.setPrototypeOf(this, x.prototype);
9
9
  }
10
10
  toJSON() {
11
11
  return {
@@ -16,7 +16,7 @@ class _ extends Error {
16
16
  };
17
17
  }
18
18
  }
19
- const qe = {
19
+ const We = {
20
20
  // ─── CROSS ────────────────────────────────────────────
21
21
  CROSS_MAINNET: {
22
22
  caipId: "eip155:612055",
@@ -66,19 +66,19 @@ const qe = {
66
66
  testnet: !0
67
67
  }
68
68
  }, $n = Object.fromEntries(
69
- Object.entries(qe).map(([r, e]) => [r, e.caipId])
70
- ), As = new Map(
71
- Object.values(qe).map((r) => [r.caipId, r])
69
+ Object.entries(We).map(([r, e]) => [r, e.caipId])
70
+ ), Rs = new Map(
71
+ Object.values(We).map((r) => [r.caipId, r])
72
72
  );
73
73
  new Map(
74
- Object.values(qe).map((r) => [r.chainId, r])
74
+ Object.values(We).map((r) => [r.chainId, r])
75
75
  );
76
- const Is = { symbol: "", decimals: 18 };
77
- function Ke(r) {
76
+ const Os = { symbol: "", decimals: 18 };
77
+ function ze(r) {
78
78
  var e;
79
- return ((e = As.get(r)) == null ? void 0 : e.nativeCurrency) ?? Is;
79
+ return ((e = Rs.get(r)) == null ? void 0 : e.nativeCurrency) ?? Os;
80
80
  }
81
- class Rs {
81
+ class Cs {
82
82
  constructor(e, s) {
83
83
  this.sdk = e, this.chainId = s, this._listeners = /* @__PURE__ */ new Map();
84
84
  }
@@ -106,7 +106,7 @@ class Rs {
106
106
  }
107
107
  case "personal_sign":
108
108
  case "eth_sign":
109
- throw new _(
109
+ throw new x(
110
110
  p.NOT_IMPLEMENTED,
111
111
  `${e} is not yet supported. Use sdk.signMessage() directly.`
112
112
  );
@@ -114,7 +114,7 @@ class Rs {
114
114
  case "eth_signTypedData_v1":
115
115
  case "eth_signTypedData_v3":
116
116
  case "eth_signTypedData_v4":
117
- throw new _(
117
+ throw new x(
118
118
  p.NOT_IMPLEMENTED,
119
119
  `${e} is not yet supported. Use sdk.signTypedData() or sdk.signTypedDataOffchain() directly.`
120
120
  );
@@ -164,36 +164,36 @@ class Rs {
164
164
  };
165
165
  }
166
166
  }
167
- let me = null;
168
- function mt(r) {
169
- me = r;
167
+ let we = null;
168
+ function wt(r) {
169
+ we = r;
170
170
  }
171
- const f = {
171
+ const g = {
172
172
  log(...r) {
173
- if (me) {
174
- me.log(...r);
173
+ if (we) {
174
+ we.log(...r);
175
175
  return;
176
176
  }
177
177
  },
178
178
  warn(...r) {
179
- if (me) {
180
- me.warn(...r);
179
+ if (we) {
180
+ we.warn(...r);
181
181
  return;
182
182
  }
183
183
  },
184
184
  error(...r) {
185
- if (me) {
186
- me.error(...r);
185
+ if (we) {
186
+ we.error(...r);
187
187
  return;
188
188
  }
189
189
  }
190
- }, ze = "crossx_access_token", Ne = "crossx_refresh_token", Pe = "crossx_user_info";
191
- class Os {
190
+ }, Ye = "crossx_access_token", Ne = "crossx_refresh_token", Pe = "crossx_user_info";
191
+ class ks {
192
192
  constructor(e, s, t, n, o, i, a) {
193
193
  this.config = e, this.storage = s, this.crypto = t, this.oauth = n, this.transport = o, this.walletProvider = i, this.tokenStore = a, this._refreshPromise = null;
194
194
  }
195
195
  get useCookieAuth() {
196
- return this.config.authMode !== "token";
196
+ return this.config.authMode === "cookie";
197
197
  }
198
198
  /**
199
199
  * 서버 응답의 에러 코드 확인.
@@ -202,7 +202,7 @@ class Os {
202
202
  */
203
203
  checkResponseError(e, s) {
204
204
  if (e != null && e.code && e.code !== 200 && e.code > 0)
205
- throw new _(
205
+ throw new x(
206
206
  p.AUTH_FAILED,
207
207
  `${s} failed (code ${e.code}): ${e.message}`
208
208
  );
@@ -210,7 +210,7 @@ class Os {
210
210
  if (typeof t == "object" && t !== null && "code" in t) {
211
211
  const n = t;
212
212
  if (n.code && n.code !== 200 && n.code > 0)
213
- throw new _(
213
+ throw new x(
214
214
  p.AUTH_FAILED,
215
215
  `${s} failed (code ${n.code}): ${n.message}`
216
216
  );
@@ -223,55 +223,55 @@ class Os {
223
223
  const c = e == null ? void 0 : e.provider;
224
224
  let l = "/login";
225
225
  c === "google" ? l = "/google" : c === "apple" && (l = "/apple");
226
- const { oauthServiceUrl: d, authApiUrl: g } = this.config, w = `${d}${l}`;
227
- f.log(`[CROSSx] OAuth 팝업 열기 (${c || "일반"} 로그인):`, w);
226
+ const { oauthServiceUrl: d, authApiUrl: f } = this.config, w = `${d}${l}`;
227
+ g.log(`[CROSSx] OAuth 팝업 열기 (${c || "일반"} 로그인):`, w);
228
228
  const m = await this.oauth.openAuth({
229
229
  authUrl: w,
230
230
  expectedOrigin: new URL(d).origin
231
231
  });
232
- f.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", m.length, ")");
233
- const { accessToken: x, refreshToken: A } = await this.exchangeFirebaseToken(m, g);
234
- let E, C;
232
+ g.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", m.length, ")");
233
+ const { accessToken: _, refreshToken: T } = await this.exchangeFirebaseToken(m, f);
234
+ let b, A;
235
235
  try {
236
- const $ = this.crypto.decodeJWT(m);
237
- C = (n = $.firebase) == null ? void 0 : n.sign_in_provider;
238
- const B = ((o = $.firebase) == null ? void 0 : o.identities) ?? {};
239
- C === "google.com" ? E = (i = B["google.com"]) == null ? void 0 : i[0] : C === "apple.com" && (E = (a = B["apple.com"]) == null ? void 0 : a[0]), f.log("[CROSSx] OAuth provider sub 추출 — provider:", C, "hasProviderSub:", !!E);
236
+ const M = this.crypto.decodeJWT(m);
237
+ A = (n = M.firebase) == null ? void 0 : n.sign_in_provider;
238
+ const D = ((o = M.firebase) == null ? void 0 : o.identities) ?? {};
239
+ A === "google.com" ? b = (i = D["google.com"]) == null ? void 0 : i[0] : A === "apple.com" && (b = (a = D["apple.com"]) == null ? void 0 : a[0]), g.log("[CROSSx] OAuth provider sub 추출 — provider:", A, "hasProviderSub:", !!b);
240
240
  } catch {
241
- f.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
241
+ g.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
242
242
  }
243
- if (x) {
244
- const $ = this.crypto.decodeJWT(x);
245
- f.log("[CROSSx] access_token 디코딩 — sub:", $.sub, "exp:", $.exp);
246
- const B = await this.crypto.verifyJWT(x);
247
- if (t = B.signatureVerified ?? !1, !B.valid)
248
- throw f.error("[CROSSx] access_token 검증 실패"), new Error("Invalid access token");
249
- const F = B.payload;
243
+ if (_) {
244
+ const M = this.crypto.decodeJWT(_);
245
+ g.log("[CROSSx] access_token 디코딩 — sub:", M.sub, "exp:", M.exp);
246
+ const D = await this.crypto.verifyJWT(_);
247
+ if (t = D.signatureVerified ?? !1, !D.valid)
248
+ throw g.error("[CROSSx] access_token 검증 실패"), new Error("Invalid access token");
249
+ const B = D.payload;
250
250
  s = {
251
- id: F.sub,
252
- email: F.email,
253
- signInProvider: C,
254
- providerSub: E
255
- }, this.tokenStore.set(x), this.useCookieAuth || (await this.storage.set(ze, x), A && await this.storage.set(Ne, A));
251
+ id: B.sub,
252
+ email: B.email,
253
+ signInProvider: A,
254
+ providerSub: b
255
+ }, this.tokenStore.set(_), this.useCookieAuth || (await this.storage.set(Ye, _), T && await this.storage.set(Ne, T));
256
256
  } else {
257
- const $ = this.crypto.decodeJWT(m);
257
+ const M = this.crypto.decodeJWT(m);
258
258
  s = {
259
- id: $.sub,
260
- email: $.email,
261
- signInProvider: C,
262
- providerSub: E
263
- }, f.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
259
+ id: M.sub,
260
+ email: M.email,
261
+ signInProvider: A,
262
+ providerSub: b
263
+ }, g.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
264
264
  }
265
- f.log("[CROSSx] 사용자 정보 — id:", s.id);
265
+ g.log("[CROSSx] 사용자 정보 — id:", s.id);
266
266
  const q = this.useCookieAuth ? { id: s.id, signInProvider: s.signInProvider, providerSub: s.providerSub } : s;
267
- await this.storage.set(Pe, q), f.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
267
+ await this.storage.set(Pe, q), g.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
268
268
  } catch (c) {
269
- return f.error("[CROSSx] SignIn 에러 (OAuth/토큰 교환 단계):", c), {
269
+ return g.error("[CROSSx] SignIn 에러 (OAuth/토큰 교환 단계):", c), {
270
270
  success: !1,
271
271
  error: c instanceof Error ? c.message : "Sign in failed"
272
272
  };
273
273
  }
274
- return f.log("[CROSSx][Migration Phase 1] OAuth 로그인 완료, 지갑 로드 시작 — userId:", s.id), this.loadWallet(s, t);
274
+ return g.log("[CROSSx][Migration Phase 1] OAuth 로그인 완료, 지갑 로드 시작 — userId:", s.id), this.loadWallet(s, t);
275
275
  }
276
276
  /**
277
277
  * Firebase 토큰 → CROSSx 인증 교환
@@ -280,7 +280,7 @@ class Os {
280
280
  */
281
281
  async exchangeFirebaseToken(e, s) {
282
282
  const t = this.useCookieAuth, n = t ? `${s}/cross-auth/social/login/cookie` : `${s}/cross-auth/social/login`;
283
- f.log("[CROSSx] Firebase 토큰 교환 요청:", n);
283
+ g.log("[CROSSx] Firebase 토큰 교환 요청:", n);
284
284
  const o = await this.transport.request({
285
285
  url: n,
286
286
  method: "POST",
@@ -288,18 +288,18 @@ class Os {
288
288
  body: { auth_code: e, login_type: "firebase" },
289
289
  ...t ? { credentials: "include" } : {}
290
290
  });
291
- f.log("[CROSSx] 토큰 교환 응답 — status:", o.status);
291
+ g.log("[CROSSx] 토큰 교환 응답 — status:", o.status);
292
292
  const i = o.data;
293
293
  this.checkResponseError(i, "Token exchange");
294
294
  const a = this.extractAccessToken(i);
295
295
  if (t && !a)
296
- return f.log("[CROSSx] Cookie 모드 — 로그인 성공 (JWT는 HttpOnly 쿠키)"), {};
296
+ return g.log("[CROSSx] Cookie 모드 — 로그인 성공 (JWT는 HttpOnly 쿠키)"), {};
297
297
  if (!a)
298
- throw new _(
298
+ throw new x(
299
299
  p.AUTH_FAILED,
300
300
  "access_token not found in exchange response"
301
301
  );
302
- f.log("[CROSSx] access_token 교환 성공");
302
+ g.log("[CROSSx] access_token 교환 성공");
303
303
  let c;
304
304
  return t || (c = this.extractRefreshToken(i)), { accessToken: a, refreshToken: c };
305
305
  }
@@ -361,38 +361,38 @@ class Os {
361
361
  if (t.valid) {
362
362
  const n = await this.storage.get(Pe);
363
363
  if (n)
364
- return f.log("[CROSSx] restoreSession — 메모리 토큰 유효, 세션 복원"), this.loadWallet(n, t.signatureVerified);
364
+ return g.log("[CROSSx] restoreSession — 메모리 토큰 유효, 세션 복원"), this.loadWallet(n, t.signatureVerified);
365
365
  }
366
366
  this.tokenStore.clear();
367
367
  }
368
368
  if (this.useCookieAuth) {
369
- f.log("[CROSSx] restoreSession — 쿠키 기반 silentRefresh 시도");
369
+ g.log("[CROSSx] restoreSession — 쿠키 기반 silentRefresh 시도");
370
370
  const t = await this.silentRefresh();
371
371
  t && this.tokenStore.set(t);
372
372
  } else {
373
- const t = await this.storage.get(ze), n = await this.storage.get(Ne);
374
- if (f.log(
373
+ const t = await this.storage.get(Ye), n = await this.storage.get(Ne);
374
+ if (g.log(
375
375
  "[CROSSx] restoreSession — access_token:",
376
376
  t ? "있음" : "없음",
377
377
  "refresh_token:",
378
378
  n ? "있음" : "없음"
379
379
  ), !n)
380
- return f.log("[CROSSx] restoreSession — refresh_token 없음, 세션 복원 생략"), null;
380
+ return g.log("[CROSSx] restoreSession — refresh_token 없음, 세션 복원 생략"), null;
381
381
  t && this.tokenStore.set(t);
382
382
  const o = await this.silentRefresh(n);
383
- f.log("[CROSSx] restoreSession — silentRefresh 결과:", o ? "토큰 발급 성공" : "토큰 없음"), o && this.tokenStore.set(o);
383
+ g.log("[CROSSx] restoreSession — silentRefresh 결과:", o ? "토큰 발급 성공" : "토큰 없음"), o && this.tokenStore.set(o);
384
384
  }
385
385
  const s = await this.storage.get(Pe);
386
- if (f.log("[CROSSx] restoreSession — userInfo 조회:", s ? `있음 (id: ${s.id})` : "없음"), !s)
386
+ if (g.log("[CROSSx] restoreSession — userInfo 조회:", s ? `있음 (id: ${s.id})` : "없음"), !s)
387
387
  return null;
388
- f.log("[CROSSx] restoreSession — silentRefresh 성공, 세션 복원 — userId:", s.id);
388
+ g.log("[CROSSx] restoreSession — silentRefresh 성공, 세션 복원 — userId:", s.id);
389
389
  try {
390
390
  return await this.loadWallet(s, !1);
391
391
  } catch (t) {
392
- return f.warn("[CROSSx] restoreSession — 지갑 로드 실패 (세션은 유지):", t), { success: !0, user: s, tokenSignatureVerified: !1 };
392
+ return g.warn("[CROSSx] restoreSession — 지갑 로드 실패 (세션은 유지):", t), { success: !0, user: s, tokenSignatureVerified: !1 };
393
393
  }
394
394
  } catch (e) {
395
- return f.log("[CROSSx] restoreSession — 세션 복원 실패, 스토리지 정리:", e), this.tokenStore.clear(), this.useCookieAuth || await this.storage.remove(Ne), await this.storage.remove(Pe), null;
395
+ return g.log("[CROSSx] restoreSession — 세션 복원 실패, 스토리지 정리:", e), this.tokenStore.clear(), this.useCookieAuth || await this.storage.remove(Ne), await this.storage.remove(Pe), null;
396
396
  }
397
397
  }
398
398
  /**
@@ -418,66 +418,66 @@ class Os {
418
418
  body: o,
419
419
  ...t ? { credentials: "include" } : {}
420
420
  });
421
- f.log("[CROSSx] silentRefresh 응답 — status:", i.status);
421
+ g.log("[CROSSx] silentRefresh 응답 — status:", i.status);
422
422
  const a = i.data;
423
423
  this.checkResponseError(a, "Silent refresh");
424
424
  const c = this.extractAccessToken(a);
425
425
  if (t && !c) {
426
- f.log("[CROSSx] silentRefresh 성공 (cookie 갱신)");
426
+ g.log("[CROSSx] silentRefresh 성공 (cookie 갱신)");
427
427
  return;
428
428
  }
429
429
  if (!c)
430
- throw new _(p.AUTH_FAILED, "Silent refresh failed: no token in response");
430
+ throw new x(p.AUTH_FAILED, "Silent refresh failed: no token in response");
431
431
  if (this.tokenStore.set(c), !t) {
432
- await this.storage.set(ze, c);
432
+ await this.storage.set(Ye, c);
433
433
  const l = this.extractRefreshToken(a);
434
434
  l && await this.storage.set(Ne, l);
435
435
  }
436
- return f.log("[CROSSx] silentRefresh 성공"), c;
436
+ return g.log("[CROSSx] silentRefresh 성공"), c;
437
437
  }
438
438
  async loadWallet(e, s) {
439
439
  let t, n = !1;
440
440
  try {
441
- f.log("[CROSSx][Migration Phase 2] POST /mnemonic/create 호출 — userId:", e.id), t = (await this.walletProvider.getOrCreateWallet(e.id)).address, f.log("[CROSSx][Migration Phase 2] 지갑 로드 완료 (기존 백업 없음) — address:", t);
441
+ g.log("[CROSSx][Migration Phase 2] POST /mnemonic/create 호출 — userId:", e.id), t = (await this.walletProvider.getOrCreateWallet(e.id)).address, g.log("[CROSSx][Migration Phase 2] 지갑 로드 완료 (기존 백업 없음) — address:", t);
442
442
  } catch (o) {
443
- if (o instanceof _ && o.code === p.MIGRATION_BACKUP_EXISTS)
444
- f.log("[CROSSx][Migration Phase 2] Gateway -10012 감지 → needsMigration = true"), n = !0;
443
+ if (o instanceof x && o.code === p.MIGRATION_BACKUP_EXISTS)
444
+ g.log("[CROSSx][Migration Phase 2] Gateway -10012 감지 → needsMigration = true"), n = !0;
445
445
  else {
446
- if (o instanceof _ && (o.code === p.PROJECT_NOT_REGISTERED || o.code === p.PROJECT_ID_MISSING || o.code === p.ORIGIN_NOT_ALLOWED))
447
- throw f.error("[CROSSx][Migration Phase 2] 프로젝트 설정 에러:", o.message), o;
448
- f.warn("[CROSSx][Migration Phase 2] 지갑 로드 실패 (로그인은 유지):", o);
446
+ if (o instanceof x && (o.code === p.PROJECT_NOT_REGISTERED || o.code === p.PROJECT_ID_MISSING || o.code === p.ORIGIN_NOT_ALLOWED))
447
+ throw g.error("[CROSSx][Migration Phase 2] 프로젝트 설정 에러:", o.message), o;
448
+ g.warn("[CROSSx][Migration Phase 2] 지갑 로드 실패 (로그인은 유지):", o);
449
449
  }
450
450
  }
451
- return f.log("[CROSSx][Migration Phase 2] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
451
+ return g.log("[CROSSx][Migration Phase 2] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
452
452
  }
453
453
  }
454
- const Cs = "crossx_access_token", Ns = "crossx_refresh_token", Ps = "crossx_user_info";
455
- class ks {
454
+ const Ns = "crossx_access_token", Ps = "crossx_refresh_token", Ls = "crossx_user_info";
455
+ class Ds {
456
456
  constructor(e, s, t) {
457
457
  this.config = e, this.storage = s, this.tokenStore = t;
458
458
  }
459
459
  async execute() {
460
- this.tokenStore.clear(), this.config.authMode === "token" && (await this.storage.remove(Cs), await this.storage.remove(Ns)), await this.storage.remove(Ps);
460
+ this.tokenStore.clear(), this.config.authMode !== "cookie" && (await this.storage.remove(Ns), await this.storage.remove(Ps)), await this.storage.remove(Ls);
461
461
  }
462
462
  }
463
- class Ls {
463
+ class $s {
464
464
  constructor(e, s) {
465
465
  this.storage = e, this.walletProvider = s;
466
466
  }
467
467
  async execute(e, s) {
468
468
  if (!this.walletProvider.migrateWallet)
469
- throw new _(
469
+ throw new x(
470
470
  p.NOT_IMPLEMENTED,
471
471
  "Migration is not supported in the current environment"
472
472
  );
473
- f.log("[CROSSx][Migration Phase 4] MigrateWalletUseCase.execute() — pin 길이:", e.length, "sub:", s);
473
+ g.log("[CROSSx][Migration Phase 4] MigrateWalletUseCase.execute() — pin 길이:", e.length, "sub:", s);
474
474
  const t = await this.walletProvider.migrateWallet(e, s);
475
- return f.log("[CROSSx][Migration Phase 5] MigrateWalletUseCase 완료 — address:", t.address), {
475
+ return g.log("[CROSSx][Migration Phase 5] MigrateWalletUseCase 완료 — address:", t.address), {
476
476
  address: t.address
477
477
  };
478
478
  }
479
479
  }
480
- class Ds {
480
+ class Bs {
481
481
  constructor(e, s) {
482
482
  this.chainRegistry = e, this.transport = s;
483
483
  }
@@ -502,14 +502,14 @@ class Ds {
502
502
  body: o
503
503
  })).data;
504
504
  if (a != null && a.error)
505
- throw new _(
505
+ throw new x(
506
506
  p.UNKNOWN_ERROR,
507
507
  `RPC error [${e}] (${t}): ${a.error.message} (code: ${a.error.code})`
508
508
  );
509
509
  return a == null ? void 0 : a.result;
510
510
  }
511
511
  }
512
- class $s {
512
+ class Ms {
513
513
  constructor() {
514
514
  this.listeners = /* @__PURE__ */ new Map();
515
515
  }
@@ -532,17 +532,56 @@ class $s {
532
532
  this.listeners.clear();
533
533
  }
534
534
  }
535
- const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA00", bt = 130, vt = 6, St = 18, Hs = 0, Gs = 30 * 1e3, Z = class Z extends $s {
536
- constructor(e, s, t, n, o, i, a, c, l) {
537
- super(), this.storage = s, this.crypto = t, this.transport = n, this.oauth = o, this.walletProvider = i, this.tokenStore = a, this.initialized = !1, this.authenticated = !1, this.userId = null, this.address = null, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._config = Object.freeze({ ...e }), e.logger && mt(e.logger), this.confirmation = c, this.chainRegistry = l, this.jsonRpc = new Ds(l, n), this.signInUseCase = new Os(
538
- e,
539
- s,
535
+ const Ue = {
536
+ production: {
537
+ oauthServiceUrl: "https://cross-wallet-oauth.crosstoken.io",
538
+ authApiUrl: "https://cross-auth.crosstoken.io",
539
+ walletGatewayUrl: "https://embedded-wallet-gateway.crosstoken.io/api/v1"
540
+ },
541
+ staging: {
542
+ oauthServiceUrl: "https://stg-cross-wallet-oauth.crosstoken.io",
543
+ authApiUrl: "https://stg-cross-auth.crosstoken.io",
544
+ walletGatewayUrl: "https://stg-embedded-wallet-gateway.crosstoken.io/api/v1"
545
+ },
546
+ development: {
547
+ oauthServiceUrl: "https://dev-cross-wallet-oauth.crosstoken.io",
548
+ authApiUrl: "https://dev-cross-auth.crosstoken.io",
549
+ walletGatewayUrl: "https://dev-embedded-wallet-gateway.crosstoken.io/api/v1"
550
+ }
551
+ }, Us = "/crossx.config.json";
552
+ function yt(r) {
553
+ const e = r.environment;
554
+ return e && e in Ue ? Ue[e] : null;
555
+ }
556
+ async function Fs() {
557
+ try {
558
+ if (typeof __CROSSX_CONFIG__ < "u") {
559
+ const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e = yt(r);
560
+ if (e) return e;
561
+ }
562
+ } catch {
563
+ }
564
+ try {
565
+ const r = await fetch(Us);
566
+ if (r.ok) {
567
+ const e = await r.json(), s = yt(e);
568
+ if (s) return s;
569
+ }
570
+ } catch {
571
+ }
572
+ return Ue.production;
573
+ }
574
+ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA00", St = 130, Et = 6, Tt = 18, js = 0, Vs = 30 * 1e3, X = class X extends Ms {
575
+ constructor(e, s, t, n, o, i, a, c, l, d) {
576
+ super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this.authenticated = !1, this.userId = null, this.address = null, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && wt(e.logger), this.confirmation = l, this.chainRegistry = d, this.jsonRpc = new Bs(d, o), this.signInUseCase = new ks(
577
+ this.internalConfig,
540
578
  t,
541
- o,
542
579
  n,
543
580
  i,
544
- a
545
- ), this.signOutUseCase = new ks(e, s, a), this.migrateWalletUseCase = new Ls(s, i);
581
+ o,
582
+ a,
583
+ c
584
+ ), this.signOutUseCase = new Ds(this.internalConfig, t, c), this.migrateWalletUseCase = new $s(t, a);
546
585
  }
547
586
  get config() {
548
587
  return this._config;
@@ -563,12 +602,14 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
563
602
  */
564
603
  async initialize() {
565
604
  if (this.initialized) return this.authenticated ? { success: !0, address: this.address ?? void 0 } : null;
566
- console.log("[CROSSx SDK] v1.0.0 initializing...");
605
+ console.log("[CROSSx SDK] v1.0.1 initializing...");
567
606
  try {
568
- const e = await this.signInUseCase.restoreSession();
569
- return e != null && e.success && this.applyAuthResult(e), this.initialized = !0, this.emit("initialized", { restored: !!(e != null && e.success) }), e ?? null;
607
+ const e = await Fs();
608
+ this.internalConfig.oauthServiceUrl = e.oauthServiceUrl, this.internalConfig.authApiUrl = e.authApiUrl, this.internalConfig.walletGatewayUrl = e.walletGatewayUrl, this.adapterConfig.gatewayUrl = e.walletGatewayUrl;
609
+ const s = await this.signInUseCase.restoreSession();
610
+ return s != null && s.success && this.applyAuthResult(s), this.initialized = !0, this.emit("initialized", { restored: !!(s != null && s.success) }), s ?? null;
570
611
  } catch (e) {
571
- throw new _(p.AUTH_NOT_INITIALIZED, "SDK initialization failed", e);
612
+ throw new x(p.AUTH_NOT_INITIALIZED, "SDK initialization failed", e);
572
613
  }
573
614
  }
574
615
  async signIn(e) {
@@ -584,7 +625,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
584
625
  const t = await this.signInUseCase.execute(s);
585
626
  return t.success && this.applyAuthResult(t), t;
586
627
  } catch (t) {
587
- throw new _(p.AUTH_FAILED, "Sign in failed", t);
628
+ throw new x(p.AUTH_FAILED, "Sign in failed", t);
588
629
  }
589
630
  }
590
631
  async signOut() {
@@ -592,7 +633,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
592
633
  try {
593
634
  await this.signOutUseCase.execute(), this.clearAuthState();
594
635
  } catch (e) {
595
- throw new _(p.UNKNOWN_ERROR, "Sign out failed", e);
636
+ throw new x(p.UNKNOWN_ERROR, "Sign out failed", e);
596
637
  }
597
638
  }
598
639
  isAuthenticated() {
@@ -668,12 +709,12 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
668
709
  */
669
710
  async migrateWallet(e) {
670
711
  if (this.ensureAuthenticated(), !this.userId)
671
- throw new _(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
712
+ throw new x(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
672
713
  try {
673
714
  const s = await this.migrateWalletUseCase.execute(e, this.userId);
674
- return this.address = s.address, this.emit("addressChanged", { address: s.address, index: 0 }), f.log("[CROSSx] migrateWallet 완료 — address:", s.address), s;
715
+ return this.address = s.address, this.emit("addressChanged", { address: s.address, index: 0 }), g.log("[CROSSx] migrateWallet 완료 — address:", s.address), s;
675
716
  } catch (s) {
676
- throw s instanceof _ ? s : new _(
717
+ throw s instanceof x ? s : new x(
677
718
  p.MIGRATION_FAILED,
678
719
  "Wallet migration failed",
679
720
  s
@@ -695,7 +736,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
695
736
  async getAddress(e) {
696
737
  if (e !== void 0) {
697
738
  if (this.ensureAuthenticated(), !this.userId)
698
- throw new _(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
739
+ throw new x(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
699
740
  return { address: (await this.walletProvider.getAddress(this.userId, e)).address, index: e };
700
741
  }
701
742
  return !this.authenticated || !this.address ? null : { address: this.address, index: 0 };
@@ -707,7 +748,37 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
707
748
  * @returns `[{ address, index }]` 형식의 배열
708
749
  */
709
750
  async getAddresses() {
710
- return this.ensureAuthenticated(), this.address ? [{ address: this.address, index: 0 }] : [];
751
+ return this.ensureAuthenticated(), this.userId ? this.walletProvider.getAddresses(this.userId) : [];
752
+ }
753
+ /**
754
+ * 연결된 지갑 선택 모달을 표시합니다.
755
+ *
756
+ * 사용자의 전체 지갑 목록을 조회하여 선택 UI를 표시합니다.
757
+ * "add a wallet" 클릭 시 새 지갑이 파생되어 목록에 추가되며,
758
+ * 모달은 사용자가 지갑을 선택하거나 닫을 때까지 유지됩니다.
759
+ *
760
+ * SDK 내부에 "활성 지갑" 상태를 저장하지 않습니다.
761
+ * 반환된 index를 서명/전송 시 opts.index로 전달하세요.
762
+ *
763
+ * @returns 선택된 지갑 `{ address, index }` 또는 닫기 시 `null`
764
+ *
765
+ * @example
766
+ * const wallet = await sdk.selectWallet();
767
+ * if (wallet) {
768
+ * await sdk.signMessage(chainId, message, { index: wallet.index });
769
+ * }
770
+ */
771
+ async selectWallet() {
772
+ if (this.ensureAuthenticated(), !this.userId)
773
+ throw new x(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
774
+ const e = await this.walletProvider.getAddresses(this.userId);
775
+ return this.confirmation.showWalletSelector(
776
+ e,
777
+ async () => {
778
+ const s = e.length, n = { address: (await this.walletProvider.getAddress(this.userId, s)).address, index: s };
779
+ return e.push(n), n;
780
+ }
781
+ );
711
782
  }
712
783
  // ============================================================================
713
784
  // 체인 조회
@@ -729,7 +800,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
729
800
  try {
730
801
  return await this.chainRegistry.getChains();
731
802
  } catch (e) {
732
- throw e instanceof _ ? e : new _(p.UNKNOWN_ERROR, "Failed to fetch chains", e);
803
+ throw e instanceof x ? e : new x(p.UNKNOWN_ERROR, "Failed to fetch chains", e);
733
804
  }
734
805
  }
735
806
  /**
@@ -748,7 +819,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
748
819
  try {
749
820
  return await this.chainRegistry.getChain(e);
750
821
  } catch (s) {
751
- throw s instanceof _ ? s : new _(p.CHAIN_NOT_SUPPORTED, `Failed to fetch chain: ${e}`, s);
822
+ throw s instanceof x ? s : new x(p.CHAIN_NOT_SUPPORTED, `Failed to fetch chain: ${e}`, s);
752
823
  }
753
824
  }
754
825
  // ============================================================================
@@ -774,19 +845,19 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
774
845
  */
775
846
  async createWallet() {
776
847
  if (this.ensureAuthenticated(), !this.userId)
777
- throw new _(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
778
- f.log("[CROSSx] 지갑 생성 시작");
848
+ throw new x(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
849
+ g.log("[CROSSx] 지갑 생성 시작");
779
850
  try {
780
851
  const e = await this.walletProvider.getOrCreateWallet(this.userId);
781
- return this.address = e.address, this.emit("addressChanged", { address: e.address, index: 0 }), f.log("[CROSSx] 지갑 생성 완료:", e.address), { address: e.address };
852
+ return this.address = e.address, this.emit("addressChanged", { address: e.address, index: 0 }), g.log("[CROSSx] 지갑 생성 완료:", e.address), { address: e.address };
782
853
  } catch (e) {
783
- if (e instanceof _ && e.code === p.MIGRATION_BACKUP_EXISTS) {
854
+ if (e instanceof x && e.code === p.MIGRATION_BACKUP_EXISTS) {
784
855
  const s = this.providerSub ?? this.userId;
785
- f.log("[CROSSx][Migration Phase 3] createWallet() — Gateway -10012 감지, 마이그레이션 UI 시작 — migrationSub:", s);
856
+ g.log("[CROSSx][Migration Phase 3] createWallet() — Gateway -10012 감지, 마이그레이션 UI 시작 — migrationSub:", s);
786
857
  const t = await this.handleMigrationFlow(s);
787
858
  if (t)
788
859
  return this.address = t.address, this.emit("addressChanged", { address: t.address, index: 0 }), { address: t.address };
789
- throw new _(
860
+ throw new x(
790
861
  p.MIGRATION_FAILED,
791
862
  "Migration skipped by user"
792
863
  );
@@ -806,7 +877,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
806
877
  */
807
878
  async signMessage(e, s, t) {
808
879
  if (this.ensureAuthenticated(), !this.userId)
809
- throw new _(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
880
+ throw new x(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
810
881
  const n = t == null ? void 0 : t.index, o = await this.walletProvider.getAddress(this.userId, n ?? 0);
811
882
  let i;
812
883
  if (this.walletProvider.prepare && (i = (await this.walletProvider.prepare("sign-message", { message: s, from: o.address })).uuid), !await this.confirmation.requestConfirmation({
@@ -817,7 +888,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
817
888
  dappName: t == null ? void 0 : t.dappName,
818
889
  accountName: t == null ? void 0 : t.accountName
819
890
  }))
820
- throw new _(p.USER_REJECTED, "User rejected message signing");
891
+ throw new x(p.USER_REJECTED, "User rejected message signing");
821
892
  try {
822
893
  const c = await this.walletProvider.signMessage(
823
894
  this.userId,
@@ -834,7 +905,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
834
905
  address: o.address
835
906
  };
836
907
  } catch (c) {
837
- throw c instanceof _ ? c : new _(p.SIGNATURE_FAILED, `Message signing failed (${e})`, c);
908
+ throw c instanceof x ? c : new x(p.SIGNATURE_FAILED, `Message signing failed (${e})`, c);
838
909
  }
839
910
  }
840
911
  /**
@@ -860,10 +931,10 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
860
931
  */
861
932
  async signTypedData(e, s, t) {
862
933
  if (this.ensureAuthenticated(), !this.userId)
863
- throw new _(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
934
+ throw new x(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
864
935
  if (!this.walletProvider.signTypedData)
865
- throw new _(p.NOT_IMPLEMENTED, "signTypedData is not implemented");
866
- Z.validateTypedDataChainId(e, s);
936
+ throw new x(p.NOT_IMPLEMENTED, "signTypedData is not implemented");
937
+ X.validateTypedDataChainId(e, s);
867
938
  const n = await this.walletProvider.getAddress(this.userId, (t == null ? void 0 : t.index) ?? 0);
868
939
  let o;
869
940
  if (this.walletProvider.prepare && (o = (await this.walletProvider.prepare("sign-typed-data", { typedData: s, from: n.address })).uuid), !await this.confirmation.requestConfirmation({
@@ -874,7 +945,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
874
945
  dappName: t == null ? void 0 : t.dappName,
875
946
  accountName: t == null ? void 0 : t.accountName
876
947
  }))
877
- throw new _(p.USER_REJECTED, "User rejected typed data signing");
948
+ throw new x(p.USER_REJECTED, "User rejected typed data signing");
878
949
  try {
879
950
  const a = await this.walletProvider.signTypedData(
880
951
  this.userId,
@@ -884,13 +955,13 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
884
955
  o,
885
956
  n.address
886
957
  );
887
- return Z.validateSignatureFormat(a.signature), {
958
+ return X.validateSignatureFormat(a.signature), {
888
959
  chainId: e,
889
960
  signature: a.signature,
890
961
  address: n.address
891
962
  };
892
963
  } catch (a) {
893
- throw a instanceof _ ? a : new _(p.SIGNATURE_FAILED, `Typed data signing failed (${e})`, a);
964
+ throw a instanceof x ? a : new x(p.SIGNATURE_FAILED, `Typed data signing failed (${e})`, a);
894
965
  }
895
966
  }
896
967
  /**
@@ -913,7 +984,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
913
984
  * });
914
985
  */
915
986
  async signTypedDataOffchain(e, s) {
916
- return this.signTypedData(Z.OFFCHAIN_CHAIN_ID, e, s);
987
+ return this.signTypedData(X.OFFCHAIN_CHAIN_ID, e, s);
917
988
  }
918
989
  // ============================================================================
919
990
  // 트랜잭션
@@ -926,11 +997,11 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
926
997
  */
927
998
  async signTransaction(e, s, t) {
928
999
  if (this.ensureAuthenticated(), !this.userId)
929
- throw new _(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
1000
+ throw new x(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
930
1001
  const n = await this.withResolvedGasAndFee(s, e);
931
1002
  let o;
932
1003
  this.walletProvider.prepare && (o = (await this.walletProvider.prepare("sign", { tx: n })).uuid);
933
- const i = Ke(e);
1004
+ const i = ze(e);
934
1005
  if (!await this.confirmation.requestConfirmation({
935
1006
  type: "sign",
936
1007
  chainId: e,
@@ -947,7 +1018,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
947
1018
  dappName: t == null ? void 0 : t.dappName,
948
1019
  accountName: t == null ? void 0 : t.accountName
949
1020
  }))
950
- throw new _(p.USER_REJECTED, "User rejected transaction signing");
1021
+ throw new x(p.USER_REJECTED, "User rejected transaction signing");
951
1022
  try {
952
1023
  const c = await this.walletProvider.signTransaction(
953
1024
  this.userId,
@@ -956,15 +1027,15 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
956
1027
  t == null ? void 0 : t.index,
957
1028
  o
958
1029
  );
959
- return Z.validateSignedTxFormat(c.signature), {
1030
+ return X.validateSignedTxFormat(c.signature), {
960
1031
  chainId: e,
961
1032
  signedTx: c.signature,
962
1033
  txHash: c.txHash ?? ""
963
1034
  };
964
1035
  } catch (c) {
965
- if (c instanceof _) throw c;
1036
+ if (c instanceof x) throw c;
966
1037
  const l = c instanceof Error ? c.message : String(c);
967
- throw new _(
1038
+ throw new x(
968
1039
  p.SIGNATURE_FAILED,
969
1040
  `Transaction signing failed (${e}): ${l}`,
970
1041
  c
@@ -979,11 +1050,11 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
979
1050
  */
980
1051
  async sendTransaction(e, s, t) {
981
1052
  if (this.ensureAuthenticated(), !this.userId)
982
- throw new _(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
1053
+ throw new x(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
983
1054
  const n = await this.withResolvedGasAndFee(s, e);
984
1055
  let o;
985
1056
  this.walletProvider.prepare && (o = (await this.walletProvider.prepare("send", { tx: n })).uuid);
986
- const i = Ke(e);
1057
+ const i = ze(e);
987
1058
  if (!await this.confirmation.requestConfirmation({
988
1059
  type: "send",
989
1060
  chainId: e,
@@ -1000,7 +1071,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1000
1071
  dappName: t == null ? void 0 : t.dappName,
1001
1072
  accountName: t == null ? void 0 : t.accountName
1002
1073
  }))
1003
- throw new _(p.USER_REJECTED, "User rejected transaction");
1074
+ throw new x(p.USER_REJECTED, "User rejected transaction");
1004
1075
  try {
1005
1076
  let c;
1006
1077
  if (this.walletProvider.sendTransaction)
@@ -1023,7 +1094,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1023
1094
  return { chainId: e, txHash: c, status: "pending" };
1024
1095
  } catch (c) {
1025
1096
  const l = c instanceof Error ? c.message : String(c);
1026
- throw new _(
1097
+ throw new x(
1027
1098
  p.TRANSACTION_FAILED,
1028
1099
  `Transaction failed (${e}): ${l}`,
1029
1100
  c
@@ -1049,14 +1120,14 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1049
1120
  * @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
1050
1121
  */
1051
1122
  async waitForTxAndGetReceipt(e, s, t = {}) {
1052
- const n = t.intervalMs ?? Ms, o = Fs, i = t.timeoutMs ?? wt, a = Date.now() + i;
1123
+ const n = t.intervalMs ?? Gs, o = qs, i = t.timeoutMs ?? bt, a = Date.now() + i;
1053
1124
  let c = n;
1054
1125
  for (; Date.now() < a; ) {
1055
1126
  const l = await this.getTransactionReceipt(e, s);
1056
1127
  if (l) return l;
1057
1128
  await new Promise((d) => setTimeout(d, c)), c = Math.min(c * 2, o);
1058
1129
  }
1059
- throw new _(
1130
+ throw new x(
1060
1131
  p.UNKNOWN_ERROR,
1061
1132
  `Transaction receipt timeout (${e})`
1062
1133
  );
@@ -1077,37 +1148,37 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1077
1148
  * logger.log(receipt.status); // '0x1' | '0x0'
1078
1149
  */
1079
1150
  async sendTransactionWithWaitForReceipt(e, s, t = {}) {
1080
- var w, m;
1081
- const { txHash: n } = await this.sendTransaction(e, s), o = t.intervalMs ?? ((w = this._config.receiptPolling) == null ? void 0 : w.intervalMs) ?? Bs, i = t.timeoutMs ?? ((m = this._config.receiptPolling) == null ? void 0 : m.timeoutMs) ?? wt, a = Ke(e), c = s.from ?? "";
1082
- let l, d;
1083
- const g = this.waitForTxAndGetReceipt(n, e, { intervalMs: o, timeoutMs: i }).then((x) => {
1084
- l = x;
1085
- const A = BigInt(x.gasUsed) * BigInt(x.effectiveGasPrice), E = s.value ? BigInt(s.value) : 0n, C = Z.formatTxAmount(s.value, a.symbol, a.decimals), q = Z.formatTxAmount("0x" + A.toString(16), a.symbol, a.decimals), $ = Z.formatTxAmount("0x" + (E + A).toString(16), a.symbol, a.decimals);
1151
+ var T, b;
1152
+ const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((T = this._config.receiptPolling) == null ? void 0 : T.intervalMs) ?? Hs, l = o ?? ((b = this._config.receiptPolling) == null ? void 0 : b.timeoutMs) ?? bt, d = ze(e), f = s.from ?? "";
1153
+ let w, m;
1154
+ const _ = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((A) => {
1155
+ w = A;
1156
+ const q = BigInt(A.gasUsed) * BigInt(A.effectiveGasPrice), M = s.value ? BigInt(s.value) : 0n, D = X.formatTxAmount(s.value, d.symbol, d.decimals), B = X.formatTxAmount("0x" + q.toString(16), d.symbol, d.decimals), Q = X.formatTxAmount("0x" + (M + q).toString(16), d.symbol, d.decimals);
1086
1157
  return {
1087
1158
  chainId: e,
1088
- txHash: n,
1089
- from: x.from,
1090
- to: x.to ?? s.to,
1091
- amount: C,
1092
- fees: q,
1093
- total: $,
1094
- nativeSymbol: a.symbol,
1095
- status: x.status === "0x1" ? "success" : "reverted"
1159
+ txHash: a,
1160
+ from: A.from,
1161
+ to: A.to ?? s.to,
1162
+ amount: D,
1163
+ fees: B,
1164
+ total: Q,
1165
+ nativeSymbol: d.symbol,
1166
+ status: A.status === "0x1" ? "success" : "reverted"
1096
1167
  };
1097
- }).catch((x) => (d = x instanceof Error ? x : new Error(String(x)), {
1168
+ }).catch((A) => (m = A instanceof Error ? A : new Error(String(A)), {
1098
1169
  chainId: e,
1099
- txHash: n,
1100
- from: c,
1170
+ txHash: a,
1171
+ from: f,
1101
1172
  to: s.to,
1102
- amount: Z.formatTxAmount(s.value, a.symbol, a.decimals),
1103
- nativeSymbol: a.symbol,
1173
+ amount: X.formatTxAmount(s.value, d.symbol, d.decimals),
1174
+ nativeSymbol: d.symbol,
1104
1175
  status: "timeout"
1105
1176
  }));
1106
1177
  if (await this.confirmation.showTransactionProgress(
1107
- { chainId: e, txHash: n, from: c, to: s.to },
1108
- g
1109
- ), d) throw d;
1110
- return { chainId: e, txHash: n, receipt: l };
1178
+ { chainId: e, txHash: a, from: f, to: s.to },
1179
+ _
1180
+ ), m) throw m;
1181
+ return { chainId: e, txHash: a, receipt: w };
1111
1182
  }
1112
1183
  // ============================================================================
1113
1184
  // Gas 조회
@@ -1127,7 +1198,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1127
1198
  return await this.walletRpc("eth_gasPrice", [], e);
1128
1199
  } catch (s) {
1129
1200
  const t = s instanceof Error ? s.message : String(s);
1130
- throw new _(p.GAS_ESTIMATION_FAILED, `Failed to get gas price (${e}): ${t}`, s);
1201
+ throw new x(p.GAS_ESTIMATION_FAILED, `Failed to get gas price (${e}): ${t}`, s);
1131
1202
  }
1132
1203
  }
1133
1204
  /**
@@ -1148,7 +1219,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1148
1219
  return await this.walletRpc("eth_estimateGas", [t], s);
1149
1220
  } catch (n) {
1150
1221
  const o = n instanceof Error ? n.message : String(n);
1151
- throw new _(p.GAS_ESTIMATION_FAILED, `Failed to estimate gas (${s}): ${o}`, n);
1222
+ throw new x(p.GAS_ESTIMATION_FAILED, `Failed to estimate gas (${s}): ${o}`, n);
1152
1223
  }
1153
1224
  }
1154
1225
  /**
@@ -1169,7 +1240,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1169
1240
  return (s == null ? void 0 : s.baseFeePerGas) ?? null;
1170
1241
  } catch (s) {
1171
1242
  const t = s instanceof Error ? s.message : String(s);
1172
- throw new _(p.GAS_ESTIMATION_FAILED, `Failed to get baseFeePerGas (${e}): ${t}`, s);
1243
+ throw new x(p.GAS_ESTIMATION_FAILED, `Failed to get baseFeePerGas (${e}): ${t}`, s);
1173
1244
  }
1174
1245
  }
1175
1246
  /**
@@ -1188,7 +1259,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1188
1259
  return await this.walletRpc("eth_maxPriorityFeePerGas", [], e);
1189
1260
  } catch (s) {
1190
1261
  const t = s instanceof Error ? s.message : String(s);
1191
- throw new _(p.GAS_ESTIMATION_FAILED, `Failed to get maxPriorityFeePerGas (${e}): ${t}`, s);
1262
+ throw new x(p.GAS_ESTIMATION_FAILED, `Failed to get maxPriorityFeePerGas (${e}): ${t}`, s);
1192
1263
  }
1193
1264
  }
1194
1265
  // ============================================================================
@@ -1206,9 +1277,9 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1206
1277
  const t = await this.jsonRpc.call("eth_getTransactionCount", [s, "pending"], e);
1207
1278
  return parseInt(t ?? "0x0", 16);
1208
1279
  } catch (t) {
1209
- if (t instanceof _) throw t;
1280
+ if (t instanceof x) throw t;
1210
1281
  const n = t instanceof Error ? t.message : String(t);
1211
- throw new _(p.UNKNOWN_ERROR, `Failed to get nonce: ${n}`, t);
1282
+ throw new x(p.UNKNOWN_ERROR, `Failed to get nonce: ${n}`, t);
1212
1283
  }
1213
1284
  }
1214
1285
  /**
@@ -1223,11 +1294,11 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1223
1294
  return { wei: "0x0", formatted: "0", chainId: e };
1224
1295
  try {
1225
1296
  const n = await this.jsonRpc.call("eth_getBalance", [s, "latest"], e) ?? "0x0";
1226
- return { wei: n, formatted: Z.formatWei(n), chainId: e };
1297
+ return { wei: n, formatted: X.formatWei(n), chainId: e };
1227
1298
  } catch (t) {
1228
- if (t instanceof _) throw t;
1299
+ if (t instanceof x) throw t;
1229
1300
  const n = t instanceof Error ? t.message : String(t);
1230
- throw new _(p.UNKNOWN_ERROR, `Failed to get balance (${e}): ${n}`, t);
1301
+ throw new x(p.UNKNOWN_ERROR, `Failed to get balance (${e}): ${n}`, t);
1231
1302
  }
1232
1303
  }
1233
1304
  static formatWei(e) {
@@ -1235,7 +1306,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1235
1306
  try {
1236
1307
  const s = BigInt(e);
1237
1308
  if (s === 0n) return "0";
1238
- const t = 10n ** BigInt(St), n = s / t, i = (s % t).toString().padStart(St, "0").replace(/0+$/, "").slice(0, vt);
1309
+ const t = 10n ** BigInt(Tt), n = s / t, i = (s % t).toString().padStart(Tt, "0").replace(/0+$/, "").slice(0, Et);
1239
1310
  return i ? `${n}.${i}` : `${n}`;
1240
1311
  } catch {
1241
1312
  return "?";
@@ -1260,7 +1331,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1260
1331
  * const client = createWalletClient({ transport: custom(provider) });
1261
1332
  */
1262
1333
  getProvider(e) {
1263
- return this.ensureAuthenticated(), new Rs(this, e);
1334
+ return this.ensureAuthenticated(), new Cs(this, e);
1264
1335
  }
1265
1336
  /**
1266
1337
  * 범용 JSON-RPC 요청 — 노드에 직접 연결.
@@ -1276,9 +1347,9 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1276
1347
  try {
1277
1348
  return await this.jsonRpc.call(e, s, t);
1278
1349
  } catch (n) {
1279
- if (n instanceof _) throw n;
1350
+ if (n instanceof x) throw n;
1280
1351
  const o = n instanceof Error ? n.message : String(n);
1281
- throw new _(p.UNKNOWN_ERROR, `rpcRequest failed [${e}] (${t}): ${o}`, n);
1352
+ throw new x(p.UNKNOWN_ERROR, `walletRpc failed [${e}] (${t}): ${o}`, n);
1282
1353
  }
1283
1354
  }
1284
1355
  // ============================================================================
@@ -1293,7 +1364,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1293
1364
  try {
1294
1365
  const n = BigInt(e);
1295
1366
  if (n === 0n) return;
1296
- const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0, vt).replace(/0+$/, "");
1367
+ const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0, Et).replace(/0+$/, "");
1297
1368
  return `${c ? `${i}.${c}` : `${i}`} ${s}`;
1298
1369
  } catch {
1299
1370
  return;
@@ -1306,26 +1377,26 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1306
1377
  * 3) migrateWallet API 호출
1307
1378
  */
1308
1379
  async handleMigrationFlow(e) {
1309
- f.log('[CROSSx][Migration Phase 3] "Wallet Found" 팝업 표시');
1380
+ g.log('[CROSSx][Migration Phase 3] "Wallet Found" 팝업 표시');
1310
1381
  const s = await this.confirmation.showMigrationFoundPrompt();
1311
- if (f.log("[CROSSx][Migration Phase 3] 사용자 선택:", s), s === "skip")
1312
- return f.log("[CROSSx][Migration Phase 3] 사용자가 마이그레이션을 건너뜀 → 종료"), null;
1382
+ if (g.log("[CROSSx][Migration Phase 3] 사용자 선택:", s), s === "skip")
1383
+ return g.log("[CROSSx][Migration Phase 3] 사용자가 마이그레이션을 건너뜀 → 종료"), null;
1313
1384
  let t, n = 0;
1314
1385
  for (; ; ) {
1315
- n++, f.log(`[CROSSx][Migration Phase 4] PIN 입력 팝업 표시 (시도 #${n})`, t ? `— 이전 에러: ${t}` : "");
1386
+ n++, g.log(`[CROSSx][Migration Phase 4] PIN 입력 팝업 표시 (시도 #${n})`, t ? `— 이전 에러: ${t}` : "");
1316
1387
  const o = await this.confirmation.showPinInputPrompt(t);
1317
1388
  if (o === null)
1318
- return f.log("[CROSSx][Migration Phase 4] 사용자가 PIN 입력을 취소함 → 종료"), null;
1319
- f.log(`[CROSSx][Migration Phase 4] PIN 입력 완료 (${o.length}자리), Gateway 마이그레이션 API 호출`);
1389
+ return g.log("[CROSSx][Migration Phase 4] 사용자가 PIN 입력을 취소함 → 종료"), null;
1390
+ g.log(`[CROSSx][Migration Phase 4] PIN 입력 완료 (${o.length}자리), Gateway 마이그레이션 API 호출`);
1320
1391
  try {
1321
1392
  const i = await this.migrateWalletUseCase.execute(o, e);
1322
- return f.log("[CROSSx][Migration Phase 5] 마이그레이션 성공 — address:", i.address), i;
1393
+ return g.log("[CROSSx][Migration Phase 5] 마이그레이션 성공 — address:", i.address), i;
1323
1394
  } catch (i) {
1324
- if (i instanceof _ && i.code === p.MIGRATION_FAILED) {
1325
- f.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 #${n}) — 재시도 요청`), t = "Incorrect PIN. Please try again.";
1395
+ if (i instanceof x && i.code === p.MIGRATION_FAILED) {
1396
+ g.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 #${n}) — 재시도 요청`), t = "Incorrect PIN. Please try again.";
1326
1397
  continue;
1327
1398
  }
1328
- throw f.error("[CROSSx][Migration Phase 4] 마이그레이션 실패 (복구 불가):", i), i;
1399
+ throw g.error("[CROSSx][Migration Phase 4] 마이그레이션 실패 (복구 불가):", i), i;
1329
1400
  }
1330
1401
  }
1331
1402
  }
@@ -1345,16 +1416,16 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1345
1416
  const t = (l) => !(l != null && l.trim()), n = e.nonce === void 0 || e.nonce === null, o = t(e.gasLimit), i = t(e.gasPrice) && t(e.maxFeePerGas), a = !t(e.maxFeePerGas) && t(e.maxPriorityFeePerGas);
1346
1417
  if (!n && !o && !i && !a) return e;
1347
1418
  const c = { ...e };
1348
- if (n && (f.log("[CROSSx] nonce 비어있음 → eth_getTransactionCount 호출"), c.nonce = await this.getNonce(s), f.log("[CROSSx] nonce 결과:", c.nonce)), o && (f.log("[CROSSx] gasLimit 비어있음 → eth_estimateGas 호출"), c.gasLimit = await this.estimateGas(e, s), f.log("[CROSSx] estimateGas 결과:", c.gasLimit)), i) {
1349
- f.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
1419
+ if (n && (g.log("[CROSSx] nonce 비어있음 → eth_getTransactionCount 호출"), c.nonce = await this.getNonce(s), g.log("[CROSSx] nonce 결과:", c.nonce)), o && (g.log("[CROSSx] gasLimit 비어있음 → eth_estimateGas 호출"), c.gasLimit = await this.estimateGas(e, s), g.log("[CROSSx] estimateGas 결과:", c.gasLimit)), i) {
1420
+ g.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
1350
1421
  const l = await this.getBaseFeePerGas(s);
1351
1422
  if (l) {
1352
- const d = yt;
1353
- c.maxFeePerGas = "0x" + (BigInt(l) + BigInt(d)).toString(16), c.maxPriorityFeePerGas = d, f.log("[CROSSx] Dynamic 체인 감지 — baseFee:", l, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
1423
+ const d = vt;
1424
+ c.maxFeePerGas = "0x" + (BigInt(l) + BigInt(d)).toString(16), c.maxPriorityFeePerGas = d, g.log("[CROSSx] Dynamic 체인 감지 — baseFee:", l, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
1354
1425
  } else
1355
- c.gasPrice = Us, f.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
1426
+ c.gasPrice = Ws, g.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
1356
1427
  }
1357
- return !i && a && (c.maxPriorityFeePerGas = yt, f.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
1428
+ return !i && a && (c.maxPriorityFeePerGas = vt, g.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
1358
1429
  }
1359
1430
  /**
1360
1431
  * EIP-712 signTypedData 호출 시 chainId와 typedData.domain.chainId 정합성 검증.
@@ -1363,10 +1434,10 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1363
1434
  * - chainId가 '0' → domain.chainId가 없거나 0이어야 함
1364
1435
  */
1365
1436
  static validateTypedDataChainId(e, s) {
1366
- const t = Z.extractDomainChainId(s);
1437
+ const t = X.extractDomainChainId(s);
1367
1438
  if (e === "0") {
1368
1439
  if (t !== void 0 && t !== 0)
1369
- throw new _(
1440
+ throw new x(
1370
1441
  p.TYPED_DATA_CHAIN_ID_MISMATCH,
1371
1442
  `Off-chain signing (chainId=0) requires typedData.domain.chainId to be absent or 0, got ${t}`
1372
1443
  );
@@ -1376,12 +1447,12 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1376
1447
  if (n) {
1377
1448
  const o = Number(n[1]);
1378
1449
  if (t === void 0)
1379
- throw new _(
1450
+ throw new x(
1380
1451
  p.TYPED_DATA_CHAIN_ID_MISMATCH,
1381
1452
  `On-chain signing (${e}) requires typedData.domain.chainId to be present`
1382
1453
  );
1383
1454
  if (t !== o)
1384
- throw new _(
1455
+ throw new x(
1385
1456
  p.TYPED_DATA_CHAIN_ID_MISMATCH,
1386
1457
  `typedData.domain.chainId (${t}) does not match chainId (${e}, expected ${o})`
1387
1458
  );
@@ -1400,20 +1471,20 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1400
1471
  static validateSignatureFormat(e) {
1401
1472
  const s = e.startsWith("0x") ? e.slice(2) : e;
1402
1473
  if (!/^[0-9a-fA-F]+$/.test(s))
1403
- throw new _(p.SIGNATURE_FAILED, "Invalid signature: not a valid hex string");
1404
- if (s.length !== bt)
1405
- throw new _(
1474
+ throw new x(p.SIGNATURE_FAILED, "Invalid signature: not a valid hex string");
1475
+ if (s.length !== St)
1476
+ throw new x(
1406
1477
  p.SIGNATURE_FAILED,
1407
- `Invalid signature length: expected ${bt} hex chars (65 bytes), got ${s.length}`
1478
+ `Invalid signature length: expected ${St} hex chars (65 bytes), got ${s.length}`
1408
1479
  );
1409
1480
  }
1410
1481
  /** RLP-encoded signed transaction 형식 검증 */
1411
1482
  static validateSignedTxFormat(e) {
1412
1483
  const s = e.startsWith("0x") ? e.slice(2) : e;
1413
1484
  if (!/^[0-9a-fA-F]+$/.test(s))
1414
- throw new _(p.SIGNATURE_FAILED, "Invalid signedTx: not a valid hex string");
1485
+ throw new x(p.SIGNATURE_FAILED, "Invalid signedTx: not a valid hex string");
1415
1486
  if (s.length < 2)
1416
- throw new _(p.SIGNATURE_FAILED, "Invalid signedTx: too short");
1487
+ throw new x(p.SIGNATURE_FAILED, "Invalid signedTx: too short");
1417
1488
  }
1418
1489
  /**
1419
1490
  * Gateway 서명 응답의 ecrecover 검증 (XF-036)
@@ -1426,23 +1497,23 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1426
1497
  try {
1427
1498
  const n = this.crypto.recoverPersonalSignSigner(e, s);
1428
1499
  if (n.toLowerCase() !== t.toLowerCase())
1429
- throw f.error("[CROSSx] 서명 검증 실패: 서명자 주소 불일치", {
1500
+ throw g.error("[CROSSx] 서명 검증 실패: 서명자 주소 불일치", {
1430
1501
  expected: t,
1431
1502
  recovered: n
1432
- }), new _(
1503
+ }), new x(
1433
1504
  p.SIGNATURE_SIGNER_MISMATCH,
1434
1505
  `Signature signer mismatch: expected ${t}, recovered ${n}`
1435
1506
  );
1436
- f.log("[CROSSx] 서명 ecrecover 검증 성공");
1507
+ g.log("[CROSSx] 서명 ecrecover 검증 성공");
1437
1508
  } catch (n) {
1438
- if (n instanceof _) throw n;
1439
- f.warn("[CROSSx] ecrecover 검증 중 예외 (무시):", n);
1509
+ if (n instanceof x) throw n;
1510
+ g.warn("[CROSSx] ecrecover 검증 중 예외 (무시):", n);
1440
1511
  }
1441
1512
  }
1442
1513
  /** AuthResult를 내부 상태에 반영합니다. */
1443
1514
  applyAuthResult(e) {
1444
1515
  var s, t, n, o;
1445
- this.authenticated = e.success, this.userId = ((s = e.user) == null ? void 0 : s.id) ?? null, this.address = e.address ?? null, this.userEmail = ((t = e.user) == null ? void 0 : t.email) ?? null, this.providerSub = ((n = e.user) == null ? void 0 : n.providerSub) ?? null, this.loginType = Z.normalizeLoginType((o = e.user) == null ? void 0 : o.signInProvider), this.tokenSignatureVerified = e.tokenSignatureVerified ?? !1, this.emit("authChanged", {
1516
+ this.authenticated = e.success, this.userId = ((s = e.user) == null ? void 0 : s.id) ?? null, this.address = e.address ?? null, this.userEmail = ((t = e.user) == null ? void 0 : t.email) ?? null, this.providerSub = ((n = e.user) == null ? void 0 : n.providerSub) ?? null, this.loginType = X.normalizeLoginType((o = e.user) == null ? void 0 : o.signInProvider), this.tokenSignatureVerified = e.tokenSignatureVerified ?? !1, this.emit("authChanged", {
1446
1517
  isAuthenticated: this.authenticated,
1447
1518
  address: this.address,
1448
1519
  userId: this.userId
@@ -1465,14 +1536,14 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1465
1536
  }
1466
1537
  ensureInitialized() {
1467
1538
  if (!this.initialized)
1468
- throw new _(
1539
+ throw new x(
1469
1540
  p.AUTH_NOT_INITIALIZED,
1470
1541
  "SDK is not initialized. Call initialize() first."
1471
1542
  );
1472
1543
  }
1473
1544
  ensureAuthenticated() {
1474
1545
  if (this.ensureInitialized(), !this.authenticated)
1475
- throw new _(
1546
+ throw new x(
1476
1547
  p.AUTH_NOT_AUTHENTICATED,
1477
1548
  "Not authenticated. Call signIn() first."
1478
1549
  );
@@ -1484,12 +1555,12 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1484
1555
  * dispose 후 SDK 인스턴스는 더 이상 사용할 수 없습니다.
1485
1556
  */
1486
1557
  dispose() {
1487
- this.clearAuthState(), this.tokenStore.clear(), this.initialized = !1, this.removeAllListeners(), mt(null);
1558
+ this.clearAuthState(), this.tokenStore.clear(), this.initialized = !1, this.removeAllListeners(), wt(null);
1488
1559
  }
1489
1560
  };
1490
- Z.OFFCHAIN_CHAIN_ID = "0";
1491
- let tt = Z;
1492
- class qs {
1561
+ X.OFFCHAIN_CHAIN_ID = "0";
1562
+ let st = X;
1563
+ class Ks {
1493
1564
  constructor() {
1494
1565
  this.prefix = "crossx_";
1495
1566
  }
@@ -1498,7 +1569,7 @@ class qs {
1498
1569
  const t = JSON.stringify(s);
1499
1570
  localStorage.setItem(this.prefix + e, t);
1500
1571
  } catch (t) {
1501
- throw f.error("Storage set error:", t), t;
1572
+ throw g.error("Storage set error:", t), t;
1502
1573
  }
1503
1574
  }
1504
1575
  async get(e) {
@@ -1506,14 +1577,14 @@ class qs {
1506
1577
  const s = localStorage.getItem(this.prefix + e);
1507
1578
  return s ? JSON.parse(s) : null;
1508
1579
  } catch (s) {
1509
- return f.error("Storage get error:", s), null;
1580
+ return g.error("Storage get error:", s), null;
1510
1581
  }
1511
1582
  }
1512
1583
  async remove(e) {
1513
1584
  try {
1514
1585
  localStorage.removeItem(this.prefix + e);
1515
1586
  } catch (s) {
1516
- throw f.error("Storage remove error:", s), s;
1587
+ throw g.error("Storage remove error:", s), s;
1517
1588
  }
1518
1589
  }
1519
1590
  async clear() {
@@ -1522,12 +1593,12 @@ class qs {
1522
1593
  s.startsWith(this.prefix) && localStorage.removeItem(s);
1523
1594
  });
1524
1595
  } catch (e) {
1525
- throw f.error("Storage clear error:", e), e;
1596
+ throw g.error("Storage clear error:", e), e;
1526
1597
  }
1527
1598
  }
1528
1599
  }
1529
- const Ws = "crossx-sdk", js = 1, ve = "data", ke = "keys", Et = "aes-primary", Vs = 12;
1530
- class Tt {
1600
+ const zs = "crossx-sdk", Ys = 1, Se = "data", Le = "keys", It = "aes-primary", Zs = 12;
1601
+ class At {
1531
1602
  constructor() {
1532
1603
  this.db = null, this.cryptoKey = null, this.initPromise = null;
1533
1604
  }
@@ -1536,10 +1607,10 @@ class Tt {
1536
1607
  }
1537
1608
  openDB() {
1538
1609
  return new Promise((e, s) => {
1539
- const t = indexedDB.open(Ws, js);
1610
+ const t = indexedDB.open(zs, Ys);
1540
1611
  t.onupgradeneeded = () => {
1541
1612
  const n = t.result;
1542
- n.objectStoreNames.contains(ve) || n.createObjectStore(ve), n.objectStoreNames.contains(ke) || n.createObjectStore(ke);
1613
+ n.objectStoreNames.contains(Se) || n.createObjectStore(Se), n.objectStoreNames.contains(Le) || n.createObjectStore(Le);
1543
1614
  }, t.onsuccess = () => e(t.result), t.onerror = () => s(t.error);
1544
1615
  });
1545
1616
  }
@@ -1569,7 +1640,7 @@ class Tt {
1569
1640
  }
1570
1641
  async init() {
1571
1642
  this.db = await this.openDB();
1572
- const e = await this.idbGet(ke, Et);
1643
+ const e = await this.idbGet(Le, It);
1573
1644
  if (e) {
1574
1645
  this.cryptoKey = e;
1575
1646
  return;
@@ -1578,10 +1649,10 @@ class Tt {
1578
1649
  { name: "AES-GCM", length: 256 },
1579
1650
  !1,
1580
1651
  ["encrypt", "decrypt"]
1581
- ), await this.idbPut(ke, Et, this.cryptoKey);
1652
+ ), await this.idbPut(Le, It, this.cryptoKey);
1582
1653
  }
1583
1654
  async encrypt(e) {
1584
- const s = new Uint8Array(Vs);
1655
+ const s = new Uint8Array(Zs);
1585
1656
  crypto.getRandomValues(s);
1586
1657
  const t = new TextEncoder().encode(e), n = await crypto.subtle.encrypt(
1587
1658
  { name: "AES-GCM", iv: s },
@@ -1602,34 +1673,34 @@ class Tt {
1602
1673
  try {
1603
1674
  await this.ensureReady();
1604
1675
  const t = JSON.stringify(s), n = await this.encrypt(t);
1605
- await this.idbPut(ve, e, n);
1676
+ await this.idbPut(Se, e, n);
1606
1677
  } catch (t) {
1607
- throw f.error("[CROSSx] IndexedDB set error:", t), t;
1678
+ throw g.error("[CROSSx] IndexedDB set error:", t), t;
1608
1679
  }
1609
1680
  }
1610
1681
  async get(e) {
1611
1682
  try {
1612
1683
  await this.ensureReady();
1613
- const s = await this.idbGet(ve, e);
1684
+ const s = await this.idbGet(Se, e);
1614
1685
  if (!s) return null;
1615
1686
  const t = await this.decrypt(s);
1616
1687
  return JSON.parse(t);
1617
1688
  } catch (s) {
1618
- return f.error("[CROSSx] IndexedDB get error:", s), null;
1689
+ return g.error("[CROSSx] IndexedDB get error:", s), null;
1619
1690
  }
1620
1691
  }
1621
1692
  async remove(e) {
1622
1693
  try {
1623
- await this.ensureReady(), await this.idbDelete(ve, e);
1694
+ await this.ensureReady(), await this.idbDelete(Se, e);
1624
1695
  } catch (s) {
1625
- throw f.error("[CROSSx] IndexedDB remove error:", s), s;
1696
+ throw g.error("[CROSSx] IndexedDB remove error:", s), s;
1626
1697
  }
1627
1698
  }
1628
1699
  async clear() {
1629
1700
  try {
1630
- await this.ensureReady(), await this.idbClear(ve);
1701
+ await this.ensureReady(), await this.idbClear(Se);
1631
1702
  } catch (e) {
1632
- throw f.error("[CROSSx] IndexedDB clear error:", e), e;
1703
+ throw g.error("[CROSSx] IndexedDB clear error:", e), e;
1633
1704
  }
1634
1705
  }
1635
1706
  /**
@@ -1640,27 +1711,27 @@ class Tt {
1640
1711
  }
1641
1712
  }
1642
1713
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1643
- function it(r) {
1714
+ function at(r) {
1644
1715
  return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
1645
1716
  }
1646
- function le(r, e = "") {
1717
+ function ue(r, e = "") {
1647
1718
  if (!Number.isSafeInteger(r) || r < 0) {
1648
1719
  const s = e && `"${e}" `;
1649
1720
  throw new Error(`${s}expected integer >= 0, got ${r}`);
1650
1721
  }
1651
1722
  }
1652
- function U(r, e, s = "") {
1653
- const t = it(r), n = r == null ? void 0 : r.length, o = e !== void 0;
1723
+ function F(r, e, s = "") {
1724
+ const t = at(r), n = r == null ? void 0 : r.length, o = e !== void 0;
1654
1725
  if (!t || o && n !== e) {
1655
1726
  const i = s && `"${s}" `, a = o ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
1656
1727
  throw new Error(i + "expected Uint8Array" + a + ", got " + c);
1657
1728
  }
1658
1729
  return r;
1659
1730
  }
1660
- function jt(r) {
1731
+ function Kt(r) {
1661
1732
  if (typeof r != "function" || typeof r.create != "function")
1662
1733
  throw new Error("Hash must wrapped by utils.createHasher");
1663
- le(r.outputLen), le(r.blockLen);
1734
+ ue(r.outputLen), ue(r.blockLen);
1664
1735
  }
1665
1736
  function Te(r, e = !0) {
1666
1737
  if (r.destroyed)
@@ -1668,63 +1739,63 @@ function Te(r, e = !0) {
1668
1739
  if (e && r.finished)
1669
1740
  throw new Error("Hash#digest() has already been called");
1670
1741
  }
1671
- function Vt(r, e) {
1672
- U(r, void 0, "digestInto() output");
1742
+ function zt(r, e) {
1743
+ F(r, void 0, "digestInto() output");
1673
1744
  const s = e.outputLen;
1674
1745
  if (r.length < s)
1675
1746
  throw new Error('"digestInto() output" expected to be of length >=' + s);
1676
1747
  }
1677
- function Ks(r) {
1748
+ function Xs(r) {
1678
1749
  return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
1679
1750
  }
1680
- function Ae(...r) {
1751
+ function Ie(...r) {
1681
1752
  for (let e = 0; e < r.length; e++)
1682
1753
  r[e].fill(0);
1683
1754
  }
1684
- function Ye(r) {
1755
+ function Ze(r) {
1685
1756
  return new DataView(r.buffer, r.byteOffset, r.byteLength);
1686
1757
  }
1687
1758
  function oe(r, e) {
1688
1759
  return r << 32 - e | r >>> e;
1689
1760
  }
1690
- const zs = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1691
- function Ys(r) {
1761
+ const Js = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1762
+ function Qs(r) {
1692
1763
  return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
1693
1764
  }
1694
- function Zs(r) {
1765
+ function er(r) {
1695
1766
  for (let e = 0; e < r.length; e++)
1696
- r[e] = Ys(r[e]);
1767
+ r[e] = Qs(r[e]);
1697
1768
  return r;
1698
1769
  }
1699
- const At = zs ? (r) => r : Zs, Kt = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Xs = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
1700
- function Ce(r) {
1701
- if (U(r), Kt)
1770
+ const Rt = Js ? (r) => r : er, Yt = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", tr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
1771
+ function ke(r) {
1772
+ if (F(r), Yt)
1702
1773
  return r.toHex();
1703
1774
  let e = "";
1704
1775
  for (let s = 0; s < r.length; s++)
1705
- e += Xs[r[s]];
1776
+ e += tr[r[s]];
1706
1777
  return e;
1707
1778
  }
1708
- const ie = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
1709
- function It(r) {
1710
- if (r >= ie._0 && r <= ie._9)
1711
- return r - ie._0;
1712
- if (r >= ie.A && r <= ie.F)
1713
- return r - (ie.A - 10);
1714
- if (r >= ie.a && r <= ie.f)
1715
- return r - (ie.a - 10);
1779
+ const ce = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
1780
+ function Ot(r) {
1781
+ if (r >= ce._0 && r <= ce._9)
1782
+ return r - ce._0;
1783
+ if (r >= ce.A && r <= ce.F)
1784
+ return r - (ce.A - 10);
1785
+ if (r >= ce.a && r <= ce.f)
1786
+ return r - (ce.a - 10);
1716
1787
  }
1717
1788
  function Fe(r) {
1718
1789
  if (typeof r != "string")
1719
1790
  throw new Error("hex string expected, got " + typeof r);
1720
- if (Kt)
1791
+ if (Yt)
1721
1792
  return Uint8Array.fromHex(r);
1722
1793
  const e = r.length, s = e / 2;
1723
1794
  if (e % 2)
1724
1795
  throw new Error("hex string expected, got unpadded hex of length " + e);
1725
1796
  const t = new Uint8Array(s);
1726
1797
  for (let n = 0, o = 0; n < s; n++, o += 2) {
1727
- const i = It(r.charCodeAt(o)), a = It(r.charCodeAt(o + 1));
1798
+ const i = Ot(r.charCodeAt(o)), a = Ot(r.charCodeAt(o + 1));
1728
1799
  if (i === void 0 || a === void 0) {
1729
1800
  const c = r[o] + r[o + 1];
1730
1801
  throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + o);
@@ -1733,11 +1804,11 @@ function Fe(r) {
1733
1804
  }
1734
1805
  return t;
1735
1806
  }
1736
- function xe(...r) {
1807
+ function _e(...r) {
1737
1808
  let e = 0;
1738
1809
  for (let t = 0; t < r.length; t++) {
1739
1810
  const n = r[t];
1740
- U(n), e += n.length;
1811
+ F(n), e += n.length;
1741
1812
  }
1742
1813
  const s = new Uint8Array(e);
1743
1814
  for (let t = 0, n = 0; t < r.length; t++) {
@@ -1746,47 +1817,47 @@ function xe(...r) {
1746
1817
  }
1747
1818
  return s;
1748
1819
  }
1749
- function zt(r, e = {}) {
1820
+ function Zt(r, e = {}) {
1750
1821
  const s = (n, o) => r(o).update(n).digest(), t = r(void 0);
1751
1822
  return s.outputLen = t.outputLen, s.blockLen = t.blockLen, s.create = (n) => r(n), Object.assign(s, e), Object.freeze(s);
1752
1823
  }
1753
- function Yt(r = 32) {
1824
+ function Xt(r = 32) {
1754
1825
  const e = typeof globalThis == "object" ? globalThis.crypto : null;
1755
1826
  if (typeof (e == null ? void 0 : e.getRandomValues) != "function")
1756
1827
  throw new Error("crypto.getRandomValues must be defined");
1757
1828
  return e.getRandomValues(new Uint8Array(r));
1758
1829
  }
1759
- const Js = (r) => ({
1830
+ const sr = (r) => ({
1760
1831
  oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, r])
1761
1832
  });
1762
- function Qs(r, e, s) {
1833
+ function rr(r, e, s) {
1763
1834
  return r & e ^ ~r & s;
1764
1835
  }
1765
- function er(r, e, s) {
1836
+ function nr(r, e, s) {
1766
1837
  return r & e ^ r & s ^ e & s;
1767
1838
  }
1768
- class tr {
1839
+ class or {
1769
1840
  constructor(e, s, t, n) {
1770
- b(this, "blockLen");
1771
- b(this, "outputLen");
1772
- b(this, "padOffset");
1773
- b(this, "isLE");
1841
+ v(this, "blockLen");
1842
+ v(this, "outputLen");
1843
+ v(this, "padOffset");
1844
+ v(this, "isLE");
1774
1845
  // For partial updates less than block size
1775
- b(this, "buffer");
1776
- b(this, "view");
1777
- b(this, "finished", !1);
1778
- b(this, "length", 0);
1779
- b(this, "pos", 0);
1780
- b(this, "destroyed", !1);
1781
- this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Ye(this.buffer);
1846
+ v(this, "buffer");
1847
+ v(this, "view");
1848
+ v(this, "finished", !1);
1849
+ v(this, "length", 0);
1850
+ v(this, "pos", 0);
1851
+ v(this, "destroyed", !1);
1852
+ this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Ze(this.buffer);
1782
1853
  }
1783
1854
  update(e) {
1784
- Te(this), U(e);
1855
+ Te(this), F(e);
1785
1856
  const { view: s, buffer: t, blockLen: n } = this, o = e.length;
1786
1857
  for (let i = 0; i < o; ) {
1787
1858
  const a = Math.min(n - this.pos, o - i);
1788
1859
  if (a === n) {
1789
- const c = Ye(e);
1860
+ const c = Ze(e);
1790
1861
  for (; n <= o - i; i += n)
1791
1862
  this.process(c, i);
1792
1863
  continue;
@@ -1796,21 +1867,21 @@ class tr {
1796
1867
  return this.length += e.length, this.roundClean(), this;
1797
1868
  }
1798
1869
  digestInto(e) {
1799
- Te(this), Vt(e, this), this.finished = !0;
1870
+ Te(this), zt(e, this), this.finished = !0;
1800
1871
  const { buffer: s, view: t, blockLen: n, isLE: o } = this;
1801
1872
  let { pos: i } = this;
1802
- s[i++] = 128, Ae(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
1803
- for (let g = i; g < n; g++)
1804
- s[g] = 0;
1873
+ s[i++] = 128, Ie(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
1874
+ for (let f = i; f < n; f++)
1875
+ s[f] = 0;
1805
1876
  t.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(t, 0);
1806
- const a = Ye(e), c = this.outputLen;
1877
+ const a = Ze(e), c = this.outputLen;
1807
1878
  if (c % 4)
1808
1879
  throw new Error("_sha2: outputLen must be aligned to 32bit");
1809
1880
  const l = c / 4, d = this.get();
1810
1881
  if (l > d.length)
1811
1882
  throw new Error("_sha2: outputLen bigger than state");
1812
- for (let g = 0; g < l; g++)
1813
- a.setUint32(4 * g, d[g], o);
1883
+ for (let f = 0; f < l; f++)
1884
+ a.setUint32(4 * f, d[f], o);
1814
1885
  }
1815
1886
  digest() {
1816
1887
  const { buffer: e, outputLen: s } = this;
@@ -1836,20 +1907,20 @@ const fe = /* @__PURE__ */ Uint32Array.from([
1836
1907
  2600822924,
1837
1908
  528734635,
1838
1909
  1541459225
1839
- ]), Le = /* @__PURE__ */ BigInt(2 ** 32 - 1), Rt = /* @__PURE__ */ BigInt(32);
1840
- function sr(r, e = !1) {
1841
- return e ? { h: Number(r & Le), l: Number(r >> Rt & Le) } : { h: Number(r >> Rt & Le) | 0, l: Number(r & Le) | 0 };
1910
+ ]), De = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ct = /* @__PURE__ */ BigInt(32);
1911
+ function ir(r, e = !1) {
1912
+ return e ? { h: Number(r & De), l: Number(r >> Ct & De) } : { h: Number(r >> Ct & De) | 0, l: Number(r & De) | 0 };
1842
1913
  }
1843
- function rr(r, e = !1) {
1914
+ function ar(r, e = !1) {
1844
1915
  const s = r.length;
1845
1916
  let t = new Uint32Array(s), n = new Uint32Array(s);
1846
1917
  for (let o = 0; o < s; o++) {
1847
- const { h: i, l: a } = sr(r[o], e);
1918
+ const { h: i, l: a } = ir(r[o], e);
1848
1919
  [t[o], n[o]] = [i, a];
1849
1920
  }
1850
1921
  return [t, n];
1851
1922
  }
1852
- const nr = (r, e, s) => r << s | e >>> 32 - s, or = (r, e, s) => e << s | r >>> 32 - s, ir = (r, e, s) => e << s - 32 | r >>> 64 - s, ar = (r, e, s) => r << s - 32 | e >>> 64 - s, cr = /* @__PURE__ */ Uint32Array.from([
1923
+ const cr = (r, e, s) => r << s | e >>> 32 - s, lr = (r, e, s) => e << s | r >>> 32 - s, dr = (r, e, s) => e << s - 32 | r >>> 64 - s, ur = (r, e, s) => r << s - 32 | e >>> 64 - s, hr = /* @__PURE__ */ Uint32Array.from([
1853
1924
  1116352408,
1854
1925
  1899447441,
1855
1926
  3049323471,
@@ -1915,7 +1986,7 @@ const nr = (r, e, s) => r << s | e >>> 32 - s, or = (r, e, s) => e << s | r >>>
1915
1986
  3204031479,
1916
1987
  3329325298
1917
1988
  ]), ge = /* @__PURE__ */ new Uint32Array(64);
1918
- class lr extends tr {
1989
+ class fr extends or {
1919
1990
  constructor(e) {
1920
1991
  super(64, e, 8, !1);
1921
1992
  }
@@ -1928,135 +1999,135 @@ class lr extends tr {
1928
1999
  this.A = e | 0, this.B = s | 0, this.C = t | 0, this.D = n | 0, this.E = o | 0, this.F = i | 0, this.G = a | 0, this.H = c | 0;
1929
2000
  }
1930
2001
  process(e, s) {
1931
- for (let g = 0; g < 16; g++, s += 4)
1932
- ge[g] = e.getUint32(s, !1);
1933
- for (let g = 16; g < 64; g++) {
1934
- const w = ge[g - 15], m = ge[g - 2], x = oe(w, 7) ^ oe(w, 18) ^ w >>> 3, A = oe(m, 17) ^ oe(m, 19) ^ m >>> 10;
1935
- ge[g] = A + ge[g - 7] + x + ge[g - 16] | 0;
2002
+ for (let f = 0; f < 16; f++, s += 4)
2003
+ ge[f] = e.getUint32(s, !1);
2004
+ for (let f = 16; f < 64; f++) {
2005
+ const w = ge[f - 15], m = ge[f - 2], _ = oe(w, 7) ^ oe(w, 18) ^ w >>> 3, T = oe(m, 17) ^ oe(m, 19) ^ m >>> 10;
2006
+ ge[f] = T + ge[f - 7] + _ + ge[f - 16] | 0;
1936
2007
  }
1937
2008
  let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: d } = this;
1938
- for (let g = 0; g < 64; g++) {
1939
- const w = oe(a, 6) ^ oe(a, 11) ^ oe(a, 25), m = d + w + Qs(a, c, l) + cr[g] + ge[g] | 0, A = (oe(t, 2) ^ oe(t, 13) ^ oe(t, 22)) + er(t, n, o) | 0;
1940
- d = l, l = c, c = a, a = i + m | 0, i = o, o = n, n = t, t = m + A | 0;
2009
+ for (let f = 0; f < 64; f++) {
2010
+ const w = oe(a, 6) ^ oe(a, 11) ^ oe(a, 25), m = d + w + rr(a, c, l) + hr[f] + ge[f] | 0, T = (oe(t, 2) ^ oe(t, 13) ^ oe(t, 22)) + nr(t, n, o) | 0;
2011
+ d = l, l = c, c = a, a = i + m | 0, i = o, o = n, n = t, t = m + T | 0;
1941
2012
  }
1942
2013
  t = t + this.A | 0, n = n + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, d = d + this.H | 0, this.set(t, n, o, i, a, c, l, d);
1943
2014
  }
1944
2015
  roundClean() {
1945
- Ae(ge);
2016
+ Ie(ge);
1946
2017
  }
1947
2018
  destroy() {
1948
- this.set(0, 0, 0, 0, 0, 0, 0, 0), Ae(this.buffer);
2019
+ this.set(0, 0, 0, 0, 0, 0, 0, 0), Ie(this.buffer);
1949
2020
  }
1950
2021
  }
1951
- class dr extends lr {
2022
+ class gr extends fr {
1952
2023
  constructor() {
1953
2024
  super(32);
1954
2025
  // We cannot use array here since array allows indexing by variable
1955
2026
  // which means optimizer/compiler cannot use registers.
1956
- b(this, "A", fe[0] | 0);
1957
- b(this, "B", fe[1] | 0);
1958
- b(this, "C", fe[2] | 0);
1959
- b(this, "D", fe[3] | 0);
1960
- b(this, "E", fe[4] | 0);
1961
- b(this, "F", fe[5] | 0);
1962
- b(this, "G", fe[6] | 0);
1963
- b(this, "H", fe[7] | 0);
1964
- }
1965
- }
1966
- const ur = /* @__PURE__ */ zt(
1967
- () => new dr(),
1968
- /* @__PURE__ */ Js(1)
2027
+ v(this, "A", fe[0] | 0);
2028
+ v(this, "B", fe[1] | 0);
2029
+ v(this, "C", fe[2] | 0);
2030
+ v(this, "D", fe[3] | 0);
2031
+ v(this, "E", fe[4] | 0);
2032
+ v(this, "F", fe[5] | 0);
2033
+ v(this, "G", fe[6] | 0);
2034
+ v(this, "H", fe[7] | 0);
2035
+ }
2036
+ }
2037
+ const pr = /* @__PURE__ */ Zt(
2038
+ () => new gr(),
2039
+ /* @__PURE__ */ sr(1)
1969
2040
  );
1970
2041
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1971
- const at = /* @__PURE__ */ BigInt(0), st = /* @__PURE__ */ BigInt(1);
1972
- function Ue(r, e = "") {
2042
+ const ct = /* @__PURE__ */ BigInt(0), rt = /* @__PURE__ */ BigInt(1);
2043
+ function He(r, e = "") {
1973
2044
  if (typeof r != "boolean") {
1974
2045
  const s = e && `"${e}" `;
1975
2046
  throw new Error(s + "expected boolean, got type=" + typeof r);
1976
2047
  }
1977
2048
  return r;
1978
2049
  }
1979
- function Zt(r) {
2050
+ function Jt(r) {
1980
2051
  if (typeof r == "bigint") {
1981
2052
  if (!Me(r))
1982
2053
  throw new Error("positive bigint expected, got " + r);
1983
2054
  } else
1984
- le(r);
2055
+ ue(r);
1985
2056
  return r;
1986
2057
  }
1987
- function De(r) {
1988
- const e = Zt(r).toString(16);
2058
+ function $e(r) {
2059
+ const e = Jt(r).toString(16);
1989
2060
  return e.length & 1 ? "0" + e : e;
1990
2061
  }
1991
- function Xt(r) {
2062
+ function Qt(r) {
1992
2063
  if (typeof r != "string")
1993
2064
  throw new Error("hex string expected, got " + typeof r);
1994
- return r === "" ? at : BigInt("0x" + r);
2065
+ return r === "" ? ct : BigInt("0x" + r);
1995
2066
  }
1996
- function We(r) {
1997
- return Xt(Ce(r));
2067
+ function je(r) {
2068
+ return Qt(ke(r));
1998
2069
  }
1999
- function Jt(r) {
2000
- return Xt(Ce(hr(U(r)).reverse()));
2070
+ function es(r) {
2071
+ return Qt(ke(_r(F(r)).reverse()));
2001
2072
  }
2002
- function ct(r, e) {
2003
- le(e), r = Zt(r);
2073
+ function lt(r, e) {
2074
+ ue(e), r = Jt(r);
2004
2075
  const s = Fe(r.toString(16).padStart(e * 2, "0"));
2005
2076
  if (s.length !== e)
2006
2077
  throw new Error("number too large");
2007
2078
  return s;
2008
2079
  }
2009
- function Qt(r, e) {
2010
- return ct(r, e).reverse();
2080
+ function ts(r, e) {
2081
+ return lt(r, e).reverse();
2011
2082
  }
2012
- function hr(r) {
2083
+ function _r(r) {
2013
2084
  return Uint8Array.from(r);
2014
2085
  }
2015
- const Me = (r) => typeof r == "bigint" && at <= r;
2016
- function fr(r, e, s) {
2086
+ const Me = (r) => typeof r == "bigint" && ct <= r;
2087
+ function xr(r, e, s) {
2017
2088
  return Me(r) && Me(e) && Me(s) && e <= r && r < s;
2018
2089
  }
2019
- function gr(r, e, s, t) {
2020
- if (!fr(e, s, t))
2090
+ function mr(r, e, s, t) {
2091
+ if (!xr(e, s, t))
2021
2092
  throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
2022
2093
  }
2023
- function pr(r) {
2094
+ function wr(r) {
2024
2095
  let e;
2025
- for (e = 0; r > at; r >>= st, e += 1)
2096
+ for (e = 0; r > ct; r >>= rt, e += 1)
2026
2097
  ;
2027
2098
  return e;
2028
2099
  }
2029
- const lt = (r) => (st << BigInt(r)) - st;
2030
- function xr(r, e, s) {
2031
- if (le(r, "hashLen"), le(e, "qByteLen"), typeof s != "function")
2100
+ const dt = (r) => (rt << BigInt(r)) - rt;
2101
+ function yr(r, e, s) {
2102
+ if (ue(r, "hashLen"), ue(e, "qByteLen"), typeof s != "function")
2032
2103
  throw new Error("hmacFn must be a function");
2033
- const t = (E) => new Uint8Array(E), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
2104
+ const t = (b) => new Uint8Array(b), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
2034
2105
  let c = t(r), l = t(r), d = 0;
2035
- const g = () => {
2106
+ const f = () => {
2036
2107
  c.fill(1), l.fill(0), d = 0;
2037
- }, w = (...E) => s(l, xe(c, ...E)), m = (E = n) => {
2038
- l = w(o, E), c = w(), E.length !== 0 && (l = w(i, E), c = w());
2039
- }, x = () => {
2108
+ }, w = (...b) => s(l, _e(c, ...b)), m = (b = n) => {
2109
+ l = w(o, b), c = w(), b.length !== 0 && (l = w(i, b), c = w());
2110
+ }, _ = () => {
2040
2111
  if (d++ >= a)
2041
2112
  throw new Error("drbg: tried max amount of iterations");
2042
- let E = 0;
2043
- const C = [];
2044
- for (; E < e; ) {
2113
+ let b = 0;
2114
+ const A = [];
2115
+ for (; b < e; ) {
2045
2116
  c = w();
2046
2117
  const q = c.slice();
2047
- C.push(q), E += c.length;
2118
+ A.push(q), b += c.length;
2048
2119
  }
2049
- return xe(...C);
2120
+ return _e(...A);
2050
2121
  };
2051
- return (E, C) => {
2052
- g(), m(E);
2122
+ return (b, A) => {
2123
+ f(), m(b);
2053
2124
  let q;
2054
- for (; !(q = C(x())); )
2125
+ for (; !(q = A(_())); )
2055
2126
  m();
2056
- return g(), q;
2127
+ return f(), q;
2057
2128
  };
2058
2129
  }
2059
- function dt(r, e = {}, s = {}) {
2130
+ function ut(r, e = {}, s = {}) {
2060
2131
  if (!r || typeof r != "object")
2061
2132
  throw new Error("expected valid options object");
2062
2133
  function t(o, i, a) {
@@ -2070,7 +2141,7 @@ function dt(r, e = {}, s = {}) {
2070
2141
  const n = (o, i) => Object.entries(o).forEach(([a, c]) => t(a, c, i));
2071
2142
  n(e, !1), n(s, !0);
2072
2143
  }
2073
- function Ot(r) {
2144
+ function kt(r) {
2074
2145
  const e = /* @__PURE__ */ new WeakMap();
2075
2146
  return (s, ...t) => {
2076
2147
  const n = e.get(s);
@@ -2081,24 +2152,24 @@ function Ot(r) {
2081
2152
  };
2082
2153
  }
2083
2154
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2084
- const X = /* @__PURE__ */ BigInt(0), z = /* @__PURE__ */ BigInt(1), we = /* @__PURE__ */ BigInt(2), es = /* @__PURE__ */ BigInt(3), ts = /* @__PURE__ */ BigInt(4), ss = /* @__PURE__ */ BigInt(5), _r = /* @__PURE__ */ BigInt(7), rs = /* @__PURE__ */ BigInt(8), mr = /* @__PURE__ */ BigInt(9), ns = /* @__PURE__ */ BigInt(16);
2155
+ const J = /* @__PURE__ */ BigInt(0), z = /* @__PURE__ */ BigInt(1), ye = /* @__PURE__ */ BigInt(2), ss = /* @__PURE__ */ BigInt(3), rs = /* @__PURE__ */ BigInt(4), ns = /* @__PURE__ */ BigInt(5), br = /* @__PURE__ */ BigInt(7), os = /* @__PURE__ */ BigInt(8), vr = /* @__PURE__ */ BigInt(9), is = /* @__PURE__ */ BigInt(16);
2085
2156
  function re(r, e) {
2086
2157
  const s = r % e;
2087
- return s >= X ? s : e + s;
2158
+ return s >= J ? s : e + s;
2088
2159
  }
2089
- function ee(r, e, s) {
2160
+ function se(r, e, s) {
2090
2161
  let t = r;
2091
- for (; e-- > X; )
2162
+ for (; e-- > J; )
2092
2163
  t *= t, t %= s;
2093
2164
  return t;
2094
2165
  }
2095
- function Ct(r, e) {
2096
- if (r === X)
2166
+ function Nt(r, e) {
2167
+ if (r === J)
2097
2168
  throw new Error("invert: expected non-zero number");
2098
- if (e <= X)
2169
+ if (e <= J)
2099
2170
  throw new Error("invert: expected positive modulus, got " + e);
2100
- let s = re(r, e), t = e, n = X, o = z;
2101
- for (; s !== X; ) {
2171
+ let s = re(r, e), t = e, n = J, o = z;
2172
+ for (; s !== J; ) {
2102
2173
  const a = t / s, c = t % s, l = n - o * a;
2103
2174
  t = s, s = c, n = o, o = l;
2104
2175
  }
@@ -2106,66 +2177,66 @@ function Ct(r, e) {
2106
2177
  throw new Error("invert: does not exist");
2107
2178
  return re(n, e);
2108
2179
  }
2109
- function ut(r, e, s) {
2180
+ function ht(r, e, s) {
2110
2181
  if (!r.eql(r.sqr(e), s))
2111
2182
  throw new Error("Cannot find square root");
2112
2183
  }
2113
- function os(r, e) {
2114
- const s = (r.ORDER + z) / ts, t = r.pow(e, s);
2115
- return ut(r, t, e), t;
2184
+ function as(r, e) {
2185
+ const s = (r.ORDER + z) / rs, t = r.pow(e, s);
2186
+ return ht(r, t, e), t;
2116
2187
  }
2117
- function wr(r, e) {
2118
- const s = (r.ORDER - ss) / rs, t = r.mul(e, we), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, we), n), a = r.mul(o, r.sub(i, r.ONE));
2119
- return ut(r, a, e), a;
2188
+ function Sr(r, e) {
2189
+ const s = (r.ORDER - ns) / os, t = r.mul(e, ye), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, ye), n), a = r.mul(o, r.sub(i, r.ONE));
2190
+ return ht(r, a, e), a;
2120
2191
  }
2121
- function yr(r) {
2122
- const e = je(r), s = is(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + _r) / ns;
2192
+ function Er(r) {
2193
+ const e = Ve(r), s = cs(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + br) / is;
2123
2194
  return (a, c) => {
2124
2195
  let l = a.pow(c, i), d = a.mul(l, t);
2125
- const g = a.mul(l, n), w = a.mul(l, o), m = a.eql(a.sqr(d), c), x = a.eql(a.sqr(g), c);
2126
- l = a.cmov(l, d, m), d = a.cmov(w, g, x);
2127
- const A = a.eql(a.sqr(d), c), E = a.cmov(l, d, A);
2128
- return ut(a, E, c), E;
2196
+ const f = a.mul(l, n), w = a.mul(l, o), m = a.eql(a.sqr(d), c), _ = a.eql(a.sqr(f), c);
2197
+ l = a.cmov(l, d, m), d = a.cmov(w, f, _);
2198
+ const T = a.eql(a.sqr(d), c), b = a.cmov(l, d, T);
2199
+ return ht(a, b, c), b;
2129
2200
  };
2130
2201
  }
2131
- function is(r) {
2132
- if (r < es)
2202
+ function cs(r) {
2203
+ if (r < ss)
2133
2204
  throw new Error("sqrt is not defined for small field");
2134
2205
  let e = r - z, s = 0;
2135
- for (; e % we === X; )
2136
- e /= we, s++;
2137
- let t = we;
2138
- const n = je(r);
2139
- for (; Nt(n, t) === 1; )
2206
+ for (; e % ye === J; )
2207
+ e /= ye, s++;
2208
+ let t = ye;
2209
+ const n = Ve(r);
2210
+ for (; Pt(n, t) === 1; )
2140
2211
  if (t++ > 1e3)
2141
2212
  throw new Error("Cannot find square root: probably non-prime P");
2142
2213
  if (s === 1)
2143
- return os;
2214
+ return as;
2144
2215
  let o = n.pow(t, e);
2145
- const i = (e + z) / we;
2216
+ const i = (e + z) / ye;
2146
2217
  return function(c, l) {
2147
2218
  if (c.is0(l))
2148
2219
  return l;
2149
- if (Nt(c, l) !== 1)
2220
+ if (Pt(c, l) !== 1)
2150
2221
  throw new Error("Cannot find square root");
2151
- let d = s, g = c.mul(c.ONE, o), w = c.pow(l, e), m = c.pow(l, i);
2222
+ let d = s, f = c.mul(c.ONE, o), w = c.pow(l, e), m = c.pow(l, i);
2152
2223
  for (; !c.eql(w, c.ONE); ) {
2153
2224
  if (c.is0(w))
2154
2225
  return c.ZERO;
2155
- let x = 1, A = c.sqr(w);
2156
- for (; !c.eql(A, c.ONE); )
2157
- if (x++, A = c.sqr(A), x === d)
2226
+ let _ = 1, T = c.sqr(w);
2227
+ for (; !c.eql(T, c.ONE); )
2228
+ if (_++, T = c.sqr(T), _ === d)
2158
2229
  throw new Error("Cannot find square root");
2159
- const E = z << BigInt(d - x - 1), C = c.pow(g, E);
2160
- d = x, g = c.sqr(C), w = c.mul(w, g), m = c.mul(m, C);
2230
+ const b = z << BigInt(d - _ - 1), A = c.pow(f, b);
2231
+ d = _, f = c.sqr(A), w = c.mul(w, f), m = c.mul(m, A);
2161
2232
  }
2162
2233
  return m;
2163
2234
  };
2164
2235
  }
2165
- function br(r) {
2166
- return r % ts === es ? os : r % rs === ss ? wr : r % ns === mr ? yr(r) : is(r);
2236
+ function Tr(r) {
2237
+ return r % rs === ss ? as : r % os === ns ? Sr : r % is === vr ? Er(r) : cs(r);
2167
2238
  }
2168
- const vr = [
2239
+ const Ir = [
2169
2240
  "create",
2170
2241
  "isValid",
2171
2242
  "is0",
@@ -2184,59 +2255,59 @@ const vr = [
2184
2255
  "mulN",
2185
2256
  "sqrN"
2186
2257
  ];
2187
- function Sr(r) {
2258
+ function Ar(r) {
2188
2259
  const e = {
2189
2260
  ORDER: "bigint",
2190
2261
  BYTES: "number",
2191
2262
  BITS: "number"
2192
- }, s = vr.reduce((t, n) => (t[n] = "function", t), e);
2193
- return dt(r, s), r;
2263
+ }, s = Ir.reduce((t, n) => (t[n] = "function", t), e);
2264
+ return ut(r, s), r;
2194
2265
  }
2195
- function Er(r, e, s) {
2196
- if (s < X)
2266
+ function Rr(r, e, s) {
2267
+ if (s < J)
2197
2268
  throw new Error("invalid exponent, negatives unsupported");
2198
- if (s === X)
2269
+ if (s === J)
2199
2270
  return r.ONE;
2200
2271
  if (s === z)
2201
2272
  return e;
2202
2273
  let t = r.ONE, n = e;
2203
- for (; s > X; )
2274
+ for (; s > J; )
2204
2275
  s & z && (t = r.mul(t, n)), n = r.sqr(n), s >>= z;
2205
2276
  return t;
2206
2277
  }
2207
- function as(r, e, s = !1) {
2278
+ function ls(r, e, s = !1) {
2208
2279
  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);
2209
2280
  return e.reduceRight((i, a, c) => r.is0(a) ? i : (t[c] = r.mul(i, t[c]), r.mul(i, a)), o), t;
2210
2281
  }
2211
- function Nt(r, e) {
2212
- const s = (r.ORDER - z) / we, 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));
2282
+ function Pt(r, e) {
2283
+ const s = (r.ORDER - z) / ye, 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));
2213
2284
  if (!n && !o && !i)
2214
2285
  throw new Error("invalid Legendre symbol result");
2215
2286
  return n ? 1 : o ? 0 : -1;
2216
2287
  }
2217
- function Tr(r, e) {
2218
- e !== void 0 && le(e);
2288
+ function Or(r, e) {
2289
+ e !== void 0 && ue(e);
2219
2290
  const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
2220
2291
  return { nBitLength: s, nByteLength: t };
2221
2292
  }
2222
- class Ar {
2293
+ class Cr {
2223
2294
  constructor(e, s = {}) {
2224
- b(this, "ORDER");
2225
- b(this, "BITS");
2226
- b(this, "BYTES");
2227
- b(this, "isLE");
2228
- b(this, "ZERO", X);
2229
- b(this, "ONE", z);
2230
- b(this, "_lengths");
2231
- b(this, "_sqrt");
2295
+ v(this, "ORDER");
2296
+ v(this, "BITS");
2297
+ v(this, "BYTES");
2298
+ v(this, "isLE");
2299
+ v(this, "ZERO", J);
2300
+ v(this, "ONE", z);
2301
+ v(this, "_lengths");
2302
+ v(this, "_sqrt");
2232
2303
  // cached sqrt
2233
- b(this, "_mod");
2304
+ v(this, "_mod");
2234
2305
  var i;
2235
- if (e <= X)
2306
+ if (e <= J)
2236
2307
  throw new Error("invalid field: expected ORDER > 0, got " + e);
2237
2308
  let t;
2238
2309
  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));
2239
- const { nBitLength: n, nByteLength: o } = Tr(e, t);
2310
+ const { nBitLength: n, nByteLength: o } = Or(e, t);
2240
2311
  if (o > 2048)
2241
2312
  throw new Error("invalid field: expected ORDER of <= 2048 bytes");
2242
2313
  this.ORDER = e, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
@@ -2247,10 +2318,10 @@ class Ar {
2247
2318
  isValid(e) {
2248
2319
  if (typeof e != "bigint")
2249
2320
  throw new Error("invalid field element: expected bigint, got " + typeof e);
2250
- return X <= e && e < this.ORDER;
2321
+ return J <= e && e < this.ORDER;
2251
2322
  }
2252
2323
  is0(e) {
2253
- return e === X;
2324
+ return e === J;
2254
2325
  }
2255
2326
  // is valid and invertible
2256
2327
  isValidNot0(e) {
@@ -2278,10 +2349,10 @@ class Ar {
2278
2349
  return re(e * s, this.ORDER);
2279
2350
  }
2280
2351
  pow(e, s) {
2281
- return Er(this, e, s);
2352
+ return Rr(this, e, s);
2282
2353
  }
2283
2354
  div(e, s) {
2284
- return re(e * Ct(s, this.ORDER), this.ORDER);
2355
+ return re(e * Nt(s, this.ORDER), this.ORDER);
2285
2356
  }
2286
2357
  // Same as above, but doesn't normalize
2287
2358
  sqrN(e) {
@@ -2297,16 +2368,16 @@ class Ar {
2297
2368
  return e * s;
2298
2369
  }
2299
2370
  inv(e) {
2300
- return Ct(e, this.ORDER);
2371
+ return Nt(e, this.ORDER);
2301
2372
  }
2302
2373
  sqrt(e) {
2303
- return this._sqrt || (this._sqrt = br(this.ORDER)), this._sqrt(this, e);
2374
+ return this._sqrt || (this._sqrt = Tr(this.ORDER)), this._sqrt(this, e);
2304
2375
  }
2305
2376
  toBytes(e) {
2306
- return this.isLE ? Qt(e, this.BYTES) : ct(e, this.BYTES);
2377
+ return this.isLE ? ts(e, this.BYTES) : lt(e, this.BYTES);
2307
2378
  }
2308
2379
  fromBytes(e, s = !1) {
2309
- U(e);
2380
+ F(e);
2310
2381
  const { _lengths: t, BYTES: n, isLE: o, ORDER: i, _mod: a } = this;
2311
2382
  if (t) {
2312
2383
  if (!t.includes(e.length) || e.length > n)
@@ -2316,14 +2387,14 @@ class Ar {
2316
2387
  }
2317
2388
  if (e.length !== n)
2318
2389
  throw new Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
2319
- let c = o ? Jt(e) : We(e);
2390
+ let c = o ? es(e) : je(e);
2320
2391
  if (a && (c = re(c, i)), !s && !this.isValid(c))
2321
2392
  throw new Error("invalid field element: outside of range 0..ORDER");
2322
2393
  return c;
2323
2394
  }
2324
2395
  // TODO: we don't need it here, move out to separate fn
2325
2396
  invertBatch(e) {
2326
- return as(this, e);
2397
+ return ls(this, e);
2327
2398
  }
2328
2399
  // We can't move this out because Fp6, Fp12 implement it
2329
2400
  // and it's unclear what to return in there.
@@ -2331,75 +2402,75 @@ class Ar {
2331
2402
  return t ? s : e;
2332
2403
  }
2333
2404
  }
2334
- function je(r, e = {}) {
2335
- return new Ar(r, e);
2405
+ function Ve(r, e = {}) {
2406
+ return new Cr(r, e);
2336
2407
  }
2337
- function cs(r) {
2408
+ function ds(r) {
2338
2409
  if (typeof r != "bigint")
2339
2410
  throw new Error("field order must be bigint");
2340
2411
  const e = r.toString(2).length;
2341
2412
  return Math.ceil(e / 8);
2342
2413
  }
2343
- function ls(r) {
2344
- const e = cs(r);
2414
+ function us(r) {
2415
+ const e = ds(r);
2345
2416
  return e + Math.ceil(e / 2);
2346
2417
  }
2347
- function Ir(r, e, s = !1) {
2348
- U(r);
2349
- const t = r.length, n = cs(e), o = ls(e);
2418
+ function kr(r, e, s = !1) {
2419
+ F(r);
2420
+ const t = r.length, n = ds(e), o = us(e);
2350
2421
  if (t < 16 || t < o || t > 1024)
2351
2422
  throw new Error("expected " + o + "-1024 bytes of input, got " + t);
2352
- const i = s ? Jt(r) : We(r), a = re(i, e - z) + z;
2353
- return s ? Qt(a, n) : ct(a, n);
2423
+ const i = s ? es(r) : je(r), a = re(i, e - z) + z;
2424
+ return s ? ts(a, n) : lt(a, n);
2354
2425
  }
2355
2426
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2356
- const Ie = /* @__PURE__ */ BigInt(0), ye = /* @__PURE__ */ BigInt(1);
2357
- function He(r, e) {
2427
+ const Ae = /* @__PURE__ */ BigInt(0), be = /* @__PURE__ */ BigInt(1);
2428
+ function Ge(r, e) {
2358
2429
  const s = e.negate();
2359
2430
  return r ? s : e;
2360
2431
  }
2361
- function Pt(r, e) {
2362
- const s = as(r.Fp, e.map((t) => t.Z));
2432
+ function Lt(r, e) {
2433
+ const s = ls(r.Fp, e.map((t) => t.Z));
2363
2434
  return e.map((t, n) => r.fromAffine(t.toAffine(s[n])));
2364
2435
  }
2365
- function ds(r, e) {
2436
+ function hs(r, e) {
2366
2437
  if (!Number.isSafeInteger(r) || r <= 0 || r > e)
2367
2438
  throw new Error("invalid window size, expected [1.." + e + "], got W=" + r);
2368
2439
  }
2369
- function Ze(r, e) {
2370
- ds(r, e);
2371
- const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = lt(r), i = BigInt(r);
2440
+ function Xe(r, e) {
2441
+ hs(r, e);
2442
+ const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = dt(r), i = BigInt(r);
2372
2443
  return { windows: s, windowSize: t, mask: o, maxNumber: n, shiftBy: i };
2373
2444
  }
2374
- function kt(r, e, s) {
2445
+ function Dt(r, e, s) {
2375
2446
  const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
2376
2447
  let a = Number(r & n), c = r >> i;
2377
- a > t && (a -= o, c += ye);
2378
- const l = e * t, d = l + Math.abs(a) - 1, g = a === 0, w = a < 0, m = e % 2 !== 0;
2379
- return { nextN: c, offset: d, isZero: g, isNeg: w, isNegF: m, offsetF: l };
2448
+ a > t && (a -= o, c += be);
2449
+ const l = e * t, d = l + Math.abs(a) - 1, f = a === 0, w = a < 0, m = e % 2 !== 0;
2450
+ return { nextN: c, offset: d, isZero: f, isNeg: w, isNegF: m, offsetF: l };
2380
2451
  }
2381
- const Xe = /* @__PURE__ */ new WeakMap(), us = /* @__PURE__ */ new WeakMap();
2382
- function Je(r) {
2383
- return us.get(r) || 1;
2452
+ const Je = /* @__PURE__ */ new WeakMap(), fs = /* @__PURE__ */ new WeakMap();
2453
+ function Qe(r) {
2454
+ return fs.get(r) || 1;
2384
2455
  }
2385
- function Lt(r) {
2386
- if (r !== Ie)
2456
+ function $t(r) {
2457
+ if (r !== Ae)
2387
2458
  throw new Error("invalid wNAF");
2388
2459
  }
2389
- class Rr {
2460
+ class Nr {
2390
2461
  // Parametrized with a given Point class (not individual point)
2391
2462
  constructor(e, s) {
2392
- b(this, "BASE");
2393
- b(this, "ZERO");
2394
- b(this, "Fn");
2395
- b(this, "bits");
2463
+ v(this, "BASE");
2464
+ v(this, "ZERO");
2465
+ v(this, "Fn");
2466
+ v(this, "bits");
2396
2467
  this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = s;
2397
2468
  }
2398
2469
  // non-const time multiplication ladder
2399
2470
  _unsafeLadder(e, s, t = this.ZERO) {
2400
2471
  let n = e;
2401
- for (; s > Ie; )
2402
- s & ye && (t = t.add(n)), n = n.double(), s >>= ye;
2472
+ for (; s > Ae; )
2473
+ s & be && (t = t.add(n)), n = n.double(), s >>= be;
2403
2474
  return t;
2404
2475
  }
2405
2476
  /**
@@ -2415,7 +2486,7 @@ class Rr {
2415
2486
  * @returns precomputed point tables flattened to a single array
2416
2487
  */
2417
2488
  precomputeWindow(e, s) {
2418
- const { windows: t, windowSize: n } = Ze(s, this.bits), o = [];
2489
+ const { windows: t, windowSize: n } = Xe(s, this.bits), o = [];
2419
2490
  let i = e, a = i;
2420
2491
  for (let c = 0; c < t; c++) {
2421
2492
  a = i, o.push(a);
@@ -2435,12 +2506,12 @@ class Rr {
2435
2506
  if (!this.Fn.isValid(t))
2436
2507
  throw new Error("invalid scalar");
2437
2508
  let n = this.ZERO, o = this.BASE;
2438
- const i = Ze(e, this.bits);
2509
+ const i = Xe(e, this.bits);
2439
2510
  for (let a = 0; a < i.windows; a++) {
2440
- const { nextN: c, offset: l, isZero: d, isNeg: g, isNegF: w, offsetF: m } = kt(t, a, i);
2441
- t = c, d ? o = o.add(He(w, s[m])) : n = n.add(He(g, s[l]));
2511
+ const { nextN: c, offset: l, isZero: d, isNeg: f, isNegF: w, offsetF: m } = Dt(t, a, i);
2512
+ t = c, d ? o = o.add(Ge(w, s[m])) : n = n.add(Ge(f, s[l]));
2442
2513
  }
2443
- return Lt(t), { p: n, f: o };
2514
+ return $t(t), { p: n, f: o };
2444
2515
  }
2445
2516
  /**
2446
2517
  * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
@@ -2448,81 +2519,81 @@ class Rr {
2448
2519
  * @returns point
2449
2520
  */
2450
2521
  wNAFUnsafe(e, s, t, n = this.ZERO) {
2451
- const o = Ze(e, this.bits);
2452
- for (let i = 0; i < o.windows && t !== Ie; i++) {
2453
- const { nextN: a, offset: c, isZero: l, isNeg: d } = kt(t, i, o);
2522
+ const o = Xe(e, this.bits);
2523
+ for (let i = 0; i < o.windows && t !== Ae; i++) {
2524
+ const { nextN: a, offset: c, isZero: l, isNeg: d } = Dt(t, i, o);
2454
2525
  if (t = a, !l) {
2455
- const g = s[c];
2456
- n = n.add(d ? g.negate() : g);
2526
+ const f = s[c];
2527
+ n = n.add(d ? f.negate() : f);
2457
2528
  }
2458
2529
  }
2459
- return Lt(t), n;
2530
+ return $t(t), n;
2460
2531
  }
2461
2532
  getPrecomputes(e, s, t) {
2462
- let n = Xe.get(s);
2463
- return n || (n = this.precomputeWindow(s, e), e !== 1 && (typeof t == "function" && (n = t(n)), Xe.set(s, n))), n;
2533
+ let n = Je.get(s);
2534
+ return n || (n = this.precomputeWindow(s, e), e !== 1 && (typeof t == "function" && (n = t(n)), Je.set(s, n))), n;
2464
2535
  }
2465
2536
  cached(e, s, t) {
2466
- const n = Je(e);
2537
+ const n = Qe(e);
2467
2538
  return this.wNAF(n, this.getPrecomputes(n, e, t), s);
2468
2539
  }
2469
2540
  unsafe(e, s, t, n) {
2470
- const o = Je(e);
2541
+ const o = Qe(e);
2471
2542
  return o === 1 ? this._unsafeLadder(e, s, n) : this.wNAFUnsafe(o, this.getPrecomputes(o, e, t), s, n);
2472
2543
  }
2473
2544
  // We calculate precomputes for elliptic curve point multiplication
2474
2545
  // using windowed method. This specifies window size and
2475
2546
  // stores precomputed values. Usually only base point would be precomputed.
2476
2547
  createCache(e, s) {
2477
- ds(s, this.bits), us.set(e, s), Xe.delete(e);
2548
+ hs(s, this.bits), fs.set(e, s), Je.delete(e);
2478
2549
  }
2479
2550
  hasCache(e) {
2480
- return Je(e) !== 1;
2551
+ return Qe(e) !== 1;
2481
2552
  }
2482
2553
  }
2483
- function Or(r, e, s, t) {
2554
+ function Pr(r, e, s, t) {
2484
2555
  let n = e, o = r.ZERO, i = r.ZERO;
2485
- for (; s > Ie || t > Ie; )
2486
- s & ye && (o = o.add(n)), t & ye && (i = i.add(n)), n = n.double(), s >>= ye, t >>= ye;
2556
+ for (; s > Ae || t > Ae; )
2557
+ s & be && (o = o.add(n)), t & be && (i = i.add(n)), n = n.double(), s >>= be, t >>= be;
2487
2558
  return { p1: o, p2: i };
2488
2559
  }
2489
- function Dt(r, e, s) {
2560
+ function Bt(r, e, s) {
2490
2561
  if (e) {
2491
2562
  if (e.ORDER !== r)
2492
2563
  throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
2493
- return Sr(e), e;
2564
+ return Ar(e), e;
2494
2565
  } else
2495
- return je(r, { isLE: s });
2566
+ return Ve(r, { isLE: s });
2496
2567
  }
2497
- function Cr(r, e, s = {}, t) {
2568
+ function Lr(r, e, s = {}, t) {
2498
2569
  if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
2499
2570
  throw new Error(`expected valid ${r} CURVE object`);
2500
2571
  for (const c of ["p", "n", "h"]) {
2501
2572
  const l = e[c];
2502
- if (!(typeof l == "bigint" && l > Ie))
2573
+ if (!(typeof l == "bigint" && l > Ae))
2503
2574
  throw new Error(`CURVE.${c} must be positive bigint`);
2504
2575
  }
2505
- const n = Dt(e.p, s.Fp, t), o = Dt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
2576
+ const n = Bt(e.p, s.Fp, t), o = Bt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
2506
2577
  for (const c of a)
2507
2578
  if (!n.isValid(e[c]))
2508
2579
  throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
2509
2580
  return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: n, Fn: o };
2510
2581
  }
2511
- function Nr(r, e) {
2582
+ function Dr(r, e) {
2512
2583
  return function(t) {
2513
2584
  const n = r(t);
2514
2585
  return { secretKey: n, publicKey: e(n) };
2515
2586
  };
2516
2587
  }
2517
- class hs {
2588
+ class gs {
2518
2589
  constructor(e, s) {
2519
- b(this, "oHash");
2520
- b(this, "iHash");
2521
- b(this, "blockLen");
2522
- b(this, "outputLen");
2523
- b(this, "finished", !1);
2524
- b(this, "destroyed", !1);
2525
- if (jt(e), U(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
2590
+ v(this, "oHash");
2591
+ v(this, "iHash");
2592
+ v(this, "blockLen");
2593
+ v(this, "outputLen");
2594
+ v(this, "finished", !1);
2595
+ v(this, "destroyed", !1);
2596
+ if (Kt(e), F(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
2526
2597
  throw new Error("Expected instance of class which extends utils.Hash");
2527
2598
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
2528
2599
  const t = this.blockLen, n = new Uint8Array(t);
@@ -2532,13 +2603,13 @@ class hs {
2532
2603
  this.iHash.update(n), this.oHash = e.create();
2533
2604
  for (let o = 0; o < n.length; o++)
2534
2605
  n[o] ^= 106;
2535
- this.oHash.update(n), Ae(n);
2606
+ this.oHash.update(n), Ie(n);
2536
2607
  }
2537
2608
  update(e) {
2538
2609
  return Te(this), this.iHash.update(e), this;
2539
2610
  }
2540
2611
  digestInto(e) {
2541
- Te(this), U(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
2612
+ Te(this), F(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
2542
2613
  }
2543
2614
  digest() {
2544
2615
  const e = new Uint8Array(this.oHash.outputLen);
@@ -2556,39 +2627,39 @@ class hs {
2556
2627
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
2557
2628
  }
2558
2629
  }
2559
- const fs = (r, e, s) => new hs(r, e).update(s).digest();
2560
- fs.create = (r, e) => new hs(r, e);
2630
+ const ps = (r, e, s) => new gs(r, e).update(s).digest();
2631
+ ps.create = (r, e) => new gs(r, e);
2561
2632
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2562
- const $t = (r, e) => (r + (r >= 0 ? e : -e) / gs) / e;
2563
- function Pr(r, e, s) {
2564
- const [[t, n], [o, i]] = e, a = $t(i * r, s), c = $t(-n * r, s);
2633
+ const Mt = (r, e) => (r + (r >= 0 ? e : -e) / _s) / e;
2634
+ function $r(r, e, s) {
2635
+ const [[t, n], [o, i]] = e, a = Mt(i * r, s), c = Mt(-n * r, s);
2565
2636
  let l = r - a * t - c * o, d = -a * n - c * i;
2566
- const g = l < ae, w = d < ae;
2567
- g && (l = -l), w && (d = -d);
2568
- const m = lt(Math.ceil(pr(s) / 2)) + Ee;
2569
- if (l < ae || l >= m || d < ae || d >= m)
2637
+ const f = l < le, w = d < le;
2638
+ f && (l = -l), w && (d = -d);
2639
+ const m = dt(Math.ceil(wr(s) / 2)) + Ee;
2640
+ if (l < le || l >= m || d < le || d >= m)
2570
2641
  throw new Error("splitScalar (endomorphism): failed, k=" + r);
2571
- return { k1neg: g, k1: l, k2neg: w, k2: d };
2642
+ return { k1neg: f, k1: l, k2neg: w, k2: d };
2572
2643
  }
2573
- function rt(r) {
2644
+ function nt(r) {
2574
2645
  if (!["compact", "recovered", "der"].includes(r))
2575
2646
  throw new Error('Signature format must be "compact", "recovered", or "der"');
2576
2647
  return r;
2577
2648
  }
2578
- function Qe(r, e) {
2649
+ function et(r, e) {
2579
2650
  const s = {};
2580
2651
  for (let t of Object.keys(e))
2581
2652
  s[t] = r[t] === void 0 ? e[t] : r[t];
2582
- return Ue(s.lowS, "lowS"), Ue(s.prehash, "prehash"), s.format !== void 0 && rt(s.format), s;
2653
+ return He(s.lowS, "lowS"), He(s.prehash, "prehash"), s.format !== void 0 && nt(s.format), s;
2583
2654
  }
2584
- class kr extends Error {
2655
+ class Br extends Error {
2585
2656
  constructor(e = "") {
2586
2657
  super(e);
2587
2658
  }
2588
2659
  }
2589
2660
  const pe = {
2590
2661
  // asn.1 DER encoding utils
2591
- Err: kr,
2662
+ Err: Br,
2592
2663
  // Basic building block is TLV (Tag-Length-Value)
2593
2664
  _tlv: {
2594
2665
  encode: (r, e) => {
@@ -2597,11 +2668,11 @@ const pe = {
2597
2668
  throw new s("tlv.encode: wrong tag");
2598
2669
  if (e.length & 1)
2599
2670
  throw new s("tlv.encode: unpadded data");
2600
- const t = e.length / 2, n = De(t);
2671
+ const t = e.length / 2, n = $e(t);
2601
2672
  if (n.length / 2 & 128)
2602
2673
  throw new s("tlv.encode: long form length too big");
2603
- const o = t > 127 ? De(n.length / 2 | 128) : "";
2604
- return De(r) + o + n + e;
2674
+ const o = t > 127 ? $e(n.length / 2 | 128) : "";
2675
+ return $e(r) + o + n + e;
2605
2676
  },
2606
2677
  // v - value, l - left bytes (unparsed)
2607
2678
  decode(r, e) {
@@ -2644,9 +2715,9 @@ const pe = {
2644
2715
  _int: {
2645
2716
  encode(r) {
2646
2717
  const { Err: e } = pe;
2647
- if (r < ae)
2718
+ if (r < le)
2648
2719
  throw new e("integer: negative integers are not allowed");
2649
- let s = De(r);
2720
+ let s = $e(r);
2650
2721
  if (Number.parseInt(s[0], 16) & 8 && (s = "00" + s), s.length & 1)
2651
2722
  throw new e("unexpected DER parsing assertion: unpadded hex");
2652
2723
  return s;
@@ -2657,11 +2728,11 @@ const pe = {
2657
2728
  throw new e("invalid signature integer: negative");
2658
2729
  if (r[0] === 0 && !(r[1] & 128))
2659
2730
  throw new e("invalid signature integer: unnecessary leading zero");
2660
- return We(r);
2731
+ return je(r);
2661
2732
  }
2662
2733
  },
2663
2734
  toSig(r) {
2664
- const { Err: e, _int: s, _tlv: t } = pe, n = U(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
2735
+ const { Err: e, _int: s, _tlv: t } = pe, n = F(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
2665
2736
  if (i.length)
2666
2737
  throw new e("invalid signature: left bytes after parsing");
2667
2738
  const { v: a, l: c } = t.decode(2, o), { v: l, l: d } = t.decode(2, c);
@@ -2673,12 +2744,12 @@ const pe = {
2673
2744
  const { _tlv: e, _int: s } = pe, t = e.encode(2, s.encode(r.r)), n = e.encode(2, s.encode(r.s)), o = t + n;
2674
2745
  return e.encode(48, o);
2675
2746
  }
2676
- }, ae = BigInt(0), Ee = BigInt(1), gs = BigInt(2), $e = BigInt(3), Lr = BigInt(4);
2677
- function Dr(r, e = {}) {
2678
- const s = Cr("weierstrass", r, e), { Fp: t, Fn: n } = s;
2747
+ }, le = BigInt(0), Ee = BigInt(1), _s = BigInt(2), Be = BigInt(3), Mr = BigInt(4);
2748
+ function Ur(r, e = {}) {
2749
+ const s = Lr("weierstrass", r, e), { Fp: t, Fn: n } = s;
2679
2750
  let o = s.CURVE;
2680
2751
  const { h: i, n: a } = o;
2681
- dt(e, {}, {
2752
+ ut(e, {}, {
2682
2753
  allowInfinityPoint: "boolean",
2683
2754
  clearCofactor: "function",
2684
2755
  isTorsionFree: "function",
@@ -2689,111 +2760,111 @@ function Dr(r, e = {}) {
2689
2760
  const { endo: c } = e;
2690
2761
  if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
2691
2762
  throw new Error('invalid endo: expected "beta": bigint and "basises": array');
2692
- const l = xs(t, n);
2763
+ const l = ms(t, n);
2693
2764
  function d() {
2694
2765
  if (!t.isOdd)
2695
2766
  throw new Error("compression is not supported: Field does not have .isOdd()");
2696
2767
  }
2697
- function g(k, u, h) {
2698
- const { x: y, y: S } = u.toAffine(), I = t.toBytes(y);
2699
- if (Ue(h, "isCompressed"), h) {
2768
+ function f(P, u, h) {
2769
+ const { x: y, y: E } = u.toAffine(), R = t.toBytes(y);
2770
+ if (He(h, "isCompressed"), h) {
2700
2771
  d();
2701
- const T = !t.isOdd(S);
2702
- return xe(ps(T), I);
2772
+ const I = !t.isOdd(E);
2773
+ return _e(xs(I), R);
2703
2774
  } else
2704
- return xe(Uint8Array.of(4), I, t.toBytes(S));
2705
- }
2706
- function w(k) {
2707
- U(k, void 0, "Point");
2708
- const { publicKey: u, publicKeyUncompressed: h } = l, y = k.length, S = k[0], I = k.subarray(1);
2709
- if (y === u && (S === 2 || S === 3)) {
2710
- const T = t.fromBytes(I);
2711
- if (!t.isValid(T))
2775
+ return _e(Uint8Array.of(4), R, t.toBytes(E));
2776
+ }
2777
+ function w(P) {
2778
+ F(P, void 0, "Point");
2779
+ const { publicKey: u, publicKeyUncompressed: h } = l, y = P.length, E = P[0], R = P.subarray(1);
2780
+ if (y === u && (E === 2 || E === 3)) {
2781
+ const I = t.fromBytes(R);
2782
+ if (!t.isValid(I))
2712
2783
  throw new Error("bad point: is not on curve, wrong x");
2713
- const R = A(T);
2714
- let v;
2784
+ const O = T(I);
2785
+ let S;
2715
2786
  try {
2716
- v = t.sqrt(R);
2787
+ S = t.sqrt(O);
2717
2788
  } catch (W) {
2718
- const M = W instanceof Error ? ": " + W.message : "";
2719
- throw new Error("bad point: is not on curve, sqrt error" + M);
2789
+ const U = W instanceof Error ? ": " + W.message : "";
2790
+ throw new Error("bad point: is not on curve, sqrt error" + U);
2720
2791
  }
2721
2792
  d();
2722
- const O = t.isOdd(v);
2723
- return (S & 1) === 1 !== O && (v = t.neg(v)), { x: T, y: v };
2724
- } else if (y === h && S === 4) {
2725
- const T = t.BYTES, R = t.fromBytes(I.subarray(0, T)), v = t.fromBytes(I.subarray(T, T * 2));
2726
- if (!E(R, v))
2793
+ const C = t.isOdd(S);
2794
+ return (E & 1) === 1 !== C && (S = t.neg(S)), { x: I, y: S };
2795
+ } else if (y === h && E === 4) {
2796
+ const I = t.BYTES, O = t.fromBytes(R.subarray(0, I)), S = t.fromBytes(R.subarray(I, I * 2));
2797
+ if (!b(O, S))
2727
2798
  throw new Error("bad point: is not on curve");
2728
- return { x: R, y: v };
2799
+ return { x: O, y: S };
2729
2800
  } else
2730
2801
  throw new Error(`bad point: got length ${y}, expected compressed=${u} or uncompressed=${h}`);
2731
2802
  }
2732
- const m = e.toBytes || g, x = e.fromBytes || w;
2733
- function A(k) {
2734
- const u = t.sqr(k), h = t.mul(u, k);
2735
- return t.add(t.add(h, t.mul(k, o.a)), o.b);
2803
+ const m = e.toBytes || f, _ = e.fromBytes || w;
2804
+ function T(P) {
2805
+ const u = t.sqr(P), h = t.mul(u, P);
2806
+ return t.add(t.add(h, t.mul(P, o.a)), o.b);
2736
2807
  }
2737
- function E(k, u) {
2738
- const h = t.sqr(u), y = A(k);
2808
+ function b(P, u) {
2809
+ const h = t.sqr(u), y = T(P);
2739
2810
  return t.eql(h, y);
2740
2811
  }
2741
- if (!E(o.Gx, o.Gy))
2812
+ if (!b(o.Gx, o.Gy))
2742
2813
  throw new Error("bad curve params: generator point");
2743
- const C = t.mul(t.pow(o.a, $e), Lr), q = t.mul(t.sqr(o.b), BigInt(27));
2744
- if (t.is0(t.add(C, q)))
2814
+ const A = t.mul(t.pow(o.a, Be), Mr), q = t.mul(t.sqr(o.b), BigInt(27));
2815
+ if (t.is0(t.add(A, q)))
2745
2816
  throw new Error("bad curve params: a or b");
2746
- function $(k, u, h = !1) {
2817
+ function M(P, u, h = !1) {
2747
2818
  if (!t.isValid(u) || h && t.is0(u))
2748
- throw new Error(`bad point coordinate ${k}`);
2819
+ throw new Error(`bad point coordinate ${P}`);
2749
2820
  return u;
2750
2821
  }
2751
- function B(k) {
2752
- if (!(k instanceof Y))
2822
+ function D(P) {
2823
+ if (!(P instanceof Z))
2753
2824
  throw new Error("Weierstrass Point expected");
2754
2825
  }
2755
- function F(k) {
2826
+ function B(P) {
2756
2827
  if (!c || !c.basises)
2757
2828
  throw new Error("no endo");
2758
- return Pr(k, c.basises, n.ORDER);
2829
+ return $r(P, c.basises, n.ORDER);
2759
2830
  }
2760
- const se = Ot((k, u) => {
2761
- const { X: h, Y: y, Z: S } = k;
2762
- if (t.eql(S, t.ONE))
2831
+ const Q = kt((P, u) => {
2832
+ const { X: h, Y: y, Z: E } = P;
2833
+ if (t.eql(E, t.ONE))
2763
2834
  return { x: h, y };
2764
- const I = k.is0();
2765
- u == null && (u = I ? t.ONE : t.inv(S));
2766
- const T = t.mul(h, u), R = t.mul(y, u), v = t.mul(S, u);
2767
- if (I)
2835
+ const R = P.is0();
2836
+ u == null && (u = R ? t.ONE : t.inv(E));
2837
+ const I = t.mul(h, u), O = t.mul(y, u), S = t.mul(E, u);
2838
+ if (R)
2768
2839
  return { x: t.ZERO, y: t.ZERO };
2769
- if (!t.eql(v, t.ONE))
2840
+ if (!t.eql(S, t.ONE))
2770
2841
  throw new Error("invZ was invalid");
2771
- return { x: T, y: R };
2772
- }), be = Ot((k) => {
2773
- if (k.is0()) {
2774
- if (e.allowInfinityPoint && !t.is0(k.Y))
2842
+ return { x: I, y: O };
2843
+ }), ve = kt((P) => {
2844
+ if (P.is0()) {
2845
+ if (e.allowInfinityPoint && !t.is0(P.Y))
2775
2846
  return;
2776
2847
  throw new Error("bad point: ZERO");
2777
2848
  }
2778
- const { x: u, y: h } = k.toAffine();
2849
+ const { x: u, y: h } = P.toAffine();
2779
2850
  if (!t.isValid(u) || !t.isValid(h))
2780
2851
  throw new Error("bad point: x or y not field elements");
2781
- if (!E(u, h))
2852
+ if (!b(u, h))
2782
2853
  throw new Error("bad point: equation left != right");
2783
- if (!k.isTorsionFree())
2854
+ if (!P.isTorsionFree())
2784
2855
  throw new Error("bad point: not in prime-order subgroup");
2785
2856
  return !0;
2786
2857
  });
2787
- function he(k, u, h, y, S) {
2788
- return h = new Y(t.mul(h.X, k), h.Y, h.Z), u = He(y, u), h = He(S, h), u.add(h);
2858
+ function he(P, u, h, y, E) {
2859
+ return h = new Z(t.mul(h.X, P), h.Y, h.Z), u = Ge(y, u), h = Ge(E, h), u.add(h);
2789
2860
  }
2790
2861
  const L = class L {
2791
2862
  /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
2792
2863
  constructor(u, h, y) {
2793
- b(this, "X");
2794
- b(this, "Y");
2795
- b(this, "Z");
2796
- this.X = $("x", u), this.Y = $("y", h, !0), this.Z = $("z", y), Object.freeze(this);
2864
+ v(this, "X");
2865
+ v(this, "Y");
2866
+ v(this, "Z");
2867
+ this.X = M("x", u), this.Y = M("y", h, !0), this.Z = M("z", y), Object.freeze(this);
2797
2868
  }
2798
2869
  static CURVE() {
2799
2870
  return o;
@@ -2808,7 +2879,7 @@ function Dr(r, e = {}) {
2808
2879
  return t.is0(h) && t.is0(y) ? L.ZERO : new L(h, y, t.ONE);
2809
2880
  }
2810
2881
  static fromBytes(u) {
2811
- const h = L.fromAffine(x(U(u, void 0, "point")));
2882
+ const h = L.fromAffine(_(F(u, void 0, "point")));
2812
2883
  return h.assertValidity(), h;
2813
2884
  }
2814
2885
  static fromHex(u) {
@@ -2827,12 +2898,12 @@ function Dr(r, e = {}) {
2827
2898
  * @returns
2828
2899
  */
2829
2900
  precompute(u = 8, h = !0) {
2830
- return ne.createCache(this, u), h || this.multiply($e), this;
2901
+ return ne.createCache(this, u), h || this.multiply(Be), this;
2831
2902
  }
2832
2903
  // TODO: return `this`
2833
2904
  /** A point on curve is valid if it conforms to equation. */
2834
2905
  assertValidity() {
2835
- be(this);
2906
+ ve(this);
2836
2907
  }
2837
2908
  hasEvenY() {
2838
2909
  const { y: u } = this.toAffine();
@@ -2842,9 +2913,9 @@ function Dr(r, e = {}) {
2842
2913
  }
2843
2914
  /** Compare one point to another. */
2844
2915
  equals(u) {
2845
- B(u);
2846
- const { X: h, Y: y, Z: S } = this, { X: I, Y: T, Z: R } = u, v = t.eql(t.mul(h, R), t.mul(I, S)), O = t.eql(t.mul(y, R), t.mul(T, S));
2847
- return v && O;
2916
+ D(u);
2917
+ const { X: h, Y: y, Z: E } = this, { X: R, Y: I, Z: O } = u, S = t.eql(t.mul(h, O), t.mul(R, E)), C = t.eql(t.mul(y, O), t.mul(I, E));
2918
+ return S && C;
2848
2919
  }
2849
2920
  /** Flips point to one corresponding to (x, -y) in Affine coordinates. */
2850
2921
  negate() {
@@ -2855,23 +2926,23 @@ function Dr(r, e = {}) {
2855
2926
  // https://eprint.iacr.org/2015/1060, algorithm 3
2856
2927
  // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
2857
2928
  double() {
2858
- const { a: u, b: h } = o, y = t.mul(h, $e), { X: S, Y: I, Z: T } = this;
2859
- let R = t.ZERO, v = t.ZERO, O = t.ZERO, P = t.mul(S, S), W = t.mul(I, I), M = t.mul(T, T), N = t.mul(S, I);
2860
- return N = t.add(N, N), O = t.mul(S, T), O = t.add(O, O), R = t.mul(u, O), v = t.mul(y, M), v = t.add(R, v), R = t.sub(W, v), v = t.add(W, v), v = t.mul(R, v), R = t.mul(N, R), O = t.mul(y, O), M = t.mul(u, M), N = t.sub(P, M), N = t.mul(u, N), N = t.add(N, O), O = t.add(P, P), P = t.add(O, P), P = t.add(P, M), P = t.mul(P, N), v = t.add(v, P), M = t.mul(I, T), M = t.add(M, M), P = t.mul(M, N), R = t.sub(R, P), O = t.mul(M, W), O = t.add(O, O), O = t.add(O, O), new L(R, v, O);
2929
+ const { a: u, b: h } = o, y = t.mul(h, Be), { X: E, Y: R, Z: I } = this;
2930
+ let O = t.ZERO, S = t.ZERO, C = t.ZERO, N = t.mul(E, E), W = t.mul(R, R), U = t.mul(I, I), k = t.mul(E, R);
2931
+ return k = t.add(k, k), C = t.mul(E, I), C = t.add(C, C), O = t.mul(u, C), S = t.mul(y, U), S = t.add(O, S), O = t.sub(W, S), S = t.add(W, S), S = t.mul(O, S), O = t.mul(k, O), C = t.mul(y, C), U = t.mul(u, U), k = t.sub(N, U), k = t.mul(u, k), k = t.add(k, C), C = t.add(N, N), N = t.add(C, N), N = t.add(N, U), N = t.mul(N, k), S = t.add(S, N), U = t.mul(R, I), U = t.add(U, U), N = t.mul(U, k), O = t.sub(O, N), C = t.mul(U, W), C = t.add(C, C), C = t.add(C, C), new L(O, S, C);
2861
2932
  }
2862
2933
  // Renes-Costello-Batina exception-free addition formula.
2863
2934
  // There is 30% faster Jacobian formula, but it is not complete.
2864
2935
  // https://eprint.iacr.org/2015/1060, algorithm 1
2865
2936
  // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
2866
2937
  add(u) {
2867
- B(u);
2868
- const { X: h, Y: y, Z: S } = this, { X: I, Y: T, Z: R } = u;
2869
- let v = t.ZERO, O = t.ZERO, P = t.ZERO;
2870
- const W = o.a, M = t.mul(o.b, $e);
2871
- let N = t.mul(h, I), j = t.mul(y, T), V = t.mul(S, R), J = t.add(h, y), H = t.add(I, T);
2872
- J = t.mul(J, H), H = t.add(N, j), J = t.sub(J, H), H = t.add(h, S);
2873
- let K = t.add(I, R);
2874
- return H = t.mul(H, K), K = t.add(N, V), H = t.sub(H, K), K = t.add(y, S), v = t.add(T, R), K = t.mul(K, v), v = t.add(j, V), K = t.sub(K, v), P = t.mul(W, H), v = t.mul(M, V), P = t.add(v, P), v = t.sub(j, P), P = t.add(j, P), O = t.mul(v, P), j = t.add(N, N), j = t.add(j, N), V = t.mul(W, V), H = t.mul(M, H), j = t.add(j, V), V = t.sub(N, V), V = t.mul(W, V), H = t.add(H, V), N = t.mul(j, H), O = t.add(O, N), N = t.mul(K, H), v = t.mul(J, v), v = t.sub(v, N), N = t.mul(J, j), P = t.mul(K, P), P = t.add(P, N), new L(v, O, P);
2938
+ D(u);
2939
+ const { X: h, Y: y, Z: E } = this, { X: R, Y: I, Z: O } = u;
2940
+ let S = t.ZERO, C = t.ZERO, N = t.ZERO;
2941
+ const W = o.a, U = t.mul(o.b, Be);
2942
+ let k = t.mul(h, R), j = t.mul(y, I), V = t.mul(E, O), ee = t.add(h, y), H = t.add(R, I);
2943
+ ee = t.mul(ee, H), H = t.add(k, j), ee = t.sub(ee, H), H = t.add(h, E);
2944
+ let K = t.add(R, O);
2945
+ return H = t.mul(H, K), K = t.add(k, V), H = t.sub(H, K), K = t.add(y, E), S = t.add(I, O), K = t.mul(K, S), S = t.add(j, V), K = t.sub(K, S), N = t.mul(W, H), S = t.mul(U, V), N = t.add(S, N), S = t.sub(j, N), N = t.add(j, N), C = t.mul(S, N), j = t.add(k, k), j = t.add(j, k), V = t.mul(W, V), H = t.mul(U, H), j = t.add(j, V), V = t.sub(k, V), V = t.mul(W, V), H = t.add(H, V), k = t.mul(j, H), C = t.add(C, k), k = t.mul(K, H), S = t.mul(ee, S), S = t.sub(S, k), k = t.mul(ee, j), N = t.mul(K, N), N = t.add(N, k), new L(S, C, N);
2875
2946
  }
2876
2947
  subtract(u) {
2877
2948
  return this.add(u.negate());
@@ -2892,16 +2963,16 @@ function Dr(r, e = {}) {
2892
2963
  const { endo: h } = e;
2893
2964
  if (!n.isValidNot0(u))
2894
2965
  throw new Error("invalid scalar: out of range");
2895
- let y, S;
2896
- const I = (T) => ne.cached(this, T, (R) => Pt(L, R));
2966
+ let y, E;
2967
+ const R = (I) => ne.cached(this, I, (O) => Lt(L, O));
2897
2968
  if (h) {
2898
- const { k1neg: T, k1: R, k2neg: v, k2: O } = F(u), { p: P, f: W } = I(R), { p: M, f: N } = I(O);
2899
- S = W.add(N), y = he(h.beta, P, M, T, v);
2969
+ const { k1neg: I, k1: O, k2neg: S, k2: C } = B(u), { p: N, f: W } = R(O), { p: U, f: k } = R(C);
2970
+ E = W.add(k), y = he(h.beta, N, U, I, S);
2900
2971
  } else {
2901
- const { p: T, f: R } = I(u);
2902
- y = T, S = R;
2972
+ const { p: I, f: O } = R(u);
2973
+ y = I, E = O;
2903
2974
  }
2904
- return Pt(L, [y, S])[0];
2975
+ return Lt(L, [y, E])[0];
2905
2976
  }
2906
2977
  /**
2907
2978
  * Non-constant-time multiplication. Uses double-and-add algorithm.
@@ -2912,15 +2983,15 @@ function Dr(r, e = {}) {
2912
2983
  const { endo: h } = e, y = this;
2913
2984
  if (!n.isValid(u))
2914
2985
  throw new Error("invalid scalar: out of range");
2915
- if (u === ae || y.is0())
2986
+ if (u === le || y.is0())
2916
2987
  return L.ZERO;
2917
2988
  if (u === Ee)
2918
2989
  return y;
2919
2990
  if (ne.hasCache(this))
2920
2991
  return this.multiply(u);
2921
2992
  if (h) {
2922
- const { k1neg: S, k1: I, k2neg: T, k2: R } = F(u), { p1: v, p2: O } = Or(L, y, I, R);
2923
- return he(h.beta, v, O, S, T);
2993
+ const { k1neg: E, k1: R, k2neg: I, k2: O } = B(u), { p1: S, p2: C } = Pr(L, y, R, O);
2994
+ return he(h.beta, S, C, E, I);
2924
2995
  } else
2925
2996
  return ne.unsafe(y, u);
2926
2997
  }
@@ -2929,7 +3000,7 @@ function Dr(r, e = {}) {
2929
3000
  * @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
2930
3001
  */
2931
3002
  toAffine(u) {
2932
- return se(this, u);
3003
+ return Q(this, u);
2933
3004
  }
2934
3005
  /**
2935
3006
  * Checks whether Point is free of torsion elements (is in prime subgroup).
@@ -2947,29 +3018,29 @@ function Dr(r, e = {}) {
2947
3018
  return this.multiplyUnsafe(i).is0();
2948
3019
  }
2949
3020
  toBytes(u = !0) {
2950
- return Ue(u, "isCompressed"), this.assertValidity(), m(L, this, u);
3021
+ return He(u, "isCompressed"), this.assertValidity(), m(L, this, u);
2951
3022
  }
2952
3023
  toHex(u = !0) {
2953
- return Ce(this.toBytes(u));
3024
+ return ke(this.toBytes(u));
2954
3025
  }
2955
3026
  toString() {
2956
3027
  return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
2957
3028
  }
2958
3029
  };
2959
3030
  // base / generator point
2960
- b(L, "BASE", new L(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
2961
- b(L, "ZERO", new L(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
3031
+ v(L, "BASE", new L(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
3032
+ v(L, "ZERO", new L(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
2962
3033
  // math field
2963
- b(L, "Fp", t), // scalar field
2964
- b(L, "Fn", n);
2965
- let Y = L;
2966
- const _e = n.BITS, ne = new Rr(Y, e.endo ? Math.ceil(_e / 2) : _e);
2967
- return Y.BASE.precompute(8), Y;
3034
+ v(L, "Fp", t), // scalar field
3035
+ v(L, "Fn", n);
3036
+ let Z = L;
3037
+ const xe = n.BITS, ne = new Nr(Z, e.endo ? Math.ceil(xe / 2) : xe);
3038
+ return Z.BASE.precompute(8), Z;
2968
3039
  }
2969
- function ps(r) {
3040
+ function xs(r) {
2970
3041
  return Uint8Array.of(r ? 2 : 3);
2971
3042
  }
2972
- function xs(r, e) {
3043
+ function ms(r, e) {
2973
3044
  return {
2974
3045
  secretKey: e.BYTES,
2975
3046
  publicKey: 1 + r.BYTES,
@@ -2978,107 +3049,107 @@ function xs(r, e) {
2978
3049
  signature: 2 * e.BYTES
2979
3050
  };
2980
3051
  }
2981
- function $r(r, e = {}) {
2982
- const { Fn: s } = r, t = e.randomBytes || Yt, n = Object.assign(xs(r.Fp, s), { seed: ls(s.ORDER) });
3052
+ function Fr(r, e = {}) {
3053
+ const { Fn: s } = r, t = e.randomBytes || Xt, n = Object.assign(ms(r.Fp, s), { seed: us(s.ORDER) });
2983
3054
  function o(m) {
2984
3055
  try {
2985
- const x = s.fromBytes(m);
2986
- return s.isValidNot0(x);
3056
+ const _ = s.fromBytes(m);
3057
+ return s.isValidNot0(_);
2987
3058
  } catch {
2988
3059
  return !1;
2989
3060
  }
2990
3061
  }
2991
- function i(m, x) {
2992
- const { publicKey: A, publicKeyUncompressed: E } = n;
3062
+ function i(m, _) {
3063
+ const { publicKey: T, publicKeyUncompressed: b } = n;
2993
3064
  try {
2994
- const C = m.length;
2995
- return x === !0 && C !== A || x === !1 && C !== E ? !1 : !!r.fromBytes(m);
3065
+ const A = m.length;
3066
+ return _ === !0 && A !== T || _ === !1 && A !== b ? !1 : !!r.fromBytes(m);
2996
3067
  } catch {
2997
3068
  return !1;
2998
3069
  }
2999
3070
  }
3000
3071
  function a(m = t(n.seed)) {
3001
- return Ir(U(m, n.seed, "seed"), s.ORDER);
3072
+ return kr(F(m, n.seed, "seed"), s.ORDER);
3002
3073
  }
3003
- function c(m, x = !0) {
3004
- return r.BASE.multiply(s.fromBytes(m)).toBytes(x);
3074
+ function c(m, _ = !0) {
3075
+ return r.BASE.multiply(s.fromBytes(m)).toBytes(_);
3005
3076
  }
3006
3077
  function l(m) {
3007
- const { secretKey: x, publicKey: A, publicKeyUncompressed: E } = n;
3008
- if (!it(m) || "_lengths" in s && s._lengths || x === A)
3078
+ const { secretKey: _, publicKey: T, publicKeyUncompressed: b } = n;
3079
+ if (!at(m) || "_lengths" in s && s._lengths || _ === T)
3009
3080
  return;
3010
- const C = U(m, void 0, "key").length;
3011
- return C === A || C === E;
3081
+ const A = F(m, void 0, "key").length;
3082
+ return A === T || A === b;
3012
3083
  }
3013
- function d(m, x, A = !0) {
3084
+ function d(m, _, T = !0) {
3014
3085
  if (l(m) === !0)
3015
3086
  throw new Error("first arg must be private key");
3016
- if (l(x) === !1)
3087
+ if (l(_) === !1)
3017
3088
  throw new Error("second arg must be public key");
3018
- const E = s.fromBytes(m);
3019
- return r.fromBytes(x).multiply(E).toBytes(A);
3089
+ const b = s.fromBytes(m);
3090
+ return r.fromBytes(_).multiply(b).toBytes(T);
3020
3091
  }
3021
- const g = {
3092
+ const f = {
3022
3093
  isValidSecretKey: o,
3023
3094
  isValidPublicKey: i,
3024
3095
  randomSecretKey: a
3025
- }, w = Nr(a, c);
3026
- return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: w, Point: r, utils: g, lengths: n });
3096
+ }, w = Dr(a, c);
3097
+ return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: w, Point: r, utils: f, lengths: n });
3027
3098
  }
3028
- function Br(r, e, s = {}) {
3029
- jt(e), dt(s, {}, {
3099
+ function Hr(r, e, s = {}) {
3100
+ Kt(e), ut(s, {}, {
3030
3101
  hmac: "function",
3031
3102
  lowS: "boolean",
3032
3103
  randomBytes: "function",
3033
3104
  bits2int: "function",
3034
3105
  bits2int_modN: "function"
3035
3106
  }), s = Object.assign({}, s);
3036
- const t = s.randomBytes || Yt, n = s.hmac || ((u, h) => fs(e, u, h)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: d, getSharedSecret: g, utils: w, lengths: m } = $r(r, s), x = {
3107
+ const t = s.randomBytes || Xt, n = s.hmac || ((u, h) => ps(e, u, h)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: d, getSharedSecret: f, utils: w, lengths: m } = Fr(r, s), _ = {
3037
3108
  prehash: !0,
3038
3109
  lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
3039
3110
  format: "compact",
3040
3111
  extraEntropy: !1
3041
- }, A = a * gs < o.ORDER;
3042
- function E(u) {
3112
+ }, T = a * _s < o.ORDER;
3113
+ function b(u) {
3043
3114
  const h = a >> Ee;
3044
3115
  return u > h;
3045
3116
  }
3046
- function C(u, h) {
3117
+ function A(u, h) {
3047
3118
  if (!i.isValidNot0(h))
3048
3119
  throw new Error(`invalid signature ${u}: out of range 1..Point.Fn.ORDER`);
3049
3120
  return h;
3050
3121
  }
3051
3122
  function q() {
3052
- if (A)
3123
+ if (T)
3053
3124
  throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
3054
3125
  }
3055
- function $(u, h) {
3056
- rt(h);
3057
- const y = m.signature, S = h === "compact" ? y : h === "recovered" ? y + 1 : void 0;
3058
- return U(u, S);
3059
- }
3060
- class B {
3061
- constructor(h, y, S) {
3062
- b(this, "r");
3063
- b(this, "s");
3064
- b(this, "recovery");
3065
- if (this.r = C("r", h), this.s = C("s", y), S != null) {
3066
- if (q(), ![0, 1, 2, 3].includes(S))
3126
+ function M(u, h) {
3127
+ nt(h);
3128
+ const y = m.signature, E = h === "compact" ? y : h === "recovered" ? y + 1 : void 0;
3129
+ return F(u, E);
3130
+ }
3131
+ class D {
3132
+ constructor(h, y, E) {
3133
+ v(this, "r");
3134
+ v(this, "s");
3135
+ v(this, "recovery");
3136
+ if (this.r = A("r", h), this.s = A("s", y), E != null) {
3137
+ if (q(), ![0, 1, 2, 3].includes(E))
3067
3138
  throw new Error("invalid recovery id");
3068
- this.recovery = S;
3139
+ this.recovery = E;
3069
3140
  }
3070
3141
  Object.freeze(this);
3071
3142
  }
3072
- static fromBytes(h, y = x.format) {
3073
- $(h, y);
3074
- let S;
3143
+ static fromBytes(h, y = _.format) {
3144
+ M(h, y);
3145
+ let E;
3075
3146
  if (y === "der") {
3076
- const { r: v, s: O } = pe.toSig(U(h));
3077
- return new B(v, O);
3147
+ const { r: S, s: C } = pe.toSig(F(h));
3148
+ return new D(S, C);
3078
3149
  }
3079
- y === "recovered" && (S = h[0], y = "compact", h = h.subarray(1));
3080
- const I = m.signature / 2, T = h.subarray(0, I), R = h.subarray(I, I * 2);
3081
- return new B(i.fromBytes(T), i.fromBytes(R), S);
3150
+ y === "recovered" && (E = h[0], y = "compact", h = h.subarray(1));
3151
+ const R = m.signature / 2, I = h.subarray(0, R), O = h.subarray(R, R * 2);
3152
+ return new D(i.fromBytes(I), i.fromBytes(O), E);
3082
3153
  }
3083
3154
  static fromHex(h, y) {
3084
3155
  return this.fromBytes(Fe(h), y);
@@ -3090,113 +3161,113 @@ function Br(r, e, s = {}) {
3090
3161
  return h;
3091
3162
  }
3092
3163
  addRecoveryBit(h) {
3093
- return new B(this.r, this.s, h);
3164
+ return new D(this.r, this.s, h);
3094
3165
  }
3095
3166
  recoverPublicKey(h) {
3096
- const { r: y, s: S } = this, I = this.assertRecovery(), T = I === 2 || I === 3 ? y + a : y;
3097
- if (!o.isValid(T))
3167
+ const { r: y, s: E } = this, R = this.assertRecovery(), I = R === 2 || R === 3 ? y + a : y;
3168
+ if (!o.isValid(I))
3098
3169
  throw new Error("invalid recovery id: sig.r+curve.n != R.x");
3099
- const R = o.toBytes(T), v = r.fromBytes(xe(ps((I & 1) === 0), R)), O = i.inv(T), P = se(U(h, void 0, "msgHash")), W = i.create(-P * O), M = i.create(S * O), N = r.BASE.multiplyUnsafe(W).add(v.multiplyUnsafe(M));
3100
- if (N.is0())
3170
+ const O = o.toBytes(I), S = r.fromBytes(_e(xs((R & 1) === 0), O)), C = i.inv(I), N = Q(F(h, void 0, "msgHash")), W = i.create(-N * C), U = i.create(E * C), k = r.BASE.multiplyUnsafe(W).add(S.multiplyUnsafe(U));
3171
+ if (k.is0())
3101
3172
  throw new Error("invalid recovery: point at infinify");
3102
- return N.assertValidity(), N;
3173
+ return k.assertValidity(), k;
3103
3174
  }
3104
3175
  // Signatures should be low-s, to prevent malleability.
3105
3176
  hasHighS() {
3106
- return E(this.s);
3177
+ return b(this.s);
3107
3178
  }
3108
- toBytes(h = x.format) {
3109
- if (rt(h), h === "der")
3179
+ toBytes(h = _.format) {
3180
+ if (nt(h), h === "der")
3110
3181
  return Fe(pe.hexFromSig(this));
3111
- const { r: y, s: S } = this, I = i.toBytes(y), T = i.toBytes(S);
3112
- return h === "recovered" ? (q(), xe(Uint8Array.of(this.assertRecovery()), I, T)) : xe(I, T);
3182
+ const { r: y, s: E } = this, R = i.toBytes(y), I = i.toBytes(E);
3183
+ return h === "recovered" ? (q(), _e(Uint8Array.of(this.assertRecovery()), R, I)) : _e(R, I);
3113
3184
  }
3114
3185
  toHex(h) {
3115
- return Ce(this.toBytes(h));
3186
+ return ke(this.toBytes(h));
3116
3187
  }
3117
3188
  }
3118
- const F = s.bits2int || function(h) {
3189
+ const B = s.bits2int || function(h) {
3119
3190
  if (h.length > 8192)
3120
3191
  throw new Error("input is too large");
3121
- const y = We(h), S = h.length * 8 - c;
3122
- return S > 0 ? y >> BigInt(S) : y;
3123
- }, se = s.bits2int_modN || function(h) {
3124
- return i.create(F(h));
3125
- }, be = lt(c);
3192
+ const y = je(h), E = h.length * 8 - c;
3193
+ return E > 0 ? y >> BigInt(E) : y;
3194
+ }, Q = s.bits2int_modN || function(h) {
3195
+ return i.create(B(h));
3196
+ }, ve = dt(c);
3126
3197
  function he(u) {
3127
- return gr("num < 2^" + c, u, ae, be), i.toBytes(u);
3198
+ return mr("num < 2^" + c, u, le, ve), i.toBytes(u);
3128
3199
  }
3129
- function Y(u, h) {
3130
- return U(u, void 0, "message"), h ? U(e(u), void 0, "prehashed message") : u;
3200
+ function Z(u, h) {
3201
+ return F(u, void 0, "message"), h ? F(e(u), void 0, "prehashed message") : u;
3131
3202
  }
3132
- function _e(u, h, y) {
3133
- const { lowS: S, prehash: I, extraEntropy: T } = Qe(y, x);
3134
- u = Y(u, I);
3135
- const R = se(u), v = i.fromBytes(h);
3136
- if (!i.isValidNot0(v))
3203
+ function xe(u, h, y) {
3204
+ const { lowS: E, prehash: R, extraEntropy: I } = et(y, _);
3205
+ u = Z(u, R);
3206
+ const O = Q(u), S = i.fromBytes(h);
3207
+ if (!i.isValidNot0(S))
3137
3208
  throw new Error("invalid private key");
3138
- const O = [he(v), he(R)];
3139
- if (T != null && T !== !1) {
3140
- const N = T === !0 ? t(m.secretKey) : T;
3141
- O.push(U(N, void 0, "extraEntropy"));
3209
+ const C = [he(S), he(O)];
3210
+ if (I != null && I !== !1) {
3211
+ const k = I === !0 ? t(m.secretKey) : I;
3212
+ C.push(F(k, void 0, "extraEntropy"));
3142
3213
  }
3143
- const P = xe(...O), W = R;
3144
- function M(N) {
3145
- const j = F(N);
3214
+ const N = _e(...C), W = O;
3215
+ function U(k) {
3216
+ const j = B(k);
3146
3217
  if (!i.isValidNot0(j))
3147
3218
  return;
3148
- const V = i.inv(j), J = r.BASE.multiply(j).toAffine(), H = i.create(J.x);
3149
- if (H === ae)
3219
+ const V = i.inv(j), ee = r.BASE.multiply(j).toAffine(), H = i.create(ee.x);
3220
+ if (H === le)
3150
3221
  return;
3151
- const K = i.create(V * i.create(W + H * v));
3152
- if (K === ae)
3222
+ const K = i.create(V * i.create(W + H * S));
3223
+ if (K === le)
3153
3224
  return;
3154
- let xt = (J.x === H ? 0 : 2) | Number(J.y & Ee), _t = K;
3155
- return S && E(K) && (_t = i.neg(K), xt ^= 1), new B(H, _t, A ? void 0 : xt);
3225
+ let xt = (ee.x === H ? 0 : 2) | Number(ee.y & Ee), mt = K;
3226
+ return E && b(K) && (mt = i.neg(K), xt ^= 1), new D(H, mt, T ? void 0 : xt);
3156
3227
  }
3157
- return { seed: P, k2sig: M };
3228
+ return { seed: N, k2sig: U };
3158
3229
  }
3159
3230
  function ne(u, h, y = {}) {
3160
- const { seed: S, k2sig: I } = _e(u, h, y);
3161
- return xr(e.outputLen, i.BYTES, n)(S, I).toBytes(y.format);
3162
- }
3163
- function L(u, h, y, S = {}) {
3164
- const { lowS: I, prehash: T, format: R } = Qe(S, x);
3165
- if (y = U(y, void 0, "publicKey"), h = Y(h, T), !it(u)) {
3166
- const v = u instanceof B ? ", use sig.toBytes()" : "";
3167
- throw new Error("verify expects Uint8Array signature" + v);
3231
+ const { seed: E, k2sig: R } = xe(u, h, y);
3232
+ return yr(e.outputLen, i.BYTES, n)(E, R).toBytes(y.format);
3233
+ }
3234
+ function L(u, h, y, E = {}) {
3235
+ const { lowS: R, prehash: I, format: O } = et(E, _);
3236
+ if (y = F(y, void 0, "publicKey"), h = Z(h, I), !at(u)) {
3237
+ const S = u instanceof D ? ", use sig.toBytes()" : "";
3238
+ throw new Error("verify expects Uint8Array signature" + S);
3168
3239
  }
3169
- $(u, R);
3240
+ M(u, O);
3170
3241
  try {
3171
- const v = B.fromBytes(u, R), O = r.fromBytes(y);
3172
- if (I && v.hasHighS())
3242
+ const S = D.fromBytes(u, O), C = r.fromBytes(y);
3243
+ if (R && S.hasHighS())
3173
3244
  return !1;
3174
- const { r: P, s: W } = v, M = se(h), N = i.inv(W), j = i.create(M * N), V = i.create(P * N), J = r.BASE.multiplyUnsafe(j).add(O.multiplyUnsafe(V));
3175
- return J.is0() ? !1 : i.create(J.x) === P;
3245
+ const { r: N, s: W } = S, U = Q(h), k = i.inv(W), j = i.create(U * k), V = i.create(N * k), ee = r.BASE.multiplyUnsafe(j).add(C.multiplyUnsafe(V));
3246
+ return ee.is0() ? !1 : i.create(ee.x) === N;
3176
3247
  } catch {
3177
3248
  return !1;
3178
3249
  }
3179
3250
  }
3180
- function k(u, h, y = {}) {
3181
- const { prehash: S } = Qe(y, x);
3182
- return h = Y(h, S), B.fromBytes(u, "recovered").recoverPublicKey(h).toBytes();
3251
+ function P(u, h, y = {}) {
3252
+ const { prehash: E } = et(y, _);
3253
+ return h = Z(h, E), D.fromBytes(u, "recovered").recoverPublicKey(h).toBytes();
3183
3254
  }
3184
3255
  return Object.freeze({
3185
3256
  keygen: l,
3186
3257
  getPublicKey: d,
3187
- getSharedSecret: g,
3258
+ getSharedSecret: f,
3188
3259
  utils: w,
3189
3260
  lengths: m,
3190
3261
  Point: r,
3191
3262
  sign: ne,
3192
3263
  verify: L,
3193
- recoverPublicKey: k,
3194
- Signature: B,
3264
+ recoverPublicKey: P,
3265
+ Signature: D,
3195
3266
  hash: e
3196
3267
  });
3197
3268
  }
3198
3269
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3199
- const ht = {
3270
+ const ft = {
3200
3271
  p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
3201
3272
  n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
3202
3273
  h: BigInt(1),
@@ -3204,44 +3275,44 @@ const ht = {
3204
3275
  b: BigInt(7),
3205
3276
  Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
3206
3277
  Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
3207
- }, Mr = {
3278
+ }, Gr = {
3208
3279
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
3209
3280
  basises: [
3210
3281
  [BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
3211
3282
  [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
3212
3283
  ]
3213
- }, Bt = /* @__PURE__ */ BigInt(2);
3214
- function Fr(r) {
3215
- const e = ht.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, g = ee(d, s, e) * d % e, w = ee(g, s, e) * d % e, m = ee(w, Bt, e) * l % e, x = ee(m, n, e) * m % e, A = ee(x, o, e) * x % e, E = ee(A, a, e) * A % e, C = ee(E, c, e) * E % e, q = ee(C, a, e) * A % e, $ = ee(q, s, e) * d % e, B = ee($, i, e) * x % e, F = ee(B, t, e) * l % e, se = ee(F, Bt, e);
3216
- if (!nt.eql(nt.sqr(se), r))
3284
+ }, Ut = /* @__PURE__ */ BigInt(2);
3285
+ function qr(r) {
3286
+ const e = ft.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, f = se(d, s, e) * d % e, w = se(f, s, e) * d % e, m = se(w, Ut, e) * l % e, _ = se(m, n, e) * m % e, T = se(_, o, e) * _ % e, b = se(T, a, e) * T % e, A = se(b, c, e) * b % e, q = se(A, a, e) * T % e, M = se(q, s, e) * d % e, D = se(M, i, e) * _ % e, B = se(D, t, e) * l % e, Q = se(B, Ut, e);
3287
+ if (!ot.eql(ot.sqr(Q), r))
3217
3288
  throw new Error("Cannot find square root");
3218
- return se;
3289
+ return Q;
3219
3290
  }
3220
- const nt = je(ht.p, { sqrt: Fr }), Ur = /* @__PURE__ */ Dr(ht, {
3221
- Fp: nt,
3222
- endo: Mr
3223
- }), Hr = /* @__PURE__ */ Br(Ur, ur), Gr = BigInt(0), Re = BigInt(1), qr = BigInt(2), Wr = BigInt(7), jr = BigInt(256), Vr = BigInt(113), _s = [], ms = [], ws = [];
3291
+ const ot = Ve(ft.p, { sqrt: qr }), Wr = /* @__PURE__ */ Ur(ft, {
3292
+ Fp: ot,
3293
+ endo: Gr
3294
+ }), jr = /* @__PURE__ */ Hr(Wr, pr), Vr = BigInt(0), Re = BigInt(1), Kr = BigInt(2), zr = BigInt(7), Yr = BigInt(256), Zr = BigInt(113), ws = [], ys = [], bs = [];
3224
3295
  for (let r = 0, e = Re, s = 1, t = 0; r < 24; r++) {
3225
- [s, t] = [t, (2 * s + 3 * t) % 5], _s.push(2 * (5 * t + s)), ms.push((r + 1) * (r + 2) / 2 % 64);
3226
- let n = Gr;
3296
+ [s, t] = [t, (2 * s + 3 * t) % 5], ws.push(2 * (5 * t + s)), ys.push((r + 1) * (r + 2) / 2 % 64);
3297
+ let n = Vr;
3227
3298
  for (let o = 0; o < 7; o++)
3228
- e = (e << Re ^ (e >> Wr) * Vr) % jr, e & qr && (n ^= Re << (Re << BigInt(o)) - Re);
3229
- ws.push(n);
3299
+ e = (e << Re ^ (e >> zr) * Zr) % Yr, e & Kr && (n ^= Re << (Re << BigInt(o)) - Re);
3300
+ bs.push(n);
3230
3301
  }
3231
- const ys = rr(ws, !0), Kr = ys[0], zr = ys[1], Mt = (r, e, s) => s > 32 ? ir(r, e, s) : nr(r, e, s), Ft = (r, e, s) => s > 32 ? ar(r, e, s) : or(r, e, s);
3232
- function Yr(r, e = 24) {
3302
+ const vs = ar(bs, !0), Xr = vs[0], Jr = vs[1], Ft = (r, e, s) => s > 32 ? dr(r, e, s) : cr(r, e, s), Ht = (r, e, s) => s > 32 ? ur(r, e, s) : lr(r, e, s);
3303
+ function Qr(r, e = 24) {
3233
3304
  const s = new Uint32Array(10);
3234
3305
  for (let t = 24 - e; t < 24; t++) {
3235
3306
  for (let i = 0; i < 10; i++)
3236
3307
  s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
3237
3308
  for (let i = 0; i < 10; i += 2) {
3238
- const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], g = Mt(l, d, 1) ^ s[a], w = Ft(l, d, 1) ^ s[a + 1];
3309
+ const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], f = Ft(l, d, 1) ^ s[a], w = Ht(l, d, 1) ^ s[a + 1];
3239
3310
  for (let m = 0; m < 50; m += 10)
3240
- r[i + m] ^= g, r[i + m + 1] ^= w;
3311
+ r[i + m] ^= f, r[i + m + 1] ^= w;
3241
3312
  }
3242
3313
  let n = r[2], o = r[3];
3243
3314
  for (let i = 0; i < 24; i++) {
3244
- const a = ms[i], c = Mt(n, o, a), l = Ft(n, o, a), d = _s[i];
3315
+ const a = ys[i], c = Ft(n, o, a), l = Ht(n, o, a), d = ws[i];
3245
3316
  n = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
3246
3317
  }
3247
3318
  for (let i = 0; i < 50; i += 10) {
@@ -3250,36 +3321,36 @@ function Yr(r, e = 24) {
3250
3321
  for (let a = 0; a < 10; a++)
3251
3322
  r[i + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
3252
3323
  }
3253
- r[0] ^= Kr[t], r[1] ^= zr[t];
3324
+ r[0] ^= Xr[t], r[1] ^= Jr[t];
3254
3325
  }
3255
- Ae(s);
3326
+ Ie(s);
3256
3327
  }
3257
- class ft {
3328
+ class gt {
3258
3329
  // NOTE: we accept arguments in bytes instead of bits here.
3259
3330
  constructor(e, s, t, n = !1, o = 24) {
3260
- b(this, "state");
3261
- b(this, "pos", 0);
3262
- b(this, "posOut", 0);
3263
- b(this, "finished", !1);
3264
- b(this, "state32");
3265
- b(this, "destroyed", !1);
3266
- b(this, "blockLen");
3267
- b(this, "suffix");
3268
- b(this, "outputLen");
3269
- b(this, "enableXOF", !1);
3270
- b(this, "rounds");
3271
- if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, le(t, "outputLen"), !(0 < e && e < 200))
3331
+ v(this, "state");
3332
+ v(this, "pos", 0);
3333
+ v(this, "posOut", 0);
3334
+ v(this, "finished", !1);
3335
+ v(this, "state32");
3336
+ v(this, "destroyed", !1);
3337
+ v(this, "blockLen");
3338
+ v(this, "suffix");
3339
+ v(this, "outputLen");
3340
+ v(this, "enableXOF", !1);
3341
+ v(this, "rounds");
3342
+ if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, ue(t, "outputLen"), !(0 < e && e < 200))
3272
3343
  throw new Error("only keccak-f1600 function is supported");
3273
- this.state = new Uint8Array(200), this.state32 = Ks(this.state);
3344
+ this.state = new Uint8Array(200), this.state32 = Xs(this.state);
3274
3345
  }
3275
3346
  clone() {
3276
3347
  return this._cloneInto();
3277
3348
  }
3278
3349
  keccak() {
3279
- At(this.state32), Yr(this.state32, this.rounds), At(this.state32), this.posOut = 0, this.pos = 0;
3350
+ Rt(this.state32), Qr(this.state32, this.rounds), Rt(this.state32), this.posOut = 0, this.pos = 0;
3280
3351
  }
3281
3352
  update(e) {
3282
- Te(this), U(e);
3353
+ Te(this), F(e);
3283
3354
  const { blockLen: s, state: t } = this, n = e.length;
3284
3355
  for (let o = 0; o < n; ) {
3285
3356
  const i = Math.min(s - this.pos, n - o);
@@ -3297,7 +3368,7 @@ class ft {
3297
3368
  e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
3298
3369
  }
3299
3370
  writeInto(e) {
3300
- Te(this, !1), U(e), this.finish();
3371
+ Te(this, !1), F(e), this.finish();
3301
3372
  const s = this.state, { blockLen: t } = this;
3302
3373
  for (let n = 0, o = e.length; n < o; ) {
3303
3374
  this.posOut >= t && this.keccak();
@@ -3312,10 +3383,10 @@ class ft {
3312
3383
  return this.writeInto(e);
3313
3384
  }
3314
3385
  xof(e) {
3315
- return le(e), this.xofInto(new Uint8Array(e));
3386
+ return ue(e), this.xofInto(new Uint8Array(e));
3316
3387
  }
3317
3388
  digestInto(e) {
3318
- if (Vt(e, this), this.finished)
3389
+ if (zt(e, this), this.finished)
3319
3390
  throw new Error("digest() was already called");
3320
3391
  return this.writeInto(e), this.destroy(), e;
3321
3392
  }
@@ -3323,36 +3394,36 @@ class ft {
3323
3394
  return this.digestInto(new Uint8Array(this.outputLen));
3324
3395
  }
3325
3396
  destroy() {
3326
- this.destroyed = !0, Ae(this.state);
3397
+ this.destroyed = !0, Ie(this.state);
3327
3398
  }
3328
3399
  _cloneInto(e) {
3329
3400
  const { blockLen: s, suffix: t, outputLen: n, rounds: o, enableXOF: i } = this;
3330
- return e || (e = new ft(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;
3401
+ return e || (e = new gt(s, t, n, i, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = t, e.outputLen = n, e.enableXOF = i, e.destroyed = this.destroyed, e;
3331
3402
  }
3332
3403
  }
3333
- const Zr = (r, e, s, t = {}) => zt(() => new ft(e, r, s), t), Ut = /* @__PURE__ */ Zr(1, 136, 32);
3334
- class Xr {
3404
+ const en = (r, e, s, t = {}) => Zt(() => new gt(e, r, s), t), Gt = /* @__PURE__ */ en(1, 136, 32);
3405
+ class tn {
3335
3406
  async verifyJWT(e, s) {
3336
3407
  try {
3337
3408
  const t = this.decodeJWT(e);
3338
- f.log("[CROSSx] JWT 디코딩 성공:", {
3409
+ g.log("[CROSSx] JWT 디코딩 성공:", {
3339
3410
  sub: t.sub,
3340
3411
  exp: t.exp,
3341
3412
  iat: t.iat,
3342
3413
  "현재 시간": Math.floor(Date.now() / 1e3)
3343
3414
  });
3344
3415
  const n = Math.floor(Date.now() / 1e3);
3345
- return t.exp && t.exp < n ? (f.warn("[CROSSx] 토큰 만료:", {
3416
+ return t.exp && t.exp < n ? (g.warn("[CROSSx] 토큰 만료:", {
3346
3417
  exp: t.exp,
3347
3418
  now: n,
3348
3419
  만료시간: new Date(t.exp * 1e3).toISOString()
3349
- }), { payload: t, valid: !1, signatureVerified: !1 }) : t.sub ? (f.log("[CROSSx] JWT 검증 성공 (서명 미검증 — JWKS 미구현)"), { payload: t, valid: !0, signatureVerified: !1 }) : (f.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 });
3420
+ }), { payload: t, valid: !1, signatureVerified: !1 }) : t.sub ? (g.log("[CROSSx] JWT 검증 성공 (서명 미검증 — JWKS 미구현)"), { payload: t, valid: !0, signatureVerified: !1 }) : (g.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 });
3350
3421
  } catch (t) {
3351
- throw f.error("[CROSSx] JWT 검증 중 에러:", t), t;
3422
+ throw g.error("[CROSSx] JWT 검증 중 에러:", t), t;
3352
3423
  }
3353
3424
  }
3354
3425
  decodeJWT(e) {
3355
- return Ts(e);
3426
+ return As(e);
3356
3427
  }
3357
3428
  /**
3358
3429
  * EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
@@ -3367,33 +3438,33 @@ class Xr {
3367
3438
  ${t.length}`
3368
3439
  ), o = new Uint8Array(n.length + t.length);
3369
3440
  o.set(n, 0), o.set(t, n.length);
3370
- const i = Ut(o), a = s.startsWith("0x") ? s.slice(2) : s;
3441
+ const i = Gt(o), a = s.startsWith("0x") ? s.slice(2) : s;
3371
3442
  if (a.length !== 130)
3372
3443
  throw new Error(`Invalid signature length: expected 130 hex chars, got ${a.length}`);
3373
- const c = Jr(a), l = c.slice(0, 32), d = c.slice(32, 64), g = c[64], w = g >= 27 ? g - 27 : g, A = new Hr.Signature(
3374
- Ht(l),
3375
- Ht(d)
3376
- ).addRecoveryBit(w).recoverPublicKey(i).toBytes(!1).slice(1), E = Ut(A);
3377
- return "0x" + Ce(E.slice(12));
3444
+ const c = sn(a), l = c.slice(0, 32), d = c.slice(32, 64), f = c[64], w = f >= 27 ? f - 27 : f, T = new jr.Signature(
3445
+ qt(l),
3446
+ qt(d)
3447
+ ).addRecoveryBit(w).recoverPublicKey(i).toBytes(!1).slice(1), b = Gt(T);
3448
+ return "0x" + ke(b.slice(12));
3378
3449
  }
3379
3450
  }
3380
- function Jr(r) {
3451
+ function sn(r) {
3381
3452
  const e = new Uint8Array(r.length / 2);
3382
3453
  for (let s = 0; s < e.length; s++)
3383
3454
  e[s] = parseInt(r.substring(s * 2, s * 2 + 2), 16);
3384
3455
  return e;
3385
3456
  }
3386
- function Ht(r) {
3457
+ function qt(r) {
3387
3458
  let e = "0x";
3388
3459
  for (const s of r) e += s.toString(16).padStart(2, "0");
3389
3460
  return BigInt(e);
3390
3461
  }
3391
- const Qr = 3e4;
3392
- class en {
3462
+ const rn = 3e4;
3463
+ class nn {
3393
3464
  async request(e) {
3394
3465
  const s = new AbortController(), t = setTimeout(
3395
3466
  () => s.abort(),
3396
- e.timeoutMs ?? Qr
3467
+ e.timeoutMs ?? rn
3397
3468
  );
3398
3469
  try {
3399
3470
  const n = await fetch(e.url, {
@@ -3420,71 +3491,71 @@ class en {
3420
3491
  }
3421
3492
  }
3422
3493
  }
3423
- class gt {
3494
+ class pt {
3424
3495
  static generateState() {
3425
3496
  const e = new Uint8Array(16);
3426
3497
  return crypto.getRandomValues(e), Array.from(e, (s) => s.toString(16).padStart(2, "0")).join("");
3427
3498
  }
3428
3499
  openAuth(e) {
3429
3500
  return new Promise((s, t) => {
3430
- const n = e.width ?? 500, o = e.height ?? 600, i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = gt.generateState(), l = e.authUrl.includes("?") ? "&" : "?", d = `${e.authUrl}${l}state=${c}`, g = window.open(
3501
+ const n = e.width ?? 500, o = e.height ?? 600, i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = pt.generateState(), l = e.authUrl.includes("?") ? "&" : "?", d = `${e.authUrl}${l}state=${c}`, f = window.open(
3431
3502
  d,
3432
3503
  "CROSSx OAuth",
3433
3504
  `width=${n},height=${o},left=${i},top=${a}`
3434
3505
  );
3435
- if (!g) {
3506
+ if (!f) {
3436
3507
  t(new Error("팝업 창을 열 수 없습니다. 팝업 차단을 해제해 주세요."));
3437
3508
  return;
3438
3509
  }
3439
3510
  const w = setTimeout(() => {
3440
- f.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), $(), t(new Error("Authentication timeout"));
3441
- }, 5 * 60 * 1e3), m = 10, x = 30;
3442
- let A = 0, E = null;
3443
- const C = () => {
3444
- clearInterval(q), f.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + x + "초간 대기합니다"), E = setTimeout(() => {
3445
- $(), t(new Error(
3511
+ g.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), M(), t(new Error("Authentication timeout"));
3512
+ }, 5 * 60 * 1e3), m = 10, _ = 30;
3513
+ let T = 0, b = null;
3514
+ const A = () => {
3515
+ clearInterval(q), g.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + _ + "초간 대기합니다"), b = setTimeout(() => {
3516
+ M(), t(new Error(
3446
3517
  "OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
3447
3518
  ));
3448
- }, x * 1e3);
3519
+ }, _ * 1e3);
3449
3520
  }, q = setInterval(() => {
3450
- A++;
3521
+ T++;
3451
3522
  try {
3452
- g.closed && (A <= m ? C() : ($(), t(new Error("로그인이 취소되었습니다"))));
3523
+ f.closed && (T <= m ? A() : (M(), t(new Error("로그인이 취소되었습니다"))));
3453
3524
  } catch {
3454
- C();
3525
+ A();
3455
3526
  }
3456
- }, 1e3), $ = () => {
3457
- clearTimeout(w), clearInterval(q), E && clearTimeout(E), window.removeEventListener("message", B);
3458
- }, B = (F) => {
3459
- var be, he, Y, _e, ne, L, k;
3460
- if (F.origin !== e.expectedOrigin) return;
3461
- $(), f.log("[CROSSx] OAuth postMessage 수신 — status:", F.data.status);
3462
- const se = F.data.state ?? ((be = F.data.data) == null ? void 0 : be.state);
3463
- if (!se || se !== c) {
3527
+ }, 1e3), M = () => {
3528
+ clearTimeout(w), clearInterval(q), b && clearTimeout(b), window.removeEventListener("message", D);
3529
+ }, D = (B) => {
3530
+ var ve, he, Z, xe, ne, L, P;
3531
+ if (B.origin !== e.expectedOrigin) return;
3532
+ M(), g.log("[CROSSx] OAuth postMessage 수신 — status:", B.data.status);
3533
+ const Q = B.data.state ?? ((ve = B.data.data) == null ? void 0 : ve.state);
3534
+ if (!Q || Q !== c) {
3464
3535
  t(new Error("OAuth state mismatch — possible CSRF attack"));
3465
3536
  return;
3466
3537
  }
3467
- if (F.data.status === "success") {
3468
- const u = ((he = F.data.data) == null ? void 0 : he.accessToken) || ((Y = F.data.data) == null ? void 0 : Y.idToken);
3469
- f.log("[CROSSx] OAuth 토큰 수신:", {
3470
- hasAccessToken: !!((_e = F.data.data) != null && _e.accessToken),
3471
- hasIdToken: !!((ne = F.data.data) != null && ne.idToken)
3472
- }), u ? s(u) : (f.error("[CROSSx] 토큰을 찾을 수 없음:", F.data), t(new Error("Token not found in response")));
3538
+ if (B.data.status === "success") {
3539
+ const u = ((he = B.data.data) == null ? void 0 : he.accessToken) || ((Z = B.data.data) == null ? void 0 : Z.idToken);
3540
+ g.log("[CROSSx] OAuth 토큰 수신:", {
3541
+ hasAccessToken: !!((xe = B.data.data) != null && xe.accessToken),
3542
+ hasIdToken: !!((ne = B.data.data) != null && ne.idToken)
3543
+ }), u ? s(u) : (g.error("[CROSSx] 토큰을 찾을 수 없음:", B.data), t(new Error("Token not found in response")));
3473
3544
  } else
3474
- f.error("[CROSSx] OAuth 실패:", (L = F.data.data) == null ? void 0 : L.error), t(new Error(((k = F.data.data) == null ? void 0 : k.error) || "Authentication failed"));
3545
+ g.error("[CROSSx] OAuth 실패:", (L = B.data.data) == null ? void 0 : L.error), t(new Error(((P = B.data.data) == null ? void 0 : P.error) || "Authentication failed"));
3475
3546
  };
3476
- window.addEventListener("message", B);
3547
+ window.addEventListener("message", D);
3477
3548
  });
3478
3549
  }
3479
3550
  }
3480
- const Be = "crossx_wallet_data";
3481
- class tn {
3551
+ const Oe = "crossx_wallet_data";
3552
+ class on {
3482
3553
  constructor(e) {
3483
3554
  this.storage = e;
3484
3555
  }
3485
3556
  async getOrCreateWallet(e) {
3486
3557
  try {
3487
- const s = await this.storage.get(Be);
3558
+ const s = await this.storage.get(Oe);
3488
3559
  if (s) return s;
3489
3560
  const t = {
3490
3561
  id: e,
@@ -3492,11 +3563,15 @@ class tn {
3492
3563
  derivationPath: "m/44'/60'/0'/0/0",
3493
3564
  createdAt: Date.now()
3494
3565
  };
3495
- return await this.storage.set(Be, t), t;
3566
+ return await this.storage.set(Oe, t), t;
3496
3567
  } catch (s) {
3497
- throw new _(p.WALLET_CREATION_FAILED, "Wallet creation failed", s);
3568
+ throw new x(p.WALLET_CREATION_FAILED, "Wallet creation failed", s);
3498
3569
  }
3499
3570
  }
3571
+ async getAddresses(e) {
3572
+ const s = await this.storage.get(Oe);
3573
+ return s ? [{ address: s.address, index: 0 }] : [];
3574
+ }
3500
3575
  async getAddress(e, s) {
3501
3576
  return {
3502
3577
  address: this.generateMockEvmAddress(),
@@ -3505,41 +3580,41 @@ class tn {
3505
3580
  }
3506
3581
  async prepare(e, s) {
3507
3582
  const t = "mock-" + crypto.randomUUID();
3508
- return f.log(`[Mock] prepare action=${e} → uuid=${t}`), { uuid: t, expiresAt: new Date(Date.now() + 5 * 6e4).toISOString() };
3583
+ return g.log(`[Mock] prepare action=${e} → uuid=${t}`), { uuid: t, expiresAt: new Date(Date.now() + 5 * 6e4).toISOString() };
3509
3584
  }
3510
3585
  async signMessage(e, s, t, n = 0, o, i) {
3511
- return f.log(`[Mock] signMessage chainId=${s} index=${n} uuid=${o} from=${i}: "${t}"`), { chainId: s, signature: this.generateMockSignature(), format: "hex" };
3586
+ return g.log(`[Mock] signMessage chainId=${s} index=${n} uuid=${o} from=${i}: "${t}"`), { chainId: s, signature: this.generateMockSignature(), format: "hex" };
3512
3587
  }
3513
3588
  async signTypedData(e, s, t, n = 0, o, i) {
3514
- return f.log(`[Mock] signTypedData chainId=${s} index=${n} uuid=${o} from=${i}`), { chainId: s, signature: this.generateMockSignature(), format: "hex" };
3589
+ return g.log(`[Mock] signTypedData chainId=${s} index=${n} uuid=${o} from=${i}`), { chainId: s, signature: this.generateMockSignature(), format: "hex" };
3515
3590
  }
3516
3591
  async signTransaction(e, s, t, n = 0, o) {
3517
- f.log(`[Mock] signTransaction chainId=${s} index=${n} uuid=${o}:`, t);
3592
+ g.log(`[Mock] signTransaction chainId=${s} index=${n} uuid=${o}:`, t);
3518
3593
  const i = "0x" + Array(64).fill(0).map(() => Math.floor(Math.random() * 16).toString(16)).join("");
3519
3594
  return { chainId: s, signature: this.generateMockSignature(), txHash: i, format: "hex" };
3520
3595
  }
3521
3596
  async sendTransaction(e, s, t, n) {
3522
- return f.log(`[Mock] sendTransaction chainId=${s} uuid=${n}:`, t), { txHash: "0x" + Array(64).fill(0).map(() => Math.floor(Math.random() * 16).toString(16)).join("") };
3597
+ return g.log(`[Mock] sendTransaction chainId=${s} uuid=${n}:`, t), { txHash: "0x" + Array(64).fill(0).map(() => Math.floor(Math.random() * 16).toString(16)).join("") };
3523
3598
  }
3524
3599
  async recoverWallet(e, s) {
3525
- f.log("[Mock] recoverWallet");
3600
+ g.log("[Mock] recoverWallet");
3526
3601
  const t = {
3527
3602
  id: e,
3528
3603
  address: this.generateMockEvmAddress(),
3529
3604
  derivationPath: "m/44'/60'/0'/0/0",
3530
3605
  createdAt: Date.now()
3531
3606
  };
3532
- return await this.storage.set(Be, t), t;
3607
+ return await this.storage.set(Oe, t), t;
3533
3608
  }
3534
3609
  async migrateWallet(e, s) {
3535
- f.log(`[Mock] migrateWallet pin=${e} sub=${s}`);
3610
+ g.log(`[Mock] migrateWallet pin=${e} sub=${s}`);
3536
3611
  const t = {
3537
3612
  id: s,
3538
3613
  address: this.generateMockEvmAddress(),
3539
3614
  derivationPath: "m/44'/60'/0'/0/0",
3540
3615
  createdAt: Date.now()
3541
3616
  };
3542
- return await this.storage.set(Be, t), t;
3617
+ return await this.storage.set(Oe, t), t;
3543
3618
  }
3544
3619
  generateMockEvmAddress() {
3545
3620
  return "0x" + Array(40).fill(0).map(
@@ -3552,14 +3627,17 @@ class tn {
3552
3627
  ).join("");
3553
3628
  }
3554
3629
  }
3555
- class Ge {
3630
+ class qe {
3556
3631
  constructor(e, s, t, n) {
3557
- this.baseUrl = e.gatewayUrl, this.projectId = e.projectId, this.storage = s, this.transport = t, this.tokenStore = n;
3632
+ this.adapterConfig = e, this.projectId = e.projectId, this.storage = s, this.transport = t, this.tokenStore = n;
3633
+ }
3634
+ get baseUrl() {
3635
+ return this.adapterConfig.gatewayUrl;
3558
3636
  }
3559
3637
  getAuthToken() {
3560
3638
  const e = this.tokenStore.get();
3561
3639
  if (!e)
3562
- throw new _(
3640
+ throw new x(
3563
3641
  p.AUTH_NOT_AUTHENTICATED,
3564
3642
  "No auth token found. Please sign in first."
3565
3643
  );
@@ -3581,33 +3659,33 @@ class Ge {
3581
3659
  })).data;
3582
3660
  if (d && typeof d.code == "number") {
3583
3661
  if (d.code < 0 || d.code >= 400) {
3584
- const g = d.message || d.data || "API request failed";
3585
- f.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
3662
+ const f = d.message || d.data || "API request failed";
3663
+ g.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
3586
3664
  code: d.code,
3587
- message: g,
3665
+ message: f,
3588
3666
  url: o,
3589
3667
  method: e,
3590
3668
  fullResponse: d
3591
3669
  });
3592
- const w = Ge.mapGatewayError(d.code), m = Ge.getGatewayErrorMessage(d.code, g), x = new _(w, m);
3593
- throw x.gatewayCode = d.code, x.gatewayMessage = g, x;
3670
+ const w = qe.mapGatewayError(d.code), m = qe.getGatewayErrorMessage(d.code, f), _ = new x(w, m);
3671
+ throw _.gatewayCode = d.code, _.gatewayMessage = f, _;
3594
3672
  }
3595
- return f.log("[CROSSx] Wallet Gateway API 성공:", { code: d.code, url: o, method: e }), d.data ?? d;
3673
+ return g.log("[CROSSx] Wallet Gateway API 성공:", { code: d.code, url: o, method: e }), d.data ?? d;
3596
3674
  }
3597
3675
  return d;
3598
3676
  } catch (l) {
3599
- if (l instanceof _) throw l;
3677
+ if (l instanceof x) throw l;
3600
3678
  if ((a = l.response) != null && a.data) {
3601
- const d = l.response.data, g = d.message || d.data || "API request failed", w = d.code || "UNKNOWN";
3602
- throw f.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
3679
+ const d = l.response.data, f = d.message || d.data || "API request failed", w = d.code || "UNKNOWN";
3680
+ throw g.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
3603
3681
  code: w,
3604
- message: g,
3682
+ message: f,
3605
3683
  url: o,
3606
3684
  method: e,
3607
3685
  status: (c = l.response) == null ? void 0 : c.status
3608
- }), new _(
3686
+ }), new x(
3609
3687
  p.UNKNOWN_ERROR,
3610
- `Wallet Gateway error (${w}): ${g}`
3688
+ `Wallet Gateway error (${w}): ${f}`
3611
3689
  );
3612
3690
  }
3613
3691
  throw l;
@@ -3615,12 +3693,12 @@ class Ge {
3615
3693
  }
3616
3694
  async getOrCreateWallet(e) {
3617
3695
  var s;
3618
- f.log("[CROSSx][Migration Phase 2] GET /mnemonic/addresses — 기존 지갑 조회");
3696
+ g.log("[CROSSx][Migration Phase 2] GET /mnemonic/addresses — 기존 지갑 조회");
3619
3697
  try {
3620
3698
  const t = await this.request("GET", "/mnemonic/addresses");
3621
3699
  if (t.addresses && t.addresses.length > 0) {
3622
3700
  const { address: n } = t.addresses[0];
3623
- return f.log("[CROSSx][Migration Phase 2] 기존 지갑 발견 — address:", n), {
3701
+ return g.log("[CROSSx][Migration Phase 2] 기존 지갑 발견 — address:", n), {
3624
3702
  id: e,
3625
3703
  address: n,
3626
3704
  derivationPath: "m/44'/60'/0'/0/0",
@@ -3628,12 +3706,12 @@ class Ge {
3628
3706
  };
3629
3707
  }
3630
3708
  } catch {
3631
- f.log("[CROSSx][Migration Phase 2] 기존 지갑 없음, POST /mnemonic/create 진행");
3709
+ g.log("[CROSSx][Migration Phase 2] 기존 지갑 없음, POST /mnemonic/create 진행");
3632
3710
  }
3633
- f.log("[CROSSx][Migration Phase 2] POST /mnemonic/create — ignoreBackup: false");
3711
+ g.log("[CROSSx][Migration Phase 2] POST /mnemonic/create — ignoreBackup: false");
3634
3712
  try {
3635
3713
  const t = { ignoreBackup: !1 }, n = await this.request("POST", "/mnemonic/create", t);
3636
- return f.log("[CROSSx][Migration Phase 2] /mnemonic/create 성공 — address:", n.address), {
3714
+ return g.log("[CROSSx][Migration Phase 2] /mnemonic/create 성공 — address:", n.address), {
3637
3715
  id: e,
3638
3716
  address: n.address,
3639
3717
  derivationPath: "m/44'/60'/0'/0/0",
@@ -3641,7 +3719,7 @@ class Ge {
3641
3719
  };
3642
3720
  } catch (t) {
3643
3721
  if ((t == null ? void 0 : t.gatewayCode) === -10004 || (s = t == null ? void 0 : t.message) != null && s.includes("-10004")) {
3644
- f.log("[CROSSx][Migration Phase 2] 지갑 이미 존재 (-10004), 주소 재조회");
3722
+ g.log("[CROSSx][Migration Phase 2] 지갑 이미 존재 (-10004), 주소 재조회");
3645
3723
  const n = await this.request("GET", "/mnemonic/addresses");
3646
3724
  if (n.addresses && n.addresses.length > 0)
3647
3725
  return {
@@ -3651,9 +3729,12 @@ class Ge {
3651
3729
  createdAt: Date.now()
3652
3730
  };
3653
3731
  }
3654
- throw (t == null ? void 0 : t.gatewayCode) === -10012 && f.log("[CROSSx][Migration Phase 2] Gateway -10012 수신 → MIGRATION_BACKUP_EXISTS throw"), t;
3732
+ throw (t == null ? void 0 : t.gatewayCode) === -10012 && g.log("[CROSSx][Migration Phase 2] Gateway -10012 수신 → MIGRATION_BACKUP_EXISTS throw"), t;
3655
3733
  }
3656
3734
  }
3735
+ async getAddresses(e) {
3736
+ return ((await this.request("GET", "/mnemonic/addresses")).addresses ?? []).map((t) => ({ address: t.address, index: t.index }));
3737
+ }
3657
3738
  async getAddress(e, s) {
3658
3739
  try {
3659
3740
  return { address: (await this.request(
@@ -3661,8 +3742,8 @@ class Ge {
3661
3742
  `/mnemonic/address?index=${s}`
3662
3743
  )).address, derivationPath: `m/44'/60'/0'/0/${s}` };
3663
3744
  } catch (t) {
3664
- if (t instanceof _ && this.isAddressNotFoundError(t))
3665
- return f.log(`[CROSSx] index ${s} 주소 없음, 파생 중...`), { address: (await this.request(
3745
+ if (t instanceof x && this.isAddressNotFoundError(t))
3746
+ return g.log(`[CROSSx] index ${s} 주소 없음, 파생 중...`), { address: (await this.request(
3666
3747
  "GET",
3667
3748
  `/mnemonic/address?index=${s}&derive=true`
3668
3749
  )).address, derivationPath: `m/44'/60'/0'/0/${s}` };
@@ -3678,15 +3759,15 @@ class Ge {
3678
3759
  switch (e) {
3679
3760
  case "sign":
3680
3761
  case "send":
3681
- if (!s.tx) throw new _(p.TX_INVALID_PARAMS, "prepare: tx is required");
3762
+ if (!s.tx) throw new x(p.TX_INVALID_PARAMS, "prepare: tx is required");
3682
3763
  t = { unsignedTx: this.buildUnsignedTx(s.tx) };
3683
3764
  break;
3684
3765
  case "sign-message":
3685
- if (!s.message) throw new _(p.TX_INVALID_PARAMS, "prepare: message is required");
3766
+ if (!s.message) throw new x(p.TX_INVALID_PARAMS, "prepare: message is required");
3686
3767
  t = { message: s.message }, s.from && (t.from = s.from);
3687
3768
  break;
3688
3769
  case "sign-typed-data":
3689
- if (!s.typedData) throw new _(p.TX_INVALID_PARAMS, "prepare: typedData is required");
3770
+ if (!s.typedData) throw new x(p.TX_INVALID_PARAMS, "prepare: typedData is required");
3690
3771
  t = { typedData: s.typedData }, s.from && (t.from = s.from);
3691
3772
  break;
3692
3773
  }
@@ -3758,13 +3839,13 @@ class Ge {
3758
3839
  };
3759
3840
  }
3760
3841
  async migrateWallet(e, s) {
3761
- f.log("[CROSSx][Migration Phase 4] POST /mnemonic/migrate 호출 — sub:", s);
3842
+ g.log("[CROSSx][Migration Phase 4] POST /mnemonic/migrate 호출 — sub:", s);
3762
3843
  const t = { pin: e, sub: s }, n = await this.request(
3763
3844
  "POST",
3764
3845
  "/mnemonic/migrate",
3765
3846
  t
3766
3847
  );
3767
- return f.log("[CROSSx][Migration Phase 4] /mnemonic/migrate 완료 — address:", n.address), {
3848
+ return g.log("[CROSSx][Migration Phase 4] /mnemonic/migrate 완료 — address:", n.address), {
3768
3849
  id: s,
3769
3850
  address: n.address,
3770
3851
  derivationPath: "m/44'/60'/0'/0/0",
@@ -3828,9 +3909,12 @@ class Ge {
3828
3909
  }
3829
3910
  }
3830
3911
  }
3831
- class Oe {
3912
+ class Ce {
3832
3913
  constructor(e, s) {
3833
- this.cache = /* @__PURE__ */ new Map(), this.loadedAt = 0, this.usingFallback = !1, this.baseUrl = e.gatewayUrl, this.projectId = e.projectId, this.transport = s;
3914
+ this.cache = /* @__PURE__ */ new Map(), this.loadedAt = 0, this.usingFallback = !1, this.adapterConfig = e, this.projectId = e.projectId, this.transport = s;
3915
+ }
3916
+ get baseUrl() {
3917
+ return this.adapterConfig.gatewayUrl;
3834
3918
  }
3835
3919
  async getChains() {
3836
3920
  if (this.isCacheValid())
@@ -3843,7 +3927,7 @@ class Oe {
3843
3927
  const s = e.data.chains;
3844
3928
  return this.populateCache(s, !1), s;
3845
3929
  } catch {
3846
- const e = Oe.fallbackChains();
3930
+ const e = Ce.fallbackChains();
3847
3931
  return this.populateCache(e, !0), e;
3848
3932
  }
3849
3933
  }
@@ -3857,7 +3941,7 @@ class Oe {
3857
3941
  }
3858
3942
  isCacheValid() {
3859
3943
  if (this.loadedAt === 0) return !1;
3860
- const e = this.usingFallback ? Gs : Hs;
3944
+ const e = this.usingFallback ? Vs : js;
3861
3945
  return e === 0 ? !0 : Date.now() - this.loadedAt < e;
3862
3946
  }
3863
3947
  populateCache(e, s) {
@@ -3878,24 +3962,24 @@ class Oe {
3878
3962
  handleEnvelopeError(e) {
3879
3963
  if (e.code < 0) {
3880
3964
  const s = typeof e.data == "string" ? e.data : e.message ?? "Chain registry request failed";
3881
- throw new _(
3882
- Oe.mapErrorCode(e.code),
3965
+ throw new x(
3966
+ Ce.mapErrorCode(e.code),
3883
3967
  s
3884
3968
  );
3885
3969
  }
3886
3970
  }
3887
3971
  fallbackOrThrow(e) {
3888
- const s = Oe.fallbackChains().find(
3972
+ const s = Ce.fallbackChains().find(
3889
3973
  (t) => t.chainId === e
3890
3974
  );
3891
3975
  if (s) return s;
3892
- throw new _(
3976
+ throw new x(
3893
3977
  p.CHAIN_NOT_SUPPORTED,
3894
3978
  `Unsupported chain: ${e}`
3895
3979
  );
3896
3980
  }
3897
3981
  static fallbackChains() {
3898
- return Object.values(qe).map((e) => ({
3982
+ return Object.values(We).map((e) => ({
3899
3983
  chainId: e.caipId,
3900
3984
  rpcUrl: e.rpcUrl
3901
3985
  }));
@@ -3919,7 +4003,7 @@ class Oe {
3919
4003
  }
3920
4004
  }
3921
4005
  }
3922
- const Gt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", sn = {
4006
+ const Wt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", an = {
3923
4007
  light: {
3924
4008
  bg: "#FFFFFF",
3925
4009
  border: "rgba(18,18,18,0.05)",
@@ -3965,8 +4049,8 @@ const Gt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", sn = {
3965
4049
  onPrimary: "#FFFFFF"
3966
4050
  }
3967
4051
  };
3968
- function qt(r, e) {
3969
- const s = sn[r], t = e == null ? void 0 : e[r];
4052
+ function jt(r, e) {
4053
+ const s = an[r], t = e == null ? void 0 : e[r];
3970
4054
  return t ? {
3971
4055
  ...s,
3972
4056
  // ── Brand
@@ -3995,7 +4079,7 @@ function qt(r, e) {
3995
4079
  ...t.bg !== void 0 && { bg: t.bg, inputBg: t.bg }
3996
4080
  } : s;
3997
4081
  }
3998
- const rn = `
4082
+ const cn = `
3999
4083
  @import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
4000
4084
 
4001
4085
  #${te} {
@@ -4630,6 +4714,85 @@ const rn = `
4630
4714
  filter: none;
4631
4715
  }
4632
4716
 
4717
+ /* ── Wallet Selector Modal ─────────────────────────────────── */
4718
+ .__crossx-wallet-list {
4719
+ display: flex;
4720
+ flex-direction: column;
4721
+ gap: 8px;
4722
+ max-height: 320px;
4723
+ overflow-y: auto;
4724
+ -webkit-overflow-scrolling: touch;
4725
+ scrollbar-width: thin;
4726
+ }
4727
+ .__crossx-wallet-list::-webkit-scrollbar {
4728
+ width: 4px;
4729
+ }
4730
+ .__crossx-wallet-list::-webkit-scrollbar-thumb {
4731
+ background: var(--cx-divider);
4732
+ border-radius: 2px;
4733
+ }
4734
+ .__crossx-wallet-item {
4735
+ display: flex;
4736
+ align-items: center;
4737
+ gap: 8px;
4738
+ padding: 16px;
4739
+ background: var(--cx-pill-bg);
4740
+ border: 1px solid var(--cx-border);
4741
+ border-radius: 8px;
4742
+ cursor: pointer;
4743
+ appearance: none;
4744
+ -webkit-appearance: none;
4745
+ -webkit-tap-highlight-color: transparent;
4746
+ box-shadow: none;
4747
+ outline: none;
4748
+ width: 100%;
4749
+ transition: opacity 0.12s;
4750
+ font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
4751
+ }
4752
+ .__crossx-wallet-item:hover { opacity: 0.8; }
4753
+ .__crossx-wallet-item:focus { outline: none; box-shadow: none; }
4754
+ .__crossx-wallet-addr {
4755
+ font-size: 16px;
4756
+ font-weight: 600;
4757
+ line-height: 1.3;
4758
+ color: var(--cx-value);
4759
+ white-space: nowrap;
4760
+ }
4761
+ .__crossx-wallet-add {
4762
+ display: flex;
4763
+ align-items: center;
4764
+ justify-content: center;
4765
+ gap: 8px;
4766
+ padding: 16px;
4767
+ border: 1px dashed var(--cx-divider);
4768
+ border-radius: 8px;
4769
+ cursor: pointer;
4770
+ appearance: none;
4771
+ -webkit-appearance: none;
4772
+ -webkit-tap-highlight-color: transparent;
4773
+ box-shadow: none;
4774
+ outline: none;
4775
+ background: none;
4776
+ width: 100%;
4777
+ transition: opacity 0.12s;
4778
+ flex-shrink: 0;
4779
+ font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
4780
+ }
4781
+ .__crossx-wallet-add:hover { opacity: 0.8; }
4782
+ .__crossx-wallet-add:focus { outline: none; box-shadow: none; }
4783
+ .__crossx-wallet-add:disabled { opacity: 0.5; cursor: not-allowed; }
4784
+ .__crossx-wallet-add-icon {
4785
+ width: 24px;
4786
+ height: 24px;
4787
+ color: var(--cx-subtitle);
4788
+ }
4789
+ .__crossx-wallet-add-label {
4790
+ font-size: 16px;
4791
+ font-weight: 600;
4792
+ line-height: 1.3;
4793
+ color: var(--cx-subtitle);
4794
+ }
4795
+
4633
4796
  /* ── Mobile bottom sheet ───────────────────────────────────── */
4634
4797
  @media (max-width: 480px) {
4635
4798
  #${te} { align-items: flex-end; }
@@ -4667,6 +4830,11 @@ const rn = `
4667
4830
  gap: 16px;
4668
4831
  }
4669
4832
  .__crossx-divider--cols { flex-shrink: 0; }
4833
+ .__crossx-col-right-ws {
4834
+ display: flex;
4835
+ flex-direction: column;
4836
+ gap: 8px;
4837
+ }
4670
4838
 
4671
4839
  /* ── Landscape for signing/transaction modals ──────────── */
4672
4840
  @media (orientation: landscape) and (max-height: 500px) {
@@ -4674,7 +4842,8 @@ const rn = `
4674
4842
  .__crossx-card--send-tx,
4675
4843
  .__crossx-card--sign-tx,
4676
4844
  .__crossx-card--sign-msg,
4677
- .__crossx-card--sign-typed {
4845
+ .__crossx-card--sign-typed,
4846
+ .__crossx-card--wallet-selector {
4678
4847
  width: 600px;
4679
4848
  max-width: calc(100vw - 32px);
4680
4849
  border-radius: 24px;
@@ -4686,20 +4855,23 @@ const rn = `
4686
4855
  .__crossx-card--send-tx .__crossx-header,
4687
4856
  .__crossx-card--sign-tx .__crossx-header,
4688
4857
  .__crossx-card--sign-msg .__crossx-header,
4689
- .__crossx-card--sign-typed .__crossx-header {
4858
+ .__crossx-card--sign-typed .__crossx-header,
4859
+ .__crossx-card--wallet-selector .__crossx-header {
4690
4860
  padding: 16px 24px 12px;
4691
4861
  }
4692
4862
  .__crossx-card--send-tx .__crossx-body,
4693
4863
  .__crossx-card--sign-tx .__crossx-body,
4694
4864
  .__crossx-card--sign-msg .__crossx-body,
4695
- .__crossx-card--sign-typed .__crossx-body {
4865
+ .__crossx-card--sign-typed .__crossx-body,
4866
+ .__crossx-card--wallet-selector .__crossx-body {
4696
4867
  padding: 16px 24px 20px;
4697
4868
  gap: 12px;
4698
4869
  }
4699
4870
  .__crossx-card--send-tx .__crossx-body-cols,
4700
4871
  .__crossx-card--sign-tx .__crossx-body-cols,
4701
4872
  .__crossx-card--sign-msg .__crossx-body-cols,
4702
- .__crossx-card--sign-typed .__crossx-body-cols {
4873
+ .__crossx-card--sign-typed .__crossx-body-cols,
4874
+ .__crossx-card--wallet-selector .__crossx-body-cols {
4703
4875
  flex-direction: row;
4704
4876
  gap: 24px;
4705
4877
  align-items: flex-start;
@@ -4716,27 +4888,33 @@ const rn = `
4716
4888
  .__crossx-card--sign-msg .__crossx-msg-box { max-height: 130px; }
4717
4889
  .__crossx-card--sign-typed .__crossx-td-rows { max-height: 130px; overflow-y: auto; }
4718
4890
  .__crossx-col-left > .__crossx-divider { display: none; }
4891
+ .__crossx-col-right-ws {
4892
+ display: flex;
4893
+ flex-direction: column;
4894
+ gap: 8px;
4895
+ }
4896
+ .__crossx-card--wallet-selector .__crossx-wallet-list { max-height: 140px; }
4719
4897
  }
4720
4898
  `;
4721
- function Se() {
4722
- let r = document.getElementById(Gt);
4723
- r || (r = document.createElement("style"), r.id = Gt, document.head.appendChild(r)), r.textContent = rn;
4899
+ function me() {
4900
+ let r = document.getElementById(Wt);
4901
+ r || (r = document.createElement("style"), r.id = Wt, document.head.appendChild(r)), r.textContent = cn;
4724
4902
  }
4725
- function Q(r) {
4903
+ function Y(r) {
4726
4904
  return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
4727
4905
  }
4728
- function nn(r, e = "CROSS", s = 18) {
4906
+ function ln(r, e = "CROSS", s = 18) {
4729
4907
  if (!r || r === "0x" || r === "0x0") return null;
4730
4908
  try {
4731
4909
  const t = BigInt(r);
4732
4910
  if (t === 0n) return null;
4733
- const n = ot(t, s);
4911
+ const n = it(t, s);
4734
4912
  return n === "0" ? null : `${n} ${e}`;
4735
4913
  } catch {
4736
4914
  return null;
4737
4915
  }
4738
4916
  }
4739
- const Wt = {
4917
+ const Vt = {
4740
4918
  1: "Ethereum Mainnet",
4741
4919
  5: "Goerli Testnet",
4742
4920
  11155111: "Ethereum Sepolia",
@@ -4759,16 +4937,16 @@ const Wt = {
4759
4937
  612044: "CROSS Testnet",
4760
4938
  612055: "CROSS Mainnet"
4761
4939
  };
4762
- function bs(r) {
4940
+ function Ss(r) {
4763
4941
  const e = parseInt(r.split(":")[1] ?? "", 10);
4764
- return !isNaN(e) && Wt[e] ? Wt[e] : r;
4942
+ return !isNaN(e) && Vt[e] ? Vt[e] : r;
4765
4943
  }
4766
- function ot(r, e) {
4944
+ function it(r, e) {
4767
4945
  if (r === 0n) return "0";
4768
4946
  const s = 10n ** BigInt(e), t = r / s, i = (r % s).toString().padStart(e, "0").slice(0, 6).replace(/0+$/, "");
4769
4947
  return i ? `${t}.${i}` : `${t}`;
4770
4948
  }
4771
- function et(r) {
4949
+ function tt(r) {
4772
4950
  try {
4773
4951
  const e = BigInt(r), s = e / 1000000000n, n = (e % 1000000000n).toString().padStart(9, "0").slice(0, 2).replace(/0+$/, "");
4774
4952
  return n ? `${s}.${n}` : `${s}`;
@@ -4776,25 +4954,25 @@ function et(r) {
4776
4954
  return r;
4777
4955
  }
4778
4956
  }
4779
- function on(r) {
4957
+ function dn(r) {
4780
4958
  try {
4781
4959
  return BigInt(r).toLocaleString();
4782
4960
  } catch {
4783
4961
  return r;
4784
4962
  }
4785
4963
  }
4786
- function an(r) {
4964
+ function un(r) {
4787
4965
  const { gasLimit: e, gasPrice: s, maxFeePerGas: t, maxPriorityFeePerGas: n, nativeSymbol: o = "ETH", nativeDecimals: i = 18 } = r;
4788
4966
  if (!e) return null;
4789
4967
  try {
4790
- const a = BigInt(e), c = on(e);
4968
+ const a = BigInt(e), c = dn(e);
4791
4969
  if (t) {
4792
4970
  const l = a * BigInt(t);
4793
4971
  return {
4794
4972
  isDynamic: !0,
4795
- estTxFee: `${ot(l, i)} ${o}`,
4796
- maxFeeGwei: et(t),
4797
- maxPriorityFeeGwei: n ? et(n) : void 0,
4973
+ estTxFee: `${it(l, i)} ${o}`,
4974
+ maxFeeGwei: tt(t),
4975
+ maxPriorityFeeGwei: n ? tt(n) : void 0,
4798
4976
  gasLimitFormatted: c
4799
4977
  };
4800
4978
  }
@@ -4802,8 +4980,8 @@ function an(r) {
4802
4980
  const l = a * BigInt(s);
4803
4981
  return {
4804
4982
  isDynamic: !1,
4805
- estTxFee: `${ot(l, i)} ${o}`,
4806
- gasPriceGwei: et(s),
4983
+ estTxFee: `${it(l, i)} ${o}`,
4984
+ gasPriceGwei: tt(s),
4807
4985
  gasLimitFormatted: c
4808
4986
  };
4809
4987
  }
@@ -4812,37 +4990,37 @@ function an(r) {
4812
4990
  return null;
4813
4991
  }
4814
4992
  }
4815
- function vs(r) {
4816
- const e = an(r);
4993
+ function Es(r) {
4994
+ const e = un(r);
4817
4995
  if (!e) return G("Estimated fee", "<span>—</span>");
4818
4996
  let s = G("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
4819
4997
  return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s += G("Max Priority Fee", `<span>${e.maxPriorityFeeGwei} Gwei</span>`)), e.maxFeeGwei !== void 0 && (s += G("Max Gas Fee", `<span>${e.maxFeeGwei} Gwei</span>`))) : e.gasPriceGwei !== void 0 && (s += G("Gas Price", `<span>${e.gasPriceGwei} Gwei</span>`)), e.gasLimitFormatted && (s += G("Gas Limit", `<span>${e.gasLimitFormatted}</span>`)), s;
4820
4998
  }
4821
- const ce = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
4999
+ const de = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
4822
5000
  <rect x="9" y="9" width="13" height="13" rx="2"/>
4823
5001
  <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
4824
- </svg>`, de = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
5002
+ </svg>`, ie = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
4825
5003
  <line x1="18" y1="6" x2="6" y2="18"/>
4826
5004
  <line x1="6" y1="6" x2="18" y2="18"/>
4827
5005
  </svg>`;
4828
- function cn(r) {
5006
+ function hn(r) {
4829
5007
  return `<svg width="28" height="28" viewBox="0 0 28 28" fill="none">
4830
5008
  <circle cx="14" cy="14" r="14" fill="${r}"/>
4831
5009
  <path d="M14 7.5L19.2 10.5V16.5L14 19.5L8.8 16.5V10.5L14 7.5Z" fill="white" opacity="0.9"/>
4832
5010
  </svg>`;
4833
5011
  }
4834
- const pt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
5012
+ const _t = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
4835
5013
  <rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
4836
5014
  <path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
4837
5015
  <rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
4838
- </svg>`, ln = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
5016
+ </svg>`, fn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
4839
5017
  <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-secondary)"/>
4840
- </svg>`, dn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
5018
+ </svg>`, gn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
4841
5019
  <circle cx="12" cy="12" r="12" fill="var(--cx-secondary)"/>
4842
5020
  <circle cx="12" cy="12" r="5.5" stroke="white" stroke-width="1.5"/>
4843
5021
  <path d="M12 9.5v3l2 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
4844
5022
  </svg>`;
4845
- function ue(r) {
5023
+ function ae(r) {
4846
5024
  return [
4847
5025
  `--cx-bg:${r.bg}`,
4848
5026
  `--cx-border:${r.border}`,
@@ -4873,35 +5051,35 @@ function G(r, e) {
4873
5051
  <div class="__crossx-row-value">${e}</div>
4874
5052
  </div>`;
4875
5053
  }
4876
- function un(r, e) {
4877
- const s = e, t = Ve(), n = r.to ? `<span class="__crossx-addr-text">${Q(r.to)}</span>
4878
- <button class="__crossx-copy-btn" data-copy="${D(r.to)}" title="Copy address">${ce}</button>` : "<span>—</span>", o = vs(r), i = r.data && r.data !== "0x" ? r.data : "0x", a = document.createElement("div");
5054
+ function pn(r, e) {
5055
+ const s = e, t = Ke(), n = r.to ? `<span class="__crossx-addr-text">${Y(r.to)}</span>
5056
+ <button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", o = Es(r), i = r.data && r.data !== "0x" ? r.data : "0x", a = document.createElement("div");
4879
5057
  return a.id = te, a.innerHTML = `
4880
- <div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ue(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5058
+ <div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
4881
5059
  <div class="__crossx-header">
4882
5060
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
4883
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5061
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
4884
5062
  </div>
4885
5063
  <hr class="__crossx-divider">
4886
5064
  <div class="__crossx-body">
4887
5065
  <div class="__crossx-body-cols">
4888
5066
  <div class="__crossx-col-left">
4889
5067
  <p class="__crossx-sig-subtitle">
4890
- <span class="__crossx-sig-origin">${D(t)} </span>is requesting a Signature
5068
+ <span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
4891
5069
  </p>
4892
5070
  <div class="__crossx-addr-pill">
4893
- ${pt}
4894
- <span class="__crossx-addr-pill-text">${Q(r.from)}</span>
5071
+ ${_t}
5072
+ <span class="__crossx-addr-pill-text">${Y(r.from)}</span>
4895
5073
  </div>
4896
5074
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
4897
5075
  <hr class="__crossx-divider">
4898
5076
  <div class="__crossx-rows">
4899
5077
  ${G("To", n)}
4900
- ${G("Network", `<span>${bs(r.chainId)}</span>`)}
5078
+ ${G("Network", `<span>${Ss(r.chainId)}</span>`)}
4901
5079
  ${o}
4902
5080
  </div>
4903
5081
  </div>
4904
- <pre class="__crossx-raw-tx">${D(i)}</pre>
5082
+ <pre class="__crossx-raw-tx">${$(i)}</pre>
4905
5083
  </div>
4906
5084
  <div class="__crossx-btn-row">
4907
5085
  <button class="__crossx-cancel-btn" id="__crossx-cancel-btn">Cancel</button>
@@ -4911,28 +5089,28 @@ function un(r, e) {
4911
5089
  </div>
4912
5090
  `, a;
4913
5091
  }
4914
- function hn(r, e) {
4915
- const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Ve(), i = r.to ? `<span class="__crossx-addr-text">${Q(r.to)}</span>
4916
- <button class="__crossx-copy-btn" data-copy="${D(r.to)}" title="Copy address">${ce}</button>` : "<span>—</span>", a = vs(r), l = nn(r.value, t, n) ?? "—", d = document.createElement("div");
5092
+ function _n(r, e) {
5093
+ const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Ke(), i = r.to ? `<span class="__crossx-addr-text">${Y(r.to)}</span>
5094
+ <button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", a = Es(r), l = ln(r.value, t, n) ?? "—", d = document.createElement("div");
4917
5095
  return d.id = te, d.innerHTML = `
4918
- <div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ue(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5096
+ <div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
4919
5097
  <div class="__crossx-header">
4920
5098
  <p class="__crossx-title" id="__crossx-ttl">Approve transaction</p>
4921
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5099
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
4922
5100
  </div>
4923
5101
  <hr class="__crossx-divider">
4924
5102
  <div class="__crossx-body">
4925
5103
  <p class="__crossx-tx-subtitle">
4926
- <span class="__crossx-sig-origin">${D(o)}</span> wants your permission to approve the following transaction.
5104
+ <span class="__crossx-sig-origin">${$(o)}</span> wants your permission to approve the following transaction.
4927
5105
  </p>
4928
5106
  <div class="__crossx-body-cols">
4929
5107
  <div class="__crossx-rows">
4930
5108
  ${G("To", i)}
4931
- ${G("Network", `<span>${bs(r.chainId)}</span>`)}
5109
+ ${G("Network", `<span>${Ss(r.chainId)}</span>`)}
4932
5110
  ${a}
4933
5111
  </div>
4934
5112
  <div class="__crossx-pill">
4935
- <span class="__crossx-pill-from">${Q(r.from)}</span>
5113
+ <span class="__crossx-pill-from">${Y(r.from)}</span>
4936
5114
  <span class="__crossx-pill-amount">${l}</span>
4937
5115
  </div>
4938
5116
  </div>
@@ -4941,7 +5119,7 @@ function hn(r, e) {
4941
5119
  </div>
4942
5120
  `, d;
4943
5121
  }
4944
- function Ve() {
5122
+ function Ke() {
4945
5123
  var r;
4946
5124
  try {
4947
5125
  return ((r = window.location) == null ? void 0 : r.hostname) || "This site";
@@ -4949,37 +5127,37 @@ function Ve() {
4949
5127
  return "This site";
4950
5128
  }
4951
5129
  }
4952
- function D(r) {
5130
+ function $(r) {
4953
5131
  return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
4954
5132
  }
4955
- function fn(r) {
5133
+ function xn(r) {
4956
5134
  return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
4957
5135
  }
4958
- function gn(r) {
4959
- if (typeof r == "string") return D(r);
5136
+ function mn(r) {
5137
+ if (typeof r == "string") return $(r);
4960
5138
  if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
4961
5139
  try {
4962
- return D(JSON.stringify(r));
5140
+ return $(JSON.stringify(r));
4963
5141
  } catch {
4964
5142
  return String(r);
4965
5143
  }
4966
5144
  }
4967
- function pn(r, e) {
5145
+ function wn(r, e) {
4968
5146
  const s = G(
4969
5147
  "From",
4970
- `<span class="__crossx-addr-text">${Q(r.from)}</span>
4971
- <button class="__crossx-copy-btn" data-copy="${D(r.from)}" title="Copy address">${ce}</button>`
4972
- ), t = r.to ? G("To", `<span class="__crossx-addr-text">${Q(r.to)}</span>
4973
- <button class="__crossx-copy-btn" data-copy="${D(r.to)}" title="Copy address">${ce}</button>`) : "", n = r.amount ? G("Transfer", `<span>${D(r.amount)}</span>`) : "", o = r.fees ? G("Tx Fee", `<span>${D(r.fees)}</span>`) : "", i = r.txHash ? G("Tx Hash", `<span class="__crossx-addr-text">${Q(r.txHash)}</span>
4974
- <button class="__crossx-copy-btn" data-copy="${D(r.txHash)}" title="Copy hash">${ce}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
5148
+ `<span class="__crossx-addr-text">${Y(r.from)}</span>
5149
+ <button class="__crossx-copy-btn" data-copy="${$(r.from)}" title="Copy address">${de}</button>`
5150
+ ), t = r.to ? G("To", `<span class="__crossx-addr-text">${Y(r.to)}</span>
5151
+ <button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${de}</button>`) : "", n = r.amount ? G("Transfer", `<span>${$(r.amount)}</span>`) : "", o = r.fees ? G("Tx Fee", `<span>${$(r.fees)}</span>`) : "", i = r.txHash ? G("Tx Hash", `<span class="__crossx-addr-text">${Y(r.txHash)}</span>
5152
+ <button class="__crossx-copy-btn" data-copy="${$(r.txHash)}" title="Copy hash">${de}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
4975
5153
  <span class="__crossx-total-label">Total<br>(including fees)</span>
4976
- <span class="__crossx-total-amount">${D(r.total)}</span>
5154
+ <span class="__crossx-total-amount">${$(r.total)}</span>
4977
5155
  </div>` : "", c = document.createElement("div");
4978
5156
  return c.id = te, c.innerHTML = `
4979
- <div class="__crossx-card __crossx-card--migration" style="${ue(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5157
+ <div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
4980
5158
  <div class="__crossx-header">
4981
5159
  <p class="__crossx-title" id="__crossx-ttl">Transaction complete</p>
4982
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5160
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
4983
5161
  </div>
4984
5162
  <hr class="__crossx-divider">
4985
5163
  <div class="__crossx-body">
@@ -4996,10 +5174,10 @@ function pn(r, e) {
4996
5174
  </div>
4997
5175
  `, c;
4998
5176
  }
4999
- function xn(r, e) {
5177
+ function yn(r, e) {
5000
5178
  const s = document.createElement("div");
5001
5179
  return s.id = te, s.innerHTML = `
5002
- <div class="__crossx-card __crossx-card--migration" style="${ue(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5180
+ <div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5003
5181
  <div class="__crossx-header">
5004
5182
  <p class="__crossx-title" id="__crossx-ttl">Waiting for confirmation</p>
5005
5183
  </div>
@@ -5013,63 +5191,63 @@ function xn(r, e) {
5013
5191
  </div>
5014
5192
  `, s;
5015
5193
  }
5016
- function _n(r, e, s) {
5194
+ function bn(r, e, s) {
5017
5195
  const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
5018
5196
  if (o) {
5019
- const x = n ? dn : t ? "" : ln, A = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
5020
- x ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${x}<span>${A}</span>`) : o.textContent = A;
5197
+ const _ = n ? gn : t ? "" : fn, T = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
5198
+ _ ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${_}<span>${T}</span>`) : o.textContent = T;
5021
5199
  }
5022
5200
  if (i && !r.querySelector("#__crossx-close-btn")) {
5023
- const x = document.createElement("button");
5024
- x.className = "__crossx-close", x.id = "__crossx-close-btn", x.setAttribute("aria-label", "Close"), x.innerHTML = de, i.appendChild(x);
5201
+ const _ = document.createElement("button");
5202
+ _.className = "__crossx-close", _.id = "__crossx-close-btn", _.setAttribute("aria-label", "Close"), _.innerHTML = ie, i.appendChild(_);
5025
5203
  }
5026
5204
  const a = r.querySelector("#__crossx-progress-body");
5027
5205
  if (!a) return;
5028
- const c = e.from ? G("From", `<span class="__crossx-addr-text">${Q(e.from)}</span>
5029
- <button class="__crossx-copy-btn" data-copy="${D(e.from)}" title="Copy address">${ce}</button>`) : "", l = e.to ? G("To", `<span class="__crossx-addr-text">${Q(e.to)}</span>
5030
- <button class="__crossx-copy-btn" data-copy="${D(e.to)}" title="Copy address">${ce}</button>`) : "", d = e.amount ? G("Transfer", `<span>${D(e.amount)}</span>`) : "", g = e.fees ? G("Tx Fee", `<span>${D(e.fees)}</span>`) : "", w = e.txHash ? G("Tx Hash", `<span class="__crossx-addr-text">${Q(e.txHash)}</span>
5031
- <button class="__crossx-copy-btn" data-copy="${D(e.txHash)}" title="Copy hash">${ce}</button>`) : "", m = e.total ? `<div class="__crossx-total-pill">
5206
+ const c = e.from ? G("From", `<span class="__crossx-addr-text">${Y(e.from)}</span>
5207
+ <button class="__crossx-copy-btn" data-copy="${$(e.from)}" title="Copy address">${de}</button>`) : "", l = e.to ? G("To", `<span class="__crossx-addr-text">${Y(e.to)}</span>
5208
+ <button class="__crossx-copy-btn" data-copy="${$(e.to)}" title="Copy address">${de}</button>`) : "", d = e.amount ? G("Transfer", `<span>${$(e.amount)}</span>`) : "", f = e.fees ? G("Tx Fee", `<span>${$(e.fees)}</span>`) : "", w = e.txHash ? G("Tx Hash", `<span class="__crossx-addr-text">${Y(e.txHash)}</span>
5209
+ <button class="__crossx-copy-btn" data-copy="${$(e.txHash)}" title="Copy hash">${de}</button>`) : "", m = e.total ? `<div class="__crossx-total-pill">
5032
5210
  <span class="__crossx-total-label">Total<br>(including fees)</span>
5033
- <span class="__crossx-total-amount">${D(e.total)}</span>
5211
+ <span class="__crossx-total-amount">${$(e.total)}</span>
5034
5212
  </div>` : "";
5035
5213
  a.innerHTML = `
5036
5214
  <div class="__crossx-rows">
5037
5215
  ${c}
5038
5216
  ${l}
5039
5217
  ${d}
5040
- ${g}
5218
+ ${f}
5041
5219
  ${w}
5042
5220
  </div>
5043
5221
  ${m}
5044
5222
  <button class="__crossx-approve-btn" id="__crossx-done-btn">${t ? "All Done" : "Done"}</button>
5045
- `, a.querySelectorAll(".__crossx-copy-btn").forEach((x) => {
5046
- x.addEventListener("click", (A) => {
5047
- var C;
5048
- A.stopPropagation();
5049
- const E = x.dataset.copy;
5050
- E && ((C = navigator.clipboard) == null || C.writeText(E).catch(() => {
5223
+ `, a.querySelectorAll(".__crossx-copy-btn").forEach((_) => {
5224
+ _.addEventListener("click", (T) => {
5225
+ var A;
5226
+ T.stopPropagation();
5227
+ const b = _.dataset.copy;
5228
+ b && ((A = navigator.clipboard) == null || A.writeText(b).catch(() => {
5051
5229
  }));
5052
5230
  });
5053
5231
  });
5054
5232
  }
5055
- function mn(r, e) {
5056
- const s = e, t = Ve(), n = D(r.message), o = document.createElement("div");
5233
+ function vn(r, e) {
5234
+ const s = e, t = Ke(), n = $(r.message), o = document.createElement("div");
5057
5235
  return o.id = te, o.innerHTML = `
5058
- <div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ue(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5236
+ <div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5059
5237
  <div class="__crossx-header">
5060
5238
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
5061
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5239
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
5062
5240
  </div>
5063
5241
  <hr class="__crossx-divider">
5064
5242
  <div class="__crossx-body">
5065
5243
  <div class="__crossx-body-cols">
5066
5244
  <div class="__crossx-col-left">
5067
5245
  <p class="__crossx-sig-subtitle">
5068
- <span class="__crossx-sig-origin">${D(t)} </span>is requesting a Signature
5246
+ <span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
5069
5247
  </p>
5070
5248
  <div class="__crossx-addr-pill">
5071
- ${pt}
5072
- <span class="__crossx-addr-pill-text">${Q(r.from)}</span>
5249
+ ${_t}
5250
+ <span class="__crossx-addr-pill-text">${Y(r.from)}</span>
5073
5251
  </div>
5074
5252
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
5075
5253
  </div>
@@ -5084,8 +5262,8 @@ function mn(r, e) {
5084
5262
  </div>
5085
5263
  `, o;
5086
5264
  }
5087
- function wn(r, e) {
5088
- const s = e, t = Ve();
5265
+ function Sn(r, e) {
5266
+ const s = e, t = Ke();
5089
5267
  let n = {};
5090
5268
  if (typeof r.typedData == "string")
5091
5269
  try {
@@ -5097,34 +5275,34 @@ function wn(r, e) {
5097
5275
  let a = `
5098
5276
  <div class="__crossx-td-row">
5099
5277
  <span class="__crossx-td-label">Primary Type</span>
5100
- <span class="__crossx-td-value">${D(o)}</span>
5278
+ <span class="__crossx-td-value">${$(o)}</span>
5101
5279
  </div>`;
5102
5280
  for (const [l, d] of Object.entries(i)) {
5103
- const g = gn(d), m = fn(d) ? `<span class="__crossx-addr-text">${Q(d)}</span>
5104
- <button class="__crossx-copy-btn" data-copy="${D(String(d))}" title="Copy">${ce}</button>` : `<span>${g}</span>`;
5281
+ const f = mn(d), m = xn(d) ? `<span class="__crossx-addr-text">${Y(d)}</span>
5282
+ <button class="__crossx-copy-btn" data-copy="${$(String(d))}" title="Copy">${de}</button>` : `<span>${f}</span>`;
5105
5283
  a += `
5106
5284
  <div class="__crossx-td-row">
5107
- <span class="__crossx-td-label">${D(l)}</span>
5285
+ <span class="__crossx-td-label">${$(l)}</span>
5108
5286
  <div class="__crossx-td-value">${m}</div>
5109
5287
  </div>`;
5110
5288
  }
5111
5289
  const c = document.createElement("div");
5112
5290
  return c.id = te, c.innerHTML = `
5113
- <div class="__crossx-card __crossx-card--migration __crossx-card--sign-typed" style="${ue(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5291
+ <div class="__crossx-card __crossx-card--migration __crossx-card--sign-typed" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5114
5292
  <div class="__crossx-header">
5115
5293
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
5116
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5294
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
5117
5295
  </div>
5118
5296
  <hr class="__crossx-divider">
5119
5297
  <div class="__crossx-body">
5120
5298
  <div class="__crossx-body-cols">
5121
5299
  <div class="__crossx-col-left">
5122
5300
  <p class="__crossx-sig-subtitle">
5123
- <span class="__crossx-sig-origin">${D(t)} </span>is requesting a Signature
5301
+ <span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
5124
5302
  </p>
5125
5303
  <div class="__crossx-addr-pill">
5126
- ${pt}
5127
- <span class="__crossx-addr-pill-text">${Q(r.from)}</span>
5304
+ ${_t}
5305
+ <span class="__crossx-addr-pill-text">${Y(r.from)}</span>
5128
5306
  </div>
5129
5307
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
5130
5308
  </div>
@@ -5139,35 +5317,78 @@ function wn(r, e) {
5139
5317
  </div>
5140
5318
  `, c;
5141
5319
  }
5142
- const yn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
5320
+ const En = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
5321
+ <line x1="12" y1="5" x2="12" y2="19"/>
5322
+ <line x1="5" y1="12" x2="19" y2="12"/>
5323
+ </svg>`;
5324
+ function Tn(r, e) {
5325
+ const s = r.map(
5326
+ (n) => `<button class="__crossx-wallet-item" data-wallet-index="${n.index}" data-wallet-address="${$(n.address)}">
5327
+ <span class="__crossx-wallet-addr">${Y(n.address)}</span>
5328
+ </button>`
5329
+ ).join(""), t = document.createElement("div");
5330
+ return t.id = te, t.innerHTML = `
5331
+ <div class="__crossx-card __crossx-card--migration __crossx-card--wallet-selector" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5332
+ <div class="__crossx-header">
5333
+ <div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
5334
+ <p class="__crossx-title" id="__crossx-ttl" style="padding-right:0;">Select Connected Wallet</p>
5335
+ <p class="__crossx-subtitle--body">Please select the wallet you previously used for this game to continue.</p>
5336
+ </div>
5337
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
5338
+ </div>
5339
+ <hr class="__crossx-divider">
5340
+ <div class="__crossx-body">
5341
+ <div class="__crossx-body-cols">
5342
+ <div class="__crossx-col-left">
5343
+ <div class="__crossx-mig-info">
5344
+ <p class="__crossx-mig-info-title">Why do I need to select a wallet?</p>
5345
+ <p class="__crossx-mig-info-desc">Identifying your previously linked wallet ensures your game progress and assets are synced correctly.</p>
5346
+ </div>
5347
+ </div>
5348
+ <hr class="__crossx-divider __crossx-divider--cols">
5349
+ <div class="__crossx-col-right-ws">
5350
+ <div class="__crossx-wallet-list" id="__crossx-wallet-list">
5351
+ ${s}
5352
+ </div>
5353
+ <button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
5354
+ <span class="__crossx-wallet-add-icon">${En}</span>
5355
+ <span class="__crossx-wallet-add-label">add a wallet</span>
5356
+ </button>
5357
+ </div>
5358
+ </div>
5359
+ </div>
5360
+ </div>
5361
+ `, t;
5362
+ }
5363
+ const In = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
5143
5364
  <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"/>
5144
5365
  <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"/>
5145
- </svg>`, bn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
5366
+ </svg>`, An = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
5146
5367
  <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"/>
5147
5368
  <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"/>
5148
5369
  <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"/>
5149
5370
  <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"/>
5150
5371
  </svg>`;
5151
- function vn(r) {
5372
+ function Rn(r) {
5152
5373
  const e = r, s = document.createElement("div");
5153
5374
  return s.id = te, s.innerHTML = `
5154
- <div class="__crossx-card __crossx-card--migration" style="${ue(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5375
+ <div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5155
5376
  <div class="__crossx-header">
5156
5377
  <div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
5157
5378
  <p class="__crossx-title" id="__crossx-ttl" style="padding-right:0;">Welcome onboard</p>
5158
5379
  <p class="__crossx-subtitle">Creating CROSSx Embedded Wallet</p>
5159
5380
  </div>
5160
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5381
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
5161
5382
  </div>
5162
5383
  <hr class="__crossx-divider">
5163
5384
  <div class="__crossx-body">
5164
5385
  <div class="__crossx-login-btn-row">
5165
5386
  <button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
5166
- <span class="__crossx-login-icon" style="color:var(--cx-value);">${yn}</span>
5387
+ <span class="__crossx-login-icon" style="color:var(--cx-value);">${In}</span>
5167
5388
  <span class="__crossx-login-btn-label">Sign in with&nbsp;&nbsp;Apple</span>
5168
5389
  </button>
5169
5390
  <button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
5170
- <span class="__crossx-login-icon">${bn}</span>
5391
+ <span class="__crossx-login-icon">${An}</span>
5171
5392
  <span class="__crossx-login-btn-label">Sign in with&nbsp;&nbsp;Google</span>
5172
5393
  </button>
5173
5394
  </div>
@@ -5179,14 +5400,14 @@ function vn(r) {
5179
5400
  </div>
5180
5401
  `, s;
5181
5402
  }
5182
- function Sn(r) {
5403
+ function On(r) {
5183
5404
  const e = r, s = document.createElement("div");
5184
5405
  return s.id = te, s.innerHTML = `
5185
- <div class="__crossx-card __crossx-card--migration" style="${ue(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5406
+ <div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5186
5407
  <div class="__crossx-header">
5187
5408
  <p class="__crossx-title" id="__crossx-ttl">Wallet Found on Social Account 🎉</p>
5188
5409
  <p class="__crossx-subtitle--body">We found a wallet linked to your social account. Enter your 4-digit PIN to restore your assets.</p>
5189
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5410
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
5190
5411
  </div>
5191
5412
  <hr class="__crossx-divider">
5192
5413
  <div class="__crossx-body">
@@ -5195,7 +5416,7 @@ function Sn(r) {
5195
5416
  <p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
5196
5417
  </div>
5197
5418
  <button class="__crossx-recover-btn" id="__crossx-recover-btn">
5198
- <span>${cn(e.primary)}</span>
5419
+ <span>${hn(e.primary)}</span>
5199
5420
  <span class="__crossx-recover-label">Recover My Wallet</span>
5200
5421
  </button>
5201
5422
  <button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>
@@ -5203,13 +5424,13 @@ function Sn(r) {
5203
5424
  </div>
5204
5425
  `, s;
5205
5426
  }
5206
- function En(r, e) {
5427
+ function Cn(r, e) {
5207
5428
  const s = r, t = e ? `<p class="__crossx-pin-error-text">${e}</p>` : "", n = document.createElement("div");
5208
5429
  return n.id = te, n.innerHTML = `
5209
- <div class="__crossx-card __crossx-card--migration" style="${ue(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5430
+ <div class="__crossx-card __crossx-card--migration" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5210
5431
  <div class="__crossx-header">
5211
5432
  <p class="__crossx-title" id="__crossx-ttl">Recover My Wallet</p>
5212
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5433
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
5213
5434
  </div>
5214
5435
  <hr class="__crossx-divider">
5215
5436
  <div class="__crossx-pin-center">
@@ -5225,7 +5446,7 @@ function En(r, e) {
5225
5446
  </div>
5226
5447
  `, n;
5227
5448
  }
5228
- function Tn(r, e, s) {
5449
+ function kn(r, e, s) {
5229
5450
  var n;
5230
5451
  const t = r.querySelectorAll(".__crossx-pin-input");
5231
5452
  t.forEach((o, i) => {
@@ -5243,24 +5464,75 @@ function Tn(r, e, s) {
5243
5464
  a.preventDefault();
5244
5465
  const c = (((d = a.clipboardData) == null ? void 0 : d.getData("text")) ?? "").replace(/\D/g, "").slice(0, 4);
5245
5466
  if (!c) return;
5246
- c.split("").forEach((g, w) => {
5247
- t[w] && (t[w].value = g);
5467
+ c.split("").forEach((f, w) => {
5468
+ t[w] && (t[w].value = f);
5248
5469
  });
5249
5470
  const l = Math.min(c.length, 3);
5250
5471
  t[l].focus(), c.length === 4 && setTimeout(() => e(c), 200);
5251
5472
  });
5252
5473
  }), (n = t[0]) == null || n.focus();
5253
5474
  }
5254
- class An {
5475
+ class Nn {
5255
5476
  constructor(e = "light", s) {
5256
- this.theme = e, this.overrides = s, this.tokens = qt(e, s);
5477
+ this.theme = e, this.overrides = s, this.tokens = jt(e, s);
5257
5478
  }
5258
5479
  setTheme(e, s) {
5259
- this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = qt(e, this.overrides);
5480
+ this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = jt(e, this.overrides);
5260
5481
  }
5261
5482
  getTheme() {
5262
5483
  return this.theme;
5263
5484
  }
5485
+ /**
5486
+ * 지갑 선택 팝업: "Select Connected Wallet"
5487
+ * 지갑 목록을 표시하고, 사용자가 선택하거나 새 지갑을 추가할 수 있습니다.
5488
+ * 모달은 지갑을 선택하거나 X를 누를 때까지 유지됩니다.
5489
+ */
5490
+ showWalletSelector(e, s) {
5491
+ return new Promise((t) => {
5492
+ var m;
5493
+ me();
5494
+ const n = [...e], o = Tn(n, this.tokens);
5495
+ document.body.appendChild(o);
5496
+ let i = !1;
5497
+ const a = () => {
5498
+ i || (i = !0, o.remove());
5499
+ }, c = (_) => {
5500
+ a(), t(_);
5501
+ }, l = () => {
5502
+ a(), t(null);
5503
+ };
5504
+ (() => {
5505
+ o.querySelectorAll(".__crossx-wallet-item").forEach((_) => {
5506
+ _.addEventListener("click", () => {
5507
+ const T = _.dataset.walletAddress ?? "", b = parseInt(_.dataset.walletIndex ?? "0", 10);
5508
+ c({ address: T, index: b });
5509
+ });
5510
+ });
5511
+ })();
5512
+ const f = o.querySelector("#__crossx-add-wallet-btn");
5513
+ f && f.addEventListener("click", async () => {
5514
+ f.disabled = !0;
5515
+ try {
5516
+ const _ = await s();
5517
+ n.push(_);
5518
+ const T = o.querySelector("#__crossx-wallet-list");
5519
+ if (T) {
5520
+ const b = document.createElement("button");
5521
+ b.className = "__crossx-wallet-item", b.dataset.walletIndex = String(_.index), b.dataset.walletAddress = _.address, b.innerHTML = `<span class="__crossx-wallet-addr">${Y(_.address)}</span>`, b.addEventListener("click", () => c(_)), T.appendChild(b), b.scrollIntoView({ behavior: "smooth", block: "nearest" });
5522
+ }
5523
+ } catch {
5524
+ } finally {
5525
+ f.disabled = !1;
5526
+ }
5527
+ }), (m = o.querySelector("#__crossx-close-btn")) == null || m.addEventListener("click", l), o.addEventListener("click", (_) => {
5528
+ _.target === o && l();
5529
+ });
5530
+ const w = (_) => {
5531
+ _.key === "Escape" && (document.removeEventListener("keydown", w), l());
5532
+ };
5533
+ document.addEventListener("keydown", w);
5534
+ });
5535
+ }
5264
5536
  /**
5265
5537
  * 로그인 프로바이더 선택 팝업: "Welcome onboard"
5266
5538
  * Apple / Google 버튼을 표시하고 선택된 프로바이더를 반환합니다.
@@ -5269,8 +5541,8 @@ class An {
5269
5541
  showLoginSelector() {
5270
5542
  return new Promise((e) => {
5271
5543
  var a, c, l;
5272
- Se();
5273
- const s = vn(this.tokens);
5544
+ me();
5545
+ const s = Rn(this.tokens);
5274
5546
  document.body.appendChild(s);
5275
5547
  const t = () => s.remove(), n = (d) => {
5276
5548
  t(), e(d);
@@ -5280,7 +5552,7 @@ class An {
5280
5552
  (a = s.querySelector("#__crossx-apple-btn")) == null || a.addEventListener("click", () => n("apple")), (c = s.querySelector("#__crossx-google-btn")) == null || c.addEventListener("click", () => n("google")), (l = s.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", o), s.addEventListener("click", (d) => {
5281
5553
  d.target === s && o();
5282
5554
  }), s.querySelectorAll(".__crossx-login-terms-link").forEach((d) => {
5283
- d.addEventListener("click", (g) => g.stopPropagation());
5555
+ d.addEventListener("click", (f) => f.stopPropagation());
5284
5556
  });
5285
5557
  const i = (d) => {
5286
5558
  d.key === "Escape" && (document.removeEventListener("keydown", i), o());
@@ -5295,8 +5567,8 @@ class An {
5295
5567
  showMigrationFoundPrompt() {
5296
5568
  return new Promise((e) => {
5297
5569
  var a, c, l;
5298
- Se();
5299
- const s = Sn(this.tokens);
5570
+ me();
5571
+ const s = On(this.tokens);
5300
5572
  document.body.appendChild(s);
5301
5573
  const t = () => s.remove(), n = () => {
5302
5574
  t(), e("recover");
@@ -5320,15 +5592,15 @@ class An {
5320
5592
  showPinInputPrompt(e) {
5321
5593
  return new Promise((s) => {
5322
5594
  var a;
5323
- Se();
5324
- const t = En(this.tokens, e);
5595
+ me();
5596
+ const t = Cn(this.tokens, e);
5325
5597
  document.body.appendChild(t);
5326
5598
  const n = () => t.remove(), o = (c) => {
5327
5599
  n(), s(c);
5328
5600
  }, i = () => {
5329
5601
  n(), s(null);
5330
5602
  };
5331
- Tn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
5603
+ kn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
5332
5604
  c.target === t && i();
5333
5605
  });
5334
5606
  });
@@ -5340,8 +5612,8 @@ class An {
5340
5612
  showTransactionComplete(e) {
5341
5613
  return new Promise((s) => {
5342
5614
  var a, c;
5343
- Se();
5344
- const t = pn(e, this.tokens);
5615
+ me();
5616
+ const t = wn(e, this.tokens);
5345
5617
  document.body.appendChild(t);
5346
5618
  const n = () => t.remove(), o = () => {
5347
5619
  n(), s();
@@ -5350,8 +5622,8 @@ class An {
5350
5622
  l.addEventListener("click", (d) => {
5351
5623
  var w;
5352
5624
  d.stopPropagation();
5353
- const g = l.dataset.copy;
5354
- g && ((w = navigator.clipboard) == null || w.writeText(g).catch(() => {
5625
+ const f = l.dataset.copy;
5626
+ f && ((w = navigator.clipboard) == null || w.writeText(f).catch(() => {
5355
5627
  }));
5356
5628
  });
5357
5629
  }), t.addEventListener("click", (l) => {
@@ -5369,16 +5641,16 @@ class An {
5369
5641
  */
5370
5642
  showTransactionProgress(e, s) {
5371
5643
  return new Promise((t) => {
5372
- Se();
5373
- const n = xn(e, this.tokens);
5644
+ me();
5645
+ const n = yn(e, this.tokens);
5374
5646
  document.body.appendChild(n);
5375
5647
  const o = () => n.remove();
5376
5648
  let i = !1;
5377
5649
  const a = () => {
5378
5650
  i || (i = !0, o(), t());
5379
5651
  }, c = () => {
5380
- var d, g;
5381
- (d = n.querySelector("#__crossx-done-btn")) == null || d.addEventListener("click", a), (g = n.querySelector("#__crossx-close-btn")) == null || g.addEventListener("click", a), n.addEventListener("click", (w) => {
5652
+ var d, f;
5653
+ (d = n.querySelector("#__crossx-done-btn")) == null || d.addEventListener("click", a), (f = n.querySelector("#__crossx-close-btn")) == null || f.addEventListener("click", a), n.addEventListener("click", (w) => {
5382
5654
  w.target === n && a();
5383
5655
  });
5384
5656
  const l = (w) => {
@@ -5387,40 +5659,40 @@ class An {
5387
5659
  document.addEventListener("keydown", l);
5388
5660
  };
5389
5661
  s.then((l) => {
5390
- i || (_n(n, l, this.tokens), c());
5662
+ i || (bn(n, l, this.tokens), c());
5391
5663
  });
5392
5664
  });
5393
5665
  }
5394
5666
  requestConfirmation(e) {
5395
5667
  return new Promise((s) => {
5396
5668
  var c, l, d;
5397
- Se();
5669
+ me();
5398
5670
  let t;
5399
- e.type === "sign-message" ? t = mn(e, this.tokens) : e.type === "sign-typed-data" ? t = wn(e, this.tokens) : e.type === "sign" ? t = un(e, this.tokens) : t = hn(e, this.tokens), document.body.appendChild(t);
5671
+ e.type === "sign-message" ? t = vn(e, this.tokens) : e.type === "sign-typed-data" ? t = Sn(e, this.tokens) : e.type === "sign" ? t = pn(e, this.tokens) : t = _n(e, this.tokens), document.body.appendChild(t);
5400
5672
  const n = () => t.remove(), o = () => {
5401
5673
  n(), s(!0);
5402
5674
  }, i = () => {
5403
5675
  n(), s(!1);
5404
5676
  };
5405
- (c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (d = t.querySelector("#__crossx-close-btn")) == null || d.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((g) => {
5406
- g.addEventListener("click", (w) => {
5407
- var x;
5677
+ (c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (d = t.querySelector("#__crossx-close-btn")) == null || d.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((f) => {
5678
+ f.addEventListener("click", (w) => {
5679
+ var _;
5408
5680
  w.stopPropagation();
5409
- const m = g.dataset.copy;
5410
- m && ((x = navigator.clipboard) == null || x.writeText(m).catch(() => {
5681
+ const m = f.dataset.copy;
5682
+ m && ((_ = navigator.clipboard) == null || _.writeText(m).catch(() => {
5411
5683
  }));
5412
5684
  });
5413
- }), t.addEventListener("click", (g) => {
5414
- g.target === t && i();
5685
+ }), t.addEventListener("click", (f) => {
5686
+ f.target === t && i();
5415
5687
  });
5416
- const a = (g) => {
5417
- g.key === "Escape" && (document.removeEventListener("keydown", a), i());
5688
+ const a = (f) => {
5689
+ f.key === "Escape" && (document.removeEventListener("keydown", a), i());
5418
5690
  };
5419
5691
  document.addEventListener("keydown", a);
5420
5692
  });
5421
5693
  }
5422
5694
  }
5423
- class In {
5695
+ class Pn {
5424
5696
  constructor() {
5425
5697
  this._accessToken = null;
5426
5698
  }
@@ -5437,54 +5709,42 @@ class In {
5437
5709
  return this._accessToken !== null;
5438
5710
  }
5439
5711
  }
5440
- const Rn = "https://cross-wallet-oauth.crosstoken.io", On = "https://cross-auth.crosstoken.io", Cn = "https://embedded-wallet-gateway.crosstoken.io/api/v1";
5441
- function Nn() {
5442
- return Rn;
5443
- }
5444
- function Pn() {
5445
- return On;
5446
- }
5447
- function kn() {
5448
- return Cn;
5449
- }
5450
5712
  function Bn(r) {
5451
5713
  r.debug;
5452
- const e = Nn(), s = Pn(), t = kn(), n = {
5714
+ const e = Ue.production, s = {
5453
5715
  ...r,
5454
- oauthServiceUrl: e,
5455
- authApiUrl: s,
5456
- walletGatewayUrl: t
5457
- }, i = r.authMode === "token" && Tt.isAvailable() ? new Tt() : new qs(), a = new Xr(), c = new en(), l = new gt(), d = new In();
5458
- let g;
5459
- r.useMockWallet ? (f.log("[CROSSx] Mock Wallet Provider 사용"), g = new tn(i)) : (f.log("[CROSSx] Remote Wallet Provider 사용"), g = new Ge(
5460
- {
5461
- gatewayUrl: t,
5462
- projectId: r.projectId
5463
- },
5464
- i,
5465
- c,
5466
- d
5716
+ oauthServiceUrl: e.oauthServiceUrl,
5717
+ authApiUrl: e.authApiUrl,
5718
+ walletGatewayUrl: e.walletGatewayUrl
5719
+ }, t = {
5720
+ gatewayUrl: e.walletGatewayUrl,
5721
+ projectId: r.projectId
5722
+ }, o = s.authMode !== "cookie" && At.isAvailable() ? new At() : new Ks(), i = new tn(), a = new nn(), c = new pt(), l = new Pn();
5723
+ let d;
5724
+ r.useMockWallet ? (g.log("[CROSSx] Mock Wallet Provider 사용"), d = new on(o)) : (g.log("[CROSSx] Remote Wallet Provider 사용"), d = new qe(
5725
+ t,
5726
+ o,
5727
+ a,
5728
+ l
5467
5729
  ));
5468
- const w = new Oe(
5469
- { gatewayUrl: t, projectId: r.projectId },
5470
- c
5471
- ), m = new An(r.theme ?? "light", r.themeTokens);
5472
- return new tt(
5473
- n,
5730
+ const f = new Ce(t, a), w = new Nn(r.theme ?? "light", r.themeTokens);
5731
+ return new st(
5732
+ s,
5733
+ t,
5734
+ o,
5474
5735
  i,
5475
5736
  a,
5476
5737
  c,
5477
- l,
5478
- g,
5479
5738
  d,
5480
- m,
5481
- w
5739
+ l,
5740
+ w,
5741
+ f
5482
5742
  );
5483
5743
  }
5484
5744
  export {
5485
- _ as CROSSxError,
5486
- Rs as CROSSxEthereumProvider,
5487
- tt as CROSSxSDK,
5745
+ x as CROSSxError,
5746
+ Cs as CROSSxEthereumProvider,
5747
+ st as CROSSxSDK,
5488
5748
  $n as ChainId,
5489
5749
  p as ErrorCode,
5490
5750
  Bn as createCROSSxSDK