@nexus-cross/crossx-sdk-core 1.2.8-beta.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts.map +1 -1
- package/dist/crossx.global +36 -36
- package/dist/index.cjs +46 -46
- package/dist/index.js +853 -834
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var Ls = Object.defineProperty;
|
|
2
2
|
var Ds = (r, e, s) => e in r ? Ls(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
|
|
3
|
-
var
|
|
3
|
+
var I = (r, e, s) => Ds(r, typeof e != "symbol" ? e + "" : e, s);
|
|
4
4
|
import { createRemoteJWKSet as Ms, jwtVerify as $s, decodeJwt as Bs } from "jose";
|
|
5
5
|
var p = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.ALREADY_AUTHENTICATED = "ALREADY_AUTHENTICATED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.WALLET_ALREADY_EXISTS = "WALLET_ALREADY_EXISTS", r.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", r.BROADCAST_FAILED = "BROADCAST_FAILED", r.USER_REJECTED = "USER_REJECTED", r.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", r.NETWORK_ERROR = "NETWORK_ERROR", r.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", r.INVALID_CHAIN = "INVALID_CHAIN", r.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", r.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.SIGNATURE_FAILED = "SIGNATURE_FAILED", r.TRANSACTION_FAILED = "TRANSACTION_FAILED", r.PREPARE_FAILED = "PREPARE_FAILED", r.PREPARE_EXPIRED = "PREPARE_EXPIRED", r.PREPARE_MISMATCH = "PREPARE_MISMATCH", r.MIGRATION_FAILED = "MIGRATION_FAILED", r.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", r.MIGRATION_PIN_LOCKED = "MIGRATION_PIN_LOCKED", r.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", r.WALLET_INCONSISTENT_STATE = "WALLET_INCONSISTENT_STATE", r.PROJECT_ID_MISSING = "PROJECT_ID_MISSING", r.ORIGIN_NOT_ALLOWED = "ORIGIN_NOT_ALLOWED", r.APP_IDENTIFIER_MISSING = "APP_IDENTIFIER_MISSING", r.INVALID_APP_TYPE = "INVALID_APP_TYPE", r.PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED", r.SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH", r.GAS_ESTIMATION_FAILED = "GAS_ESTIMATION_FAILED", r.TYPED_DATA_CHAIN_ID_MISMATCH = "TYPED_DATA_CHAIN_ID_MISMATCH", r.PIN_NOT_SET = "PIN_NOT_SET", r.PIN_WRONG = "PIN_WRONG", r.PIN_INVALID = "PIN_INVALID", r.PIN_REPEATED_PATTERN = "PIN_REPEATED_PATTERN", r.PIN_CANCELLED = "PIN_CANCELLED", r.PIN_LOCKED = "PIN_LOCKED", r.HMAC_REQUIRED = "HMAC_REQUIRED", r.HMAC_VERIFICATION_FAILED = "HMAC_VERIFICATION_FAILED", r.WITHDRAW_FAILED = "WITHDRAW_FAILED", r.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(p || {});
|
|
6
6
|
class g extends Error {
|
|
@@ -171,7 +171,7 @@ let Ee = null;
|
|
|
171
171
|
function vt(r) {
|
|
172
172
|
Ee = r;
|
|
173
173
|
}
|
|
174
|
-
const
|
|
174
|
+
const u = {
|
|
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: d, authApiUrl: h } = this.config, m = `${d}${l}`;
|
|
369
|
+
u.log(`[CROSSx] OAuth 팝업 열기 (${c || "일반"} 로그인)`);
|
|
370
|
+
const x = await this.oauth.openAuth({
|
|
371
371
|
authUrl: m,
|
|
372
|
-
expectedOrigin: new URL(
|
|
372
|
+
expectedOrigin: new URL(d).origin
|
|
373
373
|
});
|
|
374
|
-
|
|
375
|
-
const { accessToken: w, refreshToken:
|
|
376
|
-
let y,
|
|
374
|
+
u.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", x.length, ")");
|
|
375
|
+
const { accessToken: w, refreshToken: v } = await this.exchangeFirebaseToken(x, h);
|
|
376
|
+
let y, S;
|
|
377
377
|
try {
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
const
|
|
381
|
-
|
|
378
|
+
const U = this.crypto.decodeJWT(x);
|
|
379
|
+
S = (n = U.firebase) == null ? void 0 : n.sign_in_provider;
|
|
380
|
+
const N = ((o = U.firebase) == null ? void 0 : o.identities) ?? {};
|
|
381
|
+
S === "google.com" ? y = (i = N["google.com"]) == null ? void 0 : i[0] : S === "apple.com" && (y = (a = N["apple.com"]) == null ? void 0 : a[0]), u.log("[CROSSx] OAuth provider sub 추출 — provider:", S, "hasProviderSub:", !!y);
|
|
382
382
|
} catch {
|
|
383
|
-
|
|
383
|
+
u.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
|
|
384
384
|
}
|
|
385
385
|
if (w) {
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
const
|
|
389
|
-
if (t =
|
|
390
|
-
throw
|
|
391
|
-
const
|
|
386
|
+
const U = this.crypto.decodeJWT(w);
|
|
387
|
+
u.log("[CROSSx] access_token 디코딩 — sub:", U.sub, "exp:", U.exp);
|
|
388
|
+
const N = await this.crypto.verifyJWT(w);
|
|
389
|
+
if (t = N.signatureVerified ?? !1, !N.valid)
|
|
390
|
+
throw u.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
|
|
391
|
+
const V = N.payload;
|
|
392
392
|
s = {
|
|
393
|
-
id:
|
|
394
|
-
email:
|
|
395
|
-
signInProvider:
|
|
393
|
+
id: V.sub,
|
|
394
|
+
email: V.email,
|
|
395
|
+
signInProvider: S,
|
|
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), v && this.config.secureStorageAvailable !== !1 ? await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, v) : v && u.warn("[CROSSx] 안전한 스토리지 미사용 — refresh_token 영속 저장을 건너뜁니다"));
|
|
398
398
|
} else {
|
|
399
|
-
const
|
|
399
|
+
const U = this.crypto.decodeJWT(x);
|
|
400
400
|
s = {
|
|
401
|
-
id:
|
|
402
|
-
email:
|
|
403
|
-
signInProvider:
|
|
401
|
+
id: U.sub,
|
|
402
|
+
email: U.email,
|
|
403
|
+
signInProvider: S,
|
|
404
404
|
providerSub: y
|
|
405
|
-
},
|
|
405
|
+
}, u.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
|
|
406
406
|
}
|
|
407
|
-
|
|
407
|
+
u.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), u.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
|
|
410
410
|
} catch (c) {
|
|
411
|
-
return
|
|
411
|
+
return u.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 u.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
|
+
u.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
|
+
u.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 u.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
|
+
u.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 u.log("[CROSSx] restoreSession — 메모리 토큰 유효, 세션 복원"), this.loadWallet(n, t.signatureVerified);
|
|
508
508
|
}
|
|
509
509
|
this.tokenStore.clear();
|
|
510
510
|
}
|
|
511
511
|
if (this.useCookieAuth) {
|
|
512
|
-
|
|
512
|
+
u.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 (u.log(
|
|
518
518
|
"[CROSSx] restoreSession — access_token:",
|
|
519
519
|
t ? "있음" : "없음",
|
|
520
520
|
"refresh_token:",
|
|
521
521
|
n ? "있음" : "없음"
|
|
522
522
|
), !n)
|
|
523
|
-
return
|
|
523
|
+
return u.log("[CROSSx] restoreSession — refresh_token 없음, 세션 복원 생략"), null;
|
|
524
524
|
t && this.tokenStore.set(t);
|
|
525
525
|
const o = await this.silentRefresh(n);
|
|
526
|
-
|
|
526
|
+
u.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 (u.log("[CROSSx] restoreSession — userInfo 조회:", s ? `있음 (id: ${s.id})` : "없음"), !s)
|
|
530
530
|
return null;
|
|
531
|
-
|
|
531
|
+
u.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 u.warn("[CROSSx] restoreSession — 지갑 로드 실패 (세션은 유지):", t), { success: !0, user: s, tokenSignatureVerified: !1 };
|
|
536
536
|
}
|
|
537
537
|
} catch (e) {
|
|
538
|
-
return
|
|
538
|
+
return u.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
|
+
u.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
|
+
u.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 u.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 u.error("[CROSSx] signInWithJWT: access_token 검증 실패, refreshToken 없음"), { success: !1, error: "유효하지 않은 access token" };
|
|
592
|
+
u.log("[CROSSx] signInWithJWT: access_token 만료, refreshToken으로 갱신 시도");
|
|
593
593
|
const a = await this.silentRefresh(s);
|
|
594
594
|
if (!a)
|
|
595
|
-
return
|
|
595
|
+
return u.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 u.error("[CROSSx] signInWithJWT: 갱신된 access_token도 유효하지 않음"), { success: !1, error: "갱신된 access token이 유효하지 않습니다" };
|
|
598
|
+
u.log("[CROSSx] signInWithJWT: silentRefresh 성공, 새 access_token 사용");
|
|
599
599
|
}
|
|
600
600
|
const i = o.payload;
|
|
601
|
-
|
|
601
|
+
u.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), u.log("[CROSSx] signInWithJWT — 토큰 및 사용자 정보 저장 완료");
|
|
605
605
|
} catch (o) {
|
|
606
|
-
return
|
|
606
|
+
return u.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), u.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
|
|
628
628
|
} catch (e) {
|
|
629
|
-
|
|
629
|
+
u.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
|
+
u.log("[CROSSx] GET /mnemonic/check — 지갑 상태 확인 (비밀번호 불필요)");
|
|
638
638
|
const o = await this.walletProvider.checkWallet();
|
|
639
|
-
if (
|
|
640
|
-
|
|
639
|
+
if (u.log("[CROSSx] 지갑 상태:", o), o === "migration_required")
|
|
640
|
+
u.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, u.log("[CROSSx] 캐시된 주소 로드 완료 (비밀번호 불필요):", t)) : u.log("[CROSSx] 주소 캐시 없음 — createWallet 단계에서 비밀번호 입력 후 로드");
|
|
645
645
|
} catch (i) {
|
|
646
|
-
|
|
646
|
+
u.warn("[CROSSx] getAddresses 실패, createWallet 단계에서 재시도:", i);
|
|
647
647
|
}
|
|
648
648
|
} else
|
|
649
|
-
|
|
649
|
+
u.log("[CROSSx] getOrCreateWallet 직접 호출 (폴백)"), t = (await this.walletProvider.getOrCreateWallet(e.id)).address, u.log("[CROSSx] 지갑 로드 완료 — address:", t);
|
|
650
650
|
} catch (o) {
|
|
651
651
|
if (o instanceof g && o.code === p.MIGRATION_BACKUP_EXISTS)
|
|
652
|
-
|
|
652
|
+
u.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 u.error("[CROSSx] 프로젝트 설정 에러:", o.message), o;
|
|
656
|
+
u.warn("[CROSSx] 지갑 상태 확인 실패 (로그인은 유지):", o);
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
|
-
return
|
|
659
|
+
return u.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
|
+
u.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 u.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, d, 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 = d, this.jsonRpc = new zs(d, 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
|
+
u.log("[CROSSx SDK] v1.3.1 초기화 중..."), 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
|
+
u.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 && (u.log("[CROSSx] signInWithCreate: 비밀번호 설정 취소 — 자동 로그아웃 진행"), await this.signOut().catch(
|
|
928
|
+
(n) => u.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 || u.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 }), u.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
|
+
u.log("[CROSSx] createWallet 시작");
|
|
1243
1243
|
const e = await this.fetchWalletStatus();
|
|
1244
|
-
if (
|
|
1244
|
+
if (u.log("[CROSSx] 지갑 상태:", e), e === "migration_required") {
|
|
1245
1245
|
const s = this.providerSub ?? this.userId;
|
|
1246
|
-
|
|
1246
|
+
u.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 }), u.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
|
+
u.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 }), u.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
|
+
u.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 u.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((d) => setTimeout(d, 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 v, y;
|
|
1596
|
+
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((v = this._config.receiptPolling) == null ? void 0 : v.intervalMs) ?? Xs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? Tt, d = Je(e), h = s.from ?? "";
|
|
1597
|
+
let m, x;
|
|
1598
|
+
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((S) => {
|
|
1599
|
+
m = S;
|
|
1600
|
+
const C = BigInt(S.gasUsed) * BigInt(S.effectiveGasPrice), U = s.value ? BigInt(s.value) : 0n, N = re.formatTxAmount(s.value, d.symbol, d.decimals), V = re.formatTxAmount("0x" + C.toString(16), d.symbol, d.decimals), W = re.formatTxAmount("0x" + (U + C).toString(16), d.symbol, d.decimals);
|
|
1601
1601
|
return {
|
|
1602
1602
|
chainId: e,
|
|
1603
1603
|
txHash: a,
|
|
1604
|
-
from:
|
|
1605
|
-
to:
|
|
1606
|
-
amount:
|
|
1607
|
-
fees:
|
|
1608
|
-
total:
|
|
1609
|
-
nativeSymbol:
|
|
1610
|
-
status:
|
|
1604
|
+
from: S.from,
|
|
1605
|
+
to: S.to ?? s.to,
|
|
1606
|
+
amount: N,
|
|
1607
|
+
fees: V,
|
|
1608
|
+
total: W,
|
|
1609
|
+
nativeSymbol: d.symbol,
|
|
1610
|
+
status: S.status === "0x1" ? "success" : "reverted"
|
|
1611
1611
|
};
|
|
1612
|
-
}).catch((
|
|
1612
|
+
}).catch((S) => (x = S instanceof Error ? S : new Error(String(S)), {
|
|
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, d.symbol, d.decimals),
|
|
1618
|
+
nativeSymbol: d.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
|
+
), x) throw x;
|
|
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), u.log("[CROSSx] PIN 변경 완료");
|
|
1677
1677
|
} catch (n) {
|
|
1678
1678
|
throw n instanceof g ? n : new g(p.UNKNOWN_ERROR, "PIN 변경에 실패했습니다", n);
|
|
1679
1679
|
}
|
|
@@ -1877,14 +1877,14 @@ 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 c, l,
|
|
1881
|
-
|
|
1880
|
+
var c, l, d;
|
|
1881
|
+
u.log('[CROSSx][Migration Phase 3] "Wallet Found" 팝업 표시');
|
|
1882
1882
|
const s = ((c = this._config.migration) == null ? void 0 : c.allowSkip) ?? !0, t = await this.confirmation.showMigrationFoundPrompt({ allowSkip: s });
|
|
1883
|
-
if (
|
|
1884
|
-
return
|
|
1883
|
+
if (u.log("[CROSSx][Migration Phase 3] 사용자 선택:", t), t === "skip")
|
|
1884
|
+
return u.log("[CROSSx][Migration Phase 3] 사용자가 마이그레이션을 건너뜀 → 종료"), null;
|
|
1885
1885
|
let n, o = 0, i = 5, a = null;
|
|
1886
1886
|
for (; ; ) {
|
|
1887
|
-
o++,
|
|
1887
|
+
o++, u.log(
|
|
1888
1888
|
`[CROSSx][Migration Phase 4] PIN 입력 팝업 표시 (시도 #${o}/${i})`,
|
|
1889
1889
|
n ? `— 이전 메시지: ${n}` : ""
|
|
1890
1890
|
);
|
|
@@ -1894,45 +1894,45 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1894
1894
|
maxAttempts: i
|
|
1895
1895
|
});
|
|
1896
1896
|
if (h === null)
|
|
1897
|
-
return
|
|
1898
|
-
|
|
1897
|
+
return u.log("[CROSSx][Migration Phase 4] 사용자가 PIN 입력을 취소함 → 종료"), null;
|
|
1898
|
+
u.log("[CROSSx][Migration Phase 4] PIN 입력 완료 — verify-recovery-pin API 호출"), n = void 0;
|
|
1899
1899
|
try {
|
|
1900
|
-
const m = await ((
|
|
1900
|
+
const m = await ((d = (l = this.walletProvider).verifyRecoveryPin) == null ? void 0 : d.call(l, h, e));
|
|
1901
1901
|
if (!m) {
|
|
1902
|
-
|
|
1902
|
+
u.log("[CROSSx][Migration Phase 4] verifyRecoveryPin 미지원 — PIN 검증 생략"), a = h;
|
|
1903
1903
|
break;
|
|
1904
1904
|
}
|
|
1905
1905
|
if (m.valid) {
|
|
1906
|
-
|
|
1906
|
+
u.log("[CROSSx][Migration Phase 4] PIN 검증 성공"), a = h;
|
|
1907
1907
|
break;
|
|
1908
1908
|
}
|
|
1909
|
-
const
|
|
1910
|
-
if (i =
|
|
1911
|
-
const w =
|
|
1912
|
-
|
|
1909
|
+
const x = m.pinStatus;
|
|
1910
|
+
if (i = x.maxAttempts, o = i - x.remainingAttempts, x.remainingAttempts === 0 && x.lockExpiresAt) {
|
|
1911
|
+
const w = x.lockExpiresAt * 1e3, v = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = v <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
|
|
1912
|
+
u.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${v}초, 메시지: ${y}`), await this.confirmation.showRecoveryPinLockedPrompt(v, y), o = 0, n = "Your account lock has been lifted. You may try again.";
|
|
1913
1913
|
} else
|
|
1914
|
-
|
|
1914
|
+
u.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 ${o}/${i})`), n = "Incorrect PIN.";
|
|
1915
1915
|
} catch (m) {
|
|
1916
1916
|
if (!(m instanceof g)) throw m;
|
|
1917
1917
|
if (m.code === p.MIGRATION_PIN_LOCKED) {
|
|
1918
|
-
const
|
|
1919
|
-
if (i = (
|
|
1920
|
-
return
|
|
1921
|
-
const w = ((
|
|
1922
|
-
|
|
1918
|
+
const x = m.details;
|
|
1919
|
+
if (i = (x == null ? void 0 : x.maxAttempts) ?? 5, (x == null ? void 0 : x.permanent) === !0)
|
|
1920
|
+
return u.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 = ((x == null ? void 0 : x.lockExpiresAt) ?? 0) * 1e3, v = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = v <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
|
|
1922
|
+
u.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${v}초`), await this.confirmation.showRecoveryPinLockedPrompt(v, y), o = 0, n = "Your account lock has been lifted. You may try again.";
|
|
1923
1923
|
} else
|
|
1924
|
-
throw
|
|
1924
|
+
throw u.error("[CROSSx][Migration Phase 4] verify-recovery-pin 실패 (복구 불가):", m), m;
|
|
1925
1925
|
}
|
|
1926
1926
|
}
|
|
1927
|
-
|
|
1927
|
+
u.log("[CROSSx][Migration Phase 5] PIN 검증 완료 — 비밀번호 설정 및 마이그레이션 진행");
|
|
1928
1928
|
try {
|
|
1929
1929
|
await this.ensurePinSetup();
|
|
1930
1930
|
const h = await this.migrateWalletUseCase.execute(a, e);
|
|
1931
|
-
return
|
|
1931
|
+
return u.log("[CROSSx][Migration Phase 5] 마이그레이션 성공 — address:", h.address), h;
|
|
1932
1932
|
} catch (h) {
|
|
1933
1933
|
if (h instanceof g && h.code === p.MIGRATION_FAILED)
|
|
1934
|
-
return
|
|
1935
|
-
throw
|
|
1934
|
+
return u.warn("[CROSSx][Migration Phase 5] migrate PIN 불일치 (경합) — 처음부터 재시도"), this.handleMigrationFlow(e);
|
|
1935
|
+
throw u.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
|
+
u.log("[CROSSx] nonce 비어있음 → eth_getTransactionCount 호출 (from:", l, ")");
|
|
1958
|
+
const d = await this.jsonRpc.call("eth_getTransactionCount", [l, "pending"], s);
|
|
1959
|
+
c.nonce = parseInt(d ?? "0x0", 16), u.log("[CROSSx] nonce 결과:", c.nonce);
|
|
1960
1960
|
}
|
|
1961
1961
|
}
|
|
1962
|
-
if (o && (
|
|
1963
|
-
|
|
1962
|
+
if (o && (u.log("[CROSSx] gasLimit 비어있음 → eth_estimateGas 호출"), c.gasLimit = await this.estimateGas(e, s), u.log("[CROSSx] estimateGas 결과:", c.gasLimit)), i) {
|
|
1963
|
+
u.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 d = Rt;
|
|
1967
|
+
c.maxFeePerGas = "0x" + (BigInt(l) + BigInt(d)).toString(16), c.maxPriorityFeePerGas = d, u.log("[CROSSx] Dynamic 체인 감지 — baseFee:", l, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
|
|
1968
1968
|
} else
|
|
1969
|
-
c.gasPrice = er,
|
|
1969
|
+
c.gasPrice = er, u.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
|
|
1970
1970
|
}
|
|
1971
|
-
return !i && a && (c.maxPriorityFeePerGas = Rt,
|
|
1971
|
+
return !i && a && (c.maxPriorityFeePerGas = Rt, u.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 u.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
|
+
u.log("[CROSSx] 서명 ecrecover 검증 성공");
|
|
2051
2051
|
} catch (n) {
|
|
2052
2052
|
if (n instanceof g) throw n;
|
|
2053
|
-
|
|
2053
|
+
u.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 && (u.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), u.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), u.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
|
+
u.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), u.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) ? (u.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), u.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 (u.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, u.log("[CROSSx] 캐시된 주소 로드 완료 (비밀번호 불필요):", this.address), this.emit("addressChanged", { address: o.address, index: o.index });
|
|
2197
2197
|
return;
|
|
2198
2198
|
}
|
|
2199
|
-
|
|
2199
|
+
u.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, u.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
|
+
u.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 u.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 u.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 u.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 u.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, d) => {
|
|
2419
|
+
t.onsuccess = () => l(t.result), t.onerror = () => d(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, d) => {
|
|
2425
|
+
o.onsuccess = () => l(o.result), o.onerror = () => d(o.error);
|
|
2426
2426
|
}),
|
|
2427
|
-
new Promise((l,
|
|
2428
|
-
i.onsuccess = () => l(i.result), i.onerror = () =>
|
|
2427
|
+
new Promise((l, d) => {
|
|
2428
|
+
i.onsuccess = () => l(i.result), i.onerror = () => d(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), u.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), n;
|
|
2435
2435
|
} catch (e) {
|
|
2436
|
-
return
|
|
2436
|
+
return u.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 u.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 u.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 u.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 u.error("[CROSSx] IndexedDB clear error:", e), e;
|
|
2489
2489
|
}
|
|
2490
2490
|
}
|
|
2491
2491
|
/**
|
|
@@ -2505,7 +2505,7 @@ function ge(r, e = "") {
|
|
|
2505
2505
|
throw new Error(`${s}expected integer >= 0, got ${r}`);
|
|
2506
2506
|
}
|
|
2507
2507
|
}
|
|
2508
|
-
function
|
|
2508
|
+
function z(r, e, s = "") {
|
|
2509
2509
|
const t = ut(r), n = r == null ? void 0 : r.length, o = e !== void 0;
|
|
2510
2510
|
if (!t || o && n !== e) {
|
|
2511
2511
|
const i = s && `"${s}" `, a = o ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
|
|
@@ -2525,7 +2525,7 @@ function ke(r, e = !0) {
|
|
|
2525
2525
|
throw new Error("Hash#digest() has already been called");
|
|
2526
2526
|
}
|
|
2527
2527
|
function ss(r, e) {
|
|
2528
|
-
|
|
2528
|
+
z(r, void 0, "digestInto() output");
|
|
2529
2529
|
const s = e.outputLen;
|
|
2530
2530
|
if (r.length < s)
|
|
2531
2531
|
throw new Error('"digestInto() output" expected to be of length >=' + s);
|
|
@@ -2554,7 +2554,7 @@ function lr(r) {
|
|
|
2554
2554
|
}
|
|
2555
2555
|
const Ct = ar ? (r) => r : lr, rs = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", dr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
|
|
2556
2556
|
function Me(r) {
|
|
2557
|
-
if (
|
|
2557
|
+
if (z(r), rs)
|
|
2558
2558
|
return r.toHex();
|
|
2559
2559
|
let e = "";
|
|
2560
2560
|
for (let s = 0; s < r.length; s++)
|
|
@@ -2593,7 +2593,7 @@ function ve(...r) {
|
|
|
2593
2593
|
let e = 0;
|
|
2594
2594
|
for (let t = 0; t < r.length; t++) {
|
|
2595
2595
|
const n = r[t];
|
|
2596
|
-
|
|
2596
|
+
z(n), e += n.length;
|
|
2597
2597
|
}
|
|
2598
2598
|
const s = new Uint8Array(e);
|
|
2599
2599
|
for (let t = 0, n = 0; t < r.length; t++) {
|
|
@@ -2623,21 +2623,21 @@ function pr(r, e, s) {
|
|
|
2623
2623
|
}
|
|
2624
2624
|
class fr {
|
|
2625
2625
|
constructor(e, s, t, n) {
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2626
|
+
I(this, "blockLen");
|
|
2627
|
+
I(this, "outputLen");
|
|
2628
|
+
I(this, "padOffset");
|
|
2629
|
+
I(this, "isLE");
|
|
2630
2630
|
// For partial updates less than block size
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2631
|
+
I(this, "buffer");
|
|
2632
|
+
I(this, "view");
|
|
2633
|
+
I(this, "finished", !1);
|
|
2634
|
+
I(this, "length", 0);
|
|
2635
|
+
I(this, "pos", 0);
|
|
2636
|
+
I(this, "destroyed", !1);
|
|
2637
2637
|
this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Ze(this.buffer);
|
|
2638
2638
|
}
|
|
2639
2639
|
update(e) {
|
|
2640
|
-
ke(this),
|
|
2640
|
+
ke(this), z(e);
|
|
2641
2641
|
const { view: s, buffer: t, blockLen: n } = this, o = e.length;
|
|
2642
2642
|
for (let i = 0; i < o; ) {
|
|
2643
2643
|
const a = Math.min(n - this.pos, o - i);
|
|
@@ -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, d = this.get();
|
|
2666
|
+
if (l > d.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, d[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], x = we[h - 2], w = ue(m, 7) ^ ue(m, 18) ^ m >>> 3, v = ue(x, 17) ^ ue(x, 19) ^ x >>> 10;
|
|
2791
|
+
we[h] = v + 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: d } = 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), x = d + m + hr(a, c, l) + br[h] + we[h] | 0, v = (ue(t, 2) ^ ue(t, 13) ^ ue(t, 22)) + pr(t, n, o) | 0;
|
|
2796
|
+
d = l, l = c, c = a, a = i + x | 0, i = o, o = n, n = t, t = x + v | 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, d = d + this.H | 0, this.set(t, n, o, i, a, c, l, d);
|
|
2799
2799
|
}
|
|
2800
2800
|
roundClean() {
|
|
2801
2801
|
Pe(we);
|
|
@@ -2809,14 +2809,14 @@ class Sr extends vr {
|
|
|
2809
2809
|
super(32);
|
|
2810
2810
|
// We cannot use array here since array allows indexing by variable
|
|
2811
2811
|
// which means optimizer/compiler cannot use registers.
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2812
|
+
I(this, "A", me[0] | 0);
|
|
2813
|
+
I(this, "B", me[1] | 0);
|
|
2814
|
+
I(this, "C", me[2] | 0);
|
|
2815
|
+
I(this, "D", me[3] | 0);
|
|
2816
|
+
I(this, "E", me[4] | 0);
|
|
2817
|
+
I(this, "F", me[5] | 0);
|
|
2818
|
+
I(this, "G", me[6] | 0);
|
|
2819
|
+
I(this, "H", me[7] | 0);
|
|
2820
2820
|
}
|
|
2821
2821
|
}
|
|
2822
2822
|
const Er = /* @__PURE__ */ ns(
|
|
@@ -2853,7 +2853,7 @@ function ze(r) {
|
|
|
2853
2853
|
return as(Me(r));
|
|
2854
2854
|
}
|
|
2855
2855
|
function cs(r) {
|
|
2856
|
-
return as(Me(Ir(
|
|
2856
|
+
return as(Me(Ir(z(r)).reverse()));
|
|
2857
2857
|
}
|
|
2858
2858
|
function pt(r, e) {
|
|
2859
2859
|
ge(e), r = is(r);
|
|
@@ -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), d = 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), d = 0;
|
|
2893
|
+
}, m = (...y) => s(l, ve(c, ...y)), x = (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 (d++ >= a)
|
|
2897
2897
|
throw new Error("drbg: tried max amount of iterations");
|
|
2898
2898
|
let y = 0;
|
|
2899
|
-
const
|
|
2899
|
+
const S = [];
|
|
2900
2900
|
for (; y < e; ) {
|
|
2901
2901
|
c = m();
|
|
2902
2902
|
const C = c.slice();
|
|
2903
|
-
|
|
2903
|
+
S.push(C), y += c.length;
|
|
2904
2904
|
}
|
|
2905
|
-
return ve(...
|
|
2905
|
+
return ve(...S);
|
|
2906
2906
|
};
|
|
2907
|
-
return (y,
|
|
2908
|
-
h(),
|
|
2907
|
+
return (y, S) => {
|
|
2908
|
+
h(), x(y);
|
|
2909
2909
|
let C;
|
|
2910
|
-
for (; !(C =
|
|
2911
|
-
|
|
2910
|
+
for (; !(C = S(w())); )
|
|
2911
|
+
x();
|
|
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), d = a.mul(l, t);
|
|
2981
|
+
const h = a.mul(l, n), m = a.mul(l, o), x = a.eql(a.sqr(d), c), w = a.eql(a.sqr(h), c);
|
|
2982
|
+
l = a.cmov(l, d, x), d = a.cmov(m, h, w);
|
|
2983
|
+
const v = a.eql(a.sqr(d), c), y = a.cmov(l, d, v);
|
|
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 d = s, h = c.mul(c.ONE, o), m = c.pow(l, e), x = 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, v = c.sqr(m);
|
|
3012
|
+
for (; !c.eql(v, c.ONE); )
|
|
3013
|
+
if (w++, v = c.sqr(v), w === d)
|
|
3014
3014
|
throw new Error("Cannot find square root");
|
|
3015
|
-
const y = ee << BigInt(
|
|
3016
|
-
|
|
3015
|
+
const y = ee << BigInt(d - w - 1), S = c.pow(h, y);
|
|
3016
|
+
d = w, h = c.sqr(S), m = c.mul(m, h), x = c.mul(x, S);
|
|
3017
3017
|
}
|
|
3018
|
-
return
|
|
3018
|
+
return x;
|
|
3019
3019
|
};
|
|
3020
3020
|
}
|
|
3021
3021
|
function Lr(r) {
|
|
@@ -3077,16 +3077,16 @@ function Br(r, e) {
|
|
|
3077
3077
|
}
|
|
3078
3078
|
class Ur {
|
|
3079
3079
|
constructor(e, s = {}) {
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3080
|
+
I(this, "ORDER");
|
|
3081
|
+
I(this, "BITS");
|
|
3082
|
+
I(this, "BYTES");
|
|
3083
|
+
I(this, "isLE");
|
|
3084
|
+
I(this, "ZERO", ne);
|
|
3085
|
+
I(this, "ONE", ee);
|
|
3086
|
+
I(this, "_lengths");
|
|
3087
|
+
I(this, "_sqrt");
|
|
3088
3088
|
// cached sqrt
|
|
3089
|
-
|
|
3089
|
+
I(this, "_mod");
|
|
3090
3090
|
var i;
|
|
3091
3091
|
if (e <= ne)
|
|
3092
3092
|
throw new Error("invalid field: expected ORDER > 0, got " + e);
|
|
@@ -3162,7 +3162,7 @@ class Ur {
|
|
|
3162
3162
|
return this.isLE ? ls(e, this.BYTES) : pt(e, this.BYTES);
|
|
3163
3163
|
}
|
|
3164
3164
|
fromBytes(e, s = !1) {
|
|
3165
|
-
|
|
3165
|
+
z(e);
|
|
3166
3166
|
const { _lengths: t, BYTES: n, isLE: o, ORDER: i, _mod: a } = this;
|
|
3167
3167
|
if (t) {
|
|
3168
3168
|
if (!t.includes(e.length) || e.length > n)
|
|
@@ -3201,7 +3201,7 @@ function ws(r) {
|
|
|
3201
3201
|
return e + Math.ceil(e / 2);
|
|
3202
3202
|
}
|
|
3203
3203
|
function Hr(r, e, s = !1) {
|
|
3204
|
-
|
|
3204
|
+
z(r);
|
|
3205
3205
|
const t = r.length, n = ms(e), o = ws(e);
|
|
3206
3206
|
if (t < 16 || t < o || t > 1024)
|
|
3207
3207
|
throw new Error("expected " + o + "-1024 bytes of input, got " + t);
|
|
@@ -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, d = l + Math.abs(a) - 1, h = a === 0, m = a < 0, x = e % 2 !== 0;
|
|
3235
|
+
return { nextN: c, offset: d, isZero: h, isNeg: m, isNegF: x, offsetF: l };
|
|
3236
3236
|
}
|
|
3237
3237
|
const et = /* @__PURE__ */ new WeakMap(), bs = /* @__PURE__ */ new WeakMap();
|
|
3238
3238
|
function tt(r) {
|
|
@@ -3245,10 +3245,10 @@ function Ft(r) {
|
|
|
3245
3245
|
class Fr {
|
|
3246
3246
|
// Parametrized with a given Point class (not individual point)
|
|
3247
3247
|
constructor(e, s) {
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3248
|
+
I(this, "BASE");
|
|
3249
|
+
I(this, "ZERO");
|
|
3250
|
+
I(this, "Fn");
|
|
3251
|
+
I(this, "bits");
|
|
3252
3252
|
this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = s;
|
|
3253
3253
|
}
|
|
3254
3254
|
// non-const time multiplication ladder
|
|
@@ -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: d, isNeg: h, isNegF: m, offsetF: x } = Ht(t, a, i);
|
|
3297
|
+
t = c, d ? o = o.add(Ke(m, s[x])) : 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: d } = Ht(t, i, o);
|
|
3310
3310
|
if (t = a, !l) {
|
|
3311
3311
|
const h = s[c];
|
|
3312
|
-
n = n.add(
|
|
3312
|
+
n = n.add(d ? h.negate() : h);
|
|
3313
3313
|
}
|
|
3314
3314
|
}
|
|
3315
3315
|
return Ft(t), n;
|
|
@@ -3372,13 +3372,13 @@ function qr(r, e) {
|
|
|
3372
3372
|
}
|
|
3373
3373
|
class vs {
|
|
3374
3374
|
constructor(e, s) {
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
if (ts(e),
|
|
3375
|
+
I(this, "oHash");
|
|
3376
|
+
I(this, "iHash");
|
|
3377
|
+
I(this, "blockLen");
|
|
3378
|
+
I(this, "outputLen");
|
|
3379
|
+
I(this, "finished", !1);
|
|
3380
|
+
I(this, "destroyed", !1);
|
|
3381
|
+
if (ts(e), z(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
|
|
3382
3382
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
3383
3383
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
3384
3384
|
const t = this.blockLen, n = new Uint8Array(t);
|
|
@@ -3394,7 +3394,7 @@ class vs {
|
|
|
3394
3394
|
return ke(this), this.iHash.update(e), this;
|
|
3395
3395
|
}
|
|
3396
3396
|
digestInto(e) {
|
|
3397
|
-
ke(this),
|
|
3397
|
+
ke(this), z(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
|
|
3398
3398
|
}
|
|
3399
3399
|
digest() {
|
|
3400
3400
|
const e = new Uint8Array(this.oHash.outputLen);
|
|
@@ -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, d = -a * n - c * i;
|
|
3422
|
+
const h = l < _e, m = d < _e;
|
|
3423
|
+
h && (l = -l), m && (d = -d);
|
|
3424
|
+
const x = ft(Math.ceil(Rr(s) / 2)) + Re;
|
|
3425
|
+
if (l < _e || l >= x || d < _e || d >= x)
|
|
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: d };
|
|
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 d of l)
|
|
3486
|
+
i = i << 8 | d;
|
|
3487
3487
|
if (t += c, i < 128)
|
|
3488
3488
|
throw new s("tlv.decode(long): not minimal encoding");
|
|
3489
3489
|
}
|
|
@@ -3517,11 +3517,11 @@ const ye = {
|
|
|
3517
3517
|
}
|
|
3518
3518
|
},
|
|
3519
3519
|
toSig(r) {
|
|
3520
|
-
const { Err: e, _int: s, _tlv: t } = ye, n =
|
|
3520
|
+
const { Err: e, _int: s, _tlv: t } = ye, n = z(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: d } = t.decode(2, c);
|
|
3524
|
+
if (d.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,126 +3546,126 @@ 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 d() {
|
|
3550
3550
|
if (!t.isOdd)
|
|
3551
3551
|
throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
3552
3552
|
}
|
|
3553
|
-
function h(
|
|
3554
|
-
const { x:
|
|
3555
|
-
if (qe(
|
|
3556
|
-
|
|
3557
|
-
const O = !t.isOdd(
|
|
3558
|
-
return ve(Is(O),
|
|
3553
|
+
function h(A, f, _) {
|
|
3554
|
+
const { x: b, y: E } = f.toAffine(), M = t.toBytes(b);
|
|
3555
|
+
if (qe(_, "isCompressed"), _) {
|
|
3556
|
+
d();
|
|
3557
|
+
const O = !t.isOdd(E);
|
|
3558
|
+
return ve(Is(O), M);
|
|
3559
3559
|
} else
|
|
3560
|
-
return ve(Uint8Array.of(4),
|
|
3560
|
+
return ve(Uint8Array.of(4), M, t.toBytes(E));
|
|
3561
3561
|
}
|
|
3562
|
-
function m(
|
|
3563
|
-
|
|
3564
|
-
const { publicKey: f, publicKeyUncompressed:
|
|
3565
|
-
if (
|
|
3566
|
-
const O = t.fromBytes(
|
|
3562
|
+
function m(A) {
|
|
3563
|
+
z(A, void 0, "Point");
|
|
3564
|
+
const { publicKey: f, publicKeyUncompressed: _ } = l, b = A.length, E = A[0], M = A.subarray(1);
|
|
3565
|
+
if (b === f && (E === 2 || E === 3)) {
|
|
3566
|
+
const O = t.fromBytes(M);
|
|
3567
3567
|
if (!t.isValid(O))
|
|
3568
3568
|
throw new Error("bad point: is not on curve, wrong x");
|
|
3569
|
-
const
|
|
3569
|
+
const $ = v(O);
|
|
3570
3570
|
let T;
|
|
3571
3571
|
try {
|
|
3572
|
-
T = t.sqrt(
|
|
3572
|
+
T = t.sqrt($);
|
|
3573
3573
|
} catch (J) {
|
|
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
|
-
|
|
3578
|
-
const
|
|
3579
|
-
return (
|
|
3580
|
-
} else if (
|
|
3581
|
-
const O = t.BYTES,
|
|
3582
|
-
if (!y(
|
|
3577
|
+
d();
|
|
3578
|
+
const B = t.isOdd(T);
|
|
3579
|
+
return (E & 1) === 1 !== B && (T = t.neg(T)), { x: O, y: T };
|
|
3580
|
+
} else if (b === _ && E === 4) {
|
|
3581
|
+
const O = t.BYTES, $ = t.fromBytes(M.subarray(0, O)), T = t.fromBytes(M.subarray(O, O * 2));
|
|
3582
|
+
if (!y($, T))
|
|
3583
3583
|
throw new Error("bad point: is not on curve");
|
|
3584
|
-
return { x:
|
|
3584
|
+
return { x: $, y: T };
|
|
3585
3585
|
} else
|
|
3586
|
-
throw new Error(`bad point: got length ${
|
|
3586
|
+
throw new Error(`bad point: got length ${b}, expected compressed=${f} or uncompressed=${_}`);
|
|
3587
3587
|
}
|
|
3588
|
-
const
|
|
3589
|
-
function
|
|
3590
|
-
const f = t.sqr(
|
|
3591
|
-
return t.add(t.add(
|
|
3588
|
+
const x = e.toBytes || h, w = e.fromBytes || m;
|
|
3589
|
+
function v(A) {
|
|
3590
|
+
const f = t.sqr(A), _ = t.mul(f, A);
|
|
3591
|
+
return t.add(t.add(_, t.mul(A, o.a)), o.b);
|
|
3592
3592
|
}
|
|
3593
|
-
function y(
|
|
3594
|
-
const
|
|
3595
|
-
return t.eql(
|
|
3593
|
+
function y(A, f) {
|
|
3594
|
+
const _ = t.sqr(f), b = v(A);
|
|
3595
|
+
return t.eql(_, b);
|
|
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 S = t.mul(t.pow(o.a, He), zr), C = t.mul(t.sqr(o.b), BigInt(27));
|
|
3600
|
+
if (t.is0(t.add(S, C)))
|
|
3601
3601
|
throw new Error("bad curve params: a or b");
|
|
3602
|
-
function
|
|
3603
|
-
if (!t.isValid(f) ||
|
|
3604
|
-
throw new Error(`bad point coordinate ${
|
|
3602
|
+
function U(A, f, _ = !1) {
|
|
3603
|
+
if (!t.isValid(f) || _ && t.is0(f))
|
|
3604
|
+
throw new Error(`bad point coordinate ${A}`);
|
|
3605
3605
|
return f;
|
|
3606
3606
|
}
|
|
3607
|
-
function
|
|
3608
|
-
if (!(
|
|
3607
|
+
function N(A) {
|
|
3608
|
+
if (!(A instanceof D))
|
|
3609
3609
|
throw new Error("Weierstrass Point expected");
|
|
3610
3610
|
}
|
|
3611
|
-
function
|
|
3611
|
+
function V(A) {
|
|
3612
3612
|
if (!c || !c.basises)
|
|
3613
3613
|
throw new Error("no endo");
|
|
3614
|
-
return Kr(
|
|
3615
|
-
}
|
|
3616
|
-
const
|
|
3617
|
-
const { X:
|
|
3618
|
-
if (t.eql(
|
|
3619
|
-
return { x, y:
|
|
3620
|
-
const
|
|
3621
|
-
f == null && (f =
|
|
3622
|
-
const O = t.mul(
|
|
3623
|
-
if (
|
|
3614
|
+
return Kr(A, c.basises, n.ORDER);
|
|
3615
|
+
}
|
|
3616
|
+
const W = Mt((A, f) => {
|
|
3617
|
+
const { X: _, Y: b, Z: E } = A;
|
|
3618
|
+
if (t.eql(E, t.ONE))
|
|
3619
|
+
return { x: _, y: b };
|
|
3620
|
+
const M = A.is0();
|
|
3621
|
+
f == null && (f = M ? t.ONE : t.inv(E));
|
|
3622
|
+
const O = t.mul(_, f), $ = t.mul(b, f), T = t.mul(E, f);
|
|
3623
|
+
if (M)
|
|
3624
3624
|
return { x: t.ZERO, y: t.ZERO };
|
|
3625
3625
|
if (!t.eql(T, t.ONE))
|
|
3626
3626
|
throw new Error("invZ was invalid");
|
|
3627
|
-
return { x: O, y:
|
|
3628
|
-
}),
|
|
3629
|
-
if (
|
|
3630
|
-
if (e.allowInfinityPoint && !t.is0(
|
|
3627
|
+
return { x: O, y: $ };
|
|
3628
|
+
}), P = Mt((A) => {
|
|
3629
|
+
if (A.is0()) {
|
|
3630
|
+
if (e.allowInfinityPoint && !t.is0(A.Y))
|
|
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: _ } = A.toAffine();
|
|
3635
|
+
if (!t.isValid(f) || !t.isValid(_))
|
|
3636
3636
|
throw new Error("bad point: x or y not field elements");
|
|
3637
|
-
if (!y(f,
|
|
3637
|
+
if (!y(f, _))
|
|
3638
3638
|
throw new Error("bad point: equation left != right");
|
|
3639
|
-
if (!
|
|
3639
|
+
if (!A.isTorsionFree())
|
|
3640
3640
|
throw new Error("bad point: not in prime-order subgroup");
|
|
3641
3641
|
return !0;
|
|
3642
3642
|
});
|
|
3643
|
-
function
|
|
3644
|
-
return
|
|
3643
|
+
function k(A, f, _, b, E) {
|
|
3644
|
+
return _ = new D(t.mul(_.X, A), _.Y, _.Z), f = Ke(b, f), _ = Ke(E, _), f.add(_);
|
|
3645
3645
|
}
|
|
3646
3646
|
const R = class R {
|
|
3647
3647
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
3648
|
-
constructor(f,
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
this.X =
|
|
3648
|
+
constructor(f, _, b) {
|
|
3649
|
+
I(this, "X");
|
|
3650
|
+
I(this, "Y");
|
|
3651
|
+
I(this, "Z");
|
|
3652
|
+
this.X = U("x", f), this.Y = U("y", _, !0), this.Z = U("z", b), 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, y:
|
|
3660
|
-
if (!f || !t.isValid(
|
|
3659
|
+
const { x: _, y: b } = f || {};
|
|
3660
|
+
if (!f || !t.isValid(_) || !t.isValid(b))
|
|
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(_) && t.is0(b) ? R.ZERO : new R(_, b, t.ONE);
|
|
3665
3665
|
}
|
|
3666
3666
|
static fromBytes(f) {
|
|
3667
|
-
const
|
|
3668
|
-
return
|
|
3667
|
+
const _ = R.fromAffine(w(z(f, void 0, "point")));
|
|
3668
|
+
return _.assertValidity(), _;
|
|
3669
3669
|
}
|
|
3670
3670
|
static fromHex(f) {
|
|
3671
3671
|
return R.fromBytes(We(f));
|
|
@@ -3682,13 +3682,13 @@ 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
|
|
3685
|
+
precompute(f = 8, _ = !0) {
|
|
3686
|
+
return L.createCache(this, f), _ || this.multiply(He), this;
|
|
3687
3687
|
}
|
|
3688
3688
|
// TODO: return `this`
|
|
3689
3689
|
/** A point on curve is valid if it conforms to equation. */
|
|
3690
3690
|
assertValidity() {
|
|
3691
|
-
|
|
3691
|
+
P(this);
|
|
3692
3692
|
}
|
|
3693
3693
|
hasEvenY() {
|
|
3694
3694
|
const { y: f } = this.toAffine();
|
|
@@ -3698,9 +3698,9 @@ function jr(r, e = {}) {
|
|
|
3698
3698
|
}
|
|
3699
3699
|
/** Compare one point to another. */
|
|
3700
3700
|
equals(f) {
|
|
3701
|
-
|
|
3702
|
-
const { X:
|
|
3703
|
-
return T &&
|
|
3701
|
+
N(f);
|
|
3702
|
+
const { X: _, Y: b, Z: E } = this, { X: M, Y: O, Z: $ } = f, T = t.eql(t.mul(_, $), t.mul(M, E)), B = t.eql(t.mul(b, $), t.mul(O, E));
|
|
3703
|
+
return T && B;
|
|
3704
3704
|
}
|
|
3705
3705
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
3706
3706
|
negate() {
|
|
@@ -3711,23 +3711,23 @@ 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:
|
|
3715
|
-
let
|
|
3716
|
-
return
|
|
3714
|
+
const { a: f, b: _ } = o, b = t.mul(_, He), { X: E, Y: M, Z: O } = this;
|
|
3715
|
+
let $ = t.ZERO, T = t.ZERO, B = t.ZERO, G = t.mul(E, E), J = t.mul(M, M), K = t.mul(O, O), F = t.mul(E, M);
|
|
3716
|
+
return F = t.add(F, F), B = t.mul(E, O), B = t.add(B, B), $ = t.mul(f, B), T = t.mul(b, K), T = t.add($, T), $ = t.sub(J, T), T = t.add(J, T), T = t.mul($, T), $ = t.mul(F, $), B = t.mul(b, B), K = t.mul(f, K), F = t.sub(G, K), F = t.mul(f, F), F = t.add(F, B), B = t.add(G, G), G = t.add(B, G), G = t.add(G, K), G = t.mul(G, F), T = t.add(T, G), K = t.mul(M, O), K = t.add(K, K), G = t.mul(K, F), $ = t.sub($, G), B = t.mul(K, J), B = t.add(B, B), B = t.add(B, B), new R($, T, B);
|
|
3717
3717
|
}
|
|
3718
3718
|
// Renes-Costello-Batina exception-free addition formula.
|
|
3719
3719
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
3720
3720
|
// https://eprint.iacr.org/2015/1060, algorithm 1
|
|
3721
3721
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
3722
3722
|
add(f) {
|
|
3723
|
-
|
|
3724
|
-
const { X:
|
|
3725
|
-
let T = t.ZERO,
|
|
3723
|
+
N(f);
|
|
3724
|
+
const { X: _, Y: b, Z: E } = this, { X: M, Y: O, Z: $ } = f;
|
|
3725
|
+
let T = t.ZERO, B = t.ZERO, G = t.ZERO;
|
|
3726
3726
|
const J = o.a, K = t.mul(o.b, He);
|
|
3727
|
-
let
|
|
3728
|
-
oe = t.mul(oe, j), j = t.add(
|
|
3729
|
-
let Q = t.add(
|
|
3730
|
-
return j = t.mul(j, Q), Q = t.add(
|
|
3727
|
+
let F = t.mul(_, M), X = t.mul(b, O), Z = t.mul(E, $), oe = t.add(_, b), j = t.add(M, O);
|
|
3728
|
+
oe = t.mul(oe, j), j = t.add(F, X), oe = t.sub(oe, j), j = t.add(_, E);
|
|
3729
|
+
let Q = t.add(M, $);
|
|
3730
|
+
return j = t.mul(j, Q), Q = t.add(F, Z), j = t.sub(j, Q), Q = t.add(b, E), T = t.add(O, $), Q = t.mul(Q, T), T = t.add(X, Z), Q = t.sub(Q, T), G = t.mul(J, j), T = t.mul(K, Z), G = t.add(T, G), T = t.sub(X, G), G = t.add(X, G), B = t.mul(T, G), X = t.add(F, F), X = t.add(X, F), Z = t.mul(J, Z), j = t.mul(K, j), X = t.add(X, Z), Z = t.sub(F, Z), Z = t.mul(J, Z), j = t.add(j, Z), F = t.mul(X, j), B = t.add(B, F), F = t.mul(Q, j), T = t.mul(oe, T), T = t.sub(T, F), F = t.mul(oe, X), G = t.mul(Q, G), G = t.add(G, F), new R(T, B, G);
|
|
3731
3731
|
}
|
|
3732
3732
|
subtract(f) {
|
|
3733
3733
|
return this.add(f.negate());
|
|
@@ -3745,19 +3745,19 @@ function jr(r, e = {}) {
|
|
|
3745
3745
|
* @returns New point
|
|
3746
3746
|
*/
|
|
3747
3747
|
multiply(f) {
|
|
3748
|
-
const { endo:
|
|
3748
|
+
const { endo: _ } = e;
|
|
3749
3749
|
if (!n.isValidNot0(f))
|
|
3750
3750
|
throw new Error("invalid scalar: out of range");
|
|
3751
|
-
let
|
|
3752
|
-
const
|
|
3753
|
-
if (
|
|
3754
|
-
const { k1neg: O, k1:
|
|
3755
|
-
|
|
3751
|
+
let b, E;
|
|
3752
|
+
const M = (O) => L.cached(this, O, ($) => Ut(R, $));
|
|
3753
|
+
if (_) {
|
|
3754
|
+
const { k1neg: O, k1: $, k2neg: T, k2: B } = V(f), { p: G, f: J } = M($), { p: K, f: F } = M(B);
|
|
3755
|
+
E = J.add(F), b = k(_.beta, G, K, O, T);
|
|
3756
3756
|
} else {
|
|
3757
|
-
const { p: O, f:
|
|
3758
|
-
|
|
3757
|
+
const { p: O, f: $ } = M(f);
|
|
3758
|
+
b = O, E = $;
|
|
3759
3759
|
}
|
|
3760
|
-
return Ut(R, [
|
|
3760
|
+
return Ut(R, [b, E])[0];
|
|
3761
3761
|
}
|
|
3762
3762
|
/**
|
|
3763
3763
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -3765,27 +3765,27 @@ 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: _ } = e, b = this;
|
|
3769
3769
|
if (!n.isValid(f))
|
|
3770
3770
|
throw new Error("invalid scalar: out of range");
|
|
3771
|
-
if (f === _e ||
|
|
3771
|
+
if (f === _e || b.is0())
|
|
3772
3772
|
return R.ZERO;
|
|
3773
3773
|
if (f === Re)
|
|
3774
|
-
return
|
|
3775
|
-
if (
|
|
3774
|
+
return b;
|
|
3775
|
+
if (L.hasCache(this))
|
|
3776
3776
|
return this.multiply(f);
|
|
3777
|
-
if (
|
|
3778
|
-
const { k1neg:
|
|
3779
|
-
return
|
|
3777
|
+
if (_) {
|
|
3778
|
+
const { k1neg: E, k1: M, k2neg: O, k2: $ } = V(f), { p1: T, p2: B } = Gr(R, b, M, $);
|
|
3779
|
+
return k(_.beta, T, B, E, O);
|
|
3780
3780
|
} else
|
|
3781
|
-
return
|
|
3781
|
+
return L.unsafe(b, f);
|
|
3782
3782
|
}
|
|
3783
3783
|
/**
|
|
3784
3784
|
* Converts Projective point to affine (x, y) coordinates.
|
|
3785
3785
|
* @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
|
|
3786
3786
|
*/
|
|
3787
3787
|
toAffine(f) {
|
|
3788
|
-
return
|
|
3788
|
+
return W(this, f);
|
|
3789
3789
|
}
|
|
3790
3790
|
/**
|
|
3791
3791
|
* Checks whether Point is free of torsion elements (is in prime subgroup).
|
|
@@ -3793,7 +3793,7 @@ function jr(r, e = {}) {
|
|
|
3793
3793
|
*/
|
|
3794
3794
|
isTorsionFree() {
|
|
3795
3795
|
const { isTorsionFree: f } = e;
|
|
3796
|
-
return i === Re ? !0 : f ? f(R, this) :
|
|
3796
|
+
return i === Re ? !0 : f ? f(R, this) : L.unsafe(this, a).is0();
|
|
3797
3797
|
}
|
|
3798
3798
|
clearCofactor() {
|
|
3799
3799
|
const { clearCofactor: f } = e;
|
|
@@ -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(), x(R, this, f);
|
|
3807
3807
|
}
|
|
3808
3808
|
toHex(f = !0) {
|
|
3809
3809
|
return Me(this.toBytes(f));
|
|
@@ -3813,14 +3813,14 @@ function jr(r, e = {}) {
|
|
|
3813
3813
|
}
|
|
3814
3814
|
};
|
|
3815
3815
|
// base / generator point
|
|
3816
|
-
|
|
3817
|
-
|
|
3816
|
+
I(R, "BASE", new R(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
|
|
3817
|
+
I(R, "ZERO", new R(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
|
|
3818
3818
|
// math field
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
let
|
|
3822
|
-
const q = n.BITS,
|
|
3823
|
-
return
|
|
3819
|
+
I(R, "Fp", t), // scalar field
|
|
3820
|
+
I(R, "Fn", n);
|
|
3821
|
+
let D = R;
|
|
3822
|
+
const q = n.BITS, L = new Fr(D, e.endo ? Math.ceil(q / 2) : q);
|
|
3823
|
+
return D.BASE.precompute(8), D;
|
|
3824
3824
|
}
|
|
3825
3825
|
function Is(r) {
|
|
3826
3826
|
return Uint8Array.of(r ? 2 : 3);
|
|
@@ -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(x) {
|
|
3840
3840
|
try {
|
|
3841
|
-
const w = s.fromBytes(
|
|
3841
|
+
const w = s.fromBytes(x);
|
|
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(x, w) {
|
|
3848
|
+
const { publicKey: v, publicKeyUncompressed: y } = n;
|
|
3849
3849
|
try {
|
|
3850
|
-
const
|
|
3851
|
-
return w === !0 &&
|
|
3850
|
+
const S = x.length;
|
|
3851
|
+
return w === !0 && S !== v || w === !1 && S !== y ? !1 : !!r.fromBytes(x);
|
|
3852
3852
|
} catch {
|
|
3853
3853
|
return !1;
|
|
3854
3854
|
}
|
|
3855
3855
|
}
|
|
3856
|
-
function a(
|
|
3857
|
-
return Hr(
|
|
3856
|
+
function a(x = t(n.seed)) {
|
|
3857
|
+
return Hr(z(x, n.seed, "seed"), s.ORDER);
|
|
3858
3858
|
}
|
|
3859
|
-
function c(
|
|
3860
|
-
return r.BASE.multiply(s.fromBytes(
|
|
3859
|
+
function c(x, w = !0) {
|
|
3860
|
+
return r.BASE.multiply(s.fromBytes(x)).toBytes(w);
|
|
3861
3861
|
}
|
|
3862
|
-
function l(
|
|
3863
|
-
const { secretKey: w, publicKey:
|
|
3864
|
-
if (!ut(
|
|
3862
|
+
function l(x) {
|
|
3863
|
+
const { secretKey: w, publicKey: v, publicKeyUncompressed: y } = n;
|
|
3864
|
+
if (!ut(x) || "_lengths" in s && s._lengths || w === v)
|
|
3865
3865
|
return;
|
|
3866
|
-
const
|
|
3867
|
-
return
|
|
3866
|
+
const S = z(x, void 0, "key").length;
|
|
3867
|
+
return S === v || S === y;
|
|
3868
3868
|
}
|
|
3869
|
-
function
|
|
3870
|
-
if (l(
|
|
3869
|
+
function d(x, w, v = !0) {
|
|
3870
|
+
if (l(x) === !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(x);
|
|
3875
|
+
return r.fromBytes(w).multiply(y).toBytes(v);
|
|
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: d, keygen: m, Point: r, utils: h, lengths: n });
|
|
3883
3883
|
}
|
|
3884
3884
|
function Jr(r, e, s = {}) {
|
|
3885
3885
|
ts(e), _t(s, {}, {
|
|
@@ -3889,116 +3889,116 @@ 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, _) => Ss(e, f, _)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: d, getSharedSecret: h, utils: m, lengths: x } = 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
|
+
}, v = a * Es < o.ORDER;
|
|
3898
3898
|
function y(f) {
|
|
3899
|
-
const
|
|
3900
|
-
return f >
|
|
3899
|
+
const _ = a >> Re;
|
|
3900
|
+
return f > _;
|
|
3901
3901
|
}
|
|
3902
|
-
function
|
|
3903
|
-
if (!i.isValidNot0(
|
|
3902
|
+
function S(f, _) {
|
|
3903
|
+
if (!i.isValidNot0(_))
|
|
3904
3904
|
throw new Error(`invalid signature ${f}: out of range 1..Point.Fn.ORDER`);
|
|
3905
|
-
return
|
|
3905
|
+
return _;
|
|
3906
3906
|
}
|
|
3907
3907
|
function C() {
|
|
3908
|
-
if (
|
|
3908
|
+
if (v)
|
|
3909
3909
|
throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
3910
3910
|
}
|
|
3911
|
-
function
|
|
3912
|
-
ct(
|
|
3913
|
-
const
|
|
3914
|
-
return
|
|
3915
|
-
}
|
|
3916
|
-
class
|
|
3917
|
-
constructor(
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
if (this.r =
|
|
3922
|
-
if (C(), ![0, 1, 2, 3].includes(
|
|
3911
|
+
function U(f, _) {
|
|
3912
|
+
ct(_);
|
|
3913
|
+
const b = x.signature, E = _ === "compact" ? b : _ === "recovered" ? b + 1 : void 0;
|
|
3914
|
+
return z(f, E);
|
|
3915
|
+
}
|
|
3916
|
+
class N {
|
|
3917
|
+
constructor(_, b, E) {
|
|
3918
|
+
I(this, "r");
|
|
3919
|
+
I(this, "s");
|
|
3920
|
+
I(this, "recovery");
|
|
3921
|
+
if (this.r = S("r", _), this.s = S("s", b), E != null) {
|
|
3922
|
+
if (C(), ![0, 1, 2, 3].includes(E))
|
|
3923
3923
|
throw new Error("invalid recovery id");
|
|
3924
|
-
this.recovery =
|
|
3924
|
+
this.recovery = E;
|
|
3925
3925
|
}
|
|
3926
3926
|
Object.freeze(this);
|
|
3927
3927
|
}
|
|
3928
|
-
static fromBytes(
|
|
3929
|
-
|
|
3930
|
-
let
|
|
3931
|
-
if (
|
|
3932
|
-
const { r: T, s:
|
|
3933
|
-
return new
|
|
3928
|
+
static fromBytes(_, b = w.format) {
|
|
3929
|
+
U(_, b);
|
|
3930
|
+
let E;
|
|
3931
|
+
if (b === "der") {
|
|
3932
|
+
const { r: T, s: B } = ye.toSig(z(_));
|
|
3933
|
+
return new N(T, B);
|
|
3934
3934
|
}
|
|
3935
|
-
|
|
3936
|
-
const
|
|
3937
|
-
return new
|
|
3935
|
+
b === "recovered" && (E = _[0], b = "compact", _ = _.subarray(1));
|
|
3936
|
+
const M = x.signature / 2, O = _.subarray(0, M), $ = _.subarray(M, M * 2);
|
|
3937
|
+
return new N(i.fromBytes(O), i.fromBytes($), E);
|
|
3938
3938
|
}
|
|
3939
|
-
static fromHex(
|
|
3940
|
-
return this.fromBytes(We(
|
|
3939
|
+
static fromHex(_, b) {
|
|
3940
|
+
return this.fromBytes(We(_), b);
|
|
3941
3941
|
}
|
|
3942
3942
|
assertRecovery() {
|
|
3943
|
-
const { recovery:
|
|
3944
|
-
if (
|
|
3943
|
+
const { recovery: _ } = this;
|
|
3944
|
+
if (_ == null)
|
|
3945
3945
|
throw new Error("invalid recovery id: must be present");
|
|
3946
|
-
return
|
|
3946
|
+
return _;
|
|
3947
3947
|
}
|
|
3948
|
-
addRecoveryBit(
|
|
3949
|
-
return new
|
|
3948
|
+
addRecoveryBit(_) {
|
|
3949
|
+
return new N(this.r, this.s, _);
|
|
3950
3950
|
}
|
|
3951
|
-
recoverPublicKey(
|
|
3952
|
-
const { r:
|
|
3951
|
+
recoverPublicKey(_) {
|
|
3952
|
+
const { r: b, s: E } = this, M = this.assertRecovery(), O = M === 2 || M === 3 ? b + a : b;
|
|
3953
3953
|
if (!o.isValid(O))
|
|
3954
3954
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
3955
|
-
const
|
|
3956
|
-
if (
|
|
3955
|
+
const $ = o.toBytes(O), T = r.fromBytes(ve(Is((M & 1) === 0), $)), B = i.inv(O), G = W(z(_, void 0, "msgHash")), J = i.create(-G * B), K = i.create(E * B), F = r.BASE.multiplyUnsafe(J).add(T.multiplyUnsafe(K));
|
|
3956
|
+
if (F.is0())
|
|
3957
3957
|
throw new Error("invalid recovery: point at infinify");
|
|
3958
|
-
return
|
|
3958
|
+
return F.assertValidity(), F;
|
|
3959
3959
|
}
|
|
3960
3960
|
// Signatures should be low-s, to prevent malleability.
|
|
3961
3961
|
hasHighS() {
|
|
3962
3962
|
return y(this.s);
|
|
3963
3963
|
}
|
|
3964
|
-
toBytes(
|
|
3965
|
-
if (ct(
|
|
3964
|
+
toBytes(_ = w.format) {
|
|
3965
|
+
if (ct(_), _ === "der")
|
|
3966
3966
|
return We(ye.hexFromSig(this));
|
|
3967
|
-
const { r:
|
|
3968
|
-
return
|
|
3967
|
+
const { r: b, s: E } = this, M = i.toBytes(b), O = i.toBytes(E);
|
|
3968
|
+
return _ === "recovered" ? (C(), ve(Uint8Array.of(this.assertRecovery()), M, O)) : ve(M, O);
|
|
3969
3969
|
}
|
|
3970
|
-
toHex(
|
|
3971
|
-
return Me(this.toBytes(
|
|
3970
|
+
toHex(_) {
|
|
3971
|
+
return Me(this.toBytes(_));
|
|
3972
3972
|
}
|
|
3973
3973
|
}
|
|
3974
|
-
const
|
|
3975
|
-
if (
|
|
3974
|
+
const V = s.bits2int || function(_) {
|
|
3975
|
+
if (_.length > 8192)
|
|
3976
3976
|
throw new Error("input is too large");
|
|
3977
|
-
const
|
|
3978
|
-
return
|
|
3979
|
-
},
|
|
3980
|
-
return i.create(
|
|
3981
|
-
},
|
|
3982
|
-
function
|
|
3983
|
-
return Tr("num < 2^" + c, f, _e,
|
|
3984
|
-
}
|
|
3985
|
-
function
|
|
3986
|
-
return
|
|
3987
|
-
}
|
|
3988
|
-
function q(f,
|
|
3989
|
-
const { lowS:
|
|
3990
|
-
f =
|
|
3991
|
-
const
|
|
3977
|
+
const b = ze(_), E = _.length * 8 - c;
|
|
3978
|
+
return E > 0 ? b >> BigInt(E) : b;
|
|
3979
|
+
}, W = s.bits2int_modN || function(_) {
|
|
3980
|
+
return i.create(V(_));
|
|
3981
|
+
}, P = ft(c);
|
|
3982
|
+
function k(f) {
|
|
3983
|
+
return Tr("num < 2^" + c, f, _e, P), i.toBytes(f);
|
|
3984
|
+
}
|
|
3985
|
+
function D(f, _) {
|
|
3986
|
+
return z(f, void 0, "message"), _ ? z(e(f), void 0, "prehashed message") : f;
|
|
3987
|
+
}
|
|
3988
|
+
function q(f, _, b) {
|
|
3989
|
+
const { lowS: E, prehash: M, extraEntropy: O } = st(b, w);
|
|
3990
|
+
f = D(f, M);
|
|
3991
|
+
const $ = W(f), T = i.fromBytes(_);
|
|
3992
3992
|
if (!i.isValidNot0(T))
|
|
3993
3993
|
throw new Error("invalid private key");
|
|
3994
|
-
const
|
|
3994
|
+
const B = [k(T), k($)];
|
|
3995
3995
|
if (O != null && O !== !1) {
|
|
3996
|
-
const
|
|
3997
|
-
|
|
3996
|
+
const F = O === !0 ? t(x.secretKey) : O;
|
|
3997
|
+
B.push(z(F, void 0, "extraEntropy"));
|
|
3998
3998
|
}
|
|
3999
|
-
const
|
|
4000
|
-
function K(
|
|
4001
|
-
const X =
|
|
3999
|
+
const G = ve(...B), J = $;
|
|
4000
|
+
function K(F) {
|
|
4001
|
+
const X = V(F);
|
|
4002
4002
|
if (!i.isValidNot0(X))
|
|
4003
4003
|
return;
|
|
4004
4004
|
const Z = i.inv(X), oe = r.BASE.multiply(X).toAffine(), j = i.create(oe.x);
|
|
@@ -4008,46 +4008,46 @@ 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
|
|
4011
|
+
return E && y(Q) && (bt = i.neg(Q), yt ^= 1), new N(j, bt, v ? void 0 : yt);
|
|
4012
4012
|
}
|
|
4013
|
-
return { seed:
|
|
4013
|
+
return { seed: G, k2sig: K };
|
|
4014
4014
|
}
|
|
4015
|
-
function
|
|
4016
|
-
const { seed:
|
|
4017
|
-
return kr(e.outputLen, i.BYTES, n)(
|
|
4015
|
+
function L(f, _, b = {}) {
|
|
4016
|
+
const { seed: E, k2sig: M } = q(f, _, b);
|
|
4017
|
+
return kr(e.outputLen, i.BYTES, n)(E, M).toBytes(b.format);
|
|
4018
4018
|
}
|
|
4019
|
-
function R(f,
|
|
4020
|
-
const { lowS:
|
|
4021
|
-
if (
|
|
4022
|
-
const T = f instanceof
|
|
4019
|
+
function R(f, _, b, E = {}) {
|
|
4020
|
+
const { lowS: M, prehash: O, format: $ } = st(E, w);
|
|
4021
|
+
if (b = z(b, void 0, "publicKey"), _ = D(_, O), !ut(f)) {
|
|
4022
|
+
const T = f instanceof N ? ", use sig.toBytes()" : "";
|
|
4023
4023
|
throw new Error("verify expects Uint8Array signature" + T);
|
|
4024
4024
|
}
|
|
4025
|
-
|
|
4025
|
+
U(f, $);
|
|
4026
4026
|
try {
|
|
4027
|
-
const T =
|
|
4028
|
-
if (
|
|
4027
|
+
const T = N.fromBytes(f, $), B = r.fromBytes(b);
|
|
4028
|
+
if (M && T.hasHighS())
|
|
4029
4029
|
return !1;
|
|
4030
|
-
const { r:
|
|
4031
|
-
return oe.is0() ? !1 : i.create(oe.x) ===
|
|
4030
|
+
const { r: G, s: J } = T, K = W(_), F = i.inv(J), X = i.create(K * F), Z = i.create(G * F), oe = r.BASE.multiplyUnsafe(X).add(B.multiplyUnsafe(Z));
|
|
4031
|
+
return oe.is0() ? !1 : i.create(oe.x) === G;
|
|
4032
4032
|
} catch {
|
|
4033
4033
|
return !1;
|
|
4034
4034
|
}
|
|
4035
4035
|
}
|
|
4036
|
-
function
|
|
4037
|
-
const { prehash:
|
|
4038
|
-
return
|
|
4036
|
+
function A(f, _, b = {}) {
|
|
4037
|
+
const { prehash: E } = st(b, w);
|
|
4038
|
+
return _ = D(_, E), N.fromBytes(f, "recovered").recoverPublicKey(_).toBytes();
|
|
4039
4039
|
}
|
|
4040
4040
|
return Object.freeze({
|
|
4041
4041
|
keygen: l,
|
|
4042
|
-
getPublicKey:
|
|
4042
|
+
getPublicKey: d,
|
|
4043
4043
|
getSharedSecret: h,
|
|
4044
4044
|
utils: m,
|
|
4045
|
-
lengths:
|
|
4045
|
+
lengths: x,
|
|
4046
4046
|
Point: r,
|
|
4047
|
-
sign:
|
|
4047
|
+
sign: L,
|
|
4048
4048
|
verify: R,
|
|
4049
|
-
recoverPublicKey:
|
|
4050
|
-
Signature:
|
|
4049
|
+
recoverPublicKey: A,
|
|
4050
|
+
Signature: N,
|
|
4051
4051
|
hash: e
|
|
4052
4052
|
});
|
|
4053
4053
|
}
|
|
@@ -4068,10 +4068,10 @@ 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,
|
|
4072
|
-
if (!lt.eql(lt.sqr(
|
|
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, d = l * l * r % e, h = ae(d, s, e) * d % e, m = ae(h, s, e) * d % e, x = ae(m, qt, e) * l % e, w = ae(x, n, e) * x % e, v = ae(w, o, e) * w % e, y = ae(v, a, e) * v % e, S = ae(y, c, e) * y % e, C = ae(S, a, e) * v % e, U = ae(C, s, e) * d % e, N = ae(U, i, e) * w % e, V = ae(N, t, e) * l % e, W = ae(V, qt, e);
|
|
4072
|
+
if (!lt.eql(lt.sqr(W), r))
|
|
4073
4073
|
throw new Error("Cannot find square root");
|
|
4074
|
-
return
|
|
4074
|
+
return W;
|
|
4075
4075
|
}
|
|
4076
4076
|
const lt = je(gt.p, { sqrt: Zr }), Qr = /* @__PURE__ */ jr(gt, {
|
|
4077
4077
|
Fp: lt,
|
|
@@ -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], d = s[c + 1], h = Kt(l, d, 1) ^ s[a], m = Vt(l, d, 1) ^ s[a + 1];
|
|
4095
|
+
for (let x = 0; x < 50; x += 10)
|
|
4096
|
+
r[i + x] ^= h, r[i + x + 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), d = Ts[i];
|
|
4101
|
+
n = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
|
|
4102
4102
|
}
|
|
4103
4103
|
for (let i = 0; i < 50; i += 10) {
|
|
4104
4104
|
for (let a = 0; a < 10; a++)
|
|
@@ -4113,17 +4113,17 @@ function ln(r, e = 24) {
|
|
|
4113
4113
|
class mt {
|
|
4114
4114
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
4115
4115
|
constructor(e, s, t, n = !1, o = 24) {
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4116
|
+
I(this, "state");
|
|
4117
|
+
I(this, "pos", 0);
|
|
4118
|
+
I(this, "posOut", 0);
|
|
4119
|
+
I(this, "finished", !1);
|
|
4120
|
+
I(this, "state32");
|
|
4121
|
+
I(this, "destroyed", !1);
|
|
4122
|
+
I(this, "blockLen");
|
|
4123
|
+
I(this, "suffix");
|
|
4124
|
+
I(this, "outputLen");
|
|
4125
|
+
I(this, "enableXOF", !1);
|
|
4126
|
+
I(this, "rounds");
|
|
4127
4127
|
if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, ge(t, "outputLen"), !(0 < e && e < 200))
|
|
4128
4128
|
throw new Error("only keccak-f1600 function is supported");
|
|
4129
4129
|
this.state = new Uint8Array(200), this.state32 = ir(this.state);
|
|
@@ -4135,7 +4135,7 @@ class mt {
|
|
|
4135
4135
|
Ct(this.state32), ln(this.state32, this.rounds), Ct(this.state32), this.posOut = 0, this.pos = 0;
|
|
4136
4136
|
}
|
|
4137
4137
|
update(e) {
|
|
4138
|
-
ke(this),
|
|
4138
|
+
ke(this), z(e);
|
|
4139
4139
|
const { blockLen: s, state: t } = this, n = e.length;
|
|
4140
4140
|
for (let o = 0; o < n; ) {
|
|
4141
4141
|
const i = Math.min(s - this.pos, n - o);
|
|
@@ -4153,7 +4153,7 @@ class mt {
|
|
|
4153
4153
|
e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
|
|
4154
4154
|
}
|
|
4155
4155
|
writeInto(e) {
|
|
4156
|
-
ke(this, !1),
|
|
4156
|
+
ke(this, !1), z(e), this.finish();
|
|
4157
4157
|
const s = this.state, { blockLen: t } = this;
|
|
4158
4158
|
for (let n = 0, o = e.length; n < o; ) {
|
|
4159
4159
|
this.posOut >= t && this.keccak();
|
|
@@ -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)), u.log("[CROSSx] JWKS 엔드포인트 설정:", e);
|
|
4197
4197
|
} catch (s) {
|
|
4198
|
-
|
|
4198
|
+
u.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
|
+
u.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 u.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 u.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 u.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 u.error("[CROSSx] JWT 서명 검증 실패:", o), { payload: t, valid: !1, signatureVerified: !1 };
|
|
4231
|
+
u.warn("[CROSSx] JWKS 엔드포인트 접근 불가 — 서명 미검증 모드로 전환");
|
|
4232
4232
|
}
|
|
4233
|
-
return
|
|
4233
|
+
return u.log("[CROSSx] JWT 검증 성공 (서명 미검증 — JWKS 미설정 또는 접근 불가)"), { payload: t, valid: !0, signatureVerified: !1 };
|
|
4234
4234
|
} catch (t) {
|
|
4235
|
-
throw
|
|
4235
|
+
throw u.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), d = c.slice(32, 64), h = c[64], m = h >= 27 ? h - 27 : h, v = new en.Signature(
|
|
4258
4258
|
jt(l),
|
|
4259
|
-
jt(
|
|
4260
|
-
).addRecoveryBit(m).recoverPublicKey(i).toBytes(!1).slice(1), y = zt(
|
|
4259
|
+
jt(d)
|
|
4260
|
+
).addRecoveryBit(m).recoverPublicKey(i).toBytes(!1).slice(1), y = zt(v);
|
|
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 (u.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
|
+
u.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 u.error("[CROSSx] nonce claim 누락 — JWT payload 전체 키 목록:", Object.keys(t)), u.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 (u.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 (u.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
|
+
u.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(), d = e.authUrl.includes("?") ? "&" : "?", h = `${e.authUrl}${d}state=${c}&nonce=${l}`;
|
|
4391
|
+
u.log("[CROSSx] OAuth 팝업 열기 — state, nonce 생성 완료:", {
|
|
4392
4392
|
stateLength: c.length,
|
|
4393
4393
|
nonceLength: l.length,
|
|
4394
4394
|
authUrlBase: e.authUrl
|
|
@@ -4402,59 +4402,59 @@ 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 x = setTimeout(() => {
|
|
4406
|
+
u.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), N(), t(new Error("Authentication timeout"));
|
|
4407
|
+
}, 5 * 60 * 1e3), w = 10, v = 30;
|
|
4408
|
+
let y = 0, S = null;
|
|
4409
4409
|
const C = () => {
|
|
4410
|
-
clearInterval(
|
|
4411
|
-
|
|
4410
|
+
clearInterval(U), u.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + v + "초간 대기합니다"), S = setTimeout(() => {
|
|
4411
|
+
N(), t(new Error(
|
|
4412
4412
|
"OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
|
|
4413
4413
|
));
|
|
4414
|
-
},
|
|
4415
|
-
},
|
|
4414
|
+
}, v * 1e3);
|
|
4415
|
+
}, U = setInterval(() => {
|
|
4416
4416
|
y++;
|
|
4417
4417
|
try {
|
|
4418
|
-
m.closed && (y <= w ? C() : (
|
|
4418
|
+
m.closed && (y <= w ? C() : (N(), t(new Error("로그인이 취소되었습니다"))));
|
|
4419
4419
|
} catch {
|
|
4420
4420
|
C();
|
|
4421
4421
|
}
|
|
4422
|
-
}, 1e3),
|
|
4423
|
-
clearTimeout(
|
|
4424
|
-
},
|
|
4425
|
-
var
|
|
4426
|
-
if (
|
|
4427
|
-
if (!gn.has(
|
|
4428
|
-
|
|
4422
|
+
}, 1e3), N = () => {
|
|
4423
|
+
clearTimeout(x), clearInterval(U), S && clearTimeout(S), window.removeEventListener("message", V);
|
|
4424
|
+
}, V = (W) => {
|
|
4425
|
+
var k, D, q, L, R;
|
|
4426
|
+
if (W.origin !== e.expectedOrigin) return;
|
|
4427
|
+
if (!gn.has(W.origin)) {
|
|
4428
|
+
u.error("[CROSSx] postMessage origin이 허용 목록에 없음:", W.origin), N(), t(new Error("Unauthorized OAuth origin"));
|
|
4429
4429
|
return;
|
|
4430
4430
|
}
|
|
4431
|
-
|
|
4432
|
-
const
|
|
4433
|
-
if (!
|
|
4431
|
+
N(), u.log("[CROSSx] OAuth postMessage 수신 — status:", W.data.status);
|
|
4432
|
+
const P = W.data.state ?? ((k = W.data.data) == null ? void 0 : k.state);
|
|
4433
|
+
if (!P || P !== c) {
|
|
4434
4434
|
t(new Error("OAuth state mismatch — possible CSRF attack"));
|
|
4435
4435
|
return;
|
|
4436
4436
|
}
|
|
4437
|
-
if (
|
|
4438
|
-
const
|
|
4439
|
-
if (
|
|
4437
|
+
if (W.data.status === "success") {
|
|
4438
|
+
const A = (D = W.data.data) == null ? void 0 : D.idToken, f = (q = W.data.data) == null ? void 0 : q.accessToken, _ = f ?? A;
|
|
4439
|
+
if (u.log("[CROSSx] OAuth 토큰 수신:", {
|
|
4440
4440
|
hasAccessToken: !!f,
|
|
4441
|
-
hasIdToken: !!
|
|
4442
|
-
}), !
|
|
4443
|
-
|
|
4441
|
+
hasIdToken: !!A
|
|
4442
|
+
}), !_) {
|
|
4443
|
+
u.error("[CROSSx] 토큰을 찾을 수 없음:", W.data), t(new Error("Token not found in response"));
|
|
4444
4444
|
return;
|
|
4445
4445
|
}
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
}) : f ? f.split(".").length === 3 ? be.verifyIdTokenNonce(f, l).then(() => s(
|
|
4449
|
-
|
|
4450
|
-
}) : (
|
|
4446
|
+
A ? be.verifyIdTokenNonce(A, l).then(() => s(_)).catch((b) => {
|
|
4447
|
+
u.error("[CROSSx] nonce 검증 실패:", b), t(b instanceof Error ? b : new Error("nonce verification failed"));
|
|
4448
|
+
}) : f ? f.split(".").length === 3 ? be.verifyIdTokenNonce(f, l).then(() => s(_)).catch((E) => {
|
|
4449
|
+
u.error("[CROSSx] accessToken nonce 검증 실패:", E), t(E instanceof Error ? E : new Error("nonce verification failed"));
|
|
4450
|
+
}) : (u.warn(
|
|
4451
4451
|
"[CROSSx] opaque accessToken만 수신 (idToken 없음) — nonce 검증 불가.",
|
|
4452
4452
|
"서버 측 nonce 검증이 필요합니다."
|
|
4453
|
-
), s(
|
|
4453
|
+
), s(_)) : t(new Error("Token not found in response"));
|
|
4454
4454
|
} else
|
|
4455
|
-
|
|
4455
|
+
u.error("[CROSSx] OAuth 실패:", (L = W.data.data) == null ? void 0 : L.error), t(new Error(((R = W.data.data) == null ? void 0 : R.error) || "Authentication failed"));
|
|
4456
4456
|
};
|
|
4457
|
-
window.addEventListener("message",
|
|
4457
|
+
window.addEventListener("message", V);
|
|
4458
4458
|
});
|
|
4459
4459
|
}
|
|
4460
4460
|
}
|
|
@@ -4471,9 +4471,9 @@ class mn {
|
|
|
4471
4471
|
*/
|
|
4472
4472
|
async checkWallet() {
|
|
4473
4473
|
if (this.migrateScenario !== void 0)
|
|
4474
|
-
return
|
|
4474
|
+
return u.log("[Mock] checkWallet → migration_required"), "migration_required";
|
|
4475
4475
|
const s = await this.storage.get(Ce) ? "exists" : "not_found";
|
|
4476
|
-
return
|
|
4476
|
+
return u.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), u.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 u.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 u.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 u.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
|
+
u.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 u.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 (u.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), u.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 (u.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), u.log("[Mock] changePin 완료");
|
|
4548
4548
|
}
|
|
4549
4549
|
async migrateWallet(e, s) {
|
|
4550
4550
|
var o;
|
|
4551
|
-
if (
|
|
4551
|
+
if (u.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), u.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 u.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 u.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 d = (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 (d && typeof d.code == "number") {
|
|
4645
|
+
if (d.code < 0 || d.code >= 400) {
|
|
4646
|
+
const h = d.message || d.data || "API 요청에 실패했습니다";
|
|
4647
|
+
u.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
|
|
4648
|
+
code: d.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(d.code, d.data), x = Le.getGatewayErrorMessage(d.code, h), w = d.data, v = m === p.PIN_LOCKED ? Le.extractLockDetails(w) : w ?? void 0, y = new g(m, x, v);
|
|
4654
|
+
throw m === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (u.warn("[CROSSx] Gateway -10002 감지 — 강제 로그아웃 실행"), this._onUnauthorized()), y;
|
|
4655
4655
|
}
|
|
4656
|
-
return
|
|
4656
|
+
return u.log("[CROSSx] Wallet Gateway API 성공:", { code: d.code, url: o, method: e }), d.data ?? d;
|
|
4657
4657
|
}
|
|
4658
|
-
return
|
|
4658
|
+
return d;
|
|
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 d = l.response.data, h = d.message || d.data || "API 요청에 실패했습니다", m = d.code || "UNKNOWN";
|
|
4663
|
+
throw u.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
|
+
u.log("[CROSSx] GET /mnemonic/check");
|
|
4683
4683
|
const e = await this.request("GET", "/mnemonic/check");
|
|
4684
|
-
return
|
|
4684
|
+
return u.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, u.log("[CROSSx] getOrCreateWallet — 캐시된 상태 사용:", s)) : (u.log("[CROSSx] GET /mnemonic/check — 지갑 상태 확인"), s = await this.checkWallet(), this._walletStatusCache = null), s === "migration_required")
|
|
4696
|
+
throw u.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
|
+
u.log("[CROSSx] 기존 지갑 발견 — POST /mnemonic/address(0)로 주소 조회");
|
|
4702
4702
|
const o = await this.getAddress(e, 0);
|
|
4703
|
-
return
|
|
4703
|
+
return u.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
|
+
u.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 u.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
|
+
u.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 u.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",
|
|
@@ -6988,7 +6988,7 @@ function Y(r, e) {
|
|
|
6988
6988
|
}
|
|
6989
6989
|
function Tn(r, e) {
|
|
6990
6990
|
const s = e, t = Ye(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
6991
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
6991
|
+
<button class="__crossx-copy-btn" data-copy="${H(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", o = Os(r), i = r.data ?? "0x", a = document.createElement("div");
|
|
6992
6992
|
return a.id = te, a.innerHTML = `
|
|
6993
6993
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
6994
6994
|
<div class="__crossx-header">
|
|
@@ -7000,7 +7000,7 @@ function Tn(r, e) {
|
|
|
7000
7000
|
<div class="__crossx-body-cols">
|
|
7001
7001
|
<div class="__crossx-col-left">
|
|
7002
7002
|
<p class="__crossx-sig-subtitle">
|
|
7003
|
-
<span class="__crossx-sig-origin">${
|
|
7003
|
+
<span class="__crossx-sig-origin">${H(t)} </span>is requesting a Signature
|
|
7004
7004
|
</p>
|
|
7005
7005
|
<div class="__crossx-addr-pill">
|
|
7006
7006
|
${wt}
|
|
@@ -7015,7 +7015,7 @@ function Tn(r, e) {
|
|
|
7015
7015
|
${Y("Network", `<span>${Ns(r.chainId)}</span>`)}
|
|
7016
7016
|
${o}
|
|
7017
7017
|
</div>
|
|
7018
|
-
<pre class="__crossx-raw-tx">${
|
|
7018
|
+
<pre class="__crossx-raw-tx">${H(i)}</pre>
|
|
7019
7019
|
</div>
|
|
7020
7020
|
</div>
|
|
7021
7021
|
<div class="__crossx-btn-row">
|
|
@@ -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="${
|
|
7032
|
-
return
|
|
7031
|
+
<button class="__crossx-copy-btn" data-copy="${H(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", a = Os(r), l = bn(r.value, t, n) ?? "—", d = document.createElement("div");
|
|
7032
|
+
return d.id = te, d.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>
|
|
@@ -7038,7 +7038,7 @@ function Rn(r, e) {
|
|
|
7038
7038
|
<hr class="__crossx-divider">
|
|
7039
7039
|
<div class="__crossx-body">
|
|
7040
7040
|
<p class="__crossx-tx-subtitle">
|
|
7041
|
-
<span class="__crossx-sig-origin">${
|
|
7041
|
+
<span class="__crossx-sig-origin">${H(o)}</span> wants your permission to approve the following transaction.
|
|
7042
7042
|
</p>
|
|
7043
7043
|
<div class="__crossx-body-cols">
|
|
7044
7044
|
<div class="__crossx-rows">
|
|
@@ -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
|
+
`, d;
|
|
7058
7058
|
}
|
|
7059
7059
|
function Ye(r) {
|
|
7060
7060
|
var e;
|
|
@@ -7065,17 +7065,17 @@ function Ye(r) {
|
|
|
7065
7065
|
return "This site";
|
|
7066
7066
|
}
|
|
7067
7067
|
}
|
|
7068
|
-
function
|
|
7068
|
+
function H(r) {
|
|
7069
7069
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7070
7070
|
}
|
|
7071
7071
|
function kn(r) {
|
|
7072
7072
|
return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
|
|
7073
7073
|
}
|
|
7074
7074
|
function Pn(r) {
|
|
7075
|
-
if (typeof r == "string") return
|
|
7075
|
+
if (typeof r == "string") return H(r);
|
|
7076
7076
|
if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
|
|
7077
7077
|
try {
|
|
7078
|
-
return
|
|
7078
|
+
return H(JSON.stringify(r));
|
|
7079
7079
|
} catch {
|
|
7080
7080
|
return String(r);
|
|
7081
7081
|
}
|
|
@@ -7084,12 +7084,12 @@ function Nn(r, e) {
|
|
|
7084
7084
|
const s = Y(
|
|
7085
7085
|
"From",
|
|
7086
7086
|
`<span class="__crossx-addr-text">${se(r.from)}</span>
|
|
7087
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7087
|
+
<button class="__crossx-copy-btn" data-copy="${H(r.from)}" title="Copy address">${xe}</button>`
|
|
7088
7088
|
), t = r.to ? Y("To", `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
7089
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7090
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7089
|
+
<button class="__crossx-copy-btn" data-copy="${H(r.to)}" title="Copy address">${xe}</button>`) : "", n = r.amount ? Y("Transfer", `<span>${H(r.amount)}</span>`) : "", o = r.fees ? Y("Tx Fee", `<span>${H(r.fees)}</span>`) : "", i = r.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(r.txHash)}</span>
|
|
7090
|
+
<button class="__crossx-copy-btn" data-copy="${H(r.txHash)}" title="Copy hash">${xe}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
|
|
7091
7091
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
7092
|
-
<span class="__crossx-total-amount">${
|
|
7092
|
+
<span class="__crossx-total-amount">${H(r.total)}</span>
|
|
7093
7093
|
</div>` : "", c = document.createElement("div");
|
|
7094
7094
|
return c.id = te, c.innerHTML = `
|
|
7095
7095
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -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, v = 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>${v}</span>`) : o.textContent = v;
|
|
7137
7137
|
}
|
|
7138
7138
|
if (i && !r.querySelector("#__crossx-close-btn")) {
|
|
7139
7139
|
const w = document.createElement("button");
|
|
@@ -7142,34 +7142,34 @@ function Cn(r, e, s) {
|
|
|
7142
7142
|
const a = r.querySelector("#__crossx-progress-body");
|
|
7143
7143
|
if (!a) return;
|
|
7144
7144
|
const c = e.from ? Y("From", `<span class="__crossx-addr-text">${se(e.from)}</span>
|
|
7145
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7146
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7147
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7145
|
+
<button class="__crossx-copy-btn" data-copy="${H(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="${H(e.to)}" title="Copy address">${xe}</button>`) : "", d = e.amount ? Y("Transfer", `<span>${H(e.amount)}</span>`) : "", h = e.fees ? Y("Tx Fee", `<span>${H(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="${H(e.txHash)}" title="Copy hash">${xe}</button>`) : "", x = e.total ? `<div class="__crossx-total-pill">
|
|
7148
7148
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
7149
|
-
<span class="__crossx-total-amount">${
|
|
7149
|
+
<span class="__crossx-total-amount">${H(e.total)}</span>
|
|
7150
7150
|
</div>` : "";
|
|
7151
7151
|
a.innerHTML = `
|
|
7152
7152
|
<div class="__crossx-rows">
|
|
7153
7153
|
${c}
|
|
7154
7154
|
${l}
|
|
7155
|
-
${
|
|
7155
|
+
${d}
|
|
7156
7156
|
${h}
|
|
7157
7157
|
${m}
|
|
7158
7158
|
</div>
|
|
7159
|
-
${
|
|
7159
|
+
${x}
|
|
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", (v) => {
|
|
7163
|
+
var S;
|
|
7164
|
+
v.stopPropagation();
|
|
7165
7165
|
const y = w.dataset.copy;
|
|
7166
|
-
y && ((
|
|
7166
|
+
y && ((S = navigator.clipboard) == null || S.writeText(y).catch(() => {
|
|
7167
7167
|
}));
|
|
7168
7168
|
});
|
|
7169
7169
|
});
|
|
7170
7170
|
}
|
|
7171
7171
|
function Ln(r, e) {
|
|
7172
|
-
const s = e, t = Ye(r.dappName), n =
|
|
7172
|
+
const s = e, t = Ye(r.dappName), n = H(r.message), o = document.createElement("div");
|
|
7173
7173
|
return o.id = te, o.innerHTML = `
|
|
7174
7174
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7175
7175
|
<div class="__crossx-header">
|
|
@@ -7181,7 +7181,7 @@ function Ln(r, e) {
|
|
|
7181
7181
|
<div class="__crossx-body-cols">
|
|
7182
7182
|
<div class="__crossx-col-left">
|
|
7183
7183
|
<p class="__crossx-sig-subtitle">
|
|
7184
|
-
<span class="__crossx-sig-origin">${
|
|
7184
|
+
<span class="__crossx-sig-origin">${H(t)} </span>is requesting a Signature
|
|
7185
7185
|
</p>
|
|
7186
7186
|
<div class="__crossx-addr-pill">
|
|
7187
7187
|
${wt}
|
|
@@ -7213,15 +7213,15 @@ function Dn(r, e) {
|
|
|
7213
7213
|
let a = `
|
|
7214
7214
|
<div class="__crossx-td-row">
|
|
7215
7215
|
<span class="__crossx-td-label">Primary Type</span>
|
|
7216
|
-
<span class="__crossx-td-value">${
|
|
7216
|
+
<span class="__crossx-td-value">${H(o)}</span>
|
|
7217
7217
|
</div>`;
|
|
7218
|
-
for (const [l,
|
|
7219
|
-
const h = Pn(
|
|
7220
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7218
|
+
for (const [l, d] of Object.entries(i)) {
|
|
7219
|
+
const h = Pn(d), x = kn(d) ? `<span class="__crossx-addr-text">${se(d)}</span>
|
|
7220
|
+
<button class="__crossx-copy-btn" data-copy="${H(String(d))}" title="Copy">${xe}</button>` : `<span>${h}</span>`;
|
|
7221
7221
|
a += `
|
|
7222
7222
|
<div class="__crossx-td-row">
|
|
7223
|
-
<span class="__crossx-td-label">${
|
|
7224
|
-
<div class="__crossx-td-value">${
|
|
7223
|
+
<span class="__crossx-td-label">${H(l)}</span>
|
|
7224
|
+
<div class="__crossx-td-value">${x}</div>
|
|
7225
7225
|
</div>`;
|
|
7226
7226
|
}
|
|
7227
7227
|
const c = document.createElement("div");
|
|
@@ -7236,7 +7236,7 @@ function Dn(r, e) {
|
|
|
7236
7236
|
<div class="__crossx-body-cols">
|
|
7237
7237
|
<div class="__crossx-col-left">
|
|
7238
7238
|
<p class="__crossx-sig-subtitle">
|
|
7239
|
-
<span class="__crossx-sig-origin">${
|
|
7239
|
+
<span class="__crossx-sig-origin">${H(t)} </span>is requesting a Signature
|
|
7240
7240
|
</p>
|
|
7241
7241
|
<div class="__crossx-addr-pill">
|
|
7242
7242
|
${wt}
|
|
@@ -7262,7 +7262,7 @@ const Mn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="
|
|
|
7262
7262
|
function $n(r, e, s) {
|
|
7263
7263
|
const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
|
|
7264
7264
|
const a = t && i.address.toLowerCase() === t;
|
|
7265
|
-
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${
|
|
7265
|
+
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${H(i.address)}">
|
|
7266
7266
|
<span class="__crossx-wallet-addr">${se(i.address)}</span>${a ? '<span class="__crossx-wallet-selected">selected</span>' : ""}
|
|
7267
7267
|
</button>`;
|
|
7268
7268
|
}).join(""), o = document.createElement("div");
|
|
@@ -7364,7 +7364,7 @@ function Fn(r, e = !0) {
|
|
|
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>' : "", d = 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
|
+
${d}
|
|
7386
7386
|
</div>
|
|
7387
7387
|
</div>
|
|
7388
7388
|
`, h;
|
|
@@ -7426,13 +7426,13 @@ function Kn(r) {
|
|
|
7426
7426
|
const s = [r.check1, r.check2].map((t, n) => `
|
|
7427
7427
|
<div class="__crossx-pw-notice-item" data-check-index="${n}" role="checkbox" aria-checked="false" tabindex="0">
|
|
7428
7428
|
<div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${jn}</div>
|
|
7429
|
-
<span class="__crossx-pw-notice-item-text">${
|
|
7429
|
+
<span class="__crossx-pw-notice-item-text">${H(t)}</span>
|
|
7430
7430
|
</div>
|
|
7431
7431
|
`).join("");
|
|
7432
7432
|
return `
|
|
7433
7433
|
<div class="__crossx-header">
|
|
7434
|
-
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${
|
|
7435
|
-
<p class="__crossx-pw-subtitle">${
|
|
7434
|
+
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${H(r.title)}</p>
|
|
7435
|
+
<p class="__crossx-pw-subtitle">${H(r.headerSubtitle)}</p>
|
|
7436
7436
|
<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
|
|
7437
7437
|
</div>
|
|
7438
7438
|
<hr class="__crossx-divider">
|
|
@@ -7441,34 +7441,34 @@ function Kn(r) {
|
|
|
7441
7441
|
<div class="__crossx-pw-notice-header">
|
|
7442
7442
|
<div class="__crossx-pw-notice-title-row">
|
|
7443
7443
|
<span class="__crossx-pw-notice-icon">${Yn}</span>
|
|
7444
|
-
<p class="__crossx-pw-notice-title">${
|
|
7444
|
+
<p class="__crossx-pw-notice-title">${H(r.noticeTitle)}</p>
|
|
7445
7445
|
</div>
|
|
7446
|
-
<p class="__crossx-pw-notice-desc">${
|
|
7446
|
+
<p class="__crossx-pw-notice-desc">${H(r.noticeDesc)}</p>
|
|
7447
7447
|
</div>
|
|
7448
7448
|
<div class="__crossx-pw-notice-checks" id="__crossx-notice-checks">
|
|
7449
7449
|
${s}
|
|
7450
7450
|
</div>
|
|
7451
7451
|
</div>
|
|
7452
7452
|
<button class="__crossx-pw-btn --disabled" id="__crossx-pin-notice-next"
|
|
7453
|
-
data-next-label="${
|
|
7454
|
-
data-submit-label="${
|
|
7455
|
-
${
|
|
7453
|
+
data-next-label="${H(r.nextButton)}"
|
|
7454
|
+
data-submit-label="${H(r.submitButton)}">
|
|
7455
|
+
${H(r.nextButton)}
|
|
7456
7456
|
</button>
|
|
7457
7457
|
</div>
|
|
7458
7458
|
<div class="__crossx-home-indicator"></div>
|
|
7459
7459
|
`;
|
|
7460
7460
|
}
|
|
7461
7461
|
function nt(r) {
|
|
7462
|
-
const e = !!r.lockExpiresAt && r.lockExpiresAt > Date.now(), s = r.lockExpiresAt ? ` data-lock-expires="${r.lockExpiresAt}"` : "", t = r.headerSubtitle ? `<p class="__crossx-pin6-header-sub">${
|
|
7462
|
+
const e = !!r.lockExpiresAt && r.lockExpiresAt > Date.now(), s = r.lockExpiresAt ? ` data-lock-expires="${r.lockExpiresAt}"` : "", t = r.headerSubtitle ? `<p class="__crossx-pin6-header-sub">${H(r.headerSubtitle)}</p>` : "", n = r.subtitle ? `<p class="__crossx-pin6-subtitle">${H(r.subtitle)}</p>` : "", o = r.errorMessage ? `<p class="__crossx-pin6-error" id="__crossx-pin6-error">${H(r.errorMessage)}</p>` : '<p class="__crossx-pin6-error" id="__crossx-pin6-error"></p>', i = e ? `<p class="__crossx-pin6-lock-msg" id="__crossx-pin6-lock-msg">
|
|
7463
7463
|
${Cs}
|
|
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, d) => `<input class="__crossx-pin6-box${a}" type="password" maxlength="1" inputmode="numeric" pattern="[0-9]" autocomplete="off" aria-label="PIN digit ${d + 1}"${e ? " disabled" : ""}>`
|
|
7468
7468
|
).join("");
|
|
7469
7469
|
return `
|
|
7470
7470
|
<div class="__crossx-header">
|
|
7471
|
-
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${
|
|
7471
|
+
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${H(r.title)}</p>
|
|
7472
7472
|
${t}
|
|
7473
7473
|
<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
|
|
7474
7474
|
</div>
|
|
@@ -7504,62 +7504,63 @@ function zn(r) {
|
|
|
7504
7504
|
return s > 0 ? `${s}h ${String(t).padStart(2, "0")}m` : `${String(t).padStart(2, "0")}:${String(n).padStart(2, "0")}`;
|
|
7505
7505
|
}
|
|
7506
7506
|
function ot(r, e, s, t, n, o) {
|
|
7507
|
+
var V, W;
|
|
7507
7508
|
let i = !!(o && o > Date.now()), a = !1;
|
|
7508
|
-
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"),
|
|
7509
|
-
i =
|
|
7510
|
-
k.disabled =
|
|
7509
|
+
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), d = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), m = () => r.querySelector("#__crossx-pin6-lock-countdown"), x = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((P) => P.value).join(""), v = (P) => {
|
|
7510
|
+
i = P, c().forEach((k) => {
|
|
7511
|
+
k.disabled = P, k.classList.toggle("--locked", P);
|
|
7511
7512
|
});
|
|
7512
7513
|
}, y = () => {
|
|
7513
|
-
const
|
|
7514
|
-
|
|
7515
|
-
},
|
|
7516
|
-
const k =
|
|
7517
|
-
k && (k.textContent =
|
|
7518
|
-
const
|
|
7519
|
-
|
|
7520
|
-
|
|
7514
|
+
const P = d();
|
|
7515
|
+
P && (P.textContent = "");
|
|
7516
|
+
}, S = (P) => {
|
|
7517
|
+
const k = d();
|
|
7518
|
+
k && (k.textContent = P);
|
|
7519
|
+
const D = l();
|
|
7520
|
+
D == null || D.classList.add("--shake"), setTimeout(() => D == null ? void 0 : D.classList.remove("--shake"), 500), c().forEach((q) => {
|
|
7521
|
+
q.value = "";
|
|
7521
7522
|
}), setTimeout(() => {
|
|
7522
|
-
var
|
|
7523
|
-
return (
|
|
7523
|
+
var q;
|
|
7524
|
+
return (q = c()[0]) == null ? void 0 : q.focus();
|
|
7524
7525
|
}, 50);
|
|
7525
|
-
}, C = (
|
|
7526
|
-
var
|
|
7527
|
-
|
|
7528
|
-
|
|
7526
|
+
}, C = (P) => {
|
|
7527
|
+
var R;
|
|
7528
|
+
v(!0), c().forEach((A) => {
|
|
7529
|
+
A.value = "";
|
|
7529
7530
|
});
|
|
7530
|
-
const k =
|
|
7531
|
+
const k = d();
|
|
7531
7532
|
if (k && (k.textContent = "Too many failed attempts. Please wait."), !h()) {
|
|
7532
|
-
const
|
|
7533
|
-
|
|
7534
|
-
const
|
|
7535
|
-
|
|
7536
|
-
}
|
|
7537
|
-
const
|
|
7538
|
-
var
|
|
7539
|
-
const
|
|
7540
|
-
|
|
7541
|
-
var
|
|
7542
|
-
return (
|
|
7543
|
-
}, 50)) :
|
|
7544
|
-
},
|
|
7545
|
-
|
|
7546
|
-
const
|
|
7547
|
-
document.contains(r) || (clearInterval(
|
|
7533
|
+
const A = document.createElement("p");
|
|
7534
|
+
A.className = "__crossx-pin6-lock-msg", A.id = "__crossx-pin6-lock-msg", A.innerHTML = `${Cs}<span id="__crossx-pin6-lock-countdown"></span>`;
|
|
7535
|
+
const f = d();
|
|
7536
|
+
f ? f.insertAdjacentElement("afterend", A) : (R = x()) == null || R.appendChild(A);
|
|
7537
|
+
}
|
|
7538
|
+
const D = () => {
|
|
7539
|
+
var _;
|
|
7540
|
+
const A = P - Date.now(), f = m();
|
|
7541
|
+
A <= 0 ? (clearInterval(q), v(!1), (_ = h()) == null || _.remove(), k && (k.textContent = ""), setTimeout(() => {
|
|
7542
|
+
var b;
|
|
7543
|
+
return (b = c()[0]) == null ? void 0 : b.focus();
|
|
7544
|
+
}, 50)) : f && (f.textContent = ` ${zn(A)}`);
|
|
7545
|
+
}, q = setInterval(D, 1e3);
|
|
7546
|
+
D();
|
|
7547
|
+
const L = new MutationObserver(() => {
|
|
7548
|
+
document.contains(r) || (clearInterval(q), L.disconnect());
|
|
7548
7549
|
});
|
|
7549
|
-
|
|
7550
|
-
},
|
|
7550
|
+
L.observe(document.body, { childList: !0, subtree: !1 });
|
|
7551
|
+
}, U = async () => {
|
|
7551
7552
|
if (i || a) return;
|
|
7552
|
-
const
|
|
7553
|
-
if (
|
|
7553
|
+
const P = w();
|
|
7554
|
+
if (P.length === 6) {
|
|
7554
7555
|
a = !0, c().forEach((k) => {
|
|
7555
7556
|
k.disabled = !0;
|
|
7556
7557
|
});
|
|
7557
7558
|
try {
|
|
7558
7559
|
if (n) {
|
|
7559
|
-
const k = await n(
|
|
7560
|
-
k.ok ? e(
|
|
7560
|
+
const k = await n(P);
|
|
7561
|
+
k.ok ? e(P) : k.lockExpiresAt ? C(k.lockExpiresAt) : S(k.error ?? "Incorrect PIN. Please try again.");
|
|
7561
7562
|
} else
|
|
7562
|
-
e(
|
|
7563
|
+
e(P);
|
|
7563
7564
|
} catch (k) {
|
|
7564
7565
|
t && t(k);
|
|
7565
7566
|
} finally {
|
|
@@ -7570,33 +7571,44 @@ function ot(r, e, s, t, n, o) {
|
|
|
7570
7571
|
}
|
|
7571
7572
|
};
|
|
7572
7573
|
o && o > Date.now() ? C(o) : setTimeout(() => {
|
|
7573
|
-
var
|
|
7574
|
-
return (
|
|
7575
|
-
}, 100)
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7574
|
+
var P;
|
|
7575
|
+
return (P = c()[0]) == null ? void 0 : P.focus();
|
|
7576
|
+
}, 100);
|
|
7577
|
+
const N = () => {
|
|
7578
|
+
if (i || a) return;
|
|
7579
|
+
const P = c(), k = P.find((D) => !D.value) ?? P[P.length - 1];
|
|
7580
|
+
k == null || k.focus();
|
|
7581
|
+
};
|
|
7582
|
+
(V = l()) == null || V.addEventListener("click", (P) => {
|
|
7583
|
+
P.target.classList.contains("__crossx-pin6-box") || N();
|
|
7584
|
+
}), (W = x()) == null || W.addEventListener("click", (P) => {
|
|
7585
|
+
const k = P.target;
|
|
7586
|
+
k.classList.contains("__crossx-pin6-box") || k.closest("button") || N();
|
|
7587
|
+
}), c().forEach((P, k) => {
|
|
7588
|
+
P.addEventListener("input", () => {
|
|
7589
|
+
var q;
|
|
7590
|
+
const D = P.value.replace(/\D/g, "").slice(-1);
|
|
7591
|
+
P.value = D, y(), D && k < 5 && ((q = c()[k + 1]) == null || q.focus()), w().length === 6 && setTimeout(U, 80);
|
|
7592
|
+
}), P.addEventListener("keydown", (D) => {
|
|
7593
|
+
var q, L;
|
|
7594
|
+
if (D.key === "Backspace") {
|
|
7595
|
+
if (D.preventDefault(), P.value)
|
|
7596
|
+
P.value = "";
|
|
7585
7597
|
else if (k > 0) {
|
|
7586
|
-
const
|
|
7587
|
-
|
|
7598
|
+
const R = c()[k - 1];
|
|
7599
|
+
R.value = "", R.focus();
|
|
7588
7600
|
}
|
|
7589
|
-
} else
|
|
7590
|
-
}),
|
|
7591
|
-
var
|
|
7592
|
-
|
|
7593
|
-
const
|
|
7594
|
-
if (!
|
|
7595
|
-
const
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
}), (
|
|
7599
|
-
}),
|
|
7601
|
+
} else D.key === "ArrowLeft" && k > 0 ? (D.preventDefault(), (q = c()[k - 1]) == null || q.focus()) : D.key === "ArrowRight" && k < 5 ? (D.preventDefault(), (L = c()[k + 1]) == null || L.focus()) : D.key === "Escape" && s();
|
|
7602
|
+
}), P.addEventListener("paste", (D) => {
|
|
7603
|
+
var R, A;
|
|
7604
|
+
D.preventDefault();
|
|
7605
|
+
const q = (((R = D.clipboardData) == null ? void 0 : R.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
|
|
7606
|
+
if (!q) return;
|
|
7607
|
+
const L = c();
|
|
7608
|
+
q.split("").forEach((f, _) => {
|
|
7609
|
+
L[_] && (L[_].value = f);
|
|
7610
|
+
}), (A = L[Math.min(q.length - 1, 5)]) == null || A.focus(), y(), w().length === 6 && setTimeout(U, 80);
|
|
7611
|
+
}), P.addEventListener("focus", () => P.select());
|
|
7600
7612
|
});
|
|
7601
7613
|
}
|
|
7602
7614
|
const Cs = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -7607,30 +7619,37 @@ const Cs = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="h
|
|
|
7607
7619
|
<path d="M12 0C18.6274 0 24 5.37258 24 12C23.9999 18.6273 18.6274 24 12 24C5.37264 24 9.89594e-05 18.6273 0 12C0 5.37258 5.37258 0 12 0ZM10.875 15.127V17.377H13.125V15.127H10.875ZM10.875 6.62207V13.627H13.125V6.62207H10.875Z" fill="currentColor"/>
|
|
7608
7620
|
</svg>`;
|
|
7609
7621
|
function Jn(r, e, s) {
|
|
7610
|
-
var
|
|
7622
|
+
var o;
|
|
7611
7623
|
const t = r.querySelectorAll(".__crossx-pin-input");
|
|
7612
|
-
t.forEach((
|
|
7613
|
-
|
|
7614
|
-
const
|
|
7615
|
-
|
|
7616
|
-
const
|
|
7617
|
-
|
|
7618
|
-
}),
|
|
7619
|
-
|
|
7620
|
-
}),
|
|
7621
|
-
/[0-9]/.test(
|
|
7622
|
-
}),
|
|
7623
|
-
var
|
|
7624
|
-
|
|
7625
|
-
const
|
|
7626
|
-
if (!
|
|
7627
|
-
|
|
7628
|
-
t[
|
|
7624
|
+
t.forEach((i, a) => {
|
|
7625
|
+
i.addEventListener("input", () => {
|
|
7626
|
+
const c = i.value.replace(/\D/g, "");
|
|
7627
|
+
i.value = c ? c[0] : "", c && a < 3 && t[a + 1].focus();
|
|
7628
|
+
const l = Array.from(t).map((d) => d.value).join("");
|
|
7629
|
+
l.length === 4 && setTimeout(() => e(l), 200);
|
|
7630
|
+
}), i.addEventListener("keydown", (c) => {
|
|
7631
|
+
c.key === "Backspace" && !i.value && a > 0 && (t[a - 1].focus(), t[a - 1].value = ""), c.key === "Escape" && s();
|
|
7632
|
+
}), i.addEventListener("keypress", (c) => {
|
|
7633
|
+
/[0-9]/.test(c.key) || c.preventDefault();
|
|
7634
|
+
}), i.addEventListener("paste", (c) => {
|
|
7635
|
+
var h;
|
|
7636
|
+
c.preventDefault();
|
|
7637
|
+
const l = (((h = c.clipboardData) == null ? void 0 : h.getData("text")) ?? "").replace(/\D/g, "").slice(0, 4);
|
|
7638
|
+
if (!l) return;
|
|
7639
|
+
l.split("").forEach((m, x) => {
|
|
7640
|
+
t[x] && (t[x].value = m);
|
|
7629
7641
|
});
|
|
7630
|
-
const
|
|
7631
|
-
t[
|
|
7642
|
+
const d = Math.min(l.length, 3);
|
|
7643
|
+
t[d].focus(), l.length === 4 && setTimeout(() => e(l), 200);
|
|
7632
7644
|
});
|
|
7633
|
-
})
|
|
7645
|
+
});
|
|
7646
|
+
const n = r.querySelector(".__crossx-pin-inputs");
|
|
7647
|
+
n == null || n.addEventListener("click", (i) => {
|
|
7648
|
+
if (!i.target.classList.contains("__crossx-pin-input")) {
|
|
7649
|
+
const a = Array.from(t).find((c) => !c.value) ?? t[t.length - 1];
|
|
7650
|
+
a == null || a.focus();
|
|
7651
|
+
}
|
|
7652
|
+
}), (o = t[0]) == null || o.focus();
|
|
7634
7653
|
}
|
|
7635
7654
|
class Xn {
|
|
7636
7655
|
constructor(e = "light", s) {
|
|
@@ -7652,14 +7671,14 @@ class Xn {
|
|
|
7652
7671
|
*/
|
|
7653
7672
|
showWalletSelector(e, s, t) {
|
|
7654
7673
|
return new Promise((n) => {
|
|
7655
|
-
var
|
|
7674
|
+
var v;
|
|
7656
7675
|
he();
|
|
7657
7676
|
const o = [...e], i = $n(o, this.tokens, t), a = document.body.style.overflow;
|
|
7658
7677
|
document.body.style.overflow = "hidden", pe(i);
|
|
7659
7678
|
let c = !1;
|
|
7660
7679
|
const l = () => {
|
|
7661
7680
|
c || (c = !0, i.remove(), document.body.style.overflow = a);
|
|
7662
|
-
},
|
|
7681
|
+
}, d = (y) => {
|
|
7663
7682
|
l(), n(y);
|
|
7664
7683
|
}, h = () => {
|
|
7665
7684
|
l(), n(null);
|
|
@@ -7667,27 +7686,27 @@ class Xn {
|
|
|
7667
7686
|
(() => {
|
|
7668
7687
|
i.querySelectorAll(".__crossx-wallet-item").forEach((y) => {
|
|
7669
7688
|
y.addEventListener("click", () => {
|
|
7670
|
-
const
|
|
7671
|
-
|
|
7689
|
+
const S = y.dataset.walletAddress ?? "", C = parseInt(y.dataset.walletIndex ?? "0", 10);
|
|
7690
|
+
d({ address: S, index: C });
|
|
7672
7691
|
});
|
|
7673
7692
|
});
|
|
7674
7693
|
})();
|
|
7675
|
-
const
|
|
7676
|
-
|
|
7677
|
-
|
|
7694
|
+
const x = i.querySelector("#__crossx-add-wallet-btn");
|
|
7695
|
+
x && x.addEventListener("click", async () => {
|
|
7696
|
+
x.disabled = !0;
|
|
7678
7697
|
try {
|
|
7679
7698
|
const y = await s();
|
|
7680
7699
|
o.push(y);
|
|
7681
|
-
const
|
|
7682
|
-
if (
|
|
7700
|
+
const S = i.querySelector("#__crossx-wallet-list");
|
|
7701
|
+
if (S) {
|
|
7683
7702
|
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", () =>
|
|
7703
|
+
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", () => d(y)), S.appendChild(C), C.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
7685
7704
|
}
|
|
7686
7705
|
} catch {
|
|
7687
7706
|
} finally {
|
|
7688
|
-
|
|
7707
|
+
x.disabled = !1;
|
|
7689
7708
|
}
|
|
7690
|
-
}), (
|
|
7709
|
+
}), (v = i.querySelector("#__crossx-close-btn")) == null || v.addEventListener("click", h), i.addEventListener("click", (y) => {
|
|
7691
7710
|
y.target === i && h();
|
|
7692
7711
|
});
|
|
7693
7712
|
const w = (y) => {
|
|
@@ -7707,18 +7726,18 @@ class Xn {
|
|
|
7707
7726
|
he();
|
|
7708
7727
|
const s = Hn(this.tokens);
|
|
7709
7728
|
pe(s);
|
|
7710
|
-
const t = () => s.remove(), n = (
|
|
7711
|
-
t(), e(
|
|
7729
|
+
const t = () => s.remove(), n = (d) => {
|
|
7730
|
+
t(), e(d);
|
|
7712
7731
|
}, o = () => {
|
|
7713
7732
|
t(), e(null);
|
|
7714
7733
|
};
|
|
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
|
-
|
|
7734
|
+
(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", (d) => {
|
|
7735
|
+
d.target === s && o();
|
|
7736
|
+
}), s.querySelectorAll(".__crossx-login-terms-link").forEach((d) => {
|
|
7737
|
+
d.addEventListener("click", (h) => h.stopPropagation());
|
|
7719
7738
|
});
|
|
7720
|
-
const i = (
|
|
7721
|
-
|
|
7739
|
+
const i = (d) => {
|
|
7740
|
+
d.key === "Escape" && (document.removeEventListener("keydown", i), o());
|
|
7722
7741
|
};
|
|
7723
7742
|
document.addEventListener("keydown", i);
|
|
7724
7743
|
});
|
|
@@ -7739,14 +7758,14 @@ class Xn {
|
|
|
7739
7758
|
o(), t("recover");
|
|
7740
7759
|
};
|
|
7741
7760
|
if ((a = n.querySelector("#__crossx-recover-btn")) == null || a.addEventListener("click", i), s) {
|
|
7742
|
-
const
|
|
7761
|
+
const d = () => {
|
|
7743
7762
|
o(), t("skip");
|
|
7744
7763
|
};
|
|
7745
|
-
(c = n.querySelector("#__crossx-skip-btn")) == null || c.addEventListener("click",
|
|
7746
|
-
m.target === n &&
|
|
7764
|
+
(c = n.querySelector("#__crossx-skip-btn")) == null || c.addEventListener("click", d), (l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", d), n.addEventListener("click", (m) => {
|
|
7765
|
+
m.target === n && d();
|
|
7747
7766
|
});
|
|
7748
7767
|
const h = (m) => {
|
|
7749
|
-
m.key === "Escape" && (document.removeEventListener("keydown", h),
|
|
7768
|
+
m.key === "Escape" && (document.removeEventListener("keydown", h), d());
|
|
7750
7769
|
};
|
|
7751
7770
|
document.addEventListener("keydown", h);
|
|
7752
7771
|
}
|
|
@@ -7782,76 +7801,76 @@ class Xn {
|
|
|
7782
7801
|
}, a = Zt(this.tokens, Kn(n)), c = document.body.style.overflow;
|
|
7783
7802
|
document.body.style.overflow = "hidden", pe(a);
|
|
7784
7803
|
let l = !1;
|
|
7785
|
-
const
|
|
7804
|
+
const d = () => {
|
|
7786
7805
|
l || (l = !0, a.remove(), document.body.style.overflow = c);
|
|
7787
7806
|
}, h = (C) => {
|
|
7788
|
-
|
|
7807
|
+
d(), s(C);
|
|
7789
7808
|
}, m = () => {
|
|
7790
|
-
|
|
7791
|
-
},
|
|
7809
|
+
d(), s(null);
|
|
7810
|
+
}, x = a.querySelector(".__crossx-card"), w = {
|
|
7792
7811
|
tooShort: (t == null ? void 0 : t.pinValidation_tooShort) ?? "Please enter a 6-digit PIN.",
|
|
7793
7812
|
numbersOnly: (t == null ? void 0 : t.pinValidation_numbersOnly) ?? "Only numbers (0-9) are allowed.",
|
|
7794
7813
|
repeatingDigit: (t == null ? void 0 : t.pinValidation_repeatingDigit) ?? "Cannot use the same number 3+ times in a row.",
|
|
7795
7814
|
sequential: (t == null ? void 0 : t.pinValidation_sequential) ?? "Sequential numbers (e.g., 123456) are not allowed.",
|
|
7796
7815
|
alternatingPattern: (t == null ? void 0 : t.pinValidation_alternatingPattern) ?? "Repeating patterns (e.g., 121212) are not allowed."
|
|
7797
|
-
},
|
|
7798
|
-
var
|
|
7799
|
-
|
|
7816
|
+
}, v = (C) => {
|
|
7817
|
+
var U;
|
|
7818
|
+
x.innerHTML = nt({
|
|
7800
7819
|
title: i.title,
|
|
7801
7820
|
headerSubtitle: i.headerSubtitle
|
|
7802
|
-
}), (
|
|
7803
|
-
|
|
7821
|
+
}), (U = x.querySelector("#__crossx-close-btn")) == null || U.addEventListener("click", m), ot(x, (N) => {
|
|
7822
|
+
N === C ? h(C) : y(o.mismatchError);
|
|
7804
7823
|
}, m);
|
|
7805
7824
|
}, y = (C) => {
|
|
7806
|
-
var
|
|
7807
|
-
|
|
7825
|
+
var U;
|
|
7826
|
+
x.innerHTML = nt({
|
|
7808
7827
|
title: o.title,
|
|
7809
7828
|
headerSubtitle: o.headerSubtitle,
|
|
7810
7829
|
subtitle: o.subtitle,
|
|
7811
7830
|
errorMessage: C
|
|
7812
|
-
}), (
|
|
7813
|
-
const
|
|
7814
|
-
|
|
7831
|
+
}), (U = x.querySelector("#__crossx-close-btn")) == null || U.addEventListener("click", m), ot(x, (N) => {
|
|
7832
|
+
const V = Vn(N, w);
|
|
7833
|
+
V ? y(V) : v(N);
|
|
7815
7834
|
}, m);
|
|
7816
7835
|
};
|
|
7817
7836
|
(() => {
|
|
7818
7837
|
var q;
|
|
7819
|
-
const C = Array.from(
|
|
7820
|
-
|
|
7821
|
-
const
|
|
7822
|
-
const
|
|
7823
|
-
|
|
7824
|
-
},
|
|
7825
|
-
if (
|
|
7826
|
-
const
|
|
7827
|
-
|
|
7828
|
-
},
|
|
7829
|
-
if (!
|
|
7830
|
-
const
|
|
7831
|
-
|
|
7838
|
+
const C = Array.from(x.querySelectorAll(".__crossx-pw-notice-item")), U = x.querySelector("#__crossx-pin-notice-next"), N = /* @__PURE__ */ new Set();
|
|
7839
|
+
U.removeAttribute("disabled");
|
|
7840
|
+
const V = U.dataset.nextLabel ?? "Next", W = U.dataset.submitLabel ?? "I Understand", P = () => {
|
|
7841
|
+
const L = N.size === C.length;
|
|
7842
|
+
U.classList.toggle("--disabled", !L), U.textContent = L ? W : V;
|
|
7843
|
+
}, k = (L, R) => {
|
|
7844
|
+
if (N.has(R)) return;
|
|
7845
|
+
const A = L.querySelector(`#__crossx-notice-check-${R}`);
|
|
7846
|
+
N.add(R), A.classList.add("--checked"), L.setAttribute("aria-checked", "true"), P();
|
|
7847
|
+
}, D = (L, R) => {
|
|
7848
|
+
if (!N.has(R)) return;
|
|
7849
|
+
const A = L.querySelector(`#__crossx-notice-check-${R}`);
|
|
7850
|
+
N.delete(R), A.classList.remove("--checked"), L.setAttribute("aria-checked", "false"), P();
|
|
7832
7851
|
};
|
|
7833
|
-
C.forEach((
|
|
7834
|
-
const R = parseInt(
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
}),
|
|
7838
|
-
(
|
|
7852
|
+
C.forEach((L) => {
|
|
7853
|
+
const R = parseInt(L.dataset.checkIndex ?? "0", 10);
|
|
7854
|
+
L.addEventListener("click", () => {
|
|
7855
|
+
N.has(R) ? D(L, R) : k(L, R);
|
|
7856
|
+
}), L.addEventListener("keydown", (A) => {
|
|
7857
|
+
(A.key === " " || A.key === "Enter") && (A.preventDefault(), N.has(R) ? D(L, R) : k(L, R));
|
|
7839
7858
|
});
|
|
7840
|
-
}),
|
|
7841
|
-
if (
|
|
7859
|
+
}), U.addEventListener("click", () => {
|
|
7860
|
+
if (N.size === C.length) {
|
|
7842
7861
|
y(e == null ? void 0 : e.errorMessage);
|
|
7843
7862
|
return;
|
|
7844
7863
|
}
|
|
7845
|
-
const
|
|
7846
|
-
const f = parseInt(
|
|
7847
|
-
return !
|
|
7864
|
+
const L = C.find((A) => {
|
|
7865
|
+
const f = parseInt(A.dataset.checkIndex ?? "0", 10);
|
|
7866
|
+
return !N.has(f);
|
|
7848
7867
|
});
|
|
7849
|
-
if (!
|
|
7850
|
-
const R = parseInt(
|
|
7851
|
-
|
|
7852
|
-
|
|
7868
|
+
if (!L) return;
|
|
7869
|
+
const R = parseInt(L.dataset.checkIndex ?? "0", 10);
|
|
7870
|
+
L.scrollIntoView({ behavior: "smooth", block: "nearest" }), L.classList.add("--highlight"), setTimeout(() => {
|
|
7871
|
+
L.classList.remove("--highlight"), k(L, R);
|
|
7853
7872
|
}, 400);
|
|
7854
|
-
}), (q =
|
|
7873
|
+
}), (q = x.querySelector("#__crossx-close-btn")) == null || q.addEventListener("click", m);
|
|
7855
7874
|
})(), a.addEventListener("click", (C) => {
|
|
7856
7875
|
C.target === a && m();
|
|
7857
7876
|
});
|
|
@@ -7876,18 +7895,18 @@ class Xn {
|
|
|
7876
7895
|
})
|
|
7877
7896
|
), l = document.body.style.overflow;
|
|
7878
7897
|
document.body.style.overflow = "hidden", pe(c);
|
|
7879
|
-
let
|
|
7898
|
+
let d = !1;
|
|
7880
7899
|
const h = () => {
|
|
7881
|
-
|
|
7882
|
-
}, m = (
|
|
7883
|
-
h(), s(
|
|
7884
|
-
},
|
|
7900
|
+
d || (d = !0, c.remove(), document.body.style.overflow = l);
|
|
7901
|
+
}, m = (S) => {
|
|
7902
|
+
h(), s(S);
|
|
7903
|
+
}, x = () => {
|
|
7885
7904
|
h(), s(null);
|
|
7886
|
-
}, w = (
|
|
7887
|
-
h(), t(
|
|
7888
|
-
},
|
|
7889
|
-
(y =
|
|
7890
|
-
|
|
7905
|
+
}, w = (S) => {
|
|
7906
|
+
h(), t(S);
|
|
7907
|
+
}, v = c.querySelector(".__crossx-card");
|
|
7908
|
+
(y = v.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", x), ot(v, m, x, w, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt), c.addEventListener("click", (S) => {
|
|
7909
|
+
S.target === c && x();
|
|
7891
7910
|
});
|
|
7892
7911
|
});
|
|
7893
7912
|
}
|
|
@@ -7931,8 +7950,8 @@ class Xn {
|
|
|
7931
7950
|
}, a = () => {
|
|
7932
7951
|
i(), t();
|
|
7933
7952
|
}, c = o(a);
|
|
7934
|
-
(l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", a), n.addEventListener("click", (
|
|
7935
|
-
|
|
7953
|
+
(l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", a), n.addEventListener("click", (d) => {
|
|
7954
|
+
d.target === n && a();
|
|
7936
7955
|
});
|
|
7937
7956
|
});
|
|
7938
7957
|
}
|
|
@@ -7950,9 +7969,9 @@ class Xn {
|
|
|
7950
7969
|
n(), s();
|
|
7951
7970
|
};
|
|
7952
7971
|
(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) => {
|
|
7953
|
-
l.addEventListener("click", (
|
|
7972
|
+
l.addEventListener("click", (d) => {
|
|
7954
7973
|
var m;
|
|
7955
|
-
|
|
7974
|
+
d.stopPropagation();
|
|
7956
7975
|
const h = l.dataset.copy;
|
|
7957
7976
|
h && ((m = navigator.clipboard) == null || m.writeText(h).catch(() => {
|
|
7958
7977
|
}));
|
|
@@ -7980,8 +7999,8 @@ class Xn {
|
|
|
7980
7999
|
const a = () => {
|
|
7981
8000
|
i || (i = !0, o(), t());
|
|
7982
8001
|
}, c = () => {
|
|
7983
|
-
var
|
|
7984
|
-
(
|
|
8002
|
+
var d, h;
|
|
8003
|
+
(d = n.querySelector("#__crossx-done-btn")) == null || d.addEventListener("click", a), (h = n.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", a), n.addEventListener("click", (m) => {
|
|
7985
8004
|
m.target === n && a();
|
|
7986
8005
|
});
|
|
7987
8006
|
const l = (m) => {
|
|
@@ -7996,7 +8015,7 @@ class Xn {
|
|
|
7996
8015
|
}
|
|
7997
8016
|
requestConfirmation(e) {
|
|
7998
8017
|
return new Promise((s) => {
|
|
7999
|
-
var c, l,
|
|
8018
|
+
var c, l, d;
|
|
8000
8019
|
he();
|
|
8001
8020
|
let t;
|
|
8002
8021
|
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);
|
|
@@ -8005,12 +8024,12 @@ class Xn {
|
|
|
8005
8024
|
}, i = () => {
|
|
8006
8025
|
n(), s(!1);
|
|
8007
8026
|
};
|
|
8008
|
-
(c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (
|
|
8027
|
+
(c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (d = t.querySelector("#__crossx-close-btn")) == null || d.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((h) => {
|
|
8009
8028
|
h.addEventListener("click", (m) => {
|
|
8010
8029
|
var w;
|
|
8011
8030
|
m.stopPropagation();
|
|
8012
|
-
const
|
|
8013
|
-
|
|
8031
|
+
const x = h.dataset.copy;
|
|
8032
|
+
x && ((w = navigator.clipboard) == null || w.writeText(x).catch(() => {
|
|
8014
8033
|
}));
|
|
8015
8034
|
});
|
|
8016
8035
|
}), t.addEventListener("click", (h) => {
|
|
@@ -8057,21 +8076,21 @@ function so(r, e) {
|
|
|
8057
8076
|
gatewayUrl: s.walletGatewayUrl,
|
|
8058
8077
|
projectId: r.projectId
|
|
8059
8078
|
}, o = t.authMode !== "cookie" && Ot.isAvailable();
|
|
8060
|
-
!o && t.authMode !== "cookie" &&
|
|
8079
|
+
!o && t.authMode !== "cookie" && u.warn(
|
|
8061
8080
|
"[CROSSx] IndexedDB 사용 불가 — LocalStorage fallback 사용 중.",
|
|
8062
8081
|
"refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
|
|
8063
8082
|
"IndexedDB를 지원하는 브라우저 사용을 권장합니다."
|
|
8064
8083
|
), t.secureStorageAvailable = o;
|
|
8065
|
-
const i = o ? new Ot(r.projectId) : new rr(), a = new hn(), c = new xn(), l = new be(),
|
|
8084
|
+
const i = o ? new Ot(r.projectId) : new rr(), a = new hn(), c = new xn(), l = new be(), d = new Zn(), h = new es();
|
|
8066
8085
|
let m;
|
|
8067
|
-
r.useMockWallet ? (
|
|
8086
|
+
r.useMockWallet ? (u.log("[CROSSx] Mock Wallet Provider 사용"), m = new mn(i, h)) : (u.log("[CROSSx] Remote Wallet Provider 사용"), m = new Le(
|
|
8068
8087
|
n,
|
|
8069
8088
|
i,
|
|
8070
8089
|
c,
|
|
8071
|
-
|
|
8090
|
+
d,
|
|
8072
8091
|
h
|
|
8073
8092
|
));
|
|
8074
|
-
const
|
|
8093
|
+
const x = new De(n, c), w = new Xn(r.theme ?? "light", r.themeTokens), v = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w;
|
|
8075
8094
|
return new it(
|
|
8076
8095
|
t,
|
|
8077
8096
|
n,
|
|
@@ -8080,9 +8099,9 @@ function so(r, e) {
|
|
|
8080
8099
|
c,
|
|
8081
8100
|
l,
|
|
8082
8101
|
m,
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8102
|
+
d,
|
|
8103
|
+
v,
|
|
8104
|
+
x,
|
|
8086
8105
|
h
|
|
8087
8106
|
);
|
|
8088
8107
|
}
|