@nexus-cross/crossx-sdk-core 3.0.0-beta.5 → 3.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/core/types/index.d.ts +22 -1
- package/dist/crossx.global +5 -5
- package/dist/factory-5QBLaqOW.cjs +9 -0
- package/dist/{factory-B-z-0h0_.js → factory-_3WCaR8o.js} +1160 -835
- package/dist/index.cjs +1 -1
- package/dist/index.js +6 -6
- package/dist/internal.cjs +1 -1
- package/dist/internal.d.ts +6 -1
- package/dist/internal.js +11 -4
- package/dist/sdk/CROSSxSDK.d.ts +34 -1
- package/dist/sdk/factory.d.ts +7 -0
- package/dist/sdk/internalContext.d.ts +15 -0
- package/dist/sdk/services/OneIdSessionManager.d.ts +30 -1
- 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 $t, jwtVerify as Yt, decodeJwt as qt } from "jose";
|
|
2
|
+
import { secp256k1 as jt } from "@noble/curves/secp256k1.js";
|
|
3
|
+
import { keccak_256 as je } from "@noble/hashes/sha3.js";
|
|
4
|
+
import { bytesToHex as zt } 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 Jt = 2e3, ze = 6e4, Xt = 1e3, Zt = 1e4, Qt = "0x77359400", Je = "0x3B9ACA00", Xe = 130, mt = 6, Ze = 18, Qe = 3e4, es = 300 * 1e3, ts = 30 * 1e3, et = 100, ss = 300 * 1e3, tt = 60 * 1e3, _e = "crossx-sdk-js/3.0.0-beta.7", rs = "X-SDK-Version", is = !1, ns = "x-sdk-deprecation", pe = -10050, Tt = "ONEpocket";
|
|
20
|
+
var as = /* @__PURE__ */ ((i) => (i.MetaMask = "io.metamask", i.Binance = "com.binance.wallet", i.CROSSx = "crossx", i))(as || {});
|
|
21
|
+
const os = {
|
|
22
22
|
"io.metamask": "MetaMask",
|
|
23
23
|
"com.binance.wallet": "Binance Wallet",
|
|
24
|
-
crossx:
|
|
25
|
-
},
|
|
24
|
+
crossx: Tt
|
|
25
|
+
}, cs = [
|
|
26
26
|
"crossx",
|
|
27
27
|
"io.metamask",
|
|
28
28
|
"com.binance.wallet"
|
|
29
29
|
/* Binance */
|
|
30
30
|
];
|
|
31
|
-
function
|
|
32
|
-
return
|
|
31
|
+
function Vi(i) {
|
|
32
|
+
return os[i] ?? i;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return Array.isArray(i.connectOtherWallets) && i.connectOtherWallets.length > 0 ? [...i.connectOtherWallets] : i.showConnectOtherWallets === !0 ? [...
|
|
34
|
+
function ls(i) {
|
|
35
|
+
return Array.isArray(i.connectOtherWallets) && i.connectOtherWallets.length > 0 ? [...i.connectOtherWallets] : i.showConnectOtherWallets === !0 ? [...cs] : [];
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function yt(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 hs = /* @__PURE__ */ new Set(["ERR_USER_REJECTED", "USER_REJECTED", "USER_REJECT"]), ds = /user rejected|rejected the request|request (?:was )?cancell?ed|entry was cancell?ed|거부했습니다|취소되었습니다/i;
|
|
42
|
+
function Rt(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 us(i) {
|
|
48
|
+
const e = Rt(i);
|
|
49
|
+
if (e) return hs.has(e);
|
|
50
50
|
const t = i instanceof Error ? i.message : String(i);
|
|
51
|
-
return
|
|
51
|
+
return ds.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 = Rt(i), s = i instanceof Error ? i.message : String(i), r = { nativeCode: t, cause: i };
|
|
56
|
+
if (us(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
|
+
}, $i = Object.fromEntries(
|
|
111
|
+
Object.entries(Ae).map(([i, e]) => [i, e.caipId])
|
|
112
|
+
), gs = 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 _s = { symbol: "", decimals: 18 };
|
|
119
|
+
function fs(i, e) {
|
|
120
120
|
var t;
|
|
121
|
-
return (e == null ? void 0 : e[i]) ?? ((t =
|
|
121
|
+
return (e == null ? void 0 : e[i]) ?? ((t = gs.get(i)) == null ? void 0 : t.nativeCurrency);
|
|
122
122
|
}
|
|
123
|
-
class
|
|
123
|
+
class ps {
|
|
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 st(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
|
+
}, ws = {
|
|
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
|
+
}, Nt = {
|
|
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: Tt,
|
|
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
|
+
}, Ss = {
|
|
507
|
+
ko: ws,
|
|
508
|
+
en: Nt
|
|
509
509
|
};
|
|
510
510
|
function M(i = "en", e) {
|
|
511
|
-
return
|
|
511
|
+
return Ss[i] ?? Nt;
|
|
512
512
|
}
|
|
513
|
-
function
|
|
513
|
+
function Es(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 rt = "crossx_access_token", it = "crossx_refresh_token", nt = "crossx_user_info", Ie = class Ie {
|
|
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,9 +612,9 @@ 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 =
|
|
616
|
-
const
|
|
617
|
-
return `${
|
|
615
|
+
const { oauthServiceUrl: a, legacyOauthServiceUrl: l } = this.config, d = Es(this.getLocale()), g = (I) => {
|
|
616
|
+
const S = `${I}${n}`, w = S.includes("?") ? "&" : "?";
|
|
617
|
+
return `${S}${w}locale=${d}`;
|
|
618
618
|
}, u = g(a), _ = l ? g(l) : void 0;
|
|
619
619
|
c.log(`[CROSSx] OAuth 팝업 열기 (${r || "일반"} 로그인)`), c.log(`[CROSSx] Auth URL: ${u}`);
|
|
620
620
|
const p = await this.oauth.openAuth({
|
|
@@ -723,49 +723,49 @@ const qe = "crossx_access_token", je = "crossx_refresh_token", Xe = "crossx_user
|
|
|
723
723
|
let s, r = !1;
|
|
724
724
|
try {
|
|
725
725
|
const { authApiUrl: u } = this.config, { accessToken: _, refreshToken: p } = await this.exchangeFirebaseToken(e, u);
|
|
726
|
-
let
|
|
726
|
+
let I, S, w;
|
|
727
727
|
try {
|
|
728
|
-
const
|
|
729
|
-
c.log("[CROSSx] Firebase JWT 필드:", Object.keys(
|
|
730
|
-
const
|
|
731
|
-
w =
|
|
728
|
+
const f = this.crypto.decodeJWT(e);
|
|
729
|
+
c.log("[CROSSx] Firebase JWT 필드:", Object.keys(f).join(", ")), S = (n = f.firebase) == null ? void 0 : n.sign_in_provider;
|
|
730
|
+
const E = ((a = f.firebase) == null ? void 0 : a.identities) ?? {};
|
|
731
|
+
w = f.email ?? ((l = E.email) == null ? void 0 : l[0]), S === "google.com" ? I = (d = E["google.com"]) == null ? void 0 : d[0] : S === "apple.com" && (I = (g = E["apple.com"]) == null ? void 0 : g[0]), c.log("[CROSSx] OAuth provider sub 추출 — provider:", S, "hasProviderSub:", !!I, "email:", w ?? "(없음)");
|
|
732
732
|
} catch {
|
|
733
733
|
c.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
|
|
734
734
|
}
|
|
735
735
|
if (_) {
|
|
736
|
-
const
|
|
737
|
-
c.log("[CROSSx] access_token 디코딩 — sub:",
|
|
738
|
-
const
|
|
739
|
-
if (r =
|
|
736
|
+
const f = this.crypto.decodeJWT(_);
|
|
737
|
+
c.log("[CROSSx] access_token 디코딩 — sub:", f.sub, "exp:", f.exp, "필드:", Object.keys(f).join(", "));
|
|
738
|
+
const E = await this.crypto.verifyJWT(_);
|
|
739
|
+
if (r = E.signatureVerified ?? !1, !E.valid)
|
|
740
740
|
throw c.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
|
|
741
|
-
const
|
|
741
|
+
const T = E.payload, y = 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 콜백:",
|
|
748
748
|
t ?? "(없음)",
|
|
749
749
|
"→",
|
|
750
|
-
|
|
750
|
+
y ?? "(없음)"
|
|
751
751
|
), s = {
|
|
752
|
-
id:
|
|
753
|
-
email:
|
|
754
|
-
signInProvider:
|
|
755
|
-
providerSub:
|
|
752
|
+
id: T.sub,
|
|
753
|
+
email: y,
|
|
754
|
+
signInProvider: S,
|
|
755
|
+
providerSub: I
|
|
756
756
|
}, this.tokenStore.set(_), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, _), p && this.config.secureStorageAvailable !== !1 ? await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, p) : p && c.warn("[CROSSx] 안전한 스토리지 미사용 — refresh_token 영속 저장을 건너뜁니다"));
|
|
757
757
|
} else {
|
|
758
|
-
const
|
|
758
|
+
const f = this.crypto.decodeJWT(e);
|
|
759
759
|
s = {
|
|
760
|
-
id:
|
|
761
|
-
email:
|
|
762
|
-
signInProvider:
|
|
763
|
-
providerSub:
|
|
760
|
+
id: f.sub,
|
|
761
|
+
email: f.email ?? t,
|
|
762
|
+
signInProvider: S,
|
|
763
|
+
providerSub: I
|
|
764
764
|
}, c.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
|
|
765
765
|
}
|
|
766
766
|
c.log("[CROSSx] 사용자 정보 — id:", s.id, "email:", s.email ?? "(없음)");
|
|
767
|
-
const
|
|
768
|
-
await this.storage.set(this.STORAGE_KEY_USER,
|
|
767
|
+
const m = this.useCookieAuth ? { id: s.id, email: s.email, signInProvider: s.signInProvider, providerSub: s.providerSub } : s;
|
|
768
|
+
await this.storage.set(this.STORAGE_KEY_USER, m), await this.clearStoredRNBridgeSession(), c.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
|
|
769
769
|
} catch (u) {
|
|
770
770
|
return c.error("[CROSSx] SignIn 에러 (토큰 교환 단계):", u), {
|
|
771
771
|
success: !1,
|
|
@@ -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 = Ie.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(nt);
|
|
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(rt);
|
|
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(it);
|
|
1067
|
+
r && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, r), await this.storage.remove(nt), await this.storage.remove(rt), await this.storage.remove(it), 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
|
+
Ie.REFRESH_RELOGIN_CODES = /* @__PURE__ */ new Set([1007, 1008]);
|
|
1103
|
+
let Ue = Ie;
|
|
1104
|
+
class Is {
|
|
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 Ot {
|
|
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 ms = "/authorize/result", Ts = "one-oauth:authorization_response", Pt = "one-oauth:authorization_error", ys = "one-oauth:authorization_ack", Rs = "openid profile offline_access";
|
|
1223
|
+
function Be(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 Re(i = 32) {
|
|
1205
1229
|
const e = new Uint8Array(i);
|
|
1206
|
-
return crypto.getRandomValues(e),
|
|
1230
|
+
return crypto.getRandomValues(e), Be(e);
|
|
1207
1231
|
}
|
|
1208
|
-
async function
|
|
1232
|
+
async function Ne(i) {
|
|
1209
1233
|
const e = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(i));
|
|
1210
|
-
return
|
|
1234
|
+
return Be(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), Be(e);
|
|
1239
|
+
}
|
|
1240
|
+
const Ns = "onepocketSecureFrame", Ge = 1;
|
|
1241
|
+
function ae() {
|
|
1242
|
+
return new h(o.USER_REJECTED, "앱 요청을 중단했습니다");
|
|
1243
|
+
}
|
|
1244
|
+
let at = 0;
|
|
1245
|
+
function we() {
|
|
1246
|
+
return at += 1, `${typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : String(Math.random())}-${at}`;
|
|
1247
|
+
}
|
|
1248
|
+
function Os(i) {
|
|
1249
|
+
return i === "cancelled" ? o.USER_REJECTED : o.ONEID_AUTHORIZATION_FAILED;
|
|
1250
|
+
}
|
|
1251
|
+
function Ct(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 !== Ge)
|
|
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(Os(a), l, { appError: typeof a == "string" ? a : "unknown" });
|
|
1268
|
+
}
|
|
1269
|
+
return typeof s.payload == "object" && s.payload !== null ? s.payload : {};
|
|
1270
|
+
}
|
|
1271
|
+
function Ps(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 Cs(i) {
|
|
1285
|
+
const e = (t, s, r) => i.postMessage({ v: Ge, 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 = we();
|
|
1290
|
+
let a;
|
|
1291
|
+
try {
|
|
1292
|
+
a = await (r ? Ps(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 Ct(n, a);
|
|
1299
|
+
},
|
|
1300
|
+
notify(t, s) {
|
|
1301
|
+
Promise.resolve(e(t, s, we())).catch(() => {
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
function Ds(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: Ge, id: n, type: s, payload: r }));
|
|
1321
|
+
return {
|
|
1322
|
+
request(s, r, n) {
|
|
1323
|
+
const a = we();
|
|
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(Ct(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, we());
|
|
1350
|
+
} catch {
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1215
1354
|
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1355
|
+
function xs(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[Ns];
|
|
1361
|
+
if (t && typeof t.postMessage == "function") return ct(t, () => Cs(t));
|
|
1362
|
+
const s = e.onepocketSecureFrame;
|
|
1363
|
+
return s && typeof s.postMessage == "function" ? ct(s, () => Ds(s)) : null;
|
|
1364
|
+
}
|
|
1365
|
+
const ot = /* @__PURE__ */ new WeakMap();
|
|
1366
|
+
function ct(i, e) {
|
|
1367
|
+
let t = ot.get(i);
|
|
1368
|
+
return t || (t = e(), ot.set(i, t)), t;
|
|
1369
|
+
}
|
|
1370
|
+
const lt = 300 * 1e3, vs = 600 * 1e3, Oe = "crossx.oneid.pending", ks = "/auth/app-callback", Us = 1e3;
|
|
1371
|
+
function Dt(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 bs(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 Ls = 15 * 1e3;
|
|
1398
|
+
function Ws(i) {
|
|
1399
|
+
return typeof AbortSignal < "u" && typeof AbortSignal.timeout == "function" ? AbortSignal.timeout(i) : void 0;
|
|
1246
1400
|
}
|
|
1247
|
-
|
|
1401
|
+
const Ms = 300 * 1e3, oe = "https://return-to.invalid";
|
|
1402
|
+
function ce(i) {
|
|
1403
|
+
if (typeof i != "string" || !i.startsWith("/") || /[\u0000-\u001f\u007f\\]/.test(i)) return;
|
|
1404
|
+
let e;
|
|
1405
|
+
try {
|
|
1406
|
+
e = new URL(i, oe);
|
|
1407
|
+
} catch {
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
if (e.origin !== oe) return;
|
|
1411
|
+
const t = `${e.pathname}${e.search}${e.hash}`;
|
|
1412
|
+
if (!(t.startsWith("//") || new URL(t, oe).origin !== oe))
|
|
1413
|
+
return t;
|
|
1414
|
+
}
|
|
1415
|
+
function z(i) {
|
|
1248
1416
|
let e;
|
|
1249
1417
|
try {
|
|
1250
1418
|
e = new URL(i);
|
|
@@ -1253,7 +1421,7 @@ function j(i) {
|
|
|
1253
1421
|
}
|
|
1254
1422
|
return e.toString().replace(/\/+$/, "");
|
|
1255
1423
|
}
|
|
1256
|
-
function
|
|
1424
|
+
function be(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 Fs(i) {
|
|
1437
|
+
return { get: (e) => typeof i[e] == "string" ? i[e] : null };
|
|
1438
|
+
}
|
|
1439
|
+
function ht(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(Dt(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 Bs(i) {
|
|
1269
1459
|
if (typeof i != "object" || i === null) return !1;
|
|
1270
1460
|
const e = i.type;
|
|
1271
|
-
return e ===
|
|
1461
|
+
return e === Ts || e === Pt;
|
|
1272
1462
|
}
|
|
1273
|
-
function
|
|
1463
|
+
function dt(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 Gs {
|
|
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 Hs {
|
|
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 Gs(), 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 > vs)
|
|
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 = ht(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: Ws(Ls)
|
|
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 Pe(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(bs(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 = dt(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 : xs();
|
|
1610
|
+
}
|
|
1611
|
+
/**
|
|
1612
|
+
* 원포켓 앱에 인증을 맡긴다 (docs/30 §5). PAR · 토큰 교환은 이 페이지(보안 화면 origin)에서 하고,
|
|
1613
|
+
* 앱은 인증 화면을 열어 결과만 돌려준다. PKCE verifier 는 이 함수 밖으로 나가지 않는다.
|
|
1614
|
+
*/
|
|
1615
|
+
async authorizeWithApp(e, t, s) {
|
|
1616
|
+
const r = `${window.location.origin}${ks}`, n = Y(), a = Y(), l = Re(), d = await Ne(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((S, w) => {
|
|
1619
|
+
let m = !1;
|
|
1620
|
+
const f = new AbortController(), E = (R) => {
|
|
1621
|
+
m || (m = !0, s.onAbort = null, clearTimeout(y), f.abort(), R());
|
|
1622
|
+
}, T = () => e.notify("oneid.cancel", {}), y = setTimeout(() => {
|
|
1623
|
+
E(() => {
|
|
1624
|
+
T(), w(new h(o.ONEID_TIMEOUT, "ONE ID 로그인 응답 시간이 지났습니다"));
|
|
1625
|
+
});
|
|
1626
|
+
}, lt);
|
|
1627
|
+
s.onAbort = (R) => {
|
|
1628
|
+
E(() => {
|
|
1629
|
+
T(), w(new h(o.USER_REJECTED, R));
|
|
1630
|
+
});
|
|
1631
|
+
}, e.request("oneid.authorize", { authorizeUrl: u, state: n }, f.signal).then(
|
|
1632
|
+
(R) => E(() => S(R)),
|
|
1633
|
+
(R) => E(() => w(R))
|
|
1634
|
+
);
|
|
1635
|
+
}), p = ht(Fs(_), n, t.issuer), I = await this.exchangeCode(t, p, l, r, a);
|
|
1636
|
+
return c.log("[CROSSx] ONE ID 로그인 완료 (원포켓 앱)"), { status: "completed", tokens: I, 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 ?? Rs,
|
|
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 Pe(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,33 +1695,36 @@ 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 Pe(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 = dt(d, this.now());
|
|
1497
1705
|
if (g.idToken) {
|
|
1498
|
-
const u =
|
|
1706
|
+
const u = be(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), I = typeof u.exp == "number" ? u.exp * 1e3 : Number.NaN;
|
|
1710
|
+
if (!p || !(I + Ms > 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}${ms}`, a = Y(), l = Y(), d = Re(), g = await Ne(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
|
-
const _ = await new Promise((
|
|
1508
|
-
let w = 0,
|
|
1509
|
-
const
|
|
1510
|
-
s.onAbort = null, clearTimeout(
|
|
1511
|
-
},
|
|
1512
|
-
|
|
1513
|
-
},
|
|
1514
|
-
|
|
1515
|
-
},
|
|
1516
|
-
|
|
1718
|
+
const _ = await new Promise((I, S) => {
|
|
1719
|
+
let w = 0, m = 0;
|
|
1720
|
+
const f = () => {
|
|
1721
|
+
s.onAbort = null, clearTimeout(T), clearInterval(y), window.removeEventListener("message", R);
|
|
1722
|
+
}, E = (N) => {
|
|
1723
|
+
f(), S(N);
|
|
1724
|
+
}, T = setTimeout(() => {
|
|
1725
|
+
E(new h(o.ONEID_TIMEOUT, "ONE ID 로그인 응답 시간이 지났습니다"));
|
|
1726
|
+
}, lt), y = setInterval(() => {
|
|
1727
|
+
m++;
|
|
1517
1728
|
let N;
|
|
1518
1729
|
try {
|
|
1519
1730
|
N = e.closed;
|
|
@@ -1522,53 +1733,53 @@ class Is {
|
|
|
1522
1733
|
}
|
|
1523
1734
|
if (N) {
|
|
1524
1735
|
if (w === 0) {
|
|
1525
|
-
w =
|
|
1736
|
+
w = m;
|
|
1526
1737
|
return;
|
|
1527
1738
|
}
|
|
1528
|
-
c.warn("[CROSSx] ONE ID 팝업이 닫혔거나 연결이 끊겼습니다(COOP) — 로그인을 취소합니다"),
|
|
1739
|
+
c.warn("[CROSSx] ONE ID 팝업이 닫혔거나 연결이 끊겼습니다(COOP) — 로그인을 취소합니다"), E(new h(o.USER_REJECTED, "ONE ID 로그인이 취소되었습니다", { reason: "popup_closed_or_detached" }));
|
|
1529
1740
|
}
|
|
1530
|
-
},
|
|
1531
|
-
if (N.origin !== r || N.source !== e || !
|
|
1532
|
-
const
|
|
1533
|
-
if (
|
|
1741
|
+
}, Us), R = (N) => {
|
|
1742
|
+
if (N.origin !== r || N.source !== e || !Bs(N.data)) return;
|
|
1743
|
+
const O = N.data;
|
|
1744
|
+
if (O.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: ys, state: a }, r);
|
|
1539
1750
|
} catch {
|
|
1540
1751
|
}
|
|
1541
|
-
if (
|
|
1542
|
-
|
|
1752
|
+
if (O.iss !== t.issuer) {
|
|
1753
|
+
E(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 (O.type === Pt || O.error) {
|
|
1757
|
+
const P = O.error ?? "unknown_error";
|
|
1758
|
+
c.warn("[CROSSx] ONE ID 인가 오류:", P), E(
|
|
1759
|
+
new h(Dt(P), O.error_description || `ONE ID 인가 오류: ${P}`, {
|
|
1760
|
+
error: P,
|
|
1761
|
+
error_description: O.error_description
|
|
1551
1762
|
})
|
|
1552
1763
|
);
|
|
1553
1764
|
return;
|
|
1554
1765
|
}
|
|
1555
|
-
if (!
|
|
1556
|
-
|
|
1766
|
+
if (!O.code) {
|
|
1767
|
+
E(new h(o.ONEID_AUTHORIZATION_FAILED, "ONE ID 로그인 결과에 code가 없습니다"));
|
|
1557
1768
|
return;
|
|
1558
1769
|
}
|
|
1559
|
-
|
|
1770
|
+
f(), I(O.code);
|
|
1560
1771
|
};
|
|
1561
1772
|
s.onAbort = (N) => {
|
|
1562
|
-
|
|
1563
|
-
}, window.addEventListener("message",
|
|
1773
|
+
E(new h(o.USER_REJECTED, N));
|
|
1774
|
+
}, window.addEventListener("message", R);
|
|
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 = Re(), l = await Ne(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(Oe, 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(Oe);
|
|
1801
|
+
if (this.pendingStorage.removeItem(Oe), !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 Pe(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", Ce = 60 * 1e3, Le = /* @__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 he(i) {
|
|
1825
|
+
return i instanceof h && Le.has(i.code);
|
|
1826
|
+
}
|
|
1827
|
+
const Ks = "crossx.oneid.refresh";
|
|
1828
|
+
function Vs(i) {
|
|
1829
|
+
const e = typeof navigator < "u" ? navigator.locks : void 0;
|
|
1830
|
+
return e ? e.request(Ks, i) : i();
|
|
1615
1831
|
}
|
|
1616
|
-
class
|
|
1832
|
+
class $s {
|
|
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)), ut(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 ? ut(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 - Ce <= 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 && Le.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,48 +1894,61 @@ 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 - Ce > 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 = Vs(() => 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 - Ce > 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 = { ...r, idToken: r.idToken ?? t.tokens.idToken }, a = { ...t, tokens: n };
|
|
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(a)), a;
|
|
1927
|
+
} catch (r) {
|
|
1928
|
+
if (s !== this.generation) throw r;
|
|
1929
|
+
if (r instanceof h && Le.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 ut(i) {
|
|
1937
|
+
const e = i.tokens.idToken ? be(i.tokens.idToken) : null, t = typeof (e == null ? void 0 : e.sub) == "string" && e.sub ? e : be(i.tokens.accessToken);
|
|
1709
1938
|
return {
|
|
1710
|
-
subject: typeof (
|
|
1939
|
+
subject: typeof (t == null ? void 0 : t.sub) == "string" ? t.sub : "",
|
|
1711
1940
|
clientId: i.clientId,
|
|
1712
1941
|
issuer: i.issuer,
|
|
1713
1942
|
scope: i.tokens.scope,
|
|
1714
1943
|
expiresAt: i.tokens.expiresAt
|
|
1715
1944
|
};
|
|
1716
1945
|
}
|
|
1717
|
-
function
|
|
1946
|
+
function Ys(i) {
|
|
1718
1947
|
return i === "local" ? window.localStorage : window.sessionStorage;
|
|
1719
1948
|
}
|
|
1720
|
-
const
|
|
1721
|
-
function
|
|
1722
|
-
return
|
|
1949
|
+
const qs = new TextEncoder();
|
|
1950
|
+
function C(i) {
|
|
1951
|
+
return qs.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 js(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 zs(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 Js(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, He = { name: "ECDH", namedCurve: "P-256" }, Xs = 32, Zs = 12, Qs = 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(C("HPKE"), ie(16), ie(1), ie(2)), gt = F(C("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 er(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 fe(i, e, t, s) {
|
|
2004
|
+
return vt(i, F(C("HPKE-v1"), s, C(e), t));
|
|
1776
2005
|
}
|
|
1777
|
-
function
|
|
1778
|
-
return
|
|
2006
|
+
function We(i, e, t, s, r) {
|
|
2007
|
+
return er(i, F(ie(s), C("HPKE-v1"), r, C(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, He, !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 fe(H, "eae_prk", i, gt);
|
|
2015
|
+
return We(s, "shared_secret", F(e, t), Qs, gt);
|
|
1787
2016
|
}
|
|
1788
|
-
async function
|
|
1789
|
-
const e = await
|
|
2017
|
+
async function bt(i) {
|
|
2018
|
+
const e = await fe(H, "psk_id_hash", H, te), t = await fe(H, "info_hash", H, te), s = F(new Uint8Array([0]), e, t), r = await fe(i, "secret", H, te), n = await We(r, "key", s, Xs, te), a = await We(r, "base_nonce", s, Zs, te);
|
|
1790
2019
|
return { key: n, baseNonce: a };
|
|
1791
2020
|
}
|
|
1792
|
-
function
|
|
2021
|
+
function me(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(He, !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 tr(i, e, t) {
|
|
2030
|
+
me(i, "recipient public key");
|
|
2031
|
+
const s = await x.generateKey(He, !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 sr(i, e, t, s) {
|
|
2037
|
+
me(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, rr = { name: "ECDSA", namedCurve: "P-256" }, ir = "one-wallet/authz-sig/v1", nr = "one-wallet/seal-aad/v1", ar = 60, or = 32, cr = {
|
|
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 lr(i) {
|
|
2058
|
+
return F(js(i.length), i);
|
|
1830
2059
|
}
|
|
1831
|
-
function
|
|
1832
|
-
return F(
|
|
2060
|
+
function Mt(i, e, t) {
|
|
2061
|
+
return F(C(i), ...e.map(lr), new Uint8Array([t]));
|
|
1833
2062
|
}
|
|
1834
|
-
function
|
|
1835
|
-
return
|
|
1836
|
-
|
|
1837
|
-
[i.nonce,
|
|
2063
|
+
function hr(i, e, t) {
|
|
2064
|
+
return Mt(
|
|
2065
|
+
nr,
|
|
2066
|
+
[i.nonce, C(i.expiresAt), i.intentHash, C(e), C(i.authzKeyId)],
|
|
1838
2067
|
t
|
|
1839
2068
|
);
|
|
1840
2069
|
}
|
|
1841
|
-
function
|
|
1842
|
-
return
|
|
1843
|
-
|
|
1844
|
-
[i.enc, i.ciphertext, i.nonce,
|
|
2070
|
+
function dr(i, e, t) {
|
|
2071
|
+
return Mt(
|
|
2072
|
+
ir,
|
|
2073
|
+
[i.enc, i.ciphertext, i.nonce, C(i.expiresAt), i.intentHash, C(e), C(i.authzKeyId)],
|
|
1845
2074
|
t
|
|
1846
2075
|
);
|
|
1847
2076
|
}
|
|
1848
|
-
function
|
|
1849
|
-
return
|
|
2077
|
+
function ur(i, e, t) {
|
|
2078
|
+
return xt(hr(i, e, t));
|
|
1850
2079
|
}
|
|
1851
|
-
function
|
|
2080
|
+
function gr(i) {
|
|
1852
2081
|
return i.toISOString().replace(/\.\d+Z$/, "Z");
|
|
1853
2082
|
}
|
|
1854
|
-
async function
|
|
2083
|
+
async function _r(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 me(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
|
+
rr,
|
|
1867
2096
|
!1,
|
|
1868
2097
|
["sign"]
|
|
1869
2098
|
);
|
|
1870
2099
|
}
|
|
1871
|
-
async function
|
|
2100
|
+
async function fr(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 = cr[i.command], t = C(JSON.stringify(i.intent)), s = {
|
|
2103
|
+
nonce: Js(or),
|
|
2104
|
+
expiresAt: gr(new Date((i.now ?? /* @__PURE__ */ new Date()).getTime() + (i.ttlSec ?? ar) * 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 ur(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 tr(i.recipientPub, C(JSON.stringify(n)), r), d = new Uint8Array(
|
|
2110
|
+
await Wt.sign({ name: "ECDSA", hash: "SHA-256" }, i.authz.signingKey, dr({ ...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 sr(i, Z(e.enc), Z(e.ciphertext), t);
|
|
1900
2129
|
}
|
|
1901
|
-
const
|
|
1902
|
-
class
|
|
2130
|
+
const pr = 90 * 1e3;
|
|
2131
|
+
class wr {
|
|
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() > pr) 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 _r(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 Sr = 600 * 1e3, Er = {
|
|
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 Ir(i, e) {
|
|
2234
|
+
const t = (e == null ? void 0 : e.code) ?? "", s = Er[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 < Sr)
|
|
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 me(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 Ir(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}`, mr = /^0x(?:[0-9a-fA-F]{2})*$/;
|
|
2285
|
+
function Tr(i) {
|
|
2045
2286
|
try {
|
|
2046
|
-
const e = JSON.parse(new TextDecoder().decode(
|
|
2287
|
+
const e = JSON.parse(new TextDecoder().decode(zs(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 yr(i) {
|
|
2294
|
+
if (mr.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
|
-
return
|
|
2298
|
+
return C(i);
|
|
2058
2299
|
}
|
|
2059
|
-
const
|
|
2060
|
-
function
|
|
2300
|
+
const _t = (i) => `0x${i.toString(16)}`;
|
|
2301
|
+
function ft(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: _t(i.nonce),
|
|
2316
|
+
chain_id: _t(t)
|
|
2076
2317
|
};
|
|
2077
2318
|
return Object.fromEntries(Object.entries(s).filter(([, r]) => r !== void 0));
|
|
2078
2319
|
}
|
|
2079
|
-
class
|
|
2320
|
+
class Me {
|
|
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 wr({ 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 = Tr(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(yr(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: ft(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: ft(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 fr({
|
|
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 Rr = 3, Nr = /^0x(?:[0-9a-fA-F]{2}){4,}$/;
|
|
2495
|
+
function Or(i) {
|
|
2496
|
+
return i.code === Rr || /execution reverted/i.test(i.message ?? "");
|
|
2249
2497
|
}
|
|
2250
|
-
class
|
|
2498
|
+
class Pr {
|
|
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 }, _ = Or(l.error);
|
|
2524
|
+
throw _ && typeof u.data == "string" && Nr.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 Cr {
|
|
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 Dr() {
|
|
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 = Dr(), 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 xr(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 Se() {
|
|
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 = xr(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 vr(i, e = mt) {
|
|
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(Ze), r = t / s, a = (t % s).toString().padStart(Ze, "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 de(i, e, t, s = mt) {
|
|
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 kr(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 !== Xe)
|
|
2638
2886
|
throw new h(
|
|
2639
2887
|
o.SIGNATURE_FAILED,
|
|
2640
|
-
`서명 길이가 유효하지 않습니다: ${
|
|
2888
|
+
`서명 길이가 유효하지 않습니다: ${Xe} hex 문자(65 바이트) 예상, 현재 ${e.length}`
|
|
2641
2889
|
);
|
|
2642
2890
|
}
|
|
2643
|
-
function
|
|
2891
|
+
function Ur(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 br(i, e) {
|
|
2905
|
+
const t = Lr(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 Lr(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 Yi = 900 * 1e3, Wr = /* @__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
|
+
]), Mr = /* @__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 Fr(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 && Wr.has(n.slice(0, 8));
|
|
2718
2966
|
}
|
|
2719
2967
|
if (e === "sign-typed-data") {
|
|
2720
|
-
const r =
|
|
2721
|
-
return r === null ||
|
|
2968
|
+
const r = Br(t.typedData);
|
|
2969
|
+
return r === null || Mr.has(r);
|
|
2722
2970
|
}
|
|
2723
2971
|
return !1;
|
|
2724
2972
|
}
|
|
2725
|
-
function
|
|
2973
|
+
function Br(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 Gr(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 : !Fr(s);
|
|
2744
2992
|
}
|
|
2745
|
-
function
|
|
2993
|
+
function Hr(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
|
+
Gr(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
|
+
Hr((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 Kr {
|
|
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 Vr(i) {
|
|
2963
3211
|
return i === "google" || i === "apple";
|
|
2964
3212
|
}
|
|
2965
|
-
class
|
|
3213
|
+
class $r {
|
|
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 = Vr(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 Yr {
|
|
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 qr {
|
|
3104
3352
|
constructor(e) {
|
|
3105
3353
|
this.deps = e;
|
|
3106
3354
|
}
|
|
@@ -3148,14 +3396,14 @@ class yr {
|
|
|
3148
3396
|
}
|
|
3149
3397
|
const p = _.pinStatus;
|
|
3150
3398
|
if (a = p.maxAttempts, n = a - p.remainingAttempts, p.remainingAttempts === 0 && p.lockExpiresAt) {
|
|
3151
|
-
const
|
|
3399
|
+
const I = p.lockExpiresAt * 1e3, S = Math.max(
|
|
3152
3400
|
1,
|
|
3153
|
-
Math.round((
|
|
3154
|
-
), w =
|
|
3401
|
+
Math.round((I - Date.now()) / 1e3)
|
|
3402
|
+
), w = S <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
|
|
3155
3403
|
c.warn(
|
|
3156
|
-
`[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${
|
|
3404
|
+
`[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${S}초, 메시지: ${w}`
|
|
3157
3405
|
), await this.deps.confirmation.showRecoveryPinLockedPrompt(
|
|
3158
|
-
|
|
3406
|
+
S,
|
|
3159
3407
|
w
|
|
3160
3408
|
), n = 0, r = "Your account lock has been lifted. You may try again.";
|
|
3161
3409
|
} else
|
|
@@ -3168,11 +3416,11 @@ class yr {
|
|
|
3168
3416
|
c.warn(
|
|
3169
3417
|
"[CROSSx][Migration Phase 4] 세션 만료 — 재로그인 후 PIN 입력 재시도"
|
|
3170
3418
|
);
|
|
3171
|
-
const p = M(this.deps.getLocale() ?? "en"),
|
|
3419
|
+
const p = M(this.deps.getLocale() ?? "en"), I = this.deps.getUserEmail();
|
|
3172
3420
|
if (await this.deps.confirmation.showSessionAlert({
|
|
3173
3421
|
title: p.session_alert_title,
|
|
3174
3422
|
message: p.alert_session_expired,
|
|
3175
|
-
email:
|
|
3423
|
+
email: I ? this.deps.maskEmail(I, p.session_alert_apple_account) : void 0
|
|
3176
3424
|
}) === "signin-again" && (await this.deps.signInAgain()).success) {
|
|
3177
3425
|
c.log(
|
|
3178
3426
|
"[CROSSx][Migration Phase 4] 재로그인 성공 — PIN 입력 루프 계속"
|
|
@@ -3190,14 +3438,14 @@ class yr {
|
|
|
3190
3438
|
0,
|
|
3191
3439
|
"Your account has been permanently locked due to too many failed attempts."
|
|
3192
3440
|
), null;
|
|
3193
|
-
const
|
|
3441
|
+
const I = ((p == null ? void 0 : p.lockExpiresAt) ?? 0) * 1e3, S = Math.max(
|
|
3194
3442
|
1,
|
|
3195
|
-
Math.round((
|
|
3196
|
-
), w =
|
|
3443
|
+
Math.round((I - Date.now()) / 1e3)
|
|
3444
|
+
), w = S <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
|
|
3197
3445
|
c.warn(
|
|
3198
|
-
`[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${
|
|
3446
|
+
`[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${S}초`
|
|
3199
3447
|
), await this.deps.confirmation.showRecoveryPinLockedPrompt(
|
|
3200
|
-
|
|
3448
|
+
S,
|
|
3201
3449
|
w
|
|
3202
3450
|
), n = 0, r = "Your account lock has been lifted. You may try again.";
|
|
3203
3451
|
} else
|
|
@@ -3257,12 +3505,12 @@ class yr {
|
|
|
3257
3505
|
}
|
|
3258
3506
|
}
|
|
3259
3507
|
}
|
|
3260
|
-
class
|
|
3508
|
+
class jr {
|
|
3261
3509
|
constructor(e) {
|
|
3262
3510
|
this.deps = e;
|
|
3263
3511
|
}
|
|
3264
3512
|
async withResolvedGasAndFee(e, t) {
|
|
3265
|
-
const s = (
|
|
3513
|
+
const s = (I) => !(I != null && I.trim()), r = e.nonce === void 0 || e.nonce === null, n = s(e.gasLimit), a = s(e.gasPrice) && s(e.maxFeePerGas), l = !s(e.maxFeePerGas) && s(e.maxPriorityFeePerGas);
|
|
3266
3514
|
if (!r && !n && !a && !l) return e;
|
|
3267
3515
|
const d = { ...e }, g = r ? d.from ?? this.deps.getActiveAddress() ?? void 0 : void 0;
|
|
3268
3516
|
g && c.log(
|
|
@@ -3282,23 +3530,23 @@ class Rr {
|
|
|
3282
3530
|
a ? this.deps.getBaseFeePerGas(t) : null
|
|
3283
3531
|
]);
|
|
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
|
-
const
|
|
3286
|
-
if (
|
|
3287
|
-
const
|
|
3288
|
-
d.maxFeePerGas = `0x${(BigInt(
|
|
3533
|
+
const I = p;
|
|
3534
|
+
if (I) {
|
|
3535
|
+
const S = Je;
|
|
3536
|
+
d.maxFeePerGas = `0x${(BigInt(I) + BigInt(S)).toString(16)}`, d.maxPriorityFeePerGas = S, c.log(
|
|
3289
3537
|
"[CROSSx] Dynamic 체인 감지 — baseFee:",
|
|
3290
|
-
|
|
3538
|
+
I,
|
|
3291
3539
|
"maxFeePerGas:",
|
|
3292
3540
|
d.maxFeePerGas,
|
|
3293
3541
|
"maxPriorityFeePerGas: 1 Gwei"
|
|
3294
3542
|
);
|
|
3295
3543
|
} else
|
|
3296
|
-
d.gasPrice =
|
|
3544
|
+
d.gasPrice = Qt, c.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
|
|
3297
3545
|
}
|
|
3298
|
-
return !a && l && (d.maxPriorityFeePerGas =
|
|
3546
|
+
return !a && l && (d.maxPriorityFeePerGas = Je, c.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), d;
|
|
3299
3547
|
}
|
|
3300
3548
|
}
|
|
3301
|
-
class
|
|
3549
|
+
class zr {
|
|
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 Jr(i) {
|
|
3328
3576
|
return i ? i.includes("google") ? "google" : i.includes("apple") ? "apple" : i : null;
|
|
3329
3577
|
}
|
|
3330
|
-
class
|
|
3578
|
+
class Xr {
|
|
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: Jr(
|
|
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 Zr {
|
|
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 Qr {
|
|
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 ei {
|
|
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 pt(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 ti {
|
|
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 = pt(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(pt(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
|
|
3634
|
-
constructor(e, t, s, r, n, a, l, d, g, u, _, p,
|
|
3635
|
-
var
|
|
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 =
|
|
3881
|
+
const b = class b extends Cr {
|
|
3882
|
+
constructor(e, t, s, r, n, a, l, d, g, u, _, p, I, S) {
|
|
3883
|
+
var w, m;
|
|
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 = I, this.oneIdSessionFactory = S, 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 && st(e.logger), this.confirmation = g, this.pinStore = _ ?? new Ot(), this.stateManager = new Xr({
|
|
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
|
-
emitAddressChanged: ({ address: f, index:
|
|
3642
|
-
const
|
|
3643
|
-
|
|
3889
|
+
emitAddressChanged: ({ address: f, index: E, walletName: T }) => {
|
|
3890
|
+
const y = { address: f, index: E };
|
|
3891
|
+
T !== void 0 && (y.walletName = T), this.emit("addressChanged", y);
|
|
3644
3892
|
},
|
|
3645
|
-
emitAuthChanged: ({ isAuthenticated: f, address:
|
|
3893
|
+
emitAuthChanged: ({ isAuthenticated: f, address: E, userId: T, source: y }) => {
|
|
3646
3894
|
this.emit("authChanged", {
|
|
3647
3895
|
isAuthenticated: f,
|
|
3648
|
-
address:
|
|
3649
|
-
userId:
|
|
3650
|
-
...
|
|
3896
|
+
address: E,
|
|
3897
|
+
userId: T,
|
|
3898
|
+
...y ? { source: y } : {}
|
|
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 Kr({
|
|
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 Yr({
|
|
3678
3926
|
walletProvider: this.walletProvider,
|
|
3679
3927
|
pinOrchestrator: this.pinOrchestrator,
|
|
3680
3928
|
getUserId: () => this.userId,
|
|
3681
|
-
setActiveWallet: (f,
|
|
3682
|
-
}), this.migrationOrchestrator = new
|
|
3929
|
+
setActiveWallet: (f, E, T) => this.setActiveWallet(f, E, T)
|
|
3930
|
+
}), this.migrationOrchestrator = new qr({
|
|
3683
3931
|
confirmation: this.confirmation,
|
|
3684
3932
|
walletProvider: this.walletProvider,
|
|
3685
3933
|
pinOrchestrator: this.pinOrchestrator,
|
|
3686
|
-
executeMigrate: (f,
|
|
3934
|
+
executeMigrate: (f, E) => this.migrateWalletUseCase.execute(f, E),
|
|
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 jr({
|
|
3697
3945
|
getActiveAddress: () => this.address,
|
|
3698
|
-
estimateGas: (f,
|
|
3946
|
+
estimateGas: (f, E) => this.estimateGas(f, E),
|
|
3699
3947
|
getBaseFeePerGas: (f) => this.getBaseFeePerGas(f),
|
|
3700
|
-
jsonRpcCall: (f,
|
|
3701
|
-
}), this.signatureVerifier = new
|
|
3948
|
+
jsonRpcCall: (f, E, T) => this.jsonRpc.call(f, E, T)
|
|
3949
|
+
}), this.signatureVerifier = new zr(this.crypto), this.addressResolverService = new Zr({
|
|
3702
3950
|
walletProvider: this.walletProvider,
|
|
3703
3951
|
pinOrchestrator: this.pinOrchestrator,
|
|
3704
3952
|
getActiveAddress: () => this.address,
|
|
@@ -3706,25 +3954,25 @@ 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 Qr({
|
|
3710
3958
|
isInitialized: () => this.initialized,
|
|
3711
3959
|
isAuthenticated: () => this.authenticated
|
|
3712
|
-
}), this.walletCreationService = new
|
|
3960
|
+
}), this.walletCreationService = new ei({
|
|
3713
3961
|
walletProvider: this.walletProvider,
|
|
3714
3962
|
pinOrchestrator: this.pinOrchestrator,
|
|
3715
3963
|
migrationOrchestrator: this.migrationOrchestrator,
|
|
3716
3964
|
walletLifecycleService: this.walletLifecycleService,
|
|
3717
3965
|
getUserId: () => this.userId,
|
|
3718
3966
|
getProviderSub: () => this.providerSub,
|
|
3719
|
-
setActiveWallet: (f,
|
|
3967
|
+
setActiveWallet: (f, E) => this.setActiveWallet(f, E),
|
|
3720
3968
|
showWalletCreated: () => {
|
|
3721
|
-
var f,
|
|
3722
|
-
return ((
|
|
3969
|
+
var f, E;
|
|
3970
|
+
return ((E = (f = this.confirmation).showWalletCreatedPrompt) == null ? void 0 : E.call(f)) ?? Promise.resolve();
|
|
3723
3971
|
}
|
|
3724
|
-
}), this.tokenHistoryService = new
|
|
3972
|
+
}), this.tokenHistoryService = new ti({
|
|
3725
3973
|
transport: n,
|
|
3726
3974
|
getApiBaseUrl: () => this.internalConfig.authApiUrl
|
|
3727
|
-
}), this.sessionOrchestrator = new
|
|
3975
|
+
}), this.sessionOrchestrator = new $r({
|
|
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 Pr(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 Is(
|
|
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), (w = l.setOnUnauthorized) == null || w.call(l, () => this.forceLogout()), (m = l.setTokenRefresher) == null || m.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 = _e;
|
|
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] ${_e} 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.7 초기화 중..."), this.confirmation.setMessages(M(this._config.locale));
|
|
3856
4104
|
try {
|
|
3857
|
-
const r =
|
|
4105
|
+
const r = Se();
|
|
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.7 초기화 완료 (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.7 초기화 완료"), 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.7",
|
|
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.7",
|
|
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: ls(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 && he(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 Me && 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 (he(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 (he(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,18 +4627,39 @@ 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 || Se().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
|
-
|
|
4372
|
-
this.oneIdAuth,
|
|
4373
|
-
s,
|
|
4374
|
-
|
|
4375
|
-
|
|
4637
|
+
if (!this._oneIdSessions) {
|
|
4638
|
+
const r = new $s(this.oneIdAuth, s, Ys(e.storage));
|
|
4639
|
+
this._oneIdSessions = this.oneIdSessionFactory ? this.oneIdSessionFactory({ port: this.oneIdAuth, config: s, fallback: r }) : r;
|
|
4640
|
+
}
|
|
4641
|
+
return { port: this.oneIdAuth, config: s, sessions: this._oneIdSessions };
|
|
4642
|
+
}
|
|
4643
|
+
/**
|
|
4644
|
+
* 세션 통로(`OneIdSessionSource`)를 다시 읽어 SDK 로그인 상태를 맞춘다 (DEV2TF-2925, `/internal` 의
|
|
4645
|
+
* `reloadOneIdSession`). 보안 화면 앱이 OSG walletToken 교환 · 회원 확인 · 로그아웃 뒤에 부른다.
|
|
4646
|
+
* - 세션이 없으면 로그인 상태(메모리 PIN · B 키 포함)를 정리하고 null
|
|
4647
|
+
* - 다른 사용자로 로그인돼 있었으면 먼저 정리한 뒤 새 세션을 싣는다
|
|
4648
|
+
* - 세션이 끝났으면(`ONEID_SESSION_*`) 정리하고 그 오류를 던진다
|
|
4649
|
+
* - `reset` 이면 사용자가 같아도 먼저 정리한다(B 키 · 메모리 PIN) — 세션 통로가 바뀔 때 이전 통로의 상태를 넘기지 않게
|
|
4650
|
+
*/
|
|
4651
|
+
async reloadOneIdSession(e) {
|
|
4652
|
+
if (!this.usesOneWallet)
|
|
4653
|
+
throw new h(o.NOT_IMPLEMENTED, "reloadOneIdSession requires walletServer 'one-wallet'");
|
|
4654
|
+
const { sessions: t } = this.oneIdContext();
|
|
4655
|
+
e != null && e.reset && (this.authenticated || this.pinStore.has()) && this.clearAuthState();
|
|
4656
|
+
let s;
|
|
4657
|
+
try {
|
|
4658
|
+
s = await t.get();
|
|
4659
|
+
} catch (r) {
|
|
4660
|
+
throw he(r) && this.clearAuthState(), r;
|
|
4661
|
+
}
|
|
4662
|
+
return !s || !s.subject ? (this.authenticated && this.clearAuthState(), null) : (this.authenticated && this.currentUserId !== s.subject && this.clearAuthState(), this.applyOneIdSession(s));
|
|
4376
4663
|
}
|
|
4377
4664
|
async signOut() {
|
|
4378
4665
|
if (this.ensureInitialized(), this.usesOneWallet) {
|
|
@@ -4381,7 +4668,7 @@ const W = class W extends ar {
|
|
|
4381
4668
|
}
|
|
4382
4669
|
try {
|
|
4383
4670
|
await this.signOutUseCase.execute(), this.clearAuthState();
|
|
4384
|
-
const e =
|
|
4671
|
+
const e = L.getBridge();
|
|
4385
4672
|
if (e != null && e.signOut)
|
|
4386
4673
|
try {
|
|
4387
4674
|
await e.signOut(), c.log("[CROSSx] RN Bridge signOut 통보 완료 — native trust cache 무효화");
|
|
@@ -4611,19 +4898,41 @@ const W = class W extends ar {
|
|
|
4611
4898
|
const r = await this.confirmation.showWalletSelector(
|
|
4612
4899
|
s,
|
|
4613
4900
|
async () => {
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4901
|
+
this.pinOrchestrator.prepareForSigning({ action: "sign-message", context: {} });
|
|
4902
|
+
try {
|
|
4903
|
+
await this.pinOrchestrator.ensurePinForSigning();
|
|
4904
|
+
const n = s.length, l = { address: (await this.pinOrchestrator.withPinRetry(
|
|
4905
|
+
() => this.withSessionRecovery(
|
|
4906
|
+
() => this.walletProvider.getAddress(this.userId, n)
|
|
4907
|
+
)
|
|
4908
|
+
)).address, index: n };
|
|
4909
|
+
return s.push(l), l;
|
|
4910
|
+
} finally {
|
|
4911
|
+
this.pinOrchestrator.finishSigning();
|
|
4912
|
+
}
|
|
4621
4913
|
},
|
|
4622
4914
|
e,
|
|
4623
4915
|
t
|
|
4624
4916
|
);
|
|
4625
4917
|
return r && this.setActiveWallet(r.address, r.index), r;
|
|
4626
4918
|
}
|
|
4919
|
+
/**
|
|
4920
|
+
* 지갑 목록에 있는 지갑으로 사용 지갑을 바꿉니다 (모달 없이). 서비스의 지갑 목록 화면에서 고른 지갑을 쓸 때 부릅니다.
|
|
4921
|
+
* 바뀌면 `addressChanged` 이벤트가 나갑니다. 이미 사용 지갑이면 그대로 둡니다 (DEV2TF-2916).
|
|
4922
|
+
*
|
|
4923
|
+
* @param address 바꿀 지갑 주소 (대소문자 무시)
|
|
4924
|
+
* @returns 바꾼 지갑 `{ address, index, name? }`
|
|
4925
|
+
* @throws `WALLET_NOT_FOUND` 이 계정의 지갑 목록에 없는 주소
|
|
4926
|
+
*/
|
|
4927
|
+
async switchWallet(e) {
|
|
4928
|
+
var r;
|
|
4929
|
+
if (this.ensureAuthenticated(), !this.userId)
|
|
4930
|
+
throw new h(o.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
4931
|
+
const s = (await this.withSessionRecovery(() => this.walletProvider.getAddresses(this.userId))).find((n) => n.address.toLowerCase() === e.toLowerCase());
|
|
4932
|
+
if (!s)
|
|
4933
|
+
throw new h(o.WALLET_NOT_FOUND, "이 계정의 지갑이 아닙니다");
|
|
4934
|
+
return (((r = this.address) == null ? void 0 : r.toLowerCase()) !== s.address.toLowerCase() || this.activeWalletIndex !== s.index) && this.setActiveWallet(s.address, s.index), s;
|
|
4935
|
+
}
|
|
4627
4936
|
/**
|
|
4628
4937
|
* 지갑이 2개 이상이면 selectWallet()을 호출합니다.
|
|
4629
4938
|
* selectWallet() 내부에서 this.address 설정 및 addressChanged 이벤트를 처리합니다.
|
|
@@ -4638,7 +4947,7 @@ const W = class W extends ar {
|
|
|
4638
4947
|
*/
|
|
4639
4948
|
async selectWalletIfMultiple(e, t) {
|
|
4640
4949
|
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(
|
|
4950
|
+
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
4951
|
for (const a of n) {
|
|
4643
4952
|
if (typeof a != "string" || !a) continue;
|
|
4644
4953
|
const l = e.find(
|
|
@@ -4761,10 +5070,10 @@ const W = class W extends ar {
|
|
|
4761
5070
|
* 상황은 정상적으로 발생하므로, 조용히 넘어가지 않고 체인당 한 번 경고한다.
|
|
4762
5071
|
*/
|
|
4763
5072
|
resolveNativeCurrency(e) {
|
|
4764
|
-
const t =
|
|
5073
|
+
const t = fs(e, this._config.nativeCurrencies);
|
|
4765
5074
|
return t || (this._warnedUnknownNativeCurrency.has(e) || (this._warnedUnknownNativeCurrency.add(e), console.warn(
|
|
4766
5075
|
`[CROSSx SDK] ${e} 의 native 통화 정보가 없어 심볼을 비우고 decimals 를 18 로 가정합니다. 컨펌 모달 금액이 단위 없이 표시되며, decimals 가 18 이 아니면 금액이 틀립니다. SDKConfig.nativeCurrencies 에 { '${e}': { symbol, decimals } } 를 넘겨 주세요.`
|
|
4767
|
-
)),
|
|
5076
|
+
)), _s);
|
|
4768
5077
|
}
|
|
4769
5078
|
/**
|
|
4770
5079
|
* 지갑 생성/로드 (로그인 후 address가 없는 경우)
|
|
@@ -4792,7 +5101,7 @@ const W = class W extends ar {
|
|
|
4792
5101
|
return this.withSessionRecovery(() => this._signMessage(e, t, s));
|
|
4793
5102
|
}
|
|
4794
5103
|
async _signMessage(e, t, s) {
|
|
4795
|
-
const r =
|
|
5104
|
+
const r = L.getBridge(), n = this._isAuthenticatedViaRNBridge || !this.authenticated;
|
|
4796
5105
|
if (r != null && r.signMessage && n)
|
|
4797
5106
|
try {
|
|
4798
5107
|
const l = await r.signMessage({
|
|
@@ -4804,8 +5113,8 @@ const W = class W extends ar {
|
|
|
4804
5113
|
});
|
|
4805
5114
|
return { chainId: e, signature: l.signature, message: t, address: this.address ?? "" };
|
|
4806
5115
|
} catch (l) {
|
|
4807
|
-
if (!
|
|
4808
|
-
throw
|
|
5116
|
+
if (!yt(l))
|
|
5117
|
+
throw j(l, o.SIGNATURE_FAILED);
|
|
4809
5118
|
await this.clearRNBridgeDelegation("native signMessage 가 ERR_BRIDGE_NOT_AUTHORIZED 로 거부"), c.warn("[CROSSx] Bridge 미인증 — 일반 서명 경로로 폴백 (signMessage)");
|
|
4810
5119
|
}
|
|
4811
5120
|
if (this.ensureAuthenticated(), !this.userId)
|
|
@@ -4876,7 +5185,7 @@ const W = class W extends ar {
|
|
|
4876
5185
|
throw new h(o.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
4877
5186
|
if (!this.walletProvider.signTypedData)
|
|
4878
5187
|
throw new h(o.NOT_IMPLEMENTED, "signTypedData가 구현되어 있지 않습니다");
|
|
4879
|
-
|
|
5188
|
+
br(e, t);
|
|
4880
5189
|
const r = await this.resolveAddress(s == null ? void 0 : s.index);
|
|
4881
5190
|
try {
|
|
4882
5191
|
const n = await this.signingOrchestrator.confirmAndExecuteWithPreparedPin({
|
|
@@ -4900,7 +5209,7 @@ const W = class W extends ar {
|
|
|
4900
5209
|
r.address
|
|
4901
5210
|
)
|
|
4902
5211
|
});
|
|
4903
|
-
return
|
|
5212
|
+
return kr(n.signature), {
|
|
4904
5213
|
chainId: e,
|
|
4905
5214
|
signature: n.signature,
|
|
4906
5215
|
address: r.address
|
|
@@ -4929,7 +5238,7 @@ const W = class W extends ar {
|
|
|
4929
5238
|
* });
|
|
4930
5239
|
*/
|
|
4931
5240
|
async signTypedDataOffchain(e, t) {
|
|
4932
|
-
return this.signTypedData(
|
|
5241
|
+
return this.signTypedData(b.OFFCHAIN_CHAIN_ID, e, t);
|
|
4933
5242
|
}
|
|
4934
5243
|
// ============================================================================
|
|
4935
5244
|
// 트랜잭션
|
|
@@ -4978,7 +5287,7 @@ const W = class W extends ar {
|
|
|
4978
5287
|
l
|
|
4979
5288
|
)
|
|
4980
5289
|
});
|
|
4981
|
-
return
|
|
5290
|
+
return Ur(a.signature), {
|
|
4982
5291
|
chainId: e,
|
|
4983
5292
|
signedTx: a.signature,
|
|
4984
5293
|
txHash: a.txHash ?? ""
|
|
@@ -5047,7 +5356,7 @@ const W = class W extends ar {
|
|
|
5047
5356
|
return _.txHash ?? _.signature;
|
|
5048
5357
|
}
|
|
5049
5358
|
}), l = (t.data ?? "").toLowerCase().replace(/^0x/, ""), d = l === "" || l === "00000000", g = l.startsWith("a9059cbb");
|
|
5050
|
-
return (d || g) && this.tokenHistoryService.registerHistoryFireAndForget(e, a,
|
|
5359
|
+
return (d || g) && this.tokenHistoryService.registerHistoryFireAndForget(e, a, _e).catch(
|
|
5051
5360
|
(u) => c.log("[TokenHistory] register failed (non-critical):", u)
|
|
5052
5361
|
), { chainId: e, txHash: a, status: "pending" };
|
|
5053
5362
|
} catch (a) {
|
|
@@ -5079,7 +5388,7 @@ const W = class W extends ar {
|
|
|
5079
5388
|
* @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
|
|
5080
5389
|
*/
|
|
5081
5390
|
async waitForTxAndGetReceipt(e, t, s = {}) {
|
|
5082
|
-
const r = s.intervalMs ??
|
|
5391
|
+
const r = s.intervalMs ?? Xt, n = Zt, a = s.timeoutMs ?? ze, l = Date.now() + a;
|
|
5083
5392
|
let d = r;
|
|
5084
5393
|
for (; Date.now() < l; ) {
|
|
5085
5394
|
const g = await this.getTransactionReceipt(e, t);
|
|
@@ -5107,41 +5416,41 @@ const W = class W extends ar {
|
|
|
5107
5416
|
* logger.log(receipt.status); // '0x1' | '0x0'
|
|
5108
5417
|
*/
|
|
5109
5418
|
async sendTransactionWithWaitForReceipt(e, t, s = {}) {
|
|
5110
|
-
var w,
|
|
5419
|
+
var w, m;
|
|
5111
5420
|
if (this._isAuthenticatedViaRNBridge) {
|
|
5112
|
-
const
|
|
5113
|
-
if (
|
|
5114
|
-
return this.bridgeSendTransactionWithWaitForReceipt(
|
|
5115
|
-
}
|
|
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) ??
|
|
5117
|
-
let p,
|
|
5118
|
-
const
|
|
5119
|
-
p =
|
|
5120
|
-
const
|
|
5421
|
+
const f = L.getBridge();
|
|
5422
|
+
if (f != null && f.sendTransactionWithWaitForReceipt)
|
|
5423
|
+
return this.bridgeSendTransactionWithWaitForReceipt(f, e, t, s);
|
|
5424
|
+
}
|
|
5425
|
+
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) ?? Jt, g = n ?? ((m = this._config.receiptPolling) == null ? void 0 : m.timeoutMs) ?? ze, u = this.resolveNativeCurrency(e), _ = t.from ?? "";
|
|
5426
|
+
let p, I;
|
|
5427
|
+
const S = this.waitForTxAndGetReceipt(l, e, { intervalMs: d, timeoutMs: g }).then((f) => {
|
|
5428
|
+
p = f;
|
|
5429
|
+
const E = BigInt(f.gasUsed) * BigInt(f.effectiveGasPrice), T = t.value ? BigInt(t.value) : 0n, y = de(t.value, u.symbol, u.decimals, this._config.displayDecimals), R = de("0x" + E.toString(16), u.symbol, u.decimals, this._config.displayDecimals), N = de("0x" + (T + E).toString(16), u.symbol, u.decimals, this._config.displayDecimals);
|
|
5121
5430
|
return {
|
|
5122
5431
|
chainId: e,
|
|
5123
5432
|
txHash: l,
|
|
5124
|
-
from:
|
|
5125
|
-
to:
|
|
5126
|
-
amount:
|
|
5127
|
-
fees:
|
|
5433
|
+
from: f.from,
|
|
5434
|
+
to: f.to ?? t.to,
|
|
5435
|
+
amount: y,
|
|
5436
|
+
fees: R,
|
|
5128
5437
|
total: N,
|
|
5129
5438
|
nativeSymbol: u.symbol,
|
|
5130
|
-
status:
|
|
5439
|
+
status: f.status === "0x1" ? "success" : "reverted"
|
|
5131
5440
|
};
|
|
5132
|
-
}).catch((
|
|
5441
|
+
}).catch((f) => (I = f instanceof Error ? f : new Error(String(f)), {
|
|
5133
5442
|
chainId: e,
|
|
5134
5443
|
txHash: l,
|
|
5135
5444
|
from: _,
|
|
5136
5445
|
to: t.to,
|
|
5137
|
-
amount:
|
|
5446
|
+
amount: de(t.value, u.symbol, u.decimals, this._config.displayDecimals),
|
|
5138
5447
|
nativeSymbol: u.symbol,
|
|
5139
5448
|
status: "timeout"
|
|
5140
5449
|
}));
|
|
5141
5450
|
if (await this.confirmation.showTransactionProgress(
|
|
5142
5451
|
{ chainId: e, txHash: l, from: _, to: t.to },
|
|
5143
|
-
|
|
5144
|
-
),
|
|
5452
|
+
S
|
|
5453
|
+
), I) throw I;
|
|
5145
5454
|
return { chainId: e, txHash: l, receipt: p };
|
|
5146
5455
|
}
|
|
5147
5456
|
/**
|
|
@@ -5171,7 +5480,7 @@ const W = class W extends ar {
|
|
|
5171
5480
|
pollIntervalMs: r.intervalMs
|
|
5172
5481
|
});
|
|
5173
5482
|
} catch (a) {
|
|
5174
|
-
throw
|
|
5483
|
+
throw j(a, o.TRANSACTION_FAILED);
|
|
5175
5484
|
}
|
|
5176
5485
|
return {
|
|
5177
5486
|
chainId: t,
|
|
@@ -5374,7 +5683,7 @@ const W = class W extends ar {
|
|
|
5374
5683
|
return { wei: "0x0", formatted: "0", chainId: e };
|
|
5375
5684
|
try {
|
|
5376
5685
|
const r = await this.jsonRpc.call("eth_getBalance", [t, "latest"], e) ?? "0x0";
|
|
5377
|
-
return { wei: r, formatted:
|
|
5686
|
+
return { wei: r, formatted: vr(r, this._config.displayDecimals), chainId: e };
|
|
5378
5687
|
} catch (s) {
|
|
5379
5688
|
if (s instanceof h) throw s;
|
|
5380
5689
|
const r = s instanceof Error ? s.message : String(s);
|
|
@@ -5402,7 +5711,7 @@ const W = class W extends ar {
|
|
|
5402
5711
|
getProvider(e) {
|
|
5403
5712
|
this.ensureAuthenticated();
|
|
5404
5713
|
let t = this._providers.get(e);
|
|
5405
|
-
return t || (t = new
|
|
5714
|
+
return t || (t = new ps(this, e), this._providers.set(e, t)), t;
|
|
5406
5715
|
}
|
|
5407
5716
|
/**
|
|
5408
5717
|
* EIP-1193 `accountsChanged` 이벤트를 모든 활성 provider 인스턴스에 dispatch 한다.
|
|
@@ -5462,7 +5771,7 @@ const W = class W extends ar {
|
|
|
5462
5771
|
* 보안: bridge.isActivated() 가 false 이거나 payload sanitize 실패 시 이벤트 무시.
|
|
5463
5772
|
*/
|
|
5464
5773
|
subscribeBridgeWalletChanged() {
|
|
5465
|
-
const e =
|
|
5774
|
+
const e = L.getBridge();
|
|
5466
5775
|
if (!(e != null && e.onEvent)) {
|
|
5467
5776
|
c.warn("[CROSSx] bridge.onEvent 미지원 — walletChanged 구독 불가");
|
|
5468
5777
|
return;
|
|
@@ -5505,7 +5814,7 @@ const W = class W extends ar {
|
|
|
5505
5814
|
}
|
|
5506
5815
|
/** 인증 상태를 초기화합니다. */
|
|
5507
5816
|
clearAuthState() {
|
|
5508
|
-
this.stateManager.clearAuthState(), this._isAuthenticatedViaRNBridge = !1;
|
|
5817
|
+
this.stateManager.clearAuthState(), this.walletProvider instanceof Me && this.walletProvider.forgetSession(), this._isAuthenticatedViaRNBridge = !1;
|
|
5509
5818
|
}
|
|
5510
5819
|
/**
|
|
5511
5820
|
* Gateway -10002(Unauthorized) / -10033(User not found) 수신 시 강제 로그아웃.
|
|
@@ -5623,12 +5932,12 @@ const W = class W extends ar {
|
|
|
5623
5932
|
*/
|
|
5624
5933
|
dispose() {
|
|
5625
5934
|
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(),
|
|
5935
|
+
(e = this._themeMediaCleanup) == null || e.call(this), this._themeMediaCleanup = null, this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), st(null);
|
|
5627
5936
|
}
|
|
5628
5937
|
};
|
|
5629
|
-
|
|
5630
|
-
let
|
|
5631
|
-
class
|
|
5938
|
+
b.WALLET_PREF_KEY = "wallet_preference", b.OFFCHAIN_CHAIN_ID = "0";
|
|
5939
|
+
let Fe = b;
|
|
5940
|
+
class si {
|
|
5632
5941
|
constructor() {
|
|
5633
5942
|
this.prefix = "crossx_";
|
|
5634
5943
|
}
|
|
@@ -5665,8 +5974,8 @@ class kr {
|
|
|
5665
5974
|
}
|
|
5666
5975
|
}
|
|
5667
5976
|
}
|
|
5668
|
-
const
|
|
5669
|
-
class
|
|
5977
|
+
const ue = "crossx-sdk", wt = 1, v = "data", B = "keys", ge = "aes-primary", ri = 12;
|
|
5978
|
+
class St {
|
|
5670
5979
|
constructor(e) {
|
|
5671
5980
|
this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
|
|
5672
5981
|
}
|
|
@@ -5675,10 +5984,10 @@ class ct {
|
|
|
5675
5984
|
}
|
|
5676
5985
|
openDB() {
|
|
5677
5986
|
return new Promise((e, t) => {
|
|
5678
|
-
const s = indexedDB.open(this.dbName,
|
|
5987
|
+
const s = indexedDB.open(this.dbName, wt);
|
|
5679
5988
|
s.onupgradeneeded = () => {
|
|
5680
5989
|
const r = s.result;
|
|
5681
|
-
r.objectStoreNames.contains(
|
|
5990
|
+
r.objectStoreNames.contains(v) || r.createObjectStore(v), r.objectStoreNames.contains(B) || r.createObjectStore(B);
|
|
5682
5991
|
}, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error);
|
|
5683
5992
|
});
|
|
5684
5993
|
}
|
|
@@ -5693,16 +6002,16 @@ class ct {
|
|
|
5693
6002
|
openLegacyIfExists() {
|
|
5694
6003
|
return new Promise((e, t) => {
|
|
5695
6004
|
let s = !1;
|
|
5696
|
-
const r = indexedDB.open(
|
|
6005
|
+
const r = indexedDB.open(ue, wt);
|
|
5697
6006
|
r.onupgradeneeded = () => {
|
|
5698
6007
|
s = !0;
|
|
5699
6008
|
}, r.onsuccess = () => {
|
|
5700
6009
|
const n = r.result;
|
|
5701
6010
|
if (s) {
|
|
5702
|
-
n.close(), this.deleteDB(
|
|
6011
|
+
n.close(), this.deleteDB(ue).then(() => e(null));
|
|
5703
6012
|
return;
|
|
5704
6013
|
}
|
|
5705
|
-
if (!n.objectStoreNames.contains(B) || !n.objectStoreNames.contains(
|
|
6014
|
+
if (!n.objectStoreNames.contains(B) || !n.objectStoreNames.contains(v)) {
|
|
5706
6015
|
n.close(), e(null);
|
|
5707
6016
|
return;
|
|
5708
6017
|
}
|
|
@@ -5753,7 +6062,7 @@ class ct {
|
|
|
5753
6062
|
}
|
|
5754
6063
|
async init() {
|
|
5755
6064
|
this.db = await this.openDB();
|
|
5756
|
-
const e = await this.idbGet(B,
|
|
6065
|
+
const e = await this.idbGet(B, ge);
|
|
5757
6066
|
if (e) {
|
|
5758
6067
|
this.cryptoKey = e;
|
|
5759
6068
|
return;
|
|
@@ -5767,23 +6076,23 @@ class ct {
|
|
|
5767
6076
|
{ name: "AES-GCM", length: 256 },
|
|
5768
6077
|
!1,
|
|
5769
6078
|
["encrypt", "decrypt"]
|
|
5770
|
-
), await this.idbPut(B,
|
|
6079
|
+
), await this.idbPut(B, ge, this.cryptoKey);
|
|
5771
6080
|
}
|
|
5772
6081
|
/**
|
|
5773
6082
|
* 레거시 DB('crossx-sdk')에서 projectId 스코프 DB로 암호키·데이터 마이그레이션.
|
|
5774
6083
|
* 마이그레이션 성공 시 레거시 DB 삭제.
|
|
5775
6084
|
*/
|
|
5776
6085
|
async migrateFromLegacyDB() {
|
|
5777
|
-
if (this.dbName ===
|
|
6086
|
+
if (this.dbName === ue) return null;
|
|
5778
6087
|
try {
|
|
5779
6088
|
const e = await this.openLegacyIfExists();
|
|
5780
6089
|
if (!e) return null;
|
|
5781
|
-
const t = e.transaction([B,
|
|
6090
|
+
const t = e.transaction([B, v], "readonly"), s = t.objectStore(B).get(ge), r = await new Promise((g, u) => {
|
|
5782
6091
|
s.onsuccess = () => g(s.result), s.onerror = () => u(s.error);
|
|
5783
6092
|
});
|
|
5784
6093
|
if (!r)
|
|
5785
6094
|
return e.close(), null;
|
|
5786
|
-
const n = t.objectStore(
|
|
6095
|
+
const n = t.objectStore(v).getAll(), a = t.objectStore(v).getAllKeys(), [l, d] = await Promise.all([
|
|
5787
6096
|
new Promise((g, u) => {
|
|
5788
6097
|
n.onsuccess = () => g(n.result), n.onerror = () => u(n.error);
|
|
5789
6098
|
}),
|
|
@@ -5791,16 +6100,16 @@ class ct {
|
|
|
5791
6100
|
a.onsuccess = () => g(a.result), a.onerror = () => u(a.error);
|
|
5792
6101
|
})
|
|
5793
6102
|
]);
|
|
5794
|
-
e.close(), await this.idbPut(B,
|
|
6103
|
+
e.close(), await this.idbPut(B, ge, r);
|
|
5795
6104
|
for (let g = 0; g < d.length; g++)
|
|
5796
|
-
await this.idbPut(
|
|
5797
|
-
return await this.deleteDB(
|
|
6105
|
+
await this.idbPut(v, String(d[g]), l[g]);
|
|
6106
|
+
return await this.deleteDB(ue), c.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), r;
|
|
5798
6107
|
} catch (e) {
|
|
5799
6108
|
return c.warn("[CROSSx] IndexedDB 레거시 DB 마이그레이션 실패:", e), null;
|
|
5800
6109
|
}
|
|
5801
6110
|
}
|
|
5802
6111
|
async encrypt(e) {
|
|
5803
|
-
const t = new Uint8Array(
|
|
6112
|
+
const t = new Uint8Array(ri);
|
|
5804
6113
|
crypto.getRandomValues(t);
|
|
5805
6114
|
const s = new TextEncoder().encode(e), r = await crypto.subtle.encrypt(
|
|
5806
6115
|
{ name: "AES-GCM", iv: t },
|
|
@@ -5821,7 +6130,7 @@ class ct {
|
|
|
5821
6130
|
try {
|
|
5822
6131
|
await this.ensureReady();
|
|
5823
6132
|
const s = JSON.stringify(t), r = await this.encrypt(s);
|
|
5824
|
-
await this.idbPut(
|
|
6133
|
+
await this.idbPut(v, e, r);
|
|
5825
6134
|
} catch (s) {
|
|
5826
6135
|
throw c.error("[CROSSx] IndexedDB set error:", s), s;
|
|
5827
6136
|
}
|
|
@@ -5829,7 +6138,7 @@ class ct {
|
|
|
5829
6138
|
async get(e) {
|
|
5830
6139
|
try {
|
|
5831
6140
|
await this.ensureReady();
|
|
5832
|
-
const t = await this.idbGet(
|
|
6141
|
+
const t = await this.idbGet(v, e);
|
|
5833
6142
|
if (!t) return null;
|
|
5834
6143
|
const s = await this.decrypt(t);
|
|
5835
6144
|
return JSON.parse(s);
|
|
@@ -5839,14 +6148,14 @@ class ct {
|
|
|
5839
6148
|
}
|
|
5840
6149
|
async remove(e) {
|
|
5841
6150
|
try {
|
|
5842
|
-
await this.ensureReady(), await this.idbDelete(
|
|
6151
|
+
await this.ensureReady(), await this.idbDelete(v, e);
|
|
5843
6152
|
} catch (t) {
|
|
5844
6153
|
throw c.error("[CROSSx] IndexedDB remove error:", t), t;
|
|
5845
6154
|
}
|
|
5846
6155
|
}
|
|
5847
6156
|
async clear() {
|
|
5848
6157
|
try {
|
|
5849
|
-
await this.ensureReady(), await this.idbClear(
|
|
6158
|
+
await this.ensureReady(), await this.idbClear(v);
|
|
5850
6159
|
} catch (e) {
|
|
5851
6160
|
throw c.error("[CROSSx] IndexedDB clear error:", e), e;
|
|
5852
6161
|
}
|
|
@@ -5858,14 +6167,14 @@ class ct {
|
|
|
5858
6167
|
return typeof indexedDB < "u" && typeof crypto < "u" && typeof crypto.subtle < "u";
|
|
5859
6168
|
}
|
|
5860
6169
|
}
|
|
5861
|
-
const
|
|
5862
|
-
class
|
|
6170
|
+
const ii = 60;
|
|
6171
|
+
class ni {
|
|
5863
6172
|
constructor() {
|
|
5864
6173
|
this.jwks = null;
|
|
5865
6174
|
}
|
|
5866
6175
|
setJWKSEndpoint(e) {
|
|
5867
6176
|
try {
|
|
5868
|
-
this.jwks =
|
|
6177
|
+
this.jwks = $t(new URL(e)), c.log("[CROSSx] JWKS 엔드포인트 설정:", e);
|
|
5869
6178
|
} catch (t) {
|
|
5870
6179
|
c.warn("[CROSSx] JWKS 엔드포인트 URL 파싱 실패:", t);
|
|
5871
6180
|
}
|
|
@@ -5879,7 +6188,7 @@ class Lr {
|
|
|
5879
6188
|
iat: s.iat
|
|
5880
6189
|
});
|
|
5881
6190
|
const r = Math.floor(Date.now() / 1e3);
|
|
5882
|
-
if (s.exp && s.exp +
|
|
6191
|
+
if (s.exp && s.exp + ii < r)
|
|
5883
6192
|
return c.warn("[CROSSx] 토큰 만료:", {
|
|
5884
6193
|
exp: s.exp,
|
|
5885
6194
|
now: r,
|
|
@@ -5889,7 +6198,7 @@ class Lr {
|
|
|
5889
6198
|
return c.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: s, valid: !1, signatureVerified: !1 };
|
|
5890
6199
|
if (this.jwks)
|
|
5891
6200
|
try {
|
|
5892
|
-
const { payload: n } = await
|
|
6201
|
+
const { payload: n } = await Yt(e, this.jwks, {
|
|
5893
6202
|
algorithms: ["RS256", "ES256"]
|
|
5894
6203
|
});
|
|
5895
6204
|
return c.log("[CROSSx] JWT 서명 검증 성공"), {
|
|
@@ -5908,7 +6217,7 @@ class Lr {
|
|
|
5908
6217
|
}
|
|
5909
6218
|
}
|
|
5910
6219
|
decodeJWT(e) {
|
|
5911
|
-
return
|
|
6220
|
+
return qt(e);
|
|
5912
6221
|
}
|
|
5913
6222
|
/**
|
|
5914
6223
|
* EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
|
|
@@ -5923,29 +6232,29 @@ class Lr {
|
|
|
5923
6232
|
${s.length}`
|
|
5924
6233
|
), n = new Uint8Array(r.length + s.length);
|
|
5925
6234
|
n.set(r, 0), n.set(s, r.length);
|
|
5926
|
-
const a =
|
|
6235
|
+
const a = je(n), l = t.startsWith("0x") ? t.slice(2) : t;
|
|
5927
6236
|
if (l.length !== 130)
|
|
5928
6237
|
throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${l.length}`);
|
|
5929
|
-
const d =
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
).addRecoveryBit(p).recoverPublicKey(a).toBytes(!1).slice(1),
|
|
5933
|
-
return "0x" +
|
|
6238
|
+
const d = ai(l), g = d.slice(0, 32), u = d.slice(32, 64), _ = d[64], p = _ >= 27 ? _ - 27 : _, w = new jt.Signature(
|
|
6239
|
+
Et(g),
|
|
6240
|
+
Et(u)
|
|
6241
|
+
).addRecoveryBit(p).recoverPublicKey(a).toBytes(!1).slice(1), m = je(w);
|
|
6242
|
+
return "0x" + zt(m.slice(12));
|
|
5934
6243
|
}
|
|
5935
6244
|
}
|
|
5936
|
-
function
|
|
6245
|
+
function ai(i) {
|
|
5937
6246
|
const e = new Uint8Array(i.length / 2);
|
|
5938
6247
|
for (let t = 0; t < e.length; t++)
|
|
5939
6248
|
e[t] = parseInt(i.substring(t * 2, t * 2 + 2), 16);
|
|
5940
6249
|
return e;
|
|
5941
6250
|
}
|
|
5942
|
-
function
|
|
6251
|
+
function Et(i) {
|
|
5943
6252
|
let e = "0x";
|
|
5944
6253
|
for (const t of i) e += t.toString(16).padStart(2, "0");
|
|
5945
6254
|
return BigInt(e);
|
|
5946
6255
|
}
|
|
5947
|
-
const
|
|
5948
|
-
class
|
|
6256
|
+
const oi = 5e3;
|
|
6257
|
+
class ci {
|
|
5949
6258
|
constructor(e, t) {
|
|
5950
6259
|
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
6260
|
}
|
|
@@ -5958,8 +6267,8 @@ class Fr {
|
|
|
5958
6267
|
const t = this.required;
|
|
5959
6268
|
if (!t && this.hasFreshFailure()) return e;
|
|
5960
6269
|
try {
|
|
5961
|
-
const { version: s, key: r } = await this.currentKey(), n = await
|
|
5962
|
-
return `${s}.${
|
|
6270
|
+
const { version: s, key: r } = await this.currentKey(), n = await li(r, e);
|
|
6271
|
+
return `${s}.${hi(n)}`;
|
|
5963
6272
|
} catch (s) {
|
|
5964
6273
|
if (t)
|
|
5965
6274
|
throw this.keyFailedAt = Date.now(), s instanceof h ? s : new h(
|
|
@@ -5969,7 +6278,7 @@ class Fr {
|
|
|
5969
6278
|
);
|
|
5970
6279
|
return this.keyFailedAt = Date.now(), c.warn(
|
|
5971
6280
|
"[CROSSx] pin-key 조회 실패 — PIN 평문 전송을 유지합니다",
|
|
5972
|
-
`(${Math.round(
|
|
6281
|
+
`(${Math.round(tt / 1e3)}초 후 재확인)`
|
|
5973
6282
|
), e;
|
|
5974
6283
|
}
|
|
5975
6284
|
}
|
|
@@ -5996,15 +6305,15 @@ class Fr {
|
|
|
5996
6305
|
}
|
|
5997
6306
|
// ── 공개키 캐시 ─────────────────────────────────────────────────────────────
|
|
5998
6307
|
hasFreshFailure() {
|
|
5999
|
-
return this.keyFailedAt !== 0 && Date.now() - this.keyFailedAt <
|
|
6308
|
+
return this.keyFailedAt !== 0 && Date.now() - this.keyFailedAt < tt;
|
|
6000
6309
|
}
|
|
6001
6310
|
async currentKey() {
|
|
6002
|
-
return this.cachedKey && this.cachedVersion && Date.now() - this.cachedAt <
|
|
6311
|
+
return this.cachedKey && this.cachedVersion && Date.now() - this.cachedAt < ss ? { 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
6312
|
this.keyInFlight = null;
|
|
6004
6313
|
}), this.keyInFlight);
|
|
6005
6314
|
}
|
|
6006
6315
|
async fetchAndImportKey() {
|
|
6007
|
-
const e =
|
|
6316
|
+
const e = Gt();
|
|
6008
6317
|
if (!e)
|
|
6009
6318
|
throw new h(
|
|
6010
6319
|
o.PIN_ENCRYPTION_FAILED,
|
|
@@ -6014,16 +6323,16 @@ class Fr {
|
|
|
6014
6323
|
url: `${this.baseUrl}/pin-key`,
|
|
6015
6324
|
method: "GET",
|
|
6016
6325
|
headers: { "X-Project-Id": this.adapterConfig.projectId },
|
|
6017
|
-
timeoutMs:
|
|
6018
|
-
}), s =
|
|
6326
|
+
timeoutMs: oi
|
|
6327
|
+
}), s = _i(t.data);
|
|
6019
6328
|
if (!(s != null && s.keyVersion) || !(s != null && s.publicKey))
|
|
6020
6329
|
throw new h(
|
|
6021
6330
|
o.PIN_ENCRYPTION_FAILED,
|
|
6022
6331
|
"pin-key 응답을 해석할 수 없습니다."
|
|
6023
6332
|
);
|
|
6024
|
-
const r =
|
|
6333
|
+
const r = ui(s.publicKey), n = await e.importKey(
|
|
6025
6334
|
"spki",
|
|
6026
|
-
|
|
6335
|
+
gi(r),
|
|
6027
6336
|
{ name: "RSA-OAEP", hash: "SHA-256" },
|
|
6028
6337
|
!1,
|
|
6029
6338
|
["encrypt"]
|
|
@@ -6031,8 +6340,8 @@ class Fr {
|
|
|
6031
6340
|
return { version: s.keyVersion, key: n };
|
|
6032
6341
|
}
|
|
6033
6342
|
}
|
|
6034
|
-
async function
|
|
6035
|
-
const t =
|
|
6343
|
+
async function li(i, e) {
|
|
6344
|
+
const t = Gt();
|
|
6036
6345
|
if (!t)
|
|
6037
6346
|
throw new h(
|
|
6038
6347
|
o.PIN_ENCRYPTION_FAILED,
|
|
@@ -6045,29 +6354,29 @@ async function Br(i, e) {
|
|
|
6045
6354
|
);
|
|
6046
6355
|
return new Uint8Array(s);
|
|
6047
6356
|
}
|
|
6048
|
-
function
|
|
6357
|
+
function Gt() {
|
|
6049
6358
|
const i = globalThis.crypto;
|
|
6050
6359
|
return (i == null ? void 0 : i.subtle) ?? null;
|
|
6051
6360
|
}
|
|
6052
|
-
function
|
|
6053
|
-
return
|
|
6361
|
+
function hi(i) {
|
|
6362
|
+
return di(i).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
6054
6363
|
}
|
|
6055
|
-
const
|
|
6056
|
-
function
|
|
6364
|
+
const re = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
6365
|
+
function di(i) {
|
|
6057
6366
|
let e = "";
|
|
6058
6367
|
for (let t = 0; t < i.length; t += 3) {
|
|
6059
6368
|
const s = i[t], r = i[t + 1], n = i[t + 2];
|
|
6060
|
-
e +=
|
|
6369
|
+
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
6370
|
}
|
|
6062
6371
|
return e;
|
|
6063
6372
|
}
|
|
6064
|
-
function
|
|
6373
|
+
function ui(i) {
|
|
6065
6374
|
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
6375
|
for (let r = 0; r < t.length; r += 4) {
|
|
6067
6376
|
const n = [0, 1, 2, 3].map((a) => {
|
|
6068
6377
|
const l = t[r + a];
|
|
6069
6378
|
if (l === "=" || l === void 0) return -1;
|
|
6070
|
-
const d =
|
|
6379
|
+
const d = re.indexOf(l);
|
|
6071
6380
|
if (d === -1)
|
|
6072
6381
|
throw new h(
|
|
6073
6382
|
o.PIN_ENCRYPTION_FAILED,
|
|
@@ -6079,11 +6388,11 @@ function Hr(i) {
|
|
|
6079
6388
|
}
|
|
6080
6389
|
return new Uint8Array(s);
|
|
6081
6390
|
}
|
|
6082
|
-
function
|
|
6391
|
+
function gi(i) {
|
|
6083
6392
|
const e = new Uint8Array(i.length);
|
|
6084
6393
|
return e.set(i), e.buffer;
|
|
6085
6394
|
}
|
|
6086
|
-
function
|
|
6395
|
+
function _i(i) {
|
|
6087
6396
|
if (!i || typeof i != "object") return null;
|
|
6088
6397
|
const e = i;
|
|
6089
6398
|
if (typeof e.code == "number") {
|
|
@@ -6097,8 +6406,8 @@ function $r(i) {
|
|
|
6097
6406
|
}
|
|
6098
6407
|
return typeof e.keyVersion == "string" && typeof e.publicKey == "string" ? e : null;
|
|
6099
6408
|
}
|
|
6100
|
-
const
|
|
6101
|
-
class
|
|
6409
|
+
const fi = 3e4, pi = 1e3;
|
|
6410
|
+
class wi {
|
|
6102
6411
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6103
6412
|
async request(e) {
|
|
6104
6413
|
const t = e.retries ?? 0;
|
|
@@ -6109,7 +6418,7 @@ class jr {
|
|
|
6109
6418
|
} catch (r) {
|
|
6110
6419
|
if (s === t) throw r;
|
|
6111
6420
|
}
|
|
6112
|
-
await new Promise((r) => setTimeout(r,
|
|
6421
|
+
await new Promise((r) => setTimeout(r, pi * 2 ** s));
|
|
6113
6422
|
}
|
|
6114
6423
|
throw new Error("Unexpected: retry loop exited without result");
|
|
6115
6424
|
}
|
|
@@ -6117,7 +6426,7 @@ class jr {
|
|
|
6117
6426
|
async _doRequest(e) {
|
|
6118
6427
|
const t = new AbortController(), s = setTimeout(
|
|
6119
6428
|
() => t.abort(),
|
|
6120
|
-
e.timeoutMs ??
|
|
6429
|
+
e.timeoutMs ?? fi
|
|
6121
6430
|
);
|
|
6122
6431
|
try {
|
|
6123
6432
|
const r = await fetch(e.url, {
|
|
@@ -6144,7 +6453,7 @@ class jr {
|
|
|
6144
6453
|
}
|
|
6145
6454
|
}
|
|
6146
6455
|
}
|
|
6147
|
-
function
|
|
6456
|
+
function Si(i) {
|
|
6148
6457
|
const e = { raw: i }, t = i.search(/(^|;)\s*info=/i), s = t >= 0 ? i.slice(0, t) : i;
|
|
6149
6458
|
if (t >= 0) {
|
|
6150
6459
|
const r = i.slice(t).replace(/^;?\s*info=/i, "").trim();
|
|
@@ -6159,14 +6468,14 @@ function Xr(i) {
|
|
|
6159
6468
|
}
|
|
6160
6469
|
return e;
|
|
6161
6470
|
}
|
|
6162
|
-
function
|
|
6471
|
+
function It(i) {
|
|
6163
6472
|
try {
|
|
6164
6473
|
return new URL(i).origin;
|
|
6165
6474
|
} catch {
|
|
6166
6475
|
return null;
|
|
6167
6476
|
}
|
|
6168
6477
|
}
|
|
6169
|
-
class
|
|
6478
|
+
class Ei {
|
|
6170
6479
|
constructor(e, t) {
|
|
6171
6480
|
this.inner = e, this.options = t;
|
|
6172
6481
|
}
|
|
@@ -6175,52 +6484,52 @@ class zr {
|
|
|
6175
6484
|
if (!this.isGateway(e.url))
|
|
6176
6485
|
return this.inner.request(e);
|
|
6177
6486
|
const t = await this.inner.request(
|
|
6178
|
-
this.options.sendVersionHeader === !1 ? e : { ...e, headers: { ...e.headers, [
|
|
6487
|
+
this.options.sendVersionHeader === !1 ? e : { ...e, headers: { ...e.headers, [rs]: this.options.version } }
|
|
6179
6488
|
);
|
|
6180
6489
|
return this.inspect(t), t;
|
|
6181
6490
|
}
|
|
6182
6491
|
isGateway(e) {
|
|
6183
|
-
const t =
|
|
6184
|
-
return t === null ? !1 : this.options.getGatewayBaseUrls().some((s) =>
|
|
6492
|
+
const t = It(e);
|
|
6493
|
+
return t === null ? !1 : this.options.getGatewayBaseUrls().some((s) => It(s) === t);
|
|
6185
6494
|
}
|
|
6186
6495
|
inspect(e) {
|
|
6187
6496
|
var r, n, a, l;
|
|
6188
|
-
const t =
|
|
6189
|
-
t && ((n = (r = this.options).onDeprecation) == null || n.call(r,
|
|
6497
|
+
const t = Ai(e.headers, ns);
|
|
6498
|
+
t && ((n = (r = this.options).onDeprecation) == null || n.call(r, Si(t)));
|
|
6190
6499
|
const s = e.data;
|
|
6191
|
-
s && s.code ===
|
|
6500
|
+
s && s.code === pe && ((l = (a = this.options).onUnsupported) == null || l.call(a, { message: Ii(s) }));
|
|
6192
6501
|
}
|
|
6193
6502
|
}
|
|
6194
|
-
function
|
|
6503
|
+
function Ii(i) {
|
|
6195
6504
|
for (const e of [i.data, i.message])
|
|
6196
6505
|
if (typeof e == "string" && e.trim()) return e;
|
|
6197
6506
|
}
|
|
6198
|
-
function
|
|
6507
|
+
function Ai(i, e) {
|
|
6199
6508
|
if (!i) return;
|
|
6200
6509
|
const t = e.toLowerCase();
|
|
6201
6510
|
for (const [s, r] of Object.entries(i))
|
|
6202
6511
|
if (s.toLowerCase() === t && r) return r;
|
|
6203
6512
|
}
|
|
6204
|
-
const
|
|
6513
|
+
const mi = [
|
|
6205
6514
|
/CROSSx\/([\d.]+)/i,
|
|
6206
6515
|
/ONE\s?wallet[^\s/]*\/([\d.]+)/i,
|
|
6207
6516
|
/ONE\s?pocket[^\s/]*\/([\d.]+)/i
|
|
6208
6517
|
];
|
|
6209
|
-
function
|
|
6518
|
+
function Ke() {
|
|
6210
6519
|
return typeof window > "u" ? void 0 : window;
|
|
6211
6520
|
}
|
|
6212
|
-
function
|
|
6213
|
-
const i =
|
|
6521
|
+
function Ti() {
|
|
6522
|
+
const i = Ke();
|
|
6214
6523
|
return i == null ? void 0 : i.__crossx;
|
|
6215
6524
|
}
|
|
6216
|
-
function
|
|
6525
|
+
function yi(i) {
|
|
6217
6526
|
return i === "ios" || i === "android" ? i : null;
|
|
6218
6527
|
}
|
|
6219
|
-
function
|
|
6528
|
+
function ke() {
|
|
6220
6529
|
const i = typeof navigator > "u" ? "" : navigator.userAgent;
|
|
6221
6530
|
return /Android/i.test(i) ? "android" : /iPhone|iPad|iPod|Macintosh/i.test(i) ? "ios" : null;
|
|
6222
6531
|
}
|
|
6223
|
-
function
|
|
6532
|
+
function Ri(i, e) {
|
|
6224
6533
|
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
6534
|
for (let a = 0; a < n; a += 1) {
|
|
6226
6535
|
const l = (s[a] ?? 0) - (r[a] ?? 0);
|
|
@@ -6228,44 +6537,44 @@ function si(i, e) {
|
|
|
6228
6537
|
}
|
|
6229
6538
|
return 0;
|
|
6230
6539
|
}
|
|
6231
|
-
function
|
|
6232
|
-
const i =
|
|
6540
|
+
function Ni() {
|
|
6541
|
+
const i = Ke();
|
|
6233
6542
|
if (!i) return !1;
|
|
6234
6543
|
const e = i.__crossxRNBridge;
|
|
6235
6544
|
return e != null && e.isInstalled ? !0 : i.__CROSSX_BRIDGE_INITIALIZED__ === !0 || i.__CROSSX_RN_BRIDGE_READY__ === !0;
|
|
6236
6545
|
}
|
|
6237
|
-
function
|
|
6546
|
+
function At() {
|
|
6238
6547
|
const i = typeof navigator > "u" ? "" : navigator.userAgent;
|
|
6239
|
-
for (const e of
|
|
6548
|
+
for (const e of mi) {
|
|
6240
6549
|
const t = e.exec(i);
|
|
6241
6550
|
if (t) return t[1] ?? null;
|
|
6242
6551
|
}
|
|
6243
6552
|
}
|
|
6244
|
-
function
|
|
6245
|
-
const i =
|
|
6553
|
+
function Ee() {
|
|
6554
|
+
const i = Ti();
|
|
6246
6555
|
if (i != null && i.browser)
|
|
6247
6556
|
return {
|
|
6248
6557
|
version: i.version ?? null,
|
|
6249
|
-
platform:
|
|
6558
|
+
platform: yi(i.platform) ?? ke(),
|
|
6250
6559
|
detectedBy: "marker"
|
|
6251
6560
|
};
|
|
6252
|
-
if (
|
|
6561
|
+
if (Ni())
|
|
6253
6562
|
return {
|
|
6254
|
-
version:
|
|
6255
|
-
platform:
|
|
6563
|
+
version: At() ?? null,
|
|
6564
|
+
platform: ke(),
|
|
6256
6565
|
detectedBy: "bridge"
|
|
6257
6566
|
};
|
|
6258
|
-
const e =
|
|
6259
|
-
return e !== void 0 ? { version: e, platform:
|
|
6567
|
+
const e = At();
|
|
6568
|
+
return e !== void 0 ? { version: e, platform: ke(), detectedBy: "user-agent" } : null;
|
|
6260
6569
|
}
|
|
6261
|
-
function
|
|
6262
|
-
return
|
|
6570
|
+
function qi() {
|
|
6571
|
+
return Ee() !== null;
|
|
6263
6572
|
}
|
|
6264
|
-
function
|
|
6265
|
-
const e =
|
|
6266
|
-
return e ? Promise.resolve(e) :
|
|
6573
|
+
function ji(i = 3e3) {
|
|
6574
|
+
const e = Ee();
|
|
6575
|
+
return e ? Promise.resolve(e) : Ke() ? new Promise((t) => {
|
|
6267
6576
|
const s = Date.now(), r = setInterval(() => {
|
|
6268
|
-
const n =
|
|
6577
|
+
const n = Ee();
|
|
6269
6578
|
if (n) {
|
|
6270
6579
|
clearInterval(r), t(n);
|
|
6271
6580
|
return;
|
|
@@ -6274,18 +6583,18 @@ function yi(i = 3e3) {
|
|
|
6274
6583
|
}, 50);
|
|
6275
6584
|
}) : Promise.resolve(null);
|
|
6276
6585
|
}
|
|
6277
|
-
const
|
|
6586
|
+
const Oi = /* @__PURE__ */ new Set([
|
|
6278
6587
|
"https://cross-wallet-oauth.crosstoken.io",
|
|
6279
6588
|
"https://stg-cross-wallet-oauth.crosstoken.io",
|
|
6280
6589
|
"https://dev-cross-wallet-oauth.crosstoken.io",
|
|
6281
6590
|
"https://one-wallet-oauth.onechain.nexus",
|
|
6282
6591
|
"https://stg-one-wallet-oauth.onechain.nexus",
|
|
6283
6592
|
"https://dev-one-wallet-oauth.onechain.nexus"
|
|
6284
|
-
]),
|
|
6285
|
-
function
|
|
6286
|
-
return i.platform !== "ios" ? !1 : i.version ?
|
|
6593
|
+
]), Pi = "crossx://oauth-callback", Ci = "2.3.2";
|
|
6594
|
+
function Di(i) {
|
|
6595
|
+
return i.platform !== "ios" ? !1 : i.version ? Ri(i.version, Ci) <= 0 : !0;
|
|
6287
6596
|
}
|
|
6288
|
-
class
|
|
6597
|
+
class K {
|
|
6289
6598
|
constructor() {
|
|
6290
6599
|
this.abortPending = null;
|
|
6291
6600
|
}
|
|
@@ -6320,7 +6629,7 @@ class H {
|
|
|
6320
6629
|
* - Google 및 기타: originalNonce === jwt.nonce
|
|
6321
6630
|
*/
|
|
6322
6631
|
static async verifyIdTokenNonce(e, t) {
|
|
6323
|
-
const s =
|
|
6632
|
+
const s = K.parseJwtPayload(e), r = s.nonce, n = typeof s.iss == "string" ? s.iss : "(unknown)";
|
|
6324
6633
|
if (c.log("[CROSSx] nonce 검증 시작 —", {
|
|
6325
6634
|
iss: n,
|
|
6326
6635
|
nonceClaimType: typeof r,
|
|
@@ -6342,7 +6651,7 @@ class H {
|
|
|
6342
6651
|
return;
|
|
6343
6652
|
}
|
|
6344
6653
|
if (n.includes("appleid.apple.com")) {
|
|
6345
|
-
const a = await
|
|
6654
|
+
const a = await K.sha256Hex(t);
|
|
6346
6655
|
if (c.log("[CROSSx] Apple nonce 검증 —", {
|
|
6347
6656
|
expectedHashLength: a.length,
|
|
6348
6657
|
receivedHashLength: r.length,
|
|
@@ -6359,16 +6668,16 @@ class H {
|
|
|
6359
6668
|
}
|
|
6360
6669
|
openAuth(e) {
|
|
6361
6670
|
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 =
|
|
6671
|
+
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 = Ee();
|
|
6363
6672
|
let _ = e.authUrl;
|
|
6364
|
-
u && e.legacyAuthUrl &&
|
|
6673
|
+
u && e.legacyAuthUrl && Di(u) && (_ = e.legacyAuthUrl, c.info("[CROSSx] 구버전 iOS 지갑 감지 — 이관 전 OAuth 호스트 사용", {
|
|
6365
6674
|
appVersion: u.version ?? "(unknown)",
|
|
6366
6675
|
detectedBy: u.detectedBy,
|
|
6367
6676
|
authUrlBase: e.legacyAuthUrl
|
|
6368
6677
|
}));
|
|
6369
|
-
const p = _.includes("?") ? "&" : "?",
|
|
6370
|
-
let
|
|
6371
|
-
u && !
|
|
6678
|
+
const p = _.includes("?") ? "&" : "?", I = encodeURIComponent(window.location.origin);
|
|
6679
|
+
let S = `${_}${p}state=${d}&nonce=${g}&origin=${I}`;
|
|
6680
|
+
u && !S.includes("redirectUrl=") && (S += `&redirectUrl=${encodeURIComponent(Pi)}`, c.info("[CROSSx] 지갑 인앱 브라우저 감지 — redirectUrl 콜백 자동 부착", {
|
|
6372
6681
|
detectedBy: u.detectedBy,
|
|
6373
6682
|
appVersion: u.version ?? "(unknown)",
|
|
6374
6683
|
platform: u.platform ?? "(unknown)"
|
|
@@ -6378,7 +6687,7 @@ class H {
|
|
|
6378
6687
|
authUrlBase: _
|
|
6379
6688
|
});
|
|
6380
6689
|
const w = window.open(
|
|
6381
|
-
|
|
6690
|
+
S,
|
|
6382
6691
|
u ? "_blank" : "CROSSx OAuth",
|
|
6383
6692
|
`width=${r},height=${n},left=${a},top=${l}`
|
|
6384
6693
|
);
|
|
@@ -6386,79 +6695,79 @@ class H {
|
|
|
6386
6695
|
s(new Error("팝업 창을 열 수 없습니다. 팝업 차단을 해제해 주세요."));
|
|
6387
6696
|
return;
|
|
6388
6697
|
}
|
|
6389
|
-
const
|
|
6390
|
-
c.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"),
|
|
6391
|
-
}, 300 * 1e3),
|
|
6392
|
-
let
|
|
6393
|
-
const
|
|
6394
|
-
clearInterval(N), c.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " +
|
|
6395
|
-
|
|
6698
|
+
const m = setTimeout(() => {
|
|
6699
|
+
c.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), O(), s(new Error("Authentication timeout"));
|
|
6700
|
+
}, 300 * 1e3), f = 10, E = 30;
|
|
6701
|
+
let T = 0, y = null;
|
|
6702
|
+
const R = () => {
|
|
6703
|
+
clearInterval(N), c.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + E + "초간 대기합니다"), y = setTimeout(() => {
|
|
6704
|
+
O(), s(new Error(
|
|
6396
6705
|
"OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
|
|
6397
6706
|
));
|
|
6398
|
-
},
|
|
6707
|
+
}, E * 1e3);
|
|
6399
6708
|
}, N = setInterval(() => {
|
|
6400
|
-
|
|
6709
|
+
T++;
|
|
6401
6710
|
try {
|
|
6402
6711
|
if (!w.closed) return;
|
|
6403
6712
|
if (!!u) {
|
|
6404
|
-
|
|
6713
|
+
O(), s(new h(o.USER_REJECTED, "로그인이 취소되었습니다"));
|
|
6405
6714
|
return;
|
|
6406
6715
|
}
|
|
6407
|
-
const
|
|
6408
|
-
|
|
6716
|
+
const U = typeof document < "u" && document.hasFocus();
|
|
6717
|
+
T <= f && !U ? R() : (O(), s(new h(o.USER_REJECTED, "로그인이 취소되었습니다")));
|
|
6409
6718
|
} catch {
|
|
6410
|
-
|
|
6719
|
+
R();
|
|
6411
6720
|
}
|
|
6412
|
-
}, 1e3),
|
|
6413
|
-
this.abortPending = null, clearTimeout(
|
|
6414
|
-
},
|
|
6415
|
-
if (!
|
|
6416
|
-
|
|
6417
|
-
const
|
|
6721
|
+
}, 1e3), O = () => {
|
|
6722
|
+
this.abortPending = null, clearTimeout(m), clearInterval(N), y && clearTimeout(y), window.removeEventListener("message", P);
|
|
6723
|
+
}, P = (D) => {
|
|
6724
|
+
if (!Oi.has(D.origin)) return;
|
|
6725
|
+
O();
|
|
6726
|
+
const U = typeof D.data.status == "string", A = U ? D.data.data ?? {} : D.data;
|
|
6418
6727
|
c.log("[CROSSx] OAuth postMessage 수신 —", {
|
|
6419
|
-
format:
|
|
6420
|
-
status:
|
|
6728
|
+
format: U ? "wrapped" : "flat",
|
|
6729
|
+
status: U ? D.data.status : "(flat)"
|
|
6421
6730
|
});
|
|
6422
|
-
const
|
|
6423
|
-
if (!
|
|
6731
|
+
const Q = (A == null ? void 0 : A.state) ?? D.data.state;
|
|
6732
|
+
if (!Q || Q !== d) {
|
|
6424
6733
|
s(new Error("OAuth state mismatch — possible CSRF attack"));
|
|
6425
6734
|
return;
|
|
6426
6735
|
}
|
|
6427
|
-
if (
|
|
6428
|
-
c.error("[CROSSx] OAuth 실패:",
|
|
6736
|
+
if (U && D.data.status !== "success") {
|
|
6737
|
+
c.error("[CROSSx] OAuth 실패:", A == null ? void 0 : A.error), s(new Error((A == null ? void 0 : A.error) || "Authentication failed"));
|
|
6429
6738
|
return;
|
|
6430
6739
|
}
|
|
6431
|
-
if (!
|
|
6432
|
-
c.error("[CROSSx] OAuth 실패:",
|
|
6740
|
+
if (!U && (A != null && A.error)) {
|
|
6741
|
+
c.error("[CROSSx] OAuth 실패:", A.error), s(new Error(A.error || "Authentication failed"));
|
|
6433
6742
|
return;
|
|
6434
6743
|
}
|
|
6435
|
-
const $ =
|
|
6744
|
+
const $ = A == null ? void 0 : A.idToken, ee = A == null ? void 0 : A.accessToken, Ve = ee ?? $, $e = (A == null ? void 0 : A.email) || void 0;
|
|
6436
6745
|
if (c.log("[CROSSx] OAuth 토큰 수신:", {
|
|
6437
|
-
hasAccessToken: !!
|
|
6746
|
+
hasAccessToken: !!ee,
|
|
6438
6747
|
hasIdToken: !!$,
|
|
6439
|
-
hasEmail:
|
|
6440
|
-
}), !
|
|
6748
|
+
hasEmail: !!$e
|
|
6749
|
+
}), !Ve) {
|
|
6441
6750
|
c.error("[CROSSx] 토큰을 찾을 수 없음:", D.data), s(new Error("Token not found in response"));
|
|
6442
6751
|
return;
|
|
6443
6752
|
}
|
|
6444
|
-
const
|
|
6445
|
-
|
|
6446
|
-
c.error("[CROSSx] nonce 검증 실패:",
|
|
6753
|
+
const Ye = { token: Ve, email: $e }, Te = (qe) => {
|
|
6754
|
+
K.verifyIdTokenNonce(qe, g).then(() => t(Ye)).catch((ye) => {
|
|
6755
|
+
c.error("[CROSSx] nonce 검증 실패:", ye), s(ye instanceof Error ? ye : new Error("nonce verification failed"));
|
|
6447
6756
|
});
|
|
6448
6757
|
};
|
|
6449
|
-
|
|
6758
|
+
ee ? ee.split(".").length === 3 ? Te(ee) : $ ? Te($) : (c.warn(
|
|
6450
6759
|
"[CROSSx] opaque accessToken만 수신 (idToken 없음) — nonce 검증 불가.",
|
|
6451
6760
|
"서버 측 nonce 검증이 필요합니다."
|
|
6452
|
-
), t(
|
|
6761
|
+
), t(Ye)) : $ ? Te($) : s(new Error("Token not found in response"));
|
|
6453
6762
|
};
|
|
6454
6763
|
this.abortPending = (D) => {
|
|
6455
|
-
|
|
6456
|
-
}, window.addEventListener("message",
|
|
6764
|
+
O(), s(new Error(D));
|
|
6765
|
+
}, window.addEventListener("message", P);
|
|
6457
6766
|
});
|
|
6458
6767
|
}
|
|
6459
6768
|
}
|
|
6460
|
-
const
|
|
6461
|
-
class
|
|
6769
|
+
const se = "crossx_wallet_data", q = "crossx_mock_pin_hash";
|
|
6770
|
+
class xi {
|
|
6462
6771
|
constructor(e, t) {
|
|
6463
6772
|
this.storage = e, this.pinStore = t ?? null;
|
|
6464
6773
|
}
|
|
@@ -6471,13 +6780,13 @@ class ci {
|
|
|
6471
6780
|
async checkWallet() {
|
|
6472
6781
|
if (this.migrateScenario !== void 0)
|
|
6473
6782
|
return c.log("[Mock] checkWallet → migration_required"), "migration_required";
|
|
6474
|
-
const t = await this.storage.get(
|
|
6783
|
+
const t = await this.storage.get(se) ? "exists" : "not_found";
|
|
6475
6784
|
return c.log(`[Mock] checkWallet → ${t}`), t;
|
|
6476
6785
|
}
|
|
6477
6786
|
async getOrCreateWallet(e) {
|
|
6478
6787
|
var t;
|
|
6479
6788
|
try {
|
|
6480
|
-
const s = await this.storage.get(
|
|
6789
|
+
const s = await this.storage.get(se);
|
|
6481
6790
|
if (s) return s;
|
|
6482
6791
|
const r = {
|
|
6483
6792
|
id: e,
|
|
@@ -6485,16 +6794,16 @@ class ci {
|
|
|
6485
6794
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
6486
6795
|
createdAt: Date.now()
|
|
6487
6796
|
};
|
|
6488
|
-
await this.storage.set(
|
|
6797
|
+
await this.storage.set(se, r);
|
|
6489
6798
|
const n = (t = this.pinStore) == null ? void 0 : t.get();
|
|
6490
|
-
return n && (await this.storage.set(
|
|
6799
|
+
return n && (await this.storage.set(q, n), c.log("[Mock] 지갑 생성 — PIN 저장됨")), r;
|
|
6491
6800
|
} catch (s) {
|
|
6492
6801
|
throw new h(o.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", s);
|
|
6493
6802
|
}
|
|
6494
6803
|
}
|
|
6495
6804
|
/** GET /mnemonic/addresses 모킹 — PIN 불필요, 캐시된 주소 반환 */
|
|
6496
6805
|
async getAddresses(e) {
|
|
6497
|
-
const t = await this.storage.get(
|
|
6806
|
+
const t = await this.storage.get(se);
|
|
6498
6807
|
return t ? [{ address: t.address, index: 0 }] : [];
|
|
6499
6808
|
}
|
|
6500
6809
|
async getAddress(e, t) {
|
|
@@ -6529,8 +6838,8 @@ class ci {
|
|
|
6529
6838
|
var s;
|
|
6530
6839
|
if (c.log("[Mock] verifyPin"), this.pinScenario === "wrong")
|
|
6531
6840
|
return !1;
|
|
6532
|
-
const t = await this.storage.get(
|
|
6533
|
-
return t && t !== e ? !1 : (t || await this.storage.set(
|
|
6841
|
+
const t = await this.storage.get(q);
|
|
6842
|
+
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
6843
|
}
|
|
6535
6844
|
/**
|
|
6536
6845
|
* POST /mnemonic/change-password 모킹
|
|
@@ -6540,10 +6849,10 @@ class ci {
|
|
|
6540
6849
|
var n;
|
|
6541
6850
|
if (c.log("[Mock] changePin"), this.pinScenario === "wrong")
|
|
6542
6851
|
throw new h(o.PIN_WRONG, "Incorrect PIN.");
|
|
6543
|
-
const s = (n = this.pinStore) == null ? void 0 : n.get(), r = await this.storage.get(
|
|
6852
|
+
const s = (n = this.pinStore) == null ? void 0 : n.get(), r = await this.storage.get(q);
|
|
6544
6853
|
if (r && s && r !== s)
|
|
6545
6854
|
throw new h(o.PIN_WRONG, "Incorrect PIN.");
|
|
6546
|
-
await this.storage.set(
|
|
6855
|
+
await this.storage.set(q, t), c.log("[Mock] changePin 완료");
|
|
6547
6856
|
}
|
|
6548
6857
|
async migrateWallet(e, t) {
|
|
6549
6858
|
var n;
|
|
@@ -6574,9 +6883,9 @@ class ci {
|
|
|
6574
6883
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
6575
6884
|
createdAt: Date.now()
|
|
6576
6885
|
};
|
|
6577
|
-
await this.storage.set(
|
|
6886
|
+
await this.storage.set(se, s);
|
|
6578
6887
|
const r = (n = this.pinStore) == null ? void 0 : n.get();
|
|
6579
|
-
return r && (await this.storage.set(
|
|
6888
|
+
return r && (await this.storage.set(q, r), c.log("[Mock] 마이그레이션 — PIN 저장됨")), s;
|
|
6580
6889
|
}
|
|
6581
6890
|
/**
|
|
6582
6891
|
* POST /mnemonic/share-c 모킹
|
|
@@ -6603,7 +6912,7 @@ class ci {
|
|
|
6603
6912
|
).join("");
|
|
6604
6913
|
}
|
|
6605
6914
|
}
|
|
6606
|
-
const
|
|
6915
|
+
const vi = ["password", "newPassword", "recoveryPin"];
|
|
6607
6916
|
class V {
|
|
6608
6917
|
constructor(e, t, s, r, n, a) {
|
|
6609
6918
|
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 +6940,9 @@ class V {
|
|
|
6631
6940
|
*/
|
|
6632
6941
|
async ensureValidToken() {
|
|
6633
6942
|
const e = this.tokenStore.get();
|
|
6634
|
-
if (e && !this.tokenStore.isExpiringSoon(
|
|
6943
|
+
if (e && !this.tokenStore.isExpiringSoon(Qe))
|
|
6635
6944
|
return e;
|
|
6636
|
-
const t = !e || this.tokenStore.isExpiringSoon(
|
|
6945
|
+
const t = !e || this.tokenStore.isExpiringSoon(Qe);
|
|
6637
6946
|
if (this._onTokenRefresh) {
|
|
6638
6947
|
if (await this.deduplicatedRefresh()) {
|
|
6639
6948
|
const r = this.tokenStore.get();
|
|
@@ -6669,7 +6978,7 @@ class V {
|
|
|
6669
6978
|
async sealPinFields(e) {
|
|
6670
6979
|
if (!this.pinEncryptor || !e || typeof e != "object") return e;
|
|
6671
6980
|
let t = null;
|
|
6672
|
-
for (const s of
|
|
6981
|
+
for (const s of vi) {
|
|
6673
6982
|
const r = e[s];
|
|
6674
6983
|
if (typeof r != "string" || r === "") continue;
|
|
6675
6984
|
const n = await this.pinEncryptor.seal(r);
|
|
@@ -6678,7 +6987,7 @@ class V {
|
|
|
6678
6987
|
return t ?? e;
|
|
6679
6988
|
}
|
|
6680
6989
|
async request(e, t, s, r = !1, n = !1) {
|
|
6681
|
-
var u, _, p,
|
|
6990
|
+
var u, _, p, I;
|
|
6682
6991
|
const a = await this.ensureValidToken(), l = `${this.baseUrl}${t}`, d = {
|
|
6683
6992
|
Authorization: `Bearer ${a}`,
|
|
6684
6993
|
"Content-Type": "application/json",
|
|
@@ -6693,36 +7002,36 @@ class V {
|
|
|
6693
7002
|
})).data;
|
|
6694
7003
|
if (w && typeof w.code == "number") {
|
|
6695
7004
|
if (w.code < 0 || w.code >= 400) {
|
|
6696
|
-
const
|
|
7005
|
+
const m = w.message || w.data || "API 요청에 실패했습니다";
|
|
6697
7006
|
c.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
|
|
6698
7007
|
code: w.code,
|
|
6699
|
-
message:
|
|
7008
|
+
message: m,
|
|
6700
7009
|
url: l,
|
|
6701
7010
|
method: e
|
|
6702
7011
|
});
|
|
6703
|
-
const
|
|
6704
|
-
if (
|
|
7012
|
+
const f = V.mapGatewayError(w.code, w.data);
|
|
7013
|
+
if (f === o.PIN_ENCRYPTION_INVALID && this.pinEncryptor && (this.pinEncryptor.requireEncryption(), this.pinEncryptor.invalidate(), !n))
|
|
6705
7014
|
return c.warn("[CROSSx] Gateway -10045 감지 — pin-key 재조회 후 재시도"), this.request(e, t, s, r, !0);
|
|
6706
|
-
if (
|
|
7015
|
+
if (f === o.AUTH_NOT_AUTHENTICATED && !r && this._onTokenRefresh) {
|
|
6707
7016
|
if (c.warn("[CROSSx] Gateway -10002 감지 — 토큰 갱신 후 재시도"), await this.deduplicatedRefresh())
|
|
6708
7017
|
return this.request(e, t, s, !0, n);
|
|
6709
7018
|
throw new h(o.SESSION_EXPIRED, "인증 세션이 만료되었습니다. 다시 로그인해 주세요.");
|
|
6710
7019
|
}
|
|
6711
|
-
if (
|
|
7020
|
+
if (f === o.USER_NOT_FOUND)
|
|
6712
7021
|
throw c.warn("[CROSSx] Gateway -10033 감지 — 유저 미존재, 강제 로그아웃"), (u = this._onUnauthorized) == null || u.call(this), new h(
|
|
6713
7022
|
o.USER_NOT_FOUND,
|
|
6714
|
-
V.getGatewayErrorMessage(w.code,
|
|
7023
|
+
V.getGatewayErrorMessage(w.code, m)
|
|
6715
7024
|
);
|
|
6716
|
-
const
|
|
6717
|
-
let
|
|
6718
|
-
throw
|
|
7025
|
+
const E = f === o.AUTH_NOT_AUTHENTICATED ? o.SESSION_EXPIRED : f, T = E === o.SESSION_EXPIRED ? "인증 세션이 만료되었습니다. 다시 로그인해 주세요." : V.getGatewayErrorMessage(w.code, m), y = w.data;
|
|
7026
|
+
let R;
|
|
7027
|
+
throw f === o.PIN_LOCKED ? R = V.extractLockDetails(y) : f === o.ADDRESS_LIMIT_EXCEEDED ? R = { limit: et, raw: y } : R = y ?? void 0, new h(E, T, R);
|
|
6719
7028
|
}
|
|
6720
7029
|
return c.log("[CROSSx] Wallet Gateway API 성공:", { code: w.code, url: l, method: e }), w.data ?? w;
|
|
6721
7030
|
}
|
|
6722
7031
|
return w;
|
|
6723
|
-
} catch (
|
|
6724
|
-
if (
|
|
6725
|
-
const w = ((_ =
|
|
7032
|
+
} catch (S) {
|
|
7033
|
+
if (S instanceof h) throw S;
|
|
7034
|
+
const w = ((_ = S.response) == null ? void 0 : _.status) ?? S.status;
|
|
6726
7035
|
if ((w === 401 || w === 403) && !r && this._onTokenRefresh) {
|
|
6727
7036
|
if (c.warn(`[CROSSx] HTTP ${w} 감지 — 토큰 갱신 후 재시도`), await this.deduplicatedRefresh())
|
|
6728
7037
|
return this.request(e, t, s, !0, n);
|
|
@@ -6731,20 +7040,20 @@ class V {
|
|
|
6731
7040
|
"인증 세션이 만료되었습니다. 다시 로그인해 주세요."
|
|
6732
7041
|
);
|
|
6733
7042
|
}
|
|
6734
|
-
if ((p =
|
|
6735
|
-
const
|
|
7043
|
+
if ((p = S.response) != null && p.data) {
|
|
7044
|
+
const m = S.response.data, f = m.message || m.data || "API 요청에 실패했습니다", E = m.code || "UNKNOWN";
|
|
6736
7045
|
throw c.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
|
|
6737
|
-
code:
|
|
6738
|
-
message:
|
|
7046
|
+
code: E,
|
|
7047
|
+
message: f,
|
|
6739
7048
|
url: l,
|
|
6740
7049
|
method: e,
|
|
6741
|
-
status: (
|
|
7050
|
+
status: (I = S.response) == null ? void 0 : I.status
|
|
6742
7051
|
}), new h(
|
|
6743
7052
|
o.UNKNOWN_ERROR,
|
|
6744
|
-
`Wallet Gateway 오류 (${
|
|
7053
|
+
`Wallet Gateway 오류 (${E}): ${f}`
|
|
6745
7054
|
);
|
|
6746
7055
|
}
|
|
6747
|
-
throw
|
|
7056
|
+
throw S;
|
|
6748
7057
|
}
|
|
6749
7058
|
}
|
|
6750
7059
|
/**
|
|
@@ -7038,7 +7347,7 @@ class V {
|
|
|
7038
7347
|
return o.ORIGIN_NOT_ALLOWED;
|
|
7039
7348
|
case -10025:
|
|
7040
7349
|
return o.INVALID_APP_TYPE;
|
|
7041
|
-
case
|
|
7350
|
+
case pe:
|
|
7042
7351
|
return o.SDK_VERSION_UNSUPPORTED;
|
|
7043
7352
|
// PIN 관련
|
|
7044
7353
|
case -10028:
|
|
@@ -7107,7 +7416,7 @@ class V {
|
|
|
7107
7416
|
return "Origin or App ID is required. Register the current domain or set X-App-Id header.";
|
|
7108
7417
|
case -10025:
|
|
7109
7418
|
return "Invalid app type. X-App-Type must be android, ios, or windows.";
|
|
7110
|
-
case
|
|
7419
|
+
case pe:
|
|
7111
7420
|
return `This SDK version is no longer supported. Update @nexus-cross/crossx-sdk-core.${t ? ` (${t})` : ""}`;
|
|
7112
7421
|
case -10026:
|
|
7113
7422
|
return "Domain chainId mismatch: the chainId in typedData.domain does not match the request chainId.";
|
|
@@ -7126,7 +7435,7 @@ class V {
|
|
|
7126
7435
|
case -10033:
|
|
7127
7436
|
return "User not found. You have been signed out.";
|
|
7128
7437
|
case -10036:
|
|
7129
|
-
return `Account limit reached. Maximum ${
|
|
7438
|
+
return `Account limit reached. Maximum ${et} accounts allowed.`;
|
|
7130
7439
|
case -10045:
|
|
7131
7440
|
return "Could not securely send your PIN. Please try again.";
|
|
7132
7441
|
case -10046:
|
|
@@ -7140,7 +7449,7 @@ class V {
|
|
|
7140
7449
|
}
|
|
7141
7450
|
}
|
|
7142
7451
|
}
|
|
7143
|
-
class
|
|
7452
|
+
class ki {
|
|
7144
7453
|
constructor(e, t, s, r = () => {
|
|
7145
7454
|
}, n = () => {
|
|
7146
7455
|
}, a = () => {
|
|
@@ -7173,7 +7482,7 @@ class hi {
|
|
|
7173
7482
|
* 넘길 수 있으면 위임을 해제(SDK 상태 정리)하고 true 를 돌려준다.
|
|
7174
7483
|
*/
|
|
7175
7484
|
async recoverFromUnauthorized(e, t, s, r) {
|
|
7176
|
-
return !
|
|
7485
|
+
return !yt(e) || !await this.innerOwnsAddress(t, s) ? !1 : (this.onBridgeUnauthorized(
|
|
7177
7486
|
`native 가 ${r} 을 ERR_BRIDGE_NOT_AUTHORIZED 로 거부 — inner provider 로 폴백`
|
|
7178
7487
|
), !0);
|
|
7179
7488
|
}
|
|
@@ -7197,7 +7506,7 @@ class hi {
|
|
|
7197
7506
|
};
|
|
7198
7507
|
} catch (d) {
|
|
7199
7508
|
if (!await this.recoverFromUnauthorized(d, e, a, "signMessage"))
|
|
7200
|
-
throw
|
|
7509
|
+
throw j(d, o.SIGNATURE_FAILED);
|
|
7201
7510
|
}
|
|
7202
7511
|
}
|
|
7203
7512
|
return this.inner.signMessage(e, t, s, r, n, a);
|
|
@@ -7221,7 +7530,7 @@ class hi {
|
|
|
7221
7530
|
};
|
|
7222
7531
|
} catch (d) {
|
|
7223
7532
|
if (!await this.recoverFromUnauthorized(d, e, a, "signTypedData"))
|
|
7224
|
-
throw
|
|
7533
|
+
throw j(d, o.SIGNATURE_FAILED);
|
|
7225
7534
|
}
|
|
7226
7535
|
}
|
|
7227
7536
|
if (!this.inner.signTypedData)
|
|
@@ -7247,7 +7556,7 @@ class hi {
|
|
|
7247
7556
|
};
|
|
7248
7557
|
} catch (l) {
|
|
7249
7558
|
if (!await this.recoverFromUnauthorized(l, e, s.from, "signTransaction"))
|
|
7250
|
-
throw
|
|
7559
|
+
throw j(l, o.SIGNATURE_FAILED);
|
|
7251
7560
|
}
|
|
7252
7561
|
}
|
|
7253
7562
|
return this.inner.signTransaction(e, t, s, r, n);
|
|
@@ -7265,7 +7574,7 @@ class hi {
|
|
|
7265
7574
|
})).txHash };
|
|
7266
7575
|
} catch (a) {
|
|
7267
7576
|
if (!await this.recoverFromUnauthorized(a, e, s.from, "sendTransaction"))
|
|
7268
|
-
throw
|
|
7577
|
+
throw j(a, o.TRANSACTION_FAILED);
|
|
7269
7578
|
}
|
|
7270
7579
|
}
|
|
7271
7580
|
if (!this.inner.sendTransaction)
|
|
@@ -7303,7 +7612,7 @@ class hi {
|
|
|
7303
7612
|
(s = (t = this.inner).setTokenRefresher) == null || s.call(t, e);
|
|
7304
7613
|
}
|
|
7305
7614
|
}
|
|
7306
|
-
class
|
|
7615
|
+
class ne {
|
|
7307
7616
|
constructor(e, t) {
|
|
7308
7617
|
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
7618
|
}
|
|
@@ -7324,7 +7633,7 @@ class re {
|
|
|
7324
7633
|
const t = e.data.chains;
|
|
7325
7634
|
return this.populateCache(t, !1), t;
|
|
7326
7635
|
} catch {
|
|
7327
|
-
const e =
|
|
7636
|
+
const e = ne.fallbackChains();
|
|
7328
7637
|
return this.populateCache(e, !0), e;
|
|
7329
7638
|
}
|
|
7330
7639
|
}
|
|
@@ -7338,7 +7647,7 @@ class re {
|
|
|
7338
7647
|
}
|
|
7339
7648
|
isCacheValid() {
|
|
7340
7649
|
if (this.loadedAt === 0) return !1;
|
|
7341
|
-
const e = this.usingFallback ?
|
|
7650
|
+
const e = this.usingFallback ? ts : es;
|
|
7342
7651
|
return e === 0 ? !0 : Date.now() - this.loadedAt < e;
|
|
7343
7652
|
}
|
|
7344
7653
|
populateCache(e, t) {
|
|
@@ -7360,13 +7669,13 @@ class re {
|
|
|
7360
7669
|
if (e.code < 0) {
|
|
7361
7670
|
const t = typeof e.data == "string" ? e.data : e.message ?? "체인 레지스트리 요청에 실패했습니다";
|
|
7362
7671
|
throw new h(
|
|
7363
|
-
|
|
7672
|
+
ne.mapErrorCode(e.code),
|
|
7364
7673
|
t
|
|
7365
7674
|
);
|
|
7366
7675
|
}
|
|
7367
7676
|
}
|
|
7368
7677
|
fallbackOrThrow(e) {
|
|
7369
|
-
const t =
|
|
7678
|
+
const t = ne.fallbackChains().find(
|
|
7370
7679
|
(s) => s.chainId === e
|
|
7371
7680
|
);
|
|
7372
7681
|
if (t) return t;
|
|
@@ -7376,7 +7685,7 @@ class re {
|
|
|
7376
7685
|
);
|
|
7377
7686
|
}
|
|
7378
7687
|
static fallbackChains() {
|
|
7379
|
-
return Object.values(
|
|
7688
|
+
return Object.values(Ae).map((e) => ({
|
|
7380
7689
|
chainId: e.caipId,
|
|
7381
7690
|
rpcUrl: e.rpcUrl
|
|
7382
7691
|
}));
|
|
@@ -7395,7 +7704,7 @@ class re {
|
|
|
7395
7704
|
return o.APP_IDENTIFIER_MISSING;
|
|
7396
7705
|
case -10025:
|
|
7397
7706
|
return o.INVALID_APP_TYPE;
|
|
7398
|
-
case
|
|
7707
|
+
case pe:
|
|
7399
7708
|
return o.SDK_VERSION_UNSUPPORTED;
|
|
7400
7709
|
default:
|
|
7401
7710
|
return o.UNKNOWN_ERROR;
|
|
@@ -7410,7 +7719,7 @@ function G(i) {
|
|
|
7410
7719
|
)
|
|
7411
7720
|
);
|
|
7412
7721
|
}
|
|
7413
|
-
class
|
|
7722
|
+
class Ui {
|
|
7414
7723
|
// ─── 사용자 입력이 필요한 화면 → UI_NOT_PROVIDED ───
|
|
7415
7724
|
requestConfirmation(e) {
|
|
7416
7725
|
return G("requestConfirmation");
|
|
@@ -7459,7 +7768,7 @@ class di {
|
|
|
7459
7768
|
setPinKeyboard() {
|
|
7460
7769
|
}
|
|
7461
7770
|
}
|
|
7462
|
-
class
|
|
7771
|
+
class bi {
|
|
7463
7772
|
constructor(e, t, s, r = () => !1) {
|
|
7464
7773
|
this.browserConfirmation = e, this.getBridge = t, this.getOrigin = s, this.isAuthenticatedViaRNBridge = r;
|
|
7465
7774
|
}
|
|
@@ -7632,7 +7941,7 @@ class ui {
|
|
|
7632
7941
|
(s = (t = this.browserConfirmation).setPinKeyboard) == null || s.call(t, e);
|
|
7633
7942
|
}
|
|
7634
7943
|
}
|
|
7635
|
-
class
|
|
7944
|
+
class Li {
|
|
7636
7945
|
constructor() {
|
|
7637
7946
|
this._accessToken = null, this._expiresAt = 0;
|
|
7638
7947
|
}
|
|
@@ -7664,38 +7973,46 @@ class gi {
|
|
|
7664
7973
|
return !this._accessToken || this._expiresAt <= 0 ? !0 : Date.now() >= this._expiresAt - e;
|
|
7665
7974
|
}
|
|
7666
7975
|
}
|
|
7667
|
-
const
|
|
7668
|
-
function
|
|
7669
|
-
|
|
7976
|
+
const Ht = /* @__PURE__ */ new WeakMap();
|
|
7977
|
+
function Wi(i, e) {
|
|
7978
|
+
Ht.set(i, e);
|
|
7670
7979
|
}
|
|
7671
|
-
function
|
|
7672
|
-
const e =
|
|
7980
|
+
function zi(i) {
|
|
7981
|
+
const e = Ht.get(i);
|
|
7673
7982
|
if (!e)
|
|
7674
7983
|
throw new Error(
|
|
7675
7984
|
"[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
7985
|
);
|
|
7677
7986
|
return e;
|
|
7678
7987
|
}
|
|
7679
|
-
|
|
7680
|
-
|
|
7988
|
+
const Kt = /* @__PURE__ */ new WeakMap();
|
|
7989
|
+
function Mi(i, e) {
|
|
7990
|
+
Kt.set(i, e);
|
|
7681
7991
|
}
|
|
7682
|
-
function
|
|
7683
|
-
|
|
7992
|
+
function Ji(i, e) {
|
|
7993
|
+
const t = Kt.get(i);
|
|
7994
|
+
return t ? t(e) : Promise.reject(new Error("[CROSSx] reloadOneIdSession: create the SDK with the core factory"));
|
|
7684
7995
|
}
|
|
7685
|
-
function
|
|
7686
|
-
|
|
7996
|
+
function Fi(i) {
|
|
7997
|
+
return Vt(i);
|
|
7998
|
+
}
|
|
7999
|
+
function Xi(i, e) {
|
|
8000
|
+
return Vt(i, e);
|
|
8001
|
+
}
|
|
8002
|
+
function Vt(i, e) {
|
|
8003
|
+
var U;
|
|
7687
8004
|
if (!i.projectId)
|
|
7688
8005
|
throw new Error(
|
|
7689
8006
|
`[CROSSx] Fatal: projectId is required but was not provided.
|
|
7690
8007
|
Set the projectId field in SDKConfig when calling createCROSSxSDK().
|
|
7691
8008
|
Example: createCROSSxSDK({ projectId: "your-project-id", ... })`
|
|
7692
8009
|
);
|
|
7693
|
-
if (i.walletServer === "one-wallet" && !((
|
|
8010
|
+
if (i.walletServer === "one-wallet" && !((U = i.oneId) != null && U.clientId))
|
|
7694
8011
|
throw new Error(
|
|
7695
8012
|
"[CROSSx] Fatal: walletServer 'one-wallet' requires SDKConfig.oneId (ONE ID login) — DEV2TF-2755"
|
|
7696
8013
|
);
|
|
7697
8014
|
i.debug;
|
|
7698
|
-
const t =
|
|
8015
|
+
const t = X.production, s = {
|
|
7699
8016
|
...i,
|
|
7700
8017
|
oauthServiceUrl: t.oauthServiceUrl,
|
|
7701
8018
|
legacyOauthServiceUrl: t.legacyOauthServiceUrl,
|
|
@@ -7706,124 +8023,132 @@ Example: createCROSSxSDK({ projectId: "your-project-id", ... })`
|
|
|
7706
8023
|
}, r = {
|
|
7707
8024
|
gatewayUrl: t.walletGatewayUrl,
|
|
7708
8025
|
projectId: i.projectId
|
|
7709
|
-
}, n = s.authMode !== "cookie" &&
|
|
8026
|
+
}, n = s.authMode !== "cookie" && St.isAvailable();
|
|
7710
8027
|
!n && s.authMode !== "cookie" && c.warn(
|
|
7711
8028
|
"[CROSSx] IndexedDB 사용 불가 — LocalStorage fallback 사용 중.",
|
|
7712
8029
|
"refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
|
|
7713
8030
|
"IndexedDB를 지원하는 브라우저 사용을 권장합니다."
|
|
7714
8031
|
), s.secureStorageAvailable = n;
|
|
7715
|
-
const a = n ? new
|
|
8032
|
+
const a = n ? new St(i.projectId) : new si(), l = new ni();
|
|
7716
8033
|
let d = null;
|
|
7717
|
-
const g = new
|
|
7718
|
-
version:
|
|
7719
|
-
sendVersionHeader:
|
|
8034
|
+
const g = new Ei(new wi(), {
|
|
8035
|
+
version: _e,
|
|
8036
|
+
sendVersionHeader: is,
|
|
7720
8037
|
getGatewayBaseUrls: () => [r.gatewayUrl],
|
|
7721
|
-
onDeprecation: (
|
|
7722
|
-
onUnsupported: (
|
|
7723
|
-
}), u = new
|
|
7724
|
-
let
|
|
7725
|
-
i.useMockWallet ? (c.log("[CROSSx] Mock Wallet Provider 사용"),
|
|
7726
|
-
baseUrl: () =>
|
|
8038
|
+
onDeprecation: (A) => d == null ? void 0 : d.handleSdkVersionDeprecation(A),
|
|
8039
|
+
onUnsupported: (A) => d == null ? void 0 : d.handleSdkVersionUnsupported(A)
|
|
8040
|
+
}), u = new K(), _ = new Li(), p = e == null ? void 0 : e.pinReuse, I = new Ot({ ttlMs: (p == null ? void 0 : p.mode) === "memory" ? p.ttlMs : void 0 }), S = new ci(r, g);
|
|
8041
|
+
let w;
|
|
8042
|
+
i.useMockWallet ? (c.log("[CROSSx] Mock Wallet Provider 사용"), w = new xi(a, I)) : i.walletServer === "one-wallet" ? (c.log("[CROSSx] one-wallet-api Wallet Provider 사용"), w = new Me({
|
|
8043
|
+
baseUrl: () => Se().oneWalletApiUrl,
|
|
7727
8044
|
transport: g,
|
|
7728
|
-
pinStore:
|
|
8045
|
+
pinStore: I,
|
|
7729
8046
|
getAccessToken: () => d ? d.getOneIdAccessToken() : Promise.reject(new h(o.AUTH_NOT_INITIALIZED, "SDK가 아직 만들어지지 않았습니다"))
|
|
7730
|
-
})) : (c.log("[CROSSx] Remote Wallet Provider 사용"),
|
|
8047
|
+
})) : (c.log("[CROSSx] Remote Wallet Provider 사용"), w = new V(
|
|
7731
8048
|
r,
|
|
7732
8049
|
a,
|
|
7733
8050
|
g,
|
|
7734
8051
|
_,
|
|
7735
|
-
|
|
7736
|
-
|
|
8052
|
+
I,
|
|
8053
|
+
S
|
|
7737
8054
|
));
|
|
7738
|
-
const
|
|
7739
|
-
var
|
|
7740
|
-
return ((
|
|
8055
|
+
const m = () => {
|
|
8056
|
+
var A;
|
|
8057
|
+
return ((A = d == null ? void 0 : d.isAuthenticatedViaRNBridge) == null ? void 0 : A.call(d)) ?? !1;
|
|
7741
8058
|
}, f = () => {
|
|
7742
|
-
var
|
|
7743
|
-
return (
|
|
7744
|
-
},
|
|
7745
|
-
var
|
|
7746
|
-
(
|
|
8059
|
+
var A;
|
|
8060
|
+
return (A = d == null ? void 0 : d.assertRNBridgeSessionActive) == null ? void 0 : A.call(d);
|
|
8061
|
+
}, E = (A) => {
|
|
8062
|
+
var Q;
|
|
8063
|
+
(Q = d == null ? void 0 : d.clearRNBridgeDelegation) == null || Q.call(d, A);
|
|
7747
8064
|
};
|
|
7748
|
-
i.walletServer !== "one-wallet" && (
|
|
7749
|
-
|
|
8065
|
+
i.walletServer !== "one-wallet" && (w = new ki(
|
|
8066
|
+
w,
|
|
7750
8067
|
() => {
|
|
7751
|
-
var
|
|
7752
|
-
return (
|
|
8068
|
+
var A;
|
|
8069
|
+
return (A = d == null ? void 0 : d.getRNBridge) == null ? void 0 : A.call(d);
|
|
7753
8070
|
},
|
|
7754
|
-
|
|
8071
|
+
m,
|
|
7755
8072
|
f,
|
|
7756
8073
|
() => i.appName,
|
|
7757
|
-
|
|
8074
|
+
E
|
|
7758
8075
|
));
|
|
7759
|
-
const
|
|
8076
|
+
const T = new ne(r, g), y = Se(), R = e != null && e.ui ? e.ui({
|
|
7760
8077
|
theme: i.theme ?? "light",
|
|
7761
8078
|
themeTokens: i.themeTokens,
|
|
7762
8079
|
displayDecimals: i.displayDecimals,
|
|
7763
8080
|
pinKeyboard: i.pinKeyboard,
|
|
7764
8081
|
endpoints: {
|
|
7765
|
-
contentsBaseUrl:
|
|
7766
|
-
portraitBaseUrl:
|
|
8082
|
+
contentsBaseUrl: y.contentsBaseUrl,
|
|
8083
|
+
portraitBaseUrl: y.portraitBaseUrl
|
|
7767
8084
|
}
|
|
7768
|
-
}) : new
|
|
7769
|
-
|
|
8085
|
+
}) : new Ui(), N = new bi(
|
|
8086
|
+
R,
|
|
7770
8087
|
() => {
|
|
7771
|
-
var
|
|
7772
|
-
return (
|
|
8088
|
+
var A;
|
|
8089
|
+
return (A = d == null ? void 0 : d.getRNBridge) == null ? void 0 : A.call(d);
|
|
7773
8090
|
},
|
|
7774
8091
|
() => typeof window < "u" ? window.location.origin : "http://localhost",
|
|
7775
|
-
|
|
7776
|
-
),
|
|
8092
|
+
m
|
|
8093
|
+
), O = e != null && e.wrapConfirmation ? e.wrapConfirmation(N) : N, P = new Fe(
|
|
7777
8094
|
s,
|
|
7778
8095
|
r,
|
|
7779
8096
|
a,
|
|
7780
8097
|
l,
|
|
7781
8098
|
g,
|
|
7782
8099
|
u,
|
|
7783
|
-
|
|
8100
|
+
w,
|
|
7784
8101
|
_,
|
|
7785
|
-
|
|
8102
|
+
O,
|
|
8103
|
+
T,
|
|
7786
8104
|
I,
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
8105
|
+
S,
|
|
8106
|
+
new Hs(),
|
|
8107
|
+
e == null ? void 0 : e.oneIdSessions
|
|
7790
8108
|
);
|
|
7791
|
-
d =
|
|
8109
|
+
d = P, Wi(P, {
|
|
7792
8110
|
transport: g,
|
|
7793
8111
|
storage: a,
|
|
7794
|
-
walletProvider:
|
|
7795
|
-
confirmation:
|
|
8112
|
+
walletProvider: w,
|
|
8113
|
+
confirmation: O,
|
|
7796
8114
|
tokenStore: _,
|
|
7797
|
-
pinStore:
|
|
8115
|
+
pinStore: I,
|
|
7798
8116
|
adapterConfig: r,
|
|
7799
|
-
pinEncryptor:
|
|
7800
|
-
});
|
|
7801
|
-
const
|
|
7802
|
-
return
|
|
8117
|
+
pinEncryptor: S
|
|
8118
|
+
}), Mi(P, (A) => P.reloadOneIdSession(A));
|
|
8119
|
+
const D = P.signInUseCase;
|
|
8120
|
+
return D && typeof D.setFreshTokenCallback == "function" && D.setFreshTokenCallback(() => P.requestFreshFirebaseIdTokenFromBridge()), typeof window < "u" && (window.__crossxSDK = P), P;
|
|
7803
8121
|
}
|
|
7804
|
-
const
|
|
8122
|
+
const Zi = Fi;
|
|
7805
8123
|
export {
|
|
7806
|
-
|
|
7807
|
-
|
|
8124
|
+
cs as C,
|
|
8125
|
+
Yi as D,
|
|
7808
8126
|
o as E,
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
8127
|
+
Nt as M,
|
|
8128
|
+
Ce as O,
|
|
8129
|
+
Ot as P,
|
|
8130
|
+
Li as T,
|
|
8131
|
+
Tt as W,
|
|
8132
|
+
$s as a,
|
|
8133
|
+
h as b,
|
|
8134
|
+
Xi as c,
|
|
8135
|
+
be as d,
|
|
8136
|
+
ps as e,
|
|
8137
|
+
Fe as f,
|
|
8138
|
+
zi as g,
|
|
8139
|
+
$i as h,
|
|
8140
|
+
he as i,
|
|
8141
|
+
as as j,
|
|
8142
|
+
ws as k,
|
|
8143
|
+
et as l,
|
|
8144
|
+
bs as m,
|
|
8145
|
+
z as n,
|
|
8146
|
+
mt as o,
|
|
8147
|
+
Fi as p,
|
|
8148
|
+
Zi as q,
|
|
8149
|
+
Ji as r,
|
|
8150
|
+
Vi as s,
|
|
8151
|
+
Ee as t,
|
|
8152
|
+
qi as u,
|
|
8153
|
+
ji as w
|
|
7829
8154
|
};
|