@nexus-cross/crossx-sdk-core 1.2.1 → 1.2.4-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts.map +1 -1
- package/dist/adapters/oauth/BrowserOAuthAdapter.d.ts.map +1 -1
- package/dist/adapters/wallet/RemoteWalletProviderAdapter.d.ts.map +1 -1
- package/dist/adapters/wallet/types.d.ts +0 -2
- package/dist/adapters/wallet/types.d.ts.map +1 -1
- package/dist/core/types/index.d.ts +13 -4
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/crossx.global +46 -33
- package/dist/index.cjs +45 -32
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +241 -247
- package/dist/sdk/CROSSxSDK.d.ts +1 -1
- package/dist/sdk/factory.d.ts +11 -1
- package/dist/sdk/factory.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -167,26 +167,26 @@ class $s {
|
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
let
|
|
170
|
+
let ye = null;
|
|
171
171
|
function vt(r) {
|
|
172
|
-
|
|
172
|
+
ye = r;
|
|
173
173
|
}
|
|
174
174
|
const u = {
|
|
175
175
|
log(...r) {
|
|
176
|
-
if (
|
|
177
|
-
|
|
176
|
+
if (ye) {
|
|
177
|
+
ye.log(...r);
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
180
180
|
},
|
|
181
181
|
warn(...r) {
|
|
182
|
-
if (
|
|
183
|
-
|
|
182
|
+
if (ye) {
|
|
183
|
+
ye.warn(...r);
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
error(...r) {
|
|
188
|
-
if (
|
|
189
|
-
|
|
188
|
+
if (ye) {
|
|
189
|
+
ye.error(...r);
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -327,7 +327,7 @@ const u = {
|
|
|
327
327
|
function St(r = "en", e) {
|
|
328
328
|
return Us[r] ?? Zt;
|
|
329
329
|
}
|
|
330
|
-
const $e = "crossx_access_token",
|
|
330
|
+
const $e = "crossx_access_token", Ne = "crossx_refresh_token", Re = "crossx_user_info";
|
|
331
331
|
class Hs {
|
|
332
332
|
constructor(e, s, t, n, o, i, a) {
|
|
333
333
|
this.config = e, this.storage = s, this.crypto = t, this.oauth = n, this.transport = o, this.walletProvider = i, this.tokenStore = a, this._refreshPromise = null;
|
|
@@ -375,24 +375,24 @@ class Hs {
|
|
|
375
375
|
try {
|
|
376
376
|
const B = this.crypto.decodeJWT(x);
|
|
377
377
|
S = (n = B.firebase) == null ? void 0 : n.sign_in_provider;
|
|
378
|
-
const
|
|
379
|
-
S === "google.com" ? y = (i =
|
|
378
|
+
const b = ((o = B.firebase) == null ? void 0 : o.identities) ?? {};
|
|
379
|
+
S === "google.com" ? y = (i = b["google.com"]) == null ? void 0 : i[0] : S === "apple.com" && (y = (a = b["apple.com"]) == null ? void 0 : a[0]), u.log("[CROSSx] OAuth provider sub 추출 — provider:", S, "hasProviderSub:", !!y);
|
|
380
380
|
} catch {
|
|
381
381
|
u.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
|
|
382
382
|
}
|
|
383
383
|
if (w) {
|
|
384
384
|
const B = this.crypto.decodeJWT(w);
|
|
385
385
|
u.log("[CROSSx] access_token 디코딩 — sub:", B.sub, "exp:", B.exp);
|
|
386
|
-
const
|
|
387
|
-
if (t =
|
|
386
|
+
const b = await this.crypto.verifyJWT(w);
|
|
387
|
+
if (t = b.signatureVerified ?? !1, !b.valid)
|
|
388
388
|
throw u.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
|
|
389
|
-
const P =
|
|
389
|
+
const P = b.payload;
|
|
390
390
|
s = {
|
|
391
391
|
id: P.sub,
|
|
392
392
|
email: P.email,
|
|
393
393
|
signInProvider: S,
|
|
394
394
|
providerSub: y
|
|
395
|
-
}, this.tokenStore.set(w), this.useCookieAuth || (await this.storage.set($e, w), E && await this.storage.set(
|
|
395
|
+
}, this.tokenStore.set(w), this.useCookieAuth || (await this.storage.set($e, w), E && await this.storage.set(Ne, E));
|
|
396
396
|
} else {
|
|
397
397
|
const B = this.crypto.decodeJWT(x);
|
|
398
398
|
s = {
|
|
@@ -404,7 +404,7 @@ class Hs {
|
|
|
404
404
|
}
|
|
405
405
|
u.log("[CROSSx] 사용자 정보 — id:", s.id);
|
|
406
406
|
const O = this.useCookieAuth ? { id: s.id, signInProvider: s.signInProvider, providerSub: s.providerSub } : s;
|
|
407
|
-
await this.storage.set(
|
|
407
|
+
await this.storage.set(Re, O), u.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
|
|
408
408
|
} catch (c) {
|
|
409
409
|
return u.error("[CROSSx] SignIn 에러 (OAuth/토큰 교환 단계):", c), {
|
|
410
410
|
success: !1,
|
|
@@ -499,7 +499,7 @@ class Hs {
|
|
|
499
499
|
if (e) {
|
|
500
500
|
const t = await this.crypto.verifyJWT(e);
|
|
501
501
|
if (t.valid) {
|
|
502
|
-
const n = await this.storage.get(
|
|
502
|
+
const n = await this.storage.get(Re);
|
|
503
503
|
if (n)
|
|
504
504
|
return u.log("[CROSSx] restoreSession — 메모리 토큰 유효, 세션 복원"), this.loadWallet(n, t.signatureVerified);
|
|
505
505
|
}
|
|
@@ -510,7 +510,7 @@ class Hs {
|
|
|
510
510
|
const t = await this.silentRefresh();
|
|
511
511
|
t && this.tokenStore.set(t);
|
|
512
512
|
} else {
|
|
513
|
-
const t = await this.storage.get($e), n = await this.storage.get(
|
|
513
|
+
const t = await this.storage.get($e), n = await this.storage.get(Ne);
|
|
514
514
|
if (u.log(
|
|
515
515
|
"[CROSSx] restoreSession — access_token:",
|
|
516
516
|
t ? "있음" : "없음",
|
|
@@ -522,7 +522,7 @@ class Hs {
|
|
|
522
522
|
const o = await this.silentRefresh(n);
|
|
523
523
|
u.log("[CROSSx] restoreSession — silentRefresh 결과:", o ? "토큰 발급 성공" : "토큰 없음"), o && this.tokenStore.set(o);
|
|
524
524
|
}
|
|
525
|
-
const s = await this.storage.get(
|
|
525
|
+
const s = await this.storage.get(Re);
|
|
526
526
|
if (u.log("[CROSSx] restoreSession — userInfo 조회:", s ? `있음 (id: ${s.id})` : "없음"), !s)
|
|
527
527
|
return null;
|
|
528
528
|
u.log("[CROSSx] restoreSession — silentRefresh 성공, 세션 복원 — userId:", s.id);
|
|
@@ -532,7 +532,7 @@ class Hs {
|
|
|
532
532
|
return u.warn("[CROSSx] restoreSession — 지갑 로드 실패 (세션은 유지):", t), { success: !0, user: s, tokenSignatureVerified: !1 };
|
|
533
533
|
}
|
|
534
534
|
} catch (e) {
|
|
535
|
-
return u.log("[CROSSx] restoreSession — 세션 복원 실패, 스토리지 정리:", e), this.tokenStore.clear(), this.useCookieAuth || await this.storage.remove(
|
|
535
|
+
return u.log("[CROSSx] restoreSession — 세션 복원 실패, 스토리지 정리:", e), this.tokenStore.clear(), this.useCookieAuth || await this.storage.remove(Ne), await this.storage.remove(Re), null;
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
538
|
/**
|
|
@@ -571,7 +571,7 @@ class Hs {
|
|
|
571
571
|
if (this.tokenStore.set(c), !t) {
|
|
572
572
|
await this.storage.set($e, c);
|
|
573
573
|
const l = this.extractRefreshToken(a);
|
|
574
|
-
l && await this.storage.set(
|
|
574
|
+
l && await this.storage.set(Ne, l);
|
|
575
575
|
}
|
|
576
576
|
return u.log("[CROSSx] silentRefresh 성공"), c;
|
|
577
577
|
}
|
|
@@ -603,7 +603,7 @@ class Hs {
|
|
|
603
603
|
u.log("[CROSSx] signInWithJWT — sub:", i.sub, "signatureVerified:", n), t = {
|
|
604
604
|
id: i.sub,
|
|
605
605
|
email: i.email
|
|
606
|
-
}, this.tokenStore.set(e), this.useCookieAuth || (await this.storage.set($e, e), s && await this.storage.set(
|
|
606
|
+
}, this.tokenStore.set(e), this.useCookieAuth || (await this.storage.set($e, e), s && await this.storage.set(Ne, s)), await this.storage.set(Re, t), u.log("[CROSSx] signInWithJWT — 토큰 및 사용자 정보 저장 완료");
|
|
607
607
|
} catch (o) {
|
|
608
608
|
return u.error("[CROSSx] signInWithJWT 에러:", o), {
|
|
609
609
|
success: !1,
|
|
@@ -836,7 +836,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
836
836
|
}), this._initPromise);
|
|
837
837
|
}
|
|
838
838
|
async _doInitialize(e) {
|
|
839
|
-
console.log("[CROSSx SDK] v1.2.
|
|
839
|
+
console.log("[CROSSx SDK] v1.2.4 초기화 중..."), this.confirmation.setMessages(St(this._config.locale));
|
|
840
840
|
try {
|
|
841
841
|
const s = Ys();
|
|
842
842
|
this.internalConfig.oauthServiceUrl = s.oauthServiceUrl, this.internalConfig.authApiUrl = s.authApiUrl, this.internalConfig.walletGatewayUrl = s.walletGatewayUrl, this.adapterConfig.gatewayUrl = s.walletGatewayUrl;
|
|
@@ -1023,7 +1023,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1023
1023
|
* create 시 -10012 에러(기존 백업 발견)가 발생하면 자동으로 호출됩니다.
|
|
1024
1024
|
*
|
|
1025
1025
|
* @param pin 4자리 PIN (클라우드 백업 복호화용)
|
|
1026
|
-
* @returns 마이그레이션 결과 (address
|
|
1026
|
+
* @returns 마이그레이션 결과 (address)
|
|
1027
1027
|
*/
|
|
1028
1028
|
async migrateWallet(e) {
|
|
1029
1029
|
if (this.ensureAuthenticated(), !this.userId)
|
|
@@ -1282,7 +1282,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1282
1282
|
chainId: e,
|
|
1283
1283
|
from: n.address,
|
|
1284
1284
|
message: s,
|
|
1285
|
-
dappName: t == null ? void 0 : t.dappName,
|
|
1285
|
+
dappName: (t == null ? void 0 : t.dappName) ?? this._config.appName,
|
|
1286
1286
|
accountName: t == null ? void 0 : t.accountName
|
|
1287
1287
|
}))
|
|
1288
1288
|
throw new g(p.USER_REJECTED, "사용자가 메시지 서명을 거부했습니다");
|
|
@@ -1341,7 +1341,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1341
1341
|
chainId: e,
|
|
1342
1342
|
from: n.address,
|
|
1343
1343
|
typedData: s,
|
|
1344
|
-
dappName: t == null ? void 0 : t.dappName,
|
|
1344
|
+
dappName: (t == null ? void 0 : t.dappName) ?? this._config.appName,
|
|
1345
1345
|
accountName: t == null ? void 0 : t.accountName
|
|
1346
1346
|
}))
|
|
1347
1347
|
throw new g(p.USER_REJECTED, "사용자가 타입 데이터 서명을 거부했습니다");
|
|
@@ -1416,7 +1416,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1416
1416
|
maxPriorityFeePerGas: n.maxPriorityFeePerGas,
|
|
1417
1417
|
nativeSymbol: o.symbol,
|
|
1418
1418
|
nativeDecimals: o.decimals,
|
|
1419
|
-
dappName: t == null ? void 0 : t.dappName,
|
|
1419
|
+
dappName: (t == null ? void 0 : t.dappName) ?? this._config.appName,
|
|
1420
1420
|
accountName: t == null ? void 0 : t.accountName
|
|
1421
1421
|
}))
|
|
1422
1422
|
throw new g(p.USER_REJECTED, "사용자가 트랜잭션 서명을 거부했습니다");
|
|
@@ -1471,7 +1471,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1471
1471
|
maxPriorityFeePerGas: n.maxPriorityFeePerGas,
|
|
1472
1472
|
nativeSymbol: o.symbol,
|
|
1473
1473
|
nativeDecimals: o.decimals,
|
|
1474
|
-
dappName: t == null ? void 0 : t.dappName,
|
|
1474
|
+
dappName: (t == null ? void 0 : t.dappName) ?? this._config.appName,
|
|
1475
1475
|
accountName: t == null ? void 0 : t.accountName
|
|
1476
1476
|
}))
|
|
1477
1477
|
throw new g(p.USER_REJECTED, "사용자가 트랜잭션을 거부했습니다");
|
|
@@ -1557,13 +1557,13 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1557
1557
|
let m, x;
|
|
1558
1558
|
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((S) => {
|
|
1559
1559
|
m = S;
|
|
1560
|
-
const O = BigInt(S.gasUsed) * BigInt(S.effectiveGasPrice), B = s.value ? BigInt(s.value) : 0n,
|
|
1560
|
+
const O = BigInt(S.gasUsed) * BigInt(S.effectiveGasPrice), B = s.value ? BigInt(s.value) : 0n, b = re.formatTxAmount(s.value, d.symbol, d.decimals), P = re.formatTxAmount("0x" + O.toString(16), d.symbol, d.decimals), N = re.formatTxAmount("0x" + (B + O).toString(16), d.symbol, d.decimals);
|
|
1561
1561
|
return {
|
|
1562
1562
|
chainId: e,
|
|
1563
1563
|
txHash: a,
|
|
1564
1564
|
from: S.from,
|
|
1565
1565
|
to: S.to ?? s.to,
|
|
1566
|
-
amount:
|
|
1566
|
+
amount: b,
|
|
1567
1567
|
fees: P,
|
|
1568
1568
|
total: N,
|
|
1569
1569
|
nativeSymbol: d.symbol,
|
|
@@ -1855,7 +1855,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1855
1855
|
});
|
|
1856
1856
|
if (l === null)
|
|
1857
1857
|
return u.log("[CROSSx][Migration Phase 4] 사용자가 PIN 입력을 취소함 → 종료"), null;
|
|
1858
|
-
u.log(
|
|
1858
|
+
u.log("[CROSSx][Migration Phase 4] PIN 입력 완료 — verify-recovery-pin API 호출"), t = void 0;
|
|
1859
1859
|
try {
|
|
1860
1860
|
const d = await ((c = (a = this.walletProvider).verifyRecoveryPin) == null ? void 0 : c.call(a, l, e));
|
|
1861
1861
|
if (!d) {
|
|
@@ -2293,7 +2293,7 @@ class sr {
|
|
|
2293
2293
|
}
|
|
2294
2294
|
}
|
|
2295
2295
|
const rr = "crossx-sdk", nr = 1, Ie = "data", Be = "keys", Pt = "aes-primary", or = 12;
|
|
2296
|
-
class
|
|
2296
|
+
class Nt {
|
|
2297
2297
|
constructor() {
|
|
2298
2298
|
this.db = null, this.cryptoKey = null, this.initPromise = null;
|
|
2299
2299
|
}
|
|
@@ -2462,7 +2462,7 @@ function lr(r) {
|
|
|
2462
2462
|
r[e] = cr(r[e]);
|
|
2463
2463
|
return r;
|
|
2464
2464
|
}
|
|
2465
|
-
const
|
|
2465
|
+
const Rt = ar ? (r) => r : lr, ts = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", dr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
|
|
2466
2466
|
function Me(r) {
|
|
2467
2467
|
if (z(r), ts)
|
|
2468
2468
|
return r.toHex();
|
|
@@ -2499,7 +2499,7 @@ function qe(r) {
|
|
|
2499
2499
|
}
|
|
2500
2500
|
return t;
|
|
2501
2501
|
}
|
|
2502
|
-
function
|
|
2502
|
+
function we(...r) {
|
|
2503
2503
|
let e = 0;
|
|
2504
2504
|
for (let t = 0; t < r.length; t++) {
|
|
2505
2505
|
const n = r[t];
|
|
@@ -2800,7 +2800,7 @@ function Pr(r, e, s) {
|
|
|
2800
2800
|
let c = t(r), l = t(r), d = 0;
|
|
2801
2801
|
const h = () => {
|
|
2802
2802
|
c.fill(1), l.fill(0), d = 0;
|
|
2803
|
-
}, m = (...y) => s(l,
|
|
2803
|
+
}, m = (...y) => s(l, we(c, ...y)), x = (y = n) => {
|
|
2804
2804
|
l = m(o, y), c = m(), y.length !== 0 && (l = m(i, y), c = m());
|
|
2805
2805
|
}, w = () => {
|
|
2806
2806
|
if (d++ >= a)
|
|
@@ -2812,7 +2812,7 @@ function Pr(r, e, s) {
|
|
|
2812
2812
|
const O = c.slice();
|
|
2813
2813
|
S.push(O), y += c.length;
|
|
2814
2814
|
}
|
|
2815
|
-
return
|
|
2815
|
+
return we(...S);
|
|
2816
2816
|
};
|
|
2817
2817
|
return (y, S) => {
|
|
2818
2818
|
h(), x(y);
|
|
@@ -2847,7 +2847,7 @@ function Lt(r) {
|
|
|
2847
2847
|
};
|
|
2848
2848
|
}
|
|
2849
2849
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2850
|
-
const ne = /* @__PURE__ */ BigInt(0), ee = /* @__PURE__ */ BigInt(1), ve = /* @__PURE__ */ BigInt(2), cs = /* @__PURE__ */ BigInt(3), ls = /* @__PURE__ */ BigInt(4), ds = /* @__PURE__ */ BigInt(5),
|
|
2850
|
+
const ne = /* @__PURE__ */ BigInt(0), ee = /* @__PURE__ */ BigInt(1), ve = /* @__PURE__ */ BigInt(2), cs = /* @__PURE__ */ BigInt(3), ls = /* @__PURE__ */ BigInt(4), ds = /* @__PURE__ */ BigInt(5), Nr = /* @__PURE__ */ BigInt(7), us = /* @__PURE__ */ BigInt(8), Rr = /* @__PURE__ */ BigInt(9), hs = /* @__PURE__ */ BigInt(16);
|
|
2851
2851
|
function le(r, e) {
|
|
2852
2852
|
const s = r % e;
|
|
2853
2853
|
return s >= ne ? s : e + s;
|
|
@@ -2885,7 +2885,7 @@ function Cr(r, e) {
|
|
|
2885
2885
|
return xt(r, a, e), a;
|
|
2886
2886
|
}
|
|
2887
2887
|
function Or(r) {
|
|
2888
|
-
const e = Ye(r), s = fs(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r +
|
|
2888
|
+
const e = Ye(r), s = fs(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + Nr) / hs;
|
|
2889
2889
|
return (a, c) => {
|
|
2890
2890
|
let l = a.pow(c, i), d = a.mul(l, t);
|
|
2891
2891
|
const h = a.mul(l, n), m = a.mul(l, o), x = a.eql(a.sqr(d), c), w = a.eql(a.sqr(h), c);
|
|
@@ -2929,7 +2929,7 @@ function fs(r) {
|
|
|
2929
2929
|
};
|
|
2930
2930
|
}
|
|
2931
2931
|
function Lr(r) {
|
|
2932
|
-
return r % ls === cs ? ps : r % us === ds ? Cr : r % hs ===
|
|
2932
|
+
return r % ls === cs ? ps : r % us === ds ? Cr : r % hs === Rr ? Or(r) : fs(r);
|
|
2933
2933
|
}
|
|
2934
2934
|
const Dr = [
|
|
2935
2935
|
"create",
|
|
@@ -3461,18 +3461,18 @@ function jr(r, e = {}) {
|
|
|
3461
3461
|
throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
3462
3462
|
}
|
|
3463
3463
|
function h(R, f, _) {
|
|
3464
|
-
const { x:
|
|
3464
|
+
const { x: v, y: A } = f.toAffine(), L = t.toBytes(v);
|
|
3465
3465
|
if (Ve(_, "isCompressed"), _) {
|
|
3466
3466
|
d();
|
|
3467
3467
|
const C = !t.isOdd(A);
|
|
3468
|
-
return
|
|
3468
|
+
return we(Ss(C), L);
|
|
3469
3469
|
} else
|
|
3470
|
-
return
|
|
3470
|
+
return we(Uint8Array.of(4), L, t.toBytes(A));
|
|
3471
3471
|
}
|
|
3472
3472
|
function m(R) {
|
|
3473
3473
|
z(R, void 0, "Point");
|
|
3474
|
-
const { publicKey: f, publicKeyUncompressed: _ } = l,
|
|
3475
|
-
if (
|
|
3474
|
+
const { publicKey: f, publicKeyUncompressed: _ } = l, v = R.length, A = R[0], L = R.subarray(1);
|
|
3475
|
+
if (v === f && (A === 2 || A === 3)) {
|
|
3476
3476
|
const C = t.fromBytes(L);
|
|
3477
3477
|
if (!t.isValid(C))
|
|
3478
3478
|
throw new Error("bad point: is not on curve, wrong x");
|
|
@@ -3487,13 +3487,13 @@ function jr(r, e = {}) {
|
|
|
3487
3487
|
d();
|
|
3488
3488
|
const $ = t.isOdd(T);
|
|
3489
3489
|
return (A & 1) === 1 !== $ && (T = t.neg(T)), { x: C, y: T };
|
|
3490
|
-
} else if (
|
|
3490
|
+
} else if (v === _ && A === 4) {
|
|
3491
3491
|
const C = t.BYTES, M = t.fromBytes(L.subarray(0, C)), T = t.fromBytes(L.subarray(C, C * 2));
|
|
3492
3492
|
if (!y(M, T))
|
|
3493
3493
|
throw new Error("bad point: is not on curve");
|
|
3494
3494
|
return { x: M, y: T };
|
|
3495
3495
|
} else
|
|
3496
|
-
throw new Error(`bad point: got length ${
|
|
3496
|
+
throw new Error(`bad point: got length ${v}, expected compressed=${f} or uncompressed=${_}`);
|
|
3497
3497
|
}
|
|
3498
3498
|
const x = e.toBytes || h, w = e.fromBytes || m;
|
|
3499
3499
|
function E(R) {
|
|
@@ -3501,8 +3501,8 @@ function jr(r, e = {}) {
|
|
|
3501
3501
|
return t.add(t.add(_, t.mul(R, o.a)), o.b);
|
|
3502
3502
|
}
|
|
3503
3503
|
function y(R, f) {
|
|
3504
|
-
const _ = t.sqr(f),
|
|
3505
|
-
return t.eql(_,
|
|
3504
|
+
const _ = t.sqr(f), v = E(R);
|
|
3505
|
+
return t.eql(_, v);
|
|
3506
3506
|
}
|
|
3507
3507
|
if (!y(o.Gx, o.Gy))
|
|
3508
3508
|
throw new Error("bad curve params: generator point");
|
|
@@ -3514,7 +3514,7 @@ function jr(r, e = {}) {
|
|
|
3514
3514
|
throw new Error(`bad point coordinate ${R}`);
|
|
3515
3515
|
return f;
|
|
3516
3516
|
}
|
|
3517
|
-
function
|
|
3517
|
+
function b(R) {
|
|
3518
3518
|
if (!(R instanceof W))
|
|
3519
3519
|
throw new Error("Weierstrass Point expected");
|
|
3520
3520
|
}
|
|
@@ -3524,12 +3524,12 @@ function jr(r, e = {}) {
|
|
|
3524
3524
|
return Vr(R, c.basises, n.ORDER);
|
|
3525
3525
|
}
|
|
3526
3526
|
const N = Lt((R, f) => {
|
|
3527
|
-
const { X: _, Y:
|
|
3527
|
+
const { X: _, Y: v, Z: A } = R;
|
|
3528
3528
|
if (t.eql(A, t.ONE))
|
|
3529
|
-
return { x: _, y:
|
|
3529
|
+
return { x: _, y: v };
|
|
3530
3530
|
const L = R.is0();
|
|
3531
3531
|
f == null && (f = L ? t.ONE : t.inv(A));
|
|
3532
|
-
const C = t.mul(_, f), M = t.mul(
|
|
3532
|
+
const C = t.mul(_, f), M = t.mul(v, f), T = t.mul(A, f);
|
|
3533
3533
|
if (L)
|
|
3534
3534
|
return { x: t.ZERO, y: t.ZERO };
|
|
3535
3535
|
if (!t.eql(T, t.ONE))
|
|
@@ -3550,28 +3550,28 @@ function jr(r, e = {}) {
|
|
|
3550
3550
|
throw new Error("bad point: not in prime-order subgroup");
|
|
3551
3551
|
return !0;
|
|
3552
3552
|
});
|
|
3553
|
-
function K(R, f, _,
|
|
3554
|
-
return _ = new W(t.mul(_.X, R), _.Y, _.Z), f = ze(
|
|
3553
|
+
function K(R, f, _, v, A) {
|
|
3554
|
+
return _ = new W(t.mul(_.X, R), _.Y, _.Z), f = ze(v, f), _ = ze(A, _), f.add(_);
|
|
3555
3555
|
}
|
|
3556
3556
|
const k = class k {
|
|
3557
3557
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
3558
|
-
constructor(f, _,
|
|
3558
|
+
constructor(f, _, v) {
|
|
3559
3559
|
I(this, "X");
|
|
3560
3560
|
I(this, "Y");
|
|
3561
3561
|
I(this, "Z");
|
|
3562
|
-
this.X = B("x", f), this.Y = B("y", _, !0), this.Z = B("z",
|
|
3562
|
+
this.X = B("x", f), this.Y = B("y", _, !0), this.Z = B("z", v), Object.freeze(this);
|
|
3563
3563
|
}
|
|
3564
3564
|
static CURVE() {
|
|
3565
3565
|
return o;
|
|
3566
3566
|
}
|
|
3567
3567
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
3568
3568
|
static fromAffine(f) {
|
|
3569
|
-
const { x: _, y:
|
|
3570
|
-
if (!f || !t.isValid(_) || !t.isValid(
|
|
3569
|
+
const { x: _, y: v } = f || {};
|
|
3570
|
+
if (!f || !t.isValid(_) || !t.isValid(v))
|
|
3571
3571
|
throw new Error("invalid affine point");
|
|
3572
3572
|
if (f instanceof k)
|
|
3573
3573
|
throw new Error("projective point not allowed");
|
|
3574
|
-
return t.is0(_) && t.is0(
|
|
3574
|
+
return t.is0(_) && t.is0(v) ? k.ZERO : new k(_, v, t.ONE);
|
|
3575
3575
|
}
|
|
3576
3576
|
static fromBytes(f) {
|
|
3577
3577
|
const _ = k.fromAffine(w(z(f, void 0, "point")));
|
|
@@ -3608,8 +3608,8 @@ function jr(r, e = {}) {
|
|
|
3608
3608
|
}
|
|
3609
3609
|
/** Compare one point to another. */
|
|
3610
3610
|
equals(f) {
|
|
3611
|
-
|
|
3612
|
-
const { X: _, Y:
|
|
3611
|
+
b(f);
|
|
3612
|
+
const { X: _, Y: v, Z: A } = this, { X: L, Y: C, Z: M } = f, T = t.eql(t.mul(_, M), t.mul(L, A)), $ = t.eql(t.mul(v, M), t.mul(C, A));
|
|
3613
3613
|
return T && $;
|
|
3614
3614
|
}
|
|
3615
3615
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
@@ -3621,23 +3621,23 @@ function jr(r, e = {}) {
|
|
|
3621
3621
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
3622
3622
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
3623
3623
|
double() {
|
|
3624
|
-
const { a: f, b: _ } = o,
|
|
3624
|
+
const { a: f, b: _ } = o, v = t.mul(_, Fe), { X: A, Y: L, Z: C } = this;
|
|
3625
3625
|
let M = t.ZERO, T = t.ZERO, $ = t.ZERO, F = t.mul(A, A), J = t.mul(L, L), V = t.mul(C, C), H = t.mul(A, L);
|
|
3626
|
-
return H = t.add(H, H), $ = t.mul(A, C), $ = t.add($, $), M = t.mul(f, $), T = t.mul(
|
|
3626
|
+
return H = t.add(H, H), $ = t.mul(A, C), $ = t.add($, $), M = t.mul(f, $), T = t.mul(v, V), T = t.add(M, T), M = t.sub(J, T), T = t.add(J, T), T = t.mul(M, T), M = t.mul(H, M), $ = t.mul(v, $), V = t.mul(f, V), H = t.sub(F, V), H = t.mul(f, H), H = t.add(H, $), $ = t.add(F, F), F = t.add($, F), F = t.add(F, V), F = t.mul(F, H), T = t.add(T, F), V = t.mul(L, C), V = t.add(V, V), F = t.mul(V, H), M = t.sub(M, F), $ = t.mul(V, J), $ = t.add($, $), $ = t.add($, $), new k(M, T, $);
|
|
3627
3627
|
}
|
|
3628
3628
|
// Renes-Costello-Batina exception-free addition formula.
|
|
3629
3629
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
3630
3630
|
// https://eprint.iacr.org/2015/1060, algorithm 1
|
|
3631
3631
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
3632
3632
|
add(f) {
|
|
3633
|
-
|
|
3634
|
-
const { X: _, Y:
|
|
3633
|
+
b(f);
|
|
3634
|
+
const { X: _, Y: v, Z: A } = this, { X: L, Y: C, Z: M } = f;
|
|
3635
3635
|
let T = t.ZERO, $ = t.ZERO, F = t.ZERO;
|
|
3636
3636
|
const J = o.a, V = t.mul(o.b, Fe);
|
|
3637
|
-
let H = t.mul(_, L), Z = t.mul(
|
|
3637
|
+
let H = t.mul(_, L), Z = t.mul(v, C), X = t.mul(A, M), oe = t.add(_, v), j = t.add(L, C);
|
|
3638
3638
|
oe = t.mul(oe, j), j = t.add(H, Z), oe = t.sub(oe, j), j = t.add(_, A);
|
|
3639
3639
|
let Q = t.add(L, M);
|
|
3640
|
-
return j = t.mul(j, Q), Q = t.add(H, X), j = t.sub(j, Q), Q = t.add(
|
|
3640
|
+
return j = t.mul(j, Q), Q = t.add(H, X), j = t.sub(j, Q), Q = t.add(v, A), T = t.add(C, M), Q = t.mul(Q, T), T = t.add(Z, X), Q = t.sub(Q, T), F = t.mul(J, j), T = t.mul(V, X), F = t.add(T, F), T = t.sub(Z, F), F = t.add(Z, F), $ = t.mul(T, F), Z = t.add(H, H), Z = t.add(Z, H), X = t.mul(J, X), j = t.mul(V, j), Z = t.add(Z, X), X = t.sub(H, X), X = t.mul(J, X), j = t.add(j, X), H = t.mul(Z, j), $ = t.add($, H), H = t.mul(Q, j), T = t.mul(oe, T), T = t.sub(T, H), H = t.mul(oe, Z), F = t.mul(Q, F), F = t.add(F, H), new k(T, $, F);
|
|
3641
3641
|
}
|
|
3642
3642
|
subtract(f) {
|
|
3643
3643
|
return this.add(f.negate());
|
|
@@ -3658,16 +3658,16 @@ function jr(r, e = {}) {
|
|
|
3658
3658
|
const { endo: _ } = e;
|
|
3659
3659
|
if (!n.isValidNot0(f))
|
|
3660
3660
|
throw new Error("invalid scalar: out of range");
|
|
3661
|
-
let
|
|
3661
|
+
let v, A;
|
|
3662
3662
|
const L = (C) => D.cached(this, C, (M) => $t(k, M));
|
|
3663
3663
|
if (_) {
|
|
3664
3664
|
const { k1neg: C, k1: M, k2neg: T, k2: $ } = P(f), { p: F, f: J } = L(M), { p: V, f: H } = L($);
|
|
3665
|
-
A = J.add(H),
|
|
3665
|
+
A = J.add(H), v = K(_.beta, F, V, C, T);
|
|
3666
3666
|
} else {
|
|
3667
3667
|
const { p: C, f: M } = L(f);
|
|
3668
|
-
|
|
3668
|
+
v = C, A = M;
|
|
3669
3669
|
}
|
|
3670
|
-
return $t(k, [
|
|
3670
|
+
return $t(k, [v, A])[0];
|
|
3671
3671
|
}
|
|
3672
3672
|
/**
|
|
3673
3673
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -3675,20 +3675,20 @@ function jr(r, e = {}) {
|
|
|
3675
3675
|
* an exposed secret key e.g. sig verification, which works over *public* keys.
|
|
3676
3676
|
*/
|
|
3677
3677
|
multiplyUnsafe(f) {
|
|
3678
|
-
const { endo: _ } = e,
|
|
3678
|
+
const { endo: _ } = e, v = this;
|
|
3679
3679
|
if (!n.isValid(f))
|
|
3680
3680
|
throw new Error("invalid scalar: out of range");
|
|
3681
|
-
if (f === pe ||
|
|
3681
|
+
if (f === pe || v.is0())
|
|
3682
3682
|
return k.ZERO;
|
|
3683
3683
|
if (f === Te)
|
|
3684
|
-
return
|
|
3684
|
+
return v;
|
|
3685
3685
|
if (D.hasCache(this))
|
|
3686
3686
|
return this.multiply(f);
|
|
3687
3687
|
if (_) {
|
|
3688
|
-
const { k1neg: A, k1: L, k2neg: C, k2: M } = P(f), { p1: T, p2: $ } = Gr(k,
|
|
3688
|
+
const { k1neg: A, k1: L, k2neg: C, k2: M } = P(f), { p1: T, p2: $ } = Gr(k, v, L, M);
|
|
3689
3689
|
return K(_.beta, T, $, A, C);
|
|
3690
3690
|
} else
|
|
3691
|
-
return D.unsafe(
|
|
3691
|
+
return D.unsafe(v, f);
|
|
3692
3692
|
}
|
|
3693
3693
|
/**
|
|
3694
3694
|
* Converts Projective point to affine (x, y) coordinates.
|
|
@@ -3820,34 +3820,34 @@ function Jr(r, e, s = {}) {
|
|
|
3820
3820
|
}
|
|
3821
3821
|
function B(f, _) {
|
|
3822
3822
|
ct(_);
|
|
3823
|
-
const
|
|
3823
|
+
const v = x.signature, A = _ === "compact" ? v : _ === "recovered" ? v + 1 : void 0;
|
|
3824
3824
|
return z(f, A);
|
|
3825
3825
|
}
|
|
3826
|
-
class
|
|
3827
|
-
constructor(_,
|
|
3826
|
+
class b {
|
|
3827
|
+
constructor(_, v, A) {
|
|
3828
3828
|
I(this, "r");
|
|
3829
3829
|
I(this, "s");
|
|
3830
3830
|
I(this, "recovery");
|
|
3831
|
-
if (this.r = S("r", _), this.s = S("s",
|
|
3831
|
+
if (this.r = S("r", _), this.s = S("s", v), A != null) {
|
|
3832
3832
|
if (O(), ![0, 1, 2, 3].includes(A))
|
|
3833
3833
|
throw new Error("invalid recovery id");
|
|
3834
3834
|
this.recovery = A;
|
|
3835
3835
|
}
|
|
3836
3836
|
Object.freeze(this);
|
|
3837
3837
|
}
|
|
3838
|
-
static fromBytes(_,
|
|
3839
|
-
B(_,
|
|
3838
|
+
static fromBytes(_, v = w.format) {
|
|
3839
|
+
B(_, v);
|
|
3840
3840
|
let A;
|
|
3841
|
-
if (
|
|
3841
|
+
if (v === "der") {
|
|
3842
3842
|
const { r: T, s: $ } = me.toSig(z(_));
|
|
3843
|
-
return new
|
|
3843
|
+
return new b(T, $);
|
|
3844
3844
|
}
|
|
3845
|
-
|
|
3845
|
+
v === "recovered" && (A = _[0], v = "compact", _ = _.subarray(1));
|
|
3846
3846
|
const L = x.signature / 2, C = _.subarray(0, L), M = _.subarray(L, L * 2);
|
|
3847
|
-
return new
|
|
3847
|
+
return new b(i.fromBytes(C), i.fromBytes(M), A);
|
|
3848
3848
|
}
|
|
3849
|
-
static fromHex(_,
|
|
3850
|
-
return this.fromBytes(qe(_),
|
|
3849
|
+
static fromHex(_, v) {
|
|
3850
|
+
return this.fromBytes(qe(_), v);
|
|
3851
3851
|
}
|
|
3852
3852
|
assertRecovery() {
|
|
3853
3853
|
const { recovery: _ } = this;
|
|
@@ -3856,13 +3856,13 @@ function Jr(r, e, s = {}) {
|
|
|
3856
3856
|
return _;
|
|
3857
3857
|
}
|
|
3858
3858
|
addRecoveryBit(_) {
|
|
3859
|
-
return new
|
|
3859
|
+
return new b(this.r, this.s, _);
|
|
3860
3860
|
}
|
|
3861
3861
|
recoverPublicKey(_) {
|
|
3862
|
-
const { r:
|
|
3862
|
+
const { r: v, s: A } = this, L = this.assertRecovery(), C = L === 2 || L === 3 ? v + a : v;
|
|
3863
3863
|
if (!o.isValid(C))
|
|
3864
3864
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
3865
|
-
const M = o.toBytes(C), T = r.fromBytes(
|
|
3865
|
+
const M = o.toBytes(C), T = r.fromBytes(we(Ss((L & 1) === 0), M)), $ = i.inv(C), F = N(z(_, void 0, "msgHash")), J = i.create(-F * $), V = i.create(A * $), H = r.BASE.multiplyUnsafe(J).add(T.multiplyUnsafe(V));
|
|
3866
3866
|
if (H.is0())
|
|
3867
3867
|
throw new Error("invalid recovery: point at infinify");
|
|
3868
3868
|
return H.assertValidity(), H;
|
|
@@ -3874,8 +3874,8 @@ function Jr(r, e, s = {}) {
|
|
|
3874
3874
|
toBytes(_ = w.format) {
|
|
3875
3875
|
if (ct(_), _ === "der")
|
|
3876
3876
|
return qe(me.hexFromSig(this));
|
|
3877
|
-
const { r:
|
|
3878
|
-
return _ === "recovered" ? (O(),
|
|
3877
|
+
const { r: v, s: A } = this, L = i.toBytes(v), C = i.toBytes(A);
|
|
3878
|
+
return _ === "recovered" ? (O(), we(Uint8Array.of(this.assertRecovery()), L, C)) : we(L, C);
|
|
3879
3879
|
}
|
|
3880
3880
|
toHex(_) {
|
|
3881
3881
|
return Me(this.toBytes(_));
|
|
@@ -3884,8 +3884,8 @@ function Jr(r, e, s = {}) {
|
|
|
3884
3884
|
const P = s.bits2int || function(_) {
|
|
3885
3885
|
if (_.length > 8192)
|
|
3886
3886
|
throw new Error("input is too large");
|
|
3887
|
-
const
|
|
3888
|
-
return A > 0 ?
|
|
3887
|
+
const v = je(_), A = _.length * 8 - c;
|
|
3888
|
+
return A > 0 ? v >> BigInt(A) : v;
|
|
3889
3889
|
}, N = s.bits2int_modN || function(_) {
|
|
3890
3890
|
return i.create(P(_));
|
|
3891
3891
|
}, G = ft(c);
|
|
@@ -3895,8 +3895,8 @@ function Jr(r, e, s = {}) {
|
|
|
3895
3895
|
function W(f, _) {
|
|
3896
3896
|
return z(f, void 0, "message"), _ ? z(e(f), void 0, "prehashed message") : f;
|
|
3897
3897
|
}
|
|
3898
|
-
function q(f, _,
|
|
3899
|
-
const { lowS: A, prehash: L, extraEntropy: C } = st(
|
|
3898
|
+
function q(f, _, v) {
|
|
3899
|
+
const { lowS: A, prehash: L, extraEntropy: C } = st(v, w);
|
|
3900
3900
|
f = W(f, L);
|
|
3901
3901
|
const M = N(f), T = i.fromBytes(_);
|
|
3902
3902
|
if (!i.isValidNot0(T))
|
|
@@ -3906,7 +3906,7 @@ function Jr(r, e, s = {}) {
|
|
|
3906
3906
|
const H = C === !0 ? t(x.secretKey) : C;
|
|
3907
3907
|
$.push(z(H, void 0, "extraEntropy"));
|
|
3908
3908
|
}
|
|
3909
|
-
const F =
|
|
3909
|
+
const F = we(...$), J = M;
|
|
3910
3910
|
function V(H) {
|
|
3911
3911
|
const Z = P(H);
|
|
3912
3912
|
if (!i.isValidNot0(Z))
|
|
@@ -3918,23 +3918,23 @@ function Jr(r, e, s = {}) {
|
|
|
3918
3918
|
if (Q === pe)
|
|
3919
3919
|
return;
|
|
3920
3920
|
let yt = (oe.x === j ? 0 : 2) | Number(oe.y & Te), bt = Q;
|
|
3921
|
-
return A && y(Q) && (bt = i.neg(Q), yt ^= 1), new
|
|
3921
|
+
return A && y(Q) && (bt = i.neg(Q), yt ^= 1), new b(j, bt, E ? void 0 : yt);
|
|
3922
3922
|
}
|
|
3923
3923
|
return { seed: F, k2sig: V };
|
|
3924
3924
|
}
|
|
3925
|
-
function D(f, _,
|
|
3926
|
-
const { seed: A, k2sig: L } = q(f, _,
|
|
3927
|
-
return Pr(e.outputLen, i.BYTES, n)(A, L).toBytes(
|
|
3925
|
+
function D(f, _, v = {}) {
|
|
3926
|
+
const { seed: A, k2sig: L } = q(f, _, v);
|
|
3927
|
+
return Pr(e.outputLen, i.BYTES, n)(A, L).toBytes(v.format);
|
|
3928
3928
|
}
|
|
3929
|
-
function k(f, _,
|
|
3929
|
+
function k(f, _, v, A = {}) {
|
|
3930
3930
|
const { lowS: L, prehash: C, format: M } = st(A, w);
|
|
3931
|
-
if (
|
|
3932
|
-
const T = f instanceof
|
|
3931
|
+
if (v = z(v, void 0, "publicKey"), _ = W(_, C), !ut(f)) {
|
|
3932
|
+
const T = f instanceof b ? ", use sig.toBytes()" : "";
|
|
3933
3933
|
throw new Error("verify expects Uint8Array signature" + T);
|
|
3934
3934
|
}
|
|
3935
3935
|
B(f, M);
|
|
3936
3936
|
try {
|
|
3937
|
-
const T =
|
|
3937
|
+
const T = b.fromBytes(f, M), $ = r.fromBytes(v);
|
|
3938
3938
|
if (L && T.hasHighS())
|
|
3939
3939
|
return !1;
|
|
3940
3940
|
const { r: F, s: J } = T, V = N(_), H = i.inv(J), Z = i.create(V * H), X = i.create(F * H), oe = r.BASE.multiplyUnsafe(Z).add($.multiplyUnsafe(X));
|
|
@@ -3943,9 +3943,9 @@ function Jr(r, e, s = {}) {
|
|
|
3943
3943
|
return !1;
|
|
3944
3944
|
}
|
|
3945
3945
|
}
|
|
3946
|
-
function R(f, _,
|
|
3947
|
-
const { prehash: A } = st(
|
|
3948
|
-
return _ = W(_, A),
|
|
3946
|
+
function R(f, _, v = {}) {
|
|
3947
|
+
const { prehash: A } = st(v, w);
|
|
3948
|
+
return _ = W(_, A), b.fromBytes(f, "recovered").recoverPublicKey(_).toBytes();
|
|
3949
3949
|
}
|
|
3950
3950
|
return Object.freeze({
|
|
3951
3951
|
keygen: l,
|
|
@@ -3957,7 +3957,7 @@ function Jr(r, e, s = {}) {
|
|
|
3957
3957
|
sign: D,
|
|
3958
3958
|
verify: k,
|
|
3959
3959
|
recoverPublicKey: R,
|
|
3960
|
-
Signature:
|
|
3960
|
+
Signature: b,
|
|
3961
3961
|
hash: e
|
|
3962
3962
|
});
|
|
3963
3963
|
}
|
|
@@ -3978,7 +3978,7 @@ const gt = {
|
|
|
3978
3978
|
]
|
|
3979
3979
|
}, Gt = /* @__PURE__ */ BigInt(2);
|
|
3980
3980
|
function Xr(r) {
|
|
3981
|
-
const e = gt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, h = ae(d, s, e) * d % e, m = ae(h, s, e) * d % e, x = ae(m, Gt, e) * l % e, w = ae(x, n, e) * x % e, E = ae(w, o, e) * w % e, y = ae(E, a, e) * E % e, S = ae(y, c, e) * y % e, O = ae(S, a, e) * E % e, B = ae(O, s, e) * d % e,
|
|
3981
|
+
const e = gt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, h = ae(d, s, e) * d % e, m = ae(h, s, e) * d % e, x = ae(m, Gt, e) * l % e, w = ae(x, n, e) * x % e, E = ae(w, o, e) * w % e, y = ae(E, a, e) * E % e, S = ae(y, c, e) * y % e, O = ae(S, a, e) * E % e, B = ae(O, s, e) * d % e, b = ae(B, i, e) * w % e, P = ae(b, t, e) * l % e, N = ae(P, Gt, e);
|
|
3982
3982
|
if (!lt.eql(lt.sqr(N), r))
|
|
3983
3983
|
throw new Error("Cannot find square root");
|
|
3984
3984
|
return N;
|
|
@@ -4042,7 +4042,7 @@ class mt {
|
|
|
4042
4042
|
return this._cloneInto();
|
|
4043
4043
|
}
|
|
4044
4044
|
keccak() {
|
|
4045
|
-
|
|
4045
|
+
Rt(this.state32), ln(this.state32, this.rounds), Rt(this.state32), this.posOut = 0, this.pos = 0;
|
|
4046
4046
|
}
|
|
4047
4047
|
update(e) {
|
|
4048
4048
|
Ae(this), z(e);
|
|
@@ -4187,7 +4187,7 @@ class fn {
|
|
|
4187
4187
|
}
|
|
4188
4188
|
}
|
|
4189
4189
|
}
|
|
4190
|
-
class
|
|
4190
|
+
class be {
|
|
4191
4191
|
static generateRandom16Hex() {
|
|
4192
4192
|
const e = new Uint8Array(16);
|
|
4193
4193
|
return crypto.getRandomValues(e), Array.from(e, (s) => s.toString(16).padStart(2, "0")).join("");
|
|
@@ -4211,7 +4211,7 @@ class we {
|
|
|
4211
4211
|
* - Google 및 기타: originalNonce === jwt.nonce
|
|
4212
4212
|
*/
|
|
4213
4213
|
static async verifyIdTokenNonce(e, s) {
|
|
4214
|
-
const t =
|
|
4214
|
+
const t = be.parseJwtPayload(e), n = t.nonce, o = typeof t.iss == "string" ? t.iss : "(unknown)";
|
|
4215
4215
|
if (u.log("[CROSSx] nonce 검증 시작 —", {
|
|
4216
4216
|
iss: o,
|
|
4217
4217
|
nonceClaimType: typeof n,
|
|
@@ -4233,7 +4233,7 @@ class we {
|
|
|
4233
4233
|
"ID Token에 nonce claim이 없습니다 — OAuth 서버 설정을 확인해 주세요"
|
|
4234
4234
|
);
|
|
4235
4235
|
if (o.includes("appleid.apple.com")) {
|
|
4236
|
-
const i = await
|
|
4236
|
+
const i = await be.sha256Hex(s);
|
|
4237
4237
|
if (u.log("[CROSSx] Apple nonce 검증 —", {
|
|
4238
4238
|
expectedHashLength: i.length,
|
|
4239
4239
|
receivedHashLength: n.length,
|
|
@@ -4250,7 +4250,7 @@ class we {
|
|
|
4250
4250
|
}
|
|
4251
4251
|
openAuth(e) {
|
|
4252
4252
|
return new Promise((s, t) => {
|
|
4253
|
-
const n = Math.max(e.width ?? 500, 500), o = Math.max(e.height ?? 700, 700), i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c =
|
|
4253
|
+
const n = Math.max(e.width ?? 500, 500), o = Math.max(e.height ?? 700, 700), i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = be.generateRandom16Hex(), l = be.generateRandom16Hex(), d = e.authUrl.includes("?") ? "&" : "?", h = `${e.authUrl}${d}state=${c}&nonce=${l}`;
|
|
4254
4254
|
u.log("[CROSSx] OAuth 팝업 열기 — state, nonce 생성 완료:", {
|
|
4255
4255
|
stateLength: c.length,
|
|
4256
4256
|
nonceLength: l.length,
|
|
@@ -4266,28 +4266,28 @@ class we {
|
|
|
4266
4266
|
return;
|
|
4267
4267
|
}
|
|
4268
4268
|
const x = setTimeout(() => {
|
|
4269
|
-
u.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"),
|
|
4269
|
+
u.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), b(), t(new Error("Authentication timeout"));
|
|
4270
4270
|
}, 5 * 60 * 1e3), w = 10, E = 30;
|
|
4271
4271
|
let y = 0, S = null;
|
|
4272
4272
|
const O = () => {
|
|
4273
4273
|
clearInterval(B), u.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + E + "초간 대기합니다"), S = setTimeout(() => {
|
|
4274
|
-
|
|
4274
|
+
b(), t(new Error(
|
|
4275
4275
|
"OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
|
|
4276
4276
|
));
|
|
4277
4277
|
}, E * 1e3);
|
|
4278
4278
|
}, B = setInterval(() => {
|
|
4279
4279
|
y++;
|
|
4280
4280
|
try {
|
|
4281
|
-
m.closed && (y <= w ? O() : (
|
|
4281
|
+
m.closed && (y <= w ? O() : (b(), t(new Error("로그인이 취소되었습니다"))));
|
|
4282
4282
|
} catch {
|
|
4283
4283
|
O();
|
|
4284
4284
|
}
|
|
4285
|
-
}, 1e3),
|
|
4285
|
+
}, 1e3), b = () => {
|
|
4286
4286
|
clearTimeout(x), clearInterval(B), S && clearTimeout(S), window.removeEventListener("message", P);
|
|
4287
4287
|
}, P = (N) => {
|
|
4288
4288
|
var K, W, q, D, k;
|
|
4289
4289
|
if (N.origin !== e.expectedOrigin) return;
|
|
4290
|
-
|
|
4290
|
+
b(), u.log("[CROSSx] OAuth postMessage 수신 — status:", N.data.status);
|
|
4291
4291
|
const G = N.data.state ?? ((K = N.data.data) == null ? void 0 : K.state);
|
|
4292
4292
|
if (!G || G !== c) {
|
|
4293
4293
|
t(new Error("OAuth state mismatch — possible CSRF attack"));
|
|
@@ -4302,24 +4302,9 @@ class we {
|
|
|
4302
4302
|
u.error("[CROSSx] 토큰을 찾을 수 없음:", N.data), t(new Error("Token not found in response"));
|
|
4303
4303
|
return;
|
|
4304
4304
|
}
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
u.log("[CROSSx] idToken JWT payload 요약:", {
|
|
4309
|
-
iss: b.iss,
|
|
4310
|
-
sub: typeof b.sub == "string" ? `${b.sub.slice(0, 6)}...` : "(absent)",
|
|
4311
|
-
hasNonceClaim: "nonce" in b,
|
|
4312
|
-
nonceClaimType: typeof b.nonce,
|
|
4313
|
-
appleNonceSupported: b.nonce_supported ?? "(field absent)"
|
|
4314
|
-
});
|
|
4315
|
-
} catch {
|
|
4316
|
-
u.warn("[CROSSx] idToken JWT payload 파싱 실패 — 토큰 형식을 확인하세요");
|
|
4317
|
-
}
|
|
4318
|
-
we.verifyIdTokenNonce(R, l).then(() => s(_)).catch((b) => {
|
|
4319
|
-
u.error("[CROSSx] nonce 검증 실패:", b), t(b instanceof Error ? b : new Error("nonce verification failed"));
|
|
4320
|
-
});
|
|
4321
|
-
} else
|
|
4322
|
-
s(_);
|
|
4305
|
+
R ? be.verifyIdTokenNonce(R, l).then(() => s(_)).catch((v) => {
|
|
4306
|
+
u.error("[CROSSx] nonce 검증 실패:", v), t(v instanceof Error ? v : new Error("nonce verification failed"));
|
|
4307
|
+
}) : s(_);
|
|
4323
4308
|
} else
|
|
4324
4309
|
u.error("[CROSSx] OAuth 실패:", (D = N.data.data) == null ? void 0 : D.error), t(new Error(((k = N.data.data) == null ? void 0 : k.error) || "Authentication failed"));
|
|
4325
4310
|
};
|
|
@@ -4517,8 +4502,7 @@ class Le {
|
|
|
4517
4502
|
code: d.code,
|
|
4518
4503
|
message: h,
|
|
4519
4504
|
url: o,
|
|
4520
|
-
method: e
|
|
4521
|
-
fullResponse: d
|
|
4505
|
+
method: e
|
|
4522
4506
|
});
|
|
4523
4507
|
const m = Le.mapGatewayError(d.code, d.data), x = Le.getGatewayErrorMessage(d.code, h), w = d.data, E = m === p.PIN_LOCKED ? Le.extractLockDetails(w) : w ?? void 0, y = new g(m, x, E);
|
|
4524
4508
|
throw y.gatewayCode = d.code, y.gatewayMessage = h, m === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (u.warn("[CROSSx] Gateway -10002 감지 — 강제 로그아웃 실행"), this._onUnauthorized()), y;
|
|
@@ -4673,7 +4657,7 @@ class Le {
|
|
|
4673
4657
|
)).txHash };
|
|
4674
4658
|
}
|
|
4675
4659
|
async migrateWallet(e, s) {
|
|
4676
|
-
u.log("[CROSSx][Migration Phase 4] POST /mnemonic/migrate 호출
|
|
4660
|
+
u.log("[CROSSx][Migration Phase 4] POST /mnemonic/migrate 호출");
|
|
4677
4661
|
const t = { recoveryPin: e, sub: s, password: this.requirePin() }, n = await this.request(
|
|
4678
4662
|
"POST",
|
|
4679
4663
|
"/mnemonic/migrate",
|
|
@@ -5565,6 +5549,19 @@ const gn = `
|
|
|
5565
5549
|
filter: none !important;
|
|
5566
5550
|
transform: none !important;
|
|
5567
5551
|
}
|
|
5552
|
+
.__crossx-recover-icon {
|
|
5553
|
+
display: flex;
|
|
5554
|
+
align-items: center;
|
|
5555
|
+
justify-content: center;
|
|
5556
|
+
flex-shrink: 0;
|
|
5557
|
+
width: 40px;
|
|
5558
|
+
height: 40px;
|
|
5559
|
+
}
|
|
5560
|
+
.__crossx-recover-icon svg {
|
|
5561
|
+
width: 40px;
|
|
5562
|
+
height: 40px;
|
|
5563
|
+
display: block;
|
|
5564
|
+
}
|
|
5568
5565
|
.__crossx-recover-label {
|
|
5569
5566
|
font-size: 18px;
|
|
5570
5567
|
font-weight: 700;
|
|
@@ -5823,7 +5820,7 @@ const gn = `
|
|
|
5823
5820
|
.__crossx-approve-btn {
|
|
5824
5821
|
width: 100%;
|
|
5825
5822
|
padding: 16px;
|
|
5826
|
-
border: 1px solid
|
|
5823
|
+
border: 1px solid var(--cx-border);
|
|
5827
5824
|
border-radius: 12px;
|
|
5828
5825
|
background: var(--cx-primary);
|
|
5829
5826
|
color: var(--cx-on-primary);
|
|
@@ -5876,7 +5873,7 @@ const gn = `
|
|
|
5876
5873
|
.__crossx-confirm-btn {
|
|
5877
5874
|
flex: 1;
|
|
5878
5875
|
padding: 16px;
|
|
5879
|
-
border: 1px solid
|
|
5876
|
+
border: 1px solid var(--cx-border);
|
|
5880
5877
|
border-radius: 12px;
|
|
5881
5878
|
background: var(--cx-primary);
|
|
5882
5879
|
color: var(--cx-on-primary);
|
|
@@ -6218,7 +6215,7 @@ const gn = `
|
|
|
6218
6215
|
width: 100% !important;
|
|
6219
6216
|
max-width: 100% !important;
|
|
6220
6217
|
border-radius: 20px 20px 0 0 !important;
|
|
6221
|
-
border: 1px solid
|
|
6218
|
+
border: 1px solid var(--cx-border) !important;
|
|
6222
6219
|
border-bottom: none !important;
|
|
6223
6220
|
max-height: 92vh;
|
|
6224
6221
|
overflow: hidden;
|
|
@@ -6254,7 +6251,7 @@ const gn = `
|
|
|
6254
6251
|
width: 100% !important;
|
|
6255
6252
|
max-width: 100% !important;
|
|
6256
6253
|
border-radius: 20px 20px 0 0 !important;
|
|
6257
|
-
border: 1px solid
|
|
6254
|
+
border: 1px solid var(--cx-border) !important;
|
|
6258
6255
|
border-bottom: none !important;
|
|
6259
6256
|
max-height: 92vh;
|
|
6260
6257
|
overflow: hidden;
|
|
@@ -6533,7 +6530,7 @@ const gn = `
|
|
|
6533
6530
|
.__crossx-pin6-header-sub {
|
|
6534
6531
|
font-size: 14px;
|
|
6535
6532
|
font-weight: 400;
|
|
6536
|
-
color:
|
|
6533
|
+
color: var(--cx-subtitle);
|
|
6537
6534
|
line-height: 1.3;
|
|
6538
6535
|
margin: 2px 0 0;
|
|
6539
6536
|
}
|
|
@@ -6548,7 +6545,7 @@ const gn = `
|
|
|
6548
6545
|
.__crossx-pin6-subtitle {
|
|
6549
6546
|
font-size: 16px;
|
|
6550
6547
|
font-weight: 500;
|
|
6551
|
-
color:
|
|
6548
|
+
color: var(--cx-label);
|
|
6552
6549
|
text-align: center;
|
|
6553
6550
|
margin: 0;
|
|
6554
6551
|
line-height: 1.5;
|
|
@@ -6567,11 +6564,11 @@ const gn = `
|
|
|
6567
6564
|
height: 48px;
|
|
6568
6565
|
border-radius: 12px;
|
|
6569
6566
|
border: none;
|
|
6570
|
-
background:
|
|
6567
|
+
background: var(--cx-input-bg);
|
|
6571
6568
|
font-size: 24px;
|
|
6572
6569
|
font-weight: 600;
|
|
6573
6570
|
text-align: center;
|
|
6574
|
-
color: var(--cx-
|
|
6571
|
+
color: var(--cx-value);
|
|
6575
6572
|
outline: none;
|
|
6576
6573
|
caret-color: transparent;
|
|
6577
6574
|
letter-spacing: 0;
|
|
@@ -6579,8 +6576,8 @@ const gn = `
|
|
|
6579
6576
|
transition: background 0.12s, box-shadow 0.12s;
|
|
6580
6577
|
}
|
|
6581
6578
|
.__crossx-pin6-box:focus {
|
|
6582
|
-
background:
|
|
6583
|
-
box-shadow: 0 0 0 2px var(--
|
|
6579
|
+
background: var(--cx-input-border);
|
|
6580
|
+
box-shadow: 0 0 0 2px var(--cx-primary-glow);
|
|
6584
6581
|
}
|
|
6585
6582
|
.__crossx-pin6-box.--error {
|
|
6586
6583
|
/* 에러 시 박스 자체에는 별도 스타일 없음 — 에러 텍스트로만 표시 */
|
|
@@ -6603,7 +6600,7 @@ const gn = `
|
|
|
6603
6600
|
.__crossx-pin6-error {
|
|
6604
6601
|
font-size: 14px;
|
|
6605
6602
|
font-weight: 400;
|
|
6606
|
-
color: var(--cx-error
|
|
6603
|
+
color: var(--cx-error);
|
|
6607
6604
|
text-align: center;
|
|
6608
6605
|
margin: 0;
|
|
6609
6606
|
min-height: 20px;
|
|
@@ -6617,20 +6614,20 @@ const gn = `
|
|
|
6617
6614
|
gap: 6px;
|
|
6618
6615
|
font-size: 13px;
|
|
6619
6616
|
font-weight: 500;
|
|
6620
|
-
color: var(--
|
|
6617
|
+
color: var(--cx-error);
|
|
6621
6618
|
text-align: center;
|
|
6622
6619
|
margin: 0;
|
|
6623
6620
|
}
|
|
6624
6621
|
.__crossx-pin6-lock-msg svg {
|
|
6625
6622
|
flex-shrink: 0;
|
|
6626
|
-
color: var(--
|
|
6623
|
+
color: var(--cx-error);
|
|
6627
6624
|
}
|
|
6628
6625
|
/* Next 버튼 */
|
|
6629
6626
|
.__crossx-pin6-next {
|
|
6630
6627
|
width: 100%;
|
|
6631
6628
|
padding: 16px;
|
|
6632
|
-
background: var(--
|
|
6633
|
-
color:
|
|
6629
|
+
background: var(--cx-primary);
|
|
6630
|
+
color: var(--cx-on-primary);
|
|
6634
6631
|
border: none;
|
|
6635
6632
|
border-radius: 12px;
|
|
6636
6633
|
font-size: 18px;
|
|
@@ -6740,7 +6737,7 @@ function yn(r) {
|
|
|
6740
6737
|
return null;
|
|
6741
6738
|
}
|
|
6742
6739
|
}
|
|
6743
|
-
function
|
|
6740
|
+
function Ns(r) {
|
|
6744
6741
|
const e = yn(r);
|
|
6745
6742
|
if (!e) return Y("Estimated fee", "<span>—</span>");
|
|
6746
6743
|
let s = Y("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
|
|
@@ -6752,14 +6749,10 @@ const fe = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="
|
|
|
6752
6749
|
</svg>`, ie = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
|
|
6753
6750
|
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
6754
6751
|
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
6755
|
-
</svg
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
<path d="M14 7.5L19.2 10.5V16.5L14 19.5L8.8 16.5V10.5L14 7.5Z" fill="white" opacity="0.9"/>
|
|
6760
|
-
</svg>`;
|
|
6761
|
-
}
|
|
6762
|
-
const wt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
6752
|
+
</svg>`, bn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6753
|
+
<circle cx="20" cy="20" r="20" fill="#00D5AA"/>
|
|
6754
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.3225 2.85742L23.7249 6.25982V11.8301L28.1175 7.43757L32.9292 12.2493L28.5806 16.5979H20.3225C18.4435 16.5979 16.9201 18.1212 16.9201 20.0003C16.9201 21.8794 18.4434 23.4027 20.3225 23.4027H28.5372L32.9293 27.7948L28.1176 32.6066L23.7249 28.2139V33.7407L20.3225 37.1431L16.9201 33.7407V28.2584L12.5719 32.6066L7.76022 27.7948L12.1524 23.4027H6.58209L3.17969 20.0003L6.58209 16.5979H12.1089L7.76035 12.2493L12.5721 7.43757L16.9201 11.7857V6.25982L20.3225 2.85742Z" fill="#121212"/>
|
|
6755
|
+
</svg>`, wt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
6763
6756
|
<rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
|
|
6764
6757
|
<path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
|
|
6765
6758
|
<rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
|
|
@@ -6804,8 +6797,8 @@ function Y(r, e) {
|
|
|
6804
6797
|
</div>`;
|
|
6805
6798
|
}
|
|
6806
6799
|
function In(r, e) {
|
|
6807
|
-
const s = e, t = Je(), n = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
6808
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${fe}</button>` : "<span>—</span>", o =
|
|
6800
|
+
const s = e, t = Je(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
6801
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${fe}</button>` : "<span>—</span>", o = Ns(r), i = r.data ?? "0x", a = document.createElement("div");
|
|
6809
6802
|
return a.id = te, a.innerHTML = `
|
|
6810
6803
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
6811
6804
|
<div class="__crossx-header">
|
|
@@ -6844,8 +6837,8 @@ function In(r, e) {
|
|
|
6844
6837
|
`, a;
|
|
6845
6838
|
}
|
|
6846
6839
|
function En(r, e) {
|
|
6847
|
-
const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Je(), i = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
6848
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${fe}</button>` : "<span>—</span>", a =
|
|
6840
|
+
const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Je(r.dappName), i = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
6841
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${fe}</button>` : "<span>—</span>", a = Ns(r), l = mn(r.value, t, n) ?? "—", d = document.createElement("div");
|
|
6849
6842
|
return d.id = te, d.innerHTML = `
|
|
6850
6843
|
<div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
6851
6844
|
<div class="__crossx-header">
|
|
@@ -6873,10 +6866,11 @@ function En(r, e) {
|
|
|
6873
6866
|
</div>
|
|
6874
6867
|
`, d;
|
|
6875
6868
|
}
|
|
6876
|
-
function Je() {
|
|
6877
|
-
var
|
|
6869
|
+
function Je(r) {
|
|
6870
|
+
var e;
|
|
6871
|
+
if (r) return r;
|
|
6878
6872
|
try {
|
|
6879
|
-
return ((
|
|
6873
|
+
return ((e = window.location) == null ? void 0 : e.hostname) || "This site";
|
|
6880
6874
|
} catch {
|
|
6881
6875
|
return "This site";
|
|
6882
6876
|
}
|
|
@@ -6945,7 +6939,7 @@ function Pn(r, e) {
|
|
|
6945
6939
|
</div>
|
|
6946
6940
|
`, s;
|
|
6947
6941
|
}
|
|
6948
|
-
function
|
|
6942
|
+
function Nn(r, e, s) {
|
|
6949
6943
|
const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
|
|
6950
6944
|
if (o) {
|
|
6951
6945
|
const w = n ? Sn : t ? "" : vn, E = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
|
|
@@ -6984,8 +6978,8 @@ function Rn(r, e, s) {
|
|
|
6984
6978
|
});
|
|
6985
6979
|
});
|
|
6986
6980
|
}
|
|
6987
|
-
function
|
|
6988
|
-
const s = e, t = Je(), n = U(r.message), o = document.createElement("div");
|
|
6981
|
+
function Rn(r, e) {
|
|
6982
|
+
const s = e, t = Je(r.dappName), n = U(r.message), o = document.createElement("div");
|
|
6989
6983
|
return o.id = te, o.innerHTML = `
|
|
6990
6984
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
6991
6985
|
<div class="__crossx-header">
|
|
@@ -7017,7 +7011,7 @@ function Nn(r, e) {
|
|
|
7017
7011
|
`, o;
|
|
7018
7012
|
}
|
|
7019
7013
|
function Cn(r, e) {
|
|
7020
|
-
const s = e, t = Je();
|
|
7014
|
+
const s = e, t = Je(r.dappName);
|
|
7021
7015
|
let n = {};
|
|
7022
7016
|
if (typeof r.typedData == "string")
|
|
7023
7017
|
try {
|
|
@@ -7171,8 +7165,8 @@ function Bn(r) {
|
|
|
7171
7165
|
<p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
|
|
7172
7166
|
</div>
|
|
7173
7167
|
<button class="__crossx-recover-btn" id="__crossx-recover-btn">
|
|
7174
|
-
<span>${bn
|
|
7175
|
-
<span class="__crossx-recover-label">
|
|
7168
|
+
<span class="__crossx-recover-icon">${bn}</span>
|
|
7169
|
+
<span class="__crossx-recover-label">Import from Social Backup</span>
|
|
7176
7170
|
</button>
|
|
7177
7171
|
<button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>
|
|
7178
7172
|
</div>
|
|
@@ -7184,7 +7178,7 @@ function Un(r, e) {
|
|
|
7184
7178
|
return h.id = te, h.innerHTML = `
|
|
7185
7179
|
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7186
7180
|
<div class="__crossx-header">
|
|
7187
|
-
<p class="__crossx-title" id="__crossx-ttl">
|
|
7181
|
+
<p class="__crossx-title" id="__crossx-ttl">Import from Social Backup</p>
|
|
7188
7182
|
<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
|
|
7189
7183
|
</div>
|
|
7190
7184
|
<hr class="__crossx-divider">
|
|
@@ -7212,7 +7206,7 @@ function Fn(r, e, s) {
|
|
|
7212
7206
|
return a.id = te, a.innerHTML = `
|
|
7213
7207
|
<div class="__crossx-card __crossx-card--migration" style="${ce(t)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7214
7208
|
<div class="__crossx-header">
|
|
7215
|
-
<p class="__crossx-title" id="__crossx-ttl">
|
|
7209
|
+
<p class="__crossx-title" id="__crossx-ttl">Import from Social Backup</p>
|
|
7216
7210
|
<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
|
|
7217
7211
|
</div>
|
|
7218
7212
|
<hr class="__crossx-divider">
|
|
@@ -7276,7 +7270,7 @@ function Gn(r) {
|
|
|
7276
7270
|
}
|
|
7277
7271
|
function nt(r) {
|
|
7278
7272
|
const e = !!r.lockExpiresAt && r.lockExpiresAt > Date.now(), s = r.lockExpiresAt ? ` data-lock-expires="${r.lockExpiresAt}"` : "", t = r.headerSubtitle ? `<p class="__crossx-pin6-header-sub">${U(r.headerSubtitle)}</p>` : "", n = r.subtitle ? `<p class="__crossx-pin6-subtitle">${U(r.subtitle)}</p>` : "", o = r.errorMessage ? `<p class="__crossx-pin6-error" id="__crossx-pin6-error">${U(r.errorMessage)}</p>` : '<p class="__crossx-pin6-error" id="__crossx-pin6-error"></p>', i = e ? `<p class="__crossx-pin6-lock-msg" id="__crossx-pin6-lock-msg">
|
|
7279
|
-
${
|
|
7273
|
+
${Rs}
|
|
7280
7274
|
<span id="__crossx-pin6-lock-countdown"></span>
|
|
7281
7275
|
</p>` : "", a = e ? " --locked" : "", c = Array.from(
|
|
7282
7276
|
{ length: 6 },
|
|
@@ -7321,16 +7315,16 @@ function qn(r) {
|
|
|
7321
7315
|
}
|
|
7322
7316
|
function ot(r, e, s, t, n, o) {
|
|
7323
7317
|
let i = !!(o && o > Date.now()), a = !1;
|
|
7324
|
-
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), d = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), m = () => r.querySelector("#__crossx-pin6-lock-countdown"), x = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((
|
|
7325
|
-
i =
|
|
7326
|
-
P.disabled =
|
|
7318
|
+
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), d = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), m = () => r.querySelector("#__crossx-pin6-lock-countdown"), x = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((b) => b.value).join(""), E = (b) => {
|
|
7319
|
+
i = b, c().forEach((P) => {
|
|
7320
|
+
P.disabled = b, P.classList.toggle("--locked", b);
|
|
7327
7321
|
});
|
|
7328
7322
|
}, y = () => {
|
|
7329
|
-
const
|
|
7330
|
-
|
|
7331
|
-
}, S = (
|
|
7323
|
+
const b = d();
|
|
7324
|
+
b && (b.textContent = "");
|
|
7325
|
+
}, S = (b) => {
|
|
7332
7326
|
const P = d();
|
|
7333
|
-
P && (P.textContent =
|
|
7327
|
+
P && (P.textContent = b);
|
|
7334
7328
|
const N = l();
|
|
7335
7329
|
N == null || N.classList.add("--shake"), setTimeout(() => N == null ? void 0 : N.classList.remove("--shake"), 500), c().forEach((G) => {
|
|
7336
7330
|
G.value = "";
|
|
@@ -7338,7 +7332,7 @@ function ot(r, e, s, t, n, o) {
|
|
|
7338
7332
|
var G;
|
|
7339
7333
|
return (G = c()[0]) == null ? void 0 : G.focus();
|
|
7340
7334
|
}, 50);
|
|
7341
|
-
}, O = (
|
|
7335
|
+
}, O = (b) => {
|
|
7342
7336
|
var W;
|
|
7343
7337
|
E(!0), c().forEach((q) => {
|
|
7344
7338
|
q.value = "";
|
|
@@ -7346,13 +7340,13 @@ function ot(r, e, s, t, n, o) {
|
|
|
7346
7340
|
const P = d();
|
|
7347
7341
|
if (P && (P.textContent = "Too many failed attempts. Please wait."), !h()) {
|
|
7348
7342
|
const q = document.createElement("p");
|
|
7349
|
-
q.className = "__crossx-pin6-lock-msg", q.id = "__crossx-pin6-lock-msg", q.innerHTML = `${
|
|
7343
|
+
q.className = "__crossx-pin6-lock-msg", q.id = "__crossx-pin6-lock-msg", q.innerHTML = `${Rs}<span id="__crossx-pin6-lock-countdown"></span>`;
|
|
7350
7344
|
const D = d();
|
|
7351
7345
|
D ? D.insertAdjacentElement("afterend", q) : (W = x()) == null || W.appendChild(q);
|
|
7352
7346
|
}
|
|
7353
7347
|
const N = () => {
|
|
7354
7348
|
var k;
|
|
7355
|
-
const q =
|
|
7349
|
+
const q = b - Date.now(), D = m();
|
|
7356
7350
|
q <= 0 ? (clearInterval(G), E(!1), (k = h()) == null || k.remove(), P && (P.textContent = ""), setTimeout(() => {
|
|
7357
7351
|
var R;
|
|
7358
7352
|
return (R = c()[0]) == null ? void 0 : R.focus();
|
|
@@ -7365,17 +7359,17 @@ function ot(r, e, s, t, n, o) {
|
|
|
7365
7359
|
K.observe(document.body, { childList: !0, subtree: !1 });
|
|
7366
7360
|
}, B = async () => {
|
|
7367
7361
|
if (i || a) return;
|
|
7368
|
-
const
|
|
7369
|
-
if (
|
|
7362
|
+
const b = w();
|
|
7363
|
+
if (b.length === 6) {
|
|
7370
7364
|
a = !0, c().forEach((P) => {
|
|
7371
7365
|
P.disabled = !0;
|
|
7372
7366
|
});
|
|
7373
7367
|
try {
|
|
7374
7368
|
if (n) {
|
|
7375
|
-
const P = await n(
|
|
7376
|
-
P.ok ? e(
|
|
7369
|
+
const P = await n(b);
|
|
7370
|
+
P.ok ? e(b) : P.lockExpiresAt ? O(P.lockExpiresAt) : S(P.error ?? "Incorrect PIN. Please try again.");
|
|
7377
7371
|
} else
|
|
7378
|
-
e(
|
|
7372
|
+
e(b);
|
|
7379
7373
|
} catch (P) {
|
|
7380
7374
|
t && t(P);
|
|
7381
7375
|
} finally {
|
|
@@ -7386,24 +7380,24 @@ function ot(r, e, s, t, n, o) {
|
|
|
7386
7380
|
}
|
|
7387
7381
|
};
|
|
7388
7382
|
o && o > Date.now() ? O(o) : setTimeout(() => {
|
|
7389
|
-
var
|
|
7390
|
-
return (
|
|
7391
|
-
}, 100), c().forEach((
|
|
7392
|
-
|
|
7383
|
+
var b;
|
|
7384
|
+
return (b = c()[0]) == null ? void 0 : b.focus();
|
|
7385
|
+
}, 100), c().forEach((b, P) => {
|
|
7386
|
+
b.addEventListener("input", () => {
|
|
7393
7387
|
var G;
|
|
7394
|
-
const N =
|
|
7395
|
-
|
|
7396
|
-
}),
|
|
7388
|
+
const N = b.value.replace(/\D/g, "").slice(-1);
|
|
7389
|
+
b.value = N, y(), N && P < 5 && ((G = c()[P + 1]) == null || G.focus()), w().length === 6 && setTimeout(B, 80);
|
|
7390
|
+
}), b.addEventListener("keydown", (N) => {
|
|
7397
7391
|
var G, K;
|
|
7398
7392
|
if (N.key === "Backspace") {
|
|
7399
|
-
if (N.preventDefault(),
|
|
7400
|
-
|
|
7393
|
+
if (N.preventDefault(), b.value)
|
|
7394
|
+
b.value = "";
|
|
7401
7395
|
else if (P > 0) {
|
|
7402
7396
|
const W = c()[P - 1];
|
|
7403
7397
|
W.value = "", W.focus();
|
|
7404
7398
|
}
|
|
7405
7399
|
} else N.key === "ArrowLeft" && P > 0 ? (N.preventDefault(), (G = c()[P - 1]) == null || G.focus()) : N.key === "ArrowRight" && P < 5 ? (N.preventDefault(), (K = c()[P + 1]) == null || K.focus()) : N.key === "Escape" && s();
|
|
7406
|
-
}),
|
|
7400
|
+
}), b.addEventListener("paste", (N) => {
|
|
7407
7401
|
var W, q;
|
|
7408
7402
|
N.preventDefault();
|
|
7409
7403
|
const G = (((W = N.clipboardData) == null ? void 0 : W.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
|
|
@@ -7412,10 +7406,10 @@ function ot(r, e, s, t, n, o) {
|
|
|
7412
7406
|
G.split("").forEach((D, k) => {
|
|
7413
7407
|
K[k] && (K[k].value = D);
|
|
7414
7408
|
}), (q = K[Math.min(G.length - 1, 5)]) == null || q.focus(), y(), w().length === 6 && setTimeout(B, 80);
|
|
7415
|
-
}),
|
|
7409
|
+
}), b.addEventListener("focus", () => b.select());
|
|
7416
7410
|
});
|
|
7417
7411
|
}
|
|
7418
|
-
const
|
|
7412
|
+
const Rs = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7419
7413
|
<path d="M14.5 8.5H14V6.5C14 4.015 11.985 2 9.5 2C7.015 2 5 4.015 5 6.5V8.5H4.5C3.672 8.5 3 9.172 3 10V16.5C3 17.328 3.672 18 4.5 18H14.5C15.328 18 16 17.328 16 16.5V10C16 9.172 15.328 8.5 14.5 8.5ZM10.5 13.415V15C10.5 15.276 10.276 15.5 10 15.5H9C8.724 15.5 8.5 15.276 8.5 15V13.415C8.187 13.196 8 12.847 8 12.5C8 11.672 8.672 11 9.5 11C10.328 11 11 11.672 11 12.5C11 12.847 10.813 13.196 10.5 13.415ZM12.5 8.5H6.5V6.5C6.5 4.843 7.843 3.5 9.5 3.5C11.157 3.5 12.5 4.843 12.5 6.5V8.5Z" fill="currentColor"/>
|
|
7420
7414
|
</svg>`, Vn = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7421
7415
|
<path d="M1 4.5L4 7.5L10 1" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -7610,8 +7604,8 @@ class jn {
|
|
|
7610
7604
|
x.innerHTML = nt({
|
|
7611
7605
|
title: i.title,
|
|
7612
7606
|
headerSubtitle: i.headerSubtitle
|
|
7613
|
-
}), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), ot(x, (
|
|
7614
|
-
|
|
7607
|
+
}), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), ot(x, (b) => {
|
|
7608
|
+
b === O ? h(O) : y(o.mismatchError);
|
|
7615
7609
|
}, m);
|
|
7616
7610
|
}, y = (O) => {
|
|
7617
7611
|
var B;
|
|
@@ -7620,42 +7614,42 @@ class jn {
|
|
|
7620
7614
|
headerSubtitle: o.headerSubtitle,
|
|
7621
7615
|
subtitle: o.subtitle,
|
|
7622
7616
|
errorMessage: O
|
|
7623
|
-
}), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), ot(x, (
|
|
7624
|
-
const P = Wn(
|
|
7625
|
-
P ? y(P) : E(
|
|
7617
|
+
}), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), ot(x, (b) => {
|
|
7618
|
+
const P = Wn(b, w);
|
|
7619
|
+
P ? y(P) : E(b);
|
|
7626
7620
|
}, m);
|
|
7627
7621
|
};
|
|
7628
7622
|
(() => {
|
|
7629
7623
|
var q;
|
|
7630
|
-
const O = Array.from(x.querySelectorAll(".__crossx-pw-notice-item")), B = x.querySelector("#__crossx-pin-notice-next"),
|
|
7624
|
+
const O = Array.from(x.querySelectorAll(".__crossx-pw-notice-item")), B = x.querySelector("#__crossx-pin-notice-next"), b = /* @__PURE__ */ new Set();
|
|
7631
7625
|
B.removeAttribute("disabled");
|
|
7632
7626
|
const P = B.dataset.nextLabel ?? "Next", N = B.dataset.submitLabel ?? "I Understand", G = () => {
|
|
7633
|
-
const D =
|
|
7627
|
+
const D = b.size === O.length;
|
|
7634
7628
|
B.classList.toggle("--disabled", !D), B.textContent = D ? N : P;
|
|
7635
7629
|
}, K = (D, k) => {
|
|
7636
|
-
if (
|
|
7630
|
+
if (b.has(k)) return;
|
|
7637
7631
|
const R = D.querySelector(`#__crossx-notice-check-${k}`);
|
|
7638
|
-
|
|
7632
|
+
b.add(k), R.classList.add("--checked"), D.setAttribute("aria-checked", "true"), G();
|
|
7639
7633
|
}, W = (D, k) => {
|
|
7640
|
-
if (!
|
|
7634
|
+
if (!b.has(k)) return;
|
|
7641
7635
|
const R = D.querySelector(`#__crossx-notice-check-${k}`);
|
|
7642
|
-
|
|
7636
|
+
b.delete(k), R.classList.remove("--checked"), D.setAttribute("aria-checked", "false"), G();
|
|
7643
7637
|
};
|
|
7644
7638
|
O.forEach((D) => {
|
|
7645
7639
|
const k = parseInt(D.dataset.checkIndex ?? "0", 10);
|
|
7646
7640
|
D.addEventListener("click", () => {
|
|
7647
|
-
|
|
7641
|
+
b.has(k) ? W(D, k) : K(D, k);
|
|
7648
7642
|
}), D.addEventListener("keydown", (R) => {
|
|
7649
|
-
(R.key === " " || R.key === "Enter") && (R.preventDefault(),
|
|
7643
|
+
(R.key === " " || R.key === "Enter") && (R.preventDefault(), b.has(k) ? W(D, k) : K(D, k));
|
|
7650
7644
|
});
|
|
7651
7645
|
}), B.addEventListener("click", () => {
|
|
7652
|
-
if (
|
|
7646
|
+
if (b.size === O.length) {
|
|
7653
7647
|
y(e == null ? void 0 : e.errorMessage);
|
|
7654
7648
|
return;
|
|
7655
7649
|
}
|
|
7656
7650
|
const D = O.find((R) => {
|
|
7657
7651
|
const f = parseInt(R.dataset.checkIndex ?? "0", 10);
|
|
7658
|
-
return !
|
|
7652
|
+
return !b.has(f);
|
|
7659
7653
|
});
|
|
7660
7654
|
if (!D) return;
|
|
7661
7655
|
const k = parseInt(D.dataset.checkIndex ?? "0", 10);
|
|
@@ -7801,7 +7795,7 @@ class jn {
|
|
|
7801
7795
|
document.addEventListener("keydown", l);
|
|
7802
7796
|
};
|
|
7803
7797
|
s.then((l) => {
|
|
7804
|
-
i || (
|
|
7798
|
+
i || (Nn(n, l, this.tokens), c());
|
|
7805
7799
|
});
|
|
7806
7800
|
});
|
|
7807
7801
|
}
|
|
@@ -7810,7 +7804,7 @@ class jn {
|
|
|
7810
7804
|
var c, l, d;
|
|
7811
7805
|
ue();
|
|
7812
7806
|
let t;
|
|
7813
|
-
e.type === "sign-message" ? t =
|
|
7807
|
+
e.type === "sign-message" ? t = Rn(e, this.tokens) : e.type === "sign-typed-data" ? t = Cn(e, this.tokens) : e.type === "sign" ? t = In(e, this.tokens) : t = En(e, this.tokens), document.body.appendChild(t);
|
|
7814
7808
|
const n = () => t.remove(), o = () => {
|
|
7815
7809
|
n(), s(!0);
|
|
7816
7810
|
}, i = () => {
|
|
@@ -7851,38 +7845,38 @@ class Yn {
|
|
|
7851
7845
|
return this._accessToken !== null;
|
|
7852
7846
|
}
|
|
7853
7847
|
}
|
|
7854
|
-
function Qn(r) {
|
|
7848
|
+
function Qn(r, e) {
|
|
7855
7849
|
r.debug;
|
|
7856
|
-
const
|
|
7850
|
+
const s = We.production, t = {
|
|
7857
7851
|
...r,
|
|
7858
|
-
oauthServiceUrl:
|
|
7859
|
-
authApiUrl:
|
|
7860
|
-
walletGatewayUrl:
|
|
7861
|
-
},
|
|
7862
|
-
gatewayUrl:
|
|
7852
|
+
oauthServiceUrl: s.oauthServiceUrl,
|
|
7853
|
+
authApiUrl: s.authApiUrl,
|
|
7854
|
+
walletGatewayUrl: s.walletGatewayUrl
|
|
7855
|
+
}, n = {
|
|
7856
|
+
gatewayUrl: s.walletGatewayUrl,
|
|
7863
7857
|
projectId: r.projectId
|
|
7864
|
-
},
|
|
7865
|
-
let
|
|
7866
|
-
r.useMockWallet ? (u.log("[CROSSx] Mock Wallet Provider 사용"),
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7858
|
+
}, i = t.authMode !== "cookie" && Nt.isAvailable() ? new Nt() : new sr(), a = new un(), c = new fn(), l = new be(), d = new Yn(), h = new Xt();
|
|
7859
|
+
let m;
|
|
7860
|
+
r.useMockWallet ? (u.log("[CROSSx] Mock Wallet Provider 사용"), m = new _n(i, h)) : (u.log("[CROSSx] Remote Wallet Provider 사용"), m = new Le(
|
|
7861
|
+
n,
|
|
7862
|
+
i,
|
|
7863
|
+
c,
|
|
7864
|
+
d,
|
|
7865
|
+
h
|
|
7872
7866
|
));
|
|
7873
|
-
const
|
|
7867
|
+
const x = new De(n, c), w = new jn(r.theme ?? "light", r.themeTokens), E = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w;
|
|
7874
7868
|
return new it(
|
|
7875
|
-
s,
|
|
7876
7869
|
t,
|
|
7877
|
-
|
|
7870
|
+
n,
|
|
7878
7871
|
i,
|
|
7879
7872
|
a,
|
|
7880
7873
|
c,
|
|
7881
|
-
h,
|
|
7882
7874
|
l,
|
|
7883
|
-
x,
|
|
7884
7875
|
m,
|
|
7885
|
-
d
|
|
7876
|
+
d,
|
|
7877
|
+
E,
|
|
7878
|
+
x,
|
|
7879
|
+
h
|
|
7886
7880
|
);
|
|
7887
7881
|
}
|
|
7888
7882
|
export {
|