@nexus-cross/crossx-sdk-core 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  var Ls = Object.defineProperty;
2
2
  var Ds = (r, e, s) => e in r ? Ls(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
- var T = (r, e, s) => Ds(r, typeof e != "symbol" ? e + "" : e, s);
3
+ var A = (r, e, s) => Ds(r, typeof e != "symbol" ? e + "" : e, s);
4
4
  import { createRemoteJWKSet as Ms, jwtVerify as $s, decodeJwt as Bs } from "jose";
5
- var p = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.ALREADY_AUTHENTICATED = "ALREADY_AUTHENTICATED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", r.USER_REJECTED = "USER_REJECTED", r.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", r.NETWORK_ERROR = "NETWORK_ERROR", r.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", r.INVALID_CHAIN = "INVALID_CHAIN", r.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", r.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.SIGNATURE_FAILED = "SIGNATURE_FAILED", r.TRANSACTION_FAILED = "TRANSACTION_FAILED", r.PREPARE_FAILED = "PREPARE_FAILED", r.PREPARE_EXPIRED = "PREPARE_EXPIRED", r.PREPARE_MISMATCH = "PREPARE_MISMATCH", r.MIGRATION_FAILED = "MIGRATION_FAILED", r.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", r.MIGRATION_PIN_LOCKED = "MIGRATION_PIN_LOCKED", r.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", r.WALLET_INCONSISTENT_STATE = "WALLET_INCONSISTENT_STATE", r.PROJECT_ID_MISSING = "PROJECT_ID_MISSING", r.ORIGIN_NOT_ALLOWED = "ORIGIN_NOT_ALLOWED", r.APP_IDENTIFIER_MISSING = "APP_IDENTIFIER_MISSING", r.INVALID_APP_TYPE = "INVALID_APP_TYPE", r.PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED", r.SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH", r.GAS_ESTIMATION_FAILED = "GAS_ESTIMATION_FAILED", r.TYPED_DATA_CHAIN_ID_MISMATCH = "TYPED_DATA_CHAIN_ID_MISMATCH", r.PIN_NOT_SET = "PIN_NOT_SET", r.PIN_WRONG = "PIN_WRONG", r.PIN_INVALID = "PIN_INVALID", r.PIN_CANCELLED = "PIN_CANCELLED", r.PIN_LOCKED = "PIN_LOCKED", r.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(p || {});
5
+ var p = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.ALREADY_AUTHENTICATED = "ALREADY_AUTHENTICATED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.WALLET_ALREADY_EXISTS = "WALLET_ALREADY_EXISTS", r.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", r.BROADCAST_FAILED = "BROADCAST_FAILED", r.USER_REJECTED = "USER_REJECTED", r.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", r.NETWORK_ERROR = "NETWORK_ERROR", r.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", r.INVALID_CHAIN = "INVALID_CHAIN", r.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", r.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.SIGNATURE_FAILED = "SIGNATURE_FAILED", r.TRANSACTION_FAILED = "TRANSACTION_FAILED", r.PREPARE_FAILED = "PREPARE_FAILED", r.PREPARE_EXPIRED = "PREPARE_EXPIRED", r.PREPARE_MISMATCH = "PREPARE_MISMATCH", r.MIGRATION_FAILED = "MIGRATION_FAILED", r.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", r.MIGRATION_PIN_LOCKED = "MIGRATION_PIN_LOCKED", r.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", r.WALLET_INCONSISTENT_STATE = "WALLET_INCONSISTENT_STATE", r.PROJECT_ID_MISSING = "PROJECT_ID_MISSING", r.ORIGIN_NOT_ALLOWED = "ORIGIN_NOT_ALLOWED", r.APP_IDENTIFIER_MISSING = "APP_IDENTIFIER_MISSING", r.INVALID_APP_TYPE = "INVALID_APP_TYPE", r.PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED", r.SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH", r.GAS_ESTIMATION_FAILED = "GAS_ESTIMATION_FAILED", r.TYPED_DATA_CHAIN_ID_MISMATCH = "TYPED_DATA_CHAIN_ID_MISMATCH", r.PIN_NOT_SET = "PIN_NOT_SET", r.PIN_WRONG = "PIN_WRONG", r.PIN_INVALID = "PIN_INVALID", r.PIN_REPEATED_PATTERN = "PIN_REPEATED_PATTERN", r.PIN_CANCELLED = "PIN_CANCELLED", r.PIN_LOCKED = "PIN_LOCKED", r.HMAC_REQUIRED = "HMAC_REQUIRED", r.HMAC_VERIFICATION_FAILED = "HMAC_VERIFICATION_FAILED", r.WITHDRAW_FAILED = "WITHDRAW_FAILED", r.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(p || {});
6
6
  class g extends Error {
7
7
  constructor(e, s, t) {
8
8
  super(s), this.code = e, this.details = t, this.name = "CROSSxError", Object.setPrototypeOf(this, g.prototype);
@@ -327,7 +327,7 @@ const u = {
327
327
  function St(r = "en", e) {
328
328
  return Ws[r] ?? Qt;
329
329
  }
330
- const Et = "crossx_access_token", It = "crossx_refresh_token", Tt = "crossx_user_info";
330
+ const Et = "crossx_access_token", It = "crossx_refresh_token", At = "crossx_user_info";
331
331
  class qs {
332
332
  constructor(e, s, t, n, o, i, a) {
333
333
  this.config = e, this.storage = s, this.crypto = t, this.oauth = n, this.transport = o, this.walletProvider = i, this.tokenStore = a, this._refreshPromise = null, this._migrated = !1;
@@ -618,13 +618,13 @@ class qs {
618
618
  if (!this._migrated) {
619
619
  this._migrated = !0;
620
620
  try {
621
- const e = await this.storage.get(Tt);
621
+ const e = await this.storage.get(At);
622
622
  if (!e || await this.storage.get(this.STORAGE_KEY_USER)) return;
623
623
  await this.storage.set(this.STORAGE_KEY_USER, e);
624
624
  const t = await this.storage.get(Et);
625
625
  t && await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, t);
626
626
  const n = await this.storage.get(It);
627
- n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(Tt), await this.storage.remove(Et), await this.storage.remove(It), u.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
627
+ n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(At), await this.storage.remove(Et), await this.storage.remove(It), u.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
628
628
  } catch (e) {
629
629
  u.warn("[CROSSx] 스토리지 키 마이그레이션 실패:", e);
630
630
  }
@@ -819,7 +819,7 @@ function Js() {
819
819
  }
820
820
  return Ge.production;
821
821
  }
822
- const Zs = 2e3, At = 6e4, Xs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA00", kt = 130, Pt = 6, Nt = 18, tr = 5 * 60 * 1e3, sr = 30 * 1e3, re = class re extends js {
822
+ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA00", kt = 130, Pt = 6, Nt = 18, tr = 5 * 60 * 1e3, sr = 30 * 1e3, re = class re extends js {
823
823
  constructor(e, s, t, n, o, i, a, c, l, d, h) {
824
824
  var m;
825
825
  super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this._initPromise = null, this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._verifyPinMutex = null, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && vt(e.logger), this.confirmation = l, this.pinStore = h ?? new es(), this.chainRegistry = d, this.jsonRpc = new zs(d, o), this.signInUseCase = new qs(
@@ -856,7 +856,7 @@ const Zs = 2e3, At = 6e4, Xs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
856
856
  }
857
857
  async _doInitialize(e) {
858
858
  var s, t;
859
- u.log("[CROSSx SDK] v1.2.6 초기화 중..."), this.confirmation.setMessages(St(this._config.locale));
859
+ u.log("[CROSSx SDK] v1.2.7 초기화 중..."), this.confirmation.setMessages(St(this._config.locale));
860
860
  try {
861
861
  const n = Js();
862
862
  this.internalConfig.oauthServiceUrl = n.oauthServiceUrl, this.internalConfig.authApiUrl = n.authApiUrl, this.internalConfig.walletGatewayUrl = n.walletGatewayUrl, this.adapterConfig.gatewayUrl = n.walletGatewayUrl, (t = (s = this.crypto).setJWKSEndpoint) == null || t.call(s, `${n.authApiUrl}/.well-known/jwks.json`);
@@ -1325,7 +1325,7 @@ const Zs = 2e3, At = 6e4, Xs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1325
1325
  dappName: (t == null ? void 0 : t.dappName) ?? this._config.appName,
1326
1326
  accountName: t == null ? void 0 : t.accountName
1327
1327
  }))
1328
- throw new g(p.USER_REJECTED, "사용자가 메시지 서명을 거부했습니다");
1328
+ throw new g(p.USER_REJECTED, "User rejected the message signing request");
1329
1329
  try {
1330
1330
  const i = await this.withPinRetry(async () => {
1331
1331
  let a;
@@ -1384,7 +1384,7 @@ const Zs = 2e3, At = 6e4, Xs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1384
1384
  dappName: (t == null ? void 0 : t.dappName) ?? this._config.appName,
1385
1385
  accountName: t == null ? void 0 : t.accountName
1386
1386
  }))
1387
- throw new g(p.USER_REJECTED, "사용자가 타입 데이터 서명을 거부했습니다");
1387
+ throw new g(p.USER_REJECTED, "User rejected the typed data signing request");
1388
1388
  try {
1389
1389
  const i = await this.withPinRetry(async () => {
1390
1390
  let a;
@@ -1459,7 +1459,7 @@ const Zs = 2e3, At = 6e4, Xs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1459
1459
  dappName: (t == null ? void 0 : t.dappName) ?? this._config.appName,
1460
1460
  accountName: t == null ? void 0 : t.accountName
1461
1461
  }))
1462
- throw new g(p.USER_REJECTED, "사용자가 트랜잭션 서명을 거부했습니다");
1462
+ throw new g(p.USER_REJECTED, "User rejected the transaction signing request");
1463
1463
  try {
1464
1464
  const a = await this.withPinRetry(async () => {
1465
1465
  let c;
@@ -1514,7 +1514,7 @@ const Zs = 2e3, At = 6e4, Xs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1514
1514
  dappName: (t == null ? void 0 : t.dappName) ?? this._config.appName,
1515
1515
  accountName: t == null ? void 0 : t.accountName
1516
1516
  }))
1517
- throw new g(p.USER_REJECTED, "사용자가 트랜잭션을 거부했습니다");
1517
+ throw new g(p.USER_REJECTED, "User rejected the transaction request");
1518
1518
  try {
1519
1519
  const a = await this.withPinRetry(async () => {
1520
1520
  let c;
@@ -1564,7 +1564,7 @@ const Zs = 2e3, At = 6e4, Xs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1564
1564
  * @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
1565
1565
  */
1566
1566
  async waitForTxAndGetReceipt(e, s, t = {}) {
1567
- const n = t.intervalMs ?? Xs, o = Qs, i = t.timeoutMs ?? At, a = Date.now() + i;
1567
+ const n = t.intervalMs ?? Zs, o = Qs, i = t.timeoutMs ?? Tt, a = Date.now() + i;
1568
1568
  let c = n;
1569
1569
  for (; Date.now() < a; ) {
1570
1570
  const l = await this.getTransactionReceipt(e, s);
@@ -1593,7 +1593,7 @@ const Zs = 2e3, At = 6e4, Xs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
1593
1593
  */
1594
1594
  async sendTransactionWithWaitForReceipt(e, s, t = {}) {
1595
1595
  var E, y;
1596
- const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((E = this._config.receiptPolling) == null ? void 0 : E.intervalMs) ?? Zs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? At, d = Je(e), h = s.from ?? "";
1596
+ const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((E = this._config.receiptPolling) == null ? void 0 : E.intervalMs) ?? Xs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? Tt, d = Je(e), h = s.from ?? "";
1597
1597
  let m, x;
1598
1598
  const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((S) => {
1599
1599
  m = S;
@@ -2292,6 +2292,23 @@ const Zs = 2e3, At = 6e4, Xs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
2292
2292
  dispose() {
2293
2293
  this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), vt(null);
2294
2294
  }
2295
+ /**
2296
+ * @internal internal 패키지 전용 — 공개 문서에 기재하지 않음
2297
+ *
2298
+ * Internal/Private SDK가 Core의 내부 인프라에 접근하기 위한 컨텍스트를 반환합니다.
2299
+ * iOS SDK의 makePrivateContext()에 대응합니다.
2300
+ */
2301
+ _getInternalContext() {
2302
+ return {
2303
+ transport: this.transport,
2304
+ storage: this.storage,
2305
+ walletProvider: this.walletProvider,
2306
+ confirmation: this.confirmation,
2307
+ tokenStore: this.tokenStore,
2308
+ pinStore: this.pinStore,
2309
+ adapterConfig: this.adapterConfig
2310
+ };
2311
+ }
2295
2312
  };
2296
2313
  re.OFFCHAIN_CHAIN_ID = "0";
2297
2314
  let it = re;
@@ -2332,7 +2349,7 @@ class rr {
2332
2349
  }
2333
2350
  }
2334
2351
  }
2335
- const Ze = "crossx-sdk", nr = 1, de = "data", Se = "keys", $e = "aes-primary", or = 12;
2352
+ const Xe = "crossx-sdk", nr = 1, de = "data", Se = "keys", $e = "aes-primary", or = 12;
2336
2353
  class Ot {
2337
2354
  constructor(e) {
2338
2355
  this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
@@ -2396,9 +2413,9 @@ class Ot {
2396
2413
  * 마이그레이션 성공 시 레거시 DB 삭제.
2397
2414
  */
2398
2415
  async migrateFromLegacyDB() {
2399
- if (this.dbName === Ze) return null;
2416
+ if (this.dbName === Xe) return null;
2400
2417
  try {
2401
- const e = await this.openDB(Ze), s = e.transaction([Se, de], "readonly"), t = s.objectStore(Se).get($e), n = await new Promise((l, d) => {
2418
+ const e = await this.openDB(Xe), s = e.transaction([Se, de], "readonly"), t = s.objectStore(Se).get($e), n = await new Promise((l, d) => {
2402
2419
  t.onsuccess = () => l(t.result), t.onerror = () => d(t.error);
2403
2420
  });
2404
2421
  if (!n)
@@ -2414,7 +2431,7 @@ class Ot {
2414
2431
  e.close(), await this.idbPut(Se, $e, n);
2415
2432
  for (let l = 0; l < c.length; l++)
2416
2433
  await this.idbPut(de, String(c[l]), a[l]);
2417
- return indexedDB.deleteDatabase(Ze), u.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), n;
2434
+ return indexedDB.deleteDatabase(Xe), u.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), n;
2418
2435
  } catch (e) {
2419
2436
  return u.warn("[CROSSx] IndexedDB 레거시 DB 마이그레이션 실패:", e), null;
2420
2437
  }
@@ -2520,7 +2537,7 @@ function Pe(...r) {
2520
2537
  for (let e = 0; e < r.length; e++)
2521
2538
  r[e].fill(0);
2522
2539
  }
2523
- function Xe(r) {
2540
+ function Ze(r) {
2524
2541
  return new DataView(r.buffer, r.byteOffset, r.byteLength);
2525
2542
  }
2526
2543
  function ue(r, e) {
@@ -2606,18 +2623,18 @@ function pr(r, e, s) {
2606
2623
  }
2607
2624
  class fr {
2608
2625
  constructor(e, s, t, n) {
2609
- T(this, "blockLen");
2610
- T(this, "outputLen");
2611
- T(this, "padOffset");
2612
- T(this, "isLE");
2626
+ A(this, "blockLen");
2627
+ A(this, "outputLen");
2628
+ A(this, "padOffset");
2629
+ A(this, "isLE");
2613
2630
  // For partial updates less than block size
2614
- T(this, "buffer");
2615
- T(this, "view");
2616
- T(this, "finished", !1);
2617
- T(this, "length", 0);
2618
- T(this, "pos", 0);
2619
- T(this, "destroyed", !1);
2620
- this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Xe(this.buffer);
2631
+ A(this, "buffer");
2632
+ A(this, "view");
2633
+ A(this, "finished", !1);
2634
+ A(this, "length", 0);
2635
+ A(this, "pos", 0);
2636
+ A(this, "destroyed", !1);
2637
+ this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Ze(this.buffer);
2621
2638
  }
2622
2639
  update(e) {
2623
2640
  ke(this), V(e);
@@ -2625,7 +2642,7 @@ class fr {
2625
2642
  for (let i = 0; i < o; ) {
2626
2643
  const a = Math.min(n - this.pos, o - i);
2627
2644
  if (a === n) {
2628
- const c = Xe(e);
2645
+ const c = Ze(e);
2629
2646
  for (; n <= o - i; i += n)
2630
2647
  this.process(c, i);
2631
2648
  continue;
@@ -2642,7 +2659,7 @@ class fr {
2642
2659
  for (let h = i; h < n; h++)
2643
2660
  s[h] = 0;
2644
2661
  t.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(t, 0);
2645
- const a = Xe(e), c = this.outputLen;
2662
+ const a = Ze(e), c = this.outputLen;
2646
2663
  if (c % 4)
2647
2664
  throw new Error("_sha2: outputLen must be aligned to 32bit");
2648
2665
  const l = c / 4, d = this.get();
@@ -2792,14 +2809,14 @@ class Sr extends vr {
2792
2809
  super(32);
2793
2810
  // We cannot use array here since array allows indexing by variable
2794
2811
  // which means optimizer/compiler cannot use registers.
2795
- T(this, "A", me[0] | 0);
2796
- T(this, "B", me[1] | 0);
2797
- T(this, "C", me[2] | 0);
2798
- T(this, "D", me[3] | 0);
2799
- T(this, "E", me[4] | 0);
2800
- T(this, "F", me[5] | 0);
2801
- T(this, "G", me[6] | 0);
2802
- T(this, "H", me[7] | 0);
2812
+ A(this, "A", me[0] | 0);
2813
+ A(this, "B", me[1] | 0);
2814
+ A(this, "C", me[2] | 0);
2815
+ A(this, "D", me[3] | 0);
2816
+ A(this, "E", me[4] | 0);
2817
+ A(this, "F", me[5] | 0);
2818
+ A(this, "G", me[6] | 0);
2819
+ A(this, "H", me[7] | 0);
2803
2820
  }
2804
2821
  }
2805
2822
  const Er = /* @__PURE__ */ ns(
@@ -2852,11 +2869,11 @@ function Ir(r) {
2852
2869
  return Uint8Array.from(r);
2853
2870
  }
2854
2871
  const Fe = (r) => typeof r == "bigint" && ht <= r;
2855
- function Tr(r, e, s) {
2872
+ function Ar(r, e, s) {
2856
2873
  return Fe(r) && Fe(e) && Fe(s) && e <= r && r < s;
2857
2874
  }
2858
- function Ar(r, e, s, t) {
2859
- if (!Tr(e, s, t))
2875
+ function Tr(r, e, s, t) {
2876
+ if (!Ar(e, s, t))
2860
2877
  throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
2861
2878
  }
2862
2879
  function Rr(r) {
@@ -3060,16 +3077,16 @@ function Br(r, e) {
3060
3077
  }
3061
3078
  class Ur {
3062
3079
  constructor(e, s = {}) {
3063
- T(this, "ORDER");
3064
- T(this, "BITS");
3065
- T(this, "BYTES");
3066
- T(this, "isLE");
3067
- T(this, "ZERO", ne);
3068
- T(this, "ONE", ee);
3069
- T(this, "_lengths");
3070
- T(this, "_sqrt");
3080
+ A(this, "ORDER");
3081
+ A(this, "BITS");
3082
+ A(this, "BYTES");
3083
+ A(this, "isLE");
3084
+ A(this, "ZERO", ne);
3085
+ A(this, "ONE", ee);
3086
+ A(this, "_lengths");
3087
+ A(this, "_sqrt");
3071
3088
  // cached sqrt
3072
- T(this, "_mod");
3089
+ A(this, "_mod");
3073
3090
  var i;
3074
3091
  if (e <= ne)
3075
3092
  throw new Error("invalid field: expected ORDER > 0, got " + e);
@@ -3192,7 +3209,7 @@ function Hr(r, e, s = !1) {
3192
3209
  return s ? ls(a, n) : pt(a, n);
3193
3210
  }
3194
3211
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3195
- const Ne = /* @__PURE__ */ BigInt(0), Te = /* @__PURE__ */ BigInt(1);
3212
+ const Ne = /* @__PURE__ */ BigInt(0), Ae = /* @__PURE__ */ BigInt(1);
3196
3213
  function Ke(r, e) {
3197
3214
  const s = e.negate();
3198
3215
  return r ? s : e;
@@ -3213,7 +3230,7 @@ function Qe(r, e) {
3213
3230
  function Ht(r, e, s) {
3214
3231
  const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
3215
3232
  let a = Number(r & n), c = r >> i;
3216
- a > t && (a -= o, c += Te);
3233
+ a > t && (a -= o, c += Ae);
3217
3234
  const l = e * t, d = l + Math.abs(a) - 1, h = a === 0, m = a < 0, x = e % 2 !== 0;
3218
3235
  return { nextN: c, offset: d, isZero: h, isNeg: m, isNegF: x, offsetF: l };
3219
3236
  }
@@ -3228,17 +3245,17 @@ function Ft(r) {
3228
3245
  class Fr {
3229
3246
  // Parametrized with a given Point class (not individual point)
3230
3247
  constructor(e, s) {
3231
- T(this, "BASE");
3232
- T(this, "ZERO");
3233
- T(this, "Fn");
3234
- T(this, "bits");
3248
+ A(this, "BASE");
3249
+ A(this, "ZERO");
3250
+ A(this, "Fn");
3251
+ A(this, "bits");
3235
3252
  this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = s;
3236
3253
  }
3237
3254
  // non-const time multiplication ladder
3238
3255
  _unsafeLadder(e, s, t = this.ZERO) {
3239
3256
  let n = e;
3240
3257
  for (; s > Ne; )
3241
- s & Te && (t = t.add(n)), n = n.double(), s >>= Te;
3258
+ s & Ae && (t = t.add(n)), n = n.double(), s >>= Ae;
3242
3259
  return t;
3243
3260
  }
3244
3261
  /**
@@ -3322,7 +3339,7 @@ class Fr {
3322
3339
  function Gr(r, e, s, t) {
3323
3340
  let n = e, o = r.ZERO, i = r.ZERO;
3324
3341
  for (; s > Ne || t > Ne; )
3325
- s & Te && (o = o.add(n)), t & Te && (i = i.add(n)), n = n.double(), s >>= Te, t >>= Te;
3342
+ s & Ae && (o = o.add(n)), t & Ae && (i = i.add(n)), n = n.double(), s >>= Ae, t >>= Ae;
3326
3343
  return { p1: o, p2: i };
3327
3344
  }
3328
3345
  function Gt(r, e, s) {
@@ -3355,12 +3372,12 @@ function qr(r, e) {
3355
3372
  }
3356
3373
  class vs {
3357
3374
  constructor(e, s) {
3358
- T(this, "oHash");
3359
- T(this, "iHash");
3360
- T(this, "blockLen");
3361
- T(this, "outputLen");
3362
- T(this, "finished", !1);
3363
- T(this, "destroyed", !1);
3375
+ A(this, "oHash");
3376
+ A(this, "iHash");
3377
+ A(this, "blockLen");
3378
+ A(this, "outputLen");
3379
+ A(this, "finished", !1);
3380
+ A(this, "destroyed", !1);
3364
3381
  if (ts(e), V(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
3365
3382
  throw new Error("Expected instance of class which extends utils.Hash");
3366
3383
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
@@ -3528,7 +3545,7 @@ function jr(r, e = {}) {
3528
3545
  const { endo: c } = e;
3529
3546
  if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
3530
3547
  throw new Error('invalid endo: expected "beta": bigint and "basises": array');
3531
- const l = Ts(t, n);
3548
+ const l = As(t, n);
3532
3549
  function d() {
3533
3550
  if (!t.isOdd)
3534
3551
  throw new Error("compression is not supported: Field does not have .isOdd()");
@@ -3550,21 +3567,21 @@ function jr(r, e = {}) {
3550
3567
  if (!t.isValid(O))
3551
3568
  throw new Error("bad point: is not on curve, wrong x");
3552
3569
  const M = E(O);
3553
- let A;
3570
+ let T;
3554
3571
  try {
3555
- A = t.sqrt(M);
3572
+ T = t.sqrt(M);
3556
3573
  } catch (J) {
3557
3574
  const K = J instanceof Error ? ": " + J.message : "";
3558
3575
  throw new Error("bad point: is not on curve, sqrt error" + K);
3559
3576
  }
3560
3577
  d();
3561
- const $ = t.isOdd(A);
3562
- return (I & 1) === 1 !== $ && (A = t.neg(A)), { x: O, y: A };
3578
+ const $ = t.isOdd(T);
3579
+ return (I & 1) === 1 !== $ && (T = t.neg(T)), { x: O, y: T };
3563
3580
  } else if (v === _ && I === 4) {
3564
- const O = t.BYTES, M = t.fromBytes(L.subarray(0, O)), A = t.fromBytes(L.subarray(O, O * 2));
3565
- if (!y(M, A))
3581
+ const O = t.BYTES, M = t.fromBytes(L.subarray(0, O)), T = t.fromBytes(L.subarray(O, O * 2));
3582
+ if (!y(M, T))
3566
3583
  throw new Error("bad point: is not on curve");
3567
- return { x: M, y: A };
3584
+ return { x: M, y: T };
3568
3585
  } else
3569
3586
  throw new Error(`bad point: got length ${v}, expected compressed=${f} or uncompressed=${_}`);
3570
3587
  }
@@ -3602,10 +3619,10 @@ function jr(r, e = {}) {
3602
3619
  return { x: _, y: v };
3603
3620
  const L = N.is0();
3604
3621
  f == null && (f = L ? t.ONE : t.inv(I));
3605
- const O = t.mul(_, f), M = t.mul(v, f), A = t.mul(I, f);
3622
+ const O = t.mul(_, f), M = t.mul(v, f), T = t.mul(I, f);
3606
3623
  if (L)
3607
3624
  return { x: t.ZERO, y: t.ZERO };
3608
- if (!t.eql(A, t.ONE))
3625
+ if (!t.eql(T, t.ONE))
3609
3626
  throw new Error("invZ was invalid");
3610
3627
  return { x: O, y: M };
3611
3628
  }), G = Mt((N) => {
@@ -3629,9 +3646,9 @@ function jr(r, e = {}) {
3629
3646
  const R = class R {
3630
3647
  /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
3631
3648
  constructor(f, _, v) {
3632
- T(this, "X");
3633
- T(this, "Y");
3634
- T(this, "Z");
3649
+ A(this, "X");
3650
+ A(this, "Y");
3651
+ A(this, "Z");
3635
3652
  this.X = B("x", f), this.Y = B("y", _, !0), this.Z = B("z", v), Object.freeze(this);
3636
3653
  }
3637
3654
  static CURVE() {
@@ -3682,8 +3699,8 @@ function jr(r, e = {}) {
3682
3699
  /** Compare one point to another. */
3683
3700
  equals(f) {
3684
3701
  b(f);
3685
- const { X: _, Y: v, Z: I } = this, { X: L, Y: O, Z: M } = f, A = t.eql(t.mul(_, M), t.mul(L, I)), $ = t.eql(t.mul(v, M), t.mul(O, I));
3686
- return A && $;
3702
+ const { X: _, Y: v, Z: I } = this, { X: L, Y: O, Z: M } = f, T = t.eql(t.mul(_, M), t.mul(L, I)), $ = t.eql(t.mul(v, M), t.mul(O, I));
3703
+ return T && $;
3687
3704
  }
3688
3705
  /** Flips point to one corresponding to (x, -y) in Affine coordinates. */
3689
3706
  negate() {
@@ -3695,8 +3712,8 @@ function jr(r, e = {}) {
3695
3712
  // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
3696
3713
  double() {
3697
3714
  const { a: f, b: _ } = o, v = t.mul(_, He), { X: I, Y: L, Z: O } = this;
3698
- let M = t.ZERO, A = t.ZERO, $ = t.ZERO, F = t.mul(I, I), J = t.mul(L, L), K = t.mul(O, O), H = t.mul(I, L);
3699
- return H = t.add(H, H), $ = t.mul(I, O), $ = t.add($, $), M = t.mul(f, $), A = t.mul(v, K), A = t.add(M, A), M = t.sub(J, A), A = t.add(J, A), A = t.mul(M, A), M = t.mul(H, M), $ = t.mul(v, $), K = t.mul(f, K), H = t.sub(F, K), H = t.mul(f, H), H = t.add(H, $), $ = t.add(F, F), F = t.add($, F), F = t.add(F, K), F = t.mul(F, H), A = t.add(A, F), K = t.mul(L, O), K = t.add(K, K), F = t.mul(K, H), M = t.sub(M, F), $ = t.mul(K, J), $ = t.add($, $), $ = t.add($, $), new R(M, A, $);
3715
+ let M = t.ZERO, T = t.ZERO, $ = t.ZERO, F = t.mul(I, I), J = t.mul(L, L), K = t.mul(O, O), H = t.mul(I, L);
3716
+ return H = t.add(H, H), $ = t.mul(I, O), $ = t.add($, $), M = t.mul(f, $), T = t.mul(v, K), T = t.add(M, T), M = t.sub(J, T), T = t.add(J, T), T = t.mul(M, T), M = t.mul(H, M), $ = t.mul(v, $), K = t.mul(f, K), H = t.sub(F, K), H = t.mul(f, H), H = t.add(H, $), $ = t.add(F, F), F = t.add($, F), F = t.add(F, K), F = t.mul(F, H), T = t.add(T, F), K = t.mul(L, O), K = t.add(K, K), F = t.mul(K, H), M = t.sub(M, F), $ = t.mul(K, J), $ = t.add($, $), $ = t.add($, $), new R(M, T, $);
3700
3717
  }
3701
3718
  // Renes-Costello-Batina exception-free addition formula.
3702
3719
  // There is 30% faster Jacobian formula, but it is not complete.
@@ -3705,12 +3722,12 @@ function jr(r, e = {}) {
3705
3722
  add(f) {
3706
3723
  b(f);
3707
3724
  const { X: _, Y: v, Z: I } = this, { X: L, Y: O, Z: M } = f;
3708
- let A = t.ZERO, $ = t.ZERO, F = t.ZERO;
3725
+ let T = t.ZERO, $ = t.ZERO, F = t.ZERO;
3709
3726
  const J = o.a, K = t.mul(o.b, He);
3710
- let H = t.mul(_, L), Z = t.mul(v, O), X = t.mul(I, M), oe = t.add(_, v), j = t.add(L, O);
3711
- oe = t.mul(oe, j), j = t.add(H, Z), oe = t.sub(oe, j), j = t.add(_, I);
3727
+ let H = t.mul(_, L), X = t.mul(v, O), Z = t.mul(I, M), oe = t.add(_, v), j = t.add(L, O);
3728
+ oe = t.mul(oe, j), j = t.add(H, X), oe = t.sub(oe, j), j = t.add(_, I);
3712
3729
  let Q = t.add(L, M);
3713
- return j = t.mul(j, Q), Q = t.add(H, X), j = t.sub(j, Q), Q = t.add(v, I), A = t.add(O, M), Q = t.mul(Q, A), A = t.add(Z, X), Q = t.sub(Q, A), F = t.mul(J, j), A = t.mul(K, X), F = t.add(A, F), A = t.sub(Z, F), F = t.add(Z, F), $ = t.mul(A, F), Z = t.add(H, H), Z = t.add(Z, H), X = t.mul(J, X), j = t.mul(K, j), Z = t.add(Z, X), X = t.sub(H, X), X = t.mul(J, X), j = t.add(j, X), H = t.mul(Z, j), $ = t.add($, H), H = t.mul(Q, j), A = t.mul(oe, A), A = t.sub(A, H), H = t.mul(oe, Z), F = t.mul(Q, F), F = t.add(F, H), new R(A, $, F);
3730
+ return j = t.mul(j, Q), Q = t.add(H, Z), j = t.sub(j, Q), Q = t.add(v, I), T = t.add(O, M), Q = t.mul(Q, T), T = t.add(X, Z), Q = t.sub(Q, T), F = t.mul(J, j), T = t.mul(K, Z), F = t.add(T, F), T = t.sub(X, F), F = t.add(X, F), $ = t.mul(T, F), X = t.add(H, H), X = t.add(X, H), Z = t.mul(J, Z), j = t.mul(K, j), X = t.add(X, Z), Z = t.sub(H, Z), Z = t.mul(J, Z), j = t.add(j, Z), H = t.mul(X, j), $ = t.add($, H), H = t.mul(Q, j), T = t.mul(oe, T), T = t.sub(T, H), H = t.mul(oe, X), F = t.mul(Q, F), F = t.add(F, H), new R(T, $, F);
3714
3731
  }
3715
3732
  subtract(f) {
3716
3733
  return this.add(f.negate());
@@ -3734,8 +3751,8 @@ function jr(r, e = {}) {
3734
3751
  let v, I;
3735
3752
  const L = (O) => D.cached(this, O, (M) => Ut(R, M));
3736
3753
  if (_) {
3737
- const { k1neg: O, k1: M, k2neg: A, k2: $ } = k(f), { p: F, f: J } = L(M), { p: K, f: H } = L($);
3738
- I = J.add(H), v = z(_.beta, F, K, O, A);
3754
+ const { k1neg: O, k1: M, k2neg: T, k2: $ } = k(f), { p: F, f: J } = L(M), { p: K, f: H } = L($);
3755
+ I = J.add(H), v = z(_.beta, F, K, O, T);
3739
3756
  } else {
3740
3757
  const { p: O, f: M } = L(f);
3741
3758
  v = O, I = M;
@@ -3758,8 +3775,8 @@ function jr(r, e = {}) {
3758
3775
  if (D.hasCache(this))
3759
3776
  return this.multiply(f);
3760
3777
  if (_) {
3761
- const { k1neg: I, k1: L, k2neg: O, k2: M } = k(f), { p1: A, p2: $ } = Gr(R, v, L, M);
3762
- return z(_.beta, A, $, I, O);
3778
+ const { k1neg: I, k1: L, k2neg: O, k2: M } = k(f), { p1: T, p2: $ } = Gr(R, v, L, M);
3779
+ return z(_.beta, T, $, I, O);
3763
3780
  } else
3764
3781
  return D.unsafe(v, f);
3765
3782
  }
@@ -3796,11 +3813,11 @@ function jr(r, e = {}) {
3796
3813
  }
3797
3814
  };
3798
3815
  // base / generator point
3799
- T(R, "BASE", new R(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
3800
- T(R, "ZERO", new R(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
3816
+ A(R, "BASE", new R(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
3817
+ A(R, "ZERO", new R(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
3801
3818
  // math field
3802
- T(R, "Fp", t), // scalar field
3803
- T(R, "Fn", n);
3819
+ A(R, "Fp", t), // scalar field
3820
+ A(R, "Fn", n);
3804
3821
  let W = R;
3805
3822
  const q = n.BITS, D = new Fr(W, e.endo ? Math.ceil(q / 2) : q);
3806
3823
  return W.BASE.precompute(8), W;
@@ -3808,7 +3825,7 @@ function jr(r, e = {}) {
3808
3825
  function Is(r) {
3809
3826
  return Uint8Array.of(r ? 2 : 3);
3810
3827
  }
3811
- function Ts(r, e) {
3828
+ function As(r, e) {
3812
3829
  return {
3813
3830
  secretKey: e.BYTES,
3814
3831
  publicKey: 1 + r.BYTES,
@@ -3818,7 +3835,7 @@ function Ts(r, e) {
3818
3835
  };
3819
3836
  }
3820
3837
  function Yr(r, e = {}) {
3821
- const { Fn: s } = r, t = e.randomBytes || os, n = Object.assign(Ts(r.Fp, s), { seed: ws(s.ORDER) });
3838
+ const { Fn: s } = r, t = e.randomBytes || os, n = Object.assign(As(r.Fp, s), { seed: ws(s.ORDER) });
3822
3839
  function o(x) {
3823
3840
  try {
3824
3841
  const w = s.fromBytes(x);
@@ -3898,9 +3915,9 @@ function Jr(r, e, s = {}) {
3898
3915
  }
3899
3916
  class b {
3900
3917
  constructor(_, v, I) {
3901
- T(this, "r");
3902
- T(this, "s");
3903
- T(this, "recovery");
3918
+ A(this, "r");
3919
+ A(this, "s");
3920
+ A(this, "recovery");
3904
3921
  if (this.r = S("r", _), this.s = S("s", v), I != null) {
3905
3922
  if (C(), ![0, 1, 2, 3].includes(I))
3906
3923
  throw new Error("invalid recovery id");
@@ -3912,8 +3929,8 @@ function Jr(r, e, s = {}) {
3912
3929
  B(_, v);
3913
3930
  let I;
3914
3931
  if (v === "der") {
3915
- const { r: A, s: $ } = ye.toSig(V(_));
3916
- return new b(A, $);
3932
+ const { r: T, s: $ } = ye.toSig(V(_));
3933
+ return new b(T, $);
3917
3934
  }
3918
3935
  v === "recovered" && (I = _[0], v = "compact", _ = _.subarray(1));
3919
3936
  const L = x.signature / 2, O = _.subarray(0, L), M = _.subarray(L, L * 2);
@@ -3935,7 +3952,7 @@ function Jr(r, e, s = {}) {
3935
3952
  const { r: v, s: I } = this, L = this.assertRecovery(), O = L === 2 || L === 3 ? v + a : v;
3936
3953
  if (!o.isValid(O))
3937
3954
  throw new Error("invalid recovery id: sig.r+curve.n != R.x");
3938
- const M = o.toBytes(O), A = r.fromBytes(ve(Is((L & 1) === 0), M)), $ = i.inv(O), F = P(V(_, void 0, "msgHash")), J = i.create(-F * $), K = i.create(I * $), H = r.BASE.multiplyUnsafe(J).add(A.multiplyUnsafe(K));
3955
+ const M = o.toBytes(O), T = r.fromBytes(ve(Is((L & 1) === 0), M)), $ = i.inv(O), F = P(V(_, void 0, "msgHash")), J = i.create(-F * $), K = i.create(I * $), H = r.BASE.multiplyUnsafe(J).add(T.multiplyUnsafe(K));
3939
3956
  if (H.is0())
3940
3957
  throw new Error("invalid recovery: point at infinify");
3941
3958
  return H.assertValidity(), H;
@@ -3963,7 +3980,7 @@ function Jr(r, e, s = {}) {
3963
3980
  return i.create(k(_));
3964
3981
  }, G = ft(c);
3965
3982
  function z(f) {
3966
- return Ar("num < 2^" + c, f, _e, G), i.toBytes(f);
3983
+ return Tr("num < 2^" + c, f, _e, G), i.toBytes(f);
3967
3984
  }
3968
3985
  function W(f, _) {
3969
3986
  return V(f, void 0, "message"), _ ? V(e(f), void 0, "prehashed message") : f;
@@ -3971,23 +3988,23 @@ function Jr(r, e, s = {}) {
3971
3988
  function q(f, _, v) {
3972
3989
  const { lowS: I, prehash: L, extraEntropy: O } = st(v, w);
3973
3990
  f = W(f, L);
3974
- const M = P(f), A = i.fromBytes(_);
3975
- if (!i.isValidNot0(A))
3991
+ const M = P(f), T = i.fromBytes(_);
3992
+ if (!i.isValidNot0(T))
3976
3993
  throw new Error("invalid private key");
3977
- const $ = [z(A), z(M)];
3994
+ const $ = [z(T), z(M)];
3978
3995
  if (O != null && O !== !1) {
3979
3996
  const H = O === !0 ? t(x.secretKey) : O;
3980
3997
  $.push(V(H, void 0, "extraEntropy"));
3981
3998
  }
3982
3999
  const F = ve(...$), J = M;
3983
4000
  function K(H) {
3984
- const Z = k(H);
3985
- if (!i.isValidNot0(Z))
4001
+ const X = k(H);
4002
+ if (!i.isValidNot0(X))
3986
4003
  return;
3987
- const X = i.inv(Z), oe = r.BASE.multiply(Z).toAffine(), j = i.create(oe.x);
4004
+ const Z = i.inv(X), oe = r.BASE.multiply(X).toAffine(), j = i.create(oe.x);
3988
4005
  if (j === _e)
3989
4006
  return;
3990
- const Q = i.create(X * i.create(J + j * A));
4007
+ const Q = i.create(Z * i.create(J + j * T));
3991
4008
  if (Q === _e)
3992
4009
  return;
3993
4010
  let yt = (oe.x === j ? 0 : 2) | Number(oe.y & Re), bt = Q;
@@ -4002,15 +4019,15 @@ function Jr(r, e, s = {}) {
4002
4019
  function R(f, _, v, I = {}) {
4003
4020
  const { lowS: L, prehash: O, format: M } = st(I, w);
4004
4021
  if (v = V(v, void 0, "publicKey"), _ = W(_, O), !ut(f)) {
4005
- const A = f instanceof b ? ", use sig.toBytes()" : "";
4006
- throw new Error("verify expects Uint8Array signature" + A);
4022
+ const T = f instanceof b ? ", use sig.toBytes()" : "";
4023
+ throw new Error("verify expects Uint8Array signature" + T);
4007
4024
  }
4008
4025
  B(f, M);
4009
4026
  try {
4010
- const A = b.fromBytes(f, M), $ = r.fromBytes(v);
4011
- if (L && A.hasHighS())
4027
+ const T = b.fromBytes(f, M), $ = r.fromBytes(v);
4028
+ if (L && T.hasHighS())
4012
4029
  return !1;
4013
- const { r: F, s: J } = A, K = P(_), H = i.inv(J), Z = i.create(K * H), X = i.create(F * H), oe = r.BASE.multiplyUnsafe(Z).add($.multiplyUnsafe(X));
4030
+ const { r: F, s: J } = T, K = P(_), H = i.inv(J), X = i.create(K * H), Z = i.create(F * H), oe = r.BASE.multiplyUnsafe(X).add($.multiplyUnsafe(Z));
4014
4031
  return oe.is0() ? !1 : i.create(oe.x) === F;
4015
4032
  } catch {
4016
4033
  return !1;
@@ -4043,25 +4060,25 @@ const gt = {
4043
4060
  b: BigInt(7),
4044
4061
  Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
4045
4062
  Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
4046
- }, Zr = {
4063
+ }, Xr = {
4047
4064
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
4048
4065
  basises: [
4049
4066
  [BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
4050
4067
  [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
4051
4068
  ]
4052
4069
  }, qt = /* @__PURE__ */ BigInt(2);
4053
- function Xr(r) {
4070
+ function Zr(r) {
4054
4071
  const e = gt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, h = ae(d, s, e) * d % e, m = ae(h, s, e) * d % e, x = ae(m, qt, e) * l % e, w = ae(x, n, e) * x % e, E = ae(w, o, e) * w % e, y = ae(E, a, e) * E % e, S = ae(y, c, e) * y % e, C = ae(S, a, e) * E % e, B = ae(C, s, e) * d % e, b = ae(B, i, e) * w % e, k = ae(b, t, e) * l % e, P = ae(k, qt, e);
4055
4072
  if (!lt.eql(lt.sqr(P), r))
4056
4073
  throw new Error("Cannot find square root");
4057
4074
  return P;
4058
4075
  }
4059
- const lt = je(gt.p, { sqrt: Xr }), Qr = /* @__PURE__ */ jr(gt, {
4076
+ const lt = je(gt.p, { sqrt: Zr }), Qr = /* @__PURE__ */ jr(gt, {
4060
4077
  Fp: lt,
4061
- endo: Zr
4062
- }), en = /* @__PURE__ */ Jr(Qr, Er), tn = BigInt(0), Oe = BigInt(1), sn = BigInt(2), rn = BigInt(7), nn = BigInt(256), on = BigInt(113), As = [], Rs = [], ks = [];
4078
+ endo: Xr
4079
+ }), en = /* @__PURE__ */ Jr(Qr, Er), tn = BigInt(0), Oe = BigInt(1), sn = BigInt(2), rn = BigInt(7), nn = BigInt(256), on = BigInt(113), Ts = [], Rs = [], ks = [];
4063
4080
  for (let r = 0, e = Oe, s = 1, t = 0; r < 24; r++) {
4064
- [s, t] = [t, (2 * s + 3 * t) % 5], As.push(2 * (5 * t + s)), Rs.push((r + 1) * (r + 2) / 2 % 64);
4081
+ [s, t] = [t, (2 * s + 3 * t) % 5], Ts.push(2 * (5 * t + s)), Rs.push((r + 1) * (r + 2) / 2 % 64);
4065
4082
  let n = tn;
4066
4083
  for (let o = 0; o < 7; o++)
4067
4084
  e = (e << Oe ^ (e >> rn) * on) % nn, e & sn && (n ^= Oe << (Oe << BigInt(o)) - Oe);
@@ -4080,7 +4097,7 @@ function ln(r, e = 24) {
4080
4097
  }
4081
4098
  let n = r[2], o = r[3];
4082
4099
  for (let i = 0; i < 24; i++) {
4083
- const a = Rs[i], c = Kt(n, o, a), l = Vt(n, o, a), d = As[i];
4100
+ const a = Rs[i], c = Kt(n, o, a), l = Vt(n, o, a), d = Ts[i];
4084
4101
  n = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
4085
4102
  }
4086
4103
  for (let i = 0; i < 50; i += 10) {
@@ -4096,17 +4113,17 @@ function ln(r, e = 24) {
4096
4113
  class mt {
4097
4114
  // NOTE: we accept arguments in bytes instead of bits here.
4098
4115
  constructor(e, s, t, n = !1, o = 24) {
4099
- T(this, "state");
4100
- T(this, "pos", 0);
4101
- T(this, "posOut", 0);
4102
- T(this, "finished", !1);
4103
- T(this, "state32");
4104
- T(this, "destroyed", !1);
4105
- T(this, "blockLen");
4106
- T(this, "suffix");
4107
- T(this, "outputLen");
4108
- T(this, "enableXOF", !1);
4109
- T(this, "rounds");
4116
+ A(this, "state");
4117
+ A(this, "pos", 0);
4118
+ A(this, "posOut", 0);
4119
+ A(this, "finished", !1);
4120
+ A(this, "state32");
4121
+ A(this, "destroyed", !1);
4122
+ A(this, "blockLen");
4123
+ A(this, "suffix");
4124
+ A(this, "outputLen");
4125
+ A(this, "enableXOF", !1);
4126
+ A(this, "rounds");
4110
4127
  if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, ge(t, "outputLen"), !(0 < e && e < 200))
4111
4128
  throw new Error("only keccak-f1600 function is supported");
4112
4129
  this.state = new Uint8Array(200), this.state32 = ir(this.state);
@@ -4441,7 +4458,7 @@ class be {
4441
4458
  });
4442
4459
  }
4443
4460
  }
4444
- const Ce = "crossx_wallet_data", Ae = "crossx_mock_pin_hash";
4461
+ const Ce = "crossx_wallet_data", Te = "crossx_mock_pin_hash";
4445
4462
  class mn {
4446
4463
  constructor(e, s) {
4447
4464
  this.storage = e, this.pinStore = s ?? null;
@@ -4471,7 +4488,7 @@ class mn {
4471
4488
  };
4472
4489
  await this.storage.set(Ce, n);
4473
4490
  const o = (s = this.pinStore) == null ? void 0 : s.get();
4474
- return o && (await this.storage.set(Ae, o), u.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
4491
+ return o && (await this.storage.set(Te, o), u.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
4475
4492
  } catch (t) {
4476
4493
  throw new g(p.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", t);
4477
4494
  }
@@ -4513,8 +4530,8 @@ class mn {
4513
4530
  var t;
4514
4531
  if (u.log("[Mock] verifyPin"), this.pinScenario === "wrong")
4515
4532
  return !1;
4516
- const s = await this.storage.get(Ae);
4517
- return s && s !== e ? !1 : (s || await this.storage.set(Ae, e), (t = this.pinStore) == null || t.set(e), u.log("[Mock] verifyPin → 성공"), !0);
4533
+ const s = await this.storage.get(Te);
4534
+ return s && s !== e ? !1 : (s || await this.storage.set(Te, e), (t = this.pinStore) == null || t.set(e), u.log("[Mock] verifyPin → 성공"), !0);
4518
4535
  }
4519
4536
  /**
4520
4537
  * POST /mnemonic/change-password 모킹
@@ -4524,10 +4541,10 @@ class mn {
4524
4541
  var o;
4525
4542
  if (u.log("[Mock] changePin"), this.pinScenario === "wrong")
4526
4543
  throw new g(p.PIN_WRONG, "Incorrect PIN.");
4527
- const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Ae);
4544
+ const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Te);
4528
4545
  if (n && t && n !== t)
4529
4546
  throw new g(p.PIN_WRONG, "Incorrect PIN.");
4530
- await this.storage.set(Ae, s), u.log("[Mock] changePin 완료");
4547
+ await this.storage.set(Te, s), u.log("[Mock] changePin 완료");
4531
4548
  }
4532
4549
  async migrateWallet(e, s) {
4533
4550
  var o;
@@ -4560,7 +4577,7 @@ class mn {
4560
4577
  };
4561
4578
  await this.storage.set(Ce, t);
4562
4579
  const n = (o = this.pinStore) == null ? void 0 : o.get();
4563
- return n && (await this.storage.set(Ae, n), u.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
4580
+ return n && (await this.storage.set(Te, n), u.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
4564
4581
  }
4565
4582
  /**
4566
4583
  * POST /mnemonic/share-c 모킹
@@ -4865,16 +4882,27 @@ class Le {
4865
4882
  case -10002:
4866
4883
  return p.AUTH_NOT_AUTHENTICATED;
4867
4884
  case -10001:
4868
- case -10009:
4869
4885
  return p.UNKNOWN_ERROR;
4870
4886
  case -10006:
4871
4887
  return p.GATEWAY_INTERNAL_ERROR;
4888
+ case -10007:
4889
+ return p.BROADCAST_FAILED;
4872
4890
  case -10008:
4873
4891
  return p.GATEWAY_LOCK_CONFLICT;
4892
+ case -10004:
4893
+ return p.WALLET_ALREADY_EXISTS;
4894
+ case -10005:
4895
+ return p.WALLET_NOT_FOUND;
4896
+ case -10011:
4897
+ return p.WALLET_NOT_FOUND;
4898
+ case -10030:
4899
+ return p.WALLET_INCONSISTENT_STATE;
4874
4900
  case -10010:
4875
4901
  return p.MIGRATION_FAILED;
4876
4902
  case -10012:
4877
4903
  return p.MIGRATION_BACKUP_EXISTS;
4904
+ case -10013:
4905
+ return p.WITHDRAW_FAILED;
4878
4906
  case -10027:
4879
4907
  return p.MIGRATION_PIN_LOCKED;
4880
4908
  case -10022:
@@ -4883,14 +4911,16 @@ class Le {
4883
4911
  return p.PROJECT_ID_MISSING;
4884
4912
  case -10024:
4885
4913
  return p.ORIGIN_NOT_ALLOWED;
4914
+ case -10025:
4915
+ return p.INVALID_APP_TYPE;
4886
4916
  case -10028:
4887
4917
  return p.PIN_WRONG;
4888
4918
  case -10029:
4889
4919
  return p.PIN_INVALID;
4890
4920
  case -10031:
4891
4921
  return p.PIN_LOCKED;
4892
- case -10030:
4893
- return p.WALLET_INCONSISTENT_STATE;
4922
+ case -10032:
4923
+ return p.PIN_REPEATED_PATTERN;
4894
4924
  case -10026:
4895
4925
  return p.TYPED_DATA_CHAIN_ID_MISMATCH;
4896
4926
  case -10014:
@@ -4902,6 +4932,14 @@ class Le {
4902
4932
  case -10017:
4903
4933
  case -10018:
4904
4934
  return p.PREPARE_MISMATCH;
4935
+ case -10020:
4936
+ return p.CHAIN_NOT_SUPPORTED;
4937
+ case -10021:
4938
+ return p.INVALID_CHAIN;
4939
+ case -10040:
4940
+ return p.HMAC_REQUIRED;
4941
+ case -10041:
4942
+ return p.HMAC_VERIFICATION_FAILED;
4905
4943
  default:
4906
4944
  return p.UNKNOWN_ERROR;
4907
4945
  }
@@ -4910,28 +4948,44 @@ class Le {
4910
4948
  switch (e) {
4911
4949
  case -10002:
4912
4950
  return "Session expired. Please sign in again.";
4951
+ case -10004:
4952
+ return "Wallet already exists for this user.";
4953
+ case -10005:
4954
+ return "User wallet not found.";
4913
4955
  case -10006:
4914
4956
  return "Internal server error. Please try again later.";
4957
+ case -10007:
4958
+ return "Transaction broadcast failed. Please try again.";
4915
4959
  case -10008:
4916
4960
  return "Another operation is in progress. Please try again later.";
4961
+ case -10013:
4962
+ return "Withdraw failed. Please try again.";
4917
4963
  case -10022:
4918
4964
  return "Project is not whitelisted. Verify your projectId and register the current origin in the management console.";
4919
4965
  case -10023:
4920
4966
  return "Project ID is required. Set the projectId field in SDKConfig.";
4921
4967
  case -10024:
4922
- return "Origin is not in the allowed list. Register the current domain in the management console.";
4968
+ return "Origin or App ID is required. Register the current domain or set X-App-Id header.";
4969
+ case -10025:
4970
+ return "Invalid app type. X-App-Type must be android, ios, or windows.";
4923
4971
  case -10026:
4924
4972
  return "Domain chainId mismatch: the chainId in typedData.domain does not match the request chainId.";
4973
+ case -10027:
4974
+ return "Too many incorrect PIN attempts. Your account has been temporarily locked.";
4925
4975
  case -10028:
4926
4976
  return "Incorrect PIN. Please try again.";
4927
4977
  case -10029:
4928
- return "Invalid PIN format. Please enter a 6-digit numeric PIN.";
4929
- case -10031:
4930
- return "Too many failed PIN attempts. Your account is temporarily locked.";
4931
- case -10027:
4932
- return "Too many incorrect PIN attempts. Your account has been temporarily locked.";
4978
+ return "Sequential PIN is not allowed. Please choose a different PIN.";
4933
4979
  case -10030:
4934
4980
  return "Wallet is in an inconsistent state. Please contact support.";
4981
+ case -10031:
4982
+ return "Too many failed PIN attempts. Your account is temporarily locked.";
4983
+ case -10032:
4984
+ return "Repeated digit pattern is not allowed. Please choose a different PIN.";
4985
+ case -10040:
4986
+ return "HMAC signature header is required.";
4987
+ case -10041:
4988
+ return "HMAC signature verification failed.";
4935
4989
  default:
4936
4990
  return `Request failed (${e}): ${s}`;
4937
4991
  }
@@ -6797,7 +6851,7 @@ function bn(r, e = "CROSS", s = 18) {
6797
6851
  return null;
6798
6852
  }
6799
6853
  }
6800
- const Zt = {
6854
+ const Xt = {
6801
6855
  1: "Ethereum Mainnet",
6802
6856
  5: "Goerli Testnet",
6803
6857
  11155111: "Ethereum Sepolia",
@@ -6822,7 +6876,7 @@ const Zt = {
6822
6876
  };
6823
6877
  function Ns(r) {
6824
6878
  const e = parseInt(r.split(":")[1] ?? "", 10);
6825
- return !isNaN(e) && Zt[e] ? Zt[e] : r;
6879
+ return !isNaN(e) && Xt[e] ? Xt[e] : r;
6826
6880
  }
6827
6881
  function dt(r, e) {
6828
6882
  if (r === 0n) return "0";
@@ -6894,7 +6948,7 @@ const xe = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="
6894
6948
  <rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
6895
6949
  </svg>`, In = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
6896
6950
  <path d="M12 0C18.6274 0 24 5.37258 24 12C23.9999 18.6273 18.6274 24 12 24C5.37264 24 9.89594e-05 18.6273 0 12C0 5.37258 5.37258 0 12 0ZM10.875 15.127V17.377H13.125V15.127H10.875ZM10.875 6.62207V13.627H13.125V6.62207H10.875Z" fill="var(--cx-error)"/>
6897
- </svg>`, Tn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
6951
+ </svg>`, An = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
6898
6952
  <circle cx="12" cy="12" r="12" fill="var(--cx-error)"/>
6899
6953
  <circle cx="12" cy="12" r="5.5" stroke="white" stroke-width="1.5"/>
6900
6954
  <path d="M12 9.5v3l2 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
@@ -6932,7 +6986,7 @@ function Y(r, e) {
6932
6986
  <div class="__crossx-row-value">${e}</div>
6933
6987
  </div>`;
6934
6988
  }
6935
- function An(r, e) {
6989
+ function Tn(r, e) {
6936
6990
  const s = e, t = Ye(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
6937
6991
  <button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", o = Os(r), i = r.data ?? "0x", a = document.createElement("div");
6938
6992
  return a.id = te, a.innerHTML = `
@@ -7078,7 +7132,7 @@ function On(r, e) {
7078
7132
  function Cn(r, e, s) {
7079
7133
  const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
7080
7134
  if (o) {
7081
- const w = n ? Tn : t ? "" : In, E = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
7135
+ const w = n ? An : t ? "" : In, E = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
7082
7136
  w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${E}</span>`) : o.textContent = E;
7083
7137
  }
7084
7138
  if (i && !r.querySelector("#__crossx-close-btn")) {
@@ -7430,7 +7484,7 @@ function nt(r) {
7430
7484
  <div class="__crossx-home-indicator"></div>
7431
7485
  `;
7432
7486
  }
7433
- function Xt(r, e) {
7487
+ function Zt(r, e) {
7434
7488
  const s = document.createElement("div");
7435
7489
  return s.id = te, s.innerHTML = `
7436
7490
  <div class="__crossx-card __crossx-card--pin6" style="${ce(r)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
@@ -7578,7 +7632,7 @@ function Jn(r, e, s) {
7578
7632
  });
7579
7633
  }), (n = t[0]) == null || n.focus();
7580
7634
  }
7581
- class Zn {
7635
+ class Xn {
7582
7636
  constructor(e = "light", s) {
7583
7637
  this.theme = e, this.overrides = s, this.tokens = Jt(e, s);
7584
7638
  }
@@ -7720,7 +7774,7 @@ class Zn {
7720
7774
  }, i = {
7721
7775
  title: (t == null ? void 0 : t.pinSetup_confirmTitle) ?? "Confirm PIN",
7722
7776
  headerSubtitle: (t == null ? void 0 : t.pinSetup_confirmSubtitle) ?? "Enter your PIN again to confirm."
7723
- }, a = Xt(this.tokens, Kn(n)), c = document.body.style.overflow;
7777
+ }, a = Zt(this.tokens, Kn(n)), c = document.body.style.overflow;
7724
7778
  document.body.style.overflow = "hidden", pe(a);
7725
7779
  let l = !1;
7726
7780
  const d = () => {
@@ -7807,7 +7861,7 @@ class Zn {
7807
7861
  return new Promise((s, t) => {
7808
7862
  var y;
7809
7863
  he();
7810
- const n = this.messages, o = (e == null ? void 0 : e.verifyMode) === !0, i = o ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = o ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c = Xt(
7864
+ const n = this.messages, o = (e == null ? void 0 : e.verifyMode) === !0, i = o ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = o ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c = Zt(
7811
7865
  this.tokens,
7812
7866
  nt({
7813
7867
  title: i,
@@ -7940,7 +7994,7 @@ class Zn {
7940
7994
  var c, l, d;
7941
7995
  he();
7942
7996
  let t;
7943
- e.type === "sign-message" ? t = Ln(e, this.tokens) : e.type === "sign-typed-data" ? t = Dn(e, this.tokens) : e.type === "sign" ? t = An(e, this.tokens) : t = Rn(e, this.tokens), pe(t);
7997
+ e.type === "sign-message" ? t = Ln(e, this.tokens) : e.type === "sign-typed-data" ? t = Dn(e, this.tokens) : e.type === "sign" ? t = Tn(e, this.tokens) : t = Rn(e, this.tokens), pe(t);
7944
7998
  const n = () => t.remove(), o = () => {
7945
7999
  n(), s(!0);
7946
8000
  }, i = () => {
@@ -7964,7 +8018,7 @@ class Zn {
7964
8018
  });
7965
8019
  }
7966
8020
  }
7967
- class Xn {
8021
+ class Zn {
7968
8022
  constructor() {
7969
8023
  this._accessToken = null, this._expiresAt = 0;
7970
8024
  }
@@ -8003,7 +8057,7 @@ function so(r, e) {
8003
8057
  "refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
8004
8058
  "IndexedDB를 지원하는 브라우저 사용을 권장합니다."
8005
8059
  ), t.secureStorageAvailable = o;
8006
- const i = o ? new Ot(r.projectId) : new rr(), a = new hn(), c = new xn(), l = new be(), d = new Xn(), h = new es();
8060
+ const i = o ? new Ot(r.projectId) : new rr(), a = new hn(), c = new xn(), l = new be(), d = new Zn(), h = new es();
8007
8061
  let m;
8008
8062
  r.useMockWallet ? (u.log("[CROSSx] Mock Wallet Provider 사용"), m = new mn(i, h)) : (u.log("[CROSSx] Remote Wallet Provider 사용"), m = new Le(
8009
8063
  n,
@@ -8012,7 +8066,7 @@ function so(r, e) {
8012
8066
  d,
8013
8067
  h
8014
8068
  ));
8015
- const x = new De(n, c), w = new Zn(r.theme ?? "light", r.themeTokens), E = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w;
8069
+ const x = new De(n, c), w = new Xn(r.theme ?? "light", r.themeTokens), E = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w;
8016
8070
  return new it(
8017
8071
  t,
8018
8072
  n,
@@ -8033,5 +8087,7 @@ export {
8033
8087
  it as CROSSxSDK,
8034
8088
  to as ChainId,
8035
8089
  p as ErrorCode,
8090
+ es as PinMemoryStore,
8091
+ Zn as TokenMemoryStore,
8036
8092
  so as createCROSSxSDK
8037
8093
  };