@nexus-cross/crossx-sdk-core 3.0.0-beta.4 → 3.0.0-beta.6

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.
@@ -1,7 +1,7 @@
1
- import { createRemoteJWKSet as Ut, jwtVerify as bt, decodeJwt as Lt } from "jose";
2
- import { secp256k1 as Wt } from "@noble/curves/secp256k1.js";
3
- import { keccak_256 as Me } from "@noble/hashes/sha3.js";
4
- import { bytesToHex as Mt } from "@noble/hashes/utils.js";
1
+ import { createRemoteJWKSet as Vt, jwtVerify as $t, decodeJwt as Yt } from "jose";
2
+ import { secp256k1 as qt } from "@noble/curves/secp256k1.js";
3
+ import { keccak_256 as qe } from "@noble/hashes/sha3.js";
4
+ import { bytesToHex as jt } from "@noble/hashes/utils.js";
5
5
  var o = /* @__PURE__ */ ((i) => (i.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", i.AUTH_FAILED = "AUTH_FAILED", i.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", i.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", i.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", i.ALREADY_AUTHENTICATED = "ALREADY_AUTHENTICATED", i.SESSION_EXPIRED = "SESSION_EXPIRED", i.OAUTH_POPUP_BLOCKED = "OAUTH_POPUP_BLOCKED", i.ONEID_TERMS_NOT_AGREED = "ONEID_TERMS_NOT_AGREED", i.ONEID_ACCOUNT_NOT_FOUND = "ONEID_ACCOUNT_NOT_FOUND", i.ONEID_SERVICE_NOT_LINKED = "ONEID_SERVICE_NOT_LINKED", i.ONEID_AUTHORIZATION_FAILED = "ONEID_AUTHORIZATION_FAILED", i.ONEID_STATE_MISMATCH = "ONEID_STATE_MISMATCH", i.ONEID_ISSUER_MISMATCH = "ONEID_ISSUER_MISMATCH", i.ONEID_TIMEOUT = "ONEID_TIMEOUT", i.ONEID_SESSION_EVICTED = "ONEID_SESSION_EVICTED", i.ONEID_SESSION_REVOKED = "ONEID_SESSION_REVOKED", i.ONEID_SESSION_EXPIRED = "ONEID_SESSION_EXPIRED", i.ONEID_SESSION_INVALID = "ONEID_SESSION_INVALID", i.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", i.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", i.WALLET_ALREADY_EXISTS = "WALLET_ALREADY_EXISTS", i.ADDRESS_LIMIT_EXCEEDED = "ADDRESS_LIMIT_EXCEEDED", i.SIGN_FAILED = "SIGN_FAILED", i.SIGN_REJECTED = "SIGN_REJECTED", i.TX_FAILED = "TX_FAILED", i.TX_REJECTED = "TX_REJECTED", i.BROADCAST_FAILED = "BROADCAST_FAILED", i.USER_REJECTED = "USER_REJECTED", i.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", i.NETWORK_ERROR = "NETWORK_ERROR", i.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", i.INVALID_CHAIN = "INVALID_CHAIN", i.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", i.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", i.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", i.SIGNATURE_FAILED = "SIGNATURE_FAILED", i.TRANSACTION_FAILED = "TRANSACTION_FAILED", i.PREPARE_FAILED = "PREPARE_FAILED", i.PREPARE_EXPIRED = "PREPARE_EXPIRED", i.PREPARE_MISMATCH = "PREPARE_MISMATCH", i.MIGRATION_FAILED = "MIGRATION_FAILED", i.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", i.MIGRATION_PIN_LOCKED = "MIGRATION_PIN_LOCKED", i.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", i.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", i.WALLET_INCONSISTENT_STATE = "WALLET_INCONSISTENT_STATE", i.PROJECT_ID_MISSING = "PROJECT_ID_MISSING", i.ORIGIN_NOT_ALLOWED = "ORIGIN_NOT_ALLOWED", i.APP_IDENTIFIER_MISSING = "APP_IDENTIFIER_MISSING", i.INVALID_APP_TYPE = "INVALID_APP_TYPE", i.PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED", i.SDK_VERSION_UNSUPPORTED = "SDK_VERSION_UNSUPPORTED", i.UI_NOT_PROVIDED = "UI_NOT_PROVIDED", i.SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH", i.GAS_ESTIMATION_FAILED = "GAS_ESTIMATION_FAILED", i.EXECUTION_REVERTED = "EXECUTION_REVERTED", i.TYPED_DATA_CHAIN_ID_MISMATCH = "TYPED_DATA_CHAIN_ID_MISMATCH", i.PIN_NOT_SET = "PIN_NOT_SET", i.PIN_WRONG = "PIN_WRONG", i.PIN_INVALID = "PIN_INVALID", i.PIN_REPEATED_PATTERN = "PIN_REPEATED_PATTERN", i.PIN_CANCELLED = "PIN_CANCELLED", i.EXTERNAL_WALLET_REQUESTED = "EXTERNAL_WALLET_REQUESTED", i.PIN_LOCKED = "PIN_LOCKED", i.PIN_ENCRYPTION_INVALID = "PIN_ENCRYPTION_INVALID", i.PIN_POLICY_VIOLATION = "PIN_POLICY_VIOLATION", i.PIN_ENCRYPTION_FAILED = "PIN_ENCRYPTION_FAILED", i.HMAC_REQUIRED = "HMAC_REQUIRED", i.HMAC_VERIFICATION_FAILED = "HMAC_VERIFICATION_FAILED", i.WITHDRAW_FAILED = "WITHDRAW_FAILED", i.USER_NOT_FOUND = "USER_NOT_FOUND", i.RN_BRIDGE_NOT_AVAILABLE = "RN_BRIDGE_NOT_AVAILABLE", i.RN_BRIDGE_HANDSHAKE_FAILED = "RN_BRIDGE_HANDSHAKE_FAILED", i.RN_NATIVE_SESSION_EXPIRED = "RN_NATIVE_SESSION_EXPIRED", i.INVALID_CONFIG = "INVALID_CONFIG", i.UNKNOWN_ERROR = "UNKNOWN_ERROR", i))(o || {});
6
6
  class h extends Error {
7
7
  constructor(e, t, s) {
@@ -16,49 +16,49 @@ class h extends Error {
16
16
  };
17
17
  }
18
18
  }
