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