@nexus-cross/crossx-sdk-core 1.2.7 → 1.2.8-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 +4 -1
- package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts.map +1 -1
- package/dist/core/ports/ConfirmationPort.d.ts +4 -1
- package/dist/core/ports/ConfirmationPort.d.ts.map +1 -1
- package/dist/core/types/index.d.ts +11 -0
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/crossx.global +13 -13
- package/dist/index.cjs +22 -22
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +546 -541
- package/dist/sdk/CROSSxSDK.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -171,7 +171,7 @@ let Ee = null;
|
|
|
171
171
|
function vt(r) {
|
|
172
172
|
Ee = r;
|
|
173
173
|
}
|
|
174
|
-
const
|
|
174
|
+
const d = {
|
|
175
175
|
log(...r) {
|
|
176
176
|
if (Ee) {
|
|
177
177
|
Ee.log(...r);
|
|
@@ -365,55 +365,55 @@ class qs {
|
|
|
365
365
|
const c = e == null ? void 0 : e.provider;
|
|
366
366
|
let l = "/login";
|
|
367
367
|
c === "google" ? l = "/google" : c === "apple" && (l = "/apple");
|
|
368
|
-
const { oauthServiceUrl:
|
|
369
|
-
|
|
370
|
-
const
|
|
368
|
+
const { oauthServiceUrl: u, authApiUrl: h } = this.config, m = `${u}${l}`;
|
|
369
|
+
d.log(`[CROSSx] OAuth 팝업 열기 (${c || "일반"} 로그인)`);
|
|
370
|
+
const _ = await this.oauth.openAuth({
|
|
371
371
|
authUrl: m,
|
|
372
|
-
expectedOrigin: new URL(
|
|
372
|
+
expectedOrigin: new URL(u).origin
|
|
373
373
|
});
|
|
374
|
-
|
|
375
|
-
const { accessToken: w, refreshToken:
|
|
376
|
-
let y,
|
|
374
|
+
d.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", _.length, ")");
|
|
375
|
+
const { accessToken: w, refreshToken: S } = await this.exchangeFirebaseToken(_, h);
|
|
376
|
+
let y, E;
|
|
377
377
|
try {
|
|
378
|
-
const B = this.crypto.decodeJWT(
|
|
379
|
-
|
|
378
|
+
const B = this.crypto.decodeJWT(_);
|
|
379
|
+
E = (n = B.firebase) == null ? void 0 : n.sign_in_provider;
|
|
380
380
|
const b = ((o = B.firebase) == null ? void 0 : o.identities) ?? {};
|
|
381
|
-
|
|
381
|
+
E === "google.com" ? y = (i = b["google.com"]) == null ? void 0 : i[0] : E === "apple.com" && (y = (a = b["apple.com"]) == null ? void 0 : a[0]), d.log("[CROSSx] OAuth provider sub 추출 — provider:", E, "hasProviderSub:", !!y);
|
|
382
382
|
} catch {
|
|
383
|
-
|
|
383
|
+
d.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
|
|
384
384
|
}
|
|
385
385
|
if (w) {
|
|
386
386
|
const B = this.crypto.decodeJWT(w);
|
|
387
|
-
|
|
387
|
+
d.log("[CROSSx] access_token 디코딩 — sub:", B.sub, "exp:", B.exp);
|
|
388
388
|
const b = await this.crypto.verifyJWT(w);
|
|
389
389
|
if (t = b.signatureVerified ?? !1, !b.valid)
|
|
390
|
-
throw
|
|
390
|
+
throw d.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
|
|
391
391
|
const k = b.payload;
|
|
392
392
|
s = {
|
|
393
393
|
id: k.sub,
|
|
394
394
|
email: k.email,
|
|
395
|
-
signInProvider:
|
|
395
|
+
signInProvider: E,
|
|
396
396
|
providerSub: y
|
|
397
|
-
}, this.tokenStore.set(w), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, w),
|
|
397
|
+
}, this.tokenStore.set(w), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, w), S && this.config.secureStorageAvailable !== !1 ? await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, S) : S && d.warn("[CROSSx] 안전한 스토리지 미사용 — refresh_token 영속 저장을 건너뜁니다"));
|
|
398
398
|
} else {
|
|
399
|
-
const B = this.crypto.decodeJWT(
|
|
399
|
+
const B = this.crypto.decodeJWT(_);
|
|
400
400
|
s = {
|
|
401
401
|
id: B.sub,
|
|
402
402
|
email: B.email,
|
|
403
|
-
signInProvider:
|
|
403
|
+
signInProvider: E,
|
|
404
404
|
providerSub: y
|
|
405
|
-
},
|
|
405
|
+
}, d.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
|
|
406
406
|
}
|
|
407
|
-
|
|
407
|
+
d.log("[CROSSx] 사용자 정보 — id:", s.id);
|
|
408
408
|
const C = this.useCookieAuth ? { id: s.id, signInProvider: s.signInProvider, providerSub: s.providerSub } : s;
|
|
409
|
-
await this.storage.set(this.STORAGE_KEY_USER, C),
|
|
409
|
+
await this.storage.set(this.STORAGE_KEY_USER, C), d.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
|
|
410
410
|
} catch (c) {
|
|
411
|
-
return
|
|
411
|
+
return d.error("[CROSSx] SignIn 에러 (OAuth/토큰 교환 단계):", c), {
|
|
412
412
|
success: !1,
|
|
413
413
|
error: c instanceof Error ? c.message : "Sign in failed"
|
|
414
414
|
};
|
|
415
415
|
}
|
|
416
|
-
return
|
|
416
|
+
return d.log("[CROSSx][Migration Phase 1] OAuth 로그인 완료, 지갑 로드 시작 — userId:", s.id), this.loadWallet(s, t);
|
|
417
417
|
}
|
|
418
418
|
/**
|
|
419
419
|
* Firebase 토큰 → CROSSx 인증 교환
|
|
@@ -422,7 +422,7 @@ class qs {
|
|
|
422
422
|
*/
|
|
423
423
|
async exchangeFirebaseToken(e, s) {
|
|
424
424
|
const t = this.useCookieAuth, n = t ? `${s}/cross-auth/social/login/cookie` : `${s}/cross-auth/social/login`;
|
|
425
|
-
|
|
425
|
+
d.log("[CROSSx] Firebase 토큰 교환 요청");
|
|
426
426
|
const o = await this.transport.request({
|
|
427
427
|
url: n,
|
|
428
428
|
method: "POST",
|
|
@@ -430,18 +430,18 @@ class qs {
|
|
|
430
430
|
body: { auth_code: e, login_type: "firebase" },
|
|
431
431
|
...t ? { credentials: "include" } : {}
|
|
432
432
|
});
|
|
433
|
-
|
|
433
|
+
d.log("[CROSSx] 토큰 교환 응답 — status:", o.status);
|
|
434
434
|
const i = o.data;
|
|
435
435
|
this.checkResponseError(i, "Token exchange");
|
|
436
436
|
const a = this.extractAccessToken(i);
|
|
437
437
|
if (t && !a)
|
|
438
|
-
return
|
|
438
|
+
return d.log("[CROSSx] Cookie 모드 — 로그인 성공 (JWT는 HttpOnly 쿠키)"), {};
|
|
439
439
|
if (!a)
|
|
440
440
|
throw new g(
|
|
441
441
|
p.AUTH_FAILED,
|
|
442
442
|
"토큰 교환 응답에서 access_token을 찾을 수 없습니다"
|
|
443
443
|
);
|
|
444
|
-
|
|
444
|
+
d.log("[CROSSx] access_token 교환 성공");
|
|
445
445
|
let c;
|
|
446
446
|
return t || (c = this.extractRefreshToken(i)), { accessToken: a, refreshToken: c };
|
|
447
447
|
}
|
|
@@ -504,38 +504,38 @@ class qs {
|
|
|
504
504
|
if (t.valid) {
|
|
505
505
|
const n = await this.storage.get(this.STORAGE_KEY_USER);
|
|
506
506
|
if (n)
|
|
507
|
-
return
|
|
507
|
+
return d.log("[CROSSx] restoreSession — 메모리 토큰 유효, 세션 복원"), this.loadWallet(n, t.signatureVerified);
|
|
508
508
|
}
|
|
509
509
|
this.tokenStore.clear();
|
|
510
510
|
}
|
|
511
511
|
if (this.useCookieAuth) {
|
|
512
|
-
|
|
512
|
+
d.log("[CROSSx] restoreSession — 쿠키 기반 silentRefresh 시도");
|
|
513
513
|
const t = await this.silentRefresh();
|
|
514
514
|
t && this.tokenStore.set(t);
|
|
515
515
|
} else {
|
|
516
516
|
const t = await this.storage.get(this.STORAGE_KEY_ACCESS_TOKEN), n = await this.storage.get(this.STORAGE_KEY_REFRESH_TOKEN);
|
|
517
|
-
if (
|
|
517
|
+
if (d.log(
|
|
518
518
|
"[CROSSx] restoreSession — access_token:",
|
|
519
519
|
t ? "있음" : "없음",
|
|
520
520
|
"refresh_token:",
|
|
521
521
|
n ? "있음" : "없음"
|
|
522
522
|
), !n)
|
|
523
|
-
return
|
|
523
|
+
return d.log("[CROSSx] restoreSession — refresh_token 없음, 세션 복원 생략"), null;
|
|
524
524
|
t && this.tokenStore.set(t);
|
|
525
525
|
const o = await this.silentRefresh(n);
|
|
526
|
-
|
|
526
|
+
d.log("[CROSSx] restoreSession — silentRefresh 결과:", o ? "토큰 발급 성공" : "토큰 없음"), o && this.tokenStore.set(o);
|
|
527
527
|
}
|
|
528
528
|
const s = await this.storage.get(this.STORAGE_KEY_USER);
|
|
529
|
-
if (
|
|
529
|
+
if (d.log("[CROSSx] restoreSession — userInfo 조회:", s ? `있음 (id: ${s.id})` : "없음"), !s)
|
|
530
530
|
return null;
|
|
531
|
-
|
|
531
|
+
d.log("[CROSSx] restoreSession — silentRefresh 성공, 세션 복원 — userId:", s.id);
|
|
532
532
|
try {
|
|
533
533
|
return await this.loadWallet(s, !1);
|
|
534
534
|
} catch (t) {
|
|
535
|
-
return
|
|
535
|
+
return d.warn("[CROSSx] restoreSession — 지갑 로드 실패 (세션은 유지):", t), { success: !0, user: s, tokenSignatureVerified: !1 };
|
|
536
536
|
}
|
|
537
537
|
} catch (e) {
|
|
538
|
-
return
|
|
538
|
+
return d.log("[CROSSx] restoreSession — 세션 복원 실패, 스토리지 정리:", e), this.tokenStore.clear(), this.useCookieAuth || await this.storage.remove(this.STORAGE_KEY_REFRESH_TOKEN), await this.storage.remove(this.STORAGE_KEY_USER), null;
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
541
|
silentRefresh(e) {
|
|
@@ -556,12 +556,12 @@ class qs {
|
|
|
556
556
|
body: o,
|
|
557
557
|
...t ? { credentials: "include" } : {}
|
|
558
558
|
});
|
|
559
|
-
|
|
559
|
+
d.log("[CROSSx] silentRefresh 응답 — status:", i.status);
|
|
560
560
|
const a = i.data;
|
|
561
561
|
this.checkResponseError(a, "Silent refresh");
|
|
562
562
|
const c = this.extractAccessToken(a);
|
|
563
563
|
if (t && !c) {
|
|
564
|
-
|
|
564
|
+
d.log("[CROSSx] silentRefresh 성공 (cookie 갱신)");
|
|
565
565
|
return;
|
|
566
566
|
}
|
|
567
567
|
if (!c)
|
|
@@ -571,7 +571,7 @@ class qs {
|
|
|
571
571
|
const l = this.extractRefreshToken(a);
|
|
572
572
|
l && this.config.secureStorageAvailable !== !1 && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, l);
|
|
573
573
|
}
|
|
574
|
-
return
|
|
574
|
+
return d.log("[CROSSx] silentRefresh 성공"), c;
|
|
575
575
|
}
|
|
576
576
|
/**
|
|
577
577
|
* 외부에서 발급된 CROSSx JWT를 직접 주입하여 로그인합니다.
|
|
@@ -588,22 +588,22 @@ class qs {
|
|
|
588
588
|
let o = await this.crypto.verifyJWT(e);
|
|
589
589
|
if (n = o.signatureVerified ?? !1, !o.valid) {
|
|
590
590
|
if (!s)
|
|
591
|
-
return
|
|
592
|
-
|
|
591
|
+
return d.error("[CROSSx] signInWithJWT: access_token 검증 실패, refreshToken 없음"), { success: !1, error: "유효하지 않은 access token" };
|
|
592
|
+
d.log("[CROSSx] signInWithJWT: access_token 만료, refreshToken으로 갱신 시도");
|
|
593
593
|
const a = await this.silentRefresh(s);
|
|
594
594
|
if (!a)
|
|
595
|
-
return
|
|
595
|
+
return d.error("[CROSSx] signInWithJWT: silentRefresh 실패"), { success: !1, error: "access token이 만료되었고 갱신에 실패했습니다" };
|
|
596
596
|
if (e = a, o = await this.crypto.verifyJWT(e), n = o.signatureVerified ?? !1, !o.valid)
|
|
597
|
-
return
|
|
598
|
-
|
|
597
|
+
return d.error("[CROSSx] signInWithJWT: 갱신된 access_token도 유효하지 않음"), { success: !1, error: "갱신된 access token이 유효하지 않습니다" };
|
|
598
|
+
d.log("[CROSSx] signInWithJWT: silentRefresh 성공, 새 access_token 사용");
|
|
599
599
|
}
|
|
600
600
|
const i = o.payload;
|
|
601
|
-
|
|
601
|
+
d.log("[CROSSx] signInWithJWT — sub:", i.sub, "signatureVerified:", n), t = {
|
|
602
602
|
id: i.sub,
|
|
603
603
|
email: i.email
|
|
604
|
-
}, this.tokenStore.set(e), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, e), s && this.config.secureStorageAvailable !== !1 && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, s)), await this.storage.set(this.STORAGE_KEY_USER, t),
|
|
604
|
+
}, this.tokenStore.set(e), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, e), s && this.config.secureStorageAvailable !== !1 && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, s)), await this.storage.set(this.STORAGE_KEY_USER, t), d.log("[CROSSx] signInWithJWT — 토큰 및 사용자 정보 저장 완료");
|
|
605
605
|
} catch (o) {
|
|
606
|
-
return
|
|
606
|
+
return d.error("[CROSSx] signInWithJWT 에러:", o), {
|
|
607
607
|
success: !1,
|
|
608
608
|
error: o instanceof Error ? o.message : "JWT sign in failed"
|
|
609
609
|
};
|
|
@@ -624,9 +624,9 @@ class qs {
|
|
|
624
624
|
const t = await this.storage.get(Et);
|
|
625
625
|
t && await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, t);
|
|
626
626
|
const n = await this.storage.get(It);
|
|
627
|
-
n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(At), await this.storage.remove(Et), await this.storage.remove(It),
|
|
627
|
+
n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(At), await this.storage.remove(Et), await this.storage.remove(It), d.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
|
|
628
628
|
} catch (e) {
|
|
629
|
-
|
|
629
|
+
d.warn("[CROSSx] 스토리지 키 마이그레이션 실패:", e);
|
|
630
630
|
}
|
|
631
631
|
}
|
|
632
632
|
}
|
|
@@ -634,29 +634,29 @@ class qs {
|
|
|
634
634
|
let t, n = !1;
|
|
635
635
|
try {
|
|
636
636
|
if (typeof this.walletProvider.checkWallet == "function") {
|
|
637
|
-
|
|
637
|
+
d.log("[CROSSx] GET /mnemonic/check — 지갑 상태 확인 (비밀번호 불필요)");
|
|
638
638
|
const o = await this.walletProvider.checkWallet();
|
|
639
|
-
if (
|
|
640
|
-
|
|
639
|
+
if (d.log("[CROSSx] 지갑 상태:", o), o === "migration_required")
|
|
640
|
+
d.log("[CROSSx] migration_required → needsMigration = true"), n = !0;
|
|
641
641
|
else if (o === "exists")
|
|
642
642
|
try {
|
|
643
643
|
const i = await this.walletProvider.getAddresses(e.id);
|
|
644
|
-
i.length > 0 ? (t = i[0].address,
|
|
644
|
+
i.length > 0 ? (t = i[0].address, d.log("[CROSSx] 캐시된 주소 로드 완료 (비밀번호 불필요):", t)) : d.log("[CROSSx] 주소 캐시 없음 — createWallet 단계에서 비밀번호 입력 후 로드");
|
|
645
645
|
} catch (i) {
|
|
646
|
-
|
|
646
|
+
d.warn("[CROSSx] getAddresses 실패, createWallet 단계에서 재시도:", i);
|
|
647
647
|
}
|
|
648
648
|
} else
|
|
649
|
-
|
|
649
|
+
d.log("[CROSSx] getOrCreateWallet 직접 호출 (폴백)"), t = (await this.walletProvider.getOrCreateWallet(e.id)).address, d.log("[CROSSx] 지갑 로드 완료 — address:", t);
|
|
650
650
|
} catch (o) {
|
|
651
651
|
if (o instanceof g && o.code === p.MIGRATION_BACKUP_EXISTS)
|
|
652
|
-
|
|
652
|
+
d.log("[CROSSx] MIGRATION_BACKUP_EXISTS 감지 → needsMigration = true"), n = !0;
|
|
653
653
|
else {
|
|
654
654
|
if (o instanceof g && (o.code === p.PROJECT_NOT_REGISTERED || o.code === p.PROJECT_ID_MISSING || o.code === p.ORIGIN_NOT_ALLOWED))
|
|
655
|
-
throw
|
|
656
|
-
|
|
655
|
+
throw d.error("[CROSSx] 프로젝트 설정 에러:", o.message), o;
|
|
656
|
+
d.warn("[CROSSx] 지갑 상태 확인 실패 (로그인은 유지):", o);
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
|
-
return
|
|
659
|
+
return d.log("[CROSSx] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
|
|
660
660
|
}
|
|
661
661
|
}
|
|
662
662
|
class Ks {
|
|
@@ -679,9 +679,9 @@ class Vs {
|
|
|
679
679
|
p.NOT_IMPLEMENTED,
|
|
680
680
|
"현재 환경에서는 마이그레이션이 지원되지 않습니다"
|
|
681
681
|
);
|
|
682
|
-
|
|
682
|
+
d.log("[CROSSx][Migration Phase 4] MigrateWalletUseCase.execute() — pin 길이:", e.length, "sub:", s);
|
|
683
683
|
const t = await this.walletProvider.migrateWallet(e, s);
|
|
684
|
-
return
|
|
684
|
+
return d.log("[CROSSx][Migration Phase 5] MigrateWalletUseCase 완료 — address:", t.address), {
|
|
685
685
|
address: t.address
|
|
686
686
|
};
|
|
687
687
|
}
|
|
@@ -820,9 +820,9 @@ function Js() {
|
|
|
820
820
|
return Ge.production;
|
|
821
821
|
}
|
|
822
822
|
const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA00", kt = 130, Pt = 6, Nt = 18, tr = 5 * 60 * 1e3, sr = 30 * 1e3, re = class re extends js {
|
|
823
|
-
constructor(e, s, t, n, o, i, a, c, l,
|
|
823
|
+
constructor(e, s, t, n, o, i, a, c, l, u, h) {
|
|
824
824
|
var m;
|
|
825
|
-
super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this._initPromise = null, this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._verifyPinMutex = null, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && vt(e.logger), this.confirmation = l, this.pinStore = h ?? new es(), this.chainRegistry =
|
|
825
|
+
super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this._initPromise = null, this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._verifyPinMutex = null, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && vt(e.logger), this.confirmation = l, this.pinStore = h ?? new es(), this.chainRegistry = u, this.jsonRpc = new zs(u, o), this.signInUseCase = new qs(
|
|
826
826
|
this.internalConfig,
|
|
827
827
|
t,
|
|
828
828
|
n,
|
|
@@ -856,7 +856,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
856
856
|
}
|
|
857
857
|
async _doInitialize(e) {
|
|
858
858
|
var s, t;
|
|
859
|
-
|
|
859
|
+
d.log("[CROSSx SDK] v1.2.8 초기화 중..."), this.confirmation.setMessages(St(this._config.locale));
|
|
860
860
|
try {
|
|
861
861
|
const n = Js();
|
|
862
862
|
this.internalConfig.oauthServiceUrl = n.oauthServiceUrl, this.internalConfig.authApiUrl = n.authApiUrl, this.internalConfig.walletGatewayUrl = n.walletGatewayUrl, this.adapterConfig.gatewayUrl = n.walletGatewayUrl, (t = (s = this.crypto).setJWKSEndpoint) == null || t.call(s, `${n.authApiUrl}/.well-known/jwks.json`);
|
|
@@ -868,7 +868,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
868
868
|
} catch (i) {
|
|
869
869
|
if (!(i instanceof g && i.code === p.PIN_CANCELLED))
|
|
870
870
|
throw i;
|
|
871
|
-
|
|
871
|
+
d.log("[CROSSx] initialize: 비밀번호 입력 취소 — 지갑 미로드 상태로 계속");
|
|
872
872
|
}
|
|
873
873
|
}
|
|
874
874
|
return this.initialized = !0, this.emit("initialized", { restored: !!(o != null && o.success) }), o ?? null;
|
|
@@ -924,8 +924,8 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
924
924
|
const t = await this.getAddresses(), n = await this.selectWalletIfMultiple(t);
|
|
925
925
|
return { ...s, address: (n == null ? void 0 : n.address) ?? s.address, addresses: t };
|
|
926
926
|
} catch (t) {
|
|
927
|
-
throw t instanceof g && t.code === p.PIN_CANCELLED && (
|
|
928
|
-
(n) =>
|
|
927
|
+
throw t instanceof g && t.code === p.PIN_CANCELLED && (d.log("[CROSSx] signInWithCreate: 비밀번호 설정 취소 — 자동 로그아웃 진행"), await this.signOut().catch(
|
|
928
|
+
(n) => d.warn("[CROSSx] signInWithCreate: 자동 로그아웃 실패", n)
|
|
929
929
|
)), t;
|
|
930
930
|
}
|
|
931
931
|
}
|
|
@@ -1027,7 +1027,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1027
1027
|
try {
|
|
1028
1028
|
await this.loadWalletAfterAuth();
|
|
1029
1029
|
} catch (s) {
|
|
1030
|
-
s instanceof g && s.code === p.PIN_CANCELLED ||
|
|
1030
|
+
s instanceof g && s.code === p.PIN_CANCELLED || d.warn("[CROSSx] ensureLoggedIn: loadWalletAfterAuth 실패:", s);
|
|
1031
1031
|
}
|
|
1032
1032
|
return !0;
|
|
1033
1033
|
}
|
|
@@ -1070,7 +1070,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1070
1070
|
throw new g(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1071
1071
|
try {
|
|
1072
1072
|
const s = await this.migrateWalletUseCase.execute(e, this.userId);
|
|
1073
|
-
return this.address = s.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: s.address, index: 0 }),
|
|
1073
|
+
return this.address = s.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: s.address, index: 0 }), d.log("[CROSSx] migrateWallet 완료 — address:", s.address), s;
|
|
1074
1074
|
} catch (s) {
|
|
1075
1075
|
throw s instanceof g ? s : new g(
|
|
1076
1076
|
p.MIGRATION_FAILED,
|
|
@@ -1239,11 +1239,11 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1239
1239
|
async createWallet() {
|
|
1240
1240
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1241
1241
|
throw new g(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1242
|
-
|
|
1242
|
+
d.log("[CROSSx] createWallet 시작");
|
|
1243
1243
|
const e = await this.fetchWalletStatus();
|
|
1244
|
-
if (
|
|
1244
|
+
if (d.log("[CROSSx] 지갑 상태:", e), e === "migration_required") {
|
|
1245
1245
|
const s = this.providerSub ?? this.userId;
|
|
1246
|
-
|
|
1246
|
+
d.log("[CROSSx] migration_required → 마이그레이션 UI 시작 — sub:", s);
|
|
1247
1247
|
const t = await this.handleMigrationFlow(s);
|
|
1248
1248
|
if (t)
|
|
1249
1249
|
return this.address = t.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: t.address, index: 0 }), { address: t.address };
|
|
@@ -1258,11 +1258,11 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1258
1258
|
const s = await this.withPinRetry(
|
|
1259
1259
|
() => this.walletProvider.getOrCreateWallet(this.userId)
|
|
1260
1260
|
);
|
|
1261
|
-
return this.address = s.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: s.address, index: 0 }),
|
|
1261
|
+
return this.address = s.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: s.address, index: 0 }), d.log("[CROSSx] 지갑 준비 완료:", s.address), { address: s.address };
|
|
1262
1262
|
} catch (s) {
|
|
1263
1263
|
if (s instanceof g && s.code === p.MIGRATION_BACKUP_EXISTS) {
|
|
1264
1264
|
const t = this.providerSub ?? this.userId;
|
|
1265
|
-
|
|
1265
|
+
d.log("[CROSSx] MIGRATION_BACKUP_EXISTS (폴백) → 마이그레이션 UI 시작");
|
|
1266
1266
|
const n = await this.handleMigrationFlow(t);
|
|
1267
1267
|
if (n)
|
|
1268
1268
|
return this.address = n.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: n.address, index: 0 }), { address: n.address };
|
|
@@ -1277,11 +1277,11 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1277
1277
|
await this.ensurePinSetup();
|
|
1278
1278
|
try {
|
|
1279
1279
|
const s = await this.walletProvider.getOrCreateWallet(this.userId);
|
|
1280
|
-
return this.address = s.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: s.address, index: 0 }),
|
|
1280
|
+
return this.address = s.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: s.address, index: 0 }), d.log("[CROSSx] 지갑 준비 완료:", s.address), { address: s.address };
|
|
1281
1281
|
} catch (s) {
|
|
1282
1282
|
if (s instanceof g && s.code === p.MIGRATION_BACKUP_EXISTS) {
|
|
1283
1283
|
const t = this.providerSub ?? this.userId;
|
|
1284
|
-
|
|
1284
|
+
d.log("[CROSSx] MIGRATION_BACKUP_EXISTS (폴백) → 마이그레이션 UI 시작");
|
|
1285
1285
|
const n = await this.handleMigrationFlow(t);
|
|
1286
1286
|
if (n)
|
|
1287
1287
|
return this.address = n.address, this.activeWalletIndex = 0, this.emit("addressChanged", { address: n.address, index: 0 }), { address: n.address };
|
|
@@ -1299,7 +1299,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1299
1299
|
try {
|
|
1300
1300
|
return await this.walletProvider.checkWallet();
|
|
1301
1301
|
} catch (e) {
|
|
1302
|
-
return
|
|
1302
|
+
return d.warn("[CROSSx] checkWallet 실패 (폴백: not_found 처리):", e), "not_found";
|
|
1303
1303
|
}
|
|
1304
1304
|
return null;
|
|
1305
1305
|
}
|
|
@@ -1569,7 +1569,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1569
1569
|
for (; Date.now() < a; ) {
|
|
1570
1570
|
const l = await this.getTransactionReceipt(e, s);
|
|
1571
1571
|
if (l) return l;
|
|
1572
|
-
await new Promise((
|
|
1572
|
+
await new Promise((u) => setTimeout(u, c)), c = Math.min(c * 2, o);
|
|
1573
1573
|
}
|
|
1574
1574
|
throw new g(
|
|
1575
1575
|
p.UNKNOWN_ERROR,
|
|
@@ -1592,36 +1592,36 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1592
1592
|
* logger.log(receipt.status); // '0x1' | '0x0'
|
|
1593
1593
|
*/
|
|
1594
1594
|
async sendTransactionWithWaitForReceipt(e, s, t = {}) {
|
|
1595
|
-
var
|
|
1596
|
-
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((
|
|
1597
|
-
let m,
|
|
1598
|
-
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((
|
|
1599
|
-
m =
|
|
1600
|
-
const C = BigInt(
|
|
1595
|
+
var S, y;
|
|
1596
|
+
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((S = this._config.receiptPolling) == null ? void 0 : S.intervalMs) ?? Xs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? Tt, u = Je(e), h = s.from ?? "";
|
|
1597
|
+
let m, _;
|
|
1598
|
+
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((E) => {
|
|
1599
|
+
m = E;
|
|
1600
|
+
const C = BigInt(E.gasUsed) * BigInt(E.effectiveGasPrice), B = s.value ? BigInt(s.value) : 0n, b = re.formatTxAmount(s.value, u.symbol, u.decimals), k = re.formatTxAmount("0x" + C.toString(16), u.symbol, u.decimals), P = re.formatTxAmount("0x" + (B + C).toString(16), u.symbol, u.decimals);
|
|
1601
1601
|
return {
|
|
1602
1602
|
chainId: e,
|
|
1603
1603
|
txHash: a,
|
|
1604
|
-
from:
|
|
1605
|
-
to:
|
|
1604
|
+
from: E.from,
|
|
1605
|
+
to: E.to ?? s.to,
|
|
1606
1606
|
amount: b,
|
|
1607
1607
|
fees: k,
|
|
1608
1608
|
total: P,
|
|
1609
|
-
nativeSymbol:
|
|
1610
|
-
status:
|
|
1609
|
+
nativeSymbol: u.symbol,
|
|
1610
|
+
status: E.status === "0x1" ? "success" : "reverted"
|
|
1611
1611
|
};
|
|
1612
|
-
}).catch((
|
|
1612
|
+
}).catch((E) => (_ = E instanceof Error ? E : new Error(String(E)), {
|
|
1613
1613
|
chainId: e,
|
|
1614
1614
|
txHash: a,
|
|
1615
1615
|
from: h,
|
|
1616
1616
|
to: s.to,
|
|
1617
|
-
amount: re.formatTxAmount(s.value,
|
|
1618
|
-
nativeSymbol:
|
|
1617
|
+
amount: re.formatTxAmount(s.value, u.symbol, u.decimals),
|
|
1618
|
+
nativeSymbol: u.symbol,
|
|
1619
1619
|
status: "timeout"
|
|
1620
1620
|
}));
|
|
1621
1621
|
if (await this.confirmation.showTransactionProgress(
|
|
1622
1622
|
{ chainId: e, txHash: a, from: h, to: s.to },
|
|
1623
1623
|
w
|
|
1624
|
-
),
|
|
1624
|
+
), _) throw _;
|
|
1625
1625
|
return { chainId: e, txHash: a, receipt: m };
|
|
1626
1626
|
}
|
|
1627
1627
|
// ============================================================================
|
|
@@ -1673,7 +1673,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1673
1673
|
throw new g(p.NOT_IMPLEMENTED, "changePin이 구현되어 있지 않습니다");
|
|
1674
1674
|
this.pinStore.set(e);
|
|
1675
1675
|
try {
|
|
1676
|
-
await t.changePin(e, s), this.pinStore.set(s),
|
|
1676
|
+
await t.changePin(e, s), this.pinStore.set(s), d.log("[CROSSx] PIN 변경 완료");
|
|
1677
1677
|
} catch (n) {
|
|
1678
1678
|
throw n instanceof g ? n : new g(p.UNKNOWN_ERROR, "PIN 변경에 실패했습니다", n);
|
|
1679
1679
|
}
|
|
@@ -1877,62 +1877,62 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1877
1877
|
* 4) PIN 잠금 발생 시 카운트다운 화면 표시 → 자동 해제 후 PIN 재입력
|
|
1878
1878
|
*/
|
|
1879
1879
|
async handleMigrationFlow(e) {
|
|
1880
|
-
var
|
|
1881
|
-
|
|
1882
|
-
const s = await this.confirmation.showMigrationFoundPrompt();
|
|
1883
|
-
if (
|
|
1884
|
-
return
|
|
1885
|
-
let
|
|
1880
|
+
var c, l, u;
|
|
1881
|
+
d.log('[CROSSx][Migration Phase 3] "Wallet Found" 팝업 표시');
|
|
1882
|
+
const s = ((c = this._config.migration) == null ? void 0 : c.allowSkip) ?? !0, t = await this.confirmation.showMigrationFoundPrompt({ allowSkip: s });
|
|
1883
|
+
if (d.log("[CROSSx][Migration Phase 3] 사용자 선택:", t), t === "skip")
|
|
1884
|
+
return d.log("[CROSSx][Migration Phase 3] 사용자가 마이그레이션을 건너뜀 → 종료"), null;
|
|
1885
|
+
let n, o = 0, i = 5, a = null;
|
|
1886
1886
|
for (; ; ) {
|
|
1887
|
-
|
|
1888
|
-
`[CROSSx][Migration Phase 4] PIN 입력 팝업 표시 (시도 #${
|
|
1889
|
-
|
|
1887
|
+
o++, d.log(
|
|
1888
|
+
`[CROSSx][Migration Phase 4] PIN 입력 팝업 표시 (시도 #${o}/${i})`,
|
|
1889
|
+
n ? `— 이전 메시지: ${n}` : ""
|
|
1890
1890
|
);
|
|
1891
|
-
const
|
|
1892
|
-
errorMessage:
|
|
1893
|
-
attemptCount:
|
|
1894
|
-
maxAttempts:
|
|
1891
|
+
const h = await this.confirmation.showRecoveryPinInputPrompt({
|
|
1892
|
+
errorMessage: n,
|
|
1893
|
+
attemptCount: o > 1 ? o - 1 : void 0,
|
|
1894
|
+
maxAttempts: i
|
|
1895
1895
|
});
|
|
1896
|
-
if (
|
|
1897
|
-
return
|
|
1898
|
-
|
|
1896
|
+
if (h === null)
|
|
1897
|
+
return d.log("[CROSSx][Migration Phase 4] 사용자가 PIN 입력을 취소함 → 종료"), null;
|
|
1898
|
+
d.log("[CROSSx][Migration Phase 4] PIN 입력 완료 — verify-recovery-pin API 호출"), n = void 0;
|
|
1899
1899
|
try {
|
|
1900
|
-
const
|
|
1901
|
-
if (!
|
|
1902
|
-
|
|
1900
|
+
const m = await ((u = (l = this.walletProvider).verifyRecoveryPin) == null ? void 0 : u.call(l, h, e));
|
|
1901
|
+
if (!m) {
|
|
1902
|
+
d.log("[CROSSx][Migration Phase 4] verifyRecoveryPin 미지원 — PIN 검증 생략"), a = h;
|
|
1903
1903
|
break;
|
|
1904
1904
|
}
|
|
1905
|
-
if (
|
|
1906
|
-
|
|
1905
|
+
if (m.valid) {
|
|
1906
|
+
d.log("[CROSSx][Migration Phase 4] PIN 검증 성공"), a = h;
|
|
1907
1907
|
break;
|
|
1908
1908
|
}
|
|
1909
|
-
const
|
|
1910
|
-
if (
|
|
1911
|
-
const
|
|
1912
|
-
|
|
1909
|
+
const _ = m.pinStatus;
|
|
1910
|
+
if (i = _.maxAttempts, o = i - _.remainingAttempts, _.remainingAttempts === 0 && _.lockExpiresAt) {
|
|
1911
|
+
const w = _.lockExpiresAt * 1e3, S = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = S <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
|
|
1912
|
+
d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${S}초, 메시지: ${y}`), await this.confirmation.showRecoveryPinLockedPrompt(S, y), o = 0, n = "Your account lock has been lifted. You may try again.";
|
|
1913
1913
|
} else
|
|
1914
|
-
|
|
1915
|
-
} catch (
|
|
1916
|
-
if (!(
|
|
1917
|
-
if (
|
|
1918
|
-
const
|
|
1919
|
-
if (
|
|
1920
|
-
return
|
|
1921
|
-
const
|
|
1922
|
-
|
|
1914
|
+
d.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 ${o}/${i})`), n = "Incorrect PIN.";
|
|
1915
|
+
} catch (m) {
|
|
1916
|
+
if (!(m instanceof g)) throw m;
|
|
1917
|
+
if (m.code === p.MIGRATION_PIN_LOCKED) {
|
|
1918
|
+
const _ = m.details;
|
|
1919
|
+
if (i = (_ == null ? void 0 : _.maxAttempts) ?? 5, (_ == null ? void 0 : _.permanent) === !0)
|
|
1920
|
+
return d.warn("[CROSSx][Migration Phase 4] PIN 영구 잠금 (verify-recovery-pin)"), await this.confirmation.showRecoveryPinLockedPrompt(0, "Your account has been permanently locked due to too many failed attempts."), null;
|
|
1921
|
+
const w = ((_ == null ? void 0 : _.lockExpiresAt) ?? 0) * 1e3, S = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = S <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
|
|
1922
|
+
d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${S}초`), await this.confirmation.showRecoveryPinLockedPrompt(S, y), o = 0, n = "Your account lock has been lifted. You may try again.";
|
|
1923
1923
|
} else
|
|
1924
|
-
throw
|
|
1924
|
+
throw d.error("[CROSSx][Migration Phase 4] verify-recovery-pin 실패 (복구 불가):", m), m;
|
|
1925
1925
|
}
|
|
1926
1926
|
}
|
|
1927
|
-
|
|
1927
|
+
d.log("[CROSSx][Migration Phase 5] PIN 검증 완료 — 비밀번호 설정 및 마이그레이션 진행");
|
|
1928
1928
|
try {
|
|
1929
1929
|
await this.ensurePinSetup();
|
|
1930
|
-
const
|
|
1931
|
-
return
|
|
1932
|
-
} catch (
|
|
1933
|
-
if (
|
|
1934
|
-
return
|
|
1935
|
-
throw
|
|
1930
|
+
const h = await this.migrateWalletUseCase.execute(a, e);
|
|
1931
|
+
return d.log("[CROSSx][Migration Phase 5] 마이그레이션 성공 — address:", h.address), h;
|
|
1932
|
+
} catch (h) {
|
|
1933
|
+
if (h instanceof g && h.code === p.MIGRATION_FAILED)
|
|
1934
|
+
return d.warn("[CROSSx][Migration Phase 5] migrate PIN 불일치 (경합) — 처음부터 재시도"), this.handleMigrationFlow(e);
|
|
1935
|
+
throw d.error("[CROSSx][Migration Phase 5] 마이그레이션 실패 (복구 불가):", h), h;
|
|
1936
1936
|
}
|
|
1937
1937
|
}
|
|
1938
1938
|
/**
|
|
@@ -1954,21 +1954,21 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1954
1954
|
if (n) {
|
|
1955
1955
|
const l = c.from ?? this.address;
|
|
1956
1956
|
if (l) {
|
|
1957
|
-
|
|
1958
|
-
const
|
|
1959
|
-
c.nonce = parseInt(
|
|
1957
|
+
d.log("[CROSSx] nonce 비어있음 → eth_getTransactionCount 호출 (from:", l, ")");
|
|
1958
|
+
const u = await this.jsonRpc.call("eth_getTransactionCount", [l, "pending"], s);
|
|
1959
|
+
c.nonce = parseInt(u ?? "0x0", 16), d.log("[CROSSx] nonce 결과:", c.nonce);
|
|
1960
1960
|
}
|
|
1961
1961
|
}
|
|
1962
|
-
if (o && (
|
|
1963
|
-
|
|
1962
|
+
if (o && (d.log("[CROSSx] gasLimit 비어있음 → eth_estimateGas 호출"), c.gasLimit = await this.estimateGas(e, s), d.log("[CROSSx] estimateGas 결과:", c.gasLimit)), i) {
|
|
1963
|
+
d.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
|
|
1964
1964
|
const l = await this.getBaseFeePerGas(s);
|
|
1965
1965
|
if (l) {
|
|
1966
|
-
const
|
|
1967
|
-
c.maxFeePerGas = "0x" + (BigInt(l) + BigInt(
|
|
1966
|
+
const u = Rt;
|
|
1967
|
+
c.maxFeePerGas = "0x" + (BigInt(l) + BigInt(u)).toString(16), c.maxPriorityFeePerGas = u, d.log("[CROSSx] Dynamic 체인 감지 — baseFee:", l, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
|
|
1968
1968
|
} else
|
|
1969
|
-
c.gasPrice = er,
|
|
1969
|
+
c.gasPrice = er, d.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
|
|
1970
1970
|
}
|
|
1971
|
-
return !i && a && (c.maxPriorityFeePerGas = Rt,
|
|
1971
|
+
return !i && a && (c.maxPriorityFeePerGas = Rt, d.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
|
|
1972
1972
|
}
|
|
1973
1973
|
/**
|
|
1974
1974
|
* EIP-712 signTypedData 호출 시 chainId와 typedData.domain.chainId 정합성 검증.
|
|
@@ -2040,17 +2040,17 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2040
2040
|
try {
|
|
2041
2041
|
const n = this.crypto.recoverPersonalSignSigner(e, s);
|
|
2042
2042
|
if (n.toLowerCase() !== t.toLowerCase())
|
|
2043
|
-
throw
|
|
2043
|
+
throw d.error("[CROSSx] 서명 검증 실패: 서명자 주소 불일치", {
|
|
2044
2044
|
expected: t,
|
|
2045
2045
|
recovered: n
|
|
2046
2046
|
}), new g(
|
|
2047
2047
|
p.SIGNATURE_SIGNER_MISMATCH,
|
|
2048
2048
|
`서명자 주소가 일치하지 않습니다: 예상 ${t}, 복원된 주소 ${n}`
|
|
2049
2049
|
);
|
|
2050
|
-
|
|
2050
|
+
d.log("[CROSSx] 서명 ecrecover 검증 성공");
|
|
2051
2051
|
} catch (n) {
|
|
2052
2052
|
if (n instanceof g) throw n;
|
|
2053
|
-
|
|
2053
|
+
d.warn("[CROSSx] ecrecover 검증 중 예외 (무시):", n);
|
|
2054
2054
|
}
|
|
2055
2055
|
}
|
|
2056
2056
|
/** AuthResult를 내부 상태에 반영합니다. */
|
|
@@ -2076,7 +2076,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2076
2076
|
* (서버 세션 종료 API를 호출하면 또 다시 -10002가 날 수 있으므로 스킵)
|
|
2077
2077
|
*/
|
|
2078
2078
|
forceLogout() {
|
|
2079
|
-
this.authenticated && (
|
|
2079
|
+
this.authenticated && (d.warn("[CROSSx] 인증 만료(Gateway -10002) — 강제 로그아웃"), this.clearAuthState());
|
|
2080
2080
|
}
|
|
2081
2081
|
/**
|
|
2082
2082
|
* Firebase sign_in_provider 값을 정규화합니다.
|
|
@@ -2095,7 +2095,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2095
2095
|
const e = await this.confirmation.showPinSetupPrompt();
|
|
2096
2096
|
if (!e)
|
|
2097
2097
|
throw new g(p.PIN_CANCELLED, "사용자가 PIN 설정을 취소했습니다");
|
|
2098
|
-
this.pinStore.set(e),
|
|
2098
|
+
this.pinStore.set(e), d.log("[CROSSx] PIN 설정 완료 (메모리 캐시)");
|
|
2099
2099
|
}
|
|
2100
2100
|
/**
|
|
2101
2101
|
* 서명/전송 전 PIN 입력 모달 표시 후 메모리 캐시
|
|
@@ -2109,7 +2109,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2109
2109
|
const s = await this.confirmation.showPinInputPrompt({ errorMessage: e });
|
|
2110
2110
|
if (!s)
|
|
2111
2111
|
throw new g(p.PIN_CANCELLED, "사용자가 PIN 입력을 취소했습니다");
|
|
2112
|
-
this.pinStore.set(s),
|
|
2112
|
+
this.pinStore.set(s), d.log("[CROSSx] PIN 입력 완료 (메모리 캐시)");
|
|
2113
2113
|
}
|
|
2114
2114
|
/**
|
|
2115
2115
|
* PIN 입력 + verify-password API로 서버 검증
|
|
@@ -2129,7 +2129,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2129
2129
|
else if (this.pinStore.has())
|
|
2130
2130
|
return;
|
|
2131
2131
|
if (this._verifyPinMutex && !e) {
|
|
2132
|
-
|
|
2132
|
+
d.log("[CROSSx] ensureVerifiedPin: 진행 중인 검증 대기"), await this._verifyPinMutex;
|
|
2133
2133
|
return;
|
|
2134
2134
|
}
|
|
2135
2135
|
let t, n;
|
|
@@ -2145,7 +2145,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2145
2145
|
});
|
|
2146
2146
|
if (!i)
|
|
2147
2147
|
throw new g(p.PIN_CANCELLED, "사용자가 PIN 입력을 취소했습니다");
|
|
2148
|
-
this.pinStore.set(i),
|
|
2148
|
+
this.pinStore.set(i), d.log("[CROSSx] PIN 캐시 완료 (verifyPin 미지원, 로컬 전용)"), t();
|
|
2149
2149
|
return;
|
|
2150
2150
|
}
|
|
2151
2151
|
const o = await this.confirmation.showPinInputPrompt({
|
|
@@ -2156,7 +2156,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2156
2156
|
var a;
|
|
2157
2157
|
this.pinStore.set(i);
|
|
2158
2158
|
try {
|
|
2159
|
-
return await this.walletProvider.verifyPin(i) ? (
|
|
2159
|
+
return await this.walletProvider.verifyPin(i) ? (d.log("[CROSSx] PIN 서버 검증 완료 (verify-password)"), { ok: !0 }) : (this.pinStore.clear(), { ok: !1, error: "Incorrect PIN. Please try again." });
|
|
2160
2160
|
} catch (c) {
|
|
2161
2161
|
if (this.pinStore.clear(), c instanceof g) {
|
|
2162
2162
|
if (c.code === p.PIN_WRONG)
|
|
@@ -2172,7 +2172,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2172
2172
|
});
|
|
2173
2173
|
if (!o)
|
|
2174
2174
|
throw new g(p.PIN_CANCELLED, "사용자가 PIN 입력을 취소했습니다");
|
|
2175
|
-
this.pinStore.set(o),
|
|
2175
|
+
this.pinStore.set(o), d.log("[CROSSx] PIN 갱신 완료 (verify 모달 닫힘)"), t();
|
|
2176
2176
|
} catch (o) {
|
|
2177
2177
|
throw n(o), o;
|
|
2178
2178
|
} finally {
|
|
@@ -2189,16 +2189,16 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2189
2189
|
async loadWalletAfterAuth(e) {
|
|
2190
2190
|
if (!this.userId) return;
|
|
2191
2191
|
const s = await this.fetchWalletStatus();
|
|
2192
|
-
if (
|
|
2192
|
+
if (d.log("[CROSSx] loadWalletAfterAuth 지갑 상태:", s), s !== "exists") return;
|
|
2193
2193
|
const t = await this.walletProvider.getAddresses(this.userId);
|
|
2194
2194
|
if (t.length > 0) {
|
|
2195
2195
|
const o = e !== void 0 ? t.find((i) => i.index === e) ?? t[0] : t[0];
|
|
2196
|
-
this.address = o.address, this.activeWalletIndex = o.index,
|
|
2196
|
+
this.address = o.address, this.activeWalletIndex = o.index, d.log("[CROSSx] 캐시된 주소 로드 완료 (비밀번호 불필요):", this.address), this.emit("addressChanged", { address: o.address, index: o.index });
|
|
2197
2197
|
return;
|
|
2198
2198
|
}
|
|
2199
|
-
|
|
2199
|
+
d.log("[CROSSx] 주소 캐시 없음 — 비밀번호 확인 후 address(0) 조회"), await this.ensureVerifiedPin();
|
|
2200
2200
|
const n = await this.walletProvider.getAddress(this.userId, 0);
|
|
2201
|
-
this.address = n.address, this.activeWalletIndex = 0,
|
|
2201
|
+
this.address = n.address, this.activeWalletIndex = 0, d.log("[CROSSx] 세션 복원 후 지갑 주소 로드 완료:", this.address), this.emit("addressChanged", { address: n.address, index: 0 });
|
|
2202
2202
|
}
|
|
2203
2203
|
/**
|
|
2204
2204
|
* PIN_WRONG 에러 시 서버 검증 포함 PIN 재입력 모달을 표시하고 재시도합니다.
|
|
@@ -2232,7 +2232,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2232
2232
|
throw n;
|
|
2233
2233
|
}
|
|
2234
2234
|
for (; ; ) {
|
|
2235
|
-
|
|
2235
|
+
d.warn("[CROSSx] PIN 불일치/잠금 — 재입력 요청:", s), this.pinStore.clear(), await this.ensureVerifiedPin(s, t), t = void 0;
|
|
2236
2236
|
try {
|
|
2237
2237
|
return await e();
|
|
2238
2238
|
} catch (n) {
|
|
@@ -2321,7 +2321,7 @@ class rr {
|
|
|
2321
2321
|
const t = JSON.stringify(s);
|
|
2322
2322
|
localStorage.setItem(this.prefix + e, t);
|
|
2323
2323
|
} catch (t) {
|
|
2324
|
-
throw
|
|
2324
|
+
throw d.error("Storage set error:", t), t;
|
|
2325
2325
|
}
|
|
2326
2326
|
}
|
|
2327
2327
|
async get(e) {
|
|
@@ -2329,14 +2329,14 @@ class rr {
|
|
|
2329
2329
|
const s = localStorage.getItem(this.prefix + e);
|
|
2330
2330
|
return s ? JSON.parse(s) : null;
|
|
2331
2331
|
} catch (s) {
|
|
2332
|
-
return
|
|
2332
|
+
return d.error("Storage get error:", s), null;
|
|
2333
2333
|
}
|
|
2334
2334
|
}
|
|
2335
2335
|
async remove(e) {
|
|
2336
2336
|
try {
|
|
2337
2337
|
localStorage.removeItem(this.prefix + e);
|
|
2338
2338
|
} catch (s) {
|
|
2339
|
-
throw
|
|
2339
|
+
throw d.error("Storage remove error:", s), s;
|
|
2340
2340
|
}
|
|
2341
2341
|
}
|
|
2342
2342
|
async clear() {
|
|
@@ -2345,7 +2345,7 @@ class rr {
|
|
|
2345
2345
|
s.startsWith(this.prefix) && localStorage.removeItem(s);
|
|
2346
2346
|
});
|
|
2347
2347
|
} catch (e) {
|
|
2348
|
-
throw
|
|
2348
|
+
throw d.error("Storage clear error:", e), e;
|
|
2349
2349
|
}
|
|
2350
2350
|
}
|
|
2351
2351
|
}
|
|
@@ -2415,25 +2415,25 @@ class Ot {
|
|
|
2415
2415
|
async migrateFromLegacyDB() {
|
|
2416
2416
|
if (this.dbName === Xe) return null;
|
|
2417
2417
|
try {
|
|
2418
|
-
const e = await this.openDB(Xe), s = e.transaction([Se, de], "readonly"), t = s.objectStore(Se).get($e), n = await new Promise((l,
|
|
2419
|
-
t.onsuccess = () => l(t.result), t.onerror = () =>
|
|
2418
|
+
const e = await this.openDB(Xe), s = e.transaction([Se, de], "readonly"), t = s.objectStore(Se).get($e), n = await new Promise((l, u) => {
|
|
2419
|
+
t.onsuccess = () => l(t.result), t.onerror = () => u(t.error);
|
|
2420
2420
|
});
|
|
2421
2421
|
if (!n)
|
|
2422
2422
|
return e.close(), null;
|
|
2423
2423
|
const o = s.objectStore(de).getAll(), i = s.objectStore(de).getAllKeys(), [a, c] = await Promise.all([
|
|
2424
|
-
new Promise((l,
|
|
2425
|
-
o.onsuccess = () => l(o.result), o.onerror = () =>
|
|
2424
|
+
new Promise((l, u) => {
|
|
2425
|
+
o.onsuccess = () => l(o.result), o.onerror = () => u(o.error);
|
|
2426
2426
|
}),
|
|
2427
|
-
new Promise((l,
|
|
2428
|
-
i.onsuccess = () => l(i.result), i.onerror = () =>
|
|
2427
|
+
new Promise((l, u) => {
|
|
2428
|
+
i.onsuccess = () => l(i.result), i.onerror = () => u(i.error);
|
|
2429
2429
|
})
|
|
2430
2430
|
]);
|
|
2431
2431
|
e.close(), await this.idbPut(Se, $e, n);
|
|
2432
2432
|
for (let l = 0; l < c.length; l++)
|
|
2433
2433
|
await this.idbPut(de, String(c[l]), a[l]);
|
|
2434
|
-
return indexedDB.deleteDatabase(Xe),
|
|
2434
|
+
return indexedDB.deleteDatabase(Xe), d.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), n;
|
|
2435
2435
|
} catch (e) {
|
|
2436
|
-
return
|
|
2436
|
+
return d.warn("[CROSSx] IndexedDB 레거시 DB 마이그레이션 실패:", e), null;
|
|
2437
2437
|
}
|
|
2438
2438
|
}
|
|
2439
2439
|
async encrypt(e) {
|
|
@@ -2460,7 +2460,7 @@ class Ot {
|
|
|
2460
2460
|
const t = JSON.stringify(s), n = await this.encrypt(t);
|
|
2461
2461
|
await this.idbPut(de, e, n);
|
|
2462
2462
|
} catch (t) {
|
|
2463
|
-
throw
|
|
2463
|
+
throw d.error("[CROSSx] IndexedDB set error:", t), t;
|
|
2464
2464
|
}
|
|
2465
2465
|
}
|
|
2466
2466
|
async get(e) {
|
|
@@ -2471,21 +2471,21 @@ class Ot {
|
|
|
2471
2471
|
const t = await this.decrypt(s);
|
|
2472
2472
|
return JSON.parse(t);
|
|
2473
2473
|
} catch (s) {
|
|
2474
|
-
return
|
|
2474
|
+
return d.error("[CROSSx] IndexedDB get error:", s), null;
|
|
2475
2475
|
}
|
|
2476
2476
|
}
|
|
2477
2477
|
async remove(e) {
|
|
2478
2478
|
try {
|
|
2479
2479
|
await this.ensureReady(), await this.idbDelete(de, e);
|
|
2480
2480
|
} catch (s) {
|
|
2481
|
-
throw
|
|
2481
|
+
throw d.error("[CROSSx] IndexedDB remove error:", s), s;
|
|
2482
2482
|
}
|
|
2483
2483
|
}
|
|
2484
2484
|
async clear() {
|
|
2485
2485
|
try {
|
|
2486
2486
|
await this.ensureReady(), await this.idbClear(de);
|
|
2487
2487
|
} catch (e) {
|
|
2488
|
-
throw
|
|
2488
|
+
throw d.error("[CROSSx] IndexedDB clear error:", e), e;
|
|
2489
2489
|
}
|
|
2490
2490
|
}
|
|
2491
2491
|
/**
|
|
@@ -2662,11 +2662,11 @@ class fr {
|
|
|
2662
2662
|
const a = Ze(e), c = this.outputLen;
|
|
2663
2663
|
if (c % 4)
|
|
2664
2664
|
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
2665
|
-
const l = c / 4,
|
|
2666
|
-
if (l >
|
|
2665
|
+
const l = c / 4, u = this.get();
|
|
2666
|
+
if (l > u.length)
|
|
2667
2667
|
throw new Error("_sha2: outputLen bigger than state");
|
|
2668
2668
|
for (let h = 0; h < l; h++)
|
|
2669
|
-
a.setUint32(4 * h,
|
|
2669
|
+
a.setUint32(4 * h, u[h], o);
|
|
2670
2670
|
}
|
|
2671
2671
|
digest() {
|
|
2672
2672
|
const { buffer: e, outputLen: s } = this;
|
|
@@ -2787,15 +2787,15 @@ class vr extends fr {
|
|
|
2787
2787
|
for (let h = 0; h < 16; h++, s += 4)
|
|
2788
2788
|
we[h] = e.getUint32(s, !1);
|
|
2789
2789
|
for (let h = 16; h < 64; h++) {
|
|
2790
|
-
const m = we[h - 15],
|
|
2791
|
-
we[h] =
|
|
2790
|
+
const m = we[h - 15], _ = we[h - 2], w = ue(m, 7) ^ ue(m, 18) ^ m >>> 3, S = ue(_, 17) ^ ue(_, 19) ^ _ >>> 10;
|
|
2791
|
+
we[h] = S + we[h - 7] + w + we[h - 16] | 0;
|
|
2792
2792
|
}
|
|
2793
|
-
let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H:
|
|
2793
|
+
let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: u } = this;
|
|
2794
2794
|
for (let h = 0; h < 64; h++) {
|
|
2795
|
-
const m = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25),
|
|
2796
|
-
|
|
2795
|
+
const m = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), _ = u + m + hr(a, c, l) + br[h] + we[h] | 0, S = (ue(t, 2) ^ ue(t, 13) ^ ue(t, 22)) + pr(t, n, o) | 0;
|
|
2796
|
+
u = l, l = c, c = a, a = i + _ | 0, i = o, o = n, n = t, t = _ + S | 0;
|
|
2797
2797
|
}
|
|
2798
|
-
t = t + this.A | 0, n = n + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0,
|
|
2798
|
+
t = t + this.A | 0, n = n + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, u = u + this.H | 0, this.set(t, n, o, i, a, c, l, u);
|
|
2799
2799
|
}
|
|
2800
2800
|
roundClean() {
|
|
2801
2801
|
Pe(we);
|
|
@@ -2887,28 +2887,28 @@ function kr(r, e, s) {
|
|
|
2887
2887
|
if (ge(r, "hashLen"), ge(e, "qByteLen"), typeof s != "function")
|
|
2888
2888
|
throw new Error("hmacFn must be a function");
|
|
2889
2889
|
const t = (y) => new Uint8Array(y), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
|
|
2890
|
-
let c = t(r), l = t(r),
|
|
2890
|
+
let c = t(r), l = t(r), u = 0;
|
|
2891
2891
|
const h = () => {
|
|
2892
|
-
c.fill(1), l.fill(0),
|
|
2893
|
-
}, m = (...y) => s(l, ve(c, ...y)),
|
|
2892
|
+
c.fill(1), l.fill(0), u = 0;
|
|
2893
|
+
}, m = (...y) => s(l, ve(c, ...y)), _ = (y = n) => {
|
|
2894
2894
|
l = m(o, y), c = m(), y.length !== 0 && (l = m(i, y), c = m());
|
|
2895
2895
|
}, w = () => {
|
|
2896
|
-
if (
|
|
2896
|
+
if (u++ >= a)
|
|
2897
2897
|
throw new Error("drbg: tried max amount of iterations");
|
|
2898
2898
|
let y = 0;
|
|
2899
|
-
const
|
|
2899
|
+
const E = [];
|
|
2900
2900
|
for (; y < e; ) {
|
|
2901
2901
|
c = m();
|
|
2902
2902
|
const C = c.slice();
|
|
2903
|
-
|
|
2903
|
+
E.push(C), y += c.length;
|
|
2904
2904
|
}
|
|
2905
|
-
return ve(...
|
|
2905
|
+
return ve(...E);
|
|
2906
2906
|
};
|
|
2907
|
-
return (y,
|
|
2908
|
-
h(),
|
|
2907
|
+
return (y, E) => {
|
|
2908
|
+
h(), _(y);
|
|
2909
2909
|
let C;
|
|
2910
|
-
for (; !(C =
|
|
2911
|
-
|
|
2910
|
+
for (; !(C = E(w())); )
|
|
2911
|
+
_();
|
|
2912
2912
|
return h(), C;
|
|
2913
2913
|
};
|
|
2914
2914
|
}
|
|
@@ -2977,10 +2977,10 @@ function Or(r, e) {
|
|
|
2977
2977
|
function Cr(r) {
|
|
2978
2978
|
const e = je(r), s = xs(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + Pr) / fs;
|
|
2979
2979
|
return (a, c) => {
|
|
2980
|
-
let l = a.pow(c, i),
|
|
2981
|
-
const h = a.mul(l, n), m = a.mul(l, o),
|
|
2982
|
-
l = a.cmov(l,
|
|
2983
|
-
const
|
|
2980
|
+
let l = a.pow(c, i), u = a.mul(l, t);
|
|
2981
|
+
const h = a.mul(l, n), m = a.mul(l, o), _ = a.eql(a.sqr(u), c), w = a.eql(a.sqr(h), c);
|
|
2982
|
+
l = a.cmov(l, u, _), u = a.cmov(m, h, w);
|
|
2983
|
+
const S = a.eql(a.sqr(u), c), y = a.cmov(l, u, S);
|
|
2984
2984
|
return xt(a, y, c), y;
|
|
2985
2985
|
};
|
|
2986
2986
|
}
|
|
@@ -3004,18 +3004,18 @@ function xs(r) {
|
|
|
3004
3004
|
return l;
|
|
3005
3005
|
if (Bt(c, l) !== 1)
|
|
3006
3006
|
throw new Error("Cannot find square root");
|
|
3007
|
-
let
|
|
3007
|
+
let u = s, h = c.mul(c.ONE, o), m = c.pow(l, e), _ = c.pow(l, i);
|
|
3008
3008
|
for (; !c.eql(m, c.ONE); ) {
|
|
3009
3009
|
if (c.is0(m))
|
|
3010
3010
|
return c.ZERO;
|
|
3011
|
-
let w = 1,
|
|
3012
|
-
for (; !c.eql(
|
|
3013
|
-
if (w++,
|
|
3011
|
+
let w = 1, S = c.sqr(m);
|
|
3012
|
+
for (; !c.eql(S, c.ONE); )
|
|
3013
|
+
if (w++, S = c.sqr(S), w === u)
|
|
3014
3014
|
throw new Error("Cannot find square root");
|
|
3015
|
-
const y = ee << BigInt(
|
|
3016
|
-
|
|
3015
|
+
const y = ee << BigInt(u - w - 1), E = c.pow(h, y);
|
|
3016
|
+
u = w, h = c.sqr(E), m = c.mul(m, h), _ = c.mul(_, E);
|
|
3017
3017
|
}
|
|
3018
|
-
return
|
|
3018
|
+
return _;
|
|
3019
3019
|
};
|
|
3020
3020
|
}
|
|
3021
3021
|
function Lr(r) {
|
|
@@ -3231,8 +3231,8 @@ function Ht(r, e, s) {
|
|
|
3231
3231
|
const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
|
|
3232
3232
|
let a = Number(r & n), c = r >> i;
|
|
3233
3233
|
a > t && (a -= o, c += Ae);
|
|
3234
|
-
const l = e * t,
|
|
3235
|
-
return { nextN: c, offset:
|
|
3234
|
+
const l = e * t, u = l + Math.abs(a) - 1, h = a === 0, m = a < 0, _ = e % 2 !== 0;
|
|
3235
|
+
return { nextN: c, offset: u, isZero: h, isNeg: m, isNegF: _, offsetF: l };
|
|
3236
3236
|
}
|
|
3237
3237
|
const et = /* @__PURE__ */ new WeakMap(), bs = /* @__PURE__ */ new WeakMap();
|
|
3238
3238
|
function tt(r) {
|
|
@@ -3293,8 +3293,8 @@ class Fr {
|
|
|
3293
3293
|
let n = this.ZERO, o = this.BASE;
|
|
3294
3294
|
const i = Qe(e, this.bits);
|
|
3295
3295
|
for (let a = 0; a < i.windows; a++) {
|
|
3296
|
-
const { nextN: c, offset: l, isZero:
|
|
3297
|
-
t = c,
|
|
3296
|
+
const { nextN: c, offset: l, isZero: u, isNeg: h, isNegF: m, offsetF: _ } = Ht(t, a, i);
|
|
3297
|
+
t = c, u ? o = o.add(Ke(m, s[_])) : n = n.add(Ke(h, s[l]));
|
|
3298
3298
|
}
|
|
3299
3299
|
return Ft(t), { p: n, f: o };
|
|
3300
3300
|
}
|
|
@@ -3306,10 +3306,10 @@ class Fr {
|
|
|
3306
3306
|
wNAFUnsafe(e, s, t, n = this.ZERO) {
|
|
3307
3307
|
const o = Qe(e, this.bits);
|
|
3308
3308
|
for (let i = 0; i < o.windows && t !== Ne; i++) {
|
|
3309
|
-
const { nextN: a, offset: c, isZero: l, isNeg:
|
|
3309
|
+
const { nextN: a, offset: c, isZero: l, isNeg: u } = Ht(t, i, o);
|
|
3310
3310
|
if (t = a, !l) {
|
|
3311
3311
|
const h = s[c];
|
|
3312
|
-
n = n.add(
|
|
3312
|
+
n = n.add(u ? h.negate() : h);
|
|
3313
3313
|
}
|
|
3314
3314
|
}
|
|
3315
3315
|
return Ft(t), n;
|
|
@@ -3418,13 +3418,13 @@ Ss.create = (r, e) => new vs(r, e);
|
|
|
3418
3418
|
const Wt = (r, e) => (r + (r >= 0 ? e : -e) / Es) / e;
|
|
3419
3419
|
function Kr(r, e, s) {
|
|
3420
3420
|
const [[t, n], [o, i]] = e, a = Wt(i * r, s), c = Wt(-n * r, s);
|
|
3421
|
-
let l = r - a * t - c * o,
|
|
3422
|
-
const h = l < _e, m =
|
|
3423
|
-
h && (l = -l), m && (
|
|
3424
|
-
const
|
|
3425
|
-
if (l < _e || l >=
|
|
3421
|
+
let l = r - a * t - c * o, u = -a * n - c * i;
|
|
3422
|
+
const h = l < _e, m = u < _e;
|
|
3423
|
+
h && (l = -l), m && (u = -u);
|
|
3424
|
+
const _ = ft(Math.ceil(Rr(s) / 2)) + Re;
|
|
3425
|
+
if (l < _e || l >= _ || u < _e || u >= _)
|
|
3426
3426
|
throw new Error("splitScalar (endomorphism): failed, k=" + r);
|
|
3427
|
-
return { k1neg: h, k1: l, k2neg: m, k2:
|
|
3427
|
+
return { k1neg: h, k1: l, k2neg: m, k2: u };
|
|
3428
3428
|
}
|
|
3429
3429
|
function ct(r) {
|
|
3430
3430
|
if (!["compact", "recovered", "der"].includes(r))
|
|
@@ -3482,8 +3482,8 @@ const ye = {
|
|
|
3482
3482
|
throw new s("tlv.decode: length bytes not complete");
|
|
3483
3483
|
if (l[0] === 0)
|
|
3484
3484
|
throw new s("tlv.decode(long): zero leftmost byte");
|
|
3485
|
-
for (const
|
|
3486
|
-
i = i << 8 |
|
|
3485
|
+
for (const u of l)
|
|
3486
|
+
i = i << 8 | u;
|
|
3487
3487
|
if (t += c, i < 128)
|
|
3488
3488
|
throw new s("tlv.decode(long): not minimal encoding");
|
|
3489
3489
|
}
|
|
@@ -3520,8 +3520,8 @@ const ye = {
|
|
|
3520
3520
|
const { Err: e, _int: s, _tlv: t } = ye, n = V(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
|
|
3521
3521
|
if (i.length)
|
|
3522
3522
|
throw new e("invalid signature: left bytes after parsing");
|
|
3523
|
-
const { v: a, l: c } = t.decode(2, o), { v: l, l:
|
|
3524
|
-
if (
|
|
3523
|
+
const { v: a, l: c } = t.decode(2, o), { v: l, l: u } = t.decode(2, c);
|
|
3524
|
+
if (u.length)
|
|
3525
3525
|
throw new e("invalid signature: left bytes after parsing");
|
|
3526
3526
|
return { r: s.decode(a), s: s.decode(l) };
|
|
3527
3527
|
},
|
|
@@ -3546,14 +3546,14 @@ function jr(r, e = {}) {
|
|
|
3546
3546
|
if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
|
|
3547
3547
|
throw new Error('invalid endo: expected "beta": bigint and "basises": array');
|
|
3548
3548
|
const l = As(t, n);
|
|
3549
|
-
function
|
|
3549
|
+
function u() {
|
|
3550
3550
|
if (!t.isOdd)
|
|
3551
3551
|
throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
3552
3552
|
}
|
|
3553
|
-
function h(N, f,
|
|
3553
|
+
function h(N, f, x) {
|
|
3554
3554
|
const { x: v, y: I } = f.toAffine(), L = t.toBytes(v);
|
|
3555
|
-
if (qe(
|
|
3556
|
-
|
|
3555
|
+
if (qe(x, "isCompressed"), x) {
|
|
3556
|
+
u();
|
|
3557
3557
|
const O = !t.isOdd(I);
|
|
3558
3558
|
return ve(Is(O), L);
|
|
3559
3559
|
} else
|
|
@@ -3561,12 +3561,12 @@ function jr(r, e = {}) {
|
|
|
3561
3561
|
}
|
|
3562
3562
|
function m(N) {
|
|
3563
3563
|
V(N, void 0, "Point");
|
|
3564
|
-
const { publicKey: f, publicKeyUncompressed:
|
|
3564
|
+
const { publicKey: f, publicKeyUncompressed: x } = l, v = N.length, I = N[0], L = N.subarray(1);
|
|
3565
3565
|
if (v === f && (I === 2 || I === 3)) {
|
|
3566
3566
|
const O = t.fromBytes(L);
|
|
3567
3567
|
if (!t.isValid(O))
|
|
3568
3568
|
throw new Error("bad point: is not on curve, wrong x");
|
|
3569
|
-
const M =
|
|
3569
|
+
const M = S(O);
|
|
3570
3570
|
let T;
|
|
3571
3571
|
try {
|
|
3572
3572
|
T = t.sqrt(M);
|
|
@@ -3574,33 +3574,33 @@ function jr(r, e = {}) {
|
|
|
3574
3574
|
const K = J instanceof Error ? ": " + J.message : "";
|
|
3575
3575
|
throw new Error("bad point: is not on curve, sqrt error" + K);
|
|
3576
3576
|
}
|
|
3577
|
-
|
|
3577
|
+
u();
|
|
3578
3578
|
const $ = t.isOdd(T);
|
|
3579
3579
|
return (I & 1) === 1 !== $ && (T = t.neg(T)), { x: O, y: T };
|
|
3580
|
-
} else if (v ===
|
|
3580
|
+
} else if (v === x && I === 4) {
|
|
3581
3581
|
const O = t.BYTES, M = t.fromBytes(L.subarray(0, O)), T = t.fromBytes(L.subarray(O, O * 2));
|
|
3582
3582
|
if (!y(M, T))
|
|
3583
3583
|
throw new Error("bad point: is not on curve");
|
|
3584
3584
|
return { x: M, y: T };
|
|
3585
3585
|
} else
|
|
3586
|
-
throw new Error(`bad point: got length ${v}, expected compressed=${f} or uncompressed=${
|
|
3586
|
+
throw new Error(`bad point: got length ${v}, expected compressed=${f} or uncompressed=${x}`);
|
|
3587
3587
|
}
|
|
3588
|
-
const
|
|
3589
|
-
function
|
|
3590
|
-
const f = t.sqr(N),
|
|
3591
|
-
return t.add(t.add(
|
|
3588
|
+
const _ = e.toBytes || h, w = e.fromBytes || m;
|
|
3589
|
+
function S(N) {
|
|
3590
|
+
const f = t.sqr(N), x = t.mul(f, N);
|
|
3591
|
+
return t.add(t.add(x, t.mul(N, o.a)), o.b);
|
|
3592
3592
|
}
|
|
3593
3593
|
function y(N, f) {
|
|
3594
|
-
const
|
|
3595
|
-
return t.eql(
|
|
3594
|
+
const x = t.sqr(f), v = S(N);
|
|
3595
|
+
return t.eql(x, v);
|
|
3596
3596
|
}
|
|
3597
3597
|
if (!y(o.Gx, o.Gy))
|
|
3598
3598
|
throw new Error("bad curve params: generator point");
|
|
3599
|
-
const
|
|
3600
|
-
if (t.is0(t.add(
|
|
3599
|
+
const E = t.mul(t.pow(o.a, He), zr), C = t.mul(t.sqr(o.b), BigInt(27));
|
|
3600
|
+
if (t.is0(t.add(E, C)))
|
|
3601
3601
|
throw new Error("bad curve params: a or b");
|
|
3602
|
-
function B(N, f,
|
|
3603
|
-
if (!t.isValid(f) ||
|
|
3602
|
+
function B(N, f, x = !1) {
|
|
3603
|
+
if (!t.isValid(f) || x && t.is0(f))
|
|
3604
3604
|
throw new Error(`bad point coordinate ${N}`);
|
|
3605
3605
|
return f;
|
|
3606
3606
|
}
|
|
@@ -3614,12 +3614,12 @@ function jr(r, e = {}) {
|
|
|
3614
3614
|
return Kr(N, c.basises, n.ORDER);
|
|
3615
3615
|
}
|
|
3616
3616
|
const P = Mt((N, f) => {
|
|
3617
|
-
const { X:
|
|
3617
|
+
const { X: x, Y: v, Z: I } = N;
|
|
3618
3618
|
if (t.eql(I, t.ONE))
|
|
3619
|
-
return { x
|
|
3619
|
+
return { x, y: v };
|
|
3620
3620
|
const L = N.is0();
|
|
3621
3621
|
f == null && (f = L ? t.ONE : t.inv(I));
|
|
3622
|
-
const O = t.mul(
|
|
3622
|
+
const O = t.mul(x, f), M = t.mul(v, f), T = t.mul(I, f);
|
|
3623
3623
|
if (L)
|
|
3624
3624
|
return { x: t.ZERO, y: t.ZERO };
|
|
3625
3625
|
if (!t.eql(T, t.ONE))
|
|
@@ -3631,41 +3631,41 @@ function jr(r, e = {}) {
|
|
|
3631
3631
|
return;
|
|
3632
3632
|
throw new Error("bad point: ZERO");
|
|
3633
3633
|
}
|
|
3634
|
-
const { x: f, y:
|
|
3635
|
-
if (!t.isValid(f) || !t.isValid(
|
|
3634
|
+
const { x: f, y: x } = N.toAffine();
|
|
3635
|
+
if (!t.isValid(f) || !t.isValid(x))
|
|
3636
3636
|
throw new Error("bad point: x or y not field elements");
|
|
3637
|
-
if (!y(f,
|
|
3637
|
+
if (!y(f, x))
|
|
3638
3638
|
throw new Error("bad point: equation left != right");
|
|
3639
3639
|
if (!N.isTorsionFree())
|
|
3640
3640
|
throw new Error("bad point: not in prime-order subgroup");
|
|
3641
3641
|
return !0;
|
|
3642
3642
|
});
|
|
3643
|
-
function z(N, f,
|
|
3644
|
-
return
|
|
3643
|
+
function z(N, f, x, v, I) {
|
|
3644
|
+
return x = new W(t.mul(x.X, N), x.Y, x.Z), f = Ke(v, f), x = Ke(I, x), f.add(x);
|
|
3645
3645
|
}
|
|
3646
3646
|
const R = class R {
|
|
3647
3647
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
3648
|
-
constructor(f,
|
|
3648
|
+
constructor(f, x, v) {
|
|
3649
3649
|
A(this, "X");
|
|
3650
3650
|
A(this, "Y");
|
|
3651
3651
|
A(this, "Z");
|
|
3652
|
-
this.X = B("x", f), this.Y = B("y",
|
|
3652
|
+
this.X = B("x", f), this.Y = B("y", x, !0), this.Z = B("z", v), Object.freeze(this);
|
|
3653
3653
|
}
|
|
3654
3654
|
static CURVE() {
|
|
3655
3655
|
return o;
|
|
3656
3656
|
}
|
|
3657
3657
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
3658
3658
|
static fromAffine(f) {
|
|
3659
|
-
const { x
|
|
3660
|
-
if (!f || !t.isValid(
|
|
3659
|
+
const { x, y: v } = f || {};
|
|
3660
|
+
if (!f || !t.isValid(x) || !t.isValid(v))
|
|
3661
3661
|
throw new Error("invalid affine point");
|
|
3662
3662
|
if (f instanceof R)
|
|
3663
3663
|
throw new Error("projective point not allowed");
|
|
3664
|
-
return t.is0(
|
|
3664
|
+
return t.is0(x) && t.is0(v) ? R.ZERO : new R(x, v, t.ONE);
|
|
3665
3665
|
}
|
|
3666
3666
|
static fromBytes(f) {
|
|
3667
|
-
const
|
|
3668
|
-
return
|
|
3667
|
+
const x = R.fromAffine(w(V(f, void 0, "point")));
|
|
3668
|
+
return x.assertValidity(), x;
|
|
3669
3669
|
}
|
|
3670
3670
|
static fromHex(f) {
|
|
3671
3671
|
return R.fromBytes(We(f));
|
|
@@ -3682,8 +3682,8 @@ function jr(r, e = {}) {
|
|
|
3682
3682
|
* @param isLazy true will defer table computation until the first multiplication
|
|
3683
3683
|
* @returns
|
|
3684
3684
|
*/
|
|
3685
|
-
precompute(f = 8,
|
|
3686
|
-
return D.createCache(this, f),
|
|
3685
|
+
precompute(f = 8, x = !0) {
|
|
3686
|
+
return D.createCache(this, f), x || this.multiply(He), this;
|
|
3687
3687
|
}
|
|
3688
3688
|
// TODO: return `this`
|
|
3689
3689
|
/** A point on curve is valid if it conforms to equation. */
|
|
@@ -3699,7 +3699,7 @@ function jr(r, e = {}) {
|
|
|
3699
3699
|
/** Compare one point to another. */
|
|
3700
3700
|
equals(f) {
|
|
3701
3701
|
b(f);
|
|
3702
|
-
const { X:
|
|
3702
|
+
const { X: x, Y: v, Z: I } = this, { X: L, Y: O, Z: M } = f, T = t.eql(t.mul(x, M), t.mul(L, I)), $ = t.eql(t.mul(v, M), t.mul(O, I));
|
|
3703
3703
|
return T && $;
|
|
3704
3704
|
}
|
|
3705
3705
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
@@ -3711,7 +3711,7 @@ function jr(r, e = {}) {
|
|
|
3711
3711
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
3712
3712
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
3713
3713
|
double() {
|
|
3714
|
-
const { a: f, b:
|
|
3714
|
+
const { a: f, b: x } = o, v = t.mul(x, He), { X: I, Y: L, Z: O } = this;
|
|
3715
3715
|
let M = t.ZERO, T = t.ZERO, $ = t.ZERO, F = t.mul(I, I), J = t.mul(L, L), K = t.mul(O, O), H = t.mul(I, L);
|
|
3716
3716
|
return H = t.add(H, H), $ = t.mul(I, O), $ = t.add($, $), M = t.mul(f, $), T = t.mul(v, K), T = t.add(M, T), M = t.sub(J, T), T = t.add(J, T), T = t.mul(M, T), M = t.mul(H, M), $ = t.mul(v, $), K = t.mul(f, K), H = t.sub(F, K), H = t.mul(f, H), H = t.add(H, $), $ = t.add(F, F), F = t.add($, F), F = t.add(F, K), F = t.mul(F, H), T = t.add(T, F), K = t.mul(L, O), K = t.add(K, K), F = t.mul(K, H), M = t.sub(M, F), $ = t.mul(K, J), $ = t.add($, $), $ = t.add($, $), new R(M, T, $);
|
|
3717
3717
|
}
|
|
@@ -3721,11 +3721,11 @@ function jr(r, e = {}) {
|
|
|
3721
3721
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
3722
3722
|
add(f) {
|
|
3723
3723
|
b(f);
|
|
3724
|
-
const { X:
|
|
3724
|
+
const { X: x, Y: v, Z: I } = this, { X: L, Y: O, Z: M } = f;
|
|
3725
3725
|
let T = t.ZERO, $ = t.ZERO, F = t.ZERO;
|
|
3726
3726
|
const J = o.a, K = t.mul(o.b, He);
|
|
3727
|
-
let H = t.mul(
|
|
3728
|
-
oe = t.mul(oe, j), j = t.add(H, X), oe = t.sub(oe, j), j = t.add(
|
|
3727
|
+
let H = t.mul(x, L), X = t.mul(v, O), Z = t.mul(I, M), oe = t.add(x, v), j = t.add(L, O);
|
|
3728
|
+
oe = t.mul(oe, j), j = t.add(H, X), oe = t.sub(oe, j), j = t.add(x, I);
|
|
3729
3729
|
let Q = t.add(L, M);
|
|
3730
3730
|
return j = t.mul(j, Q), Q = t.add(H, Z), j = t.sub(j, Q), Q = t.add(v, I), T = t.add(O, M), Q = t.mul(Q, T), T = t.add(X, Z), Q = t.sub(Q, T), F = t.mul(J, j), T = t.mul(K, Z), F = t.add(T, F), T = t.sub(X, F), F = t.add(X, F), $ = t.mul(T, F), X = t.add(H, H), X = t.add(X, H), Z = t.mul(J, Z), j = t.mul(K, j), X = t.add(X, Z), Z = t.sub(H, Z), Z = t.mul(J, Z), j = t.add(j, Z), H = t.mul(X, j), $ = t.add($, H), H = t.mul(Q, j), T = t.mul(oe, T), T = t.sub(T, H), H = t.mul(oe, X), F = t.mul(Q, F), F = t.add(F, H), new R(T, $, F);
|
|
3731
3731
|
}
|
|
@@ -3745,14 +3745,14 @@ function jr(r, e = {}) {
|
|
|
3745
3745
|
* @returns New point
|
|
3746
3746
|
*/
|
|
3747
3747
|
multiply(f) {
|
|
3748
|
-
const { endo:
|
|
3748
|
+
const { endo: x } = e;
|
|
3749
3749
|
if (!n.isValidNot0(f))
|
|
3750
3750
|
throw new Error("invalid scalar: out of range");
|
|
3751
3751
|
let v, I;
|
|
3752
3752
|
const L = (O) => D.cached(this, O, (M) => Ut(R, M));
|
|
3753
|
-
if (
|
|
3753
|
+
if (x) {
|
|
3754
3754
|
const { k1neg: O, k1: M, k2neg: T, k2: $ } = k(f), { p: F, f: J } = L(M), { p: K, f: H } = L($);
|
|
3755
|
-
I = J.add(H), v = z(
|
|
3755
|
+
I = J.add(H), v = z(x.beta, F, K, O, T);
|
|
3756
3756
|
} else {
|
|
3757
3757
|
const { p: O, f: M } = L(f);
|
|
3758
3758
|
v = O, I = M;
|
|
@@ -3765,7 +3765,7 @@ function jr(r, e = {}) {
|
|
|
3765
3765
|
* an exposed secret key e.g. sig verification, which works over *public* keys.
|
|
3766
3766
|
*/
|
|
3767
3767
|
multiplyUnsafe(f) {
|
|
3768
|
-
const { endo:
|
|
3768
|
+
const { endo: x } = e, v = this;
|
|
3769
3769
|
if (!n.isValid(f))
|
|
3770
3770
|
throw new Error("invalid scalar: out of range");
|
|
3771
3771
|
if (f === _e || v.is0())
|
|
@@ -3774,9 +3774,9 @@ function jr(r, e = {}) {
|
|
|
3774
3774
|
return v;
|
|
3775
3775
|
if (D.hasCache(this))
|
|
3776
3776
|
return this.multiply(f);
|
|
3777
|
-
if (
|
|
3777
|
+
if (x) {
|
|
3778
3778
|
const { k1neg: I, k1: L, k2neg: O, k2: M } = k(f), { p1: T, p2: $ } = Gr(R, v, L, M);
|
|
3779
|
-
return z(
|
|
3779
|
+
return z(x.beta, T, $, I, O);
|
|
3780
3780
|
} else
|
|
3781
3781
|
return D.unsafe(v, f);
|
|
3782
3782
|
}
|
|
@@ -3803,7 +3803,7 @@ function jr(r, e = {}) {
|
|
|
3803
3803
|
return this.multiplyUnsafe(i).is0();
|
|
3804
3804
|
}
|
|
3805
3805
|
toBytes(f = !0) {
|
|
3806
|
-
return qe(f, "isCompressed"), this.assertValidity(),
|
|
3806
|
+
return qe(f, "isCompressed"), this.assertValidity(), _(R, this, f);
|
|
3807
3807
|
}
|
|
3808
3808
|
toHex(f = !0) {
|
|
3809
3809
|
return Me(this.toBytes(f));
|
|
@@ -3836,50 +3836,50 @@ function As(r, e) {
|
|
|
3836
3836
|
}
|
|
3837
3837
|
function Yr(r, e = {}) {
|
|
3838
3838
|
const { Fn: s } = r, t = e.randomBytes || os, n = Object.assign(As(r.Fp, s), { seed: ws(s.ORDER) });
|
|
3839
|
-
function o(
|
|
3839
|
+
function o(_) {
|
|
3840
3840
|
try {
|
|
3841
|
-
const w = s.fromBytes(
|
|
3841
|
+
const w = s.fromBytes(_);
|
|
3842
3842
|
return s.isValidNot0(w);
|
|
3843
3843
|
} catch {
|
|
3844
3844
|
return !1;
|
|
3845
3845
|
}
|
|
3846
3846
|
}
|
|
3847
|
-
function i(
|
|
3848
|
-
const { publicKey:
|
|
3847
|
+
function i(_, w) {
|
|
3848
|
+
const { publicKey: S, publicKeyUncompressed: y } = n;
|
|
3849
3849
|
try {
|
|
3850
|
-
const
|
|
3851
|
-
return w === !0 &&
|
|
3850
|
+
const E = _.length;
|
|
3851
|
+
return w === !0 && E !== S || w === !1 && E !== y ? !1 : !!r.fromBytes(_);
|
|
3852
3852
|
} catch {
|
|
3853
3853
|
return !1;
|
|
3854
3854
|
}
|
|
3855
3855
|
}
|
|
3856
|
-
function a(
|
|
3857
|
-
return Hr(V(
|
|
3856
|
+
function a(_ = t(n.seed)) {
|
|
3857
|
+
return Hr(V(_, n.seed, "seed"), s.ORDER);
|
|
3858
3858
|
}
|
|
3859
|
-
function c(
|
|
3860
|
-
return r.BASE.multiply(s.fromBytes(
|
|
3859
|
+
function c(_, w = !0) {
|
|
3860
|
+
return r.BASE.multiply(s.fromBytes(_)).toBytes(w);
|
|
3861
3861
|
}
|
|
3862
|
-
function l(
|
|
3863
|
-
const { secretKey: w, publicKey:
|
|
3864
|
-
if (!ut(
|
|
3862
|
+
function l(_) {
|
|
3863
|
+
const { secretKey: w, publicKey: S, publicKeyUncompressed: y } = n;
|
|
3864
|
+
if (!ut(_) || "_lengths" in s && s._lengths || w === S)
|
|
3865
3865
|
return;
|
|
3866
|
-
const
|
|
3867
|
-
return
|
|
3866
|
+
const E = V(_, void 0, "key").length;
|
|
3867
|
+
return E === S || E === y;
|
|
3868
3868
|
}
|
|
3869
|
-
function
|
|
3870
|
-
if (l(
|
|
3869
|
+
function u(_, w, S = !0) {
|
|
3870
|
+
if (l(_) === !0)
|
|
3871
3871
|
throw new Error("first arg must be private key");
|
|
3872
3872
|
if (l(w) === !1)
|
|
3873
3873
|
throw new Error("second arg must be public key");
|
|
3874
|
-
const y = s.fromBytes(
|
|
3875
|
-
return r.fromBytes(w).multiply(y).toBytes(
|
|
3874
|
+
const y = s.fromBytes(_);
|
|
3875
|
+
return r.fromBytes(w).multiply(y).toBytes(S);
|
|
3876
3876
|
}
|
|
3877
3877
|
const h = {
|
|
3878
3878
|
isValidSecretKey: o,
|
|
3879
3879
|
isValidPublicKey: i,
|
|
3880
3880
|
randomSecretKey: a
|
|
3881
3881
|
}, m = qr(a, c);
|
|
3882
|
-
return Object.freeze({ getPublicKey: c, getSharedSecret:
|
|
3882
|
+
return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen: m, Point: r, utils: h, lengths: n });
|
|
3883
3883
|
}
|
|
3884
3884
|
function Jr(r, e, s = {}) {
|
|
3885
3885
|
ts(e), _t(s, {}, {
|
|
@@ -3889,70 +3889,70 @@ function Jr(r, e, s = {}) {
|
|
|
3889
3889
|
bits2int: "function",
|
|
3890
3890
|
bits2int_modN: "function"
|
|
3891
3891
|
}), s = Object.assign({}, s);
|
|
3892
|
-
const t = s.randomBytes || os, n = s.hmac || ((f,
|
|
3892
|
+
const t = s.randomBytes || os, n = s.hmac || ((f, x) => Ss(e, f, x)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: u, getSharedSecret: h, utils: m, lengths: _ } = Yr(r, s), w = {
|
|
3893
3893
|
prehash: !0,
|
|
3894
3894
|
lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
|
|
3895
3895
|
format: "compact",
|
|
3896
3896
|
extraEntropy: !1
|
|
3897
|
-
},
|
|
3897
|
+
}, S = a * Es < o.ORDER;
|
|
3898
3898
|
function y(f) {
|
|
3899
|
-
const
|
|
3900
|
-
return f >
|
|
3899
|
+
const x = a >> Re;
|
|
3900
|
+
return f > x;
|
|
3901
3901
|
}
|
|
3902
|
-
function
|
|
3903
|
-
if (!i.isValidNot0(
|
|
3902
|
+
function E(f, x) {
|
|
3903
|
+
if (!i.isValidNot0(x))
|
|
3904
3904
|
throw new Error(`invalid signature ${f}: out of range 1..Point.Fn.ORDER`);
|
|
3905
|
-
return
|
|
3905
|
+
return x;
|
|
3906
3906
|
}
|
|
3907
3907
|
function C() {
|
|
3908
|
-
if (
|
|
3908
|
+
if (S)
|
|
3909
3909
|
throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
3910
3910
|
}
|
|
3911
|
-
function B(f,
|
|
3912
|
-
ct(
|
|
3913
|
-
const v =
|
|
3911
|
+
function B(f, x) {
|
|
3912
|
+
ct(x);
|
|
3913
|
+
const v = _.signature, I = x === "compact" ? v : x === "recovered" ? v + 1 : void 0;
|
|
3914
3914
|
return V(f, I);
|
|
3915
3915
|
}
|
|
3916
3916
|
class b {
|
|
3917
|
-
constructor(
|
|
3917
|
+
constructor(x, v, I) {
|
|
3918
3918
|
A(this, "r");
|
|
3919
3919
|
A(this, "s");
|
|
3920
3920
|
A(this, "recovery");
|
|
3921
|
-
if (this.r =
|
|
3921
|
+
if (this.r = E("r", x), this.s = E("s", v), I != null) {
|
|
3922
3922
|
if (C(), ![0, 1, 2, 3].includes(I))
|
|
3923
3923
|
throw new Error("invalid recovery id");
|
|
3924
3924
|
this.recovery = I;
|
|
3925
3925
|
}
|
|
3926
3926
|
Object.freeze(this);
|
|
3927
3927
|
}
|
|
3928
|
-
static fromBytes(
|
|
3929
|
-
B(
|
|
3928
|
+
static fromBytes(x, v = w.format) {
|
|
3929
|
+
B(x, v);
|
|
3930
3930
|
let I;
|
|
3931
3931
|
if (v === "der") {
|
|
3932
|
-
const { r: T, s: $ } = ye.toSig(V(
|
|
3932
|
+
const { r: T, s: $ } = ye.toSig(V(x));
|
|
3933
3933
|
return new b(T, $);
|
|
3934
3934
|
}
|
|
3935
|
-
v === "recovered" && (I =
|
|
3936
|
-
const L =
|
|
3935
|
+
v === "recovered" && (I = x[0], v = "compact", x = x.subarray(1));
|
|
3936
|
+
const L = _.signature / 2, O = x.subarray(0, L), M = x.subarray(L, L * 2);
|
|
3937
3937
|
return new b(i.fromBytes(O), i.fromBytes(M), I);
|
|
3938
3938
|
}
|
|
3939
|
-
static fromHex(
|
|
3940
|
-
return this.fromBytes(We(
|
|
3939
|
+
static fromHex(x, v) {
|
|
3940
|
+
return this.fromBytes(We(x), v);
|
|
3941
3941
|
}
|
|
3942
3942
|
assertRecovery() {
|
|
3943
|
-
const { recovery:
|
|
3944
|
-
if (
|
|
3943
|
+
const { recovery: x } = this;
|
|
3944
|
+
if (x == null)
|
|
3945
3945
|
throw new Error("invalid recovery id: must be present");
|
|
3946
|
-
return
|
|
3946
|
+
return x;
|
|
3947
3947
|
}
|
|
3948
|
-
addRecoveryBit(
|
|
3949
|
-
return new b(this.r, this.s,
|
|
3948
|
+
addRecoveryBit(x) {
|
|
3949
|
+
return new b(this.r, this.s, x);
|
|
3950
3950
|
}
|
|
3951
|
-
recoverPublicKey(
|
|
3951
|
+
recoverPublicKey(x) {
|
|
3952
3952
|
const { r: v, s: I } = this, L = this.assertRecovery(), O = L === 2 || L === 3 ? v + a : v;
|
|
3953
3953
|
if (!o.isValid(O))
|
|
3954
3954
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
3955
|
-
const M = o.toBytes(O), T = r.fromBytes(ve(Is((L & 1) === 0), M)), $ = i.inv(O), F = P(V(
|
|
3955
|
+
const M = o.toBytes(O), T = r.fromBytes(ve(Is((L & 1) === 0), M)), $ = i.inv(O), F = P(V(x, void 0, "msgHash")), J = i.create(-F * $), K = i.create(I * $), H = r.BASE.multiplyUnsafe(J).add(T.multiplyUnsafe(K));
|
|
3956
3956
|
if (H.is0())
|
|
3957
3957
|
throw new Error("invalid recovery: point at infinify");
|
|
3958
3958
|
return H.assertValidity(), H;
|
|
@@ -3961,39 +3961,39 @@ function Jr(r, e, s = {}) {
|
|
|
3961
3961
|
hasHighS() {
|
|
3962
3962
|
return y(this.s);
|
|
3963
3963
|
}
|
|
3964
|
-
toBytes(
|
|
3965
|
-
if (ct(
|
|
3964
|
+
toBytes(x = w.format) {
|
|
3965
|
+
if (ct(x), x === "der")
|
|
3966
3966
|
return We(ye.hexFromSig(this));
|
|
3967
3967
|
const { r: v, s: I } = this, L = i.toBytes(v), O = i.toBytes(I);
|
|
3968
|
-
return
|
|
3968
|
+
return x === "recovered" ? (C(), ve(Uint8Array.of(this.assertRecovery()), L, O)) : ve(L, O);
|
|
3969
3969
|
}
|
|
3970
|
-
toHex(
|
|
3971
|
-
return Me(this.toBytes(
|
|
3970
|
+
toHex(x) {
|
|
3971
|
+
return Me(this.toBytes(x));
|
|
3972
3972
|
}
|
|
3973
3973
|
}
|
|
3974
|
-
const k = s.bits2int || function(
|
|
3975
|
-
if (
|
|
3974
|
+
const k = s.bits2int || function(x) {
|
|
3975
|
+
if (x.length > 8192)
|
|
3976
3976
|
throw new Error("input is too large");
|
|
3977
|
-
const v = ze(
|
|
3977
|
+
const v = ze(x), I = x.length * 8 - c;
|
|
3978
3978
|
return I > 0 ? v >> BigInt(I) : v;
|
|
3979
|
-
}, P = s.bits2int_modN || function(
|
|
3980
|
-
return i.create(k(
|
|
3979
|
+
}, P = s.bits2int_modN || function(x) {
|
|
3980
|
+
return i.create(k(x));
|
|
3981
3981
|
}, G = ft(c);
|
|
3982
3982
|
function z(f) {
|
|
3983
3983
|
return Tr("num < 2^" + c, f, _e, G), i.toBytes(f);
|
|
3984
3984
|
}
|
|
3985
|
-
function W(f,
|
|
3986
|
-
return V(f, void 0, "message"),
|
|
3985
|
+
function W(f, x) {
|
|
3986
|
+
return V(f, void 0, "message"), x ? V(e(f), void 0, "prehashed message") : f;
|
|
3987
3987
|
}
|
|
3988
|
-
function q(f,
|
|
3988
|
+
function q(f, x, v) {
|
|
3989
3989
|
const { lowS: I, prehash: L, extraEntropy: O } = st(v, w);
|
|
3990
3990
|
f = W(f, L);
|
|
3991
|
-
const M = P(f), T = i.fromBytes(
|
|
3991
|
+
const M = P(f), T = i.fromBytes(x);
|
|
3992
3992
|
if (!i.isValidNot0(T))
|
|
3993
3993
|
throw new Error("invalid private key");
|
|
3994
3994
|
const $ = [z(T), z(M)];
|
|
3995
3995
|
if (O != null && O !== !1) {
|
|
3996
|
-
const H = O === !0 ? t(
|
|
3996
|
+
const H = O === !0 ? t(_.secretKey) : O;
|
|
3997
3997
|
$.push(V(H, void 0, "extraEntropy"));
|
|
3998
3998
|
}
|
|
3999
3999
|
const F = ve(...$), J = M;
|
|
@@ -4008,17 +4008,17 @@ function Jr(r, e, s = {}) {
|
|
|
4008
4008
|
if (Q === _e)
|
|
4009
4009
|
return;
|
|
4010
4010
|
let yt = (oe.x === j ? 0 : 2) | Number(oe.y & Re), bt = Q;
|
|
4011
|
-
return I && y(Q) && (bt = i.neg(Q), yt ^= 1), new b(j, bt,
|
|
4011
|
+
return I && y(Q) && (bt = i.neg(Q), yt ^= 1), new b(j, bt, S ? void 0 : yt);
|
|
4012
4012
|
}
|
|
4013
4013
|
return { seed: F, k2sig: K };
|
|
4014
4014
|
}
|
|
4015
|
-
function D(f,
|
|
4016
|
-
const { seed: I, k2sig: L } = q(f,
|
|
4015
|
+
function D(f, x, v = {}) {
|
|
4016
|
+
const { seed: I, k2sig: L } = q(f, x, v);
|
|
4017
4017
|
return kr(e.outputLen, i.BYTES, n)(I, L).toBytes(v.format);
|
|
4018
4018
|
}
|
|
4019
|
-
function R(f,
|
|
4019
|
+
function R(f, x, v, I = {}) {
|
|
4020
4020
|
const { lowS: L, prehash: O, format: M } = st(I, w);
|
|
4021
|
-
if (v = V(v, void 0, "publicKey"),
|
|
4021
|
+
if (v = V(v, void 0, "publicKey"), x = W(x, O), !ut(f)) {
|
|
4022
4022
|
const T = f instanceof b ? ", use sig.toBytes()" : "";
|
|
4023
4023
|
throw new Error("verify expects Uint8Array signature" + T);
|
|
4024
4024
|
}
|
|
@@ -4027,22 +4027,22 @@ function Jr(r, e, s = {}) {
|
|
|
4027
4027
|
const T = b.fromBytes(f, M), $ = r.fromBytes(v);
|
|
4028
4028
|
if (L && T.hasHighS())
|
|
4029
4029
|
return !1;
|
|
4030
|
-
const { r: F, s: J } = T, K = P(
|
|
4030
|
+
const { r: F, s: J } = T, K = P(x), H = i.inv(J), X = i.create(K * H), Z = i.create(F * H), oe = r.BASE.multiplyUnsafe(X).add($.multiplyUnsafe(Z));
|
|
4031
4031
|
return oe.is0() ? !1 : i.create(oe.x) === F;
|
|
4032
4032
|
} catch {
|
|
4033
4033
|
return !1;
|
|
4034
4034
|
}
|
|
4035
4035
|
}
|
|
4036
|
-
function N(f,
|
|
4036
|
+
function N(f, x, v = {}) {
|
|
4037
4037
|
const { prehash: I } = st(v, w);
|
|
4038
|
-
return
|
|
4038
|
+
return x = W(x, I), b.fromBytes(f, "recovered").recoverPublicKey(x).toBytes();
|
|
4039
4039
|
}
|
|
4040
4040
|
return Object.freeze({
|
|
4041
4041
|
keygen: l,
|
|
4042
|
-
getPublicKey:
|
|
4042
|
+
getPublicKey: u,
|
|
4043
4043
|
getSharedSecret: h,
|
|
4044
4044
|
utils: m,
|
|
4045
|
-
lengths:
|
|
4045
|
+
lengths: _,
|
|
4046
4046
|
Point: r,
|
|
4047
4047
|
sign: D,
|
|
4048
4048
|
verify: R,
|
|
@@ -4068,7 +4068,7 @@ const gt = {
|
|
|
4068
4068
|
]
|
|
4069
4069
|
}, qt = /* @__PURE__ */ BigInt(2);
|
|
4070
4070
|
function Zr(r) {
|
|
4071
|
-
const e = gt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e,
|
|
4071
|
+
const e = gt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, u = l * l * r % e, h = ae(u, s, e) * u % e, m = ae(h, s, e) * u % e, _ = ae(m, qt, e) * l % e, w = ae(_, n, e) * _ % e, S = ae(w, o, e) * w % e, y = ae(S, a, e) * S % e, E = ae(y, c, e) * y % e, C = ae(E, a, e) * S % e, B = ae(C, s, e) * u % e, b = ae(B, i, e) * w % e, k = ae(b, t, e) * l % e, P = ae(k, qt, e);
|
|
4072
4072
|
if (!lt.eql(lt.sqr(P), r))
|
|
4073
4073
|
throw new Error("Cannot find square root");
|
|
4074
4074
|
return P;
|
|
@@ -4091,14 +4091,14 @@ function ln(r, e = 24) {
|
|
|
4091
4091
|
for (let i = 0; i < 10; i++)
|
|
4092
4092
|
s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
|
|
4093
4093
|
for (let i = 0; i < 10; i += 2) {
|
|
4094
|
-
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c],
|
|
4095
|
-
for (let
|
|
4096
|
-
r[i +
|
|
4094
|
+
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], u = s[c + 1], h = Kt(l, u, 1) ^ s[a], m = Vt(l, u, 1) ^ s[a + 1];
|
|
4095
|
+
for (let _ = 0; _ < 50; _ += 10)
|
|
4096
|
+
r[i + _] ^= h, r[i + _ + 1] ^= m;
|
|
4097
4097
|
}
|
|
4098
4098
|
let n = r[2], o = r[3];
|
|
4099
4099
|
for (let i = 0; i < 24; i++) {
|
|
4100
|
-
const a = Rs[i], c = Kt(n, o, a), l = Vt(n, o, a),
|
|
4101
|
-
n = r[
|
|
4100
|
+
const a = Rs[i], c = Kt(n, o, a), l = Vt(n, o, a), u = Ts[i];
|
|
4101
|
+
n = r[u], o = r[u + 1], r[u] = c, r[u + 1] = l;
|
|
4102
4102
|
}
|
|
4103
4103
|
for (let i = 0; i < 50; i += 10) {
|
|
4104
4104
|
for (let a = 0; a < 10; a++)
|
|
@@ -4193,46 +4193,46 @@ class hn {
|
|
|
4193
4193
|
}
|
|
4194
4194
|
setJWKSEndpoint(e) {
|
|
4195
4195
|
try {
|
|
4196
|
-
this.jwks = Ms(new URL(e)),
|
|
4196
|
+
this.jwks = Ms(new URL(e)), d.log("[CROSSx] JWKS 엔드포인트 설정:", e);
|
|
4197
4197
|
} catch (s) {
|
|
4198
|
-
|
|
4198
|
+
d.warn("[CROSSx] JWKS 엔드포인트 URL 파싱 실패:", s);
|
|
4199
4199
|
}
|
|
4200
4200
|
}
|
|
4201
4201
|
async verifyJWT(e, s) {
|
|
4202
4202
|
try {
|
|
4203
4203
|
const t = this.decodeJWT(e);
|
|
4204
|
-
|
|
4204
|
+
d.log("[CROSSx] JWT 디코딩 성공:", {
|
|
4205
4205
|
sub: t.sub,
|
|
4206
4206
|
exp: t.exp,
|
|
4207
4207
|
iat: t.iat
|
|
4208
4208
|
});
|
|
4209
4209
|
const n = Math.floor(Date.now() / 1e3);
|
|
4210
4210
|
if (t.exp && t.exp + un < n)
|
|
4211
|
-
return
|
|
4211
|
+
return d.warn("[CROSSx] 토큰 만료:", {
|
|
4212
4212
|
exp: t.exp,
|
|
4213
4213
|
now: n,
|
|
4214
4214
|
만료시간: new Date(t.exp * 1e3).toISOString()
|
|
4215
4215
|
}), { payload: t, valid: !1, signatureVerified: !1 };
|
|
4216
4216
|
if (!t.sub)
|
|
4217
|
-
return
|
|
4217
|
+
return d.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 };
|
|
4218
4218
|
if (this.jwks)
|
|
4219
4219
|
try {
|
|
4220
4220
|
const { payload: o } = await $s(e, this.jwks, {
|
|
4221
4221
|
algorithms: ["RS256", "ES256"]
|
|
4222
4222
|
});
|
|
4223
|
-
return
|
|
4223
|
+
return d.log("[CROSSx] JWT 서명 검증 성공"), {
|
|
4224
4224
|
payload: o,
|
|
4225
4225
|
valid: !0,
|
|
4226
4226
|
signatureVerified: !0
|
|
4227
4227
|
};
|
|
4228
4228
|
} catch (o) {
|
|
4229
4229
|
if (o instanceof Error && (o.name === "JWSSignatureVerificationFailed" || o.name === "JWTClaimValidationFailed"))
|
|
4230
|
-
return
|
|
4231
|
-
|
|
4230
|
+
return d.error("[CROSSx] JWT 서명 검증 실패:", o), { payload: t, valid: !1, signatureVerified: !1 };
|
|
4231
|
+
d.warn("[CROSSx] JWKS 엔드포인트 접근 불가 — 서명 미검증 모드로 전환");
|
|
4232
4232
|
}
|
|
4233
|
-
return
|
|
4233
|
+
return d.log("[CROSSx] JWT 검증 성공 (서명 미검증 — JWKS 미설정 또는 접근 불가)"), { payload: t, valid: !0, signatureVerified: !1 };
|
|
4234
4234
|
} catch (t) {
|
|
4235
|
-
throw
|
|
4235
|
+
throw d.error("[CROSSx] JWT 검증 중 에러:", t), t;
|
|
4236
4236
|
}
|
|
4237
4237
|
}
|
|
4238
4238
|
decodeJWT(e) {
|
|
@@ -4254,10 +4254,10 @@ ${t.length}`
|
|
|
4254
4254
|
const i = zt(o), a = s.startsWith("0x") ? s.slice(2) : s;
|
|
4255
4255
|
if (a.length !== 130)
|
|
4256
4256
|
throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
|
|
4257
|
-
const c = pn(a), l = c.slice(0, 32),
|
|
4257
|
+
const c = pn(a), l = c.slice(0, 32), u = c.slice(32, 64), h = c[64], m = h >= 27 ? h - 27 : h, S = new en.Signature(
|
|
4258
4258
|
jt(l),
|
|
4259
|
-
jt(
|
|
4260
|
-
).addRecoveryBit(m).recoverPublicKey(i).toBytes(!1).slice(1), y = zt(
|
|
4259
|
+
jt(u)
|
|
4260
|
+
).addRecoveryBit(m).recoverPublicKey(i).toBytes(!1).slice(1), y = zt(S);
|
|
4261
4261
|
return "0x" + Me(y.slice(12));
|
|
4262
4262
|
}
|
|
4263
4263
|
}
|
|
@@ -4349,21 +4349,21 @@ class be {
|
|
|
4349
4349
|
*/
|
|
4350
4350
|
static async verifyIdTokenNonce(e, s) {
|
|
4351
4351
|
const t = be.parseJwtPayload(e), n = t.nonce, o = typeof t.iss == "string" ? t.iss : "(unknown)";
|
|
4352
|
-
if (
|
|
4352
|
+
if (d.log("[CROSSx] nonce 검증 시작 —", {
|
|
4353
4353
|
iss: o,
|
|
4354
4354
|
nonceClaimType: typeof n,
|
|
4355
4355
|
nonceClaimPresent: typeof n == "string" && n !== "",
|
|
4356
4356
|
// Apple의 nonce_supported 플래그 확인 (false면 서버가 nonce를 전달하지 않은 것)
|
|
4357
4357
|
appleNonceSupported: t.nonce_supported ?? "(field absent)"
|
|
4358
4358
|
}), o.includes("securetoken.google.com")) {
|
|
4359
|
-
|
|
4359
|
+
d.log(
|
|
4360
4360
|
"[CROSSx] Firebase ID Token 감지 — nonce 검증 skip.",
|
|
4361
4361
|
"서버 측에서 Google/Apple nonce 검증이 완료된 것으로 간주합니다."
|
|
4362
4362
|
);
|
|
4363
4363
|
return;
|
|
4364
4364
|
}
|
|
4365
4365
|
if (typeof n != "string" || n === "")
|
|
4366
|
-
throw
|
|
4366
|
+
throw d.error("[CROSSx] nonce claim 누락 — JWT payload 전체 키 목록:", Object.keys(t)), d.error(
|
|
4367
4367
|
"[CROSSx] 원인 추정: OAuth 서버가 Google/Apple 인증 요청에 nonce 파라미터를 포함하지 않았을 수 있습니다.",
|
|
4368
4368
|
"서버 로그에서 /auth/google, /auth/apple 요청 URL에 nonce 쿼리가 있는지 확인하세요."
|
|
4369
4369
|
), new Error(
|
|
@@ -4371,24 +4371,24 @@ class be {
|
|
|
4371
4371
|
);
|
|
4372
4372
|
if (o.includes("appleid.apple.com")) {
|
|
4373
4373
|
const i = await be.sha256Hex(s);
|
|
4374
|
-
if (
|
|
4374
|
+
if (d.log("[CROSSx] Apple nonce 검증 —", {
|
|
4375
4375
|
expectedHashLength: i.length,
|
|
4376
4376
|
receivedHashLength: n.length,
|
|
4377
4377
|
match: n === i
|
|
4378
4378
|
}), n !== i)
|
|
4379
4379
|
throw new Error("ID Token nonce 불일치 — replay attack 가능성이 있습니다");
|
|
4380
|
-
} else if (
|
|
4380
|
+
} else if (d.log("[CROSSx] Google nonce 검증 —", {
|
|
4381
4381
|
expectedLength: s.length,
|
|
4382
4382
|
receivedLength: n.length,
|
|
4383
4383
|
match: n === s
|
|
4384
4384
|
}), n !== s)
|
|
4385
4385
|
throw new Error("ID Token nonce 불일치 — replay attack 가능성이 있습니다");
|
|
4386
|
-
|
|
4386
|
+
d.log("[CROSSx] nonce 검증 성공 —", { iss: o });
|
|
4387
4387
|
}
|
|
4388
4388
|
openAuth(e) {
|
|
4389
4389
|
return new Promise((s, t) => {
|
|
4390
|
-
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(),
|
|
4391
|
-
|
|
4390
|
+
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(), u = e.authUrl.includes("?") ? "&" : "?", h = `${e.authUrl}${u}state=${c}&nonce=${l}`;
|
|
4391
|
+
d.log("[CROSSx] OAuth 팝업 열기 — state, nonce 생성 완료:", {
|
|
4392
4392
|
stateLength: c.length,
|
|
4393
4393
|
nonceLength: l.length,
|
|
4394
4394
|
authUrlBase: e.authUrl
|
|
@@ -4402,16 +4402,16 @@ class be {
|
|
|
4402
4402
|
t(new Error("팝업 창을 열 수 없습니다. 팝업 차단을 해제해 주세요."));
|
|
4403
4403
|
return;
|
|
4404
4404
|
}
|
|
4405
|
-
const
|
|
4406
|
-
|
|
4407
|
-
}, 5 * 60 * 1e3), w = 10,
|
|
4408
|
-
let y = 0,
|
|
4405
|
+
const _ = setTimeout(() => {
|
|
4406
|
+
d.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), b(), t(new Error("Authentication timeout"));
|
|
4407
|
+
}, 5 * 60 * 1e3), w = 10, S = 30;
|
|
4408
|
+
let y = 0, E = null;
|
|
4409
4409
|
const C = () => {
|
|
4410
|
-
clearInterval(B),
|
|
4410
|
+
clearInterval(B), d.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + S + "초간 대기합니다"), E = setTimeout(() => {
|
|
4411
4411
|
b(), t(new Error(
|
|
4412
4412
|
"OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
|
|
4413
4413
|
));
|
|
4414
|
-
},
|
|
4414
|
+
}, S * 1e3);
|
|
4415
4415
|
}, B = setInterval(() => {
|
|
4416
4416
|
y++;
|
|
4417
4417
|
try {
|
|
@@ -4420,39 +4420,39 @@ class be {
|
|
|
4420
4420
|
C();
|
|
4421
4421
|
}
|
|
4422
4422
|
}, 1e3), b = () => {
|
|
4423
|
-
clearTimeout(
|
|
4423
|
+
clearTimeout(_), clearInterval(B), E && clearTimeout(E), window.removeEventListener("message", k);
|
|
4424
4424
|
}, k = (P) => {
|
|
4425
4425
|
var z, W, q, D, R;
|
|
4426
4426
|
if (P.origin !== e.expectedOrigin) return;
|
|
4427
4427
|
if (!gn.has(P.origin)) {
|
|
4428
|
-
|
|
4428
|
+
d.error("[CROSSx] postMessage origin이 허용 목록에 없음:", P.origin), b(), t(new Error("Unauthorized OAuth origin"));
|
|
4429
4429
|
return;
|
|
4430
4430
|
}
|
|
4431
|
-
b(),
|
|
4431
|
+
b(), d.log("[CROSSx] OAuth postMessage 수신 — status:", P.data.status);
|
|
4432
4432
|
const G = P.data.state ?? ((z = P.data.data) == null ? void 0 : z.state);
|
|
4433
4433
|
if (!G || G !== c) {
|
|
4434
4434
|
t(new Error("OAuth state mismatch — possible CSRF attack"));
|
|
4435
4435
|
return;
|
|
4436
4436
|
}
|
|
4437
4437
|
if (P.data.status === "success") {
|
|
4438
|
-
const N = (W = P.data.data) == null ? void 0 : W.idToken, f = (q = P.data.data) == null ? void 0 : q.accessToken,
|
|
4439
|
-
if (
|
|
4438
|
+
const N = (W = P.data.data) == null ? void 0 : W.idToken, f = (q = P.data.data) == null ? void 0 : q.accessToken, x = f ?? N;
|
|
4439
|
+
if (d.log("[CROSSx] OAuth 토큰 수신:", {
|
|
4440
4440
|
hasAccessToken: !!f,
|
|
4441
4441
|
hasIdToken: !!N
|
|
4442
|
-
}), !
|
|
4443
|
-
|
|
4442
|
+
}), !x) {
|
|
4443
|
+
d.error("[CROSSx] 토큰을 찾을 수 없음:", P.data), t(new Error("Token not found in response"));
|
|
4444
4444
|
return;
|
|
4445
4445
|
}
|
|
4446
|
-
N ? be.verifyIdTokenNonce(N, l).then(() => s(
|
|
4447
|
-
|
|
4448
|
-
}) : f ? f.split(".").length === 3 ? be.verifyIdTokenNonce(f, l).then(() => s(
|
|
4449
|
-
|
|
4450
|
-
}) : (
|
|
4446
|
+
N ? be.verifyIdTokenNonce(N, l).then(() => s(x)).catch((v) => {
|
|
4447
|
+
d.error("[CROSSx] nonce 검증 실패:", v), t(v instanceof Error ? v : new Error("nonce verification failed"));
|
|
4448
|
+
}) : f ? f.split(".").length === 3 ? be.verifyIdTokenNonce(f, l).then(() => s(x)).catch((I) => {
|
|
4449
|
+
d.error("[CROSSx] accessToken nonce 검증 실패:", I), t(I instanceof Error ? I : new Error("nonce verification failed"));
|
|
4450
|
+
}) : (d.warn(
|
|
4451
4451
|
"[CROSSx] opaque accessToken만 수신 (idToken 없음) — nonce 검증 불가.",
|
|
4452
4452
|
"서버 측 nonce 검증이 필요합니다."
|
|
4453
|
-
), s(
|
|
4453
|
+
), s(x)) : t(new Error("Token not found in response"));
|
|
4454
4454
|
} else
|
|
4455
|
-
|
|
4455
|
+
d.error("[CROSSx] OAuth 실패:", (D = P.data.data) == null ? void 0 : D.error), t(new Error(((R = P.data.data) == null ? void 0 : R.error) || "Authentication failed"));
|
|
4456
4456
|
};
|
|
4457
4457
|
window.addEventListener("message", k);
|
|
4458
4458
|
});
|
|
@@ -4471,9 +4471,9 @@ class mn {
|
|
|
4471
4471
|
*/
|
|
4472
4472
|
async checkWallet() {
|
|
4473
4473
|
if (this.migrateScenario !== void 0)
|
|
4474
|
-
return
|
|
4474
|
+
return d.log("[Mock] checkWallet → migration_required"), "migration_required";
|
|
4475
4475
|
const s = await this.storage.get(Ce) ? "exists" : "not_found";
|
|
4476
|
-
return
|
|
4476
|
+
return d.log(`[Mock] checkWallet → ${s}`), s;
|
|
4477
4477
|
}
|
|
4478
4478
|
async getOrCreateWallet(e) {
|
|
4479
4479
|
var s;
|
|
@@ -4488,7 +4488,7 @@ class mn {
|
|
|
4488
4488
|
};
|
|
4489
4489
|
await this.storage.set(Ce, n);
|
|
4490
4490
|
const o = (s = this.pinStore) == null ? void 0 : s.get();
|
|
4491
|
-
return o && (await this.storage.set(Te, o),
|
|
4491
|
+
return o && (await this.storage.set(Te, o), d.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
|
|
4492
4492
|
} catch (t) {
|
|
4493
4493
|
throw new g(p.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", t);
|
|
4494
4494
|
}
|
|
@@ -4506,21 +4506,21 @@ class mn {
|
|
|
4506
4506
|
}
|
|
4507
4507
|
async prepare(e, s) {
|
|
4508
4508
|
const t = "mock-" + crypto.randomUUID();
|
|
4509
|
-
return
|
|
4509
|
+
return d.log(`[Mock] prepare action=${e} → uuid=${t}`), { uuid: t, expiresAt: new Date(Date.now() + 5 * 6e4).toISOString() };
|
|
4510
4510
|
}
|
|
4511
4511
|
async signMessage(e, s, t, n = 0, o, i) {
|
|
4512
|
-
return
|
|
4512
|
+
return d.log(`[Mock] signMessage chainId=${s} index=${n} uuid=${o} from=${i}: "${t}"`), { chainId: s, signature: this.generateMockSignature(), format: "hex" };
|
|
4513
4513
|
}
|
|
4514
4514
|
async signTypedData(e, s, t, n = 0, o, i) {
|
|
4515
|
-
return
|
|
4515
|
+
return d.log(`[Mock] signTypedData chainId=${s} index=${n} uuid=${o} from=${i}`), { chainId: s, signature: this.generateMockSignature(), format: "hex" };
|
|
4516
4516
|
}
|
|
4517
4517
|
async signTransaction(e, s, t, n = 0, o) {
|
|
4518
|
-
|
|
4518
|
+
d.log(`[Mock] signTransaction chainId=${s} index=${n} uuid=${o}:`, t);
|
|
4519
4519
|
const i = "0x" + Array(64).fill(0).map(() => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
4520
4520
|
return { chainId: s, signature: this.generateMockSignature(), txHash: i, format: "hex" };
|
|
4521
4521
|
}
|
|
4522
4522
|
async sendTransaction(e, s, t, n) {
|
|
4523
|
-
return
|
|
4523
|
+
return d.log(`[Mock] sendTransaction chainId=${s} uuid=${n}:`, t), { txHash: "0x" + Array(64).fill(0).map(() => Math.floor(Math.random() * 16).toString(16)).join("") };
|
|
4524
4524
|
}
|
|
4525
4525
|
/**
|
|
4526
4526
|
* POST /mnemonic/verify-password 모킹
|
|
@@ -4528,10 +4528,10 @@ class mn {
|
|
|
4528
4528
|
*/
|
|
4529
4529
|
async verifyPin(e) {
|
|
4530
4530
|
var t;
|
|
4531
|
-
if (
|
|
4531
|
+
if (d.log("[Mock] verifyPin"), this.pinScenario === "wrong")
|
|
4532
4532
|
return !1;
|
|
4533
4533
|
const s = await this.storage.get(Te);
|
|
4534
|
-
return s && s !== e ? !1 : (s || await this.storage.set(Te, e), (t = this.pinStore) == null || t.set(e),
|
|
4534
|
+
return s && s !== e ? !1 : (s || await this.storage.set(Te, e), (t = this.pinStore) == null || t.set(e), d.log("[Mock] verifyPin → 성공"), !0);
|
|
4535
4535
|
}
|
|
4536
4536
|
/**
|
|
4537
4537
|
* POST /mnemonic/change-password 모킹
|
|
@@ -4539,16 +4539,16 @@ class mn {
|
|
|
4539
4539
|
*/
|
|
4540
4540
|
async changePin(e, s) {
|
|
4541
4541
|
var o;
|
|
4542
|
-
if (
|
|
4542
|
+
if (d.log("[Mock] changePin"), this.pinScenario === "wrong")
|
|
4543
4543
|
throw new g(p.PIN_WRONG, "Incorrect PIN.");
|
|
4544
4544
|
const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Te);
|
|
4545
4545
|
if (n && t && n !== t)
|
|
4546
4546
|
throw new g(p.PIN_WRONG, "Incorrect PIN.");
|
|
4547
|
-
await this.storage.set(Te, s),
|
|
4547
|
+
await this.storage.set(Te, s), d.log("[Mock] changePin 완료");
|
|
4548
4548
|
}
|
|
4549
4549
|
async migrateWallet(e, s) {
|
|
4550
4550
|
var o;
|
|
4551
|
-
if (
|
|
4551
|
+
if (d.log(`[Mock] migrateWallet pin=${e} sub=${s}`), this.migrateScenario === "wrong_pin")
|
|
4552
4552
|
throw new g(p.MIGRATION_FAILED, "Incorrect PIN.", {
|
|
4553
4553
|
permanent: !1,
|
|
4554
4554
|
lockExpiresAt: 0,
|
|
@@ -4577,21 +4577,21 @@ class mn {
|
|
|
4577
4577
|
};
|
|
4578
4578
|
await this.storage.set(Ce, t);
|
|
4579
4579
|
const n = (o = this.pinStore) == null ? void 0 : o.get();
|
|
4580
|
-
return n && (await this.storage.set(Te, n),
|
|
4580
|
+
return n && (await this.storage.set(Te, n), d.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
|
|
4581
4581
|
}
|
|
4582
4582
|
/**
|
|
4583
4583
|
* POST /mnemonic/share-c 모킹
|
|
4584
4584
|
* 새로운 Share-C 문자열을 반환합니다.
|
|
4585
4585
|
*/
|
|
4586
4586
|
async getShareC() {
|
|
4587
|
-
return
|
|
4587
|
+
return d.log("[Mock] getShareC"), "mock-share-c-" + crypto.randomUUID();
|
|
4588
4588
|
}
|
|
4589
4589
|
/**
|
|
4590
4590
|
* POST /mnemonic/verify-recovery-pin 모킹
|
|
4591
4591
|
* CROSSx 4자리 복구 PIN 검증
|
|
4592
4592
|
*/
|
|
4593
4593
|
async verifyRecoveryPin(e, s) {
|
|
4594
|
-
return
|
|
4594
|
+
return d.log("[Mock] verifyRecoveryPin"), { valid: !0 };
|
|
4595
4595
|
}
|
|
4596
4596
|
generateMockEvmAddress() {
|
|
4597
4597
|
return "0x" + Array(40).fill(0).map(
|
|
@@ -4635,32 +4635,32 @@ class Le {
|
|
|
4635
4635
|
"X-Project-Id": this.projectId
|
|
4636
4636
|
};
|
|
4637
4637
|
try {
|
|
4638
|
-
const
|
|
4638
|
+
const u = (await this.transport.request({
|
|
4639
4639
|
url: o,
|
|
4640
4640
|
method: e,
|
|
4641
4641
|
headers: i,
|
|
4642
4642
|
body: t ?? void 0
|
|
4643
4643
|
})).data;
|
|
4644
|
-
if (
|
|
4645
|
-
if (
|
|
4646
|
-
const h =
|
|
4647
|
-
|
|
4648
|
-
code:
|
|
4644
|
+
if (u && typeof u.code == "number") {
|
|
4645
|
+
if (u.code < 0 || u.code >= 400) {
|
|
4646
|
+
const h = u.message || u.data || "API 요청에 실패했습니다";
|
|
4647
|
+
d.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
|
|
4648
|
+
code: u.code,
|
|
4649
4649
|
message: h,
|
|
4650
4650
|
url: o,
|
|
4651
4651
|
method: e
|
|
4652
4652
|
});
|
|
4653
|
-
const m = Le.mapGatewayError(
|
|
4654
|
-
throw m === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (
|
|
4653
|
+
const m = Le.mapGatewayError(u.code, u.data), _ = Le.getGatewayErrorMessage(u.code, h), w = u.data, S = m === p.PIN_LOCKED ? Le.extractLockDetails(w) : w ?? void 0, y = new g(m, _, S);
|
|
4654
|
+
throw m === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (d.warn("[CROSSx] Gateway -10002 감지 — 강제 로그아웃 실행"), this._onUnauthorized()), y;
|
|
4655
4655
|
}
|
|
4656
|
-
return
|
|
4656
|
+
return d.log("[CROSSx] Wallet Gateway API 성공:", { code: u.code, url: o, method: e }), u.data ?? u;
|
|
4657
4657
|
}
|
|
4658
|
-
return
|
|
4658
|
+
return u;
|
|
4659
4659
|
} catch (l) {
|
|
4660
4660
|
if (l instanceof g) throw l;
|
|
4661
4661
|
if ((a = l.response) != null && a.data) {
|
|
4662
|
-
const
|
|
4663
|
-
throw
|
|
4662
|
+
const u = l.response.data, h = u.message || u.data || "API 요청에 실패했습니다", m = u.code || "UNKNOWN";
|
|
4663
|
+
throw d.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
|
|
4664
4664
|
code: m,
|
|
4665
4665
|
message: h,
|
|
4666
4666
|
url: o,
|
|
@@ -4679,9 +4679,9 @@ class Le {
|
|
|
4679
4679
|
* 결과를 내부 캐시에 저장하여 getOrCreateWallet에서 재사용합니다.
|
|
4680
4680
|
*/
|
|
4681
4681
|
async checkWallet() {
|
|
4682
|
-
|
|
4682
|
+
d.log("[CROSSx] GET /mnemonic/check");
|
|
4683
4683
|
const e = await this.request("GET", "/mnemonic/check");
|
|
4684
|
-
return
|
|
4684
|
+
return d.log("[CROSSx] /mnemonic/check 결과:", e.result), this._walletStatusCache = e.result, e.result;
|
|
4685
4685
|
}
|
|
4686
4686
|
/**
|
|
4687
4687
|
* 지갑 생성 또는 로드
|
|
@@ -4692,24 +4692,24 @@ class Le {
|
|
|
4692
4692
|
*/
|
|
4693
4693
|
async getOrCreateWallet(e) {
|
|
4694
4694
|
let s;
|
|
4695
|
-
if (this._walletStatusCache !== null ? (s = this._walletStatusCache, this._walletStatusCache = null,
|
|
4696
|
-
throw
|
|
4695
|
+
if (this._walletStatusCache !== null ? (s = this._walletStatusCache, this._walletStatusCache = null, d.log("[CROSSx] getOrCreateWallet — 캐시된 상태 사용:", s)) : (d.log("[CROSSx] GET /mnemonic/check — 지갑 상태 확인"), s = await this.checkWallet(), this._walletStatusCache = null), s === "migration_required")
|
|
4696
|
+
throw d.log("[CROSSx] migration_required → MIGRATION_BACKUP_EXISTS throw"), new g(
|
|
4697
4697
|
p.MIGRATION_BACKUP_EXISTS,
|
|
4698
4698
|
"CROSSx 백업이 존재합니다. 마이그레이션을 진행해 주세요."
|
|
4699
4699
|
);
|
|
4700
4700
|
if (s === "exists") {
|
|
4701
|
-
|
|
4701
|
+
d.log("[CROSSx] 기존 지갑 발견 — POST /mnemonic/address(0)로 주소 조회");
|
|
4702
4702
|
const o = await this.getAddress(e, 0);
|
|
4703
|
-
return
|
|
4703
|
+
return d.log("[CROSSx] 주소 조회 완료 — address:", o.address), {
|
|
4704
4704
|
id: e,
|
|
4705
4705
|
address: o.address,
|
|
4706
4706
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
4707
4707
|
createdAt: Date.now()
|
|
4708
4708
|
};
|
|
4709
4709
|
}
|
|
4710
|
-
|
|
4710
|
+
d.log("[CROSSx] POST /mnemonic/create — 신규 지갑 생성");
|
|
4711
4711
|
const t = { ignoreBackup: !1, password: this.requirePin() }, n = await this.request("POST", "/mnemonic/create", t);
|
|
4712
|
-
return
|
|
4712
|
+
return d.log("[CROSSx] /mnemonic/create 완료 — address:", n.address), {
|
|
4713
4713
|
id: e,
|
|
4714
4714
|
address: n.address,
|
|
4715
4715
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
@@ -4803,13 +4803,13 @@ class Le {
|
|
|
4803
4803
|
)).txHash };
|
|
4804
4804
|
}
|
|
4805
4805
|
async migrateWallet(e, s) {
|
|
4806
|
-
|
|
4806
|
+
d.log("[CROSSx][Migration Phase 4] POST /mnemonic/migrate 호출");
|
|
4807
4807
|
const t = { recoveryPin: e, sub: s, password: this.requirePin() }, n = await this.request(
|
|
4808
4808
|
"POST",
|
|
4809
4809
|
"/mnemonic/migrate",
|
|
4810
4810
|
t
|
|
4811
4811
|
);
|
|
4812
|
-
return
|
|
4812
|
+
return d.log("[CROSSx][Migration Phase 4] /mnemonic/migrate 완료 — address:", n.address), {
|
|
4813
4813
|
id: s,
|
|
4814
4814
|
address: n.address,
|
|
4815
4815
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
@@ -7028,8 +7028,8 @@ function Tn(r, e) {
|
|
|
7028
7028
|
}
|
|
7029
7029
|
function Rn(r, e) {
|
|
7030
7030
|
const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Ye(r.dappName), i = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
7031
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", a = Os(r), l = bn(r.value, t, n) ?? "—",
|
|
7032
|
-
return
|
|
7031
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", a = Os(r), l = bn(r.value, t, n) ?? "—", u = document.createElement("div");
|
|
7032
|
+
return u.id = te, u.innerHTML = `
|
|
7033
7033
|
<div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7034
7034
|
<div class="__crossx-header">
|
|
7035
7035
|
<p class="__crossx-title" id="__crossx-ttl">Approve transaction</p>
|
|
@@ -7054,7 +7054,7 @@ function Rn(r, e) {
|
|
|
7054
7054
|
<button class="__crossx-approve-btn" id="__crossx-confirm-btn">Approve</button>
|
|
7055
7055
|
</div>
|
|
7056
7056
|
</div>
|
|
7057
|
-
`,
|
|
7057
|
+
`, u;
|
|
7058
7058
|
}
|
|
7059
7059
|
function Ye(r) {
|
|
7060
7060
|
var e;
|
|
@@ -7132,8 +7132,8 @@ function On(r, e) {
|
|
|
7132
7132
|
function Cn(r, e, s) {
|
|
7133
7133
|
const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
|
|
7134
7134
|
if (o) {
|
|
7135
|
-
const w = n ? An : t ? "" : In,
|
|
7136
|
-
w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${
|
|
7135
|
+
const w = n ? An : t ? "" : In, S = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
|
|
7136
|
+
w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${S}</span>`) : o.textContent = S;
|
|
7137
7137
|
}
|
|
7138
7138
|
if (i && !r.querySelector("#__crossx-close-btn")) {
|
|
7139
7139
|
const w = document.createElement("button");
|
|
@@ -7143,8 +7143,8 @@ function Cn(r, e, s) {
|
|
|
7143
7143
|
if (!a) return;
|
|
7144
7144
|
const c = e.from ? Y("From", `<span class="__crossx-addr-text">${se(e.from)}</span>
|
|
7145
7145
|
<button class="__crossx-copy-btn" data-copy="${U(e.from)}" title="Copy address">${xe}</button>`) : "", l = e.to ? Y("To", `<span class="__crossx-addr-text">${se(e.to)}</span>
|
|
7146
|
-
<button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${xe}</button>`) : "",
|
|
7147
|
-
<button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${xe}</button>`) : "",
|
|
7146
|
+
<button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${xe}</button>`) : "", u = e.amount ? Y("Transfer", `<span>${U(e.amount)}</span>`) : "", h = e.fees ? Y("Tx Fee", `<span>${U(e.fees)}</span>`) : "", m = e.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(e.txHash)}</span>
|
|
7147
|
+
<button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${xe}</button>`) : "", _ = e.total ? `<div class="__crossx-total-pill">
|
|
7148
7148
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
7149
7149
|
<span class="__crossx-total-amount">${U(e.total)}</span>
|
|
7150
7150
|
</div>` : "";
|
|
@@ -7152,18 +7152,18 @@ function Cn(r, e, s) {
|
|
|
7152
7152
|
<div class="__crossx-rows">
|
|
7153
7153
|
${c}
|
|
7154
7154
|
${l}
|
|
7155
|
-
${
|
|
7155
|
+
${u}
|
|
7156
7156
|
${h}
|
|
7157
7157
|
${m}
|
|
7158
7158
|
</div>
|
|
7159
|
-
${
|
|
7159
|
+
${_}
|
|
7160
7160
|
<button class="__crossx-approve-btn" id="__crossx-done-btn">${t ? "All Done" : "Done"}</button>
|
|
7161
7161
|
`, a.querySelectorAll(".__crossx-copy-btn").forEach((w) => {
|
|
7162
|
-
w.addEventListener("click", (
|
|
7163
|
-
var
|
|
7164
|
-
|
|
7162
|
+
w.addEventListener("click", (S) => {
|
|
7163
|
+
var E;
|
|
7164
|
+
S.stopPropagation();
|
|
7165
7165
|
const y = w.dataset.copy;
|
|
7166
|
-
y && ((
|
|
7166
|
+
y && ((E = navigator.clipboard) == null || E.writeText(y).catch(() => {
|
|
7167
7167
|
}));
|
|
7168
7168
|
});
|
|
7169
7169
|
});
|
|
@@ -7215,13 +7215,13 @@ function Dn(r, e) {
|
|
|
7215
7215
|
<span class="__crossx-td-label">Primary Type</span>
|
|
7216
7216
|
<span class="__crossx-td-value">${U(o)}</span>
|
|
7217
7217
|
</div>`;
|
|
7218
|
-
for (const [l,
|
|
7219
|
-
const h = Pn(
|
|
7220
|
-
<button class="__crossx-copy-btn" data-copy="${U(String(
|
|
7218
|
+
for (const [l, u] of Object.entries(i)) {
|
|
7219
|
+
const h = Pn(u), _ = kn(u) ? `<span class="__crossx-addr-text">${se(u)}</span>
|
|
7220
|
+
<button class="__crossx-copy-btn" data-copy="${U(String(u))}" title="Copy">${xe}</button>` : `<span>${h}</span>`;
|
|
7221
7221
|
a += `
|
|
7222
7222
|
<div class="__crossx-td-row">
|
|
7223
7223
|
<span class="__crossx-td-label">${U(l)}</span>
|
|
7224
|
-
<div class="__crossx-td-value">${
|
|
7224
|
+
<div class="__crossx-td-value">${_}</div>
|
|
7225
7225
|
</div>`;
|
|
7226
7226
|
}
|
|
7227
7227
|
const c = document.createElement("div");
|
|
@@ -7339,14 +7339,14 @@ function Hn(r) {
|
|
|
7339
7339
|
</div>
|
|
7340
7340
|
`, s;
|
|
7341
7341
|
}
|
|
7342
|
-
function Fn(r) {
|
|
7343
|
-
const
|
|
7344
|
-
return
|
|
7345
|
-
<div class="__crossx-card __crossx-card--migration" style="${ce(
|
|
7342
|
+
function Fn(r, e = !0) {
|
|
7343
|
+
const s = r, t = e ? `<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>` : "", n = e ? '<button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>' : "", o = document.createElement("div");
|
|
7344
|
+
return o.id = te, o.innerHTML = `
|
|
7345
|
+
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7346
7346
|
<div class="__crossx-header">
|
|
7347
7347
|
<p class="__crossx-title" id="__crossx-ttl">Wallet Found on Social Account 🎉</p>
|
|
7348
7348
|
<p class="__crossx-subtitle--body">We found a wallet linked to your social account. Enter your 4-digit PIN to restore your assets.</p>
|
|
7349
|
-
|
|
7349
|
+
${t}
|
|
7350
7350
|
</div>
|
|
7351
7351
|
<hr class="__crossx-divider">
|
|
7352
7352
|
<div class="__crossx-body">
|
|
@@ -7358,13 +7358,13 @@ function Fn(r) {
|
|
|
7358
7358
|
<span class="__crossx-recover-icon">${En}</span>
|
|
7359
7359
|
<span class="__crossx-recover-label">Import from Social Backup</span>
|
|
7360
7360
|
</button>
|
|
7361
|
-
|
|
7361
|
+
${n}
|
|
7362
7362
|
</div>
|
|
7363
7363
|
</div>
|
|
7364
|
-
`,
|
|
7364
|
+
`, o;
|
|
7365
7365
|
}
|
|
7366
7366
|
function Gn(r, e) {
|
|
7367
|
-
const s = r, { errorMessage: t, attemptCount: n, maxAttempts: o = 5 } = e ?? {}, i = !!t, a = i ? " --error" : "", c = n != null && n > 0 ? `<p class="__crossx-pin-attempt">${n}/${o}</p>` : "", l = n != null && n >= 3 ? '<p class="__crossx-pin-warning">Your account will be locked after further failures.</p>' : "",
|
|
7367
|
+
const s = r, { errorMessage: t, attemptCount: n, maxAttempts: o = 5 } = e ?? {}, i = !!t, a = i ? " --error" : "", c = n != null && n > 0 ? `<p class="__crossx-pin-attempt">${n}/${o}</p>` : "", l = n != null && n >= 3 ? '<p class="__crossx-pin-warning">Your account will be locked after further failures.</p>' : "", u = i ? `<p class="__crossx-pin-error-text">${t}</p>` : "", h = document.createElement("div");
|
|
7368
7368
|
return h.id = te, h.innerHTML = `
|
|
7369
7369
|
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7370
7370
|
<div class="__crossx-header">
|
|
@@ -7382,7 +7382,7 @@ function Gn(r, e) {
|
|
|
7382
7382
|
<input class="__crossx-pin-input${a}" type="tel" maxlength="1" inputmode="numeric" pattern="[0-9]" autocomplete="off">
|
|
7383
7383
|
</div>
|
|
7384
7384
|
<p class="__crossx-pin-hint">Enter your 4-digit PIN to recover your wallet.</p>
|
|
7385
|
-
${
|
|
7385
|
+
${u}
|
|
7386
7386
|
</div>
|
|
7387
7387
|
</div>
|
|
7388
7388
|
`, h;
|
|
@@ -7464,7 +7464,7 @@ function nt(r) {
|
|
|
7464
7464
|
<span id="__crossx-pin6-lock-countdown"></span>
|
|
7465
7465
|
</p>` : "", a = e ? " --locked" : "", c = Array.from(
|
|
7466
7466
|
{ length: 6 },
|
|
7467
|
-
(l,
|
|
7467
|
+
(l, u) => `<input class="__crossx-pin6-box${a}" type="password" maxlength="1" inputmode="numeric" pattern="[0-9]" autocomplete="off" aria-label="PIN digit ${u + 1}"${e ? " disabled" : ""}>`
|
|
7468
7468
|
).join("");
|
|
7469
7469
|
return `
|
|
7470
7470
|
<div class="__crossx-header">
|
|
@@ -7505,15 +7505,15 @@ function zn(r) {
|
|
|
7505
7505
|
}
|
|
7506
7506
|
function ot(r, e, s, t, n, o) {
|
|
7507
7507
|
let i = !!(o && o > Date.now()), a = !1;
|
|
7508
|
-
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"),
|
|
7508
|
+
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), u = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), m = () => r.querySelector("#__crossx-pin6-lock-countdown"), _ = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((b) => b.value).join(""), S = (b) => {
|
|
7509
7509
|
i = b, c().forEach((k) => {
|
|
7510
7510
|
k.disabled = b, k.classList.toggle("--locked", b);
|
|
7511
7511
|
});
|
|
7512
7512
|
}, y = () => {
|
|
7513
|
-
const b =
|
|
7513
|
+
const b = u();
|
|
7514
7514
|
b && (b.textContent = "");
|
|
7515
|
-
},
|
|
7516
|
-
const k =
|
|
7515
|
+
}, E = (b) => {
|
|
7516
|
+
const k = u();
|
|
7517
7517
|
k && (k.textContent = b);
|
|
7518
7518
|
const P = l();
|
|
7519
7519
|
P == null || P.classList.add("--shake"), setTimeout(() => P == null ? void 0 : P.classList.remove("--shake"), 500), c().forEach((G) => {
|
|
@@ -7524,20 +7524,20 @@ function ot(r, e, s, t, n, o) {
|
|
|
7524
7524
|
}, 50);
|
|
7525
7525
|
}, C = (b) => {
|
|
7526
7526
|
var W;
|
|
7527
|
-
|
|
7527
|
+
S(!0), c().forEach((q) => {
|
|
7528
7528
|
q.value = "";
|
|
7529
7529
|
});
|
|
7530
|
-
const k =
|
|
7530
|
+
const k = u();
|
|
7531
7531
|
if (k && (k.textContent = "Too many failed attempts. Please wait."), !h()) {
|
|
7532
7532
|
const q = document.createElement("p");
|
|
7533
7533
|
q.className = "__crossx-pin6-lock-msg", q.id = "__crossx-pin6-lock-msg", q.innerHTML = `${Cs}<span id="__crossx-pin6-lock-countdown"></span>`;
|
|
7534
|
-
const D =
|
|
7535
|
-
D ? D.insertAdjacentElement("afterend", q) : (W =
|
|
7534
|
+
const D = u();
|
|
7535
|
+
D ? D.insertAdjacentElement("afterend", q) : (W = _()) == null || W.appendChild(q);
|
|
7536
7536
|
}
|
|
7537
7537
|
const P = () => {
|
|
7538
7538
|
var R;
|
|
7539
7539
|
const q = b - Date.now(), D = m();
|
|
7540
|
-
q <= 0 ? (clearInterval(G),
|
|
7540
|
+
q <= 0 ? (clearInterval(G), S(!1), (R = h()) == null || R.remove(), k && (k.textContent = ""), setTimeout(() => {
|
|
7541
7541
|
var N;
|
|
7542
7542
|
return (N = c()[0]) == null ? void 0 : N.focus();
|
|
7543
7543
|
}, 50)) : D && (D.textContent = ` ${zn(q)}`);
|
|
@@ -7557,7 +7557,7 @@ function ot(r, e, s, t, n, o) {
|
|
|
7557
7557
|
try {
|
|
7558
7558
|
if (n) {
|
|
7559
7559
|
const k = await n(b);
|
|
7560
|
-
k.ok ? e(b) : k.lockExpiresAt ? C(k.lockExpiresAt) :
|
|
7560
|
+
k.ok ? e(b) : k.lockExpiresAt ? C(k.lockExpiresAt) : E(k.error ?? "Incorrect PIN. Please try again.");
|
|
7561
7561
|
} else
|
|
7562
7562
|
e(b);
|
|
7563
7563
|
} catch (k) {
|
|
@@ -7620,9 +7620,9 @@ function Jn(r, e, s) {
|
|
|
7620
7620
|
}), o.addEventListener("keypress", (a) => {
|
|
7621
7621
|
/[0-9]/.test(a.key) || a.preventDefault();
|
|
7622
7622
|
}), o.addEventListener("paste", (a) => {
|
|
7623
|
-
var
|
|
7623
|
+
var u;
|
|
7624
7624
|
a.preventDefault();
|
|
7625
|
-
const c = (((
|
|
7625
|
+
const c = (((u = a.clipboardData) == null ? void 0 : u.getData("text")) ?? "").replace(/\D/g, "").slice(0, 4);
|
|
7626
7626
|
if (!c) return;
|
|
7627
7627
|
c.split("").forEach((h, m) => {
|
|
7628
7628
|
t[m] && (t[m].value = h);
|
|
@@ -7652,14 +7652,14 @@ class Xn {
|
|
|
7652
7652
|
*/
|
|
7653
7653
|
showWalletSelector(e, s, t) {
|
|
7654
7654
|
return new Promise((n) => {
|
|
7655
|
-
var
|
|
7655
|
+
var S;
|
|
7656
7656
|
he();
|
|
7657
7657
|
const o = [...e], i = $n(o, this.tokens, t), a = document.body.style.overflow;
|
|
7658
7658
|
document.body.style.overflow = "hidden", pe(i);
|
|
7659
7659
|
let c = !1;
|
|
7660
7660
|
const l = () => {
|
|
7661
7661
|
c || (c = !0, i.remove(), document.body.style.overflow = a);
|
|
7662
|
-
},
|
|
7662
|
+
}, u = (y) => {
|
|
7663
7663
|
l(), n(y);
|
|
7664
7664
|
}, h = () => {
|
|
7665
7665
|
l(), n(null);
|
|
@@ -7667,27 +7667,27 @@ class Xn {
|
|
|
7667
7667
|
(() => {
|
|
7668
7668
|
i.querySelectorAll(".__crossx-wallet-item").forEach((y) => {
|
|
7669
7669
|
y.addEventListener("click", () => {
|
|
7670
|
-
const
|
|
7671
|
-
|
|
7670
|
+
const E = y.dataset.walletAddress ?? "", C = parseInt(y.dataset.walletIndex ?? "0", 10);
|
|
7671
|
+
u({ address: E, index: C });
|
|
7672
7672
|
});
|
|
7673
7673
|
});
|
|
7674
7674
|
})();
|
|
7675
|
-
const
|
|
7676
|
-
|
|
7677
|
-
|
|
7675
|
+
const _ = i.querySelector("#__crossx-add-wallet-btn");
|
|
7676
|
+
_ && _.addEventListener("click", async () => {
|
|
7677
|
+
_.disabled = !0;
|
|
7678
7678
|
try {
|
|
7679
7679
|
const y = await s();
|
|
7680
7680
|
o.push(y);
|
|
7681
|
-
const
|
|
7682
|
-
if (
|
|
7681
|
+
const E = i.querySelector("#__crossx-wallet-list");
|
|
7682
|
+
if (E) {
|
|
7683
7683
|
const C = document.createElement("button");
|
|
7684
|
-
C.className = "__crossx-wallet-item", C.dataset.walletIndex = String(y.index), C.dataset.walletAddress = y.address, C.innerHTML = `<span class="__crossx-wallet-addr">${se(y.address)}</span>`, C.addEventListener("click", () =>
|
|
7684
|
+
C.className = "__crossx-wallet-item", C.dataset.walletIndex = String(y.index), C.dataset.walletAddress = y.address, C.innerHTML = `<span class="__crossx-wallet-addr">${se(y.address)}</span>`, C.addEventListener("click", () => u(y)), E.appendChild(C), C.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
7685
7685
|
}
|
|
7686
7686
|
} catch {
|
|
7687
7687
|
} finally {
|
|
7688
|
-
|
|
7688
|
+
_.disabled = !1;
|
|
7689
7689
|
}
|
|
7690
|
-
}), (
|
|
7690
|
+
}), (S = i.querySelector("#__crossx-close-btn")) == null || S.addEventListener("click", h), i.addEventListener("click", (y) => {
|
|
7691
7691
|
y.target === i && h();
|
|
7692
7692
|
});
|
|
7693
7693
|
const w = (y) => {
|
|
@@ -7707,44 +7707,49 @@ class Xn {
|
|
|
7707
7707
|
he();
|
|
7708
7708
|
const s = Hn(this.tokens);
|
|
7709
7709
|
pe(s);
|
|
7710
|
-
const t = () => s.remove(), n = (
|
|
7711
|
-
t(), e(
|
|
7710
|
+
const t = () => s.remove(), n = (u) => {
|
|
7711
|
+
t(), e(u);
|
|
7712
7712
|
}, o = () => {
|
|
7713
7713
|
t(), e(null);
|
|
7714
7714
|
};
|
|
7715
|
-
(a = s.querySelector("#__crossx-apple-btn")) == null || a.addEventListener("click", () => n("apple")), (c = s.querySelector("#__crossx-google-btn")) == null || c.addEventListener("click", () => n("google")), (l = s.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", o), s.addEventListener("click", (
|
|
7716
|
-
|
|
7717
|
-
}), s.querySelectorAll(".__crossx-login-terms-link").forEach((
|
|
7718
|
-
|
|
7715
|
+
(a = s.querySelector("#__crossx-apple-btn")) == null || a.addEventListener("click", () => n("apple")), (c = s.querySelector("#__crossx-google-btn")) == null || c.addEventListener("click", () => n("google")), (l = s.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", o), s.addEventListener("click", (u) => {
|
|
7716
|
+
u.target === s && o();
|
|
7717
|
+
}), s.querySelectorAll(".__crossx-login-terms-link").forEach((u) => {
|
|
7718
|
+
u.addEventListener("click", (h) => h.stopPropagation());
|
|
7719
7719
|
});
|
|
7720
|
-
const i = (
|
|
7721
|
-
|
|
7720
|
+
const i = (u) => {
|
|
7721
|
+
u.key === "Escape" && (document.removeEventListener("keydown", i), o());
|
|
7722
7722
|
};
|
|
7723
7723
|
document.addEventListener("keydown", i);
|
|
7724
7724
|
});
|
|
7725
7725
|
}
|
|
7726
7726
|
/**
|
|
7727
7727
|
* 마이그레이션 발견 팝업: "Wallet Found on Social Account"
|
|
7728
|
+
* @param options.allowSkip false이면 Skip/닫기/오버레이/ESC 모두 비활성화
|
|
7728
7729
|
* @returns 'recover' 또는 'skip'
|
|
7729
7730
|
*/
|
|
7730
|
-
showMigrationFoundPrompt() {
|
|
7731
|
-
|
|
7731
|
+
showMigrationFoundPrompt(e) {
|
|
7732
|
+
const s = (e == null ? void 0 : e.allowSkip) ?? !0;
|
|
7733
|
+
return new Promise((t) => {
|
|
7732
7734
|
var a, c, l;
|
|
7733
7735
|
he();
|
|
7734
|
-
const
|
|
7735
|
-
pe(
|
|
7736
|
-
const
|
|
7737
|
-
|
|
7738
|
-
}, o = () => {
|
|
7739
|
-
t(), e("skip");
|
|
7740
|
-
};
|
|
7741
|
-
(a = s.querySelector("#__crossx-recover-btn")) == null || a.addEventListener("click", n), (c = s.querySelector("#__crossx-skip-btn")) == null || c.addEventListener("click", o), (l = s.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", o), s.addEventListener("click", (d) => {
|
|
7742
|
-
d.target === s && o();
|
|
7743
|
-
});
|
|
7744
|
-
const i = (d) => {
|
|
7745
|
-
d.key === "Escape" && (document.removeEventListener("keydown", i), o());
|
|
7736
|
+
const n = Fn(this.tokens, s);
|
|
7737
|
+
pe(n);
|
|
7738
|
+
const o = () => n.remove(), i = () => {
|
|
7739
|
+
o(), t("recover");
|
|
7746
7740
|
};
|
|
7747
|
-
|
|
7741
|
+
if ((a = n.querySelector("#__crossx-recover-btn")) == null || a.addEventListener("click", i), s) {
|
|
7742
|
+
const u = () => {
|
|
7743
|
+
o(), t("skip");
|
|
7744
|
+
};
|
|
7745
|
+
(c = n.querySelector("#__crossx-skip-btn")) == null || c.addEventListener("click", u), (l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", u), n.addEventListener("click", (m) => {
|
|
7746
|
+
m.target === n && u();
|
|
7747
|
+
});
|
|
7748
|
+
const h = (m) => {
|
|
7749
|
+
m.key === "Escape" && (document.removeEventListener("keydown", h), u());
|
|
7750
|
+
};
|
|
7751
|
+
document.addEventListener("keydown", h);
|
|
7752
|
+
}
|
|
7748
7753
|
});
|
|
7749
7754
|
}
|
|
7750
7755
|
/**
|
|
@@ -7777,41 +7782,41 @@ class Xn {
|
|
|
7777
7782
|
}, a = Zt(this.tokens, Kn(n)), c = document.body.style.overflow;
|
|
7778
7783
|
document.body.style.overflow = "hidden", pe(a);
|
|
7779
7784
|
let l = !1;
|
|
7780
|
-
const
|
|
7785
|
+
const u = () => {
|
|
7781
7786
|
l || (l = !0, a.remove(), document.body.style.overflow = c);
|
|
7782
7787
|
}, h = (C) => {
|
|
7783
|
-
|
|
7788
|
+
u(), s(C);
|
|
7784
7789
|
}, m = () => {
|
|
7785
|
-
|
|
7786
|
-
},
|
|
7790
|
+
u(), s(null);
|
|
7791
|
+
}, _ = a.querySelector(".__crossx-card"), w = {
|
|
7787
7792
|
tooShort: (t == null ? void 0 : t.pinValidation_tooShort) ?? "Please enter a 6-digit PIN.",
|
|
7788
7793
|
numbersOnly: (t == null ? void 0 : t.pinValidation_numbersOnly) ?? "Only numbers (0-9) are allowed.",
|
|
7789
7794
|
repeatingDigit: (t == null ? void 0 : t.pinValidation_repeatingDigit) ?? "Cannot use the same number 3+ times in a row.",
|
|
7790
7795
|
sequential: (t == null ? void 0 : t.pinValidation_sequential) ?? "Sequential numbers (e.g., 123456) are not allowed.",
|
|
7791
7796
|
alternatingPattern: (t == null ? void 0 : t.pinValidation_alternatingPattern) ?? "Repeating patterns (e.g., 121212) are not allowed."
|
|
7792
|
-
},
|
|
7797
|
+
}, S = (C) => {
|
|
7793
7798
|
var B;
|
|
7794
|
-
|
|
7799
|
+
_.innerHTML = nt({
|
|
7795
7800
|
title: i.title,
|
|
7796
7801
|
headerSubtitle: i.headerSubtitle
|
|
7797
|
-
}), (B =
|
|
7802
|
+
}), (B = _.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), ot(_, (b) => {
|
|
7798
7803
|
b === C ? h(C) : y(o.mismatchError);
|
|
7799
7804
|
}, m);
|
|
7800
7805
|
}, y = (C) => {
|
|
7801
7806
|
var B;
|
|
7802
|
-
|
|
7807
|
+
_.innerHTML = nt({
|
|
7803
7808
|
title: o.title,
|
|
7804
7809
|
headerSubtitle: o.headerSubtitle,
|
|
7805
7810
|
subtitle: o.subtitle,
|
|
7806
7811
|
errorMessage: C
|
|
7807
|
-
}), (B =
|
|
7812
|
+
}), (B = _.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), ot(_, (b) => {
|
|
7808
7813
|
const k = Vn(b, w);
|
|
7809
|
-
k ? y(k) :
|
|
7814
|
+
k ? y(k) : S(b);
|
|
7810
7815
|
}, m);
|
|
7811
7816
|
};
|
|
7812
7817
|
(() => {
|
|
7813
7818
|
var q;
|
|
7814
|
-
const C = Array.from(
|
|
7819
|
+
const C = Array.from(_.querySelectorAll(".__crossx-pw-notice-item")), B = _.querySelector("#__crossx-pin-notice-next"), b = /* @__PURE__ */ new Set();
|
|
7815
7820
|
B.removeAttribute("disabled");
|
|
7816
7821
|
const k = B.dataset.nextLabel ?? "Next", P = B.dataset.submitLabel ?? "I Understand", G = () => {
|
|
7817
7822
|
const D = b.size === C.length;
|
|
@@ -7846,7 +7851,7 @@ class Xn {
|
|
|
7846
7851
|
D.scrollIntoView({ behavior: "smooth", block: "nearest" }), D.classList.add("--highlight"), setTimeout(() => {
|
|
7847
7852
|
D.classList.remove("--highlight"), z(D, R);
|
|
7848
7853
|
}, 400);
|
|
7849
|
-
}), (q =
|
|
7854
|
+
}), (q = _.querySelector("#__crossx-close-btn")) == null || q.addEventListener("click", m);
|
|
7850
7855
|
})(), a.addEventListener("click", (C) => {
|
|
7851
7856
|
C.target === a && m();
|
|
7852
7857
|
});
|
|
@@ -7871,18 +7876,18 @@ class Xn {
|
|
|
7871
7876
|
})
|
|
7872
7877
|
), l = document.body.style.overflow;
|
|
7873
7878
|
document.body.style.overflow = "hidden", pe(c);
|
|
7874
|
-
let
|
|
7879
|
+
let u = !1;
|
|
7875
7880
|
const h = () => {
|
|
7876
|
-
|
|
7877
|
-
}, m = (
|
|
7878
|
-
h(), s(
|
|
7879
|
-
},
|
|
7881
|
+
u || (u = !0, c.remove(), document.body.style.overflow = l);
|
|
7882
|
+
}, m = (E) => {
|
|
7883
|
+
h(), s(E);
|
|
7884
|
+
}, _ = () => {
|
|
7880
7885
|
h(), s(null);
|
|
7881
|
-
}, w = (
|
|
7882
|
-
h(), t(
|
|
7883
|
-
},
|
|
7884
|
-
(y =
|
|
7885
|
-
|
|
7886
|
+
}, w = (E) => {
|
|
7887
|
+
h(), t(E);
|
|
7888
|
+
}, S = c.querySelector(".__crossx-card");
|
|
7889
|
+
(y = S.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", _), ot(S, m, _, w, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt), c.addEventListener("click", (E) => {
|
|
7890
|
+
E.target === c && _();
|
|
7886
7891
|
});
|
|
7887
7892
|
});
|
|
7888
7893
|
}
|
|
@@ -7926,8 +7931,8 @@ class Xn {
|
|
|
7926
7931
|
}, a = () => {
|
|
7927
7932
|
i(), t();
|
|
7928
7933
|
}, c = o(a);
|
|
7929
|
-
(l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", a), n.addEventListener("click", (
|
|
7930
|
-
|
|
7934
|
+
(l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", a), n.addEventListener("click", (u) => {
|
|
7935
|
+
u.target === n && a();
|
|
7931
7936
|
});
|
|
7932
7937
|
});
|
|
7933
7938
|
}
|
|
@@ -7945,9 +7950,9 @@ class Xn {
|
|
|
7945
7950
|
n(), s();
|
|
7946
7951
|
};
|
|
7947
7952
|
(a = t.querySelector("#__crossx-done-btn")) == null || a.addEventListener("click", o), (c = t.querySelector("#__crossx-close-btn")) == null || c.addEventListener("click", o), t.querySelectorAll(".__crossx-copy-btn").forEach((l) => {
|
|
7948
|
-
l.addEventListener("click", (
|
|
7953
|
+
l.addEventListener("click", (u) => {
|
|
7949
7954
|
var m;
|
|
7950
|
-
|
|
7955
|
+
u.stopPropagation();
|
|
7951
7956
|
const h = l.dataset.copy;
|
|
7952
7957
|
h && ((m = navigator.clipboard) == null || m.writeText(h).catch(() => {
|
|
7953
7958
|
}));
|
|
@@ -7975,8 +7980,8 @@ class Xn {
|
|
|
7975
7980
|
const a = () => {
|
|
7976
7981
|
i || (i = !0, o(), t());
|
|
7977
7982
|
}, c = () => {
|
|
7978
|
-
var
|
|
7979
|
-
(
|
|
7983
|
+
var u, h;
|
|
7984
|
+
(u = n.querySelector("#__crossx-done-btn")) == null || u.addEventListener("click", a), (h = n.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", a), n.addEventListener("click", (m) => {
|
|
7980
7985
|
m.target === n && a();
|
|
7981
7986
|
});
|
|
7982
7987
|
const l = (m) => {
|
|
@@ -7991,7 +7996,7 @@ class Xn {
|
|
|
7991
7996
|
}
|
|
7992
7997
|
requestConfirmation(e) {
|
|
7993
7998
|
return new Promise((s) => {
|
|
7994
|
-
var c, l,
|
|
7999
|
+
var c, l, u;
|
|
7995
8000
|
he();
|
|
7996
8001
|
let t;
|
|
7997
8002
|
e.type === "sign-message" ? t = Ln(e, this.tokens) : e.type === "sign-typed-data" ? t = Dn(e, this.tokens) : e.type === "sign" ? t = Tn(e, this.tokens) : t = Rn(e, this.tokens), pe(t);
|
|
@@ -8000,12 +8005,12 @@ class Xn {
|
|
|
8000
8005
|
}, i = () => {
|
|
8001
8006
|
n(), s(!1);
|
|
8002
8007
|
};
|
|
8003
|
-
(c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (
|
|
8008
|
+
(c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (u = t.querySelector("#__crossx-close-btn")) == null || u.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((h) => {
|
|
8004
8009
|
h.addEventListener("click", (m) => {
|
|
8005
8010
|
var w;
|
|
8006
8011
|
m.stopPropagation();
|
|
8007
|
-
const
|
|
8008
|
-
|
|
8012
|
+
const _ = h.dataset.copy;
|
|
8013
|
+
_ && ((w = navigator.clipboard) == null || w.writeText(_).catch(() => {
|
|
8009
8014
|
}));
|
|
8010
8015
|
});
|
|
8011
8016
|
}), t.addEventListener("click", (h) => {
|
|
@@ -8052,21 +8057,21 @@ function so(r, e) {
|
|
|
8052
8057
|
gatewayUrl: s.walletGatewayUrl,
|
|
8053
8058
|
projectId: r.projectId
|
|
8054
8059
|
}, o = t.authMode !== "cookie" && Ot.isAvailable();
|
|
8055
|
-
!o && t.authMode !== "cookie" &&
|
|
8060
|
+
!o && t.authMode !== "cookie" && d.warn(
|
|
8056
8061
|
"[CROSSx] IndexedDB 사용 불가 — LocalStorage fallback 사용 중.",
|
|
8057
8062
|
"refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
|
|
8058
8063
|
"IndexedDB를 지원하는 브라우저 사용을 권장합니다."
|
|
8059
8064
|
), t.secureStorageAvailable = o;
|
|
8060
|
-
const i = o ? new Ot(r.projectId) : new rr(), a = new hn(), c = new xn(), l = new be(),
|
|
8065
|
+
const i = o ? new Ot(r.projectId) : new rr(), a = new hn(), c = new xn(), l = new be(), u = new Zn(), h = new es();
|
|
8061
8066
|
let m;
|
|
8062
|
-
r.useMockWallet ? (
|
|
8067
|
+
r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), m = new mn(i, h)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), m = new Le(
|
|
8063
8068
|
n,
|
|
8064
8069
|
i,
|
|
8065
8070
|
c,
|
|
8066
|
-
|
|
8071
|
+
u,
|
|
8067
8072
|
h
|
|
8068
8073
|
));
|
|
8069
|
-
const
|
|
8074
|
+
const _ = new De(n, c), w = new Xn(r.theme ?? "light", r.themeTokens), S = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w;
|
|
8070
8075
|
return new it(
|
|
8071
8076
|
t,
|
|
8072
8077
|
n,
|
|
@@ -8075,9 +8080,9 @@ function so(r, e) {
|
|
|
8075
8080
|
c,
|
|
8076
8081
|
l,
|
|
8077
8082
|
m,
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8083
|
+
u,
|
|
8084
|
+
S,
|
|
8085
|
+
_,
|
|
8081
8086
|
h
|
|
8082
8087
|
);
|
|
8083
8088
|
}
|