19
- const Ft = 2e3, Fe = 6e4, Bt = 1e3, Gt = 1e4, Kt = "0x77359400", Be = "0x3B9ACA00", Ge = 130, ut = 6, Ke = 18, He = 3e4, Ht = 300 * 1e3, Vt = 30 * 1e3, Ve = 100, $t = 300 * 1e3, $e = 60 * 1e3, le = "crossx-sdk-js/3.0.0-beta.4", Yt = "X-SDK-Version", qt = !1, jt = "x-sdk-deprecation", de = -10050, gt = "ONEpocket";
20
- var Xt = /* @__PURE__ */ ((i) => (i.MetaMask = "io.metamask", i.Binance = "com.binance.wallet", i.CROSSx = "crossx", i))(Xt || {});
21
- const zt = {
19
+ const zt = 2e3, je = 6e4, Jt = 1e3, Xt = 1e4, Zt = "0x77359400", ze = "0x3B9ACA00", Je = 130, It = 6, Xe = 18, Ze = 3e4, Qt = 300 * 1e3, es = 30 * 1e3, Qe = 100, ts = 300 * 1e3, et = 60 * 1e3, ge = "crossx-sdk-js/3.0.0-beta.6", ss = "X-SDK-Version", rs = !1, is = "x-sdk-deprecation", fe = -10050, mt = "ONEpocket";
20
+ var ns = /* @__PURE__ */ ((i) => (i.MetaMask = "io.metamask", i.Binance = "com.binance.wallet", i.CROSSx = "crossx", i))(ns || {});
21
+ const as = {
22
22
  "io.metamask": "MetaMask",
23
23
  "com.binance.wallet": "Binance Wallet",
24
- crossx: gt
25
- }, Jt = [
24
+ crossx: mt
25
+ }, os = [
26
26
  "crossx",
27
27
  "io.metamask",
28
28
  "com.binance.wallet"
29
29
  /* Binance */
30
30
  ];
31
- function Ii(i) {
32
- return zt[i] ?? i;
31
+ function Hi(i) {
32
+ return as[i] ?? i;
33
33
  }
34
- function Zt(i) {
35
- return Array.isArray(i.connectOtherWallets) && i.connectOtherWallets.length > 0 ? [...i.connectOtherWallets] : i.showConnectOtherWallets === !0 ? [...Jt] : [];
34
+ function cs(i) {
35
+ return Array.isArray(i.connectOtherWallets) && i.connectOtherWallets.length > 0 ? [...i.connectOtherWallets] : i.showConnectOtherWallets === !0 ? [...os] : [];
36
36
  }
37
- function _t(i) {
37
+ function Tt(i) {
38
38
  const e = i instanceof Error ? i.message : String(i);
39
39
  return e.includes("BRIDGE_NOT_AUTHORIZED") || e.includes("Bridge session not authenticated");
40
40
  }
41
- const Qt = /* @__PURE__ */ new Set(["ERR_USER_REJECTED", "USER_REJECTED", "USER_REJECT"]), es = /user rejected|rejected the request|request (?:was )?cancell?ed|entry was cancell?ed|거부했습니다|취소되었습니다/i;
42
- function ft(i) {
41
+ const ls = /* @__PURE__ */ new Set(["ERR_USER_REJECTED", "USER_REJECTED", "USER_REJECT"]), hs = /user rejected|rejected the request|request (?:was )?cancell?ed|entry was cancell?ed|거부했습니다|취소되었습니다/i;
42
+ function yt(i) {
43
43
  if (!i || typeof i != "object") return;
44
44
  const e = i.code;
45
45
  return typeof e == "string" && e.length > 0 ? e : void 0;
46
46
  }
47
- function ts(i) {
48
- const e = ft(i);
49
- if (e) return Qt.has(e);
47
+ function ds(i) {
48
+ const e = yt(i);
49
+ if (e) return ls.has(e);
50
50
  const t = i instanceof Error ? i.message : String(i);
51
- return es.test(t);
51
+ return hs.test(t);
52
52
  }
53
- function q(i, e) {
53
+ function j(i, e) {
54
54
  if (i instanceof h) return i;
55
- const t = ft(i), s = i instanceof Error ? i.message : String(i), r = { nativeCode: t, cause: i };
56
- if (ts(i))
55
+ const t = yt(i), s = i instanceof Error ? i.message : String(i), r = { nativeCode: t, cause: i };
56
+ if (ds(i))
57
57
  return new h(o.USER_REJECTED, s, r);
58
58
  const n = t && !s.includes(t) ? `${s} (${t})` : s;
59
59
  return new h(e, n, r);
60
60
  }
61
- const fe = {
61
+ const Ae = {
62
62
  // ─── CROSS ────────────────────────────────────────────
63
63
  ONE_MAINNET: {
64
64
  caipId: "eip155:612055",
@@ -107,20 +107,20 @@ const fe = {
107
107
  rpcUrl: "https://saigon-testnet.roninchain.com/rpc",
108
108
  testnet: !0
109
109
  }
110
- }, mi = Object.fromEntries(
111
- Object.entries(fe).map(([i, e]) => [i, e.caipId])
112
- ), ss = new Map(
113
- Object.values(fe).map((i) => [i.caipId, i])
110
+ }, Ki = Object.fromEntries(
111
+ Object.entries(Ae).map(([i, e]) => [i, e.caipId])
112
+ ), us = new Map(
113
+ Object.values(Ae).map((i) => [i.caipId, i])
114
114
  );
115
115
  new Map(
116
- Object.values(fe).map((i) => [i.chainId, i])
116
+ Object.values(Ae).map((i) => [i.chainId, i])
117
117
  );
118
- const rs = { symbol: "", decimals: 18 };
119
- function is(i, e) {
118
+ const gs = { symbol: "", decimals: 18 };
119
+ function _s(i, e) {
120
120
  var t;
121
- return (e == null ? void 0 : e[i]) ?? ((t = ss.get(i)) == null ? void 0 : t.nativeCurrency);
121
+ return (e == null ? void 0 : e[i]) ?? ((t = us.get(i)) == null ? void 0 : t.nativeCurrency);
122
122
  }
123
- class ns {
123
+ class fs {
124
124
  constructor(e, t) {
125
125
  this.sdk = e, this.chainId = t, this._listeners = /* @__PURE__ */ new Map();
126
126
  }
@@ -217,38 +217,38 @@ class ns {
217
217
  };
218
218
  }
219
219
  }
220
- let L = null;
221
- function Ye(i) {
222
- L = i;
220
+ let W = null;
221
+ function tt(i) {
222
+ W = i;
223
223
  }
224
224
  const c = {
225
225
  /** 빌드 모드와 무관하게 항상 출력되는 정보성 로그 (SDK 수명주기 등) */
226
226
  info(...i) {
227
- if (L) {
228
- L.log(...i);
227
+ if (W) {
228
+ W.log(...i);
229
229
  return;
230
230
  }
231
231
  console.log(...i);
232
232
  },
233
233
  log(...i) {
234
- if (L) {
235
- L.log(...i);
234
+ if (W) {
235
+ W.log(...i);
236
236
  return;
237
237
  }
238
238
  },
239
239
  warn(...i) {
240
- if (L) {
241
- L.warn(...i);
240
+ if (W) {
241
+ W.warn(...i);
242
242
  return;
243
243
  }
244
244
  },
245
245
  error(...i) {
246
- if (L) {
247
- L.error(...i);
246
+ if (W) {
247
+ W.error(...i);
248
248
  return;
249
249
  }
250
250
  }
251
- }, as = {
251
+ }, ps = {
252
252
  // ── 공통 버튼 ────────────────────────────────────────────────
253
253
  confirm: "확인",
254
254
  cancel: "취소",
@@ -376,7 +376,7 @@ const c = {
376
376
  session_alert_apple_account: "Apple 계정",
377
377
  session_alert_sign_out_button: "로그아웃",
378
378
  session_alert_sign_in_again_button: "다시 로그인"
379
- }, pt = {
379
+ }, Rt = {
380
380
  // ── Common buttons ───────────────────────────────────────────
381
381
  confirm: "Confirm",
382
382
  cancel: "Cancel",
@@ -421,7 +421,7 @@ const c = {
421
421
  label_including_fees: "(including fees)",
422
422
  label_primary_type: "Primary Type",
423
423
  // ── Login selector modal ─────────────────────────────────────
424
- login_selector_title: gt,
424
+ login_selector_title: mt,
425
425
  login_selector_subtitle: "Sign in instantly with your social account",
426
426
  login_selector_google: "Sign in with Google",
427
427
  login_selector_apple: "Sign in with Apple",
@@ -503,17 +503,17 @@ For security, you must continue with the same account.`,
503
503
  session_alert_apple_account: "Apple account",
504
504
  session_alert_sign_out_button: "Sign out",
505
505
  session_alert_sign_in_again_button: "Sign in again"
506
- }, os = {
507
- ko: as,
508
- en: pt
506
+ }, ws = {
507
+ ko: ps,
508
+ en: Rt
509
509
  };
510
510
  function M(i = "en", e) {
511
- return os[i] ?? pt;
511
+ return ws[i] ?? Rt;
512
512
  }
513
- function cs(i) {
513
+ function Ss(i) {
514
514
  return i === "ko" || i === "en" ? i : typeof navigator < "u" && (navigator.language ?? "").toLowerCase().startsWith("ko") ? "ko" : "en";
515
515
  }
516
- const qe = "crossx_access_token", je = "crossx_refresh_token", Xe = "crossx_user_info", _e = class _e {
516
+ const st = "crossx_access_token", rt = "crossx_refresh_token", it = "crossx_user_info", Ee = class Ee {
517
517
  constructor(e, t, s, r, n, a, l, d, g = () => {
518
518
  }) {
519
519
  this.config = e, this.storage = t, this.crypto = s, this.oauth = r, this.transport = n, this.walletProvider = a, this.tokenStore = l, this.requestFreshTokenFromBridge = d, this.getLocale = g, this._refreshPromise = null, this._migrated = !1;
@@ -612,7 +612,7 @@ const qe = "crossx_access_token", je = "crossx_refresh_token", Xe = "crossx_user
612
612
  const r = e == null ? void 0 : e.provider;
613
613
  let n = "/login";
614
614
  r === "google" ? n = "/google" : r === "apple" && (n = "/apple");
615
- const { oauthServiceUrl: a, legacyOauthServiceUrl: l } = this.config, d = cs(this.getLocale()), g = (A) => {
615
+ const { oauthServiceUrl: a, legacyOauthServiceUrl: l } = this.config, d = Ss(this.getLocale()), g = (A) => {
616
616
  const E = `${A}${n}`, w = E.includes("?") ? "&" : "?";
617
617
  return `${E}${w}locale=${d}`;
618
618
  }, u = g(a), _ = l ? g(l) : void 0;
@@ -738,10 +738,10 @@ const qe = "crossx_access_token", je = "crossx_refresh_token", Xe = "crossx_user
738
738
  const I = await this.crypto.verifyJWT(_);
739
739
  if (r = I.signatureVerified ?? !1, !I.valid)
740
740
  throw c.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
741
- const R = I.payload, O = R.email ?? w ?? t;
741
+ const T = I.payload, O = T.email ?? w ?? t;
742
742
  c.log(
743
743
  "[CROSSx] email 소스 — CROSSx JWT:",
744
- R.email ?? "(없음)",
744
+ T.email ?? "(없음)",
745
745
  "/ Firebase JWT:",
746
746
  w ?? "(없음)",
747
747
  "/ OAuth 콜백:",
@@ -749,7 +749,7 @@ const qe = "crossx_access_token", je = "crossx_refresh_token", Xe = "crossx_user
749
749
  "→",
750
750
  O ?? "(없음)"
751
751
  ), s = {
752
- id: R.sub,
752
+ id: T.sub,
753
753
  email: O,
754
754
  signInProvider: E,
755
755
  providerSub: A
@@ -963,7 +963,7 @@ const qe = "crossx_access_token", je = "crossx_refresh_token", Xe = "crossx_user
963
963
  c.log("[CROSSx] silentRefresh 응답 — status:", a.status);
964
964
  const l = a.data, d = this.extractResponseErrorCode(l);
965
965
  if (d) {
966
- const u = _e.REFRESH_RELOGIN_CODES.has(d.code);
966
+ const u = Ee.REFRESH_RELOGIN_CODES.has(d.code);
967
967
  throw new h(
968
968
  u ? o.SESSION_EXPIRED : o.AUTH_FAILED,
969
969
  `토큰 갱신 실패 (코드 ${d.code}): ${d.message}`
@@ -1058,13 +1058,13 @@ const qe = "crossx_access_token", je = "crossx_refresh_token", Xe = "crossx_user
1058
1058
  if (!this._migrated) {
1059
1059
  this._migrated = !0;
1060
1060
  try {
1061
- const e = await this.storage.get(Xe);
1061
+ const e = await this.storage.get(it);
1062
1062
  if (!e || await this.storage.get(this.STORAGE_KEY_USER)) return;
1063
1063
  await this.storage.set(this.STORAGE_KEY_USER, e);
1064
- const s = await this.storage.get(qe);
1064
+ const s = await this.storage.get(st);
1065
1065
  s && await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, s);
1066
- const r = await this.storage.get(je);
1067
- r && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, r), await this.storage.remove(Xe), await this.storage.remove(qe), await this.storage.remove(je), c.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
1066
+ const r = await this.storage.get(rt);
1067
+ r && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, r), await this.storage.remove(it), await this.storage.remove(st), await this.storage.remove(rt), c.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
1068
1068
  } catch (e) {
1069
1069
  c.warn("[CROSSx] 스토리지 키 마이그레이션 실패:", e);
1070
1070
  }
@@ -1099,9 +1099,9 @@ const qe = "crossx_access_token", je = "crossx_refresh_token", Xe = "crossx_user
1099
1099
  return c.log("[CROSSx] loadWallet 결과 — address:", s, "needsMigration:", r), { success: !0, address: s, user: e, needsMigration: r, tokenSignatureVerified: t };
1100
1100
  }
1101
1101
  };
1102
- _e.REFRESH_RELOGIN_CODES = /* @__PURE__ */ new Set([1007, 1008]);
1103
- let Ne = _e;
1104
- class ls {
1102
+ Ee.REFRESH_RELOGIN_CODES = /* @__PURE__ */ new Set([1007, 1008]);
1103
+ let Ue = Ee;
1104
+ class Es {
1105
1105
  /**
1106
1106
  * @param preservedKeys 로그아웃 뒤에도 남길 저장소 키. 지금은 선호 지갑(`wallet_preference`)만
1107
1107
  * 쓴다 — 다시 로그인할 때 같은 지갑을 모달 없이 고르기 위해서다 (DEV2TF-2368).
@@ -1133,7 +1133,7 @@ class ls {
1133
1133
  });
1134
1134
  }
1135
1135
  }
1136
- class hs {
1136
+ class As {
1137
1137
  constructor(e, t) {
1138
1138
  this.storage = e, this.walletProvider = t;
1139
1139
  }
@@ -1150,9 +1150,13 @@ class hs {
1150
1150
  };
1151
1151
  }
1152
1152
  }
1153
- class St {
1154
- constructor() {
1155
- this.encryptedBytes = null, this.xorKey = null, this.setAt = null;
1153
+ class Nt {
1154
+ /**
1155
+ * @param options.ttlMs 주면 PIN 을 넣은 뒤 이 시간이 지나면 다음 서명을 기다리지 않고 메모리에서 지운다.
1156
+ * 재사용 정책(PinReusePolicy memory)이 더는 쓰지 않을 PIN 을 들고 있지 않게 한다 (DEV2TF-2912 AC-7).
1157
+ */
1158
+ constructor(e = {}) {
1159
+ this.options = e, this.encryptedBytes = null, this.xorKey = null, this.setAt = null, this.expiryTimer = null, this.holds = 0, this.expiredWhileHeld = !1;
1156
1160
  }
1157
1161
  /**
1158
1162
  * PIN을 메모리에 암호화하여 저장합니다.
@@ -1163,9 +1167,29 @@ class St {
1163
1167
  const t = new TextEncoder().encode(e), s = new Uint8Array(t.length);
1164
1168
  crypto.getRandomValues(s);
1165
1169
  const r = new Uint8Array(t.length);
1166
- for (let n = 0; n < t.length; n++)
1167
- r[n] = t[n] ^ s[n];
1170
+ for (let a = 0; a < t.length; a++)
1171
+ r[a] = t[a] ^ s[a];
1168
1172
  t.fill(0), this.xorKey = s, this.encryptedBytes = r, this.setAt = Date.now();
1173
+ const { ttlMs: n } = this.options;
1174
+ n !== void 0 && n > 0 && (this.expiryTimer = setTimeout(() => this.expire(), n));
1175
+ }
1176
+ /**
1177
+ * 서명을 시작할 때 부른다. {@link release} 전까지 재사용 시간이 지나도 PIN 을 지우지 않는다 —
1178
+ * 확인을 누른 뒤 서명 요청 직전에 PIN 이 사라져 `PIN_NOT_SET` 으로 실패하지 않게 한다.
1179
+ */
1180
+ hold() {
1181
+ this.holds++;
1182
+ }
1183
+ /** 서명이 끝나면 부른다. 도중에 재사용 시간이 지났으면 이제 지운다. */
1184
+ release() {
1185
+ this.holds > 0 && this.holds--, this.holds === 0 && this.expiredWhileHeld && this.clear();
1186
+ }
1187
+ expire() {
1188
+ if (this.expiryTimer = null, this.holds > 0) {
1189
+ this.expiredWhileHeld = !0;
1190
+ return;
1191
+ }
1192
+ this.clear();
1169
1193
  }
1170
1194
  /**
1171
1195
  * 저장된 PIN을 복호화하여 반환합니다. 없으면 null.
@@ -1184,7 +1208,7 @@ class St {
1184
1208
  */
1185
1209
  clear() {
1186
1210
  var e, t;
1187
- (e = this.encryptedBytes) == null || e.fill(0), (t = this.xorKey) == null || t.fill(0), this.encryptedBytes = null, this.xorKey = null, this.setAt = null;
1211
+ this.expiryTimer !== null && clearTimeout(this.expiryTimer), this.expiryTimer = null, this.expiredWhileHeld = !1, (e = this.encryptedBytes) == null || e.fill(0), (t = this.xorKey) == null || t.fill(0), this.encryptedBytes = null, this.xorKey = null, this.setAt = null;
1188
1212
  }
1189
1213
  /** PIN 을 넣은 시각 (ms). 없으면 null. */
1190
1214
  getSetAt() {
@@ -1195,26 +1219,156 @@ class St {
1195
1219
  return this.encryptedBytes !== null;
1196
1220
  }
1197
1221
  }
1198
- const ds = "/authorize/result", us = "one-oauth:authorization_response", wt = "one-oauth:authorization_error", gs = "one-oauth:authorization_ack", _s = "openid profile offline_access";
1199
- function De(i) {
1222
+ const Is = "/authorize/result", ms = "one-oauth:authorization_response", Ot = "one-oauth:authorization_error", Ts = "one-oauth:authorization_ack", ys = "openid profile offline_access";
1223
+ function Fe(i) {
1200
1224
  let e = "";
1201
1225
  for (const t of i) e += String.fromCharCode(t);
1202
1226
  return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1203
1227
  }
1204
- function ze(i = 32) {
1228
+ function ye(i = 32) {
1205
1229
  const e = new Uint8Array(i);
1206
- return crypto.getRandomValues(e), De(e);
1230
+ return crypto.getRandomValues(e), Fe(e);
1207
1231
  }
1208
- async function Je(i) {
1232
+ async function Re(i) {
1209
1233
  const e = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(i));
1210
- return De(new Uint8Array(e));
1234
+ return Fe(new Uint8Array(e));
1211
1235
  }
1212
- function ie(i = 16) {
1236
+ function Y(i = 16) {
1213
1237
  const e = new Uint8Array(i);
1214
- return crypto.getRandomValues(e), De(e);
1238
+ return crypto.getRandomValues(e), Fe(e);
1239
+ }
1240
+ const Rs = "onepocketSecureFrame", Be = 1;
1241
+ function ae() {
1242
+ return new h(o.USER_REJECTED, "앱 요청을 중단했습니다");
1243
+ }
1244
+ let nt = 0;
1245
+ function pe() {
1246
+ return nt += 1, `${typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : String(Math.random())}-${nt}`;
1247
+ }
1248
+ function Ns(i) {
1249
+ return i === "cancelled" ? o.USER_REJECTED : o.ONEID_AUTHORIZATION_FAILED;
1250
+ }
1251
+ function Pt(i, e) {
1252
+ var r, n;
1253
+ let t = e;
1254
+ if (typeof e == "string")
1255
+ try {
1256
+ t = JSON.parse(e);
1257
+ } catch {
1258
+ t = null;
1259
+ }
1260
+ const s = typeof t == "object" && t !== null ? t : {};
1261
+ if (s.v !== void 0 && s.v !== Be)
1262
+ throw new h(o.ONEID_AUTHORIZATION_FAILED, "앱 채널 버전이 다릅니다", { appError: "unsupported" });
1263
+ if (s.id !== i)
1264
+ throw new h(o.ONEID_AUTHORIZATION_FAILED, "앱 응답의 요청 id 가 다릅니다");
1265
+ if (s.ok !== !0) {
1266
+ const a = (r = s.error) == null ? void 0 : r.code, l = typeof ((n = s.error) == null ? void 0 : n.message) == "string" && s.error.message ? s.error.message : "앱이 요청을 처리하지 못했습니다";
1267
+ throw new h(Ns(a), l, { appError: typeof a == "string" ? a : "unknown" });
1268
+ }
1269
+ return typeof s.payload == "object" && s.payload !== null ? s.payload : {};
1270
+ }
1271
+ function Os(i, e) {
1272
+ return new Promise((t, s) => {
1273
+ const r = () => s(ae());
1274
+ e.addEventListener("abort", r, { once: !0 }), Promise.resolve(i).then(
1275
+ (n) => {
1276
+ e.removeEventListener("abort", r), t(n);
1277
+ },
1278
+ (n) => {
1279
+ e.removeEventListener("abort", r), s(n);
1280
+ }
1281
+ );
1282
+ });
1283
+ }
1284
+ function Ps(i) {
1285
+ const e = (t, s, r) => i.postMessage({ v: Be, id: r, type: t, payload: s });
1286
+ return {
1287
+ async request(t, s, r) {
1288
+ if (r != null && r.aborted) throw ae();
1289
+ const n = pe();
1290
+ let a;
1291
+ try {
1292
+ a = await (r ? Os(e(t, s, n), r) : e(t, s, n));
1293
+ } catch (l) {
1294
+ throw r != null && r.aborted ? ae() : new h(o.ONEID_AUTHORIZATION_FAILED, "앱이 요청을 거부했습니다", l);
1295
+ }
1296
+ if (a === void 0)
1297
+ throw new h(o.ONEID_AUTHORIZATION_FAILED, "앱이 이 요청을 지원하지 않습니다", { appError: "unsupported" });
1298
+ return Pt(n, a);
1299
+ },
1300
+ notify(t, s) {
1301
+ Promise.resolve(e(t, s, pe())).catch(() => {
1302
+ });
1303
+ }
1304
+ };
1305
+ }
1306
+ function Cs(i) {
1307
+ const e = /* @__PURE__ */ new Map();
1308
+ i.onmessage = (s) => {
1309
+ var a;
1310
+ let r;
1311
+ try {
1312
+ r = (a = typeof s.data == "string" ? JSON.parse(s.data) : s.data) == null ? void 0 : a.id;
1313
+ } catch {
1314
+ return;
1315
+ }
1316
+ if (typeof r != "string") return;
1317
+ const n = e.get(r);
1318
+ n && (e.delete(r), n(s.data));
1319
+ };
1320
+ const t = (s, r, n) => i.postMessage(JSON.stringify({ v: Be, id: n, type: s, payload: r }));
1321
+ return {
1322
+ request(s, r, n) {
1323
+ const a = pe();
1324
+ return new Promise((l, d) => {
1325
+ if (n != null && n.aborted) {
1326
+ d(ae());
1327
+ return;
1328
+ }
1329
+ const g = () => {
1330
+ e.delete(a), d(ae());
1331
+ };
1332
+ n == null || n.addEventListener("abort", g, { once: !0 }), e.set(a, (u) => {
1333
+ n == null || n.removeEventListener("abort", g);
1334
+ try {
1335
+ l(Pt(a, u));
1336
+ } catch (_) {
1337
+ d(_);
1338
+ }
1339
+ });
1340
+ try {
1341
+ t(s, r, a);
1342
+ } catch (u) {
1343
+ e.delete(a), n == null || n.removeEventListener("abort", g), d(new h(o.ONEID_AUTHORIZATION_FAILED, "앱에 요청을 보내지 못했습니다", u));
1344
+ }
1345
+ });
1346
+ },
1347
+ notify(s, r) {
1348
+ try {
1349
+ t(s, r, pe());
1350
+ } catch {
1351
+ }
1352
+ }
1353
+ };
1215
1354
  }
1216
- const fs = 300 * 1e3, ps = 600 * 1e3, Ee = "crossx.oneid.pending", Ss = 1e3, ws = 10;
1217
- function Ze(i) {
1355
+ function Ds(i = typeof window < "u" ? window : void 0) {
1356
+ var r, n;
1357
+ if (!i) return null;
1358
+ const e = i;
1359
+ if (e.self === e.top) return null;
1360
+ const t = (n = (r = e.webkit) == null ? void 0 : r.messageHandlers) == null ? void 0 : n[Rs];
1361
+ if (t && typeof t.postMessage == "function") return ot(t, () => Ps(t));
1362
+ const s = e.onepocketSecureFrame;
1363
+ return s && typeof s.postMessage == "function" ? ot(s, () => Cs(s)) : null;
1364
+ }
1365
+ const at = /* @__PURE__ */ new WeakMap();
1366
+ function ot(i, e) {
1367
+ let t = at.get(i);
1368
+ return t || (t = e(), at.set(i, t)), t;
1369
+ }
1370
+ const ct = 300 * 1e3, xs = 600 * 1e3, Ne = "crossx.oneid.pending", vs = "/auth/app-callback", ks = 1e3;
1371
+ function Ct(i) {
1218
1372
  switch (i) {
1219
1373
  case "access_denied":
1220
1374
  return o.USER_REJECTED;
@@ -1228,7 +1382,7 @@ function Ze(i) {
1228
1382
  return o.ONEID_AUTHORIZATION_FAILED;
1229
1383
  }
1230
1384
  }
1231
- function Es(i) {
1385
+ function Us(i) {
1232
1386
  switch (i) {
1233
1387
  case "session_evicted":
1234
1388
  return o.ONEID_SESSION_EVICTED;
@@ -1240,11 +1394,25 @@ function Es(i) {
1240
1394
  return o.ONEID_SESSION_INVALID;
1241
1395
  }
1242
1396
  }
1243
- function Ae(i) {
1244
- if (!(typeof i != "string" || !i.startsWith("/")) && !(i.startsWith("//") || i.startsWith("/\\")))
1245
- return i;
1397
+ const bs = 15 * 1e3;
1398
+ function Ls(i) {
1399
+ return typeof AbortSignal < "u" && typeof AbortSignal.timeout == "function" ? AbortSignal.timeout(i) : void 0;
1246
1400
  }
1247
- function j(i) {
1401
+ const Ws = 300 * 1e3, oe = "https://return-to.invalid";
1402
+ function ce(i) {
1403
+ if (typeof i != "string" || !i.startsWith("/") || /[\u0000-\u001f\u007f\\]/.test(i)) return;
1404
+ let e;
1405
+ try {
1406
+ e = new URL(i, oe);
1407
+ } catch {
1408
+ return;
1409
+ }
1410
+ if (e.origin !== oe) return;
1411
+ const t = `${e.pathname}${e.search}${e.hash}`;
1412
+ if (!(t.startsWith("//") || new URL(t, oe).origin !== oe))
1413
+ return t;
1414
+ }
1415
+ function z(i) {
1248
1416
  let e;
1249
1417
  try {
1250
1418
  e = new URL(i);
@@ -1253,7 +1421,7 @@ function j(i) {
1253
1421
  }
1254
1422
  return e.toString().replace(/\/+$/, "");
1255
1423
  }
1256
- function Et(i) {
1424
+ function Dt(i) {
1257
1425
  const e = i.split(".")[1];
1258
1426
  if (!e) return null;
1259
1427
  try {
@@ -1265,12 +1433,34 @@ function Et(i) {
1265
1433
  return null;
1266
1434
  }
1267
1435
  }
1268
- function As(i) {
1436
+ function Ms(i) {
1437
+ return { get: (e) => typeof i[e] == "string" ? i[e] : null };
1438
+ }
1439
+ function lt(i, e, t) {
1440
+ const s = i.get("state");
1441
+ if (!s || s !== e)
1442
+ throw new h(o.ONEID_STATE_MISMATCH, "ONE ID 로그인 결과의 state가 다릅니다");
1443
+ if (i.get("iss") !== t)
1444
+ throw new h(o.ONEID_ISSUER_MISMATCH, "ONE ID 로그인 결과의 발급자가 다릅니다");
1445
+ const r = i.get("error");
1446
+ if (r) {
1447
+ const a = i.get("error_description") ?? void 0;
1448
+ throw new h(Ct(r), a || `ONE ID 인가 오류: ${r}`, {
1449
+ error: r,
1450
+ error_description: a
1451
+ });
1452
+ }
1453
+ const n = i.get("code");
1454
+ if (!n)
1455
+ throw new h(o.ONEID_AUTHORIZATION_FAILED, "ONE ID 로그인 결과에 code가 없습니다");
1456
+ return n;
1457
+ }
1458
+ function Fs(i) {
1269
1459
  if (typeof i != "object" || i === null) return !1;
1270
1460
  const e = i.type;
1271
- return e === us || e === wt;
1461
+ return e === ms || e === Ot;
1272
1462
  }
1273
- function Qe(i, e) {
1463
+ function ht(i, e) {
1274
1464
  if (typeof i.access_token != "string" || i.access_token === "")
1275
1465
  throw new h(o.ONEID_AUTHORIZATION_FAILED, "토큰 응답에 access_token이 없습니다");
1276
1466
  const t = typeof i.expires_in == "number" ? i.expires_in : 0;
@@ -1283,7 +1473,7 @@ function Qe(i, e) {
1283
1473
  scope: typeof i.scope == "string" ? i.scope : void 0
1284
1474
  };
1285
1475
  }
1286
- class Is {
1476
+ class Bs {
1287
1477
  constructor() {
1288
1478
  this.reason = null, this.onAbort = null;
1289
1479
  }
@@ -1296,7 +1486,7 @@ class Is {
1296
1486
  throw new h(o.USER_REJECTED, this.reason);
1297
1487
  }
1298
1488
  }
1299
- class ms {
1489
+ class Gs {
1300
1490
  constructor(e = {}) {
1301
1491
  this.abortPending = null, this.popupSeq = 0, this.options = e;
1302
1492
  }
@@ -1315,67 +1505,53 @@ class ms {
1315
1505
  (t = this.abortPending) == null || t.call(this, e);
1316
1506
  }
1317
1507
  async authorize(e) {
1318
- let t = null;
1319
- if (e.mode !== "redirect" && (t = this.openBlankPopup(e.width, e.height), !t && e.mode === "popup"))
1508
+ const t = e.mode !== "redirect" ? this.findAppChannel() : null;
1509
+ let s = null;
1510
+ if (e.mode !== "redirect" && !t && (s = this.openBlankPopup(e.width, e.height), !s && e.mode === "popup"))
1320
1511
  throw new h(
1321
1512
  o.OAUTH_POPUP_BLOCKED,
1322
1513
  "팝업 창을 열 수 없습니다. 팝업 차단을 해제해 주세요."
1323
1514
  );
1324
1515
  try {
1325
- const s = j(e.issuer);
1516
+ const r = z(e.issuer);
1326
1517
  if (!e.clientId)
1327
1518
  throw new h(o.INVALID_CONFIG, "ONE ID clientId가 비어 있습니다");
1328
1519
  this.cancelPending("새 ONE ID 로그인 요청으로 이전 대기를 중단했습니다");
1329
- const r = new Is(), n = (a) => r.abort(a);
1330
- this.abortPending = n;
1520
+ const n = new Bs(), a = (l) => n.abort(l);
1521
+ this.abortPending = a;
1331
1522
  try {
1332
- return t ? await this.authorizeWithPopup(t, { ...e, issuer: s }, r) : await this.authorizeWithRedirect({ ...e, issuer: s }, r);
1523
+ return t ? await this.authorizeWithApp(t, { ...e, issuer: r }, n) : s ? await this.authorizeWithPopup(s, { ...e, issuer: r }, n) : await this.authorizeWithRedirect({ ...e, issuer: r }, n);
1333
1524
  } finally {
1334
- this.abortPending === n && (this.abortPending = null);
1525
+ this.abortPending === a && (this.abortPending = null);
1335
1526
  }
1336
- } catch (s) {
1527
+ } catch (r) {
1337
1528
  try {
1338
- t == null || t.close();
1529
+ s == null || s.close();
1339
1530
  } catch {
1340
1531
  }
1341
- throw s;
1532
+ throw r;
1342
1533
  }
1343
1534
  }
1344
1535
  async completeRedirect(e, t) {
1345
- const s = j(e.issuer), r = this.takePending(), n = new URL(t).searchParams;
1536
+ const s = z(e.issuer), r = this.takePending(), n = new URL(t).searchParams;
1346
1537
  if (!r || r.issuer !== s || r.clientId !== e.clientId)
1347
1538
  throw new h(
1348
1539
  o.ONEID_STATE_MISMATCH,
1349
1540
  "진행 중인 ONE ID 로그인이 없습니다. 다시 로그인해 주세요."
1350
1541
  );
1351
- if (this.now() - r.createdAt > ps)
1542
+ if (this.now() - r.createdAt > xs)
1352
1543
  throw new h(o.ONEID_TIMEOUT, "ONE ID 로그인 시간이 지났습니다");
1353
- const a = n.get("state");
1354
- if (!a || a !== r.state)
1355
- throw new h(o.ONEID_STATE_MISMATCH, "ONE ID 로그인 결과의 state가 다릅니다");
1356
- if (n.get("iss") !== s)
1357
- throw new h(o.ONEID_ISSUER_MISMATCH, "ONE ID 로그인 결과의 발급자가 다릅니다");
1358
- const l = n.get("error");
1359
- if (l) {
1360
- const u = n.get("error_description") ?? void 0;
1361
- throw new h(Ze(l), u || `ONE ID 인가 오류: ${l}`, {
1362
- error: l,
1363
- error_description: u
1364
- });
1365
- }
1366
- const d = n.get("code");
1367
- if (!d)
1368
- throw new h(o.ONEID_AUTHORIZATION_FAILED, "ONE ID 로그인 결과에 code가 없습니다");
1544
+ const a = lt(n, r.state, s);
1369
1545
  return { tokens: await this.exchangeCode(
1370
1546
  { ...e, issuer: s },
1371
- d,
1547
+ a,
1372
1548
  r.codeVerifier,
1373
1549
  r.redirectUri,
1374
1550
  r.nonce
1375
- ), returnTo: Ae(r.returnTo) };
1551
+ ), returnTo: ce(r.returnTo) };
1376
1552
  }
1377
1553
  async refresh(e, t) {
1378
- const s = j(e.issuer), r = new URLSearchParams({
1554
+ const s = z(e.issuer), r = new URLSearchParams({
1379
1555
  grant_type: "refresh_token",
1380
1556
  client_id: e.clientId,
1381
1557
  refresh_token: t
@@ -1385,16 +1561,18 @@ class ms {
1385
1561
  n = await this.fetchImpl(`${s}/token`, {
1386
1562
  method: "POST",
1387
1563
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1388
- body: r
1564
+ body: r,
1565
+ // refresh 는 탭 사이 잠금을 쥔 채 기다린다 — 응답이 안 오면 다른 탭까지 멈추므로 끊는다 (DEV2TF-2912)
1566
+ signal: Ls(bs)
1389
1567
  });
1390
1568
  } catch (d) {
1391
1569
  throw new h(o.NETWORK_ERROR, "ONE ID 세션을 갱신하지 못했습니다", d);
1392
1570
  }
1393
- const a = await Ie(n);
1571
+ const a = await Oe(n);
1394
1572
  if (!n.ok) {
1395
1573
  if (n.status === 400 && a.error === "invalid_grant") {
1396
1574
  const d = typeof a.error_reason == "string" ? a.error_reason : void 0;
1397
- throw new h(Es(d), "ONE ID 세션이 끝났습니다. 다시 로그인해 주세요.", {
1575
+ throw new h(Us(d), "ONE ID 세션이 끝났습니다. 다시 로그인해 주세요.", {
1398
1576
  error: "invalid_grant",
1399
1577
  error_reason: d
1400
1578
  });
@@ -1407,11 +1585,11 @@ class ms {
1407
1585
  error: a.error
1408
1586
  });
1409
1587
  }
1410
- const l = Qe(a, this.now());
1588
+ const l = ht(a, this.now());
1411
1589
  return { ...l, refreshToken: l.refreshToken ?? t };
1412
1590
  }
1413
1591
  async logout(e, t) {
1414
- const s = j(e.issuer);
1592
+ const s = z(e.issuer);
1415
1593
  let r;
1416
1594
  try {
1417
1595
  r = await this.fetchImpl(`${s}/logout`, {
@@ -1427,6 +1605,36 @@ class ms {
1427
1605
  });
1428
1606
  }
1429
1607
  // ─── 내부 ───────────────────────────────────────────────
1608
+ findAppChannel() {
1609
+ return this.options.appChannel !== void 0 ? this.options.appChannel : Ds();
1610
+ }
1611
+ /**
1612
+ * 원포켓 앱에 인증을 맡긴다 (docs/30 §5). PAR · 토큰 교환은 이 페이지(보안 화면 origin)에서 하고,
1613
+ * 앱은 인증 화면을 열어 결과만 돌려준다. PKCE verifier 는 이 함수 밖으로 나가지 않는다.
1614
+ */
1615
+ async authorizeWithApp(e, t, s) {
1616
+ const r = `${window.location.origin}${vs}`, n = Y(), a = Y(), l = ye(), d = await Re(l), g = await this.pushAuthorizationRequest(t, r, n, a, d);
1617
+ s.throwIfAborted(), c.log("[CROSSx] ONE ID 로그인 — 원포켓 앱 인증 화면", { issuer: t.issuer, clientId: t.clientId });
1618
+ const u = this.authorizeUrl(t, g), _ = await new Promise((E, w) => {
1619
+ let f = !1;
1620
+ const S = new AbortController(), I = (y) => {
1621
+ f || (f = !0, s.onAbort = null, clearTimeout(O), S.abort(), y());
1622
+ }, T = () => e.notify("oneid.cancel", {}), O = setTimeout(() => {
1623
+ I(() => {
1624
+ T(), w(new h(o.ONEID_TIMEOUT, "ONE ID 로그인 응답 시간이 지났습니다"));
1625
+ });
1626
+ }, ct);
1627
+ s.onAbort = (y) => {
1628
+ I(() => {
1629
+ T(), w(new h(o.USER_REJECTED, y));
1630
+ });
1631
+ }, e.request("oneid.authorize", { authorizeUrl: u, state: n }, S.signal).then(
1632
+ (y) => I(() => E(y)),
1633
+ (y) => I(() => w(y))
1634
+ );
1635
+ }), p = lt(Ms(_), n, t.issuer), A = await this.exchangeCode(t, p, l, r, a);
1636
+ return c.log("[CROSSx] ONE ID 로그인 완료 (원포켓 앱)"), { status: "completed", tokens: A, returnTo: ce(t.returnTo) };
1637
+ }
1430
1638
  openBlankPopup(e = 500, t = 700) {
1431
1639
  const s = Math.max(e, 500), r = Math.max(t, 700), n = window.screenX + (window.outerWidth - s) / 2, a = window.screenY + (window.outerHeight - r) / 2;
1432
1640
  try {
@@ -1441,7 +1649,7 @@ class ms {
1441
1649
  client_id: e.clientId,
1442
1650
  response_type: "code",
1443
1651
  redirect_uri: t,
1444
- scope: e.scope ?? _s,
1652
+ scope: e.scope ?? ys,
1445
1653
  state: s,
1446
1654
  nonce: r,
1447
1655
  code_challenge: n,
@@ -1457,7 +1665,7 @@ class ms {
1457
1665
  } catch (g) {
1458
1666
  throw new h(o.NETWORK_ERROR, "ONE ID 로그인 요청을 보내지 못했습니다", g);
1459
1667
  }
1460
- const d = await Ie(l);
1668
+ const d = await Oe(l);
1461
1669
  if (!l.ok || typeof d.request_uri != "string")
1462
1670
  throw new h(o.ONEID_AUTHORIZATION_FAILED, "ONE ID 로그인 요청이 거부되었습니다", {
1463
1671
  status: l.status,
@@ -1487,90 +1695,91 @@ class ms {
1487
1695
  } catch (u) {
1488
1696
  throw new h(o.NETWORK_ERROR, "ONE ID 토큰을 받지 못했습니다", u);
1489
1697
  }
1490
- const d = await Ie(l);
1698
+ const d = await Oe(l);
1491
1699
  if (!l.ok)
1492
1700
  throw new h(o.ONEID_AUTHORIZATION_FAILED, "ONE ID 토큰 교환이 거부되었습니다", {
1493
1701
  status: l.status,
1494
1702
  error: d.error
1495
1703
  });
1496
- const g = Qe(d, this.now());
1704
+ const g = ht(d, this.now());
1497
1705
  if (g.idToken) {
1498
- const u = Et(g.idToken);
1706
+ const u = Dt(g.idToken);
1499
1707
  if (!u || u.iss !== e.issuer || u.nonce !== n)
1500
1708
  throw new h(o.ONEID_ISSUER_MISMATCH, "ONE ID id_token의 발급자나 nonce가 요청과 다릅니다");
1709
+ const _ = u.aud, p = _ === e.clientId || Array.isArray(_) && _.includes(e.clientId), A = typeof u.exp == "number" ? u.exp * 1e3 : Number.NaN;
1710
+ if (!p || !(A + Ws > this.now()))
1711
+ throw new h(o.ONEID_ISSUER_MISMATCH, "ONE ID id_token의 대상이 이 앱이 아니거나 만료되었습니다");
1501
1712
  }
1502
1713
  return g;
1503
1714
  }
1504
1715
  async authorizeWithPopup(e, t, s) {
1505
- const r = new URL(t.issuer).origin, n = `${t.issuer}${ds}`, a = ie(), l = ie(), d = ze(), g = await Je(d), u = await this.pushAuthorizationRequest(t, n, a, l, g);
1716
+ const r = new URL(t.issuer).origin, n = `${t.issuer}${Is}`, a = Y(), l = Y(), d = ye(), g = await Re(d), u = await this.pushAuthorizationRequest(t, n, a, l, g);
1506
1717
  s.throwIfAborted(), c.log("[CROSSx] ONE ID 로그인 팝업 이동", { issuer: t.issuer, clientId: t.clientId }), e.location.href = this.authorizeUrl(t, u);
1507
1718
  const _ = await new Promise((A, E) => {
1508
- let w = 0, f = !0;
1719
+ let w = 0, f = 0;
1509
1720
  const S = () => {
1510
- s.onAbort = null, clearTimeout(R), clearInterval(O), window.removeEventListener("message", C);
1511
- }, I = (N) => {
1512
- S(), E(N);
1513
- }, R = setTimeout(() => {
1721
+ s.onAbort = null, clearTimeout(T), clearInterval(O), window.removeEventListener("message", y);
1722
+ }, I = (R) => {
1723
+ S(), E(R);
1724
+ }, T = setTimeout(() => {
1514
1725
  I(new h(o.ONEID_TIMEOUT, "ONE ID 로그인 응답 시간이 지났습니다"));
1515
- }, fs), O = setInterval(() => {
1516
- if (!f) return;
1517
- w++;
1518
- let N;
1726
+ }, ct), O = setInterval(() => {
1727
+ f++;
1728
+ let R;
1519
1729
  try {
1520
- N = e.closed;
1730
+ R = e.closed;
1521
1731
  } catch {
1522
- f = !1;
1523
1732
  return;
1524
1733
  }
1525
- if (!N) return;
1526
- const m = typeof document < "u" && document.hasFocus();
1527
- if (w <= ws && !m) {
1528
- c.warn("[CROSSx] ONE ID 팝업 closed 오탐 가능성(COOP) — 결과 대기 유지"), f = !1;
1529
- return;
1734
+ if (R) {
1735
+ if (w === 0) {
1736
+ w = f;
1737
+ return;
1738
+ }
1739
+ c.warn("[CROSSx] ONE ID 팝업이 닫혔거나 연결이 끊겼습니다(COOP) — 로그인을 취소합니다"), I(new h(o.USER_REJECTED, "ONE ID 로그인이 취소되었습니다", { reason: "popup_closed_or_detached" }));
1530
1740
  }
1531
- I(new h(o.USER_REJECTED, "ONE ID 로그인이 취소되었습니다"));
1532
- }, Ss), C = (N) => {
1533
- if (N.origin !== r || N.source !== e || !As(N.data)) return;
1534
- const m = N.data;
1535
- if (m.state !== a) {
1741
+ }, ks), y = (R) => {
1742
+ if (R.origin !== r || R.source !== e || !Fs(R.data)) return;
1743
+ const N = R.data;
1744
+ if (N.state !== a) {
1536
1745
  c.warn("[CROSSx] ONE ID 결과 state가 현재 요청과 달라 무시합니다");
1537
1746
  return;
1538
1747
  }
1539
1748
  try {
1540
- e.postMessage({ type: gs, state: a }, r);
1749
+ e.postMessage({ type: Ts, state: a }, r);
1541
1750
  } catch {
1542
1751
  }
1543
- if (m.iss !== t.issuer) {
1752
+ if (N.iss !== t.issuer) {
1544
1753
  I(new h(o.ONEID_ISSUER_MISMATCH, "ONE ID 로그인 결과의 발급자가 다릅니다"));
1545
1754
  return;
1546
1755
  }
1547
- if (m.type === wt || m.error) {
1548
- const v = m.error ?? "unknown_error";
1549
- c.warn("[CROSSx] ONE ID 인가 오류:", v), I(
1550
- new h(Ze(v), m.error_description || `ONE ID 인가 오류: ${v}`, {
1551
- error: v,
1552
- error_description: m.error_description
1756
+ if (N.type === Ot || N.error) {
1757
+ const D = N.error ?? "unknown_error";
1758
+ c.warn("[CROSSx] ONE ID 인가 오류:", D), I(
1759
+ new h(Ct(D), N.error_description || `ONE ID 인가 오류: ${D}`, {
1760
+ error: D,
1761
+ error_description: N.error_description
1553
1762
  })
1554
1763
  );
1555
1764
  return;
1556
1765
  }
1557
- if (!m.code) {
1766
+ if (!N.code) {
1558
1767
  I(new h(o.ONEID_AUTHORIZATION_FAILED, "ONE ID 로그인 결과에 code가 없습니다"));
1559
1768
  return;
1560
1769
  }
1561
- S(), A(m.code);
1770
+ S(), A(N.code);
1562
1771
  };
1563
- s.onAbort = (N) => {
1564
- I(new h(o.USER_REJECTED, N));
1565
- }, window.addEventListener("message", C);
1772
+ s.onAbort = (R) => {
1773
+ I(new h(o.USER_REJECTED, R));
1774
+ }, window.addEventListener("message", y);
1566
1775
  }), p = await this.exchangeCode(t, _, d, n, l);
1567
- return c.log("[CROSSx] ONE ID 로그인 완료 (팝업)"), { status: "completed", tokens: p, returnTo: Ae(t.returnTo) };
1776
+ return c.log("[CROSSx] ONE ID 로그인 완료 (팝업)"), { status: "completed", tokens: p, returnTo: ce(t.returnTo) };
1568
1777
  }
1569
1778
  async authorizeWithRedirect(e, t) {
1570
1779
  const s = e.redirectUri ?? `${window.location.origin}/auth/callback`;
1571
1780
  if (new URL(s).origin !== window.location.origin)
1572
1781
  throw new h(o.INVALID_CONFIG, "ONE ID redirectUri는 지금 페이지와 같은 origin이어야 합니다");
1573
- const r = ie(), n = ie(), a = ze(), l = await Je(a), d = await this.pushAuthorizationRequest(e, s, r, n, l);
1782
+ const r = Y(), n = Y(), a = ye(), l = await Re(a), d = await this.pushAuthorizationRequest(e, s, r, n, l);
1574
1783
  t.throwIfAborted();
1575
1784
  const g = {
1576
1785
  issuer: e.issuer,
@@ -1579,17 +1788,17 @@ class ms {
1579
1788
  nonce: n,
1580
1789
  codeVerifier: a,
1581
1790
  redirectUri: s,
1582
- returnTo: Ae(e.returnTo),
1791
+ returnTo: ce(e.returnTo),
1583
1792
  createdAt: this.now()
1584
1793
  };
1585
- this.pendingStorage.setItem(Ee, JSON.stringify(g)), c.log("[CROSSx] ONE ID 로그인 같은 창 이동", { issuer: e.issuer, clientId: e.clientId });
1794
+ this.pendingStorage.setItem(Ne, JSON.stringify(g)), c.log("[CROSSx] ONE ID 로그인 같은 창 이동", { issuer: e.issuer, clientId: e.clientId });
1586
1795
  const u = this.authorizeUrl(e, d);
1587
1796
  return (this.options.navigate ?? ((_) => window.location.assign(_)))(u), { status: "redirecting" };
1588
1797
  }
1589
1798
  /** 진행 정보를 꺼내고 지운다 (한 번만 쓴다) */
1590
1799
  takePending() {
1591
- const e = this.pendingStorage.getItem(Ee);
1592
- if (this.pendingStorage.removeItem(Ee), !e) return null;
1800
+ const e = this.pendingStorage.getItem(Ne);
1801
+ if (this.pendingStorage.removeItem(Ne), !e) return null;
1593
1802
  try {
1594
1803
  const t = JSON.parse(e);
1595
1804
  return typeof (t == null ? void 0 : t.state) == "string" && typeof t.codeVerifier == "string" ? t : null;
@@ -1598,7 +1807,7 @@ class ms {
1598
1807
  }
1599
1808
  }
1600
1809
  }
1601
- async function Ie(i) {
1810
+ async function Oe(i) {
1602
1811
  try {
1603
1812
  const e = await i.json();
1604
1813
  return typeof e == "object" && e !== null ? e : {};
@@ -1606,16 +1815,21 @@ async function Ie(i) {
1606
1815
  return {};
1607
1816
  }
1608
1817
  }
1609
- const ne = "crossx.oneid.session", et = 60 * 1e3, Oe = /* @__PURE__ */ new Set([
1818
+ const le = "crossx.oneid.session", Pe = 60 * 1e3, be = /* @__PURE__ */ new Set([
1610
1819
  o.ONEID_SESSION_EVICTED,
1611
1820
  o.ONEID_SESSION_REVOKED,
1612
1821
  o.ONEID_SESSION_EXPIRED,
1613
1822
  o.ONEID_SESSION_INVALID
1614
1823
  ]);
1615
- function tt(i) {
1616
- return i instanceof h && Oe.has(i.code);
1824
+ function Ce(i) {
1825
+ return i instanceof h && be.has(i.code);
1617
1826
  }
1618
- class Ts {
1827
+ const Hs = "crossx.oneid.refresh";
1828
+ function Ks(i) {
1829
+ const e = typeof navigator < "u" ? navigator.locks : void 0;
1830
+ return e ? e.request(Hs, i) : i();
1831
+ }
1832
+ class Vs {
1619
1833
  constructor(e, t, s, r = () => Date.now()) {
1620
1834
  this.port = e, this.config = t, this.storage = s, this.now = r, this.refreshing = null, this.generation = 0;
1621
1835
  }
@@ -1623,11 +1837,11 @@ class Ts {
1623
1837
  save(e) {
1624
1838
  this.generation += 1;
1625
1839
  const t = {
1626
- issuer: j(this.config.issuer),
1840
+ issuer: z(this.config.issuer),
1627
1841
  clientId: this.config.clientId,
1628
1842
  tokens: e
1629
1843
  };
1630
- return this.storage.setItem(ne, JSON.stringify(t)), st(t);
1844
+ return this.storage.setItem(le, JSON.stringify(t)), dt(t);
1631
1845
  }
1632
1846
  /**
1633
1847
  * 보관한 세션을 돌려준다. access token이 끝나 가면 갱신한다. 없으면 null.
@@ -1635,7 +1849,7 @@ class Ts {
1635
1849
  */
1636
1850
  async get() {
1637
1851
  const e = await this.ensureFresh();
1638
- return e ? st(e) : null;
1852
+ return e ? dt(e) : null;
1639
1853
  }
1640
1854
  /** 유효한 access token. 로그인하지 않았으면 `AUTH_NOT_AUTHENTICATED` */
1641
1855
  async getAccessToken() {
@@ -1655,24 +1869,24 @@ class Ts {
1655
1869
  const e = this.read();
1656
1870
  if (this.clear(), !e) return;
1657
1871
  let t = e.tokens.accessToken;
1658
- if (e.tokens.refreshToken && e.tokens.expiresAt - et <= this.now())
1872
+ if (e.tokens.refreshToken && e.tokens.expiresAt - Pe <= this.now())
1659
1873
  try {
1660
1874
  t = (await this.port.refresh(this.config, e.tokens.refreshToken)).accessToken;
1661
1875
  } catch (s) {
1662
- if (s instanceof h && Oe.has(s.code)) return;
1876
+ if (s instanceof h && be.has(s.code)) return;
1663
1877
  }
1664
1878
  await this.port.logout(this.config, t);
1665
1879
  }
1666
1880
  clear() {
1667
- this.generation += 1, this.storage.removeItem(ne);
1881
+ this.generation += 1, this.storage.removeItem(le);
1668
1882
  }
1669
1883
  read() {
1670
1884
  var t;
1671
- const e = this.storage.getItem(ne);
1885
+ const e = this.storage.getItem(le);
1672
1886
  if (!e) return null;
1673
1887
  try {
1674
1888
  const s = JSON.parse(e);
1675
- return typeof ((t = s == null ? void 0 : s.tokens) == null ? void 0 : t.accessToken) == "string" && typeof s.tokens.expiresAt == "number" && s.issuer === j(this.config.issuer) && s.clientId === this.config.clientId ? s : (this.clear(), null);
1889
+ return typeof ((t = s == null ? void 0 : s.tokens) == null ? void 0 : t.accessToken) == "string" && typeof s.tokens.expiresAt == "number" && s.issuer === z(this.config.issuer) && s.clientId === this.config.clientId ? s : (this.clear(), null);
1676
1890
  } catch {
1677
1891
  return this.clear(), null;
1678
1892
  }
@@ -1680,34 +1894,47 @@ class Ts {
1680
1894
  async ensureFresh() {
1681
1895
  const e = this.read();
1682
1896
  if (!e) return null;
1683
- if (e.tokens.expiresAt - et > this.now())
1897
+ if (e.tokens.expiresAt - Pe > this.now())
1684
1898
  return e;
1685
1899
  if (!e.tokens.refreshToken) {
1686
1900
  if (e.tokens.expiresAt > this.now()) return e;
1687
1901
  throw this.clear(), new h(o.ONEID_SESSION_EXPIRED, "ONE ID 로그인이 만료되었습니다. 다시 로그인해 주세요.");
1688
1902
  }
1689
- return this.refreshing ?? (this.refreshing = this.refresh(e).finally(() => {
1903
+ return this.refreshing ?? (this.refreshing = Ks(() => this.refresh(e.tokens.refreshToken)).finally(() => {
1690
1904
  this.refreshing = null;
1691
1905
  })), this.refreshing;
1692
1906
  }
1907
+ /**
1908
+ * 잠금 안에서 저장소를 다시 읽는다. 기다리는 사이 다른 탭이 갱신했으면 그 토큰을 쓰고,
1909
+ * 로그아웃했으면 null 이다. one-oauth 는 refresh token 을 돌려 쓰므로(rotation) 같은 값을 두 탭이 보내면
1910
+ * 늦은 쪽이 세션 종료로 거부돼 두 탭 모두 로그아웃된다.
1911
+ */
1693
1912
  async refresh(e) {
1694
- const t = this.generation;
1913
+ const t = this.read();
1914
+ if (!t) return null;
1915
+ if (t.tokens.refreshToken !== e && t.tokens.expiresAt - Pe > this.now())
1916
+ return t;
1917
+ if (!t.tokens.refreshToken) {
1918
+ if (t.tokens.expiresAt > this.now()) return t;
1919
+ throw this.clear(), new h(o.ONEID_SESSION_EXPIRED, "ONE ID 로그인이 만료되었습니다. 다시 로그인해 주세요.");
1920
+ }
1921
+ const s = this.generation;
1695
1922
  try {
1696
- const s = await this.port.refresh(this.config, e.tokens.refreshToken), r = { ...e, tokens: s };
1697
- if (t !== this.generation)
1923
+ const r = await this.port.refresh(this.config, t.tokens.refreshToken), n = { ...t, tokens: r };
1924
+ if (s !== this.generation)
1698
1925
  throw new h(o.AUTH_NOT_AUTHENTICATED, "ONE ID 세션이 바뀌었습니다");
1699
- return this.storage.setItem(ne, JSON.stringify(r)), r;
1700
- } catch (s) {
1701
- if (t !== this.generation) throw s;
1702
- if (s instanceof h && Oe.has(s.code))
1703
- throw this.clear(), s;
1704
- if (e.tokens.expiresAt > this.now()) return e;
1705
- throw s;
1926
+ return this.storage.setItem(le, JSON.stringify(n)), n;
1927
+ } catch (r) {
1928
+ if (s !== this.generation) throw r;
1929
+ if (r instanceof h && be.has(r.code))
1930
+ throw this.clear(), r;
1931
+ if (t.tokens.expiresAt > this.now()) return t;
1932
+ throw r;
1706
1933
  }
1707
1934
  }
1708
1935
  }
1709
- function st(i) {
1710
- const e = i.tokens.idToken ? Et(i.tokens.idToken) : null;
1936
+ function dt(i) {
1937
+ const e = i.tokens.idToken ? Dt(i.tokens.idToken) : null;
1711
1938
  return {
1712
1939
  subject: typeof (e == null ? void 0 : e.sub) == "string" ? e.sub : "",
1713
1940
  clientId: i.clientId,
@@ -1716,12 +1943,12 @@ function st(i) {
1716
1943
  expiresAt: i.tokens.expiresAt
1717
1944
  };
1718
1945
  }
1719
- function ys(i) {
1946
+ function $s(i) {
1720
1947
  return i === "local" ? window.localStorage : window.sessionStorage;
1721
1948
  }
1722
- const Rs = new TextEncoder();
1949
+ const Ys = new TextEncoder();
1723
1950
  function P(i) {
1724
- return Rs.encode(i);
1951
+ return Ys.encode(i);
1725
1952
  }
1726
1953
  function F(...i) {
1727
1954
  const e = new Uint8Array(i.reduce((s, r) => s + r.length, 0));
@@ -1730,90 +1957,90 @@ function F(...i) {
1730
1957
  e.set(s, t), t += s.length;
1731
1958
  return e;
1732
1959
  }
1733
- function Ns(i) {
1960
+ function qs(i) {
1734
1961
  return new Uint8Array([i >>> 24 & 255, i >>> 16 & 255, i >>> 8 & 255, i & 255]);
1735
1962
  }
1736
- function U(i) {
1963
+ function k(i) {
1737
1964
  let e = "";
1738
1965
  for (const t of i) e += String.fromCharCode(t);
1739
1966
  return btoa(e);
1740
1967
  }
1741
- function J(i) {
1968
+ function Z(i) {
1742
1969
  const e = atob(i), t = new Uint8Array(e.length);
1743
1970
  for (let s = 0; s < e.length; s++) t[s] = e.charCodeAt(s);
1744
1971
  return t;
1745
1972
  }
1746
- function me(i) {
1747
- return U(i).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1973
+ function De(i) {
1974
+ return k(i).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1748
1975
  }
1749
- function Os(i) {
1976
+ function js(i) {
1750
1977
  let e = i.replace(/-/g, "+").replace(/_/g, "/");
1751
1978
  for (; e.length % 4; ) e += "=";
1752
- return J(e);
1979
+ return Z(e);
1753
1980
  }
1754
- function Ps(i) {
1981
+ function zs(i) {
1755
1982
  return globalThis.crypto.getRandomValues(new Uint8Array(i));
1756
1983
  }
1757
- async function At(i) {
1984
+ async function xt(i) {
1758
1985
  return new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", i));
1759
1986
  }
1760
- const x = globalThis.crypto.subtle, xe = { name: "ECDH", namedCurve: "P-256" }, Cs = 32, Ds = 12, xs = 32;
1761
- function se(i) {
1987
+ const x = globalThis.crypto.subtle, Ge = { name: "ECDH", namedCurve: "P-256" }, Js = 32, Xs = 12, Zs = 32;
1988
+ function ie(i) {
1762
1989
  return new Uint8Array([i >>> 8 & 255, i & 255]);
1763
1990
  }
1764
- const Q = F(P("HPKE"), se(16), se(1), se(2)), rt = F(P("KEM"), se(16)), K = new Uint8Array(0);
1765
- async function It(i, e) {
1991
+ const te = F(P("HPKE"), ie(16), ie(1), ie(2)), ut = F(P("KEM"), ie(16)), H = new Uint8Array(0);
1992
+ async function vt(i, e) {
1766
1993
  const t = i.length === 0 ? new Uint8Array(32) : i, s = await x.importKey("raw", t, { name: "HMAC", hash: "SHA-256" }, !1, ["sign"]);
1767
1994
  return new Uint8Array(await x.sign("HMAC", s, e));
1768
1995
  }
1769
- async function vs(i, e, t) {
1996
+ async function Qs(i, e, t) {
1770
1997
  const s = new Uint8Array(t);
1771
- let r = K;
1998
+ let r = H;
1772
1999
  for (let n = 1, a = 0; a < t; n++)
1773
- r = await It(i, F(r, e, new Uint8Array([n]))), s.set(r.subarray(0, Math.min(32, t - a)), a), a += 32;
2000
+ r = await vt(i, F(r, e, new Uint8Array([n]))), s.set(r.subarray(0, Math.min(32, t - a)), a), a += 32;
1774
2001
  return s;
1775
2002
  }
1776
- function he(i, e, t, s) {
1777
- return It(i, F(P("HPKE-v1"), s, P(e), t));
2003
+ function _e(i, e, t, s) {
2004
+ return vt(i, F(P("HPKE-v1"), s, P(e), t));
1778
2005
  }
1779
- function Pe(i, e, t, s, r) {
1780
- return vs(i, F(se(s), P("HPKE-v1"), r, P(e), t), s);
2006
+ function Le(i, e, t, s, r) {
2007
+ return Qs(i, F(ie(s), P("HPKE-v1"), r, P(e), t), s);
1781
2008
  }
1782
- async function mt(i, e) {
1783
- const t = await x.importKey("raw", e, xe, !1, []);
2009
+ async function kt(i, e) {
2010
+ const t = await x.importKey("raw", e, Ge, !1, []);
1784
2011
  return new Uint8Array(await x.deriveBits({ name: "ECDH", public: t }, i, 256));
1785
2012
  }
1786
- async function Tt(i, e, t) {
1787
- const s = await he(K, "eae_prk", i, rt);
1788
- return Pe(s, "shared_secret", F(e, t), xs, rt);
2013
+ async function Ut(i, e, t) {
2014
+ const s = await _e(H, "eae_prk", i, ut);
2015
+ return Le(s, "shared_secret", F(e, t), Zs, ut);
1789
2016
  }
1790
- async function yt(i) {
1791
- const e = await he(K, "psk_id_hash", K, Q), t = await he(K, "info_hash", K, Q), s = F(new Uint8Array([0]), e, t), r = await he(i, "secret", K, Q), n = await Pe(r, "key", s, Cs, Q), a = await Pe(r, "base_nonce", s, Ds, Q);
2017
+ async function bt(i) {
2018
+ const e = await _e(H, "psk_id_hash", H, te), t = await _e(H, "info_hash", H, te), s = F(new Uint8Array([0]), e, t), r = await _e(i, "secret", H, te), n = await Le(r, "key", s, Js, te), a = await Le(r, "base_nonce", s, Xs, te);
1792
2019
  return { key: n, baseNonce: a };
1793
2020
  }
1794
- function pe(i, e) {
2021
+ function Ie(i, e) {
1795
2022
  if (i.length !== 65 || i[0] !== 4)
1796
2023
  throw new Error(`${e} must be SEC1 uncompressed P-256 (65B)`);
1797
2024
  }
1798
- async function Rt() {
1799
- const i = await x.generateKey(xe, !1, ["deriveBits"]), e = new Uint8Array(await x.exportKey("raw", i.publicKey));
2025
+ async function Lt() {
2026
+ const i = await x.generateKey(Ge, !1, ["deriveBits"]), e = new Uint8Array(await x.exportKey("raw", i.publicKey));
1800
2027
  return { privateKey: i.privateKey, publicKey: e };
1801
2028
  }
1802
- async function ks(i, e, t) {
1803
- pe(i, "recipient public key");
1804
- const s = await x.generateKey(xe, !0, ["deriveBits"]), r = new Uint8Array(await x.exportKey("raw", s.publicKey)), n = await Tt(await mt(s.privateKey, i), r, i), { key: a, baseNonce: l } = await yt(n), d = await x.importKey("raw", a, "AES-GCM", !1, ["encrypt"]), g = new Uint8Array(
2029
+ async function er(i, e, t) {
2030
+ Ie(i, "recipient public key");
2031
+ const s = await x.generateKey(Ge, !1, ["deriveBits"]), r = new Uint8Array(await x.exportKey("raw", s.publicKey)), n = await Ut(await kt(s.privateKey, i), r, i), { key: a, baseNonce: l } = await bt(n), d = await x.importKey("raw", a, "AES-GCM", !1, ["encrypt"]), g = new Uint8Array(
1805
2032
  await x.encrypt({ name: "AES-GCM", iv: l, additionalData: t }, d, e)
1806
2033
  );
1807
2034
  return { enc: r, ciphertext: g };
1808
2035
  }
1809
- async function Us(i, e, t, s) {
1810
- pe(e, "enc");
1811
- const r = await Tt(await mt(i.privateKey, e), e, i.publicKey), { key: n, baseNonce: a } = await yt(r), l = await x.importKey("raw", n, "AES-GCM", !1, ["decrypt"]);
2036
+ async function tr(i, e, t, s) {
2037
+ Ie(e, "enc");
2038
+ const r = await Ut(await kt(i.privateKey, e), e, i.publicKey), { key: n, baseNonce: a } = await bt(r), l = await x.importKey("raw", n, "AES-GCM", !1, ["decrypt"]);
1812
2039
  return new Uint8Array(
1813
2040
  await x.decrypt({ name: "AES-GCM", iv: a, additionalData: s }, l, t)
1814
2041
  );
1815
2042
  }
1816
- const Nt = globalThis.crypto.subtle, bs = { name: "ECDSA", namedCurve: "P-256" }, Ls = "one-wallet/authz-sig/v1", Ws = "one-wallet/seal-aad/v1", Ms = 60, Fs = 32, Bs = {
2043
+ const Wt = globalThis.crypto.subtle, sr = { name: "ECDSA", namedCurve: "P-256" }, rr = "one-wallet/authz-sig/v1", ir = "one-wallet/seal-aad/v1", nr = 60, ar = 32, or = {
1817
2044
  generate: 1,
1818
2045
  recover: 3,
1819
2046
  verify_pin: 4,
@@ -1827,99 +2054,111 @@ const Nt = globalThis.crypto.subtle, bs = { name: "ECDSA", namedCurve: "P-256" }
1827
2054
  sign_typed_data: 21,
1828
2055
  sign_message: 22
1829
2056
  };
1830
- function Gs(i) {
1831
- return F(Ns(i.length), i);
2057
+ function cr(i) {
2058
+ return F(qs(i.length), i);
1832
2059
  }
1833
- function Ot(i, e, t) {
1834
- return F(P(i), ...e.map(Gs), new Uint8Array([t]));
2060
+ function Mt(i, e, t) {
2061
+ return F(P(i), ...e.map(cr), new Uint8Array([t]));
1835
2062
  }
1836
- function Ks(i, e, t) {
1837
- return Ot(
1838
- Ws,
2063
+ function lr(i, e, t) {
2064
+ return Mt(
2065
+ ir,
1839
2066
  [i.nonce, P(i.expiresAt), i.intentHash, P(e), P(i.authzKeyId)],
1840
2067
  t
1841
2068
  );
1842
2069
  }
1843
- function Hs(i, e, t) {
1844
- return Ot(
1845
- Ls,
2070
+ function hr(i, e, t) {
2071
+ return Mt(
2072
+ rr,
1846
2073
  [i.enc, i.ciphertext, i.nonce, P(i.expiresAt), i.intentHash, P(e), P(i.authzKeyId)],
1847
2074
  t
1848
2075
  );
1849
2076
  }
1850
- function Vs(i, e, t) {
1851
- return At(Ks(i, e, t));
2077
+ function dr(i, e, t) {
2078
+ return xt(lr(i, e, t));
1852
2079
  }
1853
- function $s(i) {
2080
+ function ur(i) {
1854
2081
  return i.toISOString().replace(/\.\d+Z$/, "Z");
1855
2082
  }
1856
- async function Ys(i, e) {
2083
+ async function gr(i, e) {
1857
2084
  if (i.length !== 32) throw new Error("authz private key must be a 32B P-256 scalar");
1858
- return pe(e, "authz public key"), Nt.importKey(
2085
+ return Ie(e, "authz public key"), Wt.importKey(
1859
2086
  "jwk",
1860
2087
  {
1861
2088
  kty: "EC",
1862
2089
  crv: "P-256",
1863
- x: me(e.subarray(1, 33)),
1864
- y: me(e.subarray(33, 65)),
1865
- d: me(i),
2090
+ x: De(e.subarray(1, 33)),
2091
+ y: De(e.subarray(33, 65)),
2092
+ d: De(i),
1866
2093
  ext: !1
1867
2094
  },
1868
- bs,
2095
+ sr,
1869
2096
  !1,
1870
2097
  ["sign"]
1871
2098
  );
1872
2099
  }
1873
- async function qs(i) {
2100
+ async function _r(i) {
1874
2101
  if (i.intent.command !== i.command) throw new Error("intent.command must match command");
1875
- const e = Bs[i.command], t = P(JSON.stringify(i.intent)), s = {
1876
- nonce: Ps(Fs),
1877
- expiresAt: $s(new Date((i.now ?? /* @__PURE__ */ new Date()).getTime() + (i.ttlSec ?? Ms) * 1e3)),
1878
- intentHash: await At(t),
2102
+ const e = or[i.command], t = P(JSON.stringify(i.intent)), s = {
2103
+ nonce: zs(ar),
2104
+ expiresAt: ur(new Date((i.now ?? /* @__PURE__ */ new Date()).getTime() + (i.ttlSec ?? nr) * 1e3)),
2105
+ intentHash: await xt(t),
1879
2106
  authzKeyId: i.authz.keyId
1880
- }, r = await Vs(s, i.bindingId, e), n = { pin: i.plaintext.pin };
1881
- i.plaintext.new_pin != null && (n.new_pin = i.plaintext.new_pin), i.plaintext.share_c && (n.share_c = U(i.plaintext.share_c)), i.plaintext.response_key && (n.response_key = U(i.plaintext.response_key));
1882
- const { enc: a, ciphertext: l } = await ks(i.recipientPub, P(JSON.stringify(n)), r), d = new Uint8Array(
1883
- await Nt.sign({ name: "ECDSA", hash: "SHA-256" }, i.authz.signingKey, Hs({ ...s, enc: a, ciphertext: l }, i.bindingId, e))
2107
+ }, r = await dr(s, i.bindingId, e), n = { pin: i.plaintext.pin };
2108
+ i.plaintext.new_pin != null && (n.new_pin = i.plaintext.new_pin), i.plaintext.share_c && (n.share_c = k(i.plaintext.share_c)), i.plaintext.response_key && (n.response_key = k(i.plaintext.response_key));
2109
+ const { enc: a, ciphertext: l } = await er(i.recipientPub, P(JSON.stringify(n)), r), d = new Uint8Array(
2110
+ await Wt.sign({ name: "ECDSA", hash: "SHA-256" }, i.authz.signingKey, hr({ ...s, enc: a, ciphertext: l }, i.bindingId, e))
1884
2111
  );
1885
2112
  return {
1886
2113
  envelope: {
1887
- enc: U(a),
1888
- ciphertext: U(l),
1889
- nonce: U(s.nonce),
2114
+ enc: k(a),
2115
+ ciphertext: k(l),
2116
+ nonce: k(s.nonce),
1890
2117
  expires_at: s.expiresAt,
1891
- intent_hash: U(s.intentHash),
2118
+ intent_hash: k(s.intentHash),
1892
2119
  authz_key_id: s.authzKeyId,
1893
- authz_sig: U(d),
2120
+ authz_sig: k(d),
1894
2121
  authz_key_cert: i.authz.cert
1895
2122
  },
1896
- intent: U(t),
2123
+ intent: k(t),
1897
2124
  aad: r
1898
2125
  };
1899
2126
  }
1900
- function Pt(i, e, t) {
1901
- return Us(i, J(e.enc), J(e.ciphertext), t);
2127
+ function Ft(i, e, t) {
2128
+ return tr(i, Z(e.enc), Z(e.ciphertext), t);
1902
2129
  }
1903
- const js = 90 * 1e3;
1904
- class Xs {
2130
+ const fr = 90 * 1e3;
2131
+ class pr {
1905
2132
  constructor(e) {
1906
2133
  this.opts = e, this.current = null, this.pending = null, this.generation = 0, this.now = e.now ?? Date.now;
1907
2134
  }
1908
2135
  /** 쓸 수 있는 B 키. 없거나 만료가 가까우면 발급한다 */
1909
2136
  async get() {
1910
2137
  const e = this.current;
1911
- return e && e.expiresAtMs - this.now() > js ? e : (this.pending ?? (this.pending = this.issue().finally(() => {
1912
- this.pending = null;
1913
- })), this.pending);
2138
+ if (e && e.expiresAtMs - this.now() > fr) return e;
2139
+ if (!this.pending) {
2140
+ const t = this.issue().finally(() => {
2141
+ this.pending === t && (this.pending = null);
2142
+ });
2143
+ this.pending = t;
2144
+ }
2145
+ return this.pending;
1914
2146
  }
1915
2147
  /** 서버가 키를 거부했을 때 — 다음 {@link get} 에서 새로 발급한다 */
1916
2148
  invalidate() {
1917
2149
  this.current = null;
1918
2150
  }
1919
- /** 로그아웃 · 세션 종료 — 서버에서 폐기하고 잊는다. 폐기 실패는 무시한다(cert 는 곧 만료된다) */
2151
+ /**
2152
+ * 서버 호출 없이 잊는다 — 토큰이 이미 끝나 폐기를 부를 수 없을 때(세션 만료 · 폐기).
2153
+ * 진행 중인 발급 결과도 버린다. 서버의 키는 cert 수명이 지나면 끝난다 (DEV2TF-2912 AC-6).
2154
+ */
2155
+ forget() {
2156
+ this.generation++, this.current = null, this.pending = null;
2157
+ }
2158
+ /** 로그아웃 — 서버에서 폐기하고 잊는다. 폐기 실패는 무시한다(cert 는 곧 만료된다) */
1920
2159
  async revoke() {
1921
2160
  const e = this.current;
1922
- if (this.generation++, this.current = null, this.pending = null, !!e)
2161
+ if (this.forget(), !!e)
1923
2162
  try {
1924
2163
  await this.opts.client.call("DELETE", `/authz-keys/${encodeURIComponent(e.keyId)}`);
1925
2164
  } catch {
@@ -1927,19 +2166,19 @@ class Xs {
1927
2166
  }
1928
2167
  async issue() {
1929
2168
  var g;
1930
- const e = this.generation, t = await Rt(), s = await this.opts.getIssuanceJwt(), r = await this.opts.client.call("POST", "/authz-keys", {
2169
+ const e = this.generation, t = await Lt(), s = await this.opts.getIssuanceJwt(), r = await this.opts.client.call("POST", "/authz-keys", {
1931
2170
  jwt: s,
1932
- response_key: U(t.publicKey)
2171
+ response_key: k(t.publicKey)
1933
2172
  });
1934
2173
  if (!((g = r == null ? void 0 : r.key_cert) != null && g.key_id) || !r.cert_sig || !r.sealed_private_key)
1935
2174
  throw new h(o.AUTH_FAILED, "authz-keys response is incomplete");
1936
2175
  let n;
1937
2176
  try {
1938
- n = await Pt(t, r.sealed_private_key, J(r.cert_sig));
2177
+ n = await Ft(t, r.sealed_private_key, Z(r.cert_sig));
1939
2178
  } catch (u) {
1940
2179
  throw new h(o.AUTH_FAILED, "failed to open sealed authz key", { cause: u });
1941
2180
  }
1942
- const a = await Ys(n, J(r.key_cert.pubkey));
2181
+ const a = await gr(n, Z(r.key_cert.pubkey));
1943
2182
  n.fill(0);
1944
2183
  const l = Date.parse(r.key_cert.expires_at);
1945
2184
  if (Number.isNaN(l))
@@ -1955,7 +2194,7 @@ class Xs {
1955
2194
  return this.current = d, d;
1956
2195
  }
1957
2196
  }
1958
- const zs = 600 * 1e3, Js = {
2197
+ const wr = 600 * 1e3, Sr = {
1959
2198
  UNAUTHORIZED: o.AUTH_TOKEN_INVALID,
1960
2199
  AUTHZ_TOKEN_INVALID: o.AUTH_TOKEN_INVALID,
1961
2200
  FORBIDDEN: o.AUTH_FAILED,
@@ -1991,11 +2230,11 @@ const zs = 600 * 1e3, Js = {
1991
2230
  ENVELOPE_INVALID: o.SIGNATURE_FAILED,
1992
2231
  REPLAY: o.SIGNATURE_FAILED
1993
2232
  };
1994
- function Zs(i, e) {
1995
- const t = (e == null ? void 0 : e.code) ?? "", s = Js[t] ?? (i === 401 ? o.AUTH_TOKEN_INVALID : i >= 500 ? o.GATEWAY_INTERNAL_ERROR : o.UNKNOWN_ERROR), r = { status: i, serverCode: t };
2233
+ function Er(i, e) {
2234
+ const t = (e == null ? void 0 : e.code) ?? "", s = Sr[t] ?? (i === 401 ? o.AUTH_TOKEN_INVALID : i >= 500 ? o.GATEWAY_INTERNAL_ERROR : o.UNKNOWN_ERROR), r = { status: i, serverCode: t };
1996
2235
  return (e == null ? void 0 : e.remaining_attempts) != null && (r.remainingAttempts = e.remaining_attempts), (e == null ? void 0 : e.lock_expires_at) != null && (r.lockExpiresAt = e.lock_expires_at > 1e10 ? e.lock_expires_at : e.lock_expires_at * 1e3), (e == null ? void 0 : e.permanent) != null && (r.permanent = e.permanent), e != null && e.tx_hash && (r.txHash = e.tx_hash), new h(s, (e == null ? void 0 : e.message) || `one-wallet-api ${i}${t ? ` ${t}` : ""}`, r);
1997
2236
  }
1998
- class Qs {
2237
+ class Ar {
1999
2238
  constructor(e) {
2000
2239
  this.opts = e, this.recipient = null, this.now = e.now ?? Date.now;
2001
2240
  }
@@ -2010,13 +2249,13 @@ class Qs {
2010
2249
  }
2011
2250
  /** enclave 수신 공개키(SEC1 65B) */
2012
2251
  async getRecipientKey() {
2013
- if (this.recipient && this.now() - this.recipient.fetchedAt < zs)
2252
+ if (this.recipient && this.now() - this.recipient.fetchedAt < wr)
2014
2253
  return this.recipient.key;
2015
2254
  const e = await this.callPublic("GET", "/attestation");
2016
2255
  if (!(e != null && e.recipient_public_key))
2017
2256
  throw new h(o.GATEWAY_INTERNAL_ERROR, "attestation has no recipient_public_key");
2018
- const t = J(e.recipient_public_key);
2019
- return pe(t, "recipient_public_key"), this.recipient = { key: t, fetchedAt: this.now() }, t;
2257
+ const t = Z(e.recipient_public_key);
2258
+ return Ie(t, "recipient_public_key"), this.recipient = { key: t, fetchedAt: this.now() }, t;
2020
2259
  }
2021
2260
  /** 수신키 회전 등으로 봉투가 거부되면 다음 요청에서 다시 받는다 */
2022
2261
  forgetRecipientKey() {
@@ -2038,28 +2277,28 @@ class Qs {
2038
2277
  throw new h(o.NETWORK_ERROR, "one-wallet-api request failed", { cause: l });
2039
2278
  }
2040
2279
  if (a.status < 200 || a.status >= 300)
2041
- throw Zs(a.status, a.data);
2280
+ throw Er(a.status, a.data);
2042
2281
  return a.data;
2043
2282
  }
2044
2283
  }
2045
- const Te = (i) => `m/44'/60'/0'/0/${i}`, er = /^0x(?:[0-9a-fA-F]{2})*$/;
2046
- function tr(i) {
2284
+ const xe = (i) => `m/44'/60'/0'/0/${i}`, Ir = /^0x(?:[0-9a-fA-F]{2})*$/;
2285
+ function mr(i) {
2047
2286
  try {
2048
- const e = JSON.parse(new TextDecoder().decode(Os(i.split(".")[1] ?? "")));
2287
+ const e = JSON.parse(new TextDecoder().decode(js(i.split(".")[1] ?? "")));
2049
2288
  if (typeof (e == null ? void 0 : e.sub) == "string" && e.sub) return e.sub;
2050
2289
  } catch {
2051
2290
  }
2052
2291
  throw new h(o.AUTH_TOKEN_INVALID, "access token has no sub");
2053
2292
  }
2054
- function sr(i) {
2055
- if (er.test(i)) {
2293
+ function Tr(i) {
2294
+ if (Ir.test(i)) {
2056
2295
  const e = i.slice(2);
2057
2296
  return Uint8Array.from({ length: e.length / 2 }, (t, s) => parseInt(e.slice(s * 2, s * 2 + 2), 16));
2058
2297
  }
2059
2298
  return P(i);
2060
2299
  }
2061
- const it = (i) => `0x${i.toString(16)}`;
2062
- function nt(i, e) {
2300
+ const gt = (i) => `0x${i.toString(16)}`;
2301
+ function _t(i, e) {
2063
2302
  const t = i.chainId ?? Number(e.split(":")[1]);
2064
2303
  if (!Number.isSafeInteger(t))
2065
2304
  throw new h(o.TX_INVALID_PARAMS, `invalid chain id: ${e}`);
@@ -2073,19 +2312,19 @@ function nt(i, e) {
2073
2312
  gas_price: i.gasPrice,
2074
2313
  max_fee_per_gas: i.maxFeePerGas,
2075
2314
  max_priority_fee_per_gas: i.maxPriorityFeePerGas,
2076
- nonce: it(i.nonce),
2077
- chain_id: it(t)
2315
+ nonce: gt(i.nonce),
2316
+ chain_id: gt(t)
2078
2317
  };
2079
2318
  return Object.fromEntries(Object.entries(s).filter(([, r]) => r !== void 0));
2080
2319
  }
2081
- class Ct {
2320
+ class We {
2082
2321
  constructor(e) {
2083
- this.opts = e, this.walletAddress = null, this.client = new Qs({
2322
+ this.opts = e, this.walletAddress = null, this.client = new Ar({
2084
2323
  baseUrl: e.baseUrl,
2085
2324
  transport: e.transport,
2086
2325
  getAccessToken: e.getAccessToken,
2087
2326
  now: e.now
2088
- }), this.authzKeys = new Xs({ client: this.client, getIssuanceJwt: e.getAccessToken, now: e.now });
2327
+ }), this.authzKeys = new pr({ client: this.client, getIssuanceJwt: e.getAccessToken, now: e.now });
2089
2328
  }
2090
2329
  async checkWallet() {
2091
2330
  return await this.findWallet() ? "exists" : "not_found";
@@ -2094,7 +2333,7 @@ class Ct {
2094
2333
  if (this.walletAddress) return this.walletData(this.walletAddress);
2095
2334
  const t = await this.findWallet();
2096
2335
  if (t) return this.walletData(t.address);
2097
- const s = this.requirePin(), r = tr(await this.opts.getAccessToken()), n = await Rt(), { result: a, aad: l } = await this.withEnvelope(
2336
+ const s = this.requirePin(), r = mr(await this.opts.getAccessToken()), n = await Lt(), { result: a, aad: l } = await this.withEnvelope(
2098
2337
  "generate",
2099
2338
  r,
2100
2339
  { command: "generate" },
@@ -2106,7 +2345,7 @@ class Ct {
2106
2345
  })
2107
2346
  );
2108
2347
  if (this.walletAddress = a.address, a.sealed_share_c && this.opts.onShareC) {
2109
- const d = await Pt(n, a.sealed_share_c, l);
2348
+ const d = await Ft(n, a.sealed_share_c, l);
2110
2349
  await this.opts.onShareC(d, a.address);
2111
2350
  }
2112
2351
  return this.walletData(a.address);
@@ -2120,7 +2359,7 @@ class Ct {
2120
2359
  }
2121
2360
  async getAddress(e, t) {
2122
2361
  const s = await this.requireWalletAddress(), r = (await this.getAddresses(e)).find((a) => a.index === t);
2123
- if (r) return { address: r.address, derivationPath: Te(t) };
2362
+ if (r) return { address: r.address, derivationPath: xe(t) };
2124
2363
  const { result: n } = await this.withEnvelope(
2125
2364
  "get_address",
2126
2365
  s,
@@ -2128,13 +2367,13 @@ class Ct {
2128
2367
  { pin: this.requirePin() },
2129
2368
  (a, l) => this.client.call("PUT", `/wallets/${s}/addresses/${t}`, { envelope: a, intent: l })
2130
2369
  );
2131
- return { address: n.address, derivationPath: Te(t) };
2370
+ return { address: n.address, derivationPath: xe(t) };
2132
2371
  }
2133
2372
  async signMessage(e, t, s, r, n, a) {
2134
2373
  const l = await this.resolveTarget(r, a), { result: d } = await this.withEnvelope(
2135
2374
  "sign_message",
2136
2375
  l.address,
2137
- { command: "sign_message", index: l.index, message: U(sr(s)) },
2376
+ { command: "sign_message", index: l.index, message: k(Tr(s)) },
2138
2377
  { pin: this.requirePin() },
2139
2378
  (g, u) => this.client.call("POST", `/wallets/${l.address}/signatures`, { type: "message", envelope: g, intent: u })
2140
2379
  );
@@ -2159,7 +2398,7 @@ class Ct {
2159
2398
  const n = await this.resolveTarget(r, s.from), { result: a } = await this.withEnvelope(
2160
2399
  "sign",
2161
2400
  n.address,
2162
- { command: "sign", index: n.index, unsigned_tx: nt(s, t) },
2401
+ { command: "sign", index: n.index, unsigned_tx: _t(s, t) },
2163
2402
  { pin: this.requirePin() },
2164
2403
  (l, d) => this.client.call("POST", `/wallets/${n.address}/signatures`, {
2165
2404
  type: "transaction",
@@ -2174,18 +2413,25 @@ class Ct {
2174
2413
  const r = await this.resolveTarget(void 0, s.from), { result: n } = await this.withEnvelope(
2175
2414
  "sign",
2176
2415
  r.address,
2177
- { command: "sign", index: r.index, unsigned_tx: nt(s, t) },
2416
+ { command: "sign", index: r.index, unsigned_tx: _t(s, t) },
2178
2417
  { pin: this.requirePin() },
2179
2418
  (a, l) => this.client.call("POST", `/wallets/${r.address}/transactions`, { chain_id: t, envelope: a, intent: l })
2180
2419
  );
2181
2420
  return { txHash: n.tx_hash };
2182
2421
  }
2183
- /** 로그아웃 · 세션 종료 — B 키를 폐기하고 캐시를 지운다 */
2422
+ /** 로그아웃 — B 키를 폐기하고 캐시를 지운다 */
2184
2423
  async signOut() {
2185
2424
  this.walletAddress = null, await this.authzKeys.revoke();
2186
2425
  }
2426
+ /**
2427
+ * 세션이 끝났을 때(만료 · 폐기 · 강제 로그아웃) — 서버를 부르지 않고 B 키 · 지갑 주소 캐시를 잊는다.
2428
+ * 남겨 두면 다음 로그인(다른 계정일 수 있다)이 이전 세션의 키 · 주소를 쓴다 (DEV2TF-2912 AC-6).
2429
+ */
2430
+ forgetSession() {
2431
+ this.walletAddress = null, this.authzKeys.forget();
2432
+ }
2187
2433
  walletData(e) {
2188
- return { id: e, address: e, derivationPath: Te(0), createdAt: Date.now() };
2434
+ return { id: e, address: e, derivationPath: xe(0), createdAt: Date.now() };
2189
2435
  }
2190
2436
  async findWallet() {
2191
2437
  const e = await this.client.call("GET", "/wallets"), t = Array.isArray(e) ? e[0] ?? null : null;
@@ -2224,7 +2470,7 @@ class Ct {
2224
2470
  async withEnvelope(e, t, s, r, n) {
2225
2471
  var a;
2226
2472
  for (let l = 0; ; l++) {
2227
- const d = await qs({
2473
+ const d = await _r({
2228
2474
  recipientPub: await this.client.getRecipientKey(),
2229
2475
  bindingId: t,
2230
2476
  command: e,
@@ -2245,11 +2491,11 @@ class Ct {
2245
2491
  }
2246
2492
  }
2247
2493
  }
2248
- const rr = 3, ir = /^0x(?:[0-9a-fA-F]{2}){4,}$/;
2249
- function nr(i) {
2250
- return i.code === rr || /execution reverted/i.test(i.message ?? "");
2494
+ const yr = 3, Rr = /^0x(?:[0-9a-fA-F]{2}){4,}$/;
2495
+ function Nr(i) {
2496
+ return i.code === yr || /execution reverted/i.test(i.message ?? "");
2251
2497
  }
2252
- class ar {
2498
+ class Or {
2253
2499
  constructor(e, t) {
2254
2500
  this.chainRegistry = e, this.transport = t, this._nextId = 1;
2255
2501
  }
@@ -2274,8 +2520,8 @@ class ar {
2274
2520
  body: n
2275
2521
  })).data;
2276
2522
  if (l != null && l.error) {
2277
- const { code: d, message: g } = l.error, u = { method: e, chainId: s, code: d, message: g, data: l.error.data }, _ = nr(l.error);
2278
- throw _ && typeof u.data == "string" && ir.test(u.data) && (u.revertData = u.data, u.selector = u.data.slice(0, 10).toLowerCase()), new h(
2523
+ const { code: d, message: g } = l.error, u = { method: e, chainId: s, code: d, message: g, data: l.error.data }, _ = Nr(l.error);
2524
+ throw _ && typeof u.data == "string" && Rr.test(u.data) && (u.revertData = u.data, u.selector = u.data.slice(0, 10).toLowerCase()), new h(
2279
2525
  _ ? o.EXECUTION_REVERTED : o.UNKNOWN_ERROR,
2280
2526
  `RPC 오류 [${e}] (${s}): ${g} (코드: ${d})`,
2281
2527
  u
@@ -2284,7 +2530,7 @@ class ar {
2284
2530
  return l == null ? void 0 : l.result;
2285
2531
  }
2286
2532
  }
2287
- class or {
2533
+ class Pr {
2288
2534
  constructor() {
2289
2535
  this.listeners = /* @__PURE__ */ new Map();
2290
2536
  }
@@ -2307,7 +2553,7 @@ class or {
2307
2553
  this.listeners.clear();
2308
2554
  }
2309
2555
  }
2310
- function cr() {
2556
+ function Cr() {
2311
2557
  var e;
2312
2558
  if (typeof globalThis < "u" && ((e = globalThis.crypto) != null && e.getRandomValues)) {
2313
2559
  const t = new Uint8Array(16);
@@ -2315,7 +2561,7 @@ function cr() {
2315
2561
  }
2316
2562
  return require("crypto").randomBytes(16).toString("hex");
2317
2563
  }
2318
- class b {
2564
+ class L {
2319
2565
  constructor(e) {
2320
2566
  this.config = e, this.context = null;
2321
2567
  }
@@ -2352,7 +2598,7 @@ class b {
2352
2598
  * Initialize and activate bridge
2353
2599
  */
2354
2600
  async initialize() {
2355
- if (await b.waitForBridgeReady(5e3) || c.warn("[RNBridge] Bridge did not become ready in time"), this.bridge = b.getBridge(), !this.bridge)
2601
+ if (await L.waitForBridgeReady(5e3) || c.warn("[RNBridge] Bridge did not become ready in time"), this.bridge = L.getBridge(), !this.bridge)
2356
2602
  throw new h(
2357
2603
  o.AUTH_NOT_INITIALIZED,
2358
2604
  "RN Bridge not available in this environment"
@@ -2377,7 +2623,7 @@ class b {
2377
2623
  async handshake() {
2378
2624
  if (!this.bridge)
2379
2625
  throw new h(o.AUTH_NOT_INITIALIZED, "Bridge not initialized");
2380
- const e = cr(), t = Date.now(), s = {
2626
+ const e = Cr(), t = Date.now(), s = {
2381
2627
  version: 1,
2382
2628
  appId: this.config.appId,
2383
2629
  appVersion: this.config.appVersion,
@@ -2541,7 +2787,7 @@ class b {
2541
2787
  );
2542
2788
  }
2543
2789
  }
2544
- const z = {
2790
+ const X = {
2545
2791
  production: {
2546
2792
  oauthServiceUrl: "https://one-wallet-oauth.onechain.nexus",
2547
2793
  legacyOauthServiceUrl: "https://cross-wallet-oauth.crosstoken.io",
@@ -2574,8 +2820,8 @@ const z = {
2574
2820
  oneWalletApiUrl: "https://dev-one-pocket-api.onechain.nexus/embed/v1"
2575
2821
  }
2576
2822
  };
2577
- function lr(i) {
2578
- const e = i.environment, t = e && e in z ? z[e] : null;
2823
+ function Dr(i) {
2824
+ const e = i.environment, t = e && e in X ? X[e] : null;
2579
2825
  if (!t)
2580
2826
  return null;
2581
2827
  const s = i.overrides;
@@ -2586,63 +2832,63 @@ function lr(i) {
2586
2832
  typeof a == "string" && a.trim() !== "" && (r[n] = a);
2587
2833
  return r;
2588
2834
  }
2589
- function ue() {
2835
+ function we() {
2590
2836
  try {
2591
2837
  if (typeof __CROSSX_CONFIG__ < "u") {
2592
- const i = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e = lr(i);
2838
+ const i = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e = Dr(i);
2593
2839
  if (e) return e;
2594
2840
  }
2595
2841
  } catch {
2596
2842
  }
2597
2843
  try {
2598
2844
  const i = process.env.NEXT_PUBLIC_CROSSX_ENVIRONMENT;
2599
- if (i && i in z)
2600
- return z[i];
2845
+ if (i && i in X)
2846
+ return X[i];
2601
2847
  } catch {
2602
2848
  }
2603
- return z.production;
2849
+ return X.production;
2604
2850
  }
2605
- function Dt(i) {
2851
+ function Bt(i) {
2606
2852
  let e = i.length;
2607
2853
  for (; e > 0 && i.charCodeAt(e - 1) === 48; ) e--;
2608
2854
  return i.slice(0, e);
2609
2855
  }
2610
- function hr(i, e = ut) {
2856
+ function xr(i, e = It) {
2611
2857
  if (!i || i === "0x0" || i === "0x") return "0";
2612
2858
  try {
2613
2859
  const t = BigInt(i);
2614
2860
  if (t === 0n) return "0";
2615
- const s = 10n ** BigInt(Ke), r = t / s, a = (t % s).toString().padStart(Ke, "0"), l = Dt(a).slice(0, e);
2861
+ const s = 10n ** BigInt(Xe), r = t / s, a = (t % s).toString().padStart(Xe, "0"), l = Bt(a).slice(0, e);
2616
2862
  return l ? `${r}.${l}` : `${r}`;
2617
2863
  } catch {
2618
2864
  return "?";
2619
2865
  }
2620
2866
  }
2621
- function ae(i, e, t, s = ut) {
2867
+ function he(i, e, t, s = It) {
2622
2868
  if (!(!i || i === "0x" || i === "0x0"))
2623
2869
  try {
2624
2870
  const r = BigInt(i);
2625
2871
  if (r === 0n) return;
2626
- const n = 10n ** BigInt(t), a = r / n, d = (r % n).toString().padStart(t, "0"), g = Dt(d.slice(0, s)), u = g ? `${a}.${g}` : `${a}`;
2872
+ const n = 10n ** BigInt(t), a = r / n, d = (r % n).toString().padStart(t, "0"), g = Bt(d.slice(0, s)), u = g ? `${a}.${g}` : `${a}`;
2627
2873
  return e ? `${u} ${e}` : u;
2628
2874
  } catch {
2629
2875
  return;
2630
2876
  }
2631
2877
  }
2632
- function dr(i) {
2878
+ function vr(i) {
2633
2879
  const e = i.startsWith("0x") ? i.slice(2) : i;
2634
2880
  if (!/^[0-9a-fA-F]+$/.test(e))
2635
2881
  throw new h(
2636
2882
  o.SIGNATURE_FAILED,
2637
2883
  "유효하지 않은 서명: 올바른 hex 문자열이 아닙니다"
2638
2884
  );
2639
- if (e.length !== Ge)
2885
+ if (e.length !== Je)
2640
2886
  throw new h(
2641
2887
  o.SIGNATURE_FAILED,
2642
- `서명 길이가 유효하지 않습니다: ${Ge} hex 문자(65 바이트) 예상, 현재 ${e.length}`
2888
+ `서명 길이가 유효하지 않습니다: ${Je} hex 문자(65 바이트) 예상, 현재 ${e.length}`
2643
2889
  );
2644
2890
  }
2645
- function ur(i) {
2891
+ function kr(i) {
2646
2892
  const e = i.startsWith("0x") ? i.slice(2) : i;
2647
2893
  if (!/^[0-9a-fA-F]+$/.test(e))
2648
2894
  throw new h(
@@ -2655,8 +2901,8 @@ function ur(i) {
2655
2901
  "유효하지 않은 서명된 트랜잭션: 너무 짧습니다"
2656
2902
  );
2657
2903
  }
2658
- function gr(i, e) {
2659
- const t = _r(e);
2904
+ function Ur(i, e) {
2905
+ const t = br(e);
2660
2906
  if (i === "0") {
2661
2907
  if (t !== void 0 && t !== 0)
2662
2908
  throw new h(
@@ -2680,7 +2926,7 @@ function gr(i, e) {
2680
2926
  );
2681
2927
  }
2682
2928
  }
2683
- function _r(i) {
2929
+ function br(i) {
2684
2930
  if (i == null || typeof i != "object") return;
2685
2931
  const e = i.domain;
2686
2932
  if (e == null || typeof e != "object") return;
@@ -2689,7 +2935,7 @@ function _r(i) {
2689
2935
  const s = Number(t);
2690
2936
  return Number.isFinite(s) ? s : void 0;
2691
2937
  }
2692
- const Ti = 900 * 1e3, fr = /* @__PURE__ */ new Set([
2938
+ const Vi = 900 * 1e3, Lr = /* @__PURE__ */ new Set([
2693
2939
  "095ea7b3",
2694
2940
  // approve(address,uint256)
2695
2941
  "a22cb465",
@@ -2700,7 +2946,7 @@ const Ti = 900 * 1e3, fr = /* @__PURE__ */ new Set([
2700
2946
  // increaseApproval(address,uint256) — 예전 OpenZeppelin
2701
2947
  "87517c45"
2702
2948
  // Permit2 approve(address,address,uint160,uint48)
2703
- ]), pr = /* @__PURE__ */ new Set([
2949
+ ]), Wr = /* @__PURE__ */ new Set([
2704
2950
  "Permit",
2705
2951
  "PermitSingle",
2706
2952
  "PermitBatch",
@@ -2709,22 +2955,22 @@ const Ti = 900 * 1e3, fr = /* @__PURE__ */ new Set([
2709
2955
  "PermitWitnessTransferFrom",
2710
2956
  "PermitBatchWitnessTransferFrom"
2711
2957
  ]);
2712
- function Sr(i) {
2958
+ function Mr(i) {
2713
2959
  var s;
2714
2960
  const { action: e, context: t } = i;
2715
2961
  if (e === "sign" || e === "send") {
2716
2962
  const r = (s = t.tx) == null ? void 0 : s.data;
2717
2963
  if (typeof r != "string") return !1;
2718
2964
  const n = r.trim().toLowerCase().replace(/^0x/, "");
2719
- return n.length >= 8 && fr.has(n.slice(0, 8));
2965
+ return n.length >= 8 && Lr.has(n.slice(0, 8));
2720
2966
  }
2721
2967
  if (e === "sign-typed-data") {
2722
- const r = wr(t.typedData);
2723
- return r === null || pr.has(r);
2968
+ const r = Fr(t.typedData);
2969
+ return r === null || Wr.has(r);
2724
2970
  }
2725
2971
  return !1;
2726
2972
  }
2727
- function wr(i) {
2973
+ function Fr(i) {
2728
2974
  let e = i;
2729
2975
  if (typeof e == "string")
2730
2976
  try {
@@ -2738,16 +2984,16 @@ function wr(i) {
2738
2984
  }
2739
2985
  return null;
2740
2986
  }
2741
- function Er(i, e, t, s) {
2987
+ function Br(i, e, t, s) {
2742
2988
  if (!i) return !0;
2743
2989
  if (i.mode === "off" || e === null) return !1;
2744
2990
  const r = t - e;
2745
- return r < 0 || r >= i.ttlMs ? !1 : !Sr(s);
2991
+ return r < 0 || r >= i.ttlMs ? !1 : !Mr(s);
2746
2992
  }
2747
- function Ar(i) {
2993
+ function Gr(i) {
2748
2994
  return (i == null ? void 0 : i.mode) === "off";
2749
2995
  }
2750
- class X {
2996
+ class J {
2751
2997
  constructor(e) {
2752
2998
  this.deps = e, this.verifyPinMutex = null;
2753
2999
  }
@@ -2757,14 +3003,14 @@ class X {
2757
3003
  */
2758
3004
  prepareForSigning(e) {
2759
3005
  var s, r;
2760
- if (!this.deps.pinStore.has()) return;
3006
+ if (this.deps.pinStore.hold(), !this.deps.pinStore.has()) return;
2761
3007
  const t = (r = (s = this.deps).getPinReusePolicy) == null ? void 0 : r.call(s);
2762
- Er(t, this.deps.pinStore.getSetAt(), Date.now(), e) || this.deps.pinStore.clear();
3008
+ Br(t, this.deps.pinStore.getSetAt(), Date.now(), e) || this.deps.pinStore.clear();
2763
3009
  }
2764
3010
  /** 서명이 끝난 뒤 — 서명마다 PIN 을 받는 정책이면 PIN 을 메모리에 남기지 않는다. */
2765
3011
  finishSigning() {
2766
3012
  var e, t;
2767
- Ar((t = (e = this.deps).getPinReusePolicy) == null ? void 0 : t.call(e)) && this.deps.pinStore.clear();
3013
+ Gr((t = (e = this.deps).getPinReusePolicy) == null ? void 0 : t.call(e)) && this.deps.pinStore.clear(), this.deps.pinStore.release();
2768
3014
  }
2769
3015
  /** PIN 재사용 정책이 있으면 true — 서명을 하나씩 처리해야 한다 (SigningOrchestrator). */
2770
3016
  hasReusePolicy() {
@@ -2843,7 +3089,7 @@ class X {
2843
3089
  if (p.code === o.PIN_INVALID)
2844
3090
  return { ok: !1, error: p.message };
2845
3091
  if (p.code === o.PIN_LOCKED)
2846
- return X.buildPinLockedResult(p, l);
3092
+ return J.buildPinLockedResult(p, l);
2847
3093
  }
2848
3094
  throw p;
2849
3095
  }
@@ -2877,7 +3123,7 @@ class X {
2877
3123
  return await e();
2878
3124
  } catch (r) {
2879
3125
  if (r instanceof h) {
2880
- if (s = X.parsePinError(r, t), !s) throw r;
3126
+ if (s = J.parsePinError(r, t), !s) throw r;
2881
3127
  } else
2882
3128
  throw r;
2883
3129
  }
@@ -2891,7 +3137,7 @@ class X {
2891
3137
  try {
2892
3138
  return await e();
2893
3139
  } catch (r) {
2894
- if (r instanceof h && (s = X.parsePinError(r, t), s))
3140
+ if (r instanceof h && (s = J.parsePinError(r, t), s))
2895
3141
  continue;
2896
3142
  throw r;
2897
3143
  }
@@ -2916,13 +3162,13 @@ class X {
2916
3162
  return null;
2917
3163
  }
2918
3164
  static buildPinLockedResult(e, t) {
2919
- const s = X.parsePinError(e, t);
3165
+ const s = J.parsePinError(e, t);
2920
3166
  if (!s) return { ok: !1, error: e.message };
2921
3167
  const { errorMessage: r, ...n } = s;
2922
3168
  return { ok: !1, error: r, ...n };
2923
3169
  }
2924
3170
  }
2925
- class Ir {
3171
+ class Hr {
2926
3172
  constructor(e) {
2927
3173
  this.deps = e, this.signingQueue = Promise.resolve();
2928
3174
  }
@@ -2961,10 +3207,10 @@ class Ir {
2961
3207
  }
2962
3208
  }
2963
3209
  }
2964
- function mr(i) {
3210
+ function Kr(i) {
2965
3211
  return i === "google" || i === "apple";
2966
3212
  }
2967
- class Tr {
3213
+ class Vr {
2968
3214
  constructor(e) {
2969
3215
  this.deps = e;
2970
3216
  }
@@ -2975,7 +3221,7 @@ class Tr {
2975
3221
  this.deps.setRecoveringSession(!0);
2976
3222
  try {
2977
3223
  this.deps.setAuthenticated(!1), this.deps.clearTokenStore();
2978
- const r = mr(e.loginType) ? { provider: e.loginType } : void 0;
3224
+ const r = Kr(e.loginType) ? { provider: e.loginType } : void 0;
2979
3225
  let n;
2980
3226
  try {
2981
3227
  n = await this.deps.executeSignIn(r);
@@ -3055,7 +3301,7 @@ class Tr {
3055
3301
  }
3056
3302
  }
3057
3303
  }
3058
- class yr {
3304
+ class $r {
3059
3305
  constructor(e) {
3060
3306
  this.deps = e;
3061
3307
  }
@@ -3102,7 +3348,7 @@ class yr {
3102
3348
  c.log("[CROSSx] 세션 복원 후 지갑 주소 로드 완료:", l.address), this.deps.setActiveWallet(l.address, 0);
3103
3349
  }
3104
3350
  }
3105
- class Rr {
3351
+ class Yr {
3106
3352
  constructor(e) {
3107
3353
  this.deps = e;
3108
3354
  }
@@ -3259,7 +3505,7 @@ class Rr {
3259
3505
  }
3260
3506
  }
3261
3507
  }
3262
- class Nr {
3508
+ class qr {
3263
3509
  constructor(e) {
3264
3510
  this.deps = e;
3265
3511
  }
@@ -3286,7 +3532,7 @@ class Nr {
3286
3532
  if (g && (d.nonce = parseInt(u ?? "0x0", 16), c.log("[CROSSx] nonce 결과:", d.nonce)), n && (d.gasLimit = _, c.log("[CROSSx] estimateGas 결과:", d.gasLimit)), a) {
3287
3533
  const A = p;
3288
3534
  if (A) {
3289
- const E = Be;
3535
+ const E = ze;
3290
3536
  d.maxFeePerGas = `0x${(BigInt(A) + BigInt(E)).toString(16)}`, d.maxPriorityFeePerGas = E, c.log(
3291
3537
  "[CROSSx] Dynamic 체인 감지 — baseFee:",
3292
3538
  A,
@@ -3295,12 +3541,12 @@ class Nr {
3295
3541
  "maxPriorityFeePerGas: 1 Gwei"
3296
3542
  );
3297
3543
  } else
3298
- d.gasPrice = Kt, c.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
3544
+ d.gasPrice = Zt, c.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
3299
3545
  }
3300
- return !a && l && (d.maxPriorityFeePerGas = Be, c.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), d;
3546
+ return !a && l && (d.maxPriorityFeePerGas = ze, c.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), d;
3301
3547
  }
3302
3548
  }
3303
- class Or {
3549
+ class jr {
3304
3550
  constructor(e) {
3305
3551
  this.crypto = e;
3306
3552
  }
@@ -3326,10 +3572,10 @@ class Or {
3326
3572
  }
3327
3573
  }
3328
3574
  }
3329
- function Pr(i) {
3575
+ function zr(i) {
3330
3576
  return i ? i.includes("google") ? "google" : i.includes("apple") ? "apple" : i : null;
3331
3577
  }
3332
- class Cr {
3578
+ class Jr {
3333
3579
  constructor(e) {
3334
3580
  this.deps = e;
3335
3581
  }
@@ -3351,7 +3597,7 @@ class Cr {
3351
3597
  activeWalletIndex: 0,
3352
3598
  userEmail: ((n = e.user) == null ? void 0 : n.email) ?? null,
3353
3599
  providerSub: ((a = e.user) == null ? void 0 : a.providerSub) ?? null,
3354
- loginType: Pr(
3600
+ loginType: zr(
3355
3601
  (l = e.user) == null ? void 0 : l.signInProvider
3356
3602
  ),
3357
3603
  tokenSignatureVerified: e.tokenSignatureVerified ?? !1
@@ -3380,7 +3626,7 @@ class Cr {
3380
3626
  });
3381
3627
  }
3382
3628
  }
3383
- class Dr {
3629
+ class Xr {
3384
3630
  constructor(e) {
3385
3631
  this.deps = e;
3386
3632
  }
@@ -3401,7 +3647,7 @@ class Dr {
3401
3647
  )).address, index: e };
3402
3648
  }
3403
3649
  }
3404
- class xr {
3650
+ class Zr {
3405
3651
  constructor(e) {
3406
3652
  this.deps = e;
3407
3653
  }
@@ -3420,7 +3666,7 @@ class xr {
3420
3666
  );
3421
3667
  }
3422
3668
  }
3423
- class vr {
3669
+ class Qr {
3424
3670
  constructor(e) {
3425
3671
  this.deps = e;
3426
3672
  }
@@ -3480,11 +3726,11 @@ class vr {
3480
3726
  }
3481
3727
  }
3482
3728
  }
3483
- function at(i, e) {
3729
+ function ft(i, e) {
3484
3730
  const t = i.replace(/\/$/, ""), s = e.startsWith("/") ? e : `/${e}`;
3485
3731
  return `${t}/cross-auth${s}`;
3486
3732
  }
3487
- class kr {
3733
+ class ei {
3488
3734
  constructor(e) {
3489
3735
  this.deps = e;
3490
3736
  }
@@ -3520,7 +3766,7 @@ class kr {
3520
3766
  o.TX_INVALID_PARAMS,
3521
3767
  "invalid param body"
3522
3768
  );
3523
- const n = this.deps.getApiBaseUrl(), a = at(n, `/v2/token-historical/${e}/${r}`), l = { clientVersion: s };
3769
+ const n = this.deps.getApiBaseUrl(), a = ft(n, `/v2/token-historical/${e}/${r}`), l = { clientVersion: s };
3524
3770
  try {
3525
3771
  c.log("[TokenHistory] Registering tx:", e, r);
3526
3772
  const d = await this.deps.transport.request({
@@ -3550,7 +3796,7 @@ class kr {
3550
3796
  */
3551
3797
  async getTokenHistory(e) {
3552
3798
  var r;
3553
- const t = this.deps.getApiBaseUrl(), s = new URL(at(t, "/v2/token-historical"));
3799
+ const t = this.deps.getApiBaseUrl(), s = new URL(ft(t, "/v2/token-historical"));
3554
3800
  (e == null ? void 0 : e.lastTimestamp) !== void 0 && s.searchParams.append("last_timestamp", e.lastTimestamp.toString()), (e == null ? void 0 : e.lastTxIndex) !== void 0 && s.searchParams.append("last_tx_index", e.lastTxIndex.toString());
3555
3801
  try {
3556
3802
  c.log("[TokenHistory] Fetching token history");
@@ -3625,82 +3871,82 @@ class kr {
3625
3871
  throw new h(r.code, r.message);
3626
3872
  }
3627
3873
  }
3628
- function ye(i, e = "Apple account") {
3874
+ function ve(i, e = "Apple account") {
3629
3875
  if (i.endsWith("@privaterelay.appleid.com")) return e;
3630
3876
  const t = i.indexOf("@");
3631
3877
  if (t < 0) return "*".repeat(i.length || 3);
3632
3878
  const s = i.substring(0, t), r = i.substring(t);
3633
3879
  return s.length <= 1 ? `${s}${"*".repeat(Math.max(s.length, 1))}${r}` : `${s[0]}${"*".repeat(s.length - 1)}${r}`;
3634
3880
  }
3635
- const W = class W extends or {
3881
+ const b = class b extends Pr {
3636
3882
  constructor(e, t, s, r, n, a, l, d, g, u, _, p, A) {
3637
3883
  var E, w;
3638
- super(), this.storage = s, this.crypto = r, this.transport = n, this.oauth = a, this.walletProvider = l, this.tokenStore = d, this.pinEncryptor = p, this.oneIdAuth = A, this._warnedUnknownNativeCurrency = /* @__PURE__ */ new Set(), 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._themeMediaCleanup = null, this._isRecoveringSession = !1, this._rnBridgeService = null, this._providers = /* @__PURE__ */ new Map(), this._isAuthenticatedViaRNBridge = !1, this._bridgeSessionRestorePromise = null, this._sdkDeprecationNotified = !1, this._sdkUnsupportedNotified = !1, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = t, e.logger && Ye(e.logger), this.confirmation = g, this.pinStore = _ ?? new St(), this.stateManager = new Cr({
3884
+ super(), this.storage = s, this.crypto = r, this.transport = n, this.oauth = a, this.walletProvider = l, this.tokenStore = d, this.pinEncryptor = p, this.oneIdAuth = A, this._warnedUnknownNativeCurrency = /* @__PURE__ */ new Set(), 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._themeMediaCleanup = null, this._isRecoveringSession = !1, this._rnBridgeService = null, this._providers = /* @__PURE__ */ new Map(), this._isAuthenticatedViaRNBridge = !1, this._bridgeSessionRestorePromise = null, this._sdkDeprecationNotified = !1, this._sdkUnsupportedNotified = !1, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = t, e.logger && tt(e.logger), this.confirmation = g, this.pinStore = _ ?? new Nt(), this.stateManager = new Jr({
3639
3885
  setState: (f) => {
3640
3886
  f.authenticated !== void 0 && (this.authenticated = f.authenticated), f.userId !== void 0 && (this.userId = f.userId), f.address !== void 0 && (this.address = f.address), f.activeWalletIndex !== void 0 && (this.activeWalletIndex = f.activeWalletIndex), f.userEmail !== void 0 && (this.userEmail = f.userEmail), f.providerSub !== void 0 && (this.providerSub = f.providerSub), f.loginType !== void 0 && (this.loginType = f.loginType), f.tokenSignatureVerified !== void 0 && (this.tokenSignatureVerified = f.tokenSignatureVerified);
3641
3887
  },
3642
3888
  getIsRecoveringSession: () => this._isRecoveringSession,
3643
3889
  emitAddressChanged: ({ address: f, index: S, walletName: I }) => {
3644
- const R = { address: f, index: S };
3645
- I !== void 0 && (R.walletName = I), this.emit("addressChanged", R);
3890
+ const T = { address: f, index: S };
3891
+ I !== void 0 && (T.walletName = I), this.emit("addressChanged", T);
3646
3892
  },
3647
- emitAuthChanged: ({ isAuthenticated: f, address: S, userId: I, source: R }) => {
3893
+ emitAuthChanged: ({ isAuthenticated: f, address: S, userId: I, source: T }) => {
3648
3894
  this.emit("authChanged", {
3649
3895
  isAuthenticated: f,
3650
3896
  address: S,
3651
3897
  userId: I,
3652
- ...R ? { source: R } : {}
3898
+ ...T ? { source: T } : {}
3653
3899
  });
3654
3900
  },
3655
3901
  shouldPersistWalletPreference: () => this._config.persistWalletPreference !== !1,
3656
- walletPreferenceKey: W.WALLET_PREF_KEY,
3902
+ walletPreferenceKey: b.WALLET_PREF_KEY,
3657
3903
  storage: this.storage,
3658
3904
  pinStore: this.pinStore
3659
- }), this.pinOrchestrator = new X({
3905
+ }), this.pinOrchestrator = new J({
3660
3906
  confirmation: this.confirmation,
3661
3907
  walletProvider: this.walletProvider,
3662
3908
  pinStore: this.pinStore,
3663
3909
  getLocale: () => this._config.locale,
3664
3910
  getUserEmail: () => this.userEmail,
3665
- maskEmail: ye,
3911
+ maskEmail: ve,
3666
3912
  signInAgain: () => this.signInAgain(),
3667
3913
  // §12 native sign delegation: bridge 자동 로그인 세션이면 JS PIN 단계를 스킵한다.
3668
3914
  // dApp 이 sdk.pinOrchestrator.ensureVerifiedPin() 을 직접 호출해도 (SigningOrchestrator 우회)
3669
3915
  // WebView 안에서 embedded PIN 프롬프트가 뜨지 않도록 게이팅. SigningOrchestrator 와 동일 신호.
3670
3916
  isRNBridgeMode: () => this._isAuthenticatedViaRNBridge,
3671
3917
  getPinReusePolicy: () => this.internalConfig.pinReuse
3672
- }), this.signingOrchestrator = new Ir({
3918
+ }), this.signingOrchestrator = new Hr({
3673
3919
  confirmation: this.confirmation,
3674
3920
  walletProvider: this.walletProvider,
3675
3921
  pinOrchestrator: this.pinOrchestrator,
3676
3922
  // §12 native sign delegation: 이 SDK 세션이 RN bridge 자동 로그인으로 인증된 경우만 활성.
3677
3923
  // 자동 로그인 거부 / OAuth 로 별도 로그인한 세션에서는 native SDK 가 미인증이라 우회한다.
3678
3924
  isRNBridgeMode: () => this._isAuthenticatedViaRNBridge
3679
- }), this.walletLifecycleService = new yr({
3925
+ }), this.walletLifecycleService = new $r({
3680
3926
  walletProvider: this.walletProvider,
3681
3927
  pinOrchestrator: this.pinOrchestrator,
3682
3928
  getUserId: () => this.userId,
3683
3929
  setActiveWallet: (f, S, I) => this.setActiveWallet(f, S, I)
3684
- }), this.migrationOrchestrator = new Rr({
3930
+ }), this.migrationOrchestrator = new Yr({
3685
3931
  confirmation: this.confirmation,
3686
3932
  walletProvider: this.walletProvider,
3687
3933
  pinOrchestrator: this.pinOrchestrator,
3688
3934
  executeMigrate: (f, S) => this.migrateWalletUseCase.execute(f, S),
3689
3935
  getLocale: () => this._config.locale,
3690
3936
  getUserEmail: () => this.userEmail,
3691
- maskEmail: ye,
3937
+ maskEmail: ve,
3692
3938
  signInAgain: () => this.signInAgain(),
3693
3939
  clearAuthState: () => this.clearAuthState(),
3694
3940
  getAllowSkip: () => {
3695
3941
  var f;
3696
3942
  return ((f = this._config.migration) == null ? void 0 : f.allowSkip) ?? !0;
3697
3943
  }
3698
- }), this.transactionLifecycleService = new Nr({
3944
+ }), this.transactionLifecycleService = new qr({
3699
3945
  getActiveAddress: () => this.address,
3700
3946
  estimateGas: (f, S) => this.estimateGas(f, S),
3701
3947
  getBaseFeePerGas: (f) => this.getBaseFeePerGas(f),
3702
3948
  jsonRpcCall: (f, S, I) => this.jsonRpc.call(f, S, I)
3703
- }), this.signatureVerifier = new Or(this.crypto), this.addressResolverService = new Dr({
3949
+ }), this.signatureVerifier = new jr(this.crypto), this.addressResolverService = new Xr({
3704
3950
  walletProvider: this.walletProvider,
3705
3951
  pinOrchestrator: this.pinOrchestrator,
3706
3952
  getActiveAddress: () => this.address,
@@ -3708,10 +3954,10 @@ const W = class W extends or {
3708
3954
  getUserId: () => this.userId,
3709
3955
  // one-wallet: 지갑은 처음 쓸 때 만든다 (DEV2TF-2755)
3710
3956
  ensureWallet: this.usesOneWallet ? () => this.walletCreationService.createWallet().then((f) => f.address) : void 0
3711
- }), this.authGuardService = new xr({
3957
+ }), this.authGuardService = new Zr({
3712
3958
  isInitialized: () => this.initialized,
3713
3959
  isAuthenticated: () => this.authenticated
3714
- }), this.walletCreationService = new vr({
3960
+ }), this.walletCreationService = new Qr({
3715
3961
  walletProvider: this.walletProvider,
3716
3962
  pinOrchestrator: this.pinOrchestrator,
3717
3963
  migrationOrchestrator: this.migrationOrchestrator,
@@ -3723,10 +3969,10 @@ const W = class W extends or {
3723
3969
  var f, S;
3724
3970
  return ((S = (f = this.confirmation).showWalletCreatedPrompt) == null ? void 0 : S.call(f)) ?? Promise.resolve();
3725
3971
  }
3726
- }), this.tokenHistoryService = new kr({
3972
+ }), this.tokenHistoryService = new ei({
3727
3973
  transport: n,
3728
3974
  getApiBaseUrl: () => this.internalConfig.authApiUrl
3729
- }), this.sessionOrchestrator = new Tr({
3975
+ }), this.sessionOrchestrator = new Vr({
3730
3976
  ensureInitialized: () => this.ensureInitialized(),
3731
3977
  getSessionSnapshot: () => ({
3732
3978
  providerSub: this.providerSub,
@@ -3748,8 +3994,8 @@ const W = class W extends or {
3748
3994
  applyAuthResult: (f) => this.applyAuthResult(f),
3749
3995
  loadWalletAfterAuth: () => this.walletLifecycleService.loadWalletAfterAuth(),
3750
3996
  getLocale: () => this._config.locale,
3751
- maskEmail: ye
3752
- }), this.chainRegistry = u, this.jsonRpc = new ar(u, n), this.signInUseCase = new Ne(
3997
+ maskEmail: ve
3998
+ }), this.chainRegistry = u, this.jsonRpc = new Or(u, n), this.signInUseCase = new Ue(
3753
3999
  this.internalConfig,
3754
4000
  s,
3755
4001
  r,
@@ -3759,12 +4005,12 @@ const W = class W extends or {
3759
4005
  d,
3760
4006
  void 0,
3761
4007
  () => this._config.locale
3762
- ), this.signOutUseCase = new ls(
4008
+ ), this.signOutUseCase = new Es(
3763
4009
  this.internalConfig,
3764
4010
  s,
3765
4011
  d,
3766
- this._config.persistWalletPreference !== !1 ? [W.WALLET_PREF_KEY] : []
3767
- ), this.migrateWalletUseCase = new hs(s, l), (E = l.setOnUnauthorized) == null || E.call(l, () => this.forceLogout()), (w = l.setTokenRefresher) == null || w.call(
4012
+ this._config.persistWalletPreference !== !1 ? [b.WALLET_PREF_KEY] : []
4013
+ ), this.migrateWalletUseCase = new As(s, l), (E = l.setOnUnauthorized) == null || E.call(l, () => this.forceLogout()), (w = l.setTokenRefresher) == null || w.call(
3768
4014
  l,
3769
4015
  () => this.signInUseCase.refreshAccessToken()
3770
4016
  ), e.autoDetectTheme && this._setupAutoDetectTheme();
@@ -3776,7 +4022,7 @@ const W = class W extends or {
3776
4022
  handleSdkVersionDeprecation(e) {
3777
4023
  if (this._sdkDeprecationNotified) return;
3778
4024
  this._sdkDeprecationNotified = !0;
3779
- const t = le;
4025
+ const t = ge;
3780
4026
  console.warn(
3781
4027
  `[CROSSx] ${t} is deprecated` + (e.sunset ? ` and will stop working on ${e.sunset}` : "") + ". Update @nexus-cross/crossx-sdk-core." + (e.infoUrl ? ` See ${e.infoUrl}` : "")
3782
4028
  ), this.emit("versionDeprecated", { version: t, sunset: e.sunset, infoUrl: e.infoUrl });
@@ -3788,7 +4034,7 @@ const W = class W extends or {
3788
4034
  */
3789
4035
  handleSdkVersionUnsupported(e) {
3790
4036
  this._sdkUnsupportedNotified || (this._sdkUnsupportedNotified = !0, console.error(
3791
- `[CROSSx] ${le} is no longer supported by the wallet gateway. Update @nexus-cross/crossx-sdk-core.` + (e.message ? ` (${e.message})` : "")
4037
+ `[CROSSx] ${ge} is no longer supported by the wallet gateway. Update @nexus-cross/crossx-sdk-core.` + (e.message ? ` (${e.message})` : "")
3792
4038
  ), this.confirmation.showUpdateRequired().catch((t) => {
3793
4039
  c.warn("[CROSSx] 업데이트 필요 모달 표시 실패:", t);
3794
4040
  }));
@@ -3854,15 +4100,15 @@ const W = class W extends or {
3854
4100
  }
3855
4101
  async _doInitialize(e) {
3856
4102
  var t, s;
3857
- c.log("[CROSSx SDK] v3.0.0-beta.4 초기화 중..."), this.confirmation.setMessages(M(this._config.locale));
4103
+ c.log("[CROSSx SDK] v3.0.0-beta.6 초기화 중..."), this.confirmation.setMessages(M(this._config.locale));
3858
4104
  try {
3859
- const r = ue();
4105
+ const r = we();
3860
4106
  if (this.internalConfig.oauthServiceUrl = r.oauthServiceUrl, this.internalConfig.legacyOauthServiceUrl = r.legacyOauthServiceUrl, this.internalConfig.authApiUrl = r.authApiUrl, this.internalConfig.walletGatewayUrl = r.walletGatewayUrl, this.adapterConfig.gatewayUrl = r.walletGatewayUrl, (s = (t = this.crypto).setJWKSEndpoint) == null || s.call(t, `${r.authApiUrl}/.well-known/jwks.json`), this.usesOneWallet) {
3861
4107
  const g = await this.restoreOneWalletSession();
3862
- return this.initialized = !0, c.info("[CROSSx SDK] v3.0.0-beta.4 초기화 완료 (one-wallet)"), this.emit("initialized", { restored: !!(g != null && g.success) }), g;
4108
+ return this.initialized = !0, c.info("[CROSSx SDK] v3.0.0-beta.6 초기화 완료 (one-wallet)"), this.emit("initialized", { restored: !!(g != null && g.success) }), g;
3863
4109
  }
3864
4110
  const n = this._config.persistWalletPreference !== !1 ? await this.storage.get(
3865
- W.WALLET_PREF_KEY
4111
+ b.WALLET_PREF_KEY
3866
4112
  ).catch(() => null) : null, a = (e == null ? void 0 : e.preferredWalletIndex) ?? (n == null ? void 0 : n.index);
3867
4113
  let l = (e == null ? void 0 : e.preferredWalletAddress) ?? (n == null ? void 0 : n.address), d = await this.tryRNBridgeBootstrap();
3868
4114
  if (this._rnBridgeWalletAddress && ((l == null ? void 0 : l.toLowerCase()) !== this._rnBridgeWalletAddress.toLowerCase() && c.log("[CROSSx] RN Bridge active wallet으로 preferredWalletAddress 갱신:", this._rnBridgeWalletAddress), l = this._rnBridgeWalletAddress), d || (d = await this.signInUseCase.restoreSession()), d != null && d.success) {
@@ -3893,7 +4139,7 @@ const W = class W extends or {
3893
4139
  throw _;
3894
4140
  }
3895
4141
  }
3896
- return this.initialized = !0, c.info("[CROSSx SDK] v3.0.0-beta.4 초기화 완료"), this.emit("initialized", { restored: !!(d != null && d.success) }), d ?? null;
4142
+ return this.initialized = !0, c.info("[CROSSx SDK] v3.0.0-beta.6 초기화 완료"), this.emit("initialized", { restored: !!(d != null && d.success) }), d ?? null;
3897
4143
  } catch (r) {
3898
4144
  throw new h(o.AUTH_NOT_INITIALIZED, "SDK 초기화에 실패했습니다", r);
3899
4145
  }
@@ -3908,20 +4154,20 @@ const W = class W extends or {
3908
4154
  * → 사용자가 signIn() 을 호출할 때 bridge 로그인을 시도한다.
3909
4155
  */
3910
4156
  async tryRNBridgeBootstrap() {
3911
- if (!b.isAvailable()) return null;
4157
+ if (!L.isAvailable()) return null;
3912
4158
  try {
3913
4159
  c.log("[CROSSx] RN Bridge 감지 — Handshake 시도"), c.info("[CROSSx][RNBridge trace] Bootstrap config", {
3914
4160
  appId: this._config.projectId,
3915
4161
  appVersion: "1.0.0",
3916
- sdkVersion: "3.0.0-beta.4",
4162
+ sdkVersion: "3.0.0-beta.6",
3917
4163
  keyId: "key-id-1",
3918
4164
  userIdHash: "user-hash-placeholder",
3919
4165
  projectId: this._config.projectId
3920
4166
  });
3921
- const e = new b({
4167
+ const e = new L({
3922
4168
  appId: this._config.projectId,
3923
4169
  appVersion: "1.0.0",
3924
- sdkVersion: "3.0.0-beta.4",
4170
+ sdkVersion: "3.0.0-beta.6",
3925
4171
  keyId: "key-id-1",
3926
4172
  userIdHash: "user-hash-placeholder",
3927
4173
  projectId: this._config.projectId
@@ -4046,7 +4292,7 @@ const W = class W extends or {
4046
4292
  * @internal
4047
4293
  */
4048
4294
  getRNBridge() {
4049
- return b.getBridge();
4295
+ return L.getBridge();
4050
4296
  }
4051
4297
  async signIn(e) {
4052
4298
  if (this.ensureInitialized(), this.authenticated)
@@ -4067,7 +4313,7 @@ const W = class W extends or {
4067
4313
  let s = e;
4068
4314
  if (!(e != null && e.provider)) {
4069
4315
  const r = await this.confirmation.showLoginSelector({
4070
- connectOtherWallets: Zt(this._config)
4316
+ connectOtherWallets: cs(this._config)
4071
4317
  });
4072
4318
  if (r === null)
4073
4319
  return { success: !1, error: "User cancelled login" };
@@ -4285,7 +4531,7 @@ const W = class W extends or {
4285
4531
  try {
4286
4532
  return await e.sessions.getAccessToken();
4287
4533
  } catch (t) {
4288
- throw this.usesOneWallet && tt(t) && this.clearAuthState(), t;
4534
+ throw this.usesOneWallet && Ce(t) && this.clearAuthState(), t;
4289
4535
  }
4290
4536
  }
4291
4537
  /**
@@ -4293,7 +4539,7 @@ const W = class W extends or {
4293
4539
  */
4294
4540
  async signOutOneId() {
4295
4541
  const { sessions: e } = this.oneIdContext();
4296
- this.walletProvider instanceof Ct && await this.walletProvider.signOut().catch((t) => c.warn("[CROSSx] B 키 폐기 실패 (로그아웃은 진행)", t));
4542
+ this.walletProvider instanceof We && await this.walletProvider.signOut().catch((t) => c.warn("[CROSSx] B 키 폐기 실패 (로그아웃은 진행)", t));
4297
4543
  try {
4298
4544
  await e.signOut();
4299
4545
  } finally {
@@ -4341,16 +4587,34 @@ const W = class W extends or {
4341
4587
  }
4342
4588
  /** ONE ID 세션 → SDK 로그인 상태. 지갑이 있으면 주소를 싣고(PIN 불필요), 없으면 처음 쓸 때 만든다 */
4343
4589
  async applyOneIdSession(e) {
4344
- var r, n;
4590
+ var n, a;
4345
4591
  let t;
4346
4592
  try {
4347
- await ((n = (r = this.walletProvider).checkWallet) == null ? void 0 : n.call(r)) === "exists" && (t = (await this.walletProvider.getOrCreateWallet(e.subject)).address);
4348
- } catch (a) {
4349
- if (tt(a)) throw a;
4350
- c.warn("[CROSSx] one-wallet: 지갑 조회 실패 — 주소 없이 로그인 상태로 둔다", a);
4593
+ await ((a = (n = this.walletProvider).checkWallet) == null ? void 0 : a.call(n)) === "exists" && (t = (await this.walletProvider.getOrCreateWallet(e.subject)).address);
4594
+ } catch (l) {
4595
+ if (Ce(l)) throw l;
4596
+ c.warn("[CROSSx] one-wallet: 지갑 조회 실패 — 주소 없이 로그인 상태로 둔다", l);
4597
+ }
4598
+ const s = t ? await this.preferredOneWallet(e.subject, t) : void 0, r = { success: !0, address: s == null ? void 0 : s.address, user: { id: e.subject } };
4599
+ return this.applyAuthResult(r), s && this.setActiveWallet(s.address, s.index), r;
4600
+ }
4601
+ /**
4602
+ * one-wallet 로그인 · 복원 때 쓸 사용 지갑. 저장된 선호 지갑(`persistWalletPreference`)이 이 계정의 주소 목록에
4603
+ * 있으면 그 지갑, 없거나 읽지 못하면 첫 지갑(index 0) — 2.x 와 같이 고른 지갑이 새로고침 · 재로그인 뒤에도 이어진다.
4604
+ * 다른 계정으로 로그인하면 저장값이 목록에 없어 첫 지갑이 된다 (DEV2TF-2916).
4605
+ */
4606
+ async preferredOneWallet(e, t) {
4607
+ const s = { address: t, index: 0 };
4608
+ if (this._config.persistWalletPreference === !1) return s;
4609
+ const r = await this.storage.get(b.WALLET_PREF_KEY).catch(() => null);
4610
+ if (typeof (r == null ? void 0 : r.address) != "string" || r.address.toLowerCase() === t.toLowerCase()) return s;
4611
+ try {
4612
+ const a = (await this.walletProvider.getAddresses(e)).find((l) => l.address.toLowerCase() === r.address.toLowerCase());
4613
+ return a ? { address: a.address, index: a.index } : s;
4614
+ } catch (n) {
4615
+ if (Ce(n)) throw n;
4616
+ return c.warn("[CROSSx] one-wallet: 선호 지갑 확인 실패 — 첫 지갑을 쓴다", n), s;
4351
4617
  }
4352
- const s = { success: !0, address: t, user: { id: e.subject } };
4353
- return this.applyAuthResult(s), t && this.setActiveWallet(t, 0), s;
4354
4618
  }
4355
4619
  oneIdContext() {
4356
4620
  return this.ensureInitialized(), this.oneIdContextUnchecked();
@@ -4363,17 +4627,17 @@ const W = class W extends or {
4363
4627
  o.NOT_IMPLEMENTED,
4364
4628
  "이 환경에서는 ONE ID 로그인을 사용할 수 없습니다 (SDKConfig.oneId 필요)"
4365
4629
  );
4366
- const t = e.issuer || ue().oneIdIssuer;
4630
+ const t = e.issuer || we().oneIdIssuer;
4367
4631
  if (!t)
4368
4632
  throw new h(
4369
4633
  o.NOT_IMPLEMENTED,
4370
4634
  "ONE ID issuer가 정해지지 않았습니다. SDKConfig.oneId.issuer를 지정하세요"
4371
4635
  );
4372
4636
  const s = { issuer: t, clientId: e.clientId, scope: e.scope };
4373
- return this._oneIdSessions ?? (this._oneIdSessions = new Ts(
4637
+ return this._oneIdSessions ?? (this._oneIdSessions = new Vs(
4374
4638
  this.oneIdAuth,
4375
4639
  s,
4376
- ys(e.storage)
4640
+ $s(e.storage)
4377
4641
  )), { port: this.oneIdAuth, config: s, sessions: this._oneIdSessions };
4378
4642
  }
4379
4643
  async signOut() {
@@ -4383,7 +4647,7 @@ const W = class W extends or {
4383
4647
  }
4384
4648
  try {
4385
4649
  await this.signOutUseCase.execute(), this.clearAuthState();
4386
- const e = b.getBridge();
4650
+ const e = L.getBridge();
4387
4651
  if (e != null && e.signOut)
4388
4652
  try {
4389
4653
  await e.signOut(), c.log("[CROSSx] RN Bridge signOut 통보 완료 — native trust cache 무효화");
@@ -4613,19 +4877,41 @@ const W = class W extends or {
4613
4877
  const r = await this.confirmation.showWalletSelector(
4614
4878
  s,
4615
4879
  async () => {
4616
- await this.pinOrchestrator.ensurePinForSigning();
4617
- const n = s.length, l = { address: (await this.pinOrchestrator.withPinRetry(
4618
- () => this.withSessionRecovery(
4619
- () => this.walletProvider.getAddress(this.userId, n)
4620
- )
4621
- )).address, index: n };
4622
- return s.push(l), l;
4880
+ this.pinOrchestrator.prepareForSigning({ action: "sign-message", context: {} });
4881
+ try {
4882
+ await this.pinOrchestrator.ensurePinForSigning();
4883
+ const n = s.length, l = { address: (await this.pinOrchestrator.withPinRetry(
4884
+ () => this.withSessionRecovery(
4885
+ () => this.walletProvider.getAddress(this.userId, n)
4886
+ )
4887
+ )).address, index: n };
4888
+ return s.push(l), l;
4889
+ } finally {
4890
+ this.pinOrchestrator.finishSigning();
4891
+ }
4623
4892
  },
4624
4893
  e,
4625
4894
  t
4626
4895
  );
4627
4896
  return r && this.setActiveWallet(r.address, r.index), r;
4628
4897
  }
4898
+ /**
4899
+ * 지갑 목록에 있는 지갑으로 사용 지갑을 바꿉니다 (모달 없이). 서비스의 지갑 목록 화면에서 고른 지갑을 쓸 때 부릅니다.
4900
+ * 바뀌면 `addressChanged` 이벤트가 나갑니다. 이미 사용 지갑이면 그대로 둡니다 (DEV2TF-2916).
4901
+ *
4902
+ * @param address 바꿀 지갑 주소 (대소문자 무시)
4903
+ * @returns 바꾼 지갑 `{ address, index, name? }`
4904
+ * @throws `WALLET_NOT_FOUND` 이 계정의 지갑 목록에 없는 주소
4905
+ */
4906
+ async switchWallet(e) {
4907
+ var r;
4908
+ if (this.ensureAuthenticated(), !this.userId)
4909
+ throw new h(o.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
4910
+ const s = (await this.withSessionRecovery(() => this.walletProvider.getAddresses(this.userId))).find((n) => n.address.toLowerCase() === e.toLowerCase());
4911
+ if (!s)
4912
+ throw new h(o.WALLET_NOT_FOUND, "이 계정의 지갑이 아닙니다");
4913
+ return (((r = this.address) == null ? void 0 : r.toLowerCase()) !== s.address.toLowerCase() || this.activeWalletIndex !== s.index) && this.setActiveWallet(s.address, s.index), s;
4914
+ }
4629
4915
  /**
4630
4916
  * 지갑이 2개 이상이면 selectWallet()을 호출합니다.
4631
4917
  * selectWallet() 내부에서 this.address 설정 및 addressChanged 이벤트를 처리합니다.
@@ -4640,7 +4926,7 @@ const W = class W extends or {
4640
4926
  */
4641
4927
  async selectWalletIfMultiple(e, t) {
4642
4928
  if (e.length < 2) return null;
4643
- const s = this._isAuthenticatedViaRNBridge ? this._rnBridgeWalletAddress ?? this.address ?? void 0 : void 0, r = !s && this._config.persistWalletPreference !== !1 ? await this.storage.get(W.WALLET_PREF_KEY).catch(() => null) : null, n = s ? [s, t] : [t, r == null ? void 0 : r.address];
4929
+ const s = this._isAuthenticatedViaRNBridge ? this._rnBridgeWalletAddress ?? this.address ?? void 0 : void 0, r = !s && this._config.persistWalletPreference !== !1 ? await this.storage.get(b.WALLET_PREF_KEY).catch(() => null) : null, n = s ? [s, t] : [t, r == null ? void 0 : r.address];
4644
4930
  for (const a of n) {
4645
4931
  if (typeof a != "string" || !a) continue;
4646
4932
  const l = e.find(
@@ -4763,10 +5049,10 @@ const W = class W extends or {
4763
5049
  * 상황은 정상적으로 발생하므로, 조용히 넘어가지 않고 체인당 한 번 경고한다.
4764
5050
  */
4765
5051
  resolveNativeCurrency(e) {
4766
- const t = is(e, this._config.nativeCurrencies);
5052
+ const t = _s(e, this._config.nativeCurrencies);
4767
5053
  return t || (this._warnedUnknownNativeCurrency.has(e) || (this._warnedUnknownNativeCurrency.add(e), console.warn(
4768
5054
  `[CROSSx SDK] ${e} 의 native 통화 정보가 없어 심볼을 비우고 decimals 를 18 로 가정합니다. 컨펌 모달 금액이 단위 없이 표시되며, decimals 가 18 이 아니면 금액이 틀립니다. SDKConfig.nativeCurrencies 에 { '${e}': { symbol, decimals } } 를 넘겨 주세요.`
4769
- )), rs);
5055
+ )), gs);
4770
5056
  }
4771
5057
  /**
4772
5058
  * 지갑 생성/로드 (로그인 후 address가 없는 경우)
@@ -4794,7 +5080,7 @@ const W = class W extends or {
4794
5080
  return this.withSessionRecovery(() => this._signMessage(e, t, s));
4795
5081
  }
4796
5082
  async _signMessage(e, t, s) {
4797
- const r = b.getBridge(), n = this._isAuthenticatedViaRNBridge || !this.authenticated;
5083
+ const r = L.getBridge(), n = this._isAuthenticatedViaRNBridge || !this.authenticated;
4798
5084
  if (r != null && r.signMessage && n)
4799
5085
  try {
4800
5086
  const l = await r.signMessage({
@@ -4806,8 +5092,8 @@ const W = class W extends or {
4806
5092
  });
4807
5093
  return { chainId: e, signature: l.signature, message: t, address: this.address ?? "" };
4808
5094
  } catch (l) {
4809
- if (!_t(l))
4810
- throw q(l, o.SIGNATURE_FAILED);
5095
+ if (!Tt(l))
5096
+ throw j(l, o.SIGNATURE_FAILED);
4811
5097
  await this.clearRNBridgeDelegation("native signMessage 가 ERR_BRIDGE_NOT_AUTHORIZED 로 거부"), c.warn("[CROSSx] Bridge 미인증 — 일반 서명 경로로 폴백 (signMessage)");
4812
5098
  }
4813
5099
  if (this.ensureAuthenticated(), !this.userId)
@@ -4878,7 +5164,7 @@ const W = class W extends or {
4878
5164
  throw new h(o.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
4879
5165
  if (!this.walletProvider.signTypedData)
4880
5166
  throw new h(o.NOT_IMPLEMENTED, "signTypedData가 구현되어 있지 않습니다");
4881
- gr(e, t);
5167
+ Ur(e, t);
4882
5168
  const r = await this.resolveAddress(s == null ? void 0 : s.index);
4883
5169
  try {
4884
5170
  const n = await this.signingOrchestrator.confirmAndExecuteWithPreparedPin({
@@ -4902,7 +5188,7 @@ const W = class W extends or {
4902
5188
  r.address
4903
5189
  )
4904
5190
  });
4905
- return dr(n.signature), {
5191
+ return vr(n.signature), {
4906
5192
  chainId: e,
4907
5193
  signature: n.signature,
4908
5194
  address: r.address
@@ -4931,7 +5217,7 @@ const W = class W extends or {
4931
5217
  * });
4932
5218
  */
4933
5219
  async signTypedDataOffchain(e, t) {
4934
- return this.signTypedData(W.OFFCHAIN_CHAIN_ID, e, t);
5220
+ return this.signTypedData(b.OFFCHAIN_CHAIN_ID, e, t);
4935
5221
  }
4936
5222
  // ============================================================================
4937
5223
  // 트랜잭션
@@ -4980,7 +5266,7 @@ const W = class W extends or {
4980
5266
  l
4981
5267
  )
4982
5268
  });
4983
- return ur(a.signature), {
5269
+ return kr(a.signature), {
4984
5270
  chainId: e,
4985
5271
  signedTx: a.signature,
4986
5272
  txHash: a.txHash ?? ""
@@ -5049,7 +5335,7 @@ const W = class W extends or {
5049
5335
  return _.txHash ?? _.signature;
5050
5336
  }
5051
5337
  }), l = (t.data ?? "").toLowerCase().replace(/^0x/, ""), d = l === "" || l === "00000000", g = l.startsWith("a9059cbb");
5052
- return (d || g) && this.tokenHistoryService.registerHistoryFireAndForget(e, a, le).catch(
5338
+ return (d || g) && this.tokenHistoryService.registerHistoryFireAndForget(e, a, ge).catch(
5053
5339
  (u) => c.log("[TokenHistory] register failed (non-critical):", u)
5054
5340
  ), { chainId: e, txHash: a, status: "pending" };
5055
5341
  } catch (a) {
@@ -5081,7 +5367,7 @@ const W = class W extends or {
5081
5367
  * @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
5082
5368
  */
5083
5369
  async waitForTxAndGetReceipt(e, t, s = {}) {
5084
- const r = s.intervalMs ?? Bt, n = Gt, a = s.timeoutMs ?? Fe, l = Date.now() + a;
5370
+ const r = s.intervalMs ?? Jt, n = Xt, a = s.timeoutMs ?? je, l = Date.now() + a;
5085
5371
  let d = r;
5086
5372
  for (; Date.now() < l; ) {
5087
5373
  const g = await this.getTransactionReceipt(e, t);
@@ -5111,23 +5397,23 @@ const W = class W extends or {
5111
5397
  async sendTransactionWithWaitForReceipt(e, t, s = {}) {
5112
5398
  var w, f;
5113
5399
  if (this._isAuthenticatedViaRNBridge) {
5114
- const S = b.getBridge();
5400
+ const S = L.getBridge();
5115
5401
  if (S != null && S.sendTransactionWithWaitForReceipt)
5116
5402
  return this.bridgeSendTransactionWithWaitForReceipt(S, e, t, s);
5117
5403
  }
5118
- const { intervalMs: r, timeoutMs: n, ...a } = s, { txHash: l } = await this.sendTransaction(e, t, a), d = r ?? ((w = this._config.receiptPolling) == null ? void 0 : w.intervalMs) ?? Ft, g = n ?? ((f = this._config.receiptPolling) == null ? void 0 : f.timeoutMs) ?? Fe, u = this.resolveNativeCurrency(e), _ = t.from ?? "";
5404
+ const { intervalMs: r, timeoutMs: n, ...a } = s, { txHash: l } = await this.sendTransaction(e, t, a), d = r ?? ((w = this._config.receiptPolling) == null ? void 0 : w.intervalMs) ?? zt, g = n ?? ((f = this._config.receiptPolling) == null ? void 0 : f.timeoutMs) ?? je, u = this.resolveNativeCurrency(e), _ = t.from ?? "";
5119
5405
  let p, A;
5120
5406
  const E = this.waitForTxAndGetReceipt(l, e, { intervalMs: d, timeoutMs: g }).then((S) => {
5121
5407
  p = S;
5122
- const I = BigInt(S.gasUsed) * BigInt(S.effectiveGasPrice), R = t.value ? BigInt(t.value) : 0n, O = ae(t.value, u.symbol, u.decimals, this._config.displayDecimals), C = ae("0x" + I.toString(16), u.symbol, u.decimals, this._config.displayDecimals), N = ae("0x" + (R + I).toString(16), u.symbol, u.decimals, this._config.displayDecimals);
5408
+ const I = BigInt(S.gasUsed) * BigInt(S.effectiveGasPrice), T = t.value ? BigInt(t.value) : 0n, O = he(t.value, u.symbol, u.decimals, this._config.displayDecimals), y = he("0x" + I.toString(16), u.symbol, u.decimals, this._config.displayDecimals), R = he("0x" + (T + I).toString(16), u.symbol, u.decimals, this._config.displayDecimals);
5123
5409
  return {
5124
5410
  chainId: e,
5125
5411
  txHash: l,
5126
5412
  from: S.from,
5127
5413
  to: S.to ?? t.to,
5128
5414
  amount: O,
5129
- fees: C,
5130
- total: N,
5415
+ fees: y,
5416
+ total: R,
5131
5417
  nativeSymbol: u.symbol,
5132
5418
  status: S.status === "0x1" ? "success" : "reverted"
5133
5419
  };
@@ -5136,7 +5422,7 @@ const W = class W extends or {
5136
5422
  txHash: l,
5137
5423
  from: _,
5138
5424
  to: t.to,
5139
- amount: ae(t.value, u.symbol, u.decimals, this._config.displayDecimals),
5425
+ amount: he(t.value, u.symbol, u.decimals, this._config.displayDecimals),
5140
5426
  nativeSymbol: u.symbol,
5141
5427
  status: "timeout"
5142
5428
  }));
@@ -5173,7 +5459,7 @@ const W = class W extends or {
5173
5459
  pollIntervalMs: r.intervalMs
5174
5460
  });
5175
5461
  } catch (a) {
5176
- throw q(a, o.TRANSACTION_FAILED);
5462
+ throw j(a, o.TRANSACTION_FAILED);
5177
5463
  }
5178
5464
  return {
5179
5465
  chainId: t,
@@ -5376,7 +5662,7 @@ const W = class W extends or {
5376
5662
  return { wei: "0x0", formatted: "0", chainId: e };
5377
5663
  try {
5378
5664
  const r = await this.jsonRpc.call("eth_getBalance", [t, "latest"], e) ?? "0x0";
5379
- return { wei: r, formatted: hr(r, this._config.displayDecimals), chainId: e };
5665
+ return { wei: r, formatted: xr(r, this._config.displayDecimals), chainId: e };
5380
5666
  } catch (s) {
5381
5667
  if (s instanceof h) throw s;
5382
5668
  const r = s instanceof Error ? s.message : String(s);
@@ -5404,7 +5690,7 @@ const W = class W extends or {
5404
5690
  getProvider(e) {
5405
5691
  this.ensureAuthenticated();
5406
5692
  let t = this._providers.get(e);
5407
- return t || (t = new ns(this, e), this._providers.set(e, t)), t;
5693
+ return t || (t = new fs(this, e), this._providers.set(e, t)), t;
5408
5694
  }
5409
5695
  /**
5410
5696
  * EIP-1193 `accountsChanged` 이벤트를 모든 활성 provider 인스턴스에 dispatch 한다.
@@ -5464,7 +5750,7 @@ const W = class W extends or {
5464
5750
  * 보안: bridge.isActivated() 가 false 이거나 payload sanitize 실패 시 이벤트 무시.
5465
5751
  */
5466
5752
  subscribeBridgeWalletChanged() {
5467
- const e = b.getBridge();
5753
+ const e = L.getBridge();
5468
5754
  if (!(e != null && e.onEvent)) {
5469
5755
  c.warn("[CROSSx] bridge.onEvent 미지원 — walletChanged 구독 불가");
5470
5756
  return;
@@ -5507,7 +5793,7 @@ const W = class W extends or {
5507
5793
  }
5508
5794
  /** 인증 상태를 초기화합니다. */
5509
5795
  clearAuthState() {
5510
- this.stateManager.clearAuthState(), this._isAuthenticatedViaRNBridge = !1;
5796
+ this.stateManager.clearAuthState(), this.walletProvider instanceof We && this.walletProvider.forgetSession(), this._isAuthenticatedViaRNBridge = !1;
5511
5797
  }
5512
5798
  /**
5513
5799
  * Gateway -10002(Unauthorized) / -10033(User not found) 수신 시 강제 로그아웃.
@@ -5625,12 +5911,12 @@ const W = class W extends or {
5625
5911
  */
5626
5912
  dispose() {
5627
5913
  var e;
5628
- (e = this._themeMediaCleanup) == null || e.call(this), this._themeMediaCleanup = null, this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), Ye(null);
5914
+ (e = this._themeMediaCleanup) == null || e.call(this), this._themeMediaCleanup = null, this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), tt(null);
5629
5915
  }
5630
5916
  };
5631
- W.WALLET_PREF_KEY = "wallet_preference", W.OFFCHAIN_CHAIN_ID = "0";
5632
- let Ce = W;
5633
- class Ur {
5917
+ b.WALLET_PREF_KEY = "wallet_preference", b.OFFCHAIN_CHAIN_ID = "0";
5918
+ let Me = b;
5919
+ class ti {
5634
5920
  constructor() {
5635
5921
  this.prefix = "crossx_";
5636
5922
  }
@@ -5667,8 +5953,8 @@ class Ur {
5667
5953
  }
5668
5954
  }
5669
5955
  }
5670
- const oe = "crossx-sdk", ot = 1, k = "data", B = "keys", ce = "aes-primary", br = 12;
5671
- class ct {
5956
+ const de = "crossx-sdk", pt = 1, v = "data", B = "keys", ue = "aes-primary", si = 12;
5957
+ class wt {
5672
5958
  constructor(e) {
5673
5959
  this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
5674
5960
  }
@@ -5677,10 +5963,10 @@ class ct {
5677
5963
  }
5678
5964
  openDB() {
5679
5965
  return new Promise((e, t) => {
5680
- const s = indexedDB.open(this.dbName, ot);
5966
+ const s = indexedDB.open(this.dbName, pt);
5681
5967
  s.onupgradeneeded = () => {
5682
5968
  const r = s.result;
5683
- r.objectStoreNames.contains(k) || r.createObjectStore(k), r.objectStoreNames.contains(B) || r.createObjectStore(B);
5969
+ r.objectStoreNames.contains(v) || r.createObjectStore(v), r.objectStoreNames.contains(B) || r.createObjectStore(B);
5684
5970
  }, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error);
5685
5971
  });
5686
5972
  }
@@ -5695,16 +5981,16 @@ class ct {
5695
5981
  openLegacyIfExists() {
5696
5982
  return new Promise((e, t) => {
5697
5983
  let s = !1;
5698
- const r = indexedDB.open(oe, ot);
5984
+ const r = indexedDB.open(de, pt);
5699
5985
  r.onupgradeneeded = () => {
5700
5986
  s = !0;
5701
5987
  }, r.onsuccess = () => {
5702
5988
  const n = r.result;
5703
5989
  if (s) {
5704
- n.close(), this.deleteDB(oe).then(() => e(null));
5990
+ n.close(), this.deleteDB(de).then(() => e(null));
5705
5991
  return;
5706
5992
  }
5707
- if (!n.objectStoreNames.contains(B) || !n.objectStoreNames.contains(k)) {
5993
+ if (!n.objectStoreNames.contains(B) || !n.objectStoreNames.contains(v)) {
5708
5994
  n.close(), e(null);
5709
5995
  return;
5710
5996
  }
@@ -5755,7 +6041,7 @@ class ct {
5755
6041
  }
5756
6042
  async init() {
5757
6043
  this.db = await this.openDB();
5758
- const e = await this.idbGet(B, ce);
6044
+ const e = await this.idbGet(B, ue);
5759
6045
  if (e) {
5760
6046
  this.cryptoKey = e;
5761
6047
  return;
@@ -5769,23 +6055,23 @@ class ct {
5769
6055
  { name: "AES-GCM", length: 256 },
5770
6056
  !1,
5771
6057
  ["encrypt", "decrypt"]
5772
- ), await this.idbPut(B, ce, this.cryptoKey);
6058
+ ), await this.idbPut(B, ue, this.cryptoKey);
5773
6059
  }
5774
6060
  /**
5775
6061
  * 레거시 DB('crossx-sdk')에서 projectId 스코프 DB로 암호키·데이터 마이그레이션.
5776
6062
  * 마이그레이션 성공 시 레거시 DB 삭제.
5777
6063
  */
5778
6064
  async migrateFromLegacyDB() {
5779
- if (this.dbName === oe) return null;
6065
+ if (this.dbName === de) return null;
5780
6066
  try {
5781
6067
  const e = await this.openLegacyIfExists();
5782
6068
  if (!e) return null;
5783
- const t = e.transaction([B, k], "readonly"), s = t.objectStore(B).get(ce), r = await new Promise((g, u) => {
6069
+ const t = e.transaction([B, v], "readonly"), s = t.objectStore(B).get(ue), r = await new Promise((g, u) => {
5784
6070
  s.onsuccess = () => g(s.result), s.onerror = () => u(s.error);
5785
6071
  });
5786
6072
  if (!r)
5787
6073
  return e.close(), null;
5788
- const n = t.objectStore(k).getAll(), a = t.objectStore(k).getAllKeys(), [l, d] = await Promise.all([
6074
+ const n = t.objectStore(v).getAll(), a = t.objectStore(v).getAllKeys(), [l, d] = await Promise.all([
5789
6075
  new Promise((g, u) => {
5790
6076
  n.onsuccess = () => g(n.result), n.onerror = () => u(n.error);
5791
6077
  }),
@@ -5793,16 +6079,16 @@ class ct {
5793
6079
  a.onsuccess = () => g(a.result), a.onerror = () => u(a.error);
5794
6080
  })
5795
6081
  ]);
5796
- e.close(), await this.idbPut(B, ce, r);
6082
+ e.close(), await this.idbPut(B, ue, r);
5797
6083
  for (let g = 0; g < d.length; g++)
5798
- await this.idbPut(k, String(d[g]), l[g]);
5799
- return await this.deleteDB(oe), c.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), r;
6084
+ await this.idbPut(v, String(d[g]), l[g]);
6085
+ return await this.deleteDB(de), c.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), r;
5800
6086
  } catch (e) {
5801
6087
  return c.warn("[CROSSx] IndexedDB 레거시 DB 마이그레이션 실패:", e), null;
5802
6088
  }
5803
6089
  }
5804
6090
  async encrypt(e) {
5805
- const t = new Uint8Array(br);
6091
+ const t = new Uint8Array(si);
5806
6092
  crypto.getRandomValues(t);
5807
6093
  const s = new TextEncoder().encode(e), r = await crypto.subtle.encrypt(
5808
6094
  { name: "AES-GCM", iv: t },
@@ -5823,7 +6109,7 @@ class ct {
5823
6109
  try {
5824
6110
  await this.ensureReady();
5825
6111
  const s = JSON.stringify(t), r = await this.encrypt(s);
5826
- await this.idbPut(k, e, r);
6112
+ await this.idbPut(v, e, r);
5827
6113
  } catch (s) {
5828
6114
  throw c.error("[CROSSx] IndexedDB set error:", s), s;
5829
6115
  }
@@ -5831,7 +6117,7 @@ class ct {
5831
6117
  async get(e) {
5832
6118
  try {
5833
6119
  await this.ensureReady();
5834
- const t = await this.idbGet(k, e);
6120
+ const t = await this.idbGet(v, e);
5835
6121
  if (!t) return null;
5836
6122
  const s = await this.decrypt(t);
5837
6123
  return JSON.parse(s);
@@ -5841,14 +6127,14 @@ class ct {
5841
6127
  }
5842
6128
  async remove(e) {
5843
6129
  try {
5844
- await this.ensureReady(), await this.idbDelete(k, e);
6130
+ await this.ensureReady(), await this.idbDelete(v, e);
5845
6131
  } catch (t) {
5846
6132
  throw c.error("[CROSSx] IndexedDB remove error:", t), t;
5847
6133
  }
5848
6134
  }
5849
6135
  async clear() {
5850
6136
  try {
5851
- await this.ensureReady(), await this.idbClear(k);
6137
+ await this.ensureReady(), await this.idbClear(v);
5852
6138
  } catch (e) {
5853
6139
  throw c.error("[CROSSx] IndexedDB clear error:", e), e;
5854
6140
  }
@@ -5860,14 +6146,14 @@ class ct {
5860
6146
  return typeof indexedDB < "u" && typeof crypto < "u" && typeof crypto.subtle < "u";
5861
6147
  }
5862
6148
  }
5863
- const Lr = 60;
5864
- class Wr {
6149
+ const ri = 60;
6150
+ class ii {
5865
6151
  constructor() {
5866
6152
  this.jwks = null;
5867
6153
  }
5868
6154
  setJWKSEndpoint(e) {
5869
6155
  try {
5870
- this.jwks = Ut(new URL(e)), c.log("[CROSSx] JWKS 엔드포인트 설정:", e);
6156
+ this.jwks = Vt(new URL(e)), c.log("[CROSSx] JWKS 엔드포인트 설정:", e);
5871
6157
  } catch (t) {
5872
6158
  c.warn("[CROSSx] JWKS 엔드포인트 URL 파싱 실패:", t);
5873
6159
  }
@@ -5881,7 +6167,7 @@ class Wr {
5881
6167
  iat: s.iat
5882
6168
  });
5883
6169
  const r = Math.floor(Date.now() / 1e3);
5884
- if (s.exp && s.exp + Lr < r)
6170
+ if (s.exp && s.exp + ri < r)
5885
6171
  return c.warn("[CROSSx] 토큰 만료:", {
5886
6172
  exp: s.exp,
5887
6173
  now: r,
@@ -5891,7 +6177,7 @@ class Wr {
5891
6177
  return c.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: s, valid: !1, signatureVerified: !1 };
5892
6178
  if (this.jwks)
5893
6179
  try {
5894
- const { payload: n } = await bt(e, this.jwks, {
6180
+ const { payload: n } = await $t(e, this.jwks, {
5895
6181
  algorithms: ["RS256", "ES256"]
5896
6182
  });
5897
6183
  return c.log("[CROSSx] JWT 서명 검증 성공"), {
@@ -5910,7 +6196,7 @@ class Wr {
5910
6196
  }
5911
6197
  }
5912
6198
  decodeJWT(e) {
5913
- return Lt(e);
6199
+ return Yt(e);
5914
6200
  }
5915
6201
  /**
5916
6202
  * EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
@@ -5925,29 +6211,29 @@ class Wr {
5925
6211
  ${s.length}`
5926
6212
  ), n = new Uint8Array(r.length + s.length);
5927
6213
  n.set(r, 0), n.set(s, r.length);
5928
- const a = Me(n), l = t.startsWith("0x") ? t.slice(2) : t;
6214
+ const a = qe(n), l = t.startsWith("0x") ? t.slice(2) : t;
5929
6215
  if (l.length !== 130)
5930
6216
  throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${l.length}`);
5931
- const d = Mr(l), g = d.slice(0, 32), u = d.slice(32, 64), _ = d[64], p = _ >= 27 ? _ - 27 : _, w = new Wt.Signature(
5932
- lt(g),
5933
- lt(u)
5934
- ).addRecoveryBit(p).recoverPublicKey(a).toBytes(!1).slice(1), f = Me(w);
5935
- return "0x" + Mt(f.slice(12));
6217
+ const d = ni(l), g = d.slice(0, 32), u = d.slice(32, 64), _ = d[64], p = _ >= 27 ? _ - 27 : _, w = new qt.Signature(
6218
+ St(g),
6219
+ St(u)
6220
+ ).addRecoveryBit(p).recoverPublicKey(a).toBytes(!1).slice(1), f = qe(w);
6221
+ return "0x" + jt(f.slice(12));
5936
6222
  }
5937
6223
  }
5938
- function Mr(i) {
6224
+ function ni(i) {
5939
6225
  const e = new Uint8Array(i.length / 2);
5940
6226
  for (let t = 0; t < e.length; t++)
5941
6227
  e[t] = parseInt(i.substring(t * 2, t * 2 + 2), 16);
5942
6228
  return e;
5943
6229
  }
5944
- function lt(i) {
6230
+ function St(i) {
5945
6231
  let e = "0x";
5946
6232
  for (const t of i) e += t.toString(16).padStart(2, "0");
5947
6233
  return BigInt(e);
5948
6234
  }
5949
- const Fr = 5e3;
5950
- class Br {
6235
+ const ai = 5e3;
6236
+ class oi {
5951
6237
  constructor(e, t) {
5952
6238
  this.cachedKey = null, this.cachedVersion = null, this.cachedAt = 0, this.keyInFlight = null, this.keyFailedAt = 0, this.required = !1, this.adapterConfig = e, this.transport = t;
5953
6239
  }
@@ -5960,8 +6246,8 @@ class Br {
5960
6246
  const t = this.required;
5961
6247
  if (!t && this.hasFreshFailure()) return e;
5962
6248
  try {
5963
- const { version: s, key: r } = await this.currentKey(), n = await Gr(r, e);
5964
- return `${s}.${Kr(n)}`;
6249
+ const { version: s, key: r } = await this.currentKey(), n = await ci(r, e);
6250
+ return `${s}.${li(n)}`;
5965
6251
  } catch (s) {
5966
6252
  if (t)
5967
6253
  throw this.keyFailedAt = Date.now(), s instanceof h ? s : new h(
@@ -5971,7 +6257,7 @@ class Br {
5971
6257
  );
5972
6258
  return this.keyFailedAt = Date.now(), c.warn(
5973
6259
  "[CROSSx] pin-key 조회 실패 — PIN 평문 전송을 유지합니다",
5974
- `(${Math.round($e / 1e3)}초 후 재확인)`
6260
+ `(${Math.round(et / 1e3)}초 후 재확인)`
5975
6261
  ), e;
5976
6262
  }
5977
6263
  }
@@ -5998,15 +6284,15 @@ class Br {
5998
6284
  }
5999
6285
  // ── 공개키 캐시 ─────────────────────────────────────────────────────────────
6000
6286
  hasFreshFailure() {
6001
- return this.keyFailedAt !== 0 && Date.now() - this.keyFailedAt < $e;
6287
+ return this.keyFailedAt !== 0 && Date.now() - this.keyFailedAt < et;
6002
6288
  }
6003
6289
  async currentKey() {
6004
- return this.cachedKey && this.cachedVersion && Date.now() - this.cachedAt < $t ? { version: this.cachedVersion, key: this.cachedKey } : this.keyInFlight ? this.keyInFlight : (this.keyInFlight = this.fetchAndImportKey().then((e) => (this.cachedVersion = e.version, this.cachedKey = e.key, this.cachedAt = Date.now(), this.keyFailedAt = 0, c.log("[CROSSx] PIN 공개키 캐시 완료 (keyVersion:", e.version, ")"), e)).finally(() => {
6290
+ return this.cachedKey && this.cachedVersion && Date.now() - this.cachedAt < ts ? { version: this.cachedVersion, key: this.cachedKey } : this.keyInFlight ? this.keyInFlight : (this.keyInFlight = this.fetchAndImportKey().then((e) => (this.cachedVersion = e.version, this.cachedKey = e.key, this.cachedAt = Date.now(), this.keyFailedAt = 0, c.log("[CROSSx] PIN 공개키 캐시 완료 (keyVersion:", e.version, ")"), e)).finally(() => {
6005
6291
  this.keyInFlight = null;
6006
6292
  }), this.keyInFlight);
6007
6293
  }
6008
6294
  async fetchAndImportKey() {
6009
- const e = xt();
6295
+ const e = Gt();
6010
6296
  if (!e)
6011
6297
  throw new h(
6012
6298
  o.PIN_ENCRYPTION_FAILED,
@@ -6016,16 +6302,16 @@ class Br {
6016
6302
  url: `${this.baseUrl}/pin-key`,
6017
6303
  method: "GET",
6018
6304
  headers: { "X-Project-Id": this.adapterConfig.projectId },
6019
- timeoutMs: Fr
6020
- }), s = Yr(t.data);
6305
+ timeoutMs: ai
6306
+ }), s = gi(t.data);
6021
6307
  if (!(s != null && s.keyVersion) || !(s != null && s.publicKey))
6022
6308
  throw new h(
6023
6309
  o.PIN_ENCRYPTION_FAILED,
6024
6310
  "pin-key 응답을 해석할 수 없습니다."
6025
6311
  );
6026
- const r = Vr(s.publicKey), n = await e.importKey(
6312
+ const r = di(s.publicKey), n = await e.importKey(
6027
6313
  "spki",
6028
- $r(r),
6314
+ ui(r),
6029
6315
  { name: "RSA-OAEP", hash: "SHA-256" },
6030
6316
  !1,
6031
6317
  ["encrypt"]
@@ -6033,8 +6319,8 @@ class Br {
6033
6319
  return { version: s.keyVersion, key: n };
6034
6320
  }
6035
6321
  }
6036
- async function Gr(i, e) {
6037
- const t = xt();
6322
+ async function ci(i, e) {
6323
+ const t = Gt();
6038
6324
  if (!t)
6039
6325
  throw new h(
6040
6326
  o.PIN_ENCRYPTION_FAILED,
@@ -6047,29 +6333,29 @@ async function Gr(i, e) {
6047
6333
  );
6048
6334
  return new Uint8Array(s);
6049
6335
  }
6050
- function xt() {
6336
+ function Gt() {
6051
6337
  const i = globalThis.crypto;
6052
6338
  return (i == null ? void 0 : i.subtle) ?? null;
6053
6339
  }
6054
- function Kr(i) {
6055
- return Hr(i).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
6340
+ function li(i) {
6341
+ return hi(i).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
6056
6342
  }
6057
- const te = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
6058
- function Hr(i) {
6343
+ const re = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
6344
+ function hi(i) {
6059
6345
  let e = "";
6060
6346
  for (let t = 0; t < i.length; t += 3) {
6061
6347
  const s = i[t], r = i[t + 1], n = i[t + 2];
6062
- e += te[s >> 2], e += te[(s & 3) << 4 | (r ?? 0) >> 4], e += r === void 0 ? "=" : te[(r & 15) << 2 | (n ?? 0) >> 6], e += n === void 0 ? "=" : te[n & 63];
6348
+ e += re[s >> 2], e += re[(s & 3) << 4 | (r ?? 0) >> 4], e += r === void 0 ? "=" : re[(r & 15) << 2 | (n ?? 0) >> 6], e += n === void 0 ? "=" : re[n & 63];
6063
6349
  }
6064
6350
  return e;
6065
6351
  }
6066
- function Vr(i) {
6352
+ function di(i) {
6067
6353
  const e = i.replace(/-----BEGIN [A-Z ]+-----/g, "").replace(/-----END [A-Z ]+-----/g, "").replace(/\s+/g, "").replace(/-/g, "+").replace(/_/g, "/"), t = e.length % 4 === 0 ? e : e + "=".repeat(4 - e.length % 4), s = [];
6068
6354
  for (let r = 0; r < t.length; r += 4) {
6069
6355
  const n = [0, 1, 2, 3].map((a) => {
6070
6356
  const l = t[r + a];
6071
6357
  if (l === "=" || l === void 0) return -1;
6072
- const d = te.indexOf(l);
6358
+ const d = re.indexOf(l);
6073
6359
  if (d === -1)
6074
6360
  throw new h(
6075
6361
  o.PIN_ENCRYPTION_FAILED,
@@ -6081,11 +6367,11 @@ function Vr(i) {
6081
6367
  }
6082
6368
  return new Uint8Array(s);
6083
6369
  }
6084
- function $r(i) {
6370
+ function ui(i) {
6085
6371
  const e = new Uint8Array(i.length);
6086
6372
  return e.set(i), e.buffer;
6087
6373
  }
6088
- function Yr(i) {
6374
+ function gi(i) {
6089
6375
  if (!i || typeof i != "object") return null;
6090
6376
  const e = i;
6091
6377
  if (typeof e.code == "number") {
@@ -6099,8 +6385,8 @@ function Yr(i) {
6099
6385
  }
6100
6386
  return typeof e.keyVersion == "string" && typeof e.publicKey == "string" ? e : null;
6101
6387
  }
6102
- const qr = 3e4, jr = 1e3;
6103
- class Xr {
6388
+ const _i = 3e4, fi = 1e3;
6389
+ class pi {
6104
6390
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6105
6391
  async request(e) {
6106
6392
  const t = e.retries ?? 0;
@@ -6111,7 +6397,7 @@ class Xr {
6111
6397
  } catch (r) {
6112
6398
  if (s === t) throw r;
6113
6399
  }
6114
- await new Promise((r) => setTimeout(r, jr * 2 ** s));
6400
+ await new Promise((r) => setTimeout(r, fi * 2 ** s));
6115
6401
  }
6116
6402
  throw new Error("Unexpected: retry loop exited without result");
6117
6403
  }
@@ -6119,7 +6405,7 @@ class Xr {
6119
6405
  async _doRequest(e) {
6120
6406
  const t = new AbortController(), s = setTimeout(
6121
6407
  () => t.abort(),
6122
- e.timeoutMs ?? qr
6408
+ e.timeoutMs ?? _i
6123
6409
  );
6124
6410
  try {
6125
6411
  const r = await fetch(e.url, {
@@ -6146,7 +6432,7 @@ class Xr {
6146
6432
  }
6147
6433
  }
6148
6434
  }
6149
- function zr(i) {
6435
+ function wi(i) {
6150
6436
  const e = { raw: i }, t = i.search(/(^|;)\s*info=/i), s = t >= 0 ? i.slice(0, t) : i;
6151
6437
  if (t >= 0) {
6152
6438
  const r = i.slice(t).replace(/^;?\s*info=/i, "").trim();
@@ -6161,14 +6447,14 @@ function zr(i) {
6161
6447
  }
6162
6448
  return e;
6163
6449
  }
6164
- function ht(i) {
6450
+ function Et(i) {
6165
6451
  try {
6166
6452
  return new URL(i).origin;
6167
6453
  } catch {
6168
6454
  return null;
6169
6455
  }
6170
6456
  }
6171
- class Jr {
6457
+ class Si {
6172
6458
  constructor(e, t) {
6173
6459
  this.inner = e, this.options = t;
6174
6460
  }
@@ -6177,52 +6463,52 @@ class Jr {
6177
6463
  if (!this.isGateway(e.url))
6178
6464
  return this.inner.request(e);
6179
6465
  const t = await this.inner.request(
6180
- this.options.sendVersionHeader === !1 ? e : { ...e, headers: { ...e.headers, [Yt]: this.options.version } }
6466
+ this.options.sendVersionHeader === !1 ? e : { ...e, headers: { ...e.headers, [ss]: this.options.version } }
6181
6467
  );
6182
6468
  return this.inspect(t), t;
6183
6469
  }
6184
6470
  isGateway(e) {
6185
- const t = ht(e);
6186
- return t === null ? !1 : this.options.getGatewayBaseUrls().some((s) => ht(s) === t);
6471
+ const t = Et(e);
6472
+ return t === null ? !1 : this.options.getGatewayBaseUrls().some((s) => Et(s) === t);
6187
6473
  }
6188
6474
  inspect(e) {
6189
6475
  var r, n, a, l;
6190
- const t = Qr(e.headers, jt);
6191
- t && ((n = (r = this.options).onDeprecation) == null || n.call(r, zr(t)));
6476
+ const t = Ai(e.headers, is);
6477
+ t && ((n = (r = this.options).onDeprecation) == null || n.call(r, wi(t)));
6192
6478
  const s = e.data;
6193
- s && s.code === de && ((l = (a = this.options).onUnsupported) == null || l.call(a, { message: Zr(s) }));
6479
+ s && s.code === fe && ((l = (a = this.options).onUnsupported) == null || l.call(a, { message: Ei(s) }));
6194
6480
  }
6195
6481
  }
6196
- function Zr(i) {
6482
+ function Ei(i) {
6197
6483
  for (const e of [i.data, i.message])
6198
6484
  if (typeof e == "string" && e.trim()) return e;
6199
6485
  }
6200
- function Qr(i, e) {
6486
+ function Ai(i, e) {
6201
6487
  if (!i) return;
6202
6488
  const t = e.toLowerCase();
6203
6489
  for (const [s, r] of Object.entries(i))
6204
6490
  if (s.toLowerCase() === t && r) return r;
6205
6491
  }
6206
- const ei = [
6492
+ const Ii = [
6207
6493
  /CROSSx\/([\d.]+)/i,
6208
6494
  /ONE\s?wallet[^\s/]*\/([\d.]+)/i,
6209
6495
  /ONE\s?pocket[^\s/]*\/([\d.]+)/i
6210
6496
  ];
6211
- function ve() {
6497
+ function He() {
6212
6498
  return typeof window > "u" ? void 0 : window;
6213
6499
  }
6214
- function ti() {
6215
- const i = ve();
6500
+ function mi() {
6501
+ const i = He();
6216
6502
  return i == null ? void 0 : i.__crossx;
6217
6503
  }
6218
- function si(i) {
6504
+ function Ti(i) {
6219
6505
  return i === "ios" || i === "android" ? i : null;
6220
6506
  }
6221
- function Re() {
6507
+ function ke() {
6222
6508
  const i = typeof navigator > "u" ? "" : navigator.userAgent;
6223
6509
  return /Android/i.test(i) ? "android" : /iPhone|iPad|iPod|Macintosh/i.test(i) ? "ios" : null;
6224
6510
  }
6225
- function ri(i, e) {
6511
+ function yi(i, e) {
6226
6512
  const t = (a) => a.split(/[^\d]+/).filter((l) => l !== "").map((l) => Number.parseInt(l, 10)), s = t(i), r = t(e), n = Math.max(s.length, r.length);
6227
6513
  for (let a = 0; a < n; a += 1) {
6228
6514
  const l = (s[a] ?? 0) - (r[a] ?? 0);
@@ -6230,44 +6516,44 @@ function ri(i, e) {
6230
6516
  }
6231
6517
  return 0;
6232
6518
  }
6233
- function ii() {
6234
- const i = ve();
6519
+ function Ri() {
6520
+ const i = He();
6235
6521
  if (!i) return !1;
6236
6522
  const e = i.__crossxRNBridge;
6237
6523
  return e != null && e.isInstalled ? !0 : i.__CROSSX_BRIDGE_INITIALIZED__ === !0 || i.__CROSSX_RN_BRIDGE_READY__ === !0;
6238
6524
  }
6239
- function dt() {
6525
+ function At() {
6240
6526
  const i = typeof navigator > "u" ? "" : navigator.userAgent;
6241
- for (const e of ei) {
6527
+ for (const e of Ii) {
6242
6528
  const t = e.exec(i);
6243
6529
  if (t) return t[1] ?? null;
6244
6530
  }
6245
6531
  }
6246
- function ge() {
6247
- const i = ti();
6532
+ function Se() {
6533
+ const i = mi();
6248
6534
  if (i != null && i.browser)
6249
6535
  return {
6250
6536
  version: i.version ?? null,
6251
- platform: si(i.platform) ?? Re(),
6537
+ platform: Ti(i.platform) ?? ke(),
6252
6538
  detectedBy: "marker"
6253
6539
  };
6254
- if (ii())
6540
+ if (Ri())
6255
6541
  return {
6256
- version: dt() ?? null,
6257
- platform: Re(),
6542
+ version: At() ?? null,
6543
+ platform: ke(),
6258
6544
  detectedBy: "bridge"
6259
6545
  };
6260
- const e = dt();
6261
- return e !== void 0 ? { version: e, platform: Re(), detectedBy: "user-agent" } : null;
6546
+ const e = At();
6547
+ return e !== void 0 ? { version: e, platform: ke(), detectedBy: "user-agent" } : null;
6262
6548
  }
6263
- function yi() {
6264
- return ge() !== null;
6549
+ function $i() {
6550
+ return Se() !== null;
6265
6551
  }
6266
- function Ri(i = 3e3) {
6267
- const e = ge();
6268
- return e ? Promise.resolve(e) : ve() ? new Promise((t) => {
6552
+ function Yi(i = 3e3) {
6553
+ const e = Se();
6554
+ return e ? Promise.resolve(e) : He() ? new Promise((t) => {
6269
6555
  const s = Date.now(), r = setInterval(() => {
6270
- const n = ge();
6556
+ const n = Se();
6271
6557
  if (n) {
6272
6558
  clearInterval(r), t(n);
6273
6559
  return;
@@ -6276,18 +6562,18 @@ function Ri(i = 3e3) {
6276
6562
  }, 50);
6277
6563
  }) : Promise.resolve(null);
6278
6564
  }
6279
- const ni = /* @__PURE__ */ new Set([
6565
+ const Ni = /* @__PURE__ */ new Set([
6280
6566
  "https://cross-wallet-oauth.crosstoken.io",
6281
6567
  "https://stg-cross-wallet-oauth.crosstoken.io",
6282
6568
  "https://dev-cross-wallet-oauth.crosstoken.io",
6283
6569
  "https://one-wallet-oauth.onechain.nexus",
6284
6570
  "https://stg-one-wallet-oauth.onechain.nexus",
6285
6571
  "https://dev-one-wallet-oauth.onechain.nexus"
6286
- ]), ai = "crossx://oauth-callback", oi = "2.3.2";
6287
- function ci(i) {
6288
- return i.platform !== "ios" ? !1 : i.version ? ri(i.version, oi) <= 0 : !0;
6572
+ ]), Oi = "crossx://oauth-callback", Pi = "2.3.2";
6573
+ function Ci(i) {
6574
+ return i.platform !== "ios" ? !1 : i.version ? yi(i.version, Pi) <= 0 : !0;
6289
6575
  }
6290
- class H {
6576
+ class K {
6291
6577
  constructor() {
6292
6578
  this.abortPending = null;
6293
6579
  }
@@ -6322,7 +6608,7 @@ class H {
6322
6608
  * - Google 및 기타: originalNonce === jwt.nonce
6323
6609
  */
6324
6610
  static async verifyIdTokenNonce(e, t) {
6325
- const s = H.parseJwtPayload(e), r = s.nonce, n = typeof s.iss == "string" ? s.iss : "(unknown)";
6611
+ const s = K.parseJwtPayload(e), r = s.nonce, n = typeof s.iss == "string" ? s.iss : "(unknown)";
6326
6612
  if (c.log("[CROSSx] nonce 검증 시작 —", {
6327
6613
  iss: n,
6328
6614
  nonceClaimType: typeof r,
@@ -6344,7 +6630,7 @@ class H {
6344
6630
  return;
6345
6631
  }
6346
6632
  if (n.includes("appleid.apple.com")) {
6347
- const a = await H.sha256Hex(t);
6633
+ const a = await K.sha256Hex(t);
6348
6634
  if (c.log("[CROSSx] Apple nonce 검증 —", {
6349
6635
  expectedHashLength: a.length,
6350
6636
  receivedHashLength: r.length,
@@ -6361,16 +6647,16 @@ class H {
6361
6647
  }
6362
6648
  openAuth(e) {
6363
6649
  return new Promise((t, s) => {
6364
- const r = Math.max(e.width ?? 500, 500), n = Math.max(e.height ?? 700, 700), a = window.screenX + (window.outerWidth - r) / 2, l = window.screenY + (window.outerHeight - n) / 2, d = H.generateRandom16Hex(), g = H.generateRandom16Hex(), u = ge();
6650
+ const r = Math.max(e.width ?? 500, 500), n = Math.max(e.height ?? 700, 700), a = window.screenX + (window.outerWidth - r) / 2, l = window.screenY + (window.outerHeight - n) / 2, d = K.generateRandom16Hex(), g = K.generateRandom16Hex(), u = Se();
6365
6651
  let _ = e.authUrl;
6366
- u && e.legacyAuthUrl && ci(u) && (_ = e.legacyAuthUrl, c.info("[CROSSx] 구버전 iOS 지갑 감지 — 이관 전 OAuth 호스트 사용", {
6652
+ u && e.legacyAuthUrl && Ci(u) && (_ = e.legacyAuthUrl, c.info("[CROSSx] 구버전 iOS 지갑 감지 — 이관 전 OAuth 호스트 사용", {
6367
6653
  appVersion: u.version ?? "(unknown)",
6368
6654
  detectedBy: u.detectedBy,
6369
6655
  authUrlBase: e.legacyAuthUrl
6370
6656
  }));
6371
6657
  const p = _.includes("?") ? "&" : "?", A = encodeURIComponent(window.location.origin);
6372
6658
  let E = `${_}${p}state=${d}&nonce=${g}&origin=${A}`;
6373
- u && !E.includes("redirectUrl=") && (E += `&redirectUrl=${encodeURIComponent(ai)}`, c.info("[CROSSx] 지갑 인앱 브라우저 감지 — redirectUrl 콜백 자동 부착", {
6659
+ u && !E.includes("redirectUrl=") && (E += `&redirectUrl=${encodeURIComponent(Oi)}`, c.info("[CROSSx] 지갑 인앱 브라우저 감지 — redirectUrl 콜백 자동 부착", {
6374
6660
  detectedBy: u.detectedBy,
6375
6661
  appVersion: u.version ?? "(unknown)",
6376
6662
  platform: u.platform ?? "(unknown)"
@@ -6389,78 +6675,78 @@ class H {
6389
6675
  return;
6390
6676
  }
6391
6677
  const f = setTimeout(() => {
6392
- c.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), m(), s(new Error("Authentication timeout"));
6678
+ c.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), N(), s(new Error("Authentication timeout"));
6393
6679
  }, 300 * 1e3), S = 10, I = 30;
6394
- let R = 0, O = null;
6395
- const C = () => {
6396
- clearInterval(N), c.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + I + "초간 대기합니다"), O = setTimeout(() => {
6397
- m(), s(new Error(
6680
+ let T = 0, O = null;
6681
+ const y = () => {
6682
+ clearInterval(R), c.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + I + "초간 대기합니다"), O = setTimeout(() => {
6683
+ N(), s(new Error(
6398
6684
  "OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
6399
6685
  ));
6400
6686
  }, I * 1e3);
6401
- }, N = setInterval(() => {
6402
- R++;
6687
+ }, R = setInterval(() => {
6688
+ T++;
6403
6689
  try {
6404
6690
  if (!w.closed) return;
6405
6691
  if (!!u) {
6406
- m(), s(new h(o.USER_REJECTED, "로그인이 취소되었습니다"));
6692
+ N(), s(new h(o.USER_REJECTED, "로그인이 취소되었습니다"));
6407
6693
  return;
6408
6694
  }
6409
- const y = typeof document < "u" && document.hasFocus();
6410
- R <= S && !y ? C() : (m(), s(new h(o.USER_REJECTED, "로그인이 취소되었습니다")));
6695
+ const U = typeof document < "u" && document.hasFocus();
6696
+ T <= S && !U ? y() : (N(), s(new h(o.USER_REJECTED, "로그인이 취소되었습니다")));
6411
6697
  } catch {
6412
- C();
6698
+ y();
6413
6699
  }
6414
- }, 1e3), m = () => {
6415
- this.abortPending = null, clearTimeout(f), clearInterval(N), O && clearTimeout(O), window.removeEventListener("message", v);
6416
- }, v = (D) => {
6417
- if (!ni.has(D.origin)) return;
6418
- m();
6419
- const y = typeof D.data.status == "string", T = y ? D.data.data ?? {} : D.data;
6700
+ }, 1e3), N = () => {
6701
+ this.abortPending = null, clearTimeout(f), clearInterval(R), O && clearTimeout(O), window.removeEventListener("message", D);
6702
+ }, D = (C) => {
6703
+ if (!Ni.has(C.origin)) return;
6704
+ N();
6705
+ const U = typeof C.data.status == "string", m = U ? C.data.data ?? {} : C.data;
6420
6706
  c.log("[CROSSx] OAuth postMessage 수신 —", {
6421
- format: y ? "wrapped" : "flat",
6422
- status: y ? D.data.status : "(flat)"
6707
+ format: U ? "wrapped" : "flat",
6708
+ status: U ? C.data.status : "(flat)"
6423
6709
  });
6424
- const ke = (T == null ? void 0 : T.state) ?? D.data.state;
6425
- if (!ke || ke !== d) {
6710
+ const Q = (m == null ? void 0 : m.state) ?? C.data.state;
6711
+ if (!Q || Q !== d) {
6426
6712
  s(new Error("OAuth state mismatch — possible CSRF attack"));
6427
6713
  return;
6428
6714
  }
6429
- if (y && D.data.status !== "success") {
6430
- c.error("[CROSSx] OAuth 실패:", T == null ? void 0 : T.error), s(new Error((T == null ? void 0 : T.error) || "Authentication failed"));
6715
+ if (U && C.data.status !== "success") {
6716
+ c.error("[CROSSx] OAuth 실패:", m == null ? void 0 : m.error), s(new Error((m == null ? void 0 : m.error) || "Authentication failed"));
6431
6717
  return;
6432
6718
  }
6433
- if (!y && (T != null && T.error)) {
6434
- c.error("[CROSSx] OAuth 실패:", T.error), s(new Error(T.error || "Authentication failed"));
6719
+ if (!U && (m != null && m.error)) {
6720
+ c.error("[CROSSx] OAuth 실패:", m.error), s(new Error(m.error || "Authentication failed"));
6435
6721
  return;
6436
6722
  }
6437
- const $ = T == null ? void 0 : T.idToken, Z = T == null ? void 0 : T.accessToken, Ue = Z ?? $, be = (T == null ? void 0 : T.email) || void 0;
6723
+ const $ = m == null ? void 0 : m.idToken, ee = m == null ? void 0 : m.accessToken, Ke = ee ?? $, Ve = (m == null ? void 0 : m.email) || void 0;
6438
6724
  if (c.log("[CROSSx] OAuth 토큰 수신:", {
6439
- hasAccessToken: !!Z,
6725
+ hasAccessToken: !!ee,
6440
6726
  hasIdToken: !!$,
6441
- hasEmail: !!be
6442
- }), !Ue) {
6443
- c.error("[CROSSx] 토큰을 찾을 수 없음:", D.data), s(new Error("Token not found in response"));
6727
+ hasEmail: !!Ve
6728
+ }), !Ke) {
6729
+ c.error("[CROSSx] 토큰을 찾을 수 없음:", C.data), s(new Error("Token not found in response"));
6444
6730
  return;
6445
6731
  }
6446
- const Le = { token: Ue, email: be }, Se = (We) => {
6447
- H.verifyIdTokenNonce(We, g).then(() => t(Le)).catch((we) => {
6448
- c.error("[CROSSx] nonce 검증 실패:", we), s(we instanceof Error ? we : new Error("nonce verification failed"));
6732
+ const $e = { token: Ke, email: Ve }, me = (Ye) => {
6733
+ K.verifyIdTokenNonce(Ye, g).then(() => t($e)).catch((Te) => {
6734
+ c.error("[CROSSx] nonce 검증 실패:", Te), s(Te instanceof Error ? Te : new Error("nonce verification failed"));
6449
6735
  });
6450
6736
  };
6451
- Z ? Z.split(".").length === 3 ? Se(Z) : $ ? Se($) : (c.warn(
6737
+ ee ? ee.split(".").length === 3 ? me(ee) : $ ? me($) : (c.warn(
6452
6738
  "[CROSSx] opaque accessToken만 수신 (idToken 없음) — nonce 검증 불가.",
6453
6739
  "서버 측 nonce 검증이 필요합니다."
6454
- ), t(Le)) : $ ? Se($) : s(new Error("Token not found in response"));
6740
+ ), t($e)) : $ ? me($) : s(new Error("Token not found in response"));
6455
6741
  };
6456
- this.abortPending = (D) => {
6457
- m(), s(new Error(D));
6458
- }, window.addEventListener("message", v);
6742
+ this.abortPending = (C) => {
6743
+ N(), s(new Error(C));
6744
+ }, window.addEventListener("message", D);
6459
6745
  });
6460
6746
  }
6461
6747
  }
6462
- const ee = "crossx_wallet_data", Y = "crossx_mock_pin_hash";
6463
- class li {
6748
+ const se = "crossx_wallet_data", q = "crossx_mock_pin_hash";
6749
+ class Di {
6464
6750
  constructor(e, t) {
6465
6751
  this.storage = e, this.pinStore = t ?? null;
6466
6752
  }
@@ -6473,13 +6759,13 @@ class li {
6473
6759
  async checkWallet() {
6474
6760
  if (this.migrateScenario !== void 0)
6475
6761
  return c.log("[Mock] checkWallet → migration_required"), "migration_required";
6476
- const t = await this.storage.get(ee) ? "exists" : "not_found";
6762
+ const t = await this.storage.get(se) ? "exists" : "not_found";
6477
6763
  return c.log(`[Mock] checkWallet → ${t}`), t;
6478
6764
  }
6479
6765
  async getOrCreateWallet(e) {
6480
6766
  var t;
6481
6767
  try {
6482
- const s = await this.storage.get(ee);
6768
+ const s = await this.storage.get(se);
6483
6769
  if (s) return s;
6484
6770
  const r = {
6485
6771
  id: e,
@@ -6487,16 +6773,16 @@ class li {
6487
6773
  derivationPath: "m/44'/60'/0'/0/0",
6488
6774
  createdAt: Date.now()
6489
6775
  };
6490
- await this.storage.set(ee, r);
6776
+ await this.storage.set(se, r);
6491
6777
  const n = (t = this.pinStore) == null ? void 0 : t.get();
6492
- return n && (await this.storage.set(Y, n), c.log("[Mock] 지갑 생성 — PIN 저장됨")), r;
6778
+ return n && (await this.storage.set(q, n), c.log("[Mock] 지갑 생성 — PIN 저장됨")), r;
6493
6779
  } catch (s) {
6494
6780
  throw new h(o.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", s);
6495
6781
  }
6496
6782
  }
6497
6783
  /** GET /mnemonic/addresses 모킹 — PIN 불필요, 캐시된 주소 반환 */
6498
6784
  async getAddresses(e) {
6499
- const t = await this.storage.get(ee);
6785
+ const t = await this.storage.get(se);
6500
6786
  return t ? [{ address: t.address, index: 0 }] : [];
6501
6787
  }
6502
6788
  async getAddress(e, t) {
@@ -6531,8 +6817,8 @@ class li {
6531
6817
  var s;
6532
6818
  if (c.log("[Mock] verifyPin"), this.pinScenario === "wrong")
6533
6819
  return !1;
6534
- const t = await this.storage.get(Y);
6535
- return t && t !== e ? !1 : (t || await this.storage.set(Y, e), (s = this.pinStore) == null || s.set(e), c.log("[Mock] verifyPin → 성공"), !0);
6820
+ const t = await this.storage.get(q);
6821
+ return t && t !== e ? !1 : (t || await this.storage.set(q, e), (s = this.pinStore) == null || s.set(e), c.log("[Mock] verifyPin → 성공"), !0);
6536
6822
  }
6537
6823
  /**
6538
6824
  * POST /mnemonic/change-password 모킹
@@ -6542,10 +6828,10 @@ class li {
6542
6828
  var n;
6543
6829
  if (c.log("[Mock] changePin"), this.pinScenario === "wrong")
6544
6830
  throw new h(o.PIN_WRONG, "Incorrect PIN.");
6545
- const s = (n = this.pinStore) == null ? void 0 : n.get(), r = await this.storage.get(Y);
6831
+ const s = (n = this.pinStore) == null ? void 0 : n.get(), r = await this.storage.get(q);
6546
6832
  if (r && s && r !== s)
6547
6833
  throw new h(o.PIN_WRONG, "Incorrect PIN.");
6548
- await this.storage.set(Y, t), c.log("[Mock] changePin 완료");
6834
+ await this.storage.set(q, t), c.log("[Mock] changePin 완료");
6549
6835
  }
6550
6836
  async migrateWallet(e, t) {
6551
6837
  var n;
@@ -6576,9 +6862,9 @@ class li {
6576
6862
  derivationPath: "m/44'/60'/0'/0/0",
6577
6863
  createdAt: Date.now()
6578
6864
  };
6579
- await this.storage.set(ee, s);
6865
+ await this.storage.set(se, s);
6580
6866
  const r = (n = this.pinStore) == null ? void 0 : n.get();
6581
- return r && (await this.storage.set(Y, r), c.log("[Mock] 마이그레이션 — PIN 저장됨")), s;
6867
+ return r && (await this.storage.set(q, r), c.log("[Mock] 마이그레이션 — PIN 저장됨")), s;
6582
6868
  }
6583
6869
  /**
6584
6870
  * POST /mnemonic/share-c 모킹
@@ -6605,7 +6891,7 @@ class li {
6605
6891
  ).join("");
6606
6892
  }
6607
6893
  }
6608
- const hi = ["password", "newPassword", "recoveryPin"];
6894
+ const xi = ["password", "newPassword", "recoveryPin"];
6609
6895
  class V {
6610
6896
  constructor(e, t, s, r, n, a) {
6611
6897
  this._refreshPromise = null, this._walletStatusCache = null, this.adapterConfig = e, this.projectId = e.projectId, this.storage = t, this.transport = s, this.tokenStore = r, this.pinStore = n ?? null, this.pinEncryptor = a ?? null;
@@ -6633,9 +6919,9 @@ class V {
6633
6919
  */
6634
6920
  async ensureValidToken() {
6635
6921
  const e = this.tokenStore.get();
6636
- if (e && !this.tokenStore.isExpiringSoon(He))
6922
+ if (e && !this.tokenStore.isExpiringSoon(Ze))
6637
6923
  return e;
6638
- const t = !e || this.tokenStore.isExpiringSoon(He);
6924
+ const t = !e || this.tokenStore.isExpiringSoon(Ze);
6639
6925
  if (this._onTokenRefresh) {
6640
6926
  if (await this.deduplicatedRefresh()) {
6641
6927
  const r = this.tokenStore.get();
@@ -6671,7 +6957,7 @@ class V {
6671
6957
  async sealPinFields(e) {
6672
6958
  if (!this.pinEncryptor || !e || typeof e != "object") return e;
6673
6959
  let t = null;
6674
- for (const s of hi) {
6960
+ for (const s of xi) {
6675
6961
  const r = e[s];
6676
6962
  if (typeof r != "string" || r === "") continue;
6677
6963
  const n = await this.pinEncryptor.seal(r);
@@ -6715,9 +7001,9 @@ class V {
6715
7001
  o.USER_NOT_FOUND,
6716
7002
  V.getGatewayErrorMessage(w.code, f)
6717
7003
  );
6718
- const I = S === o.AUTH_NOT_AUTHENTICATED ? o.SESSION_EXPIRED : S, R = I === o.SESSION_EXPIRED ? "인증 세션이 만료되었습니다. 다시 로그인해 주세요." : V.getGatewayErrorMessage(w.code, f), O = w.data;
6719
- let C;
6720
- throw S === o.PIN_LOCKED ? C = V.extractLockDetails(O) : S === o.ADDRESS_LIMIT_EXCEEDED ? C = { limit: Ve, raw: O } : C = O ?? void 0, new h(I, R, C);
7004
+ const I = S === o.AUTH_NOT_AUTHENTICATED ? o.SESSION_EXPIRED : S, T = I === o.SESSION_EXPIRED ? "인증 세션이 만료되었습니다. 다시 로그인해 주세요." : V.getGatewayErrorMessage(w.code, f), O = w.data;
7005
+ let y;
7006
+ throw S === o.PIN_LOCKED ? y = V.extractLockDetails(O) : S === o.ADDRESS_LIMIT_EXCEEDED ? y = { limit: Qe, raw: O } : y = O ?? void 0, new h(I, T, y);
6721
7007
  }
6722
7008
  return c.log("[CROSSx] Wallet Gateway API 성공:", { code: w.code, url: l, method: e }), w.data ?? w;
6723
7009
  }
@@ -7040,7 +7326,7 @@ class V {
7040
7326
  return o.ORIGIN_NOT_ALLOWED;
7041
7327
  case -10025:
7042
7328
  return o.INVALID_APP_TYPE;
7043
- case de:
7329
+ case fe:
7044
7330
  return o.SDK_VERSION_UNSUPPORTED;
7045
7331
  // PIN 관련
7046
7332
  case -10028:
@@ -7109,7 +7395,7 @@ class V {
7109
7395
  return "Origin or App ID is required. Register the current domain or set X-App-Id header.";
7110
7396
  case -10025:
7111
7397
  return "Invalid app type. X-App-Type must be android, ios, or windows.";
7112
- case de:
7398
+ case fe:
7113
7399
  return `This SDK version is no longer supported. Update @nexus-cross/crossx-sdk-core.${t ? ` (${t})` : ""}`;
7114
7400
  case -10026:
7115
7401
  return "Domain chainId mismatch: the chainId in typedData.domain does not match the request chainId.";
@@ -7128,7 +7414,7 @@ class V {
7128
7414
  case -10033:
7129
7415
  return "User not found. You have been signed out.";
7130
7416
  case -10036:
7131
- return `Account limit reached. Maximum ${Ve} accounts allowed.`;
7417
+ return `Account limit reached. Maximum ${Qe} accounts allowed.`;
7132
7418
  case -10045:
7133
7419
  return "Could not securely send your PIN. Please try again.";
7134
7420
  case -10046:
@@ -7142,7 +7428,7 @@ class V {
7142
7428
  }
7143
7429
  }
7144
7430
  }
7145
- class di {
7431
+ class vi {
7146
7432
  constructor(e, t, s, r = () => {
7147
7433
  }, n = () => {
7148
7434
  }, a = () => {
@@ -7175,7 +7461,7 @@ class di {
7175
7461
  * 넘길 수 있으면 위임을 해제(SDK 상태 정리)하고 true 를 돌려준다.
7176
7462
  */
7177
7463
  async recoverFromUnauthorized(e, t, s, r) {
7178
- return !_t(e) || !await this.innerOwnsAddress(t, s) ? !1 : (this.onBridgeUnauthorized(
7464
+ return !Tt(e) || !await this.innerOwnsAddress(t, s) ? !1 : (this.onBridgeUnauthorized(
7179
7465
  `native 가 ${r} 을 ERR_BRIDGE_NOT_AUTHORIZED 로 거부 — inner provider 로 폴백`
7180
7466
  ), !0);
7181
7467
  }
@@ -7199,7 +7485,7 @@ class di {
7199
7485
  };
7200
7486
  } catch (d) {
7201
7487
  if (!await this.recoverFromUnauthorized(d, e, a, "signMessage"))
7202
- throw q(d, o.SIGNATURE_FAILED);
7488
+ throw j(d, o.SIGNATURE_FAILED);
7203
7489
  }
7204
7490
  }
7205
7491
  return this.inner.signMessage(e, t, s, r, n, a);
@@ -7223,7 +7509,7 @@ class di {
7223
7509
  };
7224
7510
  } catch (d) {
7225
7511
  if (!await this.recoverFromUnauthorized(d, e, a, "signTypedData"))
7226
- throw q(d, o.SIGNATURE_FAILED);
7512
+ throw j(d, o.SIGNATURE_FAILED);
7227
7513
  }
7228
7514
  }
7229
7515
  if (!this.inner.signTypedData)
@@ -7249,7 +7535,7 @@ class di {
7249
7535
  };
7250
7536
  } catch (l) {
7251
7537
  if (!await this.recoverFromUnauthorized(l, e, s.from, "signTransaction"))
7252
- throw q(l, o.SIGNATURE_FAILED);
7538
+ throw j(l, o.SIGNATURE_FAILED);
7253
7539
  }
7254
7540
  }
7255
7541
  return this.inner.signTransaction(e, t, s, r, n);
@@ -7267,7 +7553,7 @@ class di {
7267
7553
  })).txHash };
7268
7554
  } catch (a) {
7269
7555
  if (!await this.recoverFromUnauthorized(a, e, s.from, "sendTransaction"))
7270
- throw q(a, o.TRANSACTION_FAILED);
7556
+ throw j(a, o.TRANSACTION_FAILED);
7271
7557
  }
7272
7558
  }
7273
7559
  if (!this.inner.sendTransaction)
@@ -7305,7 +7591,7 @@ class di {
7305
7591
  (s = (t = this.inner).setTokenRefresher) == null || s.call(t, e);
7306
7592
  }
7307
7593
  }
7308
- class re {
7594
+ class ne {
7309
7595
  constructor(e, t) {
7310
7596
  this.cache = /* @__PURE__ */ new Map(), this.loadedAt = 0, this.usingFallback = !1, this._fetchPromise = null, this.adapterConfig = e, this.projectId = e.projectId, this.transport = t;
7311
7597
  }
@@ -7326,7 +7612,7 @@ class re {
7326
7612
  const t = e.data.chains;
7327
7613
  return this.populateCache(t, !1), t;
7328
7614
  } catch {
7329
- const e = re.fallbackChains();
7615
+ const e = ne.fallbackChains();
7330
7616
  return this.populateCache(e, !0), e;
7331
7617
  }
7332
7618
  }
@@ -7340,7 +7626,7 @@ class re {
7340
7626
  }
7341
7627
  isCacheValid() {
7342
7628
  if (this.loadedAt === 0) return !1;
7343
- const e = this.usingFallback ? Vt : Ht;
7629
+ const e = this.usingFallback ? es : Qt;
7344
7630
  return e === 0 ? !0 : Date.now() - this.loadedAt < e;
7345
7631
  }
7346
7632
  populateCache(e, t) {
@@ -7362,13 +7648,13 @@ class re {
7362
7648
  if (e.code < 0) {
7363
7649
  const t = typeof e.data == "string" ? e.data : e.message ?? "체인 레지스트리 요청에 실패했습니다";
7364
7650
  throw new h(
7365
- re.mapErrorCode(e.code),
7651
+ ne.mapErrorCode(e.code),
7366
7652
  t
7367
7653
  );
7368
7654
  }
7369
7655
  }
7370
7656
  fallbackOrThrow(e) {
7371
- const t = re.fallbackChains().find(
7657
+ const t = ne.fallbackChains().find(
7372
7658
  (s) => s.chainId === e
7373
7659
  );
7374
7660
  if (t) return t;
@@ -7378,7 +7664,7 @@ class re {
7378
7664
  );
7379
7665
  }
7380
7666
  static fallbackChains() {
7381
- return Object.values(fe).map((e) => ({
7667
+ return Object.values(Ae).map((e) => ({
7382
7668
  chainId: e.caipId,
7383
7669
  rpcUrl: e.rpcUrl
7384
7670
  }));
@@ -7397,7 +7683,7 @@ class re {
7397
7683
  return o.APP_IDENTIFIER_MISSING;
7398
7684
  case -10025:
7399
7685
  return o.INVALID_APP_TYPE;
7400
- case de:
7686
+ case fe:
7401
7687
  return o.SDK_VERSION_UNSUPPORTED;
7402
7688
  default:
7403
7689
  return o.UNKNOWN_ERROR;
@@ -7412,7 +7698,7 @@ function G(i) {
7412
7698
  )
7413
7699
  );
7414
7700
  }
7415
- class ui {
7701
+ class ki {
7416
7702
  // ─── 사용자 입력이 필요한 화면 → UI_NOT_PROVIDED ───
7417
7703
  requestConfirmation(e) {
7418
7704
  return G("requestConfirmation");
@@ -7461,7 +7747,7 @@ class ui {
7461
7747
  setPinKeyboard() {
7462
7748
  }
7463
7749
  }
7464
- class gi {
7750
+ class Ui {
7465
7751
  constructor(e, t, s, r = () => !1) {
7466
7752
  this.browserConfirmation = e, this.getBridge = t, this.getOrigin = s, this.isAuthenticatedViaRNBridge = r;
7467
7753
  }
@@ -7634,7 +7920,7 @@ class gi {
7634
7920
  (s = (t = this.browserConfirmation).setPinKeyboard) == null || s.call(t, e);
7635
7921
  }
7636
7922
  }
7637
- class _i {
7923
+ class bi {
7638
7924
  constructor() {
7639
7925
  this._accessToken = null, this._expiresAt = 0;
7640
7926
  }
@@ -7666,38 +7952,38 @@ class _i {
7666
7952
  return !this._accessToken || this._expiresAt <= 0 ? !0 : Date.now() >= this._expiresAt - e;
7667
7953
  }
7668
7954
  }
7669
- const vt = /* @__PURE__ */ new WeakMap();
7670
- function fi(i, e) {
7671
- vt.set(i, e);
7955
+ const Ht = /* @__PURE__ */ new WeakMap();
7956
+ function Li(i, e) {
7957
+ Ht.set(i, e);
7672
7958
  }
7673
- function Ni(i) {
7674
- const e = vt.get(i);
7959
+ function qi(i) {
7960
+ const e = Ht.get(i);
7675
7961
  if (!e)
7676
7962
  throw new Error(
7677
7963
  "[CROSSx] Internal context not found — create the SDK with the core factory, and import the root and /internal entries in the same module format (ESM or CJS)."
7678
7964
  );
7679
7965
  return e;
7680
7966
  }
7681
- function pi(i) {
7682
- return kt(i);
7967
+ function Wi(i) {
7968
+ return Kt(i);
7683
7969
  }
7684
- function Oi(i, e) {
7685
- return kt(i, e);
7970
+ function ji(i, e) {
7971
+ return Kt(i, e);
7686
7972
  }
7687
- function kt(i, e) {
7688
- var D;
7973
+ function Kt(i, e) {
7974
+ var U;
7689
7975
  if (!i.projectId)
7690
7976
  throw new Error(
7691
7977
  `[CROSSx] Fatal: projectId is required but was not provided.
7692
7978
  Set the projectId field in SDKConfig when calling createCROSSxSDK().
7693
7979
  Example: createCROSSxSDK({ projectId: "your-project-id", ... })`
7694
7980
  );
7695
- if (i.walletServer === "one-wallet" && !((D = i.oneId) != null && D.clientId))
7981
+ if (i.walletServer === "one-wallet" && !((U = i.oneId) != null && U.clientId))
7696
7982
  throw new Error(
7697
7983
  "[CROSSx] Fatal: walletServer 'one-wallet' requires SDKConfig.oneId (ONE ID login) — DEV2TF-2755"
7698
7984
  );
7699
7985
  i.debug;
7700
- const t = z.production, s = {
7986
+ const t = X.production, s = {
7701
7987
  ...i,
7702
7988
  oauthServiceUrl: t.oauthServiceUrl,
7703
7989
  legacyOauthServiceUrl: t.legacyOauthServiceUrl,
@@ -7708,124 +7994,124 @@ Example: createCROSSxSDK({ projectId: "your-project-id", ... })`
7708
7994
  }, r = {
7709
7995
  gatewayUrl: t.walletGatewayUrl,
7710
7996
  projectId: i.projectId
7711
- }, n = s.authMode !== "cookie" && ct.isAvailable();
7997
+ }, n = s.authMode !== "cookie" && wt.isAvailable();
7712
7998
  !n && s.authMode !== "cookie" && c.warn(
7713
7999
  "[CROSSx] IndexedDB 사용 불가 — LocalStorage fallback 사용 중.",
7714
8000
  "refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
7715
8001
  "IndexedDB를 지원하는 브라우저 사용을 권장합니다."
7716
8002
  ), s.secureStorageAvailable = n;
7717
- const a = n ? new ct(i.projectId) : new Ur(), l = new Wr();
8003
+ const a = n ? new wt(i.projectId) : new ti(), l = new ii();
7718
8004
  let d = null;
7719
- const g = new Jr(new Xr(), {
7720
- version: le,
7721
- sendVersionHeader: qt,
8005
+ const g = new Si(new pi(), {
8006
+ version: ge,
8007
+ sendVersionHeader: rs,
7722
8008
  getGatewayBaseUrls: () => [r.gatewayUrl],
7723
- onDeprecation: (y) => d == null ? void 0 : d.handleSdkVersionDeprecation(y),
7724
- onUnsupported: (y) => d == null ? void 0 : d.handleSdkVersionUnsupported(y)
7725
- }), u = new H(), _ = new _i(), p = new St(), A = new Br(r, g);
7726
- let E;
7727
- i.useMockWallet ? (c.log("[CROSSx] Mock Wallet Provider 사용"), E = new li(a, p)) : i.walletServer === "one-wallet" ? (c.log("[CROSSx] one-wallet-api Wallet Provider 사용"), E = new Ct({
7728
- baseUrl: () => ue().oneWalletApiUrl,
8009
+ onDeprecation: (m) => d == null ? void 0 : d.handleSdkVersionDeprecation(m),
8010
+ onUnsupported: (m) => d == null ? void 0 : d.handleSdkVersionUnsupported(m)
8011
+ }), u = new K(), _ = new bi(), p = e == null ? void 0 : e.pinReuse, A = new Nt({ ttlMs: (p == null ? void 0 : p.mode) === "memory" ? p.ttlMs : void 0 }), E = new oi(r, g);
8012
+ let w;
8013
+ i.useMockWallet ? (c.log("[CROSSx] Mock Wallet Provider 사용"), w = new Di(a, A)) : i.walletServer === "one-wallet" ? (c.log("[CROSSx] one-wallet-api Wallet Provider 사용"), w = new We({
8014
+ baseUrl: () => we().oneWalletApiUrl,
7729
8015
  transport: g,
7730
- pinStore: p,
8016
+ pinStore: A,
7731
8017
  getAccessToken: () => d ? d.getOneIdAccessToken() : Promise.reject(new h(o.AUTH_NOT_INITIALIZED, "SDK가 아직 만들어지지 않았습니다"))
7732
- })) : (c.log("[CROSSx] Remote Wallet Provider 사용"), E = new V(
8018
+ })) : (c.log("[CROSSx] Remote Wallet Provider 사용"), w = new V(
7733
8019
  r,
7734
8020
  a,
7735
8021
  g,
7736
8022
  _,
7737
- p,
7738
- A
8023
+ A,
8024
+ E
7739
8025
  ));
7740
- const w = () => {
7741
- var y;
7742
- return ((y = d == null ? void 0 : d.isAuthenticatedViaRNBridge) == null ? void 0 : y.call(d)) ?? !1;
7743
- }, f = () => {
7744
- var y;
7745
- return (y = d == null ? void 0 : d.assertRNBridgeSessionActive) == null ? void 0 : y.call(d);
7746
- }, S = (y) => {
7747
- var T;
7748
- (T = d == null ? void 0 : d.clearRNBridgeDelegation) == null || T.call(d, y);
8026
+ const f = () => {
8027
+ var m;
8028
+ return ((m = d == null ? void 0 : d.isAuthenticatedViaRNBridge) == null ? void 0 : m.call(d)) ?? !1;
8029
+ }, S = () => {
8030
+ var m;
8031
+ return (m = d == null ? void 0 : d.assertRNBridgeSessionActive) == null ? void 0 : m.call(d);
8032
+ }, I = (m) => {
8033
+ var Q;
8034
+ (Q = d == null ? void 0 : d.clearRNBridgeDelegation) == null || Q.call(d, m);
7749
8035
  };
7750
- i.walletServer !== "one-wallet" && (E = new di(
7751
- E,
8036
+ i.walletServer !== "one-wallet" && (w = new vi(
8037
+ w,
7752
8038
  () => {
7753
- var y;
7754
- return (y = d == null ? void 0 : d.getRNBridge) == null ? void 0 : y.call(d);
8039
+ var m;
8040
+ return (m = d == null ? void 0 : d.getRNBridge) == null ? void 0 : m.call(d);
7755
8041
  },
7756
- w,
7757
8042
  f,
8043
+ S,
7758
8044
  () => i.appName,
7759
- S
8045
+ I
7760
8046
  ));
7761
- const I = new re(r, g), R = ue(), O = e != null && e.ui ? e.ui({
8047
+ const T = new ne(r, g), O = we(), y = e != null && e.ui ? e.ui({
7762
8048
  theme: i.theme ?? "light",
7763
8049
  themeTokens: i.themeTokens,
7764
8050
  displayDecimals: i.displayDecimals,
7765
8051
  pinKeyboard: i.pinKeyboard,
7766
8052
  endpoints: {
7767
- contentsBaseUrl: R.contentsBaseUrl,
7768
- portraitBaseUrl: R.portraitBaseUrl
8053
+ contentsBaseUrl: O.contentsBaseUrl,
8054
+ portraitBaseUrl: O.portraitBaseUrl
7769
8055
  }
7770
- }) : new ui(), C = new gi(
7771
- O,
8056
+ }) : new ki(), R = new Ui(
8057
+ y,
7772
8058
  () => {
7773
- var y;
7774
- return (y = d == null ? void 0 : d.getRNBridge) == null ? void 0 : y.call(d);
8059
+ var m;
8060
+ return (m = d == null ? void 0 : d.getRNBridge) == null ? void 0 : m.call(d);
7775
8061
  },
7776
8062
  () => typeof window < "u" ? window.location.origin : "http://localhost",
7777
- w
7778
- ), N = e != null && e.wrapConfirmation ? e.wrapConfirmation(C) : C, m = new Ce(
8063
+ f
8064
+ ), N = e != null && e.wrapConfirmation ? e.wrapConfirmation(R) : R, D = new Me(
7779
8065
  s,
7780
8066
  r,
7781
8067
  a,
7782
8068
  l,
7783
8069
  g,
7784
8070
  u,
7785
- E,
8071
+ w,
7786
8072
  _,
7787
8073
  N,
7788
- I,
7789
- p,
8074
+ T,
7790
8075
  A,
7791
- new ms()
8076
+ E,
8077
+ new Gs()
7792
8078
  );
7793
- d = m, fi(m, {
8079
+ d = D, Li(D, {
7794
8080
  transport: g,
7795
8081
  storage: a,
7796
- walletProvider: E,
8082
+ walletProvider: w,
7797
8083
  confirmation: N,
7798
8084
  tokenStore: _,
7799
- pinStore: p,
8085
+ pinStore: A,
7800
8086
  adapterConfig: r,
7801
- pinEncryptor: A
8087
+ pinEncryptor: E
7802
8088
  });
7803
- const v = m.signInUseCase;
7804
- return v && typeof v.setFreshTokenCallback == "function" && v.setFreshTokenCallback(() => m.requestFreshFirebaseIdTokenFromBridge()), typeof window < "u" && (window.__crossxSDK = m), m;
8089
+ const C = D.signInUseCase;
8090
+ return C && typeof C.setFreshTokenCallback == "function" && C.setFreshTokenCallback(() => D.requestFreshFirebaseIdTokenFromBridge()), typeof window < "u" && (window.__crossxSDK = D), D;
7805
8091
  }
7806
- const Pi = pi;
8092
+ const zi = Wi;
7807
8093
  export {
7808
- Jt as C,
7809
- Ti as D,
8094
+ os as C,
8095
+ Vi as D,
7810
8096
  o as E,
7811
- pt as M,
7812
- St as P,
7813
- _i as T,
7814
- gt as W,
8097
+ Rt as M,
8098
+ Nt as P,
8099
+ bi as T,
8100
+ mt as W,
7815
8101
  h as a,
7816
- ns as b,
7817
- Oi as c,
7818
- Ce as d,
7819
- mi as e,
7820
- Xt as f,
7821
- Ni as g,
7822
- as as h,
7823
- Ve as i,
7824
- ut as j,
7825
- pi as k,
7826
- Pi as l,
7827
- Ii as m,
7828
- ge as n,
7829
- yi as o,
7830
- Ri as w
8102
+ fs as b,
8103
+ ji as c,
8104
+ Me as d,
8105
+ Ki as e,
8106
+ ns as f,
8107
+ qi as g,
8108
+ ps as h,
8109
+ Qe as i,
8110
+ It as j,
8111
+ Wi as k,
8112
+ zi as l,
8113
+ Hi as m,
8114
+ Se as n,
8115
+ $i as o,
8116
+ Yi as w
7831
8117
  };