@nexus-cross/crossx-sdk-core 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts.map +1 -1
- package/dist/adapters/crypto/JoseCryptoAdapter.d.ts +2 -0
- package/dist/adapters/crypto/JoseCryptoAdapter.d.ts.map +1 -1
- package/dist/adapters/oauth/BrowserOAuthAdapter.d.ts.map +1 -1
- package/dist/adapters/storage/IndexedDBStorageAdapter.d.ts +7 -0
- package/dist/adapters/storage/IndexedDBStorageAdapter.d.ts.map +1 -1
- package/dist/adapters/transport/FetchTransportAdapter.d.ts +1 -0
- package/dist/adapters/transport/FetchTransportAdapter.d.ts.map +1 -1
- package/dist/adapters/wallet/RemoteWalletProviderAdapter.d.ts.map +1 -1
- package/dist/core/constants.d.ts +2 -2
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/ports/CryptoPort.d.ts +5 -0
- package/dist/core/ports/CryptoPort.d.ts.map +1 -1
- package/dist/core/ports/TransportPort.d.ts +2 -0
- package/dist/core/ports/TransportPort.d.ts.map +1 -1
- package/dist/core/services/JsonRpcService.d.ts +1 -0
- package/dist/core/services/JsonRpcService.d.ts.map +1 -1
- package/dist/core/services/TokenMemoryStore.d.ts +1 -0
- package/dist/core/services/TokenMemoryStore.d.ts.map +1 -1
- package/dist/core/types/internal.d.ts +5 -0
- package/dist/core/types/internal.d.ts.map +1 -1
- package/dist/core/usecases/SignInUseCase.d.ts +10 -0
- package/dist/core/usecases/SignInUseCase.d.ts.map +1 -1
- package/dist/core/usecases/SignOutUseCase.d.ts +3 -0
- package/dist/core/usecases/SignOutUseCase.d.ts.map +1 -1
- package/dist/crossx.global +117 -116
- package/dist/index.cjs +49 -48
- package/dist/index.js +915 -767
- package/dist/sdk/CROSSxSDK.d.ts +11 -0
- package/dist/sdk/CROSSxSDK.d.ts.map +1 -1
- package/dist/sdk/factory.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { decodeJwt as
|
|
1
|
+
var Ls = Object.defineProperty;
|
|
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 T = (r, e, s) => Ds(r, typeof e != "symbol" ? e + "" : e, s);
|
|
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.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", 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_CANCELLED = "PIN_CANCELLED", r.PIN_LOCKED = "PIN_LOCKED", r.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(p || {});
|
|
6
6
|
class g extends Error {
|
|
7
7
|
constructor(e, s, t) {
|
|
@@ -16,7 +16,7 @@ class g extends Error {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const Ve = {
|
|
20
20
|
// ─── CROSS ────────────────────────────────────────────
|
|
21
21
|
CROSS_MAINNET: {
|
|
22
22
|
caipId: "eip155:612055",
|
|
@@ -65,20 +65,20 @@ const Ke = {
|
|
|
65
65
|
rpcUrl: "https://saigon-testnet.roninchain.com/rpc",
|
|
66
66
|
testnet: !0
|
|
67
67
|
}
|
|
68
|
-
},
|
|
69
|
-
Object.entries(
|
|
70
|
-
),
|
|
71
|
-
Object.values(
|
|
68
|
+
}, to = Object.fromEntries(
|
|
69
|
+
Object.entries(Ve).map(([r, e]) => [r, e.caipId])
|
|
70
|
+
), Us = new Map(
|
|
71
|
+
Object.values(Ve).map((r) => [r.caipId, r])
|
|
72
72
|
);
|
|
73
73
|
new Map(
|
|
74
|
-
Object.values(
|
|
74
|
+
Object.values(Ve).map((r) => [r.chainId, r])
|
|
75
75
|
);
|
|
76
|
-
const
|
|
77
|
-
function
|
|
76
|
+
const Hs = { symbol: "", decimals: 18 };
|
|
77
|
+
function Je(r) {
|
|
78
78
|
var e;
|
|
79
|
-
return ((e =
|
|
79
|
+
return ((e = Us.get(r)) == null ? void 0 : e.nativeCurrency) ?? Hs;
|
|
80
80
|
}
|
|
81
|
-
class
|
|
81
|
+
class Fs {
|
|
82
82
|
constructor(e, s) {
|
|
83
83
|
this.sdk = e, this.chainId = s, this._listeners = /* @__PURE__ */ new Map();
|
|
84
84
|
}
|
|
@@ -167,30 +167,30 @@ class $s {
|
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
let
|
|
170
|
+
let Ee = null;
|
|
171
171
|
function vt(r) {
|
|
172
|
-
|
|
172
|
+
Ee = r;
|
|
173
173
|
}
|
|
174
174
|
const u = {
|
|
175
175
|
log(...r) {
|
|
176
|
-
if (
|
|
177
|
-
|
|
176
|
+
if (Ee) {
|
|
177
|
+
Ee.log(...r);
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
180
180
|
},
|
|
181
181
|
warn(...r) {
|
|
182
|
-
if (
|
|
183
|
-
|
|
182
|
+
if (Ee) {
|
|
183
|
+
Ee.warn(...r);
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
error(...r) {
|
|
188
|
-
if (
|
|
189
|
-
|
|
188
|
+
if (Ee) {
|
|
189
|
+
Ee.error(...r);
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
},
|
|
193
|
+
}, Gs = {
|
|
194
194
|
// ── 공통 버튼 ────────────────────────────────────────────────
|
|
195
195
|
confirm: "확인",
|
|
196
196
|
cancel: "취소",
|
|
@@ -255,7 +255,7 @@ const u = {
|
|
|
255
255
|
// ── PIN 잠금 안내 ─────────────────────────────────────────────
|
|
256
256
|
pinLocked_message: "잠금이 해제된 후 다시 시도해 주세요.",
|
|
257
257
|
pinLocked_availableFrom: "이용 가능 시간"
|
|
258
|
-
},
|
|
258
|
+
}, Qt = {
|
|
259
259
|
// ── Common buttons ───────────────────────────────────────────
|
|
260
260
|
confirm: "Confirm",
|
|
261
261
|
cancel: "Cancel",
|
|
@@ -320,17 +320,19 @@ const u = {
|
|
|
320
320
|
// ── PIN lock message ─────────────────────────────────────────
|
|
321
321
|
pinLocked_message: "Please try again after the lock expires.",
|
|
322
322
|
pinLocked_availableFrom: "Available from"
|
|
323
|
-
},
|
|
324
|
-
ko:
|
|
325
|
-
en:
|
|
323
|
+
}, Ws = {
|
|
324
|
+
ko: Gs,
|
|
325
|
+
en: Qt
|
|
326
326
|
};
|
|
327
327
|
function St(r = "en", e) {
|
|
328
|
-
return
|
|
328
|
+
return Ws[r] ?? Qt;
|
|
329
329
|
}
|
|
330
|
-
const
|
|
331
|
-
class
|
|
330
|
+
const Et = "crossx_access_token", It = "crossx_refresh_token", Tt = "crossx_user_info";
|
|
331
|
+
class qs {
|
|
332
332
|
constructor(e, s, t, n, o, i, a) {
|
|
333
|
-
this.config = e, this.storage = s, this.crypto = t, this.oauth = n, this.transport = o, this.walletProvider = i, this.tokenStore = a, this._refreshPromise = null;
|
|
333
|
+
this.config = e, this.storage = s, this.crypto = t, this.oauth = n, this.transport = o, this.walletProvider = i, this.tokenStore = a, this._refreshPromise = null, this._migrated = !1;
|
|
334
|
+
const c = e.projectId;
|
|
335
|
+
this.STORAGE_KEY_ACCESS_TOKEN = `crossx_${c}_access_token`, this.STORAGE_KEY_REFRESH_TOKEN = `crossx_${c}_refresh_token`, this.STORAGE_KEY_USER = `crossx_${c}_user_info`;
|
|
334
336
|
}
|
|
335
337
|
get useCookieAuth() {
|
|
336
338
|
return this.config.authMode === "cookie";
|
|
@@ -386,13 +388,13 @@ class Hs {
|
|
|
386
388
|
const b = await this.crypto.verifyJWT(w);
|
|
387
389
|
if (t = b.signatureVerified ?? !1, !b.valid)
|
|
388
390
|
throw u.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
|
|
389
|
-
const
|
|
391
|
+
const k = b.payload;
|
|
390
392
|
s = {
|
|
391
|
-
id:
|
|
392
|
-
email:
|
|
393
|
+
id: k.sub,
|
|
394
|
+
email: k.email,
|
|
393
395
|
signInProvider: S,
|
|
394
396
|
providerSub: y
|
|
395
|
-
}, this.tokenStore.set(w), this.useCookieAuth || (await this.storage.set(
|
|
397
|
+
}, this.tokenStore.set(w), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, w), E && this.config.secureStorageAvailable !== !1 ? await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, E) : E && u.warn("[CROSSx] 안전한 스토리지 미사용 — refresh_token 영속 저장을 건너뜁니다"));
|
|
396
398
|
} else {
|
|
397
399
|
const B = this.crypto.decodeJWT(x);
|
|
398
400
|
s = {
|
|
@@ -403,8 +405,8 @@ class Hs {
|
|
|
403
405
|
}, u.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
|
|
404
406
|
}
|
|
405
407
|
u.log("[CROSSx] 사용자 정보 — id:", s.id);
|
|
406
|
-
const
|
|
407
|
-
await this.storage.set(
|
|
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), u.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
|
|
408
410
|
} catch (c) {
|
|
409
411
|
return u.error("[CROSSx] SignIn 에러 (OAuth/토큰 교환 단계):", c), {
|
|
410
412
|
success: !1,
|
|
@@ -495,11 +497,12 @@ class Hs {
|
|
|
495
497
|
*/
|
|
496
498
|
async restoreSession() {
|
|
497
499
|
try {
|
|
500
|
+
await this.migrateStorageKeys();
|
|
498
501
|
const e = this.tokenStore.get();
|
|
499
502
|
if (e) {
|
|
500
503
|
const t = await this.crypto.verifyJWT(e);
|
|
501
504
|
if (t.valid) {
|
|
502
|
-
const n = await this.storage.get(
|
|
505
|
+
const n = await this.storage.get(this.STORAGE_KEY_USER);
|
|
503
506
|
if (n)
|
|
504
507
|
return u.log("[CROSSx] restoreSession — 메모리 토큰 유효, 세션 복원"), this.loadWallet(n, t.signatureVerified);
|
|
505
508
|
}
|
|
@@ -510,7 +513,7 @@ class Hs {
|
|
|
510
513
|
const t = await this.silentRefresh();
|
|
511
514
|
t && this.tokenStore.set(t);
|
|
512
515
|
} else {
|
|
513
|
-
const t = await this.storage.get(
|
|
516
|
+
const t = await this.storage.get(this.STORAGE_KEY_ACCESS_TOKEN), n = await this.storage.get(this.STORAGE_KEY_REFRESH_TOKEN);
|
|
514
517
|
if (u.log(
|
|
515
518
|
"[CROSSx] restoreSession — access_token:",
|
|
516
519
|
t ? "있음" : "없음",
|
|
@@ -522,7 +525,7 @@ class Hs {
|
|
|
522
525
|
const o = await this.silentRefresh(n);
|
|
523
526
|
u.log("[CROSSx] restoreSession — silentRefresh 결과:", o ? "토큰 발급 성공" : "토큰 없음"), o && this.tokenStore.set(o);
|
|
524
527
|
}
|
|
525
|
-
const s = await this.storage.get(
|
|
528
|
+
const s = await this.storage.get(this.STORAGE_KEY_USER);
|
|
526
529
|
if (u.log("[CROSSx] restoreSession — userInfo 조회:", s ? `있음 (id: ${s.id})` : "없음"), !s)
|
|
527
530
|
return null;
|
|
528
531
|
u.log("[CROSSx] restoreSession — silentRefresh 성공, 세션 복원 — userId:", s.id);
|
|
@@ -532,17 +535,12 @@ class Hs {
|
|
|
532
535
|
return u.warn("[CROSSx] restoreSession — 지갑 로드 실패 (세션은 유지):", t), { success: !0, user: s, tokenSignatureVerified: !1 };
|
|
533
536
|
}
|
|
534
537
|
} catch (e) {
|
|
535
|
-
return u.log("[CROSSx] restoreSession — 세션 복원 실패, 스토리지 정리:", e), this.tokenStore.clear(), this.useCookieAuth || await this.storage.remove(
|
|
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;
|
|
536
539
|
}
|
|
537
540
|
}
|
|
538
|
-
/**
|
|
539
|
-
* silent refresh (새 access_token 발급)
|
|
540
|
-
* 동시 호출 시 단일 요청으로 deduplicate.
|
|
541
|
-
* cookie 모드에서는 JWT가 body에 없을 수 있으므로 undefined 반환 가능.
|
|
542
|
-
*/
|
|
543
541
|
silentRefresh(e) {
|
|
544
|
-
return this._refreshPromise ? this._refreshPromise : (this._refreshPromise = this._doSilentRefresh(e).finally(() => {
|
|
545
|
-
this._refreshPromise = null;
|
|
542
|
+
return this._refreshPromise && this._lastRefreshToken === e ? this._refreshPromise : (this._lastRefreshToken = e, this._refreshPromise = this._doSilentRefresh(e).finally(() => {
|
|
543
|
+
this._refreshPromise = null, this._lastRefreshToken = void 0;
|
|
546
544
|
}), this._refreshPromise);
|
|
547
545
|
}
|
|
548
546
|
async _doSilentRefresh(e) {
|
|
@@ -569,9 +567,9 @@ class Hs {
|
|
|
569
567
|
if (!c)
|
|
570
568
|
throw new g(p.AUTH_FAILED, "토큰 자동 갱신 실패: 응답에 토큰이 없습니다");
|
|
571
569
|
if (this.tokenStore.set(c), !t) {
|
|
572
|
-
await this.storage.set(
|
|
570
|
+
await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, c);
|
|
573
571
|
const l = this.extractRefreshToken(a);
|
|
574
|
-
l && await this.storage.set(
|
|
572
|
+
l && this.config.secureStorageAvailable !== !1 && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, l);
|
|
575
573
|
}
|
|
576
574
|
return u.log("[CROSSx] silentRefresh 성공"), c;
|
|
577
575
|
}
|
|
@@ -603,7 +601,7 @@ class Hs {
|
|
|
603
601
|
u.log("[CROSSx] signInWithJWT — sub:", i.sub, "signatureVerified:", n), t = {
|
|
604
602
|
id: i.sub,
|
|
605
603
|
email: i.email
|
|
606
|
-
}, this.tokenStore.set(e), this.useCookieAuth || (await this.storage.set(
|
|
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 — 토큰 및 사용자 정보 저장 완료");
|
|
607
605
|
} catch (o) {
|
|
608
606
|
return u.error("[CROSSx] signInWithJWT 에러:", o), {
|
|
609
607
|
success: !1,
|
|
@@ -612,6 +610,26 @@ class Hs {
|
|
|
612
610
|
}
|
|
613
611
|
return this.loadWallet(t, n);
|
|
614
612
|
}
|
|
613
|
+
/**
|
|
614
|
+
* 레거시 고정 키(`crossx_*`) → projectId 스코프 키(`crossx_{pid}_*`) 마이그레이션.
|
|
615
|
+
* 최초 1회만 실행되며, 레거시 키의 데이터가 있고 새 키에 데이터가 없을 때만 이동.
|
|
616
|
+
*/
|
|
617
|
+
async migrateStorageKeys() {
|
|
618
|
+
if (!this._migrated) {
|
|
619
|
+
this._migrated = !0;
|
|
620
|
+
try {
|
|
621
|
+
const e = await this.storage.get(Tt);
|
|
622
|
+
if (!e || await this.storage.get(this.STORAGE_KEY_USER)) return;
|
|
623
|
+
await this.storage.set(this.STORAGE_KEY_USER, e);
|
|
624
|
+
const t = await this.storage.get(Et);
|
|
625
|
+
t && await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, t);
|
|
626
|
+
const n = await this.storage.get(It);
|
|
627
|
+
n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(Tt), await this.storage.remove(Et), await this.storage.remove(It), u.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
|
|
628
|
+
} catch (e) {
|
|
629
|
+
u.warn("[CROSSx] 스토리지 키 마이그레이션 실패:", e);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
615
633
|
async loadWallet(e, s) {
|
|
616
634
|
let t, n = !1;
|
|
617
635
|
try {
|
|
@@ -641,13 +659,14 @@ class Hs {
|
|
|
641
659
|
return u.log("[CROSSx] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
|
|
642
660
|
}
|
|
643
661
|
}
|
|
644
|
-
|
|
645
|
-
class qs {
|
|
662
|
+
class Ks {
|
|
646
663
|
constructor(e, s, t) {
|
|
647
664
|
this.config = e, this.storage = s, this.tokenStore = t;
|
|
665
|
+
const n = e.projectId;
|
|
666
|
+
this.STORAGE_KEY_ACCESS_TOKEN = `crossx_${n}_access_token`, this.STORAGE_KEY_REFRESH_TOKEN = `crossx_${n}_refresh_token`, this.STORAGE_KEY_USER = `crossx_${n}_user_info`;
|
|
648
667
|
}
|
|
649
668
|
async execute() {
|
|
650
|
-
this.tokenStore.clear(), this.config.authMode !== "cookie" && (await this.storage.remove(
|
|
669
|
+
this.tokenStore.clear(), this.config.authMode !== "cookie" && (await this.storage.remove(this.STORAGE_KEY_ACCESS_TOKEN), await this.storage.remove(this.STORAGE_KEY_REFRESH_TOKEN)), await this.storage.remove(this.STORAGE_KEY_USER), await this.storage.clear();
|
|
651
670
|
}
|
|
652
671
|
}
|
|
653
672
|
class Vs {
|
|
@@ -667,7 +686,7 @@ class Vs {
|
|
|
667
686
|
};
|
|
668
687
|
}
|
|
669
688
|
}
|
|
670
|
-
class
|
|
689
|
+
class es {
|
|
671
690
|
constructor() {
|
|
672
691
|
this.encryptedBytes = null, this.xorKey = null;
|
|
673
692
|
}
|
|
@@ -710,7 +729,7 @@ class Xt {
|
|
|
710
729
|
}
|
|
711
730
|
class zs {
|
|
712
731
|
constructor(e, s) {
|
|
713
|
-
this.chainRegistry = e, this.transport = s;
|
|
732
|
+
this.chainRegistry = e, this.transport = s, this._nextId = 1;
|
|
714
733
|
}
|
|
715
734
|
/**
|
|
716
735
|
* JSON-RPC 호출
|
|
@@ -725,7 +744,7 @@ class zs {
|
|
|
725
744
|
jsonrpc: "2.0",
|
|
726
745
|
method: e,
|
|
727
746
|
params: s,
|
|
728
|
-
id:
|
|
747
|
+
id: this._nextId++
|
|
729
748
|
}, a = (await this.transport.request({
|
|
730
749
|
url: n.rpcUrl,
|
|
731
750
|
method: "POST",
|
|
@@ -740,7 +759,7 @@ class zs {
|
|
|
740
759
|
return a == null ? void 0 : a.result;
|
|
741
760
|
}
|
|
742
761
|
}
|
|
743
|
-
class
|
|
762
|
+
class js {
|
|
744
763
|
constructor() {
|
|
745
764
|
this.listeners = /* @__PURE__ */ new Map();
|
|
746
765
|
}
|
|
@@ -763,7 +782,7 @@ class Ks {
|
|
|
763
782
|
this.listeners.clear();
|
|
764
783
|
}
|
|
765
784
|
}
|
|
766
|
-
const
|
|
785
|
+
const Ge = {
|
|
767
786
|
// TODO(v2.0.0-BEFORE-RELEASE): 아래 블록으로 교체
|
|
768
787
|
// production: {
|
|
769
788
|
// oauthServiceUrl: 'https://cross-wallet-oauth.crosstoken.io',
|
|
@@ -786,24 +805,24 @@ const We = {
|
|
|
786
805
|
walletGatewayUrl: "https://dev-embedded-wallet-gateway.crosstoken.io/api/v1"
|
|
787
806
|
}
|
|
788
807
|
};
|
|
789
|
-
function
|
|
808
|
+
function Ys(r) {
|
|
790
809
|
const e = r.environment;
|
|
791
|
-
return e && e in
|
|
810
|
+
return e && e in Ge ? Ge[e] : null;
|
|
792
811
|
}
|
|
793
|
-
function
|
|
812
|
+
function Js() {
|
|
794
813
|
try {
|
|
795
814
|
if (typeof __CROSSX_CONFIG__ < "u") {
|
|
796
|
-
const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e =
|
|
815
|
+
const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e = Ys(r);
|
|
797
816
|
if (e) return e;
|
|
798
817
|
}
|
|
799
818
|
} catch {
|
|
800
819
|
}
|
|
801
|
-
return
|
|
820
|
+
return Ge.production;
|
|
802
821
|
}
|
|
803
|
-
const
|
|
822
|
+
const Zs = 2e3, At = 6e4, Xs = 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 {
|
|
804
823
|
constructor(e, s, t, n, o, i, a, c, l, d, h) {
|
|
805
824
|
var m;
|
|
806
|
-
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
|
|
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(
|
|
807
826
|
this.internalConfig,
|
|
808
827
|
t,
|
|
809
828
|
n,
|
|
@@ -811,7 +830,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
811
830
|
o,
|
|
812
831
|
a,
|
|
813
832
|
c
|
|
814
|
-
), this.signOutUseCase = new
|
|
833
|
+
), this.signOutUseCase = new Ks(this.internalConfig, t, c), this.migrateWalletUseCase = new Vs(t, a), (m = a.setOnUnauthorized) == null || m.call(a, () => this.forceLogout());
|
|
815
834
|
}
|
|
816
835
|
get config() {
|
|
817
836
|
return this._config;
|
|
@@ -836,24 +855,25 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
836
855
|
}), this._initPromise);
|
|
837
856
|
}
|
|
838
857
|
async _doInitialize(e) {
|
|
839
|
-
|
|
858
|
+
var s, t;
|
|
859
|
+
u.log("[CROSSx SDK] v1.2.6 초기화 중..."), this.confirmation.setMessages(St(this._config.locale));
|
|
840
860
|
try {
|
|
841
|
-
const
|
|
842
|
-
this.internalConfig.oauthServiceUrl =
|
|
843
|
-
const
|
|
844
|
-
if (
|
|
845
|
-
this.applyAuthResult(
|
|
861
|
+
const n = Js();
|
|
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`);
|
|
863
|
+
const o = await this.signInUseCase.restoreSession();
|
|
864
|
+
if (o != null && o.success) {
|
|
865
|
+
this.applyAuthResult(o);
|
|
846
866
|
try {
|
|
847
867
|
await this.loadWalletAfterAuth(e == null ? void 0 : e.preferredWalletIndex);
|
|
848
|
-
} catch (
|
|
849
|
-
if (!(
|
|
850
|
-
throw
|
|
868
|
+
} catch (i) {
|
|
869
|
+
if (!(i instanceof g && i.code === p.PIN_CANCELLED))
|
|
870
|
+
throw i;
|
|
851
871
|
u.log("[CROSSx] initialize: 비밀번호 입력 취소 — 지갑 미로드 상태로 계속");
|
|
852
872
|
}
|
|
853
873
|
}
|
|
854
|
-
return this.initialized = !0, this.emit("initialized", { restored: !!(
|
|
855
|
-
} catch (
|
|
856
|
-
throw new g(p.AUTH_NOT_INITIALIZED, "SDK 초기화에 실패했습니다",
|
|
874
|
+
return this.initialized = !0, this.emit("initialized", { restored: !!(o != null && o.success) }), o ?? null;
|
|
875
|
+
} catch (n) {
|
|
876
|
+
throw new g(p.AUTH_NOT_INITIALIZED, "SDK 초기화에 실패했습니다", n);
|
|
857
877
|
}
|
|
858
878
|
}
|
|
859
879
|
async signIn(e) {
|
|
@@ -948,6 +968,26 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
948
968
|
isAuthenticated() {
|
|
949
969
|
return this.authenticated;
|
|
950
970
|
}
|
|
971
|
+
/**
|
|
972
|
+
* SDK 초기화 완료까지 대기합니다.
|
|
973
|
+
*
|
|
974
|
+
* wagmi 등 외부 프레임워크가 connector.setup()을 await하지 않아
|
|
975
|
+
* 초기화 도중 isAuthenticated()가 false를 반환하는 race condition을 방지합니다.
|
|
976
|
+
*
|
|
977
|
+
* - 이미 초기화 완료: 즉시 `true`
|
|
978
|
+
* - 초기화 진행 중(`_initPromise` 존재): 완료 대기 후 결과 반환
|
|
979
|
+
* - 초기화 미시작: 즉시 `false`
|
|
980
|
+
*/
|
|
981
|
+
async whenReady() {
|
|
982
|
+
if (this.initialized) return !0;
|
|
983
|
+
if (this._initPromise)
|
|
984
|
+
try {
|
|
985
|
+
return await this._initPromise, this.initialized;
|
|
986
|
+
} catch {
|
|
987
|
+
return !1;
|
|
988
|
+
}
|
|
989
|
+
return !1;
|
|
990
|
+
}
|
|
951
991
|
/** 현재 지갑 주소 (동기) — useSyncExternalStore 등에서 사용 */
|
|
952
992
|
get currentAddress() {
|
|
953
993
|
return this.address;
|
|
@@ -1402,7 +1442,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1402
1442
|
throw new g(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1403
1443
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
1404
1444
|
n.from || (n.from = (await this.resolveAddress(t == null ? void 0 : t.index)).address);
|
|
1405
|
-
const o =
|
|
1445
|
+
const o = Je(e);
|
|
1406
1446
|
if (!await this.confirmation.requestConfirmation({
|
|
1407
1447
|
type: "sign",
|
|
1408
1448
|
chainId: e,
|
|
@@ -1457,7 +1497,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1457
1497
|
throw new g(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1458
1498
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
1459
1499
|
n.from || (n.from = (await this.resolveAddress(t == null ? void 0 : t.index)).address);
|
|
1460
|
-
const o =
|
|
1500
|
+
const o = Je(e);
|
|
1461
1501
|
if (!await this.confirmation.requestConfirmation({
|
|
1462
1502
|
type: "send",
|
|
1463
1503
|
chainId: e,
|
|
@@ -1524,7 +1564,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1524
1564
|
* @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
|
|
1525
1565
|
*/
|
|
1526
1566
|
async waitForTxAndGetReceipt(e, s, t = {}) {
|
|
1527
|
-
const n = t.intervalMs ??
|
|
1567
|
+
const n = t.intervalMs ?? Xs, o = Qs, i = t.timeoutMs ?? At, a = Date.now() + i;
|
|
1528
1568
|
let c = n;
|
|
1529
1569
|
for (; Date.now() < a; ) {
|
|
1530
1570
|
const l = await this.getTransactionReceipt(e, s);
|
|
@@ -1553,19 +1593,19 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1553
1593
|
*/
|
|
1554
1594
|
async sendTransactionWithWaitForReceipt(e, s, t = {}) {
|
|
1555
1595
|
var E, y;
|
|
1556
|
-
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((E = this._config.receiptPolling) == null ? void 0 : E.intervalMs) ??
|
|
1596
|
+
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((E = this._config.receiptPolling) == null ? void 0 : E.intervalMs) ?? Zs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? At, d = Je(e), h = s.from ?? "";
|
|
1557
1597
|
let m, x;
|
|
1558
1598
|
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((S) => {
|
|
1559
1599
|
m = S;
|
|
1560
|
-
const
|
|
1600
|
+
const C = BigInt(S.gasUsed) * BigInt(S.effectiveGasPrice), B = s.value ? BigInt(s.value) : 0n, b = re.formatTxAmount(s.value, d.symbol, d.decimals), k = re.formatTxAmount("0x" + C.toString(16), d.symbol, d.decimals), P = re.formatTxAmount("0x" + (B + C).toString(16), d.symbol, d.decimals);
|
|
1561
1601
|
return {
|
|
1562
1602
|
chainId: e,
|
|
1563
1603
|
txHash: a,
|
|
1564
1604
|
from: S.from,
|
|
1565
1605
|
to: S.to ?? s.to,
|
|
1566
1606
|
amount: b,
|
|
1567
|
-
fees:
|
|
1568
|
-
total:
|
|
1607
|
+
fees: k,
|
|
1608
|
+
total: P,
|
|
1569
1609
|
nativeSymbol: d.symbol,
|
|
1570
1610
|
status: S.status === "0x1" ? "success" : "reverted"
|
|
1571
1611
|
};
|
|
@@ -1764,7 +1804,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1764
1804
|
try {
|
|
1765
1805
|
const s = BigInt(e);
|
|
1766
1806
|
if (s === 0n) return "0";
|
|
1767
|
-
const t = 10n ** BigInt(
|
|
1807
|
+
const t = 10n ** BigInt(Nt), n = s / t, i = (s % t).toString().padStart(Nt, "0").replace(/0+$/, "").slice(0, Pt);
|
|
1768
1808
|
return i ? `${n}.${i}` : `${n}`;
|
|
1769
1809
|
} catch {
|
|
1770
1810
|
return "?";
|
|
@@ -1789,7 +1829,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1789
1829
|
* const client = createWalletClient({ transport: custom(provider) });
|
|
1790
1830
|
*/
|
|
1791
1831
|
getProvider(e) {
|
|
1792
|
-
return this.ensureAuthenticated(), new
|
|
1832
|
+
return this.ensureAuthenticated(), new Fs(this, e);
|
|
1793
1833
|
}
|
|
1794
1834
|
/**
|
|
1795
1835
|
* 범용 JSON-RPC 요청 — 노드에 직접 연결.
|
|
@@ -1823,7 +1863,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1823
1863
|
try {
|
|
1824
1864
|
const n = BigInt(e);
|
|
1825
1865
|
if (n === 0n) return;
|
|
1826
|
-
const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0,
|
|
1866
|
+
const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0, Pt).replace(/0+$/, "");
|
|
1827
1867
|
return `${c ? `${i}.${c}` : `${i}`} ${s}`;
|
|
1828
1868
|
} catch {
|
|
1829
1869
|
return;
|
|
@@ -1923,12 +1963,12 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1923
1963
|
u.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
|
|
1924
1964
|
const l = await this.getBaseFeePerGas(s);
|
|
1925
1965
|
if (l) {
|
|
1926
|
-
const d =
|
|
1966
|
+
const d = Rt;
|
|
1927
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");
|
|
1928
1968
|
} else
|
|
1929
|
-
c.gasPrice =
|
|
1969
|
+
c.gasPrice = er, u.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
|
|
1930
1970
|
}
|
|
1931
|
-
return !i && a && (c.maxPriorityFeePerGas =
|
|
1971
|
+
return !i && a && (c.maxPriorityFeePerGas = Rt, u.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
|
|
1932
1972
|
}
|
|
1933
1973
|
/**
|
|
1934
1974
|
* EIP-712 signTypedData 호출 시 chainId와 typedData.domain.chainId 정합성 검증.
|
|
@@ -1975,10 +2015,10 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
1975
2015
|
const s = e.startsWith("0x") ? e.slice(2) : e;
|
|
1976
2016
|
if (!/^[0-9a-fA-F]+$/.test(s))
|
|
1977
2017
|
throw new g(p.SIGNATURE_FAILED, "유효하지 않은 서명: 올바른 hex 문자열이 아닙니다");
|
|
1978
|
-
if (s.length !==
|
|
2018
|
+
if (s.length !== kt)
|
|
1979
2019
|
throw new g(
|
|
1980
2020
|
p.SIGNATURE_FAILED,
|
|
1981
|
-
`서명 길이가 유효하지 않습니다: ${
|
|
2021
|
+
`서명 길이가 유효하지 않습니다: ${kt} hex 문자(65 바이트) 예상, 현재 ${s.length}`
|
|
1982
2022
|
);
|
|
1983
2023
|
}
|
|
1984
2024
|
/** RLP-encoded signed transaction 형식 검증 */
|
|
@@ -2255,7 +2295,7 @@ const Js = 2e3, It = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", Et = "0x3B9ACA0
|
|
|
2255
2295
|
};
|
|
2256
2296
|
re.OFFCHAIN_CHAIN_ID = "0";
|
|
2257
2297
|
let it = re;
|
|
2258
|
-
class
|
|
2298
|
+
class rr {
|
|
2259
2299
|
constructor() {
|
|
2260
2300
|
this.prefix = "crossx_";
|
|
2261
2301
|
}
|
|
@@ -2292,21 +2332,21 @@ class sr {
|
|
|
2292
2332
|
}
|
|
2293
2333
|
}
|
|
2294
2334
|
}
|
|
2295
|
-
const
|
|
2296
|
-
class
|
|
2297
|
-
constructor() {
|
|
2298
|
-
this.db = null, this.cryptoKey = null, this.initPromise = null
|
|
2335
|
+
const Ze = "crossx-sdk", nr = 1, de = "data", Se = "keys", $e = "aes-primary", or = 12;
|
|
2336
|
+
class Ot {
|
|
2337
|
+
constructor(e) {
|
|
2338
|
+
this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
|
|
2299
2339
|
}
|
|
2300
2340
|
async ensureReady() {
|
|
2301
2341
|
this.db && this.cryptoKey || (this.initPromise || (this.initPromise = this.init()), await this.initPromise);
|
|
2302
2342
|
}
|
|
2303
|
-
openDB() {
|
|
2304
|
-
return new Promise((
|
|
2305
|
-
const
|
|
2306
|
-
|
|
2307
|
-
const
|
|
2308
|
-
|
|
2309
|
-
},
|
|
2343
|
+
openDB(e = this.dbName) {
|
|
2344
|
+
return new Promise((s, t) => {
|
|
2345
|
+
const n = indexedDB.open(e, nr);
|
|
2346
|
+
n.onupgradeneeded = () => {
|
|
2347
|
+
const o = n.result;
|
|
2348
|
+
o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(Se) || o.createObjectStore(Se);
|
|
2349
|
+
}, n.onsuccess = () => s(n.result), n.onerror = () => t(n.error);
|
|
2310
2350
|
});
|
|
2311
2351
|
}
|
|
2312
2352
|
idbGet(e, s) {
|
|
@@ -2335,16 +2375,49 @@ class Nt {
|
|
|
2335
2375
|
}
|
|
2336
2376
|
async init() {
|
|
2337
2377
|
this.db = await this.openDB();
|
|
2338
|
-
const e = await this.idbGet(
|
|
2378
|
+
const e = await this.idbGet(Se, $e);
|
|
2339
2379
|
if (e) {
|
|
2340
2380
|
this.cryptoKey = e;
|
|
2341
2381
|
return;
|
|
2342
2382
|
}
|
|
2383
|
+
const s = await this.migrateFromLegacyDB();
|
|
2384
|
+
if (s) {
|
|
2385
|
+
this.cryptoKey = s;
|
|
2386
|
+
return;
|
|
2387
|
+
}
|
|
2343
2388
|
this.cryptoKey = await crypto.subtle.generateKey(
|
|
2344
2389
|
{ name: "AES-GCM", length: 256 },
|
|
2345
2390
|
!1,
|
|
2346
2391
|
["encrypt", "decrypt"]
|
|
2347
|
-
), await this.idbPut(
|
|
2392
|
+
), await this.idbPut(Se, $e, this.cryptoKey);
|
|
2393
|
+
}
|
|
2394
|
+
/**
|
|
2395
|
+
* 레거시 DB('crossx-sdk')에서 projectId 스코프 DB로 암호키·데이터 마이그레이션.
|
|
2396
|
+
* 마이그레이션 성공 시 레거시 DB 삭제.
|
|
2397
|
+
*/
|
|
2398
|
+
async migrateFromLegacyDB() {
|
|
2399
|
+
if (this.dbName === Ze) return null;
|
|
2400
|
+
try {
|
|
2401
|
+
const e = await this.openDB(Ze), s = e.transaction([Se, de], "readonly"), t = s.objectStore(Se).get($e), n = await new Promise((l, d) => {
|
|
2402
|
+
t.onsuccess = () => l(t.result), t.onerror = () => d(t.error);
|
|
2403
|
+
});
|
|
2404
|
+
if (!n)
|
|
2405
|
+
return e.close(), null;
|
|
2406
|
+
const o = s.objectStore(de).getAll(), i = s.objectStore(de).getAllKeys(), [a, c] = await Promise.all([
|
|
2407
|
+
new Promise((l, d) => {
|
|
2408
|
+
o.onsuccess = () => l(o.result), o.onerror = () => d(o.error);
|
|
2409
|
+
}),
|
|
2410
|
+
new Promise((l, d) => {
|
|
2411
|
+
i.onsuccess = () => l(i.result), i.onerror = () => d(i.error);
|
|
2412
|
+
})
|
|
2413
|
+
]);
|
|
2414
|
+
e.close(), await this.idbPut(Se, $e, n);
|
|
2415
|
+
for (let l = 0; l < c.length; l++)
|
|
2416
|
+
await this.idbPut(de, String(c[l]), a[l]);
|
|
2417
|
+
return indexedDB.deleteDatabase(Ze), u.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), n;
|
|
2418
|
+
} catch (e) {
|
|
2419
|
+
return u.warn("[CROSSx] IndexedDB 레거시 DB 마이그레이션 실패:", e), null;
|
|
2420
|
+
}
|
|
2348
2421
|
}
|
|
2349
2422
|
async encrypt(e) {
|
|
2350
2423
|
const s = new Uint8Array(or);
|
|
@@ -2368,7 +2441,7 @@ class Nt {
|
|
|
2368
2441
|
try {
|
|
2369
2442
|
await this.ensureReady();
|
|
2370
2443
|
const t = JSON.stringify(s), n = await this.encrypt(t);
|
|
2371
|
-
await this.idbPut(
|
|
2444
|
+
await this.idbPut(de, e, n);
|
|
2372
2445
|
} catch (t) {
|
|
2373
2446
|
throw u.error("[CROSSx] IndexedDB set error:", t), t;
|
|
2374
2447
|
}
|
|
@@ -2376,7 +2449,7 @@ class Nt {
|
|
|
2376
2449
|
async get(e) {
|
|
2377
2450
|
try {
|
|
2378
2451
|
await this.ensureReady();
|
|
2379
|
-
const s = await this.idbGet(
|
|
2452
|
+
const s = await this.idbGet(de, e);
|
|
2380
2453
|
if (!s) return null;
|
|
2381
2454
|
const t = await this.decrypt(s);
|
|
2382
2455
|
return JSON.parse(t);
|
|
@@ -2386,14 +2459,14 @@ class Nt {
|
|
|
2386
2459
|
}
|
|
2387
2460
|
async remove(e) {
|
|
2388
2461
|
try {
|
|
2389
|
-
await this.ensureReady(), await this.idbDelete(
|
|
2462
|
+
await this.ensureReady(), await this.idbDelete(de, e);
|
|
2390
2463
|
} catch (s) {
|
|
2391
2464
|
throw u.error("[CROSSx] IndexedDB remove error:", s), s;
|
|
2392
2465
|
}
|
|
2393
2466
|
}
|
|
2394
2467
|
async clear() {
|
|
2395
2468
|
try {
|
|
2396
|
-
await this.ensureReady(), await this.idbClear(
|
|
2469
|
+
await this.ensureReady(), await this.idbClear(de);
|
|
2397
2470
|
} catch (e) {
|
|
2398
2471
|
throw u.error("[CROSSx] IndexedDB clear error:", e), e;
|
|
2399
2472
|
}
|
|
@@ -2409,13 +2482,13 @@ class Nt {
|
|
|
2409
2482
|
function ut(r) {
|
|
2410
2483
|
return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
|
|
2411
2484
|
}
|
|
2412
|
-
function
|
|
2485
|
+
function ge(r, e = "") {
|
|
2413
2486
|
if (!Number.isSafeInteger(r) || r < 0) {
|
|
2414
2487
|
const s = e && `"${e}" `;
|
|
2415
2488
|
throw new Error(`${s}expected integer >= 0, got ${r}`);
|
|
2416
2489
|
}
|
|
2417
2490
|
}
|
|
2418
|
-
function
|
|
2491
|
+
function V(r, e, s = "") {
|
|
2419
2492
|
const t = ut(r), n = r == null ? void 0 : r.length, o = e !== void 0;
|
|
2420
2493
|
if (!t || o && n !== e) {
|
|
2421
2494
|
const i = s && `"${s}" `, a = o ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
|
|
@@ -2423,19 +2496,19 @@ function z(r, e, s = "") {
|
|
|
2423
2496
|
}
|
|
2424
2497
|
return r;
|
|
2425
2498
|
}
|
|
2426
|
-
function
|
|
2499
|
+
function ts(r) {
|
|
2427
2500
|
if (typeof r != "function" || typeof r.create != "function")
|
|
2428
2501
|
throw new Error("Hash must wrapped by utils.createHasher");
|
|
2429
|
-
|
|
2502
|
+
ge(r.outputLen), ge(r.blockLen);
|
|
2430
2503
|
}
|
|
2431
|
-
function
|
|
2504
|
+
function ke(r, e = !0) {
|
|
2432
2505
|
if (r.destroyed)
|
|
2433
2506
|
throw new Error("Hash instance has been destroyed");
|
|
2434
2507
|
if (e && r.finished)
|
|
2435
2508
|
throw new Error("Hash#digest() has already been called");
|
|
2436
2509
|
}
|
|
2437
|
-
function
|
|
2438
|
-
|
|
2510
|
+
function ss(r, e) {
|
|
2511
|
+
V(r, void 0, "digestInto() output");
|
|
2439
2512
|
const s = e.outputLen;
|
|
2440
2513
|
if (r.length < s)
|
|
2441
2514
|
throw new Error('"digestInto() output" expected to be of length >=' + s);
|
|
@@ -2443,14 +2516,14 @@ function es(r, e) {
|
|
|
2443
2516
|
function ir(r) {
|
|
2444
2517
|
return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
|
|
2445
2518
|
}
|
|
2446
|
-
function
|
|
2519
|
+
function Pe(...r) {
|
|
2447
2520
|
for (let e = 0; e < r.length; e++)
|
|
2448
2521
|
r[e].fill(0);
|
|
2449
2522
|
}
|
|
2450
2523
|
function Xe(r) {
|
|
2451
2524
|
return new DataView(r.buffer, r.byteOffset, r.byteLength);
|
|
2452
2525
|
}
|
|
2453
|
-
function
|
|
2526
|
+
function ue(r, e) {
|
|
2454
2527
|
return r << 32 - e | r >>> e;
|
|
2455
2528
|
}
|
|
2456
2529
|
const ar = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
@@ -2462,35 +2535,35 @@ function lr(r) {
|
|
|
2462
2535
|
r[e] = cr(r[e]);
|
|
2463
2536
|
return r;
|
|
2464
2537
|
}
|
|
2465
|
-
const
|
|
2538
|
+
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"));
|
|
2466
2539
|
function Me(r) {
|
|
2467
|
-
if (
|
|
2540
|
+
if (V(r), rs)
|
|
2468
2541
|
return r.toHex();
|
|
2469
2542
|
let e = "";
|
|
2470
2543
|
for (let s = 0; s < r.length; s++)
|
|
2471
2544
|
e += dr[r[s]];
|
|
2472
2545
|
return e;
|
|
2473
2546
|
}
|
|
2474
|
-
const
|
|
2475
|
-
function
|
|
2476
|
-
if (r >=
|
|
2477
|
-
return r -
|
|
2478
|
-
if (r >=
|
|
2479
|
-
return r - (
|
|
2480
|
-
if (r >=
|
|
2481
|
-
return r - (
|
|
2482
|
-
}
|
|
2483
|
-
function
|
|
2547
|
+
const fe = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
2548
|
+
function Lt(r) {
|
|
2549
|
+
if (r >= fe._0 && r <= fe._9)
|
|
2550
|
+
return r - fe._0;
|
|
2551
|
+
if (r >= fe.A && r <= fe.F)
|
|
2552
|
+
return r - (fe.A - 10);
|
|
2553
|
+
if (r >= fe.a && r <= fe.f)
|
|
2554
|
+
return r - (fe.a - 10);
|
|
2555
|
+
}
|
|
2556
|
+
function We(r) {
|
|
2484
2557
|
if (typeof r != "string")
|
|
2485
2558
|
throw new Error("hex string expected, got " + typeof r);
|
|
2486
|
-
if (
|
|
2559
|
+
if (rs)
|
|
2487
2560
|
return Uint8Array.fromHex(r);
|
|
2488
2561
|
const e = r.length, s = e / 2;
|
|
2489
2562
|
if (e % 2)
|
|
2490
2563
|
throw new Error("hex string expected, got unpadded hex of length " + e);
|
|
2491
2564
|
const t = new Uint8Array(s);
|
|
2492
2565
|
for (let n = 0, o = 0; n < s; n++, o += 2) {
|
|
2493
|
-
const i =
|
|
2566
|
+
const i = Lt(r.charCodeAt(o)), a = Lt(r.charCodeAt(o + 1));
|
|
2494
2567
|
if (i === void 0 || a === void 0) {
|
|
2495
2568
|
const c = r[o] + r[o + 1];
|
|
2496
2569
|
throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + o);
|
|
@@ -2499,11 +2572,11 @@ function qe(r) {
|
|
|
2499
2572
|
}
|
|
2500
2573
|
return t;
|
|
2501
2574
|
}
|
|
2502
|
-
function
|
|
2575
|
+
function ve(...r) {
|
|
2503
2576
|
let e = 0;
|
|
2504
2577
|
for (let t = 0; t < r.length; t++) {
|
|
2505
2578
|
const n = r[t];
|
|
2506
|
-
|
|
2579
|
+
V(n), e += n.length;
|
|
2507
2580
|
}
|
|
2508
2581
|
const s = new Uint8Array(e);
|
|
2509
2582
|
for (let t = 0, n = 0; t < r.length; t++) {
|
|
@@ -2512,11 +2585,11 @@ function we(...r) {
|
|
|
2512
2585
|
}
|
|
2513
2586
|
return s;
|
|
2514
2587
|
}
|
|
2515
|
-
function
|
|
2588
|
+
function ns(r, e = {}) {
|
|
2516
2589
|
const s = (n, o) => r(o).update(n).digest(), t = r(void 0);
|
|
2517
2590
|
return s.outputLen = t.outputLen, s.blockLen = t.blockLen, s.create = (n) => r(n), Object.assign(s, e), Object.freeze(s);
|
|
2518
2591
|
}
|
|
2519
|
-
function
|
|
2592
|
+
function os(r = 32) {
|
|
2520
2593
|
const e = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
2521
2594
|
if (typeof (e == null ? void 0 : e.getRandomValues) != "function")
|
|
2522
2595
|
throw new Error("crypto.getRandomValues must be defined");
|
|
@@ -2533,21 +2606,21 @@ function pr(r, e, s) {
|
|
|
2533
2606
|
}
|
|
2534
2607
|
class fr {
|
|
2535
2608
|
constructor(e, s, t, n) {
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2609
|
+
T(this, "blockLen");
|
|
2610
|
+
T(this, "outputLen");
|
|
2611
|
+
T(this, "padOffset");
|
|
2612
|
+
T(this, "isLE");
|
|
2540
2613
|
// For partial updates less than block size
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2614
|
+
T(this, "buffer");
|
|
2615
|
+
T(this, "view");
|
|
2616
|
+
T(this, "finished", !1);
|
|
2617
|
+
T(this, "length", 0);
|
|
2618
|
+
T(this, "pos", 0);
|
|
2619
|
+
T(this, "destroyed", !1);
|
|
2547
2620
|
this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Xe(this.buffer);
|
|
2548
2621
|
}
|
|
2549
2622
|
update(e) {
|
|
2550
|
-
|
|
2623
|
+
ke(this), V(e);
|
|
2551
2624
|
const { view: s, buffer: t, blockLen: n } = this, o = e.length;
|
|
2552
2625
|
for (let i = 0; i < o; ) {
|
|
2553
2626
|
const a = Math.min(n - this.pos, o - i);
|
|
@@ -2562,10 +2635,10 @@ class fr {
|
|
|
2562
2635
|
return this.length += e.length, this.roundClean(), this;
|
|
2563
2636
|
}
|
|
2564
2637
|
digestInto(e) {
|
|
2565
|
-
|
|
2638
|
+
ke(this), ss(e, this), this.finished = !0;
|
|
2566
2639
|
const { buffer: s, view: t, blockLen: n, isLE: o } = this;
|
|
2567
2640
|
let { pos: i } = this;
|
|
2568
|
-
s[i++] = 128,
|
|
2641
|
+
s[i++] = 128, Pe(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
|
|
2569
2642
|
for (let h = i; h < n; h++)
|
|
2570
2643
|
s[h] = 0;
|
|
2571
2644
|
t.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(t, 0);
|
|
@@ -2593,7 +2666,7 @@ class fr {
|
|
|
2593
2666
|
return this._cloneInto();
|
|
2594
2667
|
}
|
|
2595
2668
|
}
|
|
2596
|
-
const
|
|
2669
|
+
const me = /* @__PURE__ */ Uint32Array.from([
|
|
2597
2670
|
1779033703,
|
|
2598
2671
|
3144134277,
|
|
2599
2672
|
1013904242,
|
|
@@ -2602,9 +2675,9 @@ const xe = /* @__PURE__ */ Uint32Array.from([
|
|
|
2602
2675
|
2600822924,
|
|
2603
2676
|
528734635,
|
|
2604
2677
|
1541459225
|
|
2605
|
-
]),
|
|
2678
|
+
]), Be = /* @__PURE__ */ BigInt(2 ** 32 - 1), Dt = /* @__PURE__ */ BigInt(32);
|
|
2606
2679
|
function _r(r, e = !1) {
|
|
2607
|
-
return e ? { h: Number(r &
|
|
2680
|
+
return e ? { h: Number(r & Be), l: Number(r >> Dt & Be) } : { h: Number(r >> Dt & Be) | 0, l: Number(r & Be) | 0 };
|
|
2608
2681
|
}
|
|
2609
2682
|
function xr(r, e = !1) {
|
|
2610
2683
|
const s = r.length;
|
|
@@ -2680,7 +2753,7 @@ const gr = (r, e, s) => r << s | e >>> 32 - s, mr = (r, e, s) => e << s | r >>>
|
|
|
2680
2753
|
2756734187,
|
|
2681
2754
|
3204031479,
|
|
2682
2755
|
3329325298
|
|
2683
|
-
]),
|
|
2756
|
+
]), we = /* @__PURE__ */ new Uint32Array(64);
|
|
2684
2757
|
class vr extends fr {
|
|
2685
2758
|
constructor(e) {
|
|
2686
2759
|
super(64, e, 8, !1);
|
|
@@ -2695,23 +2768,23 @@ class vr extends fr {
|
|
|
2695
2768
|
}
|
|
2696
2769
|
process(e, s) {
|
|
2697
2770
|
for (let h = 0; h < 16; h++, s += 4)
|
|
2698
|
-
|
|
2771
|
+
we[h] = e.getUint32(s, !1);
|
|
2699
2772
|
for (let h = 16; h < 64; h++) {
|
|
2700
|
-
const m =
|
|
2701
|
-
|
|
2773
|
+
const m = we[h - 15], x = we[h - 2], w = ue(m, 7) ^ ue(m, 18) ^ m >>> 3, E = ue(x, 17) ^ ue(x, 19) ^ x >>> 10;
|
|
2774
|
+
we[h] = E + we[h - 7] + w + we[h - 16] | 0;
|
|
2702
2775
|
}
|
|
2703
2776
|
let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: d } = this;
|
|
2704
2777
|
for (let h = 0; h < 64; h++) {
|
|
2705
|
-
const m =
|
|
2778
|
+
const m = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), x = d + m + hr(a, c, l) + br[h] + we[h] | 0, E = (ue(t, 2) ^ ue(t, 13) ^ ue(t, 22)) + pr(t, n, o) | 0;
|
|
2706
2779
|
d = l, l = c, c = a, a = i + x | 0, i = o, o = n, n = t, t = x + E | 0;
|
|
2707
2780
|
}
|
|
2708
2781
|
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);
|
|
2709
2782
|
}
|
|
2710
2783
|
roundClean() {
|
|
2711
|
-
|
|
2784
|
+
Pe(we);
|
|
2712
2785
|
}
|
|
2713
2786
|
destroy() {
|
|
2714
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0),
|
|
2787
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0), Pe(this.buffer);
|
|
2715
2788
|
}
|
|
2716
2789
|
}
|
|
2717
2790
|
class Sr extends vr {
|
|
@@ -2719,88 +2792,88 @@ class Sr extends vr {
|
|
|
2719
2792
|
super(32);
|
|
2720
2793
|
// We cannot use array here since array allows indexing by variable
|
|
2721
2794
|
// which means optimizer/compiler cannot use registers.
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2795
|
+
T(this, "A", me[0] | 0);
|
|
2796
|
+
T(this, "B", me[1] | 0);
|
|
2797
|
+
T(this, "C", me[2] | 0);
|
|
2798
|
+
T(this, "D", me[3] | 0);
|
|
2799
|
+
T(this, "E", me[4] | 0);
|
|
2800
|
+
T(this, "F", me[5] | 0);
|
|
2801
|
+
T(this, "G", me[6] | 0);
|
|
2802
|
+
T(this, "H", me[7] | 0);
|
|
2730
2803
|
}
|
|
2731
2804
|
}
|
|
2732
|
-
const
|
|
2805
|
+
const Er = /* @__PURE__ */ ns(
|
|
2733
2806
|
() => new Sr(),
|
|
2734
2807
|
/* @__PURE__ */ ur(1)
|
|
2735
2808
|
);
|
|
2736
2809
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2737
2810
|
const ht = /* @__PURE__ */ BigInt(0), at = /* @__PURE__ */ BigInt(1);
|
|
2738
|
-
function
|
|
2811
|
+
function qe(r, e = "") {
|
|
2739
2812
|
if (typeof r != "boolean") {
|
|
2740
2813
|
const s = e && `"${e}" `;
|
|
2741
2814
|
throw new Error(s + "expected boolean, got type=" + typeof r);
|
|
2742
2815
|
}
|
|
2743
2816
|
return r;
|
|
2744
2817
|
}
|
|
2745
|
-
function
|
|
2818
|
+
function is(r) {
|
|
2746
2819
|
if (typeof r == "bigint") {
|
|
2747
|
-
if (!
|
|
2820
|
+
if (!Fe(r))
|
|
2748
2821
|
throw new Error("positive bigint expected, got " + r);
|
|
2749
2822
|
} else
|
|
2750
|
-
|
|
2823
|
+
ge(r);
|
|
2751
2824
|
return r;
|
|
2752
2825
|
}
|
|
2753
|
-
function
|
|
2754
|
-
const e =
|
|
2826
|
+
function Ue(r) {
|
|
2827
|
+
const e = is(r).toString(16);
|
|
2755
2828
|
return e.length & 1 ? "0" + e : e;
|
|
2756
2829
|
}
|
|
2757
|
-
function
|
|
2830
|
+
function as(r) {
|
|
2758
2831
|
if (typeof r != "string")
|
|
2759
2832
|
throw new Error("hex string expected, got " + typeof r);
|
|
2760
2833
|
return r === "" ? ht : BigInt("0x" + r);
|
|
2761
2834
|
}
|
|
2762
|
-
function
|
|
2763
|
-
return
|
|
2835
|
+
function ze(r) {
|
|
2836
|
+
return as(Me(r));
|
|
2764
2837
|
}
|
|
2765
|
-
function
|
|
2766
|
-
return
|
|
2838
|
+
function cs(r) {
|
|
2839
|
+
return as(Me(Ir(V(r)).reverse()));
|
|
2767
2840
|
}
|
|
2768
2841
|
function pt(r, e) {
|
|
2769
|
-
|
|
2770
|
-
const s =
|
|
2842
|
+
ge(e), r = is(r);
|
|
2843
|
+
const s = We(r.toString(16).padStart(e * 2, "0"));
|
|
2771
2844
|
if (s.length !== e)
|
|
2772
2845
|
throw new Error("number too large");
|
|
2773
2846
|
return s;
|
|
2774
2847
|
}
|
|
2775
|
-
function
|
|
2848
|
+
function ls(r, e) {
|
|
2776
2849
|
return pt(r, e).reverse();
|
|
2777
2850
|
}
|
|
2778
|
-
function
|
|
2851
|
+
function Ir(r) {
|
|
2779
2852
|
return Uint8Array.from(r);
|
|
2780
2853
|
}
|
|
2781
|
-
const
|
|
2854
|
+
const Fe = (r) => typeof r == "bigint" && ht <= r;
|
|
2782
2855
|
function Tr(r, e, s) {
|
|
2783
|
-
return
|
|
2856
|
+
return Fe(r) && Fe(e) && Fe(s) && e <= r && r < s;
|
|
2784
2857
|
}
|
|
2785
2858
|
function Ar(r, e, s, t) {
|
|
2786
2859
|
if (!Tr(e, s, t))
|
|
2787
2860
|
throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
|
|
2788
2861
|
}
|
|
2789
|
-
function
|
|
2862
|
+
function Rr(r) {
|
|
2790
2863
|
let e;
|
|
2791
2864
|
for (e = 0; r > ht; r >>= at, e += 1)
|
|
2792
2865
|
;
|
|
2793
2866
|
return e;
|
|
2794
2867
|
}
|
|
2795
2868
|
const ft = (r) => (at << BigInt(r)) - at;
|
|
2796
|
-
function
|
|
2797
|
-
if (
|
|
2869
|
+
function kr(r, e, s) {
|
|
2870
|
+
if (ge(r, "hashLen"), ge(e, "qByteLen"), typeof s != "function")
|
|
2798
2871
|
throw new Error("hmacFn must be a function");
|
|
2799
2872
|
const t = (y) => new Uint8Array(y), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
|
|
2800
2873
|
let c = t(r), l = t(r), d = 0;
|
|
2801
2874
|
const h = () => {
|
|
2802
2875
|
c.fill(1), l.fill(0), d = 0;
|
|
2803
|
-
}, m = (...y) => s(l,
|
|
2876
|
+
}, m = (...y) => s(l, ve(c, ...y)), x = (y = n) => {
|
|
2804
2877
|
l = m(o, y), c = m(), y.length !== 0 && (l = m(i, y), c = m());
|
|
2805
2878
|
}, w = () => {
|
|
2806
2879
|
if (d++ >= a)
|
|
@@ -2809,17 +2882,17 @@ function Pr(r, e, s) {
|
|
|
2809
2882
|
const S = [];
|
|
2810
2883
|
for (; y < e; ) {
|
|
2811
2884
|
c = m();
|
|
2812
|
-
const
|
|
2813
|
-
S.push(
|
|
2885
|
+
const C = c.slice();
|
|
2886
|
+
S.push(C), y += c.length;
|
|
2814
2887
|
}
|
|
2815
|
-
return
|
|
2888
|
+
return ve(...S);
|
|
2816
2889
|
};
|
|
2817
2890
|
return (y, S) => {
|
|
2818
2891
|
h(), x(y);
|
|
2819
|
-
let
|
|
2820
|
-
for (; !(
|
|
2892
|
+
let C;
|
|
2893
|
+
for (; !(C = S(w())); )
|
|
2821
2894
|
x();
|
|
2822
|
-
return h(),
|
|
2895
|
+
return h(), C;
|
|
2823
2896
|
};
|
|
2824
2897
|
}
|
|
2825
2898
|
function _t(r, e = {}, s = {}) {
|
|
@@ -2836,7 +2909,7 @@ function _t(r, e = {}, s = {}) {
|
|
|
2836
2909
|
const n = (o, i) => Object.entries(o).forEach(([a, c]) => t(a, c, i));
|
|
2837
2910
|
n(e, !1), n(s, !0);
|
|
2838
2911
|
}
|
|
2839
|
-
function
|
|
2912
|
+
function Mt(r) {
|
|
2840
2913
|
const e = /* @__PURE__ */ new WeakMap();
|
|
2841
2914
|
return (s, ...t) => {
|
|
2842
2915
|
const n = e.get(s);
|
|
@@ -2847,7 +2920,7 @@ function Lt(r) {
|
|
|
2847
2920
|
};
|
|
2848
2921
|
}
|
|
2849
2922
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2850
|
-
const ne = /* @__PURE__ */ BigInt(0), ee = /* @__PURE__ */ BigInt(1),
|
|
2923
|
+
const ne = /* @__PURE__ */ BigInt(0), ee = /* @__PURE__ */ BigInt(1), Ie = /* @__PURE__ */ BigInt(2), ds = /* @__PURE__ */ BigInt(3), us = /* @__PURE__ */ BigInt(4), hs = /* @__PURE__ */ BigInt(5), Pr = /* @__PURE__ */ BigInt(7), ps = /* @__PURE__ */ BigInt(8), Nr = /* @__PURE__ */ BigInt(9), fs = /* @__PURE__ */ BigInt(16);
|
|
2851
2924
|
function le(r, e) {
|
|
2852
2925
|
const s = r % e;
|
|
2853
2926
|
return s >= ne ? s : e + s;
|
|
@@ -2858,7 +2931,7 @@ function ae(r, e, s) {
|
|
|
2858
2931
|
t *= t, t %= s;
|
|
2859
2932
|
return t;
|
|
2860
2933
|
}
|
|
2861
|
-
function
|
|
2934
|
+
function $t(r, e) {
|
|
2862
2935
|
if (r === ne)
|
|
2863
2936
|
throw new Error("invert: expected non-zero number");
|
|
2864
2937
|
if (e <= ne)
|
|
@@ -2876,16 +2949,16 @@ function xt(r, e, s) {
|
|
|
2876
2949
|
if (!r.eql(r.sqr(e), s))
|
|
2877
2950
|
throw new Error("Cannot find square root");
|
|
2878
2951
|
}
|
|
2879
|
-
function
|
|
2880
|
-
const s = (r.ORDER + ee) /
|
|
2952
|
+
function _s(r, e) {
|
|
2953
|
+
const s = (r.ORDER + ee) / us, t = r.pow(e, s);
|
|
2881
2954
|
return xt(r, t, e), t;
|
|
2882
2955
|
}
|
|
2883
|
-
function
|
|
2884
|
-
const s = (r.ORDER -
|
|
2956
|
+
function Or(r, e) {
|
|
2957
|
+
const s = (r.ORDER - hs) / ps, t = r.mul(e, Ie), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, Ie), n), a = r.mul(o, r.sub(i, r.ONE));
|
|
2885
2958
|
return xt(r, a, e), a;
|
|
2886
2959
|
}
|
|
2887
|
-
function
|
|
2888
|
-
const e =
|
|
2960
|
+
function Cr(r) {
|
|
2961
|
+
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;
|
|
2889
2962
|
return (a, c) => {
|
|
2890
2963
|
let l = a.pow(c, i), d = a.mul(l, t);
|
|
2891
2964
|
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);
|
|
@@ -2894,25 +2967,25 @@ function Or(r) {
|
|
|
2894
2967
|
return xt(a, y, c), y;
|
|
2895
2968
|
};
|
|
2896
2969
|
}
|
|
2897
|
-
function
|
|
2898
|
-
if (r <
|
|
2970
|
+
function xs(r) {
|
|
2971
|
+
if (r < ds)
|
|
2899
2972
|
throw new Error("sqrt is not defined for small field");
|
|
2900
2973
|
let e = r - ee, s = 0;
|
|
2901
|
-
for (; e %
|
|
2902
|
-
e /=
|
|
2903
|
-
let t =
|
|
2904
|
-
const n =
|
|
2905
|
-
for (;
|
|
2974
|
+
for (; e % Ie === ne; )
|
|
2975
|
+
e /= Ie, s++;
|
|
2976
|
+
let t = Ie;
|
|
2977
|
+
const n = je(r);
|
|
2978
|
+
for (; Bt(n, t) === 1; )
|
|
2906
2979
|
if (t++ > 1e3)
|
|
2907
2980
|
throw new Error("Cannot find square root: probably non-prime P");
|
|
2908
2981
|
if (s === 1)
|
|
2909
|
-
return
|
|
2982
|
+
return _s;
|
|
2910
2983
|
let o = n.pow(t, e);
|
|
2911
|
-
const i = (e + ee) /
|
|
2984
|
+
const i = (e + ee) / Ie;
|
|
2912
2985
|
return function(c, l) {
|
|
2913
2986
|
if (c.is0(l))
|
|
2914
2987
|
return l;
|
|
2915
|
-
if (
|
|
2988
|
+
if (Bt(c, l) !== 1)
|
|
2916
2989
|
throw new Error("Cannot find square root");
|
|
2917
2990
|
let d = s, h = c.mul(c.ONE, o), m = c.pow(l, e), x = c.pow(l, i);
|
|
2918
2991
|
for (; !c.eql(m, c.ONE); ) {
|
|
@@ -2929,7 +3002,7 @@ function fs(r) {
|
|
|
2929
3002
|
};
|
|
2930
3003
|
}
|
|
2931
3004
|
function Lr(r) {
|
|
2932
|
-
return r %
|
|
3005
|
+
return r % us === ds ? _s : r % ps === hs ? Or : r % fs === Nr ? Cr(r) : xs(r);
|
|
2933
3006
|
}
|
|
2934
3007
|
const Dr = [
|
|
2935
3008
|
"create",
|
|
@@ -2970,33 +3043,33 @@ function $r(r, e, s) {
|
|
|
2970
3043
|
s & ee && (t = r.mul(t, n)), n = r.sqr(n), s >>= ee;
|
|
2971
3044
|
return t;
|
|
2972
3045
|
}
|
|
2973
|
-
function
|
|
3046
|
+
function gs(r, e, s = !1) {
|
|
2974
3047
|
const t = new Array(e.length).fill(s ? r.ZERO : void 0), n = e.reduce((i, a, c) => r.is0(a) ? i : (t[c] = i, r.mul(i, a)), r.ONE), o = r.inv(n);
|
|
2975
3048
|
return e.reduceRight((i, a, c) => r.is0(a) ? i : (t[c] = r.mul(i, t[c]), r.mul(i, a)), o), t;
|
|
2976
3049
|
}
|
|
2977
|
-
function
|
|
2978
|
-
const s = (r.ORDER - ee) /
|
|
3050
|
+
function Bt(r, e) {
|
|
3051
|
+
const s = (r.ORDER - ee) / Ie, t = r.pow(e, s), n = r.eql(t, r.ONE), o = r.eql(t, r.ZERO), i = r.eql(t, r.neg(r.ONE));
|
|
2979
3052
|
if (!n && !o && !i)
|
|
2980
3053
|
throw new Error("invalid Legendre symbol result");
|
|
2981
3054
|
return n ? 1 : o ? 0 : -1;
|
|
2982
3055
|
}
|
|
2983
3056
|
function Br(r, e) {
|
|
2984
|
-
e !== void 0 &&
|
|
3057
|
+
e !== void 0 && ge(e);
|
|
2985
3058
|
const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
|
|
2986
3059
|
return { nBitLength: s, nByteLength: t };
|
|
2987
3060
|
}
|
|
2988
3061
|
class Ur {
|
|
2989
3062
|
constructor(e, s = {}) {
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
3063
|
+
T(this, "ORDER");
|
|
3064
|
+
T(this, "BITS");
|
|
3065
|
+
T(this, "BYTES");
|
|
3066
|
+
T(this, "isLE");
|
|
3067
|
+
T(this, "ZERO", ne);
|
|
3068
|
+
T(this, "ONE", ee);
|
|
3069
|
+
T(this, "_lengths");
|
|
3070
|
+
T(this, "_sqrt");
|
|
2998
3071
|
// cached sqrt
|
|
2999
|
-
|
|
3072
|
+
T(this, "_mod");
|
|
3000
3073
|
var i;
|
|
3001
3074
|
if (e <= ne)
|
|
3002
3075
|
throw new Error("invalid field: expected ORDER > 0, got " + e);
|
|
@@ -3047,7 +3120,7 @@ class Ur {
|
|
|
3047
3120
|
return $r(this, e, s);
|
|
3048
3121
|
}
|
|
3049
3122
|
div(e, s) {
|
|
3050
|
-
return le(e *
|
|
3123
|
+
return le(e * $t(s, this.ORDER), this.ORDER);
|
|
3051
3124
|
}
|
|
3052
3125
|
// Same as above, but doesn't normalize
|
|
3053
3126
|
sqrN(e) {
|
|
@@ -3063,16 +3136,16 @@ class Ur {
|
|
|
3063
3136
|
return e * s;
|
|
3064
3137
|
}
|
|
3065
3138
|
inv(e) {
|
|
3066
|
-
return
|
|
3139
|
+
return $t(e, this.ORDER);
|
|
3067
3140
|
}
|
|
3068
3141
|
sqrt(e) {
|
|
3069
3142
|
return this._sqrt || (this._sqrt = Lr(this.ORDER)), this._sqrt(this, e);
|
|
3070
3143
|
}
|
|
3071
3144
|
toBytes(e) {
|
|
3072
|
-
return this.isLE ?
|
|
3145
|
+
return this.isLE ? ls(e, this.BYTES) : pt(e, this.BYTES);
|
|
3073
3146
|
}
|
|
3074
3147
|
fromBytes(e, s = !1) {
|
|
3075
|
-
|
|
3148
|
+
V(e);
|
|
3076
3149
|
const { _lengths: t, BYTES: n, isLE: o, ORDER: i, _mod: a } = this;
|
|
3077
3150
|
if (t) {
|
|
3078
3151
|
if (!t.includes(e.length) || e.length > n)
|
|
@@ -3082,14 +3155,14 @@ class Ur {
|
|
|
3082
3155
|
}
|
|
3083
3156
|
if (e.length !== n)
|
|
3084
3157
|
throw new Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
|
|
3085
|
-
let c = o ?
|
|
3158
|
+
let c = o ? cs(e) : ze(e);
|
|
3086
3159
|
if (a && (c = le(c, i)), !s && !this.isValid(c))
|
|
3087
3160
|
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
3088
3161
|
return c;
|
|
3089
3162
|
}
|
|
3090
3163
|
// TODO: we don't need it here, move out to separate fn
|
|
3091
3164
|
invertBatch(e) {
|
|
3092
|
-
return
|
|
3165
|
+
return gs(this, e);
|
|
3093
3166
|
}
|
|
3094
3167
|
// We can't move this out because Fp6, Fp12 implement it
|
|
3095
3168
|
// and it's unclear what to return in there.
|
|
@@ -3097,75 +3170,75 @@ class Ur {
|
|
|
3097
3170
|
return t ? s : e;
|
|
3098
3171
|
}
|
|
3099
3172
|
}
|
|
3100
|
-
function
|
|
3173
|
+
function je(r, e = {}) {
|
|
3101
3174
|
return new Ur(r, e);
|
|
3102
3175
|
}
|
|
3103
|
-
function
|
|
3176
|
+
function ms(r) {
|
|
3104
3177
|
if (typeof r != "bigint")
|
|
3105
3178
|
throw new Error("field order must be bigint");
|
|
3106
3179
|
const e = r.toString(2).length;
|
|
3107
3180
|
return Math.ceil(e / 8);
|
|
3108
3181
|
}
|
|
3109
|
-
function
|
|
3110
|
-
const e =
|
|
3182
|
+
function ws(r) {
|
|
3183
|
+
const e = ms(r);
|
|
3111
3184
|
return e + Math.ceil(e / 2);
|
|
3112
3185
|
}
|
|
3113
3186
|
function Hr(r, e, s = !1) {
|
|
3114
|
-
|
|
3115
|
-
const t = r.length, n =
|
|
3187
|
+
V(r);
|
|
3188
|
+
const t = r.length, n = ms(e), o = ws(e);
|
|
3116
3189
|
if (t < 16 || t < o || t > 1024)
|
|
3117
3190
|
throw new Error("expected " + o + "-1024 bytes of input, got " + t);
|
|
3118
|
-
const i = s ?
|
|
3119
|
-
return s ?
|
|
3191
|
+
const i = s ? cs(r) : ze(r), a = le(i, e - ee) + ee;
|
|
3192
|
+
return s ? ls(a, n) : pt(a, n);
|
|
3120
3193
|
}
|
|
3121
3194
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3122
|
-
const
|
|
3123
|
-
function
|
|
3195
|
+
const Ne = /* @__PURE__ */ BigInt(0), Te = /* @__PURE__ */ BigInt(1);
|
|
3196
|
+
function Ke(r, e) {
|
|
3124
3197
|
const s = e.negate();
|
|
3125
3198
|
return r ? s : e;
|
|
3126
3199
|
}
|
|
3127
|
-
function
|
|
3128
|
-
const s =
|
|
3200
|
+
function Ut(r, e) {
|
|
3201
|
+
const s = gs(r.Fp, e.map((t) => t.Z));
|
|
3129
3202
|
return e.map((t, n) => r.fromAffine(t.toAffine(s[n])));
|
|
3130
3203
|
}
|
|
3131
|
-
function
|
|
3204
|
+
function ys(r, e) {
|
|
3132
3205
|
if (!Number.isSafeInteger(r) || r <= 0 || r > e)
|
|
3133
3206
|
throw new Error("invalid window size, expected [1.." + e + "], got W=" + r);
|
|
3134
3207
|
}
|
|
3135
3208
|
function Qe(r, e) {
|
|
3136
|
-
|
|
3209
|
+
ys(r, e);
|
|
3137
3210
|
const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = ft(r), i = BigInt(r);
|
|
3138
3211
|
return { windows: s, windowSize: t, mask: o, maxNumber: n, shiftBy: i };
|
|
3139
3212
|
}
|
|
3140
|
-
function
|
|
3213
|
+
function Ht(r, e, s) {
|
|
3141
3214
|
const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
|
|
3142
3215
|
let a = Number(r & n), c = r >> i;
|
|
3143
|
-
a > t && (a -= o, c +=
|
|
3216
|
+
a > t && (a -= o, c += Te);
|
|
3144
3217
|
const l = e * t, d = l + Math.abs(a) - 1, h = a === 0, m = a < 0, x = e % 2 !== 0;
|
|
3145
3218
|
return { nextN: c, offset: d, isZero: h, isNeg: m, isNegF: x, offsetF: l };
|
|
3146
3219
|
}
|
|
3147
|
-
const et = /* @__PURE__ */ new WeakMap(),
|
|
3220
|
+
const et = /* @__PURE__ */ new WeakMap(), bs = /* @__PURE__ */ new WeakMap();
|
|
3148
3221
|
function tt(r) {
|
|
3149
|
-
return
|
|
3222
|
+
return bs.get(r) || 1;
|
|
3150
3223
|
}
|
|
3151
|
-
function
|
|
3152
|
-
if (r !==
|
|
3224
|
+
function Ft(r) {
|
|
3225
|
+
if (r !== Ne)
|
|
3153
3226
|
throw new Error("invalid wNAF");
|
|
3154
3227
|
}
|
|
3155
3228
|
class Fr {
|
|
3156
3229
|
// Parametrized with a given Point class (not individual point)
|
|
3157
3230
|
constructor(e, s) {
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3231
|
+
T(this, "BASE");
|
|
3232
|
+
T(this, "ZERO");
|
|
3233
|
+
T(this, "Fn");
|
|
3234
|
+
T(this, "bits");
|
|
3162
3235
|
this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = s;
|
|
3163
3236
|
}
|
|
3164
3237
|
// non-const time multiplication ladder
|
|
3165
3238
|
_unsafeLadder(e, s, t = this.ZERO) {
|
|
3166
3239
|
let n = e;
|
|
3167
|
-
for (; s >
|
|
3168
|
-
s &
|
|
3240
|
+
for (; s > Ne; )
|
|
3241
|
+
s & Te && (t = t.add(n)), n = n.double(), s >>= Te;
|
|
3169
3242
|
return t;
|
|
3170
3243
|
}
|
|
3171
3244
|
/**
|
|
@@ -3203,10 +3276,10 @@ class Fr {
|
|
|
3203
3276
|
let n = this.ZERO, o = this.BASE;
|
|
3204
3277
|
const i = Qe(e, this.bits);
|
|
3205
3278
|
for (let a = 0; a < i.windows; a++) {
|
|
3206
|
-
const { nextN: c, offset: l, isZero: d, isNeg: h, isNegF: m, offsetF: x } =
|
|
3207
|
-
t = c, d ? o = o.add(
|
|
3279
|
+
const { nextN: c, offset: l, isZero: d, isNeg: h, isNegF: m, offsetF: x } = Ht(t, a, i);
|
|
3280
|
+
t = c, d ? o = o.add(Ke(m, s[x])) : n = n.add(Ke(h, s[l]));
|
|
3208
3281
|
}
|
|
3209
|
-
return
|
|
3282
|
+
return Ft(t), { p: n, f: o };
|
|
3210
3283
|
}
|
|
3211
3284
|
/**
|
|
3212
3285
|
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
@@ -3215,14 +3288,14 @@ class Fr {
|
|
|
3215
3288
|
*/
|
|
3216
3289
|
wNAFUnsafe(e, s, t, n = this.ZERO) {
|
|
3217
3290
|
const o = Qe(e, this.bits);
|
|
3218
|
-
for (let i = 0; i < o.windows && t !==
|
|
3219
|
-
const { nextN: a, offset: c, isZero: l, isNeg: d } =
|
|
3291
|
+
for (let i = 0; i < o.windows && t !== Ne; i++) {
|
|
3292
|
+
const { nextN: a, offset: c, isZero: l, isNeg: d } = Ht(t, i, o);
|
|
3220
3293
|
if (t = a, !l) {
|
|
3221
3294
|
const h = s[c];
|
|
3222
3295
|
n = n.add(d ? h.negate() : h);
|
|
3223
3296
|
}
|
|
3224
3297
|
}
|
|
3225
|
-
return
|
|
3298
|
+
return Ft(t), n;
|
|
3226
3299
|
}
|
|
3227
3300
|
getPrecomputes(e, s, t) {
|
|
3228
3301
|
let n = et.get(s);
|
|
@@ -3240,7 +3313,7 @@ class Fr {
|
|
|
3240
3313
|
// using windowed method. This specifies window size and
|
|
3241
3314
|
// stores precomputed values. Usually only base point would be precomputed.
|
|
3242
3315
|
createCache(e, s) {
|
|
3243
|
-
|
|
3316
|
+
ys(s, this.bits), bs.set(e, s), et.delete(e);
|
|
3244
3317
|
}
|
|
3245
3318
|
hasCache(e) {
|
|
3246
3319
|
return tt(e) !== 1;
|
|
@@ -3248,27 +3321,27 @@ class Fr {
|
|
|
3248
3321
|
}
|
|
3249
3322
|
function Gr(r, e, s, t) {
|
|
3250
3323
|
let n = e, o = r.ZERO, i = r.ZERO;
|
|
3251
|
-
for (; s >
|
|
3252
|
-
s &
|
|
3324
|
+
for (; s > Ne || t > Ne; )
|
|
3325
|
+
s & Te && (o = o.add(n)), t & Te && (i = i.add(n)), n = n.double(), s >>= Te, t >>= Te;
|
|
3253
3326
|
return { p1: o, p2: i };
|
|
3254
3327
|
}
|
|
3255
|
-
function
|
|
3328
|
+
function Gt(r, e, s) {
|
|
3256
3329
|
if (e) {
|
|
3257
3330
|
if (e.ORDER !== r)
|
|
3258
3331
|
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
3259
3332
|
return Mr(e), e;
|
|
3260
3333
|
} else
|
|
3261
|
-
return
|
|
3334
|
+
return je(r, { isLE: s });
|
|
3262
3335
|
}
|
|
3263
3336
|
function Wr(r, e, s = {}, t) {
|
|
3264
3337
|
if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
|
|
3265
3338
|
throw new Error(`expected valid ${r} CURVE object`);
|
|
3266
3339
|
for (const c of ["p", "n", "h"]) {
|
|
3267
3340
|
const l = e[c];
|
|
3268
|
-
if (!(typeof l == "bigint" && l >
|
|
3341
|
+
if (!(typeof l == "bigint" && l > Ne))
|
|
3269
3342
|
throw new Error(`CURVE.${c} must be positive bigint`);
|
|
3270
3343
|
}
|
|
3271
|
-
const n =
|
|
3344
|
+
const n = Gt(e.p, s.Fp, t), o = Gt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
|
|
3272
3345
|
for (const c of a)
|
|
3273
3346
|
if (!n.isValid(e[c]))
|
|
3274
3347
|
throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
|
|
@@ -3280,15 +3353,15 @@ function qr(r, e) {
|
|
|
3280
3353
|
return { secretKey: n, publicKey: e(n) };
|
|
3281
3354
|
};
|
|
3282
3355
|
}
|
|
3283
|
-
class
|
|
3356
|
+
class vs {
|
|
3284
3357
|
constructor(e, s) {
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
if (
|
|
3358
|
+
T(this, "oHash");
|
|
3359
|
+
T(this, "iHash");
|
|
3360
|
+
T(this, "blockLen");
|
|
3361
|
+
T(this, "outputLen");
|
|
3362
|
+
T(this, "finished", !1);
|
|
3363
|
+
T(this, "destroyed", !1);
|
|
3364
|
+
if (ts(e), V(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
|
|
3292
3365
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
3293
3366
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
3294
3367
|
const t = this.blockLen, n = new Uint8Array(t);
|
|
@@ -3298,13 +3371,13 @@ class ys {
|
|
|
3298
3371
|
this.iHash.update(n), this.oHash = e.create();
|
|
3299
3372
|
for (let o = 0; o < n.length; o++)
|
|
3300
3373
|
n[o] ^= 106;
|
|
3301
|
-
this.oHash.update(n),
|
|
3374
|
+
this.oHash.update(n), Pe(n);
|
|
3302
3375
|
}
|
|
3303
3376
|
update(e) {
|
|
3304
|
-
return
|
|
3377
|
+
return ke(this), this.iHash.update(e), this;
|
|
3305
3378
|
}
|
|
3306
3379
|
digestInto(e) {
|
|
3307
|
-
|
|
3380
|
+
ke(this), V(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
|
|
3308
3381
|
}
|
|
3309
3382
|
digest() {
|
|
3310
3383
|
const e = new Uint8Array(this.oHash.outputLen);
|
|
@@ -3322,17 +3395,17 @@ class ys {
|
|
|
3322
3395
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
3323
3396
|
}
|
|
3324
3397
|
}
|
|
3325
|
-
const
|
|
3326
|
-
|
|
3398
|
+
const Ss = (r, e, s) => new vs(r, e).update(s).digest();
|
|
3399
|
+
Ss.create = (r, e) => new vs(r, e);
|
|
3327
3400
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3328
|
-
const
|
|
3329
|
-
function
|
|
3330
|
-
const [[t, n], [o, i]] = e, a =
|
|
3401
|
+
const Wt = (r, e) => (r + (r >= 0 ? e : -e) / Es) / e;
|
|
3402
|
+
function Kr(r, e, s) {
|
|
3403
|
+
const [[t, n], [o, i]] = e, a = Wt(i * r, s), c = Wt(-n * r, s);
|
|
3331
3404
|
let l = r - a * t - c * o, d = -a * n - c * i;
|
|
3332
|
-
const h = l <
|
|
3405
|
+
const h = l < _e, m = d < _e;
|
|
3333
3406
|
h && (l = -l), m && (d = -d);
|
|
3334
|
-
const x = ft(Math.ceil(
|
|
3335
|
-
if (l <
|
|
3407
|
+
const x = ft(Math.ceil(Rr(s) / 2)) + Re;
|
|
3408
|
+
if (l < _e || l >= x || d < _e || d >= x)
|
|
3336
3409
|
throw new Error("splitScalar (endomorphism): failed, k=" + r);
|
|
3337
3410
|
return { k1neg: h, k1: l, k2neg: m, k2: d };
|
|
3338
3411
|
}
|
|
@@ -3345,33 +3418,33 @@ function st(r, e) {
|
|
|
3345
3418
|
const s = {};
|
|
3346
3419
|
for (let t of Object.keys(e))
|
|
3347
3420
|
s[t] = r[t] === void 0 ? e[t] : r[t];
|
|
3348
|
-
return
|
|
3421
|
+
return qe(s.lowS, "lowS"), qe(s.prehash, "prehash"), s.format !== void 0 && ct(s.format), s;
|
|
3349
3422
|
}
|
|
3350
|
-
class
|
|
3423
|
+
class Vr extends Error {
|
|
3351
3424
|
constructor(e = "") {
|
|
3352
3425
|
super(e);
|
|
3353
3426
|
}
|
|
3354
3427
|
}
|
|
3355
|
-
const
|
|
3428
|
+
const ye = {
|
|
3356
3429
|
// asn.1 DER encoding utils
|
|
3357
|
-
Err:
|
|
3430
|
+
Err: Vr,
|
|
3358
3431
|
// Basic building block is TLV (Tag-Length-Value)
|
|
3359
3432
|
_tlv: {
|
|
3360
3433
|
encode: (r, e) => {
|
|
3361
|
-
const { Err: s } =
|
|
3434
|
+
const { Err: s } = ye;
|
|
3362
3435
|
if (r < 0 || r > 256)
|
|
3363
3436
|
throw new s("tlv.encode: wrong tag");
|
|
3364
3437
|
if (e.length & 1)
|
|
3365
3438
|
throw new s("tlv.encode: unpadded data");
|
|
3366
|
-
const t = e.length / 2, n =
|
|
3439
|
+
const t = e.length / 2, n = Ue(t);
|
|
3367
3440
|
if (n.length / 2 & 128)
|
|
3368
3441
|
throw new s("tlv.encode: long form length too big");
|
|
3369
|
-
const o = t > 127 ?
|
|
3370
|
-
return
|
|
3442
|
+
const o = t > 127 ? Ue(n.length / 2 | 128) : "";
|
|
3443
|
+
return Ue(r) + o + n + e;
|
|
3371
3444
|
},
|
|
3372
3445
|
// v - value, l - left bytes (unparsed)
|
|
3373
3446
|
decode(r, e) {
|
|
3374
|
-
const { Err: s } =
|
|
3447
|
+
const { Err: s } = ye;
|
|
3375
3448
|
let t = 0;
|
|
3376
3449
|
if (r < 0 || r > 256)
|
|
3377
3450
|
throw new s("tlv.encode: wrong tag");
|
|
@@ -3409,25 +3482,25 @@ const me = {
|
|
|
3409
3482
|
// - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
|
|
3410
3483
|
_int: {
|
|
3411
3484
|
encode(r) {
|
|
3412
|
-
const { Err: e } =
|
|
3413
|
-
if (r <
|
|
3485
|
+
const { Err: e } = ye;
|
|
3486
|
+
if (r < _e)
|
|
3414
3487
|
throw new e("integer: negative integers are not allowed");
|
|
3415
|
-
let s =
|
|
3488
|
+
let s = Ue(r);
|
|
3416
3489
|
if (Number.parseInt(s[0], 16) & 8 && (s = "00" + s), s.length & 1)
|
|
3417
3490
|
throw new e("unexpected DER parsing assertion: unpadded hex");
|
|
3418
3491
|
return s;
|
|
3419
3492
|
},
|
|
3420
3493
|
decode(r) {
|
|
3421
|
-
const { Err: e } =
|
|
3494
|
+
const { Err: e } = ye;
|
|
3422
3495
|
if (r[0] & 128)
|
|
3423
3496
|
throw new e("invalid signature integer: negative");
|
|
3424
3497
|
if (r[0] === 0 && !(r[1] & 128))
|
|
3425
3498
|
throw new e("invalid signature integer: unnecessary leading zero");
|
|
3426
|
-
return
|
|
3499
|
+
return ze(r);
|
|
3427
3500
|
}
|
|
3428
3501
|
},
|
|
3429
3502
|
toSig(r) {
|
|
3430
|
-
const { Err: e, _int: s, _tlv: t } =
|
|
3503
|
+
const { Err: e, _int: s, _tlv: t } = ye, n = V(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
|
|
3431
3504
|
if (i.length)
|
|
3432
3505
|
throw new e("invalid signature: left bytes after parsing");
|
|
3433
3506
|
const { v: a, l: c } = t.decode(2, o), { v: l, l: d } = t.decode(2, c);
|
|
@@ -3436,10 +3509,10 @@ const me = {
|
|
|
3436
3509
|
return { r: s.decode(a), s: s.decode(l) };
|
|
3437
3510
|
},
|
|
3438
3511
|
hexFromSig(r) {
|
|
3439
|
-
const { _tlv: e, _int: s } =
|
|
3512
|
+
const { _tlv: e, _int: s } = ye, t = e.encode(2, s.encode(r.r)), n = e.encode(2, s.encode(r.s)), o = t + n;
|
|
3440
3513
|
return e.encode(48, o);
|
|
3441
3514
|
}
|
|
3442
|
-
},
|
|
3515
|
+
}, _e = BigInt(0), Re = BigInt(1), Es = BigInt(2), He = BigInt(3), zr = BigInt(4);
|
|
3443
3516
|
function jr(r, e = {}) {
|
|
3444
3517
|
const s = Wr("weierstrass", r, e), { Fp: t, Fn: n } = s;
|
|
3445
3518
|
let o = s.CURVE;
|
|
@@ -3455,110 +3528,110 @@ function jr(r, e = {}) {
|
|
|
3455
3528
|
const { endo: c } = e;
|
|
3456
3529
|
if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
|
|
3457
3530
|
throw new Error('invalid endo: expected "beta": bigint and "basises": array');
|
|
3458
|
-
const l =
|
|
3531
|
+
const l = Ts(t, n);
|
|
3459
3532
|
function d() {
|
|
3460
3533
|
if (!t.isOdd)
|
|
3461
3534
|
throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
3462
3535
|
}
|
|
3463
|
-
function h(
|
|
3464
|
-
const { x: v, y:
|
|
3465
|
-
if (
|
|
3536
|
+
function h(N, f, _) {
|
|
3537
|
+
const { x: v, y: I } = f.toAffine(), L = t.toBytes(v);
|
|
3538
|
+
if (qe(_, "isCompressed"), _) {
|
|
3466
3539
|
d();
|
|
3467
|
-
const
|
|
3468
|
-
return
|
|
3540
|
+
const O = !t.isOdd(I);
|
|
3541
|
+
return ve(Is(O), L);
|
|
3469
3542
|
} else
|
|
3470
|
-
return
|
|
3471
|
-
}
|
|
3472
|
-
function m(
|
|
3473
|
-
|
|
3474
|
-
const { publicKey: f, publicKeyUncompressed: _ } = l, v =
|
|
3475
|
-
if (v === f && (
|
|
3476
|
-
const
|
|
3477
|
-
if (!t.isValid(
|
|
3543
|
+
return ve(Uint8Array.of(4), L, t.toBytes(I));
|
|
3544
|
+
}
|
|
3545
|
+
function m(N) {
|
|
3546
|
+
V(N, void 0, "Point");
|
|
3547
|
+
const { publicKey: f, publicKeyUncompressed: _ } = l, v = N.length, I = N[0], L = N.subarray(1);
|
|
3548
|
+
if (v === f && (I === 2 || I === 3)) {
|
|
3549
|
+
const O = t.fromBytes(L);
|
|
3550
|
+
if (!t.isValid(O))
|
|
3478
3551
|
throw new Error("bad point: is not on curve, wrong x");
|
|
3479
|
-
const M = E(
|
|
3480
|
-
let
|
|
3552
|
+
const M = E(O);
|
|
3553
|
+
let A;
|
|
3481
3554
|
try {
|
|
3482
|
-
|
|
3555
|
+
A = t.sqrt(M);
|
|
3483
3556
|
} catch (J) {
|
|
3484
|
-
const
|
|
3485
|
-
throw new Error("bad point: is not on curve, sqrt error" +
|
|
3557
|
+
const K = J instanceof Error ? ": " + J.message : "";
|
|
3558
|
+
throw new Error("bad point: is not on curve, sqrt error" + K);
|
|
3486
3559
|
}
|
|
3487
3560
|
d();
|
|
3488
|
-
const $ = t.isOdd(
|
|
3489
|
-
return (
|
|
3490
|
-
} else if (v === _ &&
|
|
3491
|
-
const
|
|
3492
|
-
if (!y(M,
|
|
3561
|
+
const $ = t.isOdd(A);
|
|
3562
|
+
return (I & 1) === 1 !== $ && (A = t.neg(A)), { x: O, y: A };
|
|
3563
|
+
} else if (v === _ && I === 4) {
|
|
3564
|
+
const O = t.BYTES, M = t.fromBytes(L.subarray(0, O)), A = t.fromBytes(L.subarray(O, O * 2));
|
|
3565
|
+
if (!y(M, A))
|
|
3493
3566
|
throw new Error("bad point: is not on curve");
|
|
3494
|
-
return { x: M, y:
|
|
3567
|
+
return { x: M, y: A };
|
|
3495
3568
|
} else
|
|
3496
3569
|
throw new Error(`bad point: got length ${v}, expected compressed=${f} or uncompressed=${_}`);
|
|
3497
3570
|
}
|
|
3498
3571
|
const x = e.toBytes || h, w = e.fromBytes || m;
|
|
3499
|
-
function E(
|
|
3500
|
-
const f = t.sqr(
|
|
3501
|
-
return t.add(t.add(_, t.mul(
|
|
3572
|
+
function E(N) {
|
|
3573
|
+
const f = t.sqr(N), _ = t.mul(f, N);
|
|
3574
|
+
return t.add(t.add(_, t.mul(N, o.a)), o.b);
|
|
3502
3575
|
}
|
|
3503
|
-
function y(
|
|
3504
|
-
const _ = t.sqr(f), v = E(
|
|
3576
|
+
function y(N, f) {
|
|
3577
|
+
const _ = t.sqr(f), v = E(N);
|
|
3505
3578
|
return t.eql(_, v);
|
|
3506
3579
|
}
|
|
3507
3580
|
if (!y(o.Gx, o.Gy))
|
|
3508
3581
|
throw new Error("bad curve params: generator point");
|
|
3509
|
-
const S = t.mul(t.pow(o.a,
|
|
3510
|
-
if (t.is0(t.add(S,
|
|
3582
|
+
const S = t.mul(t.pow(o.a, He), zr), C = t.mul(t.sqr(o.b), BigInt(27));
|
|
3583
|
+
if (t.is0(t.add(S, C)))
|
|
3511
3584
|
throw new Error("bad curve params: a or b");
|
|
3512
|
-
function B(
|
|
3585
|
+
function B(N, f, _ = !1) {
|
|
3513
3586
|
if (!t.isValid(f) || _ && t.is0(f))
|
|
3514
|
-
throw new Error(`bad point coordinate ${
|
|
3587
|
+
throw new Error(`bad point coordinate ${N}`);
|
|
3515
3588
|
return f;
|
|
3516
3589
|
}
|
|
3517
|
-
function b(
|
|
3518
|
-
if (!(
|
|
3590
|
+
function b(N) {
|
|
3591
|
+
if (!(N instanceof W))
|
|
3519
3592
|
throw new Error("Weierstrass Point expected");
|
|
3520
3593
|
}
|
|
3521
|
-
function
|
|
3594
|
+
function k(N) {
|
|
3522
3595
|
if (!c || !c.basises)
|
|
3523
3596
|
throw new Error("no endo");
|
|
3524
|
-
return
|
|
3597
|
+
return Kr(N, c.basises, n.ORDER);
|
|
3525
3598
|
}
|
|
3526
|
-
const
|
|
3527
|
-
const { X: _, Y: v, Z:
|
|
3528
|
-
if (t.eql(
|
|
3599
|
+
const P = Mt((N, f) => {
|
|
3600
|
+
const { X: _, Y: v, Z: I } = N;
|
|
3601
|
+
if (t.eql(I, t.ONE))
|
|
3529
3602
|
return { x: _, y: v };
|
|
3530
|
-
const L =
|
|
3531
|
-
f == null && (f = L ? t.ONE : t.inv(
|
|
3532
|
-
const
|
|
3603
|
+
const L = N.is0();
|
|
3604
|
+
f == null && (f = L ? t.ONE : t.inv(I));
|
|
3605
|
+
const O = t.mul(_, f), M = t.mul(v, f), A = t.mul(I, f);
|
|
3533
3606
|
if (L)
|
|
3534
3607
|
return { x: t.ZERO, y: t.ZERO };
|
|
3535
|
-
if (!t.eql(
|
|
3608
|
+
if (!t.eql(A, t.ONE))
|
|
3536
3609
|
throw new Error("invZ was invalid");
|
|
3537
|
-
return { x:
|
|
3538
|
-
}), G =
|
|
3539
|
-
if (
|
|
3540
|
-
if (e.allowInfinityPoint && !t.is0(
|
|
3610
|
+
return { x: O, y: M };
|
|
3611
|
+
}), G = Mt((N) => {
|
|
3612
|
+
if (N.is0()) {
|
|
3613
|
+
if (e.allowInfinityPoint && !t.is0(N.Y))
|
|
3541
3614
|
return;
|
|
3542
3615
|
throw new Error("bad point: ZERO");
|
|
3543
3616
|
}
|
|
3544
|
-
const { x: f, y: _ } =
|
|
3617
|
+
const { x: f, y: _ } = N.toAffine();
|
|
3545
3618
|
if (!t.isValid(f) || !t.isValid(_))
|
|
3546
3619
|
throw new Error("bad point: x or y not field elements");
|
|
3547
3620
|
if (!y(f, _))
|
|
3548
3621
|
throw new Error("bad point: equation left != right");
|
|
3549
|
-
if (!
|
|
3622
|
+
if (!N.isTorsionFree())
|
|
3550
3623
|
throw new Error("bad point: not in prime-order subgroup");
|
|
3551
3624
|
return !0;
|
|
3552
3625
|
});
|
|
3553
|
-
function
|
|
3554
|
-
return _ = new W(t.mul(_.X,
|
|
3626
|
+
function z(N, f, _, v, I) {
|
|
3627
|
+
return _ = new W(t.mul(_.X, N), _.Y, _.Z), f = Ke(v, f), _ = Ke(I, _), f.add(_);
|
|
3555
3628
|
}
|
|
3556
|
-
const
|
|
3629
|
+
const R = class R {
|
|
3557
3630
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
3558
3631
|
constructor(f, _, v) {
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3632
|
+
T(this, "X");
|
|
3633
|
+
T(this, "Y");
|
|
3634
|
+
T(this, "Z");
|
|
3562
3635
|
this.X = B("x", f), this.Y = B("y", _, !0), this.Z = B("z", v), Object.freeze(this);
|
|
3563
3636
|
}
|
|
3564
3637
|
static CURVE() {
|
|
@@ -3569,16 +3642,16 @@ function jr(r, e = {}) {
|
|
|
3569
3642
|
const { x: _, y: v } = f || {};
|
|
3570
3643
|
if (!f || !t.isValid(_) || !t.isValid(v))
|
|
3571
3644
|
throw new Error("invalid affine point");
|
|
3572
|
-
if (f instanceof
|
|
3645
|
+
if (f instanceof R)
|
|
3573
3646
|
throw new Error("projective point not allowed");
|
|
3574
|
-
return t.is0(_) && t.is0(v) ?
|
|
3647
|
+
return t.is0(_) && t.is0(v) ? R.ZERO : new R(_, v, t.ONE);
|
|
3575
3648
|
}
|
|
3576
3649
|
static fromBytes(f) {
|
|
3577
|
-
const _ =
|
|
3650
|
+
const _ = R.fromAffine(w(V(f, void 0, "point")));
|
|
3578
3651
|
return _.assertValidity(), _;
|
|
3579
3652
|
}
|
|
3580
3653
|
static fromHex(f) {
|
|
3581
|
-
return
|
|
3654
|
+
return R.fromBytes(We(f));
|
|
3582
3655
|
}
|
|
3583
3656
|
get x() {
|
|
3584
3657
|
return this.toAffine().x;
|
|
@@ -3593,7 +3666,7 @@ function jr(r, e = {}) {
|
|
|
3593
3666
|
* @returns
|
|
3594
3667
|
*/
|
|
3595
3668
|
precompute(f = 8, _ = !0) {
|
|
3596
|
-
return D.createCache(this, f), _ || this.multiply(
|
|
3669
|
+
return D.createCache(this, f), _ || this.multiply(He), this;
|
|
3597
3670
|
}
|
|
3598
3671
|
// TODO: return `this`
|
|
3599
3672
|
/** A point on curve is valid if it conforms to equation. */
|
|
@@ -3609,21 +3682,21 @@ function jr(r, e = {}) {
|
|
|
3609
3682
|
/** Compare one point to another. */
|
|
3610
3683
|
equals(f) {
|
|
3611
3684
|
b(f);
|
|
3612
|
-
const { X: _, Y: v, Z:
|
|
3613
|
-
return
|
|
3685
|
+
const { X: _, Y: v, Z: I } = this, { X: L, Y: O, Z: M } = f, A = t.eql(t.mul(_, M), t.mul(L, I)), $ = t.eql(t.mul(v, M), t.mul(O, I));
|
|
3686
|
+
return A && $;
|
|
3614
3687
|
}
|
|
3615
3688
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
3616
3689
|
negate() {
|
|
3617
|
-
return new
|
|
3690
|
+
return new R(this.X, t.neg(this.Y), this.Z);
|
|
3618
3691
|
}
|
|
3619
3692
|
// Renes-Costello-Batina exception-free doubling formula.
|
|
3620
3693
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
3621
3694
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
3622
3695
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
3623
3696
|
double() {
|
|
3624
|
-
const { a: f, b: _ } = o, v = t.mul(_,
|
|
3625
|
-
let M = t.ZERO,
|
|
3626
|
-
return H = t.add(H, H), $ = t.mul(
|
|
3697
|
+
const { a: f, b: _ } = o, v = t.mul(_, He), { X: I, Y: L, Z: O } = this;
|
|
3698
|
+
let M = t.ZERO, A = t.ZERO, $ = t.ZERO, F = t.mul(I, I), J = t.mul(L, L), K = t.mul(O, O), H = t.mul(I, L);
|
|
3699
|
+
return H = t.add(H, H), $ = t.mul(I, O), $ = t.add($, $), M = t.mul(f, $), A = t.mul(v, K), A = t.add(M, A), M = t.sub(J, A), A = t.add(J, A), A = t.mul(M, A), M = t.mul(H, M), $ = t.mul(v, $), K = t.mul(f, K), H = t.sub(F, K), H = t.mul(f, H), H = t.add(H, $), $ = t.add(F, F), F = t.add($, F), F = t.add(F, K), F = t.mul(F, H), A = t.add(A, F), K = t.mul(L, O), K = t.add(K, K), F = t.mul(K, H), M = t.sub(M, F), $ = t.mul(K, J), $ = t.add($, $), $ = t.add($, $), new R(M, A, $);
|
|
3627
3700
|
}
|
|
3628
3701
|
// Renes-Costello-Batina exception-free addition formula.
|
|
3629
3702
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
@@ -3631,19 +3704,19 @@ function jr(r, e = {}) {
|
|
|
3631
3704
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
3632
3705
|
add(f) {
|
|
3633
3706
|
b(f);
|
|
3634
|
-
const { X: _, Y: v, Z:
|
|
3635
|
-
let
|
|
3636
|
-
const J = o.a,
|
|
3637
|
-
let H = t.mul(_, L), Z = t.mul(v,
|
|
3638
|
-
oe = t.mul(oe, j), j = t.add(H, Z), oe = t.sub(oe, j), j = t.add(_,
|
|
3707
|
+
const { X: _, Y: v, Z: I } = this, { X: L, Y: O, Z: M } = f;
|
|
3708
|
+
let A = t.ZERO, $ = t.ZERO, F = t.ZERO;
|
|
3709
|
+
const J = o.a, K = t.mul(o.b, He);
|
|
3710
|
+
let H = t.mul(_, L), Z = t.mul(v, O), X = t.mul(I, M), oe = t.add(_, v), j = t.add(L, O);
|
|
3711
|
+
oe = t.mul(oe, j), j = t.add(H, Z), oe = t.sub(oe, j), j = t.add(_, I);
|
|
3639
3712
|
let Q = t.add(L, M);
|
|
3640
|
-
return j = t.mul(j, Q), Q = t.add(H, X), j = t.sub(j, Q), Q = t.add(v,
|
|
3713
|
+
return j = t.mul(j, Q), Q = t.add(H, X), j = t.sub(j, Q), Q = t.add(v, I), A = t.add(O, M), Q = t.mul(Q, A), A = t.add(Z, X), Q = t.sub(Q, A), F = t.mul(J, j), A = t.mul(K, X), F = t.add(A, F), A = t.sub(Z, F), F = t.add(Z, F), $ = t.mul(A, F), Z = t.add(H, H), Z = t.add(Z, H), X = t.mul(J, X), j = t.mul(K, j), Z = t.add(Z, X), X = t.sub(H, X), X = t.mul(J, X), j = t.add(j, X), H = t.mul(Z, j), $ = t.add($, H), H = t.mul(Q, j), A = t.mul(oe, A), A = t.sub(A, H), H = t.mul(oe, Z), F = t.mul(Q, F), F = t.add(F, H), new R(A, $, F);
|
|
3641
3714
|
}
|
|
3642
3715
|
subtract(f) {
|
|
3643
3716
|
return this.add(f.negate());
|
|
3644
3717
|
}
|
|
3645
3718
|
is0() {
|
|
3646
|
-
return this.equals(
|
|
3719
|
+
return this.equals(R.ZERO);
|
|
3647
3720
|
}
|
|
3648
3721
|
/**
|
|
3649
3722
|
* Constant time multiplication.
|
|
@@ -3658,16 +3731,16 @@ function jr(r, e = {}) {
|
|
|
3658
3731
|
const { endo: _ } = e;
|
|
3659
3732
|
if (!n.isValidNot0(f))
|
|
3660
3733
|
throw new Error("invalid scalar: out of range");
|
|
3661
|
-
let v,
|
|
3662
|
-
const L = (
|
|
3734
|
+
let v, I;
|
|
3735
|
+
const L = (O) => D.cached(this, O, (M) => Ut(R, M));
|
|
3663
3736
|
if (_) {
|
|
3664
|
-
const { k1neg:
|
|
3665
|
-
|
|
3737
|
+
const { k1neg: O, k1: M, k2neg: A, k2: $ } = k(f), { p: F, f: J } = L(M), { p: K, f: H } = L($);
|
|
3738
|
+
I = J.add(H), v = z(_.beta, F, K, O, A);
|
|
3666
3739
|
} else {
|
|
3667
|
-
const { p:
|
|
3668
|
-
v =
|
|
3740
|
+
const { p: O, f: M } = L(f);
|
|
3741
|
+
v = O, I = M;
|
|
3669
3742
|
}
|
|
3670
|
-
return
|
|
3743
|
+
return Ut(R, [v, I])[0];
|
|
3671
3744
|
}
|
|
3672
3745
|
/**
|
|
3673
3746
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -3678,15 +3751,15 @@ function jr(r, e = {}) {
|
|
|
3678
3751
|
const { endo: _ } = e, v = this;
|
|
3679
3752
|
if (!n.isValid(f))
|
|
3680
3753
|
throw new Error("invalid scalar: out of range");
|
|
3681
|
-
if (f ===
|
|
3682
|
-
return
|
|
3683
|
-
if (f ===
|
|
3754
|
+
if (f === _e || v.is0())
|
|
3755
|
+
return R.ZERO;
|
|
3756
|
+
if (f === Re)
|
|
3684
3757
|
return v;
|
|
3685
3758
|
if (D.hasCache(this))
|
|
3686
3759
|
return this.multiply(f);
|
|
3687
3760
|
if (_) {
|
|
3688
|
-
const { k1neg:
|
|
3689
|
-
return
|
|
3761
|
+
const { k1neg: I, k1: L, k2neg: O, k2: M } = k(f), { p1: A, p2: $ } = Gr(R, v, L, M);
|
|
3762
|
+
return z(_.beta, A, $, I, O);
|
|
3690
3763
|
} else
|
|
3691
3764
|
return D.unsafe(v, f);
|
|
3692
3765
|
}
|
|
@@ -3695,7 +3768,7 @@ function jr(r, e = {}) {
|
|
|
3695
3768
|
* @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
|
|
3696
3769
|
*/
|
|
3697
3770
|
toAffine(f) {
|
|
3698
|
-
return
|
|
3771
|
+
return P(this, f);
|
|
3699
3772
|
}
|
|
3700
3773
|
/**
|
|
3701
3774
|
* Checks whether Point is free of torsion elements (is in prime subgroup).
|
|
@@ -3703,17 +3776,17 @@ function jr(r, e = {}) {
|
|
|
3703
3776
|
*/
|
|
3704
3777
|
isTorsionFree() {
|
|
3705
3778
|
const { isTorsionFree: f } = e;
|
|
3706
|
-
return i ===
|
|
3779
|
+
return i === Re ? !0 : f ? f(R, this) : D.unsafe(this, a).is0();
|
|
3707
3780
|
}
|
|
3708
3781
|
clearCofactor() {
|
|
3709
3782
|
const { clearCofactor: f } = e;
|
|
3710
|
-
return i ===
|
|
3783
|
+
return i === Re ? this : f ? f(R, this) : this.multiplyUnsafe(i);
|
|
3711
3784
|
}
|
|
3712
3785
|
isSmallOrder() {
|
|
3713
3786
|
return this.multiplyUnsafe(i).is0();
|
|
3714
3787
|
}
|
|
3715
3788
|
toBytes(f = !0) {
|
|
3716
|
-
return
|
|
3789
|
+
return qe(f, "isCompressed"), this.assertValidity(), x(R, this, f);
|
|
3717
3790
|
}
|
|
3718
3791
|
toHex(f = !0) {
|
|
3719
3792
|
return Me(this.toBytes(f));
|
|
@@ -3723,19 +3796,19 @@ function jr(r, e = {}) {
|
|
|
3723
3796
|
}
|
|
3724
3797
|
};
|
|
3725
3798
|
// base / generator point
|
|
3726
|
-
|
|
3727
|
-
|
|
3799
|
+
T(R, "BASE", new R(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
|
|
3800
|
+
T(R, "ZERO", new R(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
|
|
3728
3801
|
// math field
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
let W =
|
|
3802
|
+
T(R, "Fp", t), // scalar field
|
|
3803
|
+
T(R, "Fn", n);
|
|
3804
|
+
let W = R;
|
|
3732
3805
|
const q = n.BITS, D = new Fr(W, e.endo ? Math.ceil(q / 2) : q);
|
|
3733
3806
|
return W.BASE.precompute(8), W;
|
|
3734
3807
|
}
|
|
3735
|
-
function
|
|
3808
|
+
function Is(r) {
|
|
3736
3809
|
return Uint8Array.of(r ? 2 : 3);
|
|
3737
3810
|
}
|
|
3738
|
-
function
|
|
3811
|
+
function Ts(r, e) {
|
|
3739
3812
|
return {
|
|
3740
3813
|
secretKey: e.BYTES,
|
|
3741
3814
|
publicKey: 1 + r.BYTES,
|
|
@@ -3745,7 +3818,7 @@ function Is(r, e) {
|
|
|
3745
3818
|
};
|
|
3746
3819
|
}
|
|
3747
3820
|
function Yr(r, e = {}) {
|
|
3748
|
-
const { Fn: s } = r, t = e.randomBytes ||
|
|
3821
|
+
const { Fn: s } = r, t = e.randomBytes || os, n = Object.assign(Ts(r.Fp, s), { seed: ws(s.ORDER) });
|
|
3749
3822
|
function o(x) {
|
|
3750
3823
|
try {
|
|
3751
3824
|
const w = s.fromBytes(x);
|
|
@@ -3764,7 +3837,7 @@ function Yr(r, e = {}) {
|
|
|
3764
3837
|
}
|
|
3765
3838
|
}
|
|
3766
3839
|
function a(x = t(n.seed)) {
|
|
3767
|
-
return Hr(
|
|
3840
|
+
return Hr(V(x, n.seed, "seed"), s.ORDER);
|
|
3768
3841
|
}
|
|
3769
3842
|
function c(x, w = !0) {
|
|
3770
3843
|
return r.BASE.multiply(s.fromBytes(x)).toBytes(w);
|
|
@@ -3773,7 +3846,7 @@ function Yr(r, e = {}) {
|
|
|
3773
3846
|
const { secretKey: w, publicKey: E, publicKeyUncompressed: y } = n;
|
|
3774
3847
|
if (!ut(x) || "_lengths" in s && s._lengths || w === E)
|
|
3775
3848
|
return;
|
|
3776
|
-
const S =
|
|
3849
|
+
const S = V(x, void 0, "key").length;
|
|
3777
3850
|
return S === E || S === y;
|
|
3778
3851
|
}
|
|
3779
3852
|
function d(x, w, E = !0) {
|
|
@@ -3792,21 +3865,21 @@ function Yr(r, e = {}) {
|
|
|
3792
3865
|
return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: m, Point: r, utils: h, lengths: n });
|
|
3793
3866
|
}
|
|
3794
3867
|
function Jr(r, e, s = {}) {
|
|
3795
|
-
|
|
3868
|
+
ts(e), _t(s, {}, {
|
|
3796
3869
|
hmac: "function",
|
|
3797
3870
|
lowS: "boolean",
|
|
3798
3871
|
randomBytes: "function",
|
|
3799
3872
|
bits2int: "function",
|
|
3800
3873
|
bits2int_modN: "function"
|
|
3801
3874
|
}), s = Object.assign({}, s);
|
|
3802
|
-
const t = s.randomBytes ||
|
|
3875
|
+
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 = {
|
|
3803
3876
|
prehash: !0,
|
|
3804
3877
|
lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
|
|
3805
3878
|
format: "compact",
|
|
3806
3879
|
extraEntropy: !1
|
|
3807
|
-
}, E = a *
|
|
3880
|
+
}, E = a * Es < o.ORDER;
|
|
3808
3881
|
function y(f) {
|
|
3809
|
-
const _ = a >>
|
|
3882
|
+
const _ = a >> Re;
|
|
3810
3883
|
return f > _;
|
|
3811
3884
|
}
|
|
3812
3885
|
function S(f, _) {
|
|
@@ -3814,40 +3887,40 @@ function Jr(r, e, s = {}) {
|
|
|
3814
3887
|
throw new Error(`invalid signature ${f}: out of range 1..Point.Fn.ORDER`);
|
|
3815
3888
|
return _;
|
|
3816
3889
|
}
|
|
3817
|
-
function
|
|
3890
|
+
function C() {
|
|
3818
3891
|
if (E)
|
|
3819
3892
|
throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
3820
3893
|
}
|
|
3821
3894
|
function B(f, _) {
|
|
3822
3895
|
ct(_);
|
|
3823
|
-
const v = x.signature,
|
|
3824
|
-
return
|
|
3896
|
+
const v = x.signature, I = _ === "compact" ? v : _ === "recovered" ? v + 1 : void 0;
|
|
3897
|
+
return V(f, I);
|
|
3825
3898
|
}
|
|
3826
3899
|
class b {
|
|
3827
|
-
constructor(_, v,
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
if (this.r = S("r", _), this.s = S("s", v),
|
|
3832
|
-
if (
|
|
3900
|
+
constructor(_, v, I) {
|
|
3901
|
+
T(this, "r");
|
|
3902
|
+
T(this, "s");
|
|
3903
|
+
T(this, "recovery");
|
|
3904
|
+
if (this.r = S("r", _), this.s = S("s", v), I != null) {
|
|
3905
|
+
if (C(), ![0, 1, 2, 3].includes(I))
|
|
3833
3906
|
throw new Error("invalid recovery id");
|
|
3834
|
-
this.recovery =
|
|
3907
|
+
this.recovery = I;
|
|
3835
3908
|
}
|
|
3836
3909
|
Object.freeze(this);
|
|
3837
3910
|
}
|
|
3838
3911
|
static fromBytes(_, v = w.format) {
|
|
3839
3912
|
B(_, v);
|
|
3840
|
-
let
|
|
3913
|
+
let I;
|
|
3841
3914
|
if (v === "der") {
|
|
3842
|
-
const { r:
|
|
3843
|
-
return new b(
|
|
3915
|
+
const { r: A, s: $ } = ye.toSig(V(_));
|
|
3916
|
+
return new b(A, $);
|
|
3844
3917
|
}
|
|
3845
|
-
v === "recovered" && (
|
|
3846
|
-
const L = x.signature / 2,
|
|
3847
|
-
return new b(i.fromBytes(
|
|
3918
|
+
v === "recovered" && (I = _[0], v = "compact", _ = _.subarray(1));
|
|
3919
|
+
const L = x.signature / 2, O = _.subarray(0, L), M = _.subarray(L, L * 2);
|
|
3920
|
+
return new b(i.fromBytes(O), i.fromBytes(M), I);
|
|
3848
3921
|
}
|
|
3849
3922
|
static fromHex(_, v) {
|
|
3850
|
-
return this.fromBytes(
|
|
3923
|
+
return this.fromBytes(We(_), v);
|
|
3851
3924
|
}
|
|
3852
3925
|
assertRecovery() {
|
|
3853
3926
|
const { recovery: _ } = this;
|
|
@@ -3859,10 +3932,10 @@ function Jr(r, e, s = {}) {
|
|
|
3859
3932
|
return new b(this.r, this.s, _);
|
|
3860
3933
|
}
|
|
3861
3934
|
recoverPublicKey(_) {
|
|
3862
|
-
const { r: v, s:
|
|
3863
|
-
if (!o.isValid(
|
|
3935
|
+
const { r: v, s: I } = this, L = this.assertRecovery(), O = L === 2 || L === 3 ? v + a : v;
|
|
3936
|
+
if (!o.isValid(O))
|
|
3864
3937
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
3865
|
-
const M = o.toBytes(
|
|
3938
|
+
const M = o.toBytes(O), A = r.fromBytes(ve(Is((L & 1) === 0), M)), $ = i.inv(O), F = P(V(_, void 0, "msgHash")), J = i.create(-F * $), K = i.create(I * $), H = r.BASE.multiplyUnsafe(J).add(A.multiplyUnsafe(K));
|
|
3866
3939
|
if (H.is0())
|
|
3867
3940
|
throw new Error("invalid recovery: point at infinify");
|
|
3868
3941
|
return H.assertValidity(), H;
|
|
@@ -3873,79 +3946,79 @@ function Jr(r, e, s = {}) {
|
|
|
3873
3946
|
}
|
|
3874
3947
|
toBytes(_ = w.format) {
|
|
3875
3948
|
if (ct(_), _ === "der")
|
|
3876
|
-
return
|
|
3877
|
-
const { r: v, s:
|
|
3878
|
-
return _ === "recovered" ? (
|
|
3949
|
+
return We(ye.hexFromSig(this));
|
|
3950
|
+
const { r: v, s: I } = this, L = i.toBytes(v), O = i.toBytes(I);
|
|
3951
|
+
return _ === "recovered" ? (C(), ve(Uint8Array.of(this.assertRecovery()), L, O)) : ve(L, O);
|
|
3879
3952
|
}
|
|
3880
3953
|
toHex(_) {
|
|
3881
3954
|
return Me(this.toBytes(_));
|
|
3882
3955
|
}
|
|
3883
3956
|
}
|
|
3884
|
-
const
|
|
3957
|
+
const k = s.bits2int || function(_) {
|
|
3885
3958
|
if (_.length > 8192)
|
|
3886
3959
|
throw new Error("input is too large");
|
|
3887
|
-
const v =
|
|
3888
|
-
return
|
|
3889
|
-
},
|
|
3890
|
-
return i.create(
|
|
3960
|
+
const v = ze(_), I = _.length * 8 - c;
|
|
3961
|
+
return I > 0 ? v >> BigInt(I) : v;
|
|
3962
|
+
}, P = s.bits2int_modN || function(_) {
|
|
3963
|
+
return i.create(k(_));
|
|
3891
3964
|
}, G = ft(c);
|
|
3892
|
-
function
|
|
3893
|
-
return Ar("num < 2^" + c, f,
|
|
3965
|
+
function z(f) {
|
|
3966
|
+
return Ar("num < 2^" + c, f, _e, G), i.toBytes(f);
|
|
3894
3967
|
}
|
|
3895
3968
|
function W(f, _) {
|
|
3896
|
-
return
|
|
3969
|
+
return V(f, void 0, "message"), _ ? V(e(f), void 0, "prehashed message") : f;
|
|
3897
3970
|
}
|
|
3898
3971
|
function q(f, _, v) {
|
|
3899
|
-
const { lowS:
|
|
3972
|
+
const { lowS: I, prehash: L, extraEntropy: O } = st(v, w);
|
|
3900
3973
|
f = W(f, L);
|
|
3901
|
-
const M =
|
|
3902
|
-
if (!i.isValidNot0(
|
|
3974
|
+
const M = P(f), A = i.fromBytes(_);
|
|
3975
|
+
if (!i.isValidNot0(A))
|
|
3903
3976
|
throw new Error("invalid private key");
|
|
3904
|
-
const $ = [
|
|
3905
|
-
if (
|
|
3906
|
-
const H =
|
|
3907
|
-
$.push(
|
|
3908
|
-
}
|
|
3909
|
-
const F =
|
|
3910
|
-
function
|
|
3911
|
-
const Z =
|
|
3977
|
+
const $ = [z(A), z(M)];
|
|
3978
|
+
if (O != null && O !== !1) {
|
|
3979
|
+
const H = O === !0 ? t(x.secretKey) : O;
|
|
3980
|
+
$.push(V(H, void 0, "extraEntropy"));
|
|
3981
|
+
}
|
|
3982
|
+
const F = ve(...$), J = M;
|
|
3983
|
+
function K(H) {
|
|
3984
|
+
const Z = k(H);
|
|
3912
3985
|
if (!i.isValidNot0(Z))
|
|
3913
3986
|
return;
|
|
3914
3987
|
const X = i.inv(Z), oe = r.BASE.multiply(Z).toAffine(), j = i.create(oe.x);
|
|
3915
|
-
if (j ===
|
|
3988
|
+
if (j === _e)
|
|
3916
3989
|
return;
|
|
3917
|
-
const Q = i.create(X * i.create(J + j *
|
|
3918
|
-
if (Q ===
|
|
3990
|
+
const Q = i.create(X * i.create(J + j * A));
|
|
3991
|
+
if (Q === _e)
|
|
3919
3992
|
return;
|
|
3920
|
-
let yt = (oe.x === j ? 0 : 2) | Number(oe.y &
|
|
3921
|
-
return
|
|
3993
|
+
let yt = (oe.x === j ? 0 : 2) | Number(oe.y & Re), bt = Q;
|
|
3994
|
+
return I && y(Q) && (bt = i.neg(Q), yt ^= 1), new b(j, bt, E ? void 0 : yt);
|
|
3922
3995
|
}
|
|
3923
|
-
return { seed: F, k2sig:
|
|
3996
|
+
return { seed: F, k2sig: K };
|
|
3924
3997
|
}
|
|
3925
3998
|
function D(f, _, v = {}) {
|
|
3926
|
-
const { seed:
|
|
3927
|
-
return
|
|
3999
|
+
const { seed: I, k2sig: L } = q(f, _, v);
|
|
4000
|
+
return kr(e.outputLen, i.BYTES, n)(I, L).toBytes(v.format);
|
|
3928
4001
|
}
|
|
3929
|
-
function
|
|
3930
|
-
const { lowS: L, prehash:
|
|
3931
|
-
if (v =
|
|
3932
|
-
const
|
|
3933
|
-
throw new Error("verify expects Uint8Array signature" +
|
|
4002
|
+
function R(f, _, v, I = {}) {
|
|
4003
|
+
const { lowS: L, prehash: O, format: M } = st(I, w);
|
|
4004
|
+
if (v = V(v, void 0, "publicKey"), _ = W(_, O), !ut(f)) {
|
|
4005
|
+
const A = f instanceof b ? ", use sig.toBytes()" : "";
|
|
4006
|
+
throw new Error("verify expects Uint8Array signature" + A);
|
|
3934
4007
|
}
|
|
3935
4008
|
B(f, M);
|
|
3936
4009
|
try {
|
|
3937
|
-
const
|
|
3938
|
-
if (L &&
|
|
4010
|
+
const A = b.fromBytes(f, M), $ = r.fromBytes(v);
|
|
4011
|
+
if (L && A.hasHighS())
|
|
3939
4012
|
return !1;
|
|
3940
|
-
const { r: F, s: J } =
|
|
4013
|
+
const { r: F, s: J } = A, K = P(_), H = i.inv(J), Z = i.create(K * H), X = i.create(F * H), oe = r.BASE.multiplyUnsafe(Z).add($.multiplyUnsafe(X));
|
|
3941
4014
|
return oe.is0() ? !1 : i.create(oe.x) === F;
|
|
3942
4015
|
} catch {
|
|
3943
4016
|
return !1;
|
|
3944
4017
|
}
|
|
3945
4018
|
}
|
|
3946
|
-
function
|
|
3947
|
-
const { prehash:
|
|
3948
|
-
return _ = W(_,
|
|
4019
|
+
function N(f, _, v = {}) {
|
|
4020
|
+
const { prehash: I } = st(v, w);
|
|
4021
|
+
return _ = W(_, I), b.fromBytes(f, "recovered").recoverPublicKey(_).toBytes();
|
|
3949
4022
|
}
|
|
3950
4023
|
return Object.freeze({
|
|
3951
4024
|
keygen: l,
|
|
@@ -3955,8 +4028,8 @@ function Jr(r, e, s = {}) {
|
|
|
3955
4028
|
lengths: x,
|
|
3956
4029
|
Point: r,
|
|
3957
4030
|
sign: D,
|
|
3958
|
-
verify:
|
|
3959
|
-
recoverPublicKey:
|
|
4031
|
+
verify: R,
|
|
4032
|
+
recoverPublicKey: N,
|
|
3960
4033
|
Signature: b,
|
|
3961
4034
|
hash: e
|
|
3962
4035
|
});
|
|
@@ -3976,38 +4049,38 @@ const gt = {
|
|
|
3976
4049
|
[BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
|
|
3977
4050
|
[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
|
|
3978
4051
|
]
|
|
3979
|
-
},
|
|
4052
|
+
}, qt = /* @__PURE__ */ BigInt(2);
|
|
3980
4053
|
function Xr(r) {
|
|
3981
|
-
const e = gt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, h = ae(d, s, e) * d % e, m = ae(h, s, e) * d % e, x = ae(m,
|
|
3982
|
-
if (!lt.eql(lt.sqr(
|
|
4054
|
+
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, E = ae(w, o, e) * w % e, y = ae(E, a, e) * E % e, S = ae(y, c, e) * y % e, C = ae(S, a, e) * E % e, B = ae(C, s, e) * d % e, b = ae(B, i, e) * w % e, k = ae(b, t, e) * l % e, P = ae(k, qt, e);
|
|
4055
|
+
if (!lt.eql(lt.sqr(P), r))
|
|
3983
4056
|
throw new Error("Cannot find square root");
|
|
3984
|
-
return
|
|
4057
|
+
return P;
|
|
3985
4058
|
}
|
|
3986
|
-
const lt =
|
|
4059
|
+
const lt = je(gt.p, { sqrt: Xr }), Qr = /* @__PURE__ */ jr(gt, {
|
|
3987
4060
|
Fp: lt,
|
|
3988
4061
|
endo: Zr
|
|
3989
|
-
}), en = /* @__PURE__ */ Jr(Qr,
|
|
3990
|
-
for (let r = 0, e =
|
|
3991
|
-
[s, t] = [t, (2 * s + 3 * t) % 5],
|
|
4062
|
+
}), en = /* @__PURE__ */ Jr(Qr, Er), tn = BigInt(0), Oe = BigInt(1), sn = BigInt(2), rn = BigInt(7), nn = BigInt(256), on = BigInt(113), As = [], Rs = [], ks = [];
|
|
4063
|
+
for (let r = 0, e = Oe, s = 1, t = 0; r < 24; r++) {
|
|
4064
|
+
[s, t] = [t, (2 * s + 3 * t) % 5], As.push(2 * (5 * t + s)), Rs.push((r + 1) * (r + 2) / 2 % 64);
|
|
3992
4065
|
let n = tn;
|
|
3993
4066
|
for (let o = 0; o < 7; o++)
|
|
3994
|
-
e = (e <<
|
|
3995
|
-
|
|
4067
|
+
e = (e << Oe ^ (e >> rn) * on) % nn, e & sn && (n ^= Oe << (Oe << BigInt(o)) - Oe);
|
|
4068
|
+
ks.push(n);
|
|
3996
4069
|
}
|
|
3997
|
-
const
|
|
4070
|
+
const Ps = xr(ks, !0), an = Ps[0], cn = Ps[1], Kt = (r, e, s) => s > 32 ? wr(r, e, s) : gr(r, e, s), Vt = (r, e, s) => s > 32 ? yr(r, e, s) : mr(r, e, s);
|
|
3998
4071
|
function ln(r, e = 24) {
|
|
3999
4072
|
const s = new Uint32Array(10);
|
|
4000
4073
|
for (let t = 24 - e; t < 24; t++) {
|
|
4001
4074
|
for (let i = 0; i < 10; i++)
|
|
4002
4075
|
s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
|
|
4003
4076
|
for (let i = 0; i < 10; i += 2) {
|
|
4004
|
-
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], h =
|
|
4077
|
+
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];
|
|
4005
4078
|
for (let x = 0; x < 50; x += 10)
|
|
4006
4079
|
r[i + x] ^= h, r[i + x + 1] ^= m;
|
|
4007
4080
|
}
|
|
4008
4081
|
let n = r[2], o = r[3];
|
|
4009
4082
|
for (let i = 0; i < 24; i++) {
|
|
4010
|
-
const a =
|
|
4083
|
+
const a = Rs[i], c = Kt(n, o, a), l = Vt(n, o, a), d = As[i];
|
|
4011
4084
|
n = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
|
|
4012
4085
|
}
|
|
4013
4086
|
for (let i = 0; i < 50; i += 10) {
|
|
@@ -4018,23 +4091,23 @@ function ln(r, e = 24) {
|
|
|
4018
4091
|
}
|
|
4019
4092
|
r[0] ^= an[t], r[1] ^= cn[t];
|
|
4020
4093
|
}
|
|
4021
|
-
|
|
4094
|
+
Pe(s);
|
|
4022
4095
|
}
|
|
4023
4096
|
class mt {
|
|
4024
4097
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
4025
4098
|
constructor(e, s, t, n = !1, o = 24) {
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o,
|
|
4099
|
+
T(this, "state");
|
|
4100
|
+
T(this, "pos", 0);
|
|
4101
|
+
T(this, "posOut", 0);
|
|
4102
|
+
T(this, "finished", !1);
|
|
4103
|
+
T(this, "state32");
|
|
4104
|
+
T(this, "destroyed", !1);
|
|
4105
|
+
T(this, "blockLen");
|
|
4106
|
+
T(this, "suffix");
|
|
4107
|
+
T(this, "outputLen");
|
|
4108
|
+
T(this, "enableXOF", !1);
|
|
4109
|
+
T(this, "rounds");
|
|
4110
|
+
if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, ge(t, "outputLen"), !(0 < e && e < 200))
|
|
4038
4111
|
throw new Error("only keccak-f1600 function is supported");
|
|
4039
4112
|
this.state = new Uint8Array(200), this.state32 = ir(this.state);
|
|
4040
4113
|
}
|
|
@@ -4042,10 +4115,10 @@ class mt {
|
|
|
4042
4115
|
return this._cloneInto();
|
|
4043
4116
|
}
|
|
4044
4117
|
keccak() {
|
|
4045
|
-
|
|
4118
|
+
Ct(this.state32), ln(this.state32, this.rounds), Ct(this.state32), this.posOut = 0, this.pos = 0;
|
|
4046
4119
|
}
|
|
4047
4120
|
update(e) {
|
|
4048
|
-
|
|
4121
|
+
ke(this), V(e);
|
|
4049
4122
|
const { blockLen: s, state: t } = this, n = e.length;
|
|
4050
4123
|
for (let o = 0; o < n; ) {
|
|
4051
4124
|
const i = Math.min(s - this.pos, n - o);
|
|
@@ -4063,7 +4136,7 @@ class mt {
|
|
|
4063
4136
|
e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
|
|
4064
4137
|
}
|
|
4065
4138
|
writeInto(e) {
|
|
4066
|
-
|
|
4139
|
+
ke(this, !1), V(e), this.finish();
|
|
4067
4140
|
const s = this.state, { blockLen: t } = this;
|
|
4068
4141
|
for (let n = 0, o = e.length; n < o; ) {
|
|
4069
4142
|
this.posOut >= t && this.keccak();
|
|
@@ -4078,10 +4151,10 @@ class mt {
|
|
|
4078
4151
|
return this.writeInto(e);
|
|
4079
4152
|
}
|
|
4080
4153
|
xof(e) {
|
|
4081
|
-
return
|
|
4154
|
+
return ge(e), this.xofInto(new Uint8Array(e));
|
|
4082
4155
|
}
|
|
4083
4156
|
digestInto(e) {
|
|
4084
|
-
if (
|
|
4157
|
+
if (ss(e, this), this.finished)
|
|
4085
4158
|
throw new Error("digest() was already called");
|
|
4086
4159
|
return this.writeInto(e), this.destroy(), e;
|
|
4087
4160
|
}
|
|
@@ -4089,36 +4162,64 @@ class mt {
|
|
|
4089
4162
|
return this.digestInto(new Uint8Array(this.outputLen));
|
|
4090
4163
|
}
|
|
4091
4164
|
destroy() {
|
|
4092
|
-
this.destroyed = !0,
|
|
4165
|
+
this.destroyed = !0, Pe(this.state);
|
|
4093
4166
|
}
|
|
4094
4167
|
_cloneInto(e) {
|
|
4095
4168
|
const { blockLen: s, suffix: t, outputLen: n, rounds: o, enableXOF: i } = this;
|
|
4096
4169
|
return e || (e = new mt(s, t, n, i, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = t, e.outputLen = n, e.enableXOF = i, e.destroyed = this.destroyed, e;
|
|
4097
4170
|
}
|
|
4098
4171
|
}
|
|
4099
|
-
const dn = (r, e, s, t = {}) =>
|
|
4100
|
-
class
|
|
4172
|
+
const dn = (r, e, s, t = {}) => ns(() => new mt(e, r, s), t), zt = /* @__PURE__ */ dn(1, 136, 32), un = 60;
|
|
4173
|
+
class hn {
|
|
4174
|
+
constructor() {
|
|
4175
|
+
this.jwks = null;
|
|
4176
|
+
}
|
|
4177
|
+
setJWKSEndpoint(e) {
|
|
4178
|
+
try {
|
|
4179
|
+
this.jwks = Ms(new URL(e)), u.log("[CROSSx] JWKS 엔드포인트 설정:", e);
|
|
4180
|
+
} catch (s) {
|
|
4181
|
+
u.warn("[CROSSx] JWKS 엔드포인트 URL 파싱 실패:", s);
|
|
4182
|
+
}
|
|
4183
|
+
}
|
|
4101
4184
|
async verifyJWT(e, s) {
|
|
4102
4185
|
try {
|
|
4103
4186
|
const t = this.decodeJWT(e);
|
|
4104
4187
|
u.log("[CROSSx] JWT 디코딩 성공:", {
|
|
4105
4188
|
sub: t.sub,
|
|
4106
4189
|
exp: t.exp,
|
|
4107
|
-
iat: t.iat
|
|
4108
|
-
"현재 시간": Math.floor(Date.now() / 1e3)
|
|
4190
|
+
iat: t.iat
|
|
4109
4191
|
});
|
|
4110
4192
|
const n = Math.floor(Date.now() / 1e3);
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4193
|
+
if (t.exp && t.exp + un < n)
|
|
4194
|
+
return u.warn("[CROSSx] 토큰 만료:", {
|
|
4195
|
+
exp: t.exp,
|
|
4196
|
+
now: n,
|
|
4197
|
+
만료시간: new Date(t.exp * 1e3).toISOString()
|
|
4198
|
+
}), { payload: t, valid: !1, signatureVerified: !1 };
|
|
4199
|
+
if (!t.sub)
|
|
4200
|
+
return u.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 };
|
|
4201
|
+
if (this.jwks)
|
|
4202
|
+
try {
|
|
4203
|
+
const { payload: o } = await $s(e, this.jwks, {
|
|
4204
|
+
algorithms: ["RS256", "ES256"]
|
|
4205
|
+
});
|
|
4206
|
+
return u.log("[CROSSx] JWT 서명 검증 성공"), {
|
|
4207
|
+
payload: o,
|
|
4208
|
+
valid: !0,
|
|
4209
|
+
signatureVerified: !0
|
|
4210
|
+
};
|
|
4211
|
+
} catch (o) {
|
|
4212
|
+
if (o instanceof Error && (o.name === "JWSSignatureVerificationFailed" || o.name === "JWTClaimValidationFailed"))
|
|
4213
|
+
return u.error("[CROSSx] JWT 서명 검증 실패:", o), { payload: t, valid: !1, signatureVerified: !1 };
|
|
4214
|
+
u.warn("[CROSSx] JWKS 엔드포인트 접근 불가 — 서명 미검증 모드로 전환");
|
|
4215
|
+
}
|
|
4216
|
+
return u.log("[CROSSx] JWT 검증 성공 (서명 미검증 — JWKS 미설정 또는 접근 불가)"), { payload: t, valid: !0, signatureVerified: !1 };
|
|
4116
4217
|
} catch (t) {
|
|
4117
4218
|
throw u.error("[CROSSx] JWT 검증 중 에러:", t), t;
|
|
4118
4219
|
}
|
|
4119
4220
|
}
|
|
4120
4221
|
decodeJWT(e) {
|
|
4121
|
-
return
|
|
4222
|
+
return Bs(e);
|
|
4122
4223
|
}
|
|
4123
4224
|
/**
|
|
4124
4225
|
* EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
|
|
@@ -4133,34 +4234,48 @@ class un {
|
|
|
4133
4234
|
${t.length}`
|
|
4134
4235
|
), o = new Uint8Array(n.length + t.length);
|
|
4135
4236
|
o.set(n, 0), o.set(t, n.length);
|
|
4136
|
-
const i =
|
|
4237
|
+
const i = zt(o), a = s.startsWith("0x") ? s.slice(2) : s;
|
|
4137
4238
|
if (a.length !== 130)
|
|
4138
4239
|
throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
|
|
4139
|
-
const c =
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
).addRecoveryBit(m).recoverPublicKey(i).toBytes(!1).slice(1), y =
|
|
4240
|
+
const c = pn(a), l = c.slice(0, 32), d = c.slice(32, 64), h = c[64], m = h >= 27 ? h - 27 : h, E = new en.Signature(
|
|
4241
|
+
jt(l),
|
|
4242
|
+
jt(d)
|
|
4243
|
+
).addRecoveryBit(m).recoverPublicKey(i).toBytes(!1).slice(1), y = zt(E);
|
|
4143
4244
|
return "0x" + Me(y.slice(12));
|
|
4144
4245
|
}
|
|
4145
4246
|
}
|
|
4146
|
-
function
|
|
4247
|
+
function pn(r) {
|
|
4147
4248
|
const e = new Uint8Array(r.length / 2);
|
|
4148
4249
|
for (let s = 0; s < e.length; s++)
|
|
4149
4250
|
e[s] = parseInt(r.substring(s * 2, s * 2 + 2), 16);
|
|
4150
4251
|
return e;
|
|
4151
4252
|
}
|
|
4152
|
-
function
|
|
4253
|
+
function jt(r) {
|
|
4153
4254
|
let e = "0x";
|
|
4154
4255
|
for (const s of r) e += s.toString(16).padStart(2, "0");
|
|
4155
4256
|
return BigInt(e);
|
|
4156
4257
|
}
|
|
4157
|
-
const
|
|
4158
|
-
class
|
|
4258
|
+
const fn = 3e4, _n = 1e3;
|
|
4259
|
+
class xn {
|
|
4159
4260
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4160
4261
|
async request(e) {
|
|
4262
|
+
const s = e.retries ?? 0;
|
|
4263
|
+
for (let t = 0; t <= s; t++) {
|
|
4264
|
+
try {
|
|
4265
|
+
const n = await this._doRequest(e);
|
|
4266
|
+
if (n.status < 500 || t === s) return n;
|
|
4267
|
+
} catch (n) {
|
|
4268
|
+
if (t === s) throw n;
|
|
4269
|
+
}
|
|
4270
|
+
await new Promise((n) => setTimeout(n, _n * 2 ** t));
|
|
4271
|
+
}
|
|
4272
|
+
throw new Error("Unexpected: retry loop exited without result");
|
|
4273
|
+
}
|
|
4274
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4275
|
+
async _doRequest(e) {
|
|
4161
4276
|
const s = new AbortController(), t = setTimeout(
|
|
4162
4277
|
() => s.abort(),
|
|
4163
|
-
e.timeoutMs ??
|
|
4278
|
+
e.timeoutMs ?? fn
|
|
4164
4279
|
);
|
|
4165
4280
|
try {
|
|
4166
4281
|
const n = await fetch(e.url, {
|
|
@@ -4187,6 +4302,11 @@ class fn {
|
|
|
4187
4302
|
}
|
|
4188
4303
|
}
|
|
4189
4304
|
}
|
|
4305
|
+
const gn = /* @__PURE__ */ new Set([
|
|
4306
|
+
"https://cross-wallet-oauth.crosstoken.io",
|
|
4307
|
+
"https://stg-cross-wallet-oauth.crosstoken.io",
|
|
4308
|
+
"https://dev-cross-wallet-oauth.crosstoken.io"
|
|
4309
|
+
]);
|
|
4190
4310
|
class be {
|
|
4191
4311
|
static generateRandom16Hex() {
|
|
4192
4312
|
const e = new Uint8Array(16);
|
|
@@ -4269,7 +4389,7 @@ class be {
|
|
|
4269
4389
|
u.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), b(), t(new Error("Authentication timeout"));
|
|
4270
4390
|
}, 5 * 60 * 1e3), w = 10, E = 30;
|
|
4271
4391
|
let y = 0, S = null;
|
|
4272
|
-
const
|
|
4392
|
+
const C = () => {
|
|
4273
4393
|
clearInterval(B), u.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + E + "초간 대기합니다"), S = setTimeout(() => {
|
|
4274
4394
|
b(), t(new Error(
|
|
4275
4395
|
"OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
|
|
@@ -4278,42 +4398,51 @@ class be {
|
|
|
4278
4398
|
}, B = setInterval(() => {
|
|
4279
4399
|
y++;
|
|
4280
4400
|
try {
|
|
4281
|
-
m.closed && (y <= w ?
|
|
4401
|
+
m.closed && (y <= w ? C() : (b(), t(new Error("로그인이 취소되었습니다"))));
|
|
4282
4402
|
} catch {
|
|
4283
|
-
|
|
4403
|
+
C();
|
|
4284
4404
|
}
|
|
4285
4405
|
}, 1e3), b = () => {
|
|
4286
|
-
clearTimeout(x), clearInterval(B), S && clearTimeout(S), window.removeEventListener("message",
|
|
4287
|
-
},
|
|
4288
|
-
var
|
|
4289
|
-
if (
|
|
4290
|
-
|
|
4291
|
-
|
|
4406
|
+
clearTimeout(x), clearInterval(B), S && clearTimeout(S), window.removeEventListener("message", k);
|
|
4407
|
+
}, k = (P) => {
|
|
4408
|
+
var z, W, q, D, R;
|
|
4409
|
+
if (P.origin !== e.expectedOrigin) return;
|
|
4410
|
+
if (!gn.has(P.origin)) {
|
|
4411
|
+
u.error("[CROSSx] postMessage origin이 허용 목록에 없음:", P.origin), b(), t(new Error("Unauthorized OAuth origin"));
|
|
4412
|
+
return;
|
|
4413
|
+
}
|
|
4414
|
+
b(), u.log("[CROSSx] OAuth postMessage 수신 — status:", P.data.status);
|
|
4415
|
+
const G = P.data.state ?? ((z = P.data.data) == null ? void 0 : z.state);
|
|
4292
4416
|
if (!G || G !== c) {
|
|
4293
4417
|
t(new Error("OAuth state mismatch — possible CSRF attack"));
|
|
4294
4418
|
return;
|
|
4295
4419
|
}
|
|
4296
|
-
if (
|
|
4297
|
-
const
|
|
4420
|
+
if (P.data.status === "success") {
|
|
4421
|
+
const N = (W = P.data.data) == null ? void 0 : W.idToken, f = (q = P.data.data) == null ? void 0 : q.accessToken, _ = f ?? N;
|
|
4298
4422
|
if (u.log("[CROSSx] OAuth 토큰 수신:", {
|
|
4299
4423
|
hasAccessToken: !!f,
|
|
4300
|
-
hasIdToken: !!
|
|
4424
|
+
hasIdToken: !!N
|
|
4301
4425
|
}), !_) {
|
|
4302
|
-
u.error("[CROSSx] 토큰을 찾을 수 없음:",
|
|
4426
|
+
u.error("[CROSSx] 토큰을 찾을 수 없음:", P.data), t(new Error("Token not found in response"));
|
|
4303
4427
|
return;
|
|
4304
4428
|
}
|
|
4305
|
-
|
|
4429
|
+
N ? be.verifyIdTokenNonce(N, l).then(() => s(_)).catch((v) => {
|
|
4306
4430
|
u.error("[CROSSx] nonce 검증 실패:", v), t(v instanceof Error ? v : new Error("nonce verification failed"));
|
|
4307
|
-
}) : s(_)
|
|
4431
|
+
}) : f ? f.split(".").length === 3 ? be.verifyIdTokenNonce(f, l).then(() => s(_)).catch((I) => {
|
|
4432
|
+
u.error("[CROSSx] accessToken nonce 검증 실패:", I), t(I instanceof Error ? I : new Error("nonce verification failed"));
|
|
4433
|
+
}) : (u.warn(
|
|
4434
|
+
"[CROSSx] opaque accessToken만 수신 (idToken 없음) — nonce 검증 불가.",
|
|
4435
|
+
"서버 측 nonce 검증이 필요합니다."
|
|
4436
|
+
), s(_)) : t(new Error("Token not found in response"));
|
|
4308
4437
|
} else
|
|
4309
|
-
u.error("[CROSSx] OAuth 실패:", (D =
|
|
4438
|
+
u.error("[CROSSx] OAuth 실패:", (D = P.data.data) == null ? void 0 : D.error), t(new Error(((R = P.data.data) == null ? void 0 : R.error) || "Authentication failed"));
|
|
4310
4439
|
};
|
|
4311
|
-
window.addEventListener("message",
|
|
4440
|
+
window.addEventListener("message", k);
|
|
4312
4441
|
});
|
|
4313
4442
|
}
|
|
4314
4443
|
}
|
|
4315
|
-
const
|
|
4316
|
-
class
|
|
4444
|
+
const Ce = "crossx_wallet_data", Ae = "crossx_mock_pin_hash";
|
|
4445
|
+
class mn {
|
|
4317
4446
|
constructor(e, s) {
|
|
4318
4447
|
this.storage = e, this.pinStore = s ?? null;
|
|
4319
4448
|
}
|
|
@@ -4326,13 +4455,13 @@ class _n {
|
|
|
4326
4455
|
async checkWallet() {
|
|
4327
4456
|
if (this.migrateScenario !== void 0)
|
|
4328
4457
|
return u.log("[Mock] checkWallet → migration_required"), "migration_required";
|
|
4329
|
-
const s = await this.storage.get(
|
|
4458
|
+
const s = await this.storage.get(Ce) ? "exists" : "not_found";
|
|
4330
4459
|
return u.log(`[Mock] checkWallet → ${s}`), s;
|
|
4331
4460
|
}
|
|
4332
4461
|
async getOrCreateWallet(e) {
|
|
4333
4462
|
var s;
|
|
4334
4463
|
try {
|
|
4335
|
-
const t = await this.storage.get(
|
|
4464
|
+
const t = await this.storage.get(Ce);
|
|
4336
4465
|
if (t) return t;
|
|
4337
4466
|
const n = {
|
|
4338
4467
|
id: e,
|
|
@@ -4340,16 +4469,16 @@ class _n {
|
|
|
4340
4469
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
4341
4470
|
createdAt: Date.now()
|
|
4342
4471
|
};
|
|
4343
|
-
await this.storage.set(
|
|
4472
|
+
await this.storage.set(Ce, n);
|
|
4344
4473
|
const o = (s = this.pinStore) == null ? void 0 : s.get();
|
|
4345
|
-
return o && (await this.storage.set(
|
|
4474
|
+
return o && (await this.storage.set(Ae, o), u.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
|
|
4346
4475
|
} catch (t) {
|
|
4347
4476
|
throw new g(p.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", t);
|
|
4348
4477
|
}
|
|
4349
4478
|
}
|
|
4350
4479
|
/** GET /mnemonic/addresses 모킹 — PIN 불필요, 캐시된 주소 반환 */
|
|
4351
4480
|
async getAddresses(e) {
|
|
4352
|
-
const s = await this.storage.get(
|
|
4481
|
+
const s = await this.storage.get(Ce);
|
|
4353
4482
|
return s ? [{ address: s.address, index: 0 }] : [];
|
|
4354
4483
|
}
|
|
4355
4484
|
async getAddress(e, s) {
|
|
@@ -4384,8 +4513,8 @@ class _n {
|
|
|
4384
4513
|
var t;
|
|
4385
4514
|
if (u.log("[Mock] verifyPin"), this.pinScenario === "wrong")
|
|
4386
4515
|
return !1;
|
|
4387
|
-
const s = await this.storage.get(
|
|
4388
|
-
return s && s !== e ? !1 : (s || await this.storage.set(
|
|
4516
|
+
const s = await this.storage.get(Ae);
|
|
4517
|
+
return s && s !== e ? !1 : (s || await this.storage.set(Ae, e), (t = this.pinStore) == null || t.set(e), u.log("[Mock] verifyPin → 성공"), !0);
|
|
4389
4518
|
}
|
|
4390
4519
|
/**
|
|
4391
4520
|
* POST /mnemonic/change-password 모킹
|
|
@@ -4395,10 +4524,10 @@ class _n {
|
|
|
4395
4524
|
var o;
|
|
4396
4525
|
if (u.log("[Mock] changePin"), this.pinScenario === "wrong")
|
|
4397
4526
|
throw new g(p.PIN_WRONG, "Incorrect PIN.");
|
|
4398
|
-
const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(
|
|
4527
|
+
const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Ae);
|
|
4399
4528
|
if (n && t && n !== t)
|
|
4400
4529
|
throw new g(p.PIN_WRONG, "Incorrect PIN.");
|
|
4401
|
-
await this.storage.set(
|
|
4530
|
+
await this.storage.set(Ae, s), u.log("[Mock] changePin 완료");
|
|
4402
4531
|
}
|
|
4403
4532
|
async migrateWallet(e, s) {
|
|
4404
4533
|
var o;
|
|
@@ -4429,9 +4558,9 @@ class _n {
|
|
|
4429
4558
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
4430
4559
|
createdAt: Date.now()
|
|
4431
4560
|
};
|
|
4432
|
-
await this.storage.set(
|
|
4561
|
+
await this.storage.set(Ce, t);
|
|
4433
4562
|
const n = (o = this.pinStore) == null ? void 0 : o.get();
|
|
4434
|
-
return n && (await this.storage.set(
|
|
4563
|
+
return n && (await this.storage.set(Ae, n), u.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
|
|
4435
4564
|
}
|
|
4436
4565
|
/**
|
|
4437
4566
|
* POST /mnemonic/share-c 모킹
|
|
@@ -4505,7 +4634,7 @@ class Le {
|
|
|
4505
4634
|
method: e
|
|
4506
4635
|
});
|
|
4507
4636
|
const m = Le.mapGatewayError(d.code, d.data), x = Le.getGatewayErrorMessage(d.code, h), w = d.data, E = m === p.PIN_LOCKED ? Le.extractLockDetails(w) : w ?? void 0, y = new g(m, x, E);
|
|
4508
|
-
throw
|
|
4637
|
+
throw m === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (u.warn("[CROSSx] Gateway -10002 감지 — 강제 로그아웃 실행"), this._onUnauthorized()), y;
|
|
4509
4638
|
}
|
|
4510
4639
|
return u.log("[CROSSx] Wallet Gateway API 성공:", { code: d.code, url: o, method: e }), d.data ?? d;
|
|
4511
4640
|
}
|
|
@@ -4840,7 +4969,7 @@ class De {
|
|
|
4840
4969
|
}
|
|
4841
4970
|
isCacheValid() {
|
|
4842
4971
|
if (this.loadedAt === 0) return !1;
|
|
4843
|
-
const e = this.usingFallback ?
|
|
4972
|
+
const e = this.usingFallback ? sr : tr;
|
|
4844
4973
|
return e === 0 ? !0 : Date.now() - this.loadedAt < e;
|
|
4845
4974
|
}
|
|
4846
4975
|
populateCache(e, s) {
|
|
@@ -4878,7 +5007,7 @@ class De {
|
|
|
4878
5007
|
);
|
|
4879
5008
|
}
|
|
4880
5009
|
static fallbackChains() {
|
|
4881
|
-
return Object.values(
|
|
5010
|
+
return Object.values(Ve).map((e) => ({
|
|
4882
5011
|
chainId: e.caipId,
|
|
4883
5012
|
rpcUrl: e.rpcUrl
|
|
4884
5013
|
}));
|
|
@@ -4902,7 +5031,7 @@ class De {
|
|
|
4902
5031
|
}
|
|
4903
5032
|
}
|
|
4904
5033
|
}
|
|
4905
|
-
const
|
|
5034
|
+
const Yt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", wn = {
|
|
4906
5035
|
light: {
|
|
4907
5036
|
bg: "#FFFFFF",
|
|
4908
5037
|
border: "rgba(18,18,18,0.05)",
|
|
@@ -4958,8 +5087,8 @@ const Kt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", xn = {
|
|
|
4958
5087
|
onPrimary: "#FFFFFF"
|
|
4959
5088
|
}
|
|
4960
5089
|
};
|
|
4961
|
-
function
|
|
4962
|
-
const s =
|
|
5090
|
+
function Jt(r, e) {
|
|
5091
|
+
const s = wn[r], t = e == null ? void 0 : e[r];
|
|
4963
5092
|
return t ? {
|
|
4964
5093
|
...s,
|
|
4965
5094
|
// ── Brand
|
|
@@ -4991,7 +5120,7 @@ function jt(r, e) {
|
|
|
4991
5120
|
...t.error !== void 0 && { errorColor: t.error }
|
|
4992
5121
|
} : s;
|
|
4993
5122
|
}
|
|
4994
|
-
const
|
|
5123
|
+
const yn = `
|
|
4995
5124
|
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
|
|
4996
5125
|
|
|
4997
5126
|
#${te} {
|
|
@@ -5004,6 +5133,7 @@ const gn = `
|
|
|
5004
5133
|
background: rgba(0,0,0,0.55);
|
|
5005
5134
|
font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
5006
5135
|
animation: __crossx-fade-in 0.15s ease;
|
|
5136
|
+
pointer-events: auto;
|
|
5007
5137
|
}
|
|
5008
5138
|
@keyframes __crossx-fade-in {
|
|
5009
5139
|
from { opacity: 0; }
|
|
@@ -6643,14 +6773,20 @@ const gn = `
|
|
|
6643
6773
|
cursor: default;
|
|
6644
6774
|
}
|
|
6645
6775
|
`;
|
|
6646
|
-
function
|
|
6647
|
-
let r = document.getElementById(
|
|
6648
|
-
r || (r = document.createElement("style"), r.id =
|
|
6776
|
+
function he() {
|
|
6777
|
+
let r = document.getElementById(Yt);
|
|
6778
|
+
r || (r = document.createElement("style"), r.id = Yt, document.head.appendChild(r)), r.textContent = yn;
|
|
6779
|
+
}
|
|
6780
|
+
function pe(r) {
|
|
6781
|
+
const e = (s) => s.stopPropagation();
|
|
6782
|
+
for (const s of ["pointerdown", "pointerup", "mousedown", "mouseup", "click", "touchstart", "touchend"])
|
|
6783
|
+
r.addEventListener(s, e);
|
|
6784
|
+
document.body.appendChild(r);
|
|
6649
6785
|
}
|
|
6650
6786
|
function se(r) {
|
|
6651
6787
|
return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
|
|
6652
6788
|
}
|
|
6653
|
-
function
|
|
6789
|
+
function bn(r, e = "CROSS", s = 18) {
|
|
6654
6790
|
if (!r || r === "0x" || r === "0x0") return null;
|
|
6655
6791
|
try {
|
|
6656
6792
|
const t = BigInt(r);
|
|
@@ -6661,7 +6797,7 @@ function mn(r, e = "CROSS", s = 18) {
|
|
|
6661
6797
|
return null;
|
|
6662
6798
|
}
|
|
6663
6799
|
}
|
|
6664
|
-
const
|
|
6800
|
+
const Zt = {
|
|
6665
6801
|
1: "Ethereum Mainnet",
|
|
6666
6802
|
5: "Goerli Testnet",
|
|
6667
6803
|
11155111: "Ethereum Sepolia",
|
|
@@ -6684,9 +6820,9 @@ const Yt = {
|
|
|
6684
6820
|
612044: "CROSS Testnet",
|
|
6685
6821
|
612055: "CROSS Mainnet"
|
|
6686
6822
|
};
|
|
6687
|
-
function
|
|
6823
|
+
function Ns(r) {
|
|
6688
6824
|
const e = parseInt(r.split(":")[1] ?? "", 10);
|
|
6689
|
-
return !isNaN(e) &&
|
|
6825
|
+
return !isNaN(e) && Zt[e] ? Zt[e] : r;
|
|
6690
6826
|
}
|
|
6691
6827
|
function dt(r, e) {
|
|
6692
6828
|
if (r === 0n) return "0";
|
|
@@ -6701,18 +6837,18 @@ function rt(r) {
|
|
|
6701
6837
|
return r;
|
|
6702
6838
|
}
|
|
6703
6839
|
}
|
|
6704
|
-
function
|
|
6840
|
+
function vn(r) {
|
|
6705
6841
|
try {
|
|
6706
6842
|
return BigInt(r).toLocaleString();
|
|
6707
6843
|
} catch {
|
|
6708
6844
|
return r;
|
|
6709
6845
|
}
|
|
6710
6846
|
}
|
|
6711
|
-
function
|
|
6847
|
+
function Sn(r) {
|
|
6712
6848
|
const { gasLimit: e, gasPrice: s, maxFeePerGas: t, maxPriorityFeePerGas: n, nativeSymbol: o = "ETH", nativeDecimals: i = 18 } = r;
|
|
6713
6849
|
if (!e) return null;
|
|
6714
6850
|
try {
|
|
6715
|
-
const a = BigInt(e), c =
|
|
6851
|
+
const a = BigInt(e), c = vn(e);
|
|
6716
6852
|
if (t) {
|
|
6717
6853
|
const l = a * BigInt(t);
|
|
6718
6854
|
return {
|
|
@@ -6737,28 +6873,28 @@ function yn(r) {
|
|
|
6737
6873
|
return null;
|
|
6738
6874
|
}
|
|
6739
6875
|
}
|
|
6740
|
-
function
|
|
6741
|
-
const e =
|
|
6876
|
+
function Os(r) {
|
|
6877
|
+
const e = Sn(r);
|
|
6742
6878
|
if (!e) return Y("Estimated fee", "<span>—</span>");
|
|
6743
6879
|
let s = Y("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
|
|
6744
6880
|
return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s += Y("Max Priority Fee", `<span>${e.maxPriorityFeeGwei} Gwei</span>`)), e.maxFeeGwei !== void 0 && (s += Y("Max Gas Fee", `<span>${e.maxFeeGwei} Gwei</span>`))) : e.gasPriceGwei !== void 0 && (s += Y("Gas Price", `<span>${e.gasPriceGwei} Gwei</span>`)), e.gasLimitFormatted && (s += Y("Gas Limit", `<span>${e.gasLimitFormatted}</span>`)), s;
|
|
6745
6881
|
}
|
|
6746
|
-
const
|
|
6882
|
+
const xe = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
6747
6883
|
<rect x="9" y="9" width="13" height="13" rx="2"/>
|
|
6748
6884
|
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
|
|
6749
6885
|
</svg>`, ie = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
|
|
6750
6886
|
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
6751
6887
|
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
6752
|
-
</svg>`,
|
|
6888
|
+
</svg>`, En = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6753
6889
|
<circle cx="20" cy="20" r="20" fill="#00D5AA"/>
|
|
6754
6890
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.3225 2.85742L23.7249 6.25982V11.8301L28.1175 7.43757L32.9292 12.2493L28.5806 16.5979H20.3225C18.4435 16.5979 16.9201 18.1212 16.9201 20.0003C16.9201 21.8794 18.4434 23.4027 20.3225 23.4027H28.5372L32.9293 27.7948L28.1176 32.6066L23.7249 28.2139V33.7407L20.3225 37.1431L16.9201 33.7407V28.2584L12.5719 32.6066L7.76022 27.7948L12.1524 23.4027H6.58209L3.17969 20.0003L6.58209 16.5979H12.1089L7.76035 12.2493L12.5721 7.43757L16.9201 11.7857V6.25982L20.3225 2.85742Z" fill="#121212"/>
|
|
6755
6891
|
</svg>`, wt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
6756
6892
|
<rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
|
|
6757
6893
|
<path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
|
|
6758
6894
|
<rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
|
|
6759
|
-
</svg>`,
|
|
6895
|
+
</svg>`, In = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
6760
6896
|
<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="var(--cx-error)"/>
|
|
6761
|
-
</svg>`,
|
|
6897
|
+
</svg>`, Tn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
6762
6898
|
<circle cx="12" cy="12" r="12" fill="var(--cx-error)"/>
|
|
6763
6899
|
<circle cx="12" cy="12" r="5.5" stroke="white" stroke-width="1.5"/>
|
|
6764
6900
|
<path d="M12 9.5v3l2 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
|
|
@@ -6796,9 +6932,9 @@ function Y(r, e) {
|
|
|
6796
6932
|
<div class="__crossx-row-value">${e}</div>
|
|
6797
6933
|
</div>`;
|
|
6798
6934
|
}
|
|
6799
|
-
function
|
|
6800
|
-
const s = e, t =
|
|
6801
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${
|
|
6935
|
+
function An(r, e) {
|
|
6936
|
+
const s = e, t = Ye(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
6937
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", o = Os(r), i = r.data ?? "0x", a = document.createElement("div");
|
|
6802
6938
|
return a.id = te, a.innerHTML = `
|
|
6803
6939
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
6804
6940
|
<div class="__crossx-header">
|
|
@@ -6822,7 +6958,7 @@ function In(r, e) {
|
|
|
6822
6958
|
<div class="__crossx-col-right-sign">
|
|
6823
6959
|
<div class="__crossx-rows">
|
|
6824
6960
|
${Y("To", n)}
|
|
6825
|
-
${Y("Network", `<span>${
|
|
6961
|
+
${Y("Network", `<span>${Ns(r.chainId)}</span>`)}
|
|
6826
6962
|
${o}
|
|
6827
6963
|
</div>
|
|
6828
6964
|
<pre class="__crossx-raw-tx">${U(i)}</pre>
|
|
@@ -6836,9 +6972,9 @@ function In(r, e) {
|
|
|
6836
6972
|
</div>
|
|
6837
6973
|
`, a;
|
|
6838
6974
|
}
|
|
6839
|
-
function
|
|
6840
|
-
const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o =
|
|
6841
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${
|
|
6975
|
+
function Rn(r, e) {
|
|
6976
|
+
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>
|
|
6977
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", a = Os(r), l = bn(r.value, t, n) ?? "—", d = document.createElement("div");
|
|
6842
6978
|
return d.id = te, d.innerHTML = `
|
|
6843
6979
|
<div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
6844
6980
|
<div class="__crossx-header">
|
|
@@ -6853,7 +6989,7 @@ function En(r, e) {
|
|
|
6853
6989
|
<div class="__crossx-body-cols">
|
|
6854
6990
|
<div class="__crossx-rows">
|
|
6855
6991
|
${Y("To", i)}
|
|
6856
|
-
${Y("Network", `<span>${
|
|
6992
|
+
${Y("Network", `<span>${Ns(r.chainId)}</span>`)}
|
|
6857
6993
|
${a}
|
|
6858
6994
|
</div>
|
|
6859
6995
|
<div class="__crossx-pill">
|
|
@@ -6866,7 +7002,7 @@ function En(r, e) {
|
|
|
6866
7002
|
</div>
|
|
6867
7003
|
`, d;
|
|
6868
7004
|
}
|
|
6869
|
-
function
|
|
7005
|
+
function Ye(r) {
|
|
6870
7006
|
var e;
|
|
6871
7007
|
if (r) return r;
|
|
6872
7008
|
try {
|
|
@@ -6878,10 +7014,10 @@ function Je(r) {
|
|
|
6878
7014
|
function U(r) {
|
|
6879
7015
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
6880
7016
|
}
|
|
6881
|
-
function
|
|
7017
|
+
function kn(r) {
|
|
6882
7018
|
return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
|
|
6883
7019
|
}
|
|
6884
|
-
function
|
|
7020
|
+
function Pn(r) {
|
|
6885
7021
|
if (typeof r == "string") return U(r);
|
|
6886
7022
|
if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
|
|
6887
7023
|
try {
|
|
@@ -6890,14 +7026,14 @@ function An(r) {
|
|
|
6890
7026
|
return String(r);
|
|
6891
7027
|
}
|
|
6892
7028
|
}
|
|
6893
|
-
function
|
|
7029
|
+
function Nn(r, e) {
|
|
6894
7030
|
const s = Y(
|
|
6895
7031
|
"From",
|
|
6896
7032
|
`<span class="__crossx-addr-text">${se(r.from)}</span>
|
|
6897
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.from)}" title="Copy address">${
|
|
7033
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.from)}" title="Copy address">${xe}</button>`
|
|
6898
7034
|
), t = r.to ? Y("To", `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
6899
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${
|
|
6900
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.txHash)}" title="Copy hash">${
|
|
7035
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>`) : "", n = r.amount ? Y("Transfer", `<span>${U(r.amount)}</span>`) : "", o = r.fees ? Y("Tx Fee", `<span>${U(r.fees)}</span>`) : "", i = r.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(r.txHash)}</span>
|
|
7036
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.txHash)}" title="Copy hash">${xe}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
|
|
6901
7037
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
6902
7038
|
<span class="__crossx-total-amount">${U(r.total)}</span>
|
|
6903
7039
|
</div>` : "", c = document.createElement("div");
|
|
@@ -6922,7 +7058,7 @@ function kn(r, e) {
|
|
|
6922
7058
|
</div>
|
|
6923
7059
|
`, c;
|
|
6924
7060
|
}
|
|
6925
|
-
function
|
|
7061
|
+
function On(r, e) {
|
|
6926
7062
|
const s = document.createElement("div");
|
|
6927
7063
|
return s.id = te, s.innerHTML = `
|
|
6928
7064
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -6939,10 +7075,10 @@ function Pn(r, e) {
|
|
|
6939
7075
|
</div>
|
|
6940
7076
|
`, s;
|
|
6941
7077
|
}
|
|
6942
|
-
function
|
|
7078
|
+
function Cn(r, e, s) {
|
|
6943
7079
|
const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
|
|
6944
7080
|
if (o) {
|
|
6945
|
-
const w = n ?
|
|
7081
|
+
const w = n ? Tn : t ? "" : In, E = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
|
|
6946
7082
|
w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${E}</span>`) : o.textContent = E;
|
|
6947
7083
|
}
|
|
6948
7084
|
if (i && !r.querySelector("#__crossx-close-btn")) {
|
|
@@ -6952,9 +7088,9 @@ function Nn(r, e, s) {
|
|
|
6952
7088
|
const a = r.querySelector("#__crossx-progress-body");
|
|
6953
7089
|
if (!a) return;
|
|
6954
7090
|
const c = e.from ? Y("From", `<span class="__crossx-addr-text">${se(e.from)}</span>
|
|
6955
|
-
<button class="__crossx-copy-btn" data-copy="${U(e.from)}" title="Copy address">${
|
|
6956
|
-
<button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${
|
|
6957
|
-
<button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${
|
|
7091
|
+
<button class="__crossx-copy-btn" data-copy="${U(e.from)}" title="Copy address">${xe}</button>`) : "", l = e.to ? Y("To", `<span class="__crossx-addr-text">${se(e.to)}</span>
|
|
7092
|
+
<button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${xe}</button>`) : "", d = e.amount ? Y("Transfer", `<span>${U(e.amount)}</span>`) : "", h = e.fees ? Y("Tx Fee", `<span>${U(e.fees)}</span>`) : "", m = e.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(e.txHash)}</span>
|
|
7093
|
+
<button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${xe}</button>`) : "", x = e.total ? `<div class="__crossx-total-pill">
|
|
6958
7094
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
6959
7095
|
<span class="__crossx-total-amount">${U(e.total)}</span>
|
|
6960
7096
|
</div>` : "";
|
|
@@ -6978,8 +7114,8 @@ function Nn(r, e, s) {
|
|
|
6978
7114
|
});
|
|
6979
7115
|
});
|
|
6980
7116
|
}
|
|
6981
|
-
function
|
|
6982
|
-
const s = e, t =
|
|
7117
|
+
function Ln(r, e) {
|
|
7118
|
+
const s = e, t = Ye(r.dappName), n = U(r.message), o = document.createElement("div");
|
|
6983
7119
|
return o.id = te, o.innerHTML = `
|
|
6984
7120
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
6985
7121
|
<div class="__crossx-header">
|
|
@@ -7010,8 +7146,8 @@ function Rn(r, e) {
|
|
|
7010
7146
|
</div>
|
|
7011
7147
|
`, o;
|
|
7012
7148
|
}
|
|
7013
|
-
function
|
|
7014
|
-
const s = e, t =
|
|
7149
|
+
function Dn(r, e) {
|
|
7150
|
+
const s = e, t = Ye(r.dappName);
|
|
7015
7151
|
let n = {};
|
|
7016
7152
|
if (typeof r.typedData == "string")
|
|
7017
7153
|
try {
|
|
@@ -7026,8 +7162,8 @@ function Cn(r, e) {
|
|
|
7026
7162
|
<span class="__crossx-td-value">${U(o)}</span>
|
|
7027
7163
|
</div>`;
|
|
7028
7164
|
for (const [l, d] of Object.entries(i)) {
|
|
7029
|
-
const h =
|
|
7030
|
-
<button class="__crossx-copy-btn" data-copy="${U(String(d))}" title="Copy">${
|
|
7165
|
+
const h = Pn(d), x = kn(d) ? `<span class="__crossx-addr-text">${se(d)}</span>
|
|
7166
|
+
<button class="__crossx-copy-btn" data-copy="${U(String(d))}" title="Copy">${xe}</button>` : `<span>${h}</span>`;
|
|
7031
7167
|
a += `
|
|
7032
7168
|
<div class="__crossx-td-row">
|
|
7033
7169
|
<span class="__crossx-td-label">${U(l)}</span>
|
|
@@ -7065,11 +7201,11 @@ function Cn(r, e) {
|
|
|
7065
7201
|
</div>
|
|
7066
7202
|
`, c;
|
|
7067
7203
|
}
|
|
7068
|
-
const
|
|
7204
|
+
const Mn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
7069
7205
|
<line x1="12" y1="5" x2="12" y2="19"/>
|
|
7070
7206
|
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
7071
7207
|
</svg>`;
|
|
7072
|
-
function
|
|
7208
|
+
function $n(r, e, s) {
|
|
7073
7209
|
const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
|
|
7074
7210
|
const a = t && i.address.toLowerCase() === t;
|
|
7075
7211
|
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${U(i.address)}">
|
|
@@ -7100,7 +7236,7 @@ function Ln(r, e, s) {
|
|
|
7100
7236
|
${n}
|
|
7101
7237
|
</div>
|
|
7102
7238
|
<button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
|
|
7103
|
-
<span class="__crossx-wallet-add-icon">${
|
|
7239
|
+
<span class="__crossx-wallet-add-icon">${Mn}</span>
|
|
7104
7240
|
<span class="__crossx-wallet-add-label">add a wallet</span>
|
|
7105
7241
|
</button>
|
|
7106
7242
|
</div>
|
|
@@ -7109,16 +7245,16 @@ function Ln(r, e, s) {
|
|
|
7109
7245
|
</div>
|
|
7110
7246
|
`, o;
|
|
7111
7247
|
}
|
|
7112
|
-
const
|
|
7248
|
+
const Bn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7113
7249
|
<path d="M26.693 21.193c-.028-3.168 2.587-4.712 2.706-4.786-1.477-2.16-3.77-2.454-4.58-2.484-1.944-.197-3.804 1.148-4.793 1.148-.992 0-2.52-1.12-4.147-1.09-2.13.032-4.1 1.239-5.198 3.133-2.222 3.855-.569 9.562 1.593 12.69 1.061 1.535 2.318 3.258 3.975 3.196 1.6-.064 2.2-1.03 4.133-1.03 1.928 0 2.48 1.03 4.172.997 1.72-.03 2.806-1.56 3.862-3.1 1.211-1.779 1.713-3.495 1.74-3.583-.037-.017-3.427-1.316-3.463-5.09z" fill="currentColor"/>
|
|
7114
7250
|
<path d="M23.527 11.876c.877-1.065 1.471-2.545 1.31-4.024-1.266.053-2.807.845-3.718 1.907-.813.946-1.53 2.468-1.34 3.915 1.41.107 2.852-.716 3.748-1.798z" fill="currentColor"/>
|
|
7115
|
-
</svg>`,
|
|
7251
|
+
</svg>`, Un = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7116
7252
|
<path d="M38.06 20.44c0-1.34-.12-2.63-.34-3.87H20.5v7.32h9.84c-.42 2.28-1.71 4.21-3.65 5.51v4.57h5.91c3.46-3.19 5.46-7.88 5.46-13.53z" fill="#4285F4"/>
|
|
7117
7253
|
<path d="M20.5 38.5c4.94 0 9.09-1.64 12.12-4.44l-5.91-4.57c-1.64 1.1-3.73 1.75-6.21 1.75-4.77 0-8.82-3.22-10.26-7.55H4.16v4.72A18.49 18.49 0 0 0 20.5 38.5z" fill="#34A853"/>
|
|
7118
7254
|
<path d="M10.24 23.69A11.16 11.16 0 0 1 9.66 20c0-1.28.22-2.52.58-3.69v-4.72H4.16A18.49 18.49 0 0 0 2 20c0 2.97.71 5.78 1.97 8.28l6.27-4.59z" fill="#FBBC05"/>
|
|
7119
7255
|
<path d="M20.5 8.76c2.69 0 5.1.92 7 2.73l5.24-5.24C29.58 3.36 25.43 1.5 20.5 1.5A18.49 18.49 0 0 0 4.16 11.59l6.08 4.72C11.68 11.98 15.73 8.76 20.5 8.76z" fill="#EA4335"/>
|
|
7120
7256
|
</svg>`;
|
|
7121
|
-
function
|
|
7257
|
+
function Hn(r) {
|
|
7122
7258
|
const e = r, s = document.createElement("div");
|
|
7123
7259
|
return s.id = te, s.innerHTML = `
|
|
7124
7260
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7133,11 +7269,11 @@ function $n(r) {
|
|
|
7133
7269
|
<div class="__crossx-body">
|
|
7134
7270
|
<div class="__crossx-login-btn-row">
|
|
7135
7271
|
<button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
|
|
7136
|
-
<span class="__crossx-login-icon" style="color:var(--cx-value);">${
|
|
7272
|
+
<span class="__crossx-login-icon" style="color:var(--cx-value);">${Bn}</span>
|
|
7137
7273
|
<span class="__crossx-login-btn-label">Sign in with Apple</span>
|
|
7138
7274
|
</button>
|
|
7139
7275
|
<button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
|
|
7140
|
-
<span class="__crossx-login-icon">${
|
|
7276
|
+
<span class="__crossx-login-icon">${Un}</span>
|
|
7141
7277
|
<span class="__crossx-login-btn-label">Sign in with Google</span>
|
|
7142
7278
|
</button>
|
|
7143
7279
|
</div>
|
|
@@ -7149,7 +7285,7 @@ function $n(r) {
|
|
|
7149
7285
|
</div>
|
|
7150
7286
|
`, s;
|
|
7151
7287
|
}
|
|
7152
|
-
function
|
|
7288
|
+
function Fn(r) {
|
|
7153
7289
|
const e = r, s = document.createElement("div");
|
|
7154
7290
|
return s.id = te, s.innerHTML = `
|
|
7155
7291
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7165,7 +7301,7 @@ function Bn(r) {
|
|
|
7165
7301
|
<p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
|
|
7166
7302
|
</div>
|
|
7167
7303
|
<button class="__crossx-recover-btn" id="__crossx-recover-btn">
|
|
7168
|
-
<span class="__crossx-recover-icon">${
|
|
7304
|
+
<span class="__crossx-recover-icon">${En}</span>
|
|
7169
7305
|
<span class="__crossx-recover-label">Import from Social Backup</span>
|
|
7170
7306
|
</button>
|
|
7171
7307
|
<button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>
|
|
@@ -7173,7 +7309,7 @@ function Bn(r) {
|
|
|
7173
7309
|
</div>
|
|
7174
7310
|
`, s;
|
|
7175
7311
|
}
|
|
7176
|
-
function
|
|
7312
|
+
function Gn(r, e) {
|
|
7177
7313
|
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");
|
|
7178
7314
|
return h.id = te, h.innerHTML = `
|
|
7179
7315
|
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7197,12 +7333,12 @@ function Un(r, e) {
|
|
|
7197
7333
|
</div>
|
|
7198
7334
|
`, h;
|
|
7199
7335
|
}
|
|
7200
|
-
function
|
|
7336
|
+
function Wn(r) {
|
|
7201
7337
|
const e = new Date(r), s = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], t = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], n = s[e.getDay()], o = t[e.getMonth()], i = e.getDate(), a = String(e.getHours()).padStart(2, "0"), c = String(e.getMinutes()).padStart(2, "0");
|
|
7202
7338
|
return `${n}, ${o} ${i} ${a}:${c}`;
|
|
7203
7339
|
}
|
|
7204
|
-
function
|
|
7205
|
-
const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ?
|
|
7340
|
+
function qn(r, e, s) {
|
|
7341
|
+
const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ? Wn(o) : null, a = document.createElement("div");
|
|
7206
7342
|
return a.id = te, a.innerHTML = `
|
|
7207
7343
|
<div class="__crossx-card __crossx-card--migration" style="${ce(t)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7208
7344
|
<div class="__crossx-header">
|
|
@@ -7232,10 +7368,10 @@ function Fn(r, e, s) {
|
|
|
7232
7368
|
return () => clearInterval(h);
|
|
7233
7369
|
} };
|
|
7234
7370
|
}
|
|
7235
|
-
function
|
|
7371
|
+
function Kn(r) {
|
|
7236
7372
|
const s = [r.check1, r.check2].map((t, n) => `
|
|
7237
7373
|
<div class="__crossx-pw-notice-item" data-check-index="${n}" role="checkbox" aria-checked="false" tabindex="0">
|
|
7238
|
-
<div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${
|
|
7374
|
+
<div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${jn}</div>
|
|
7239
7375
|
<span class="__crossx-pw-notice-item-text">${U(t)}</span>
|
|
7240
7376
|
</div>
|
|
7241
7377
|
`).join("");
|
|
@@ -7250,7 +7386,7 @@ function Gn(r) {
|
|
|
7250
7386
|
<div class="__crossx-pw-fields __crossx-pw-fields--notice">
|
|
7251
7387
|
<div class="__crossx-pw-notice-header">
|
|
7252
7388
|
<div class="__crossx-pw-notice-title-row">
|
|
7253
|
-
<span class="__crossx-pw-notice-icon">${
|
|
7389
|
+
<span class="__crossx-pw-notice-icon">${Yn}</span>
|
|
7254
7390
|
<p class="__crossx-pw-notice-title">${U(r.noticeTitle)}</p>
|
|
7255
7391
|
</div>
|
|
7256
7392
|
<p class="__crossx-pw-notice-desc">${U(r.noticeDesc)}</p>
|
|
@@ -7270,7 +7406,7 @@ function Gn(r) {
|
|
|
7270
7406
|
}
|
|
7271
7407
|
function nt(r) {
|
|
7272
7408
|
const e = !!r.lockExpiresAt && r.lockExpiresAt > Date.now(), s = r.lockExpiresAt ? ` data-lock-expires="${r.lockExpiresAt}"` : "", t = r.headerSubtitle ? `<p class="__crossx-pin6-header-sub">${U(r.headerSubtitle)}</p>` : "", n = r.subtitle ? `<p class="__crossx-pin6-subtitle">${U(r.subtitle)}</p>` : "", o = r.errorMessage ? `<p class="__crossx-pin6-error" id="__crossx-pin6-error">${U(r.errorMessage)}</p>` : '<p class="__crossx-pin6-error" id="__crossx-pin6-error"></p>', i = e ? `<p class="__crossx-pin6-lock-msg" id="__crossx-pin6-lock-msg">
|
|
7273
|
-
${
|
|
7409
|
+
${Cs}
|
|
7274
7410
|
<span id="__crossx-pin6-lock-countdown"></span>
|
|
7275
7411
|
</p>` : "", a = e ? " --locked" : "", c = Array.from(
|
|
7276
7412
|
{ length: 6 },
|
|
@@ -7294,7 +7430,7 @@ function nt(r) {
|
|
|
7294
7430
|
<div class="__crossx-home-indicator"></div>
|
|
7295
7431
|
`;
|
|
7296
7432
|
}
|
|
7297
|
-
function
|
|
7433
|
+
function Xt(r, e) {
|
|
7298
7434
|
const s = document.createElement("div");
|
|
7299
7435
|
return s.id = te, s.innerHTML = `
|
|
7300
7436
|
<div class="__crossx-card __crossx-card--pin6" style="${ce(r)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7302,121 +7438,121 @@ function Jt(r, e) {
|
|
|
7302
7438
|
</div>
|
|
7303
7439
|
`, s;
|
|
7304
7440
|
}
|
|
7305
|
-
function
|
|
7441
|
+
function Vn(r, e) {
|
|
7306
7442
|
if (r.length !== 6) return e.tooShort;
|
|
7307
7443
|
if (!/^\d+$/.test(r)) return e.numbersOnly;
|
|
7308
7444
|
if (/(.)\1{2}/.test(r)) return e.repeatingDigit;
|
|
7309
7445
|
const s = r.split("").map(Number), t = s.every((o, i) => i === 0 || o === (s[i - 1] + 1) % 10), n = s.every((o, i) => i === 0 || o === (s[i - 1] + 9) % 10);
|
|
7310
7446
|
return t || n ? e.sequential : r[0] !== r[1] && r === r.slice(0, 2).repeat(3) ? e.alternatingPattern : null;
|
|
7311
7447
|
}
|
|
7312
|
-
function
|
|
7448
|
+
function zn(r) {
|
|
7313
7449
|
const e = Math.max(0, Math.ceil(r / 1e3)), s = Math.floor(e / 3600), t = Math.floor(e % 3600 / 60), n = e % 60;
|
|
7314
7450
|
return s > 0 ? `${s}h ${String(t).padStart(2, "0")}m` : `${String(t).padStart(2, "0")}:${String(n).padStart(2, "0")}`;
|
|
7315
7451
|
}
|
|
7316
7452
|
function ot(r, e, s, t, n, o) {
|
|
7317
7453
|
let i = !!(o && o > Date.now()), a = !1;
|
|
7318
7454
|
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), d = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), m = () => r.querySelector("#__crossx-pin6-lock-countdown"), x = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((b) => b.value).join(""), E = (b) => {
|
|
7319
|
-
i = b, c().forEach((
|
|
7320
|
-
|
|
7455
|
+
i = b, c().forEach((k) => {
|
|
7456
|
+
k.disabled = b, k.classList.toggle("--locked", b);
|
|
7321
7457
|
});
|
|
7322
7458
|
}, y = () => {
|
|
7323
7459
|
const b = d();
|
|
7324
7460
|
b && (b.textContent = "");
|
|
7325
7461
|
}, S = (b) => {
|
|
7326
|
-
const
|
|
7327
|
-
|
|
7328
|
-
const
|
|
7329
|
-
|
|
7462
|
+
const k = d();
|
|
7463
|
+
k && (k.textContent = b);
|
|
7464
|
+
const P = l();
|
|
7465
|
+
P == null || P.classList.add("--shake"), setTimeout(() => P == null ? void 0 : P.classList.remove("--shake"), 500), c().forEach((G) => {
|
|
7330
7466
|
G.value = "";
|
|
7331
7467
|
}), setTimeout(() => {
|
|
7332
7468
|
var G;
|
|
7333
7469
|
return (G = c()[0]) == null ? void 0 : G.focus();
|
|
7334
7470
|
}, 50);
|
|
7335
|
-
},
|
|
7471
|
+
}, C = (b) => {
|
|
7336
7472
|
var W;
|
|
7337
7473
|
E(!0), c().forEach((q) => {
|
|
7338
7474
|
q.value = "";
|
|
7339
7475
|
});
|
|
7340
|
-
const
|
|
7341
|
-
if (
|
|
7476
|
+
const k = d();
|
|
7477
|
+
if (k && (k.textContent = "Too many failed attempts. Please wait."), !h()) {
|
|
7342
7478
|
const q = document.createElement("p");
|
|
7343
|
-
q.className = "__crossx-pin6-lock-msg", q.id = "__crossx-pin6-lock-msg", q.innerHTML = `${
|
|
7479
|
+
q.className = "__crossx-pin6-lock-msg", q.id = "__crossx-pin6-lock-msg", q.innerHTML = `${Cs}<span id="__crossx-pin6-lock-countdown"></span>`;
|
|
7344
7480
|
const D = d();
|
|
7345
7481
|
D ? D.insertAdjacentElement("afterend", q) : (W = x()) == null || W.appendChild(q);
|
|
7346
7482
|
}
|
|
7347
|
-
const
|
|
7348
|
-
var
|
|
7483
|
+
const P = () => {
|
|
7484
|
+
var R;
|
|
7349
7485
|
const q = b - Date.now(), D = m();
|
|
7350
|
-
q <= 0 ? (clearInterval(G), E(!1), (
|
|
7351
|
-
var
|
|
7352
|
-
return (
|
|
7353
|
-
}, 50)) : D && (D.textContent = ` ${
|
|
7354
|
-
}, G = setInterval(
|
|
7355
|
-
|
|
7356
|
-
const
|
|
7357
|
-
document.contains(r) || (clearInterval(G),
|
|
7486
|
+
q <= 0 ? (clearInterval(G), E(!1), (R = h()) == null || R.remove(), k && (k.textContent = ""), setTimeout(() => {
|
|
7487
|
+
var N;
|
|
7488
|
+
return (N = c()[0]) == null ? void 0 : N.focus();
|
|
7489
|
+
}, 50)) : D && (D.textContent = ` ${zn(q)}`);
|
|
7490
|
+
}, G = setInterval(P, 1e3);
|
|
7491
|
+
P();
|
|
7492
|
+
const z = new MutationObserver(() => {
|
|
7493
|
+
document.contains(r) || (clearInterval(G), z.disconnect());
|
|
7358
7494
|
});
|
|
7359
|
-
|
|
7495
|
+
z.observe(document.body, { childList: !0, subtree: !1 });
|
|
7360
7496
|
}, B = async () => {
|
|
7361
7497
|
if (i || a) return;
|
|
7362
7498
|
const b = w();
|
|
7363
7499
|
if (b.length === 6) {
|
|
7364
|
-
a = !0, c().forEach((
|
|
7365
|
-
|
|
7500
|
+
a = !0, c().forEach((k) => {
|
|
7501
|
+
k.disabled = !0;
|
|
7366
7502
|
});
|
|
7367
7503
|
try {
|
|
7368
7504
|
if (n) {
|
|
7369
|
-
const
|
|
7370
|
-
|
|
7505
|
+
const k = await n(b);
|
|
7506
|
+
k.ok ? e(b) : k.lockExpiresAt ? C(k.lockExpiresAt) : S(k.error ?? "Incorrect PIN. Please try again.");
|
|
7371
7507
|
} else
|
|
7372
7508
|
e(b);
|
|
7373
|
-
} catch (
|
|
7374
|
-
t && t(
|
|
7509
|
+
} catch (k) {
|
|
7510
|
+
t && t(k);
|
|
7375
7511
|
} finally {
|
|
7376
|
-
a = !1, i || c().forEach((
|
|
7377
|
-
|
|
7512
|
+
a = !1, i || c().forEach((k) => {
|
|
7513
|
+
k.disabled = !1;
|
|
7378
7514
|
});
|
|
7379
7515
|
}
|
|
7380
7516
|
}
|
|
7381
7517
|
};
|
|
7382
|
-
o && o > Date.now() ?
|
|
7518
|
+
o && o > Date.now() ? C(o) : setTimeout(() => {
|
|
7383
7519
|
var b;
|
|
7384
7520
|
return (b = c()[0]) == null ? void 0 : b.focus();
|
|
7385
|
-
}, 100), c().forEach((b,
|
|
7521
|
+
}, 100), c().forEach((b, k) => {
|
|
7386
7522
|
b.addEventListener("input", () => {
|
|
7387
7523
|
var G;
|
|
7388
|
-
const
|
|
7389
|
-
b.value =
|
|
7390
|
-
}), b.addEventListener("keydown", (
|
|
7391
|
-
var G,
|
|
7392
|
-
if (
|
|
7393
|
-
if (
|
|
7524
|
+
const P = b.value.replace(/\D/g, "").slice(-1);
|
|
7525
|
+
b.value = P, y(), P && k < 5 && ((G = c()[k + 1]) == null || G.focus()), w().length === 6 && setTimeout(B, 80);
|
|
7526
|
+
}), b.addEventListener("keydown", (P) => {
|
|
7527
|
+
var G, z;
|
|
7528
|
+
if (P.key === "Backspace") {
|
|
7529
|
+
if (P.preventDefault(), b.value)
|
|
7394
7530
|
b.value = "";
|
|
7395
|
-
else if (
|
|
7396
|
-
const W = c()[
|
|
7531
|
+
else if (k > 0) {
|
|
7532
|
+
const W = c()[k - 1];
|
|
7397
7533
|
W.value = "", W.focus();
|
|
7398
7534
|
}
|
|
7399
|
-
} else
|
|
7400
|
-
}), b.addEventListener("paste", (
|
|
7535
|
+
} else P.key === "ArrowLeft" && k > 0 ? (P.preventDefault(), (G = c()[k - 1]) == null || G.focus()) : P.key === "ArrowRight" && k < 5 ? (P.preventDefault(), (z = c()[k + 1]) == null || z.focus()) : P.key === "Escape" && s();
|
|
7536
|
+
}), b.addEventListener("paste", (P) => {
|
|
7401
7537
|
var W, q;
|
|
7402
|
-
|
|
7403
|
-
const G = (((W =
|
|
7538
|
+
P.preventDefault();
|
|
7539
|
+
const G = (((W = P.clipboardData) == null ? void 0 : W.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
|
|
7404
7540
|
if (!G) return;
|
|
7405
|
-
const
|
|
7406
|
-
G.split("").forEach((D,
|
|
7407
|
-
|
|
7408
|
-
}), (q =
|
|
7541
|
+
const z = c();
|
|
7542
|
+
G.split("").forEach((D, R) => {
|
|
7543
|
+
z[R] && (z[R].value = D);
|
|
7544
|
+
}), (q = z[Math.min(G.length - 1, 5)]) == null || q.focus(), y(), w().length === 6 && setTimeout(B, 80);
|
|
7409
7545
|
}), b.addEventListener("focus", () => b.select());
|
|
7410
7546
|
});
|
|
7411
7547
|
}
|
|
7412
|
-
const
|
|
7548
|
+
const Cs = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7413
7549
|
<path d="M14.5 8.5H14V6.5C14 4.015 11.985 2 9.5 2C7.015 2 5 4.015 5 6.5V8.5H4.5C3.672 8.5 3 9.172 3 10V16.5C3 17.328 3.672 18 4.5 18H14.5C15.328 18 16 17.328 16 16.5V10C16 9.172 15.328 8.5 14.5 8.5ZM10.5 13.415V15C10.5 15.276 10.276 15.5 10 15.5H9C8.724 15.5 8.5 15.276 8.5 15V13.415C8.187 13.196 8 12.847 8 12.5C8 11.672 8.672 11 9.5 11C10.328 11 11 11.672 11 12.5C11 12.847 10.813 13.196 10.5 13.415ZM12.5 8.5H6.5V6.5C6.5 4.843 7.843 3.5 9.5 3.5C11.157 3.5 12.5 4.843 12.5 6.5V8.5Z" fill="currentColor"/>
|
|
7414
|
-
</svg>`,
|
|
7550
|
+
</svg>`, jn = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7415
7551
|
<path d="M1 4.5L4 7.5L10 1" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
7416
|
-
</svg>`,
|
|
7552
|
+
</svg>`, Yn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7417
7553
|
<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"/>
|
|
7418
7554
|
</svg>`;
|
|
7419
|
-
function
|
|
7555
|
+
function Jn(r, e, s) {
|
|
7420
7556
|
var n;
|
|
7421
7557
|
const t = r.querySelectorAll(".__crossx-pin-input");
|
|
7422
7558
|
t.forEach((o, i) => {
|
|
@@ -7442,12 +7578,12 @@ function Kn(r, e, s) {
|
|
|
7442
7578
|
});
|
|
7443
7579
|
}), (n = t[0]) == null || n.focus();
|
|
7444
7580
|
}
|
|
7445
|
-
class
|
|
7581
|
+
class Zn {
|
|
7446
7582
|
constructor(e = "light", s) {
|
|
7447
|
-
this.theme = e, this.overrides = s, this.tokens =
|
|
7583
|
+
this.theme = e, this.overrides = s, this.tokens = Jt(e, s);
|
|
7448
7584
|
}
|
|
7449
7585
|
setTheme(e, s) {
|
|
7450
|
-
this.theme = e, s !== void 0 && (this.overrides = s), this.tokens =
|
|
7586
|
+
this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = Jt(e, this.overrides);
|
|
7451
7587
|
}
|
|
7452
7588
|
setMessages(e) {
|
|
7453
7589
|
this.messages = e;
|
|
@@ -7463,9 +7599,9 @@ class jn {
|
|
|
7463
7599
|
showWalletSelector(e, s, t) {
|
|
7464
7600
|
return new Promise((n) => {
|
|
7465
7601
|
var E;
|
|
7466
|
-
|
|
7467
|
-
const o = [...e], i =
|
|
7468
|
-
document.body.style.overflow = "hidden",
|
|
7602
|
+
he();
|
|
7603
|
+
const o = [...e], i = $n(o, this.tokens, t), a = document.body.style.overflow;
|
|
7604
|
+
document.body.style.overflow = "hidden", pe(i);
|
|
7469
7605
|
let c = !1;
|
|
7470
7606
|
const l = () => {
|
|
7471
7607
|
c || (c = !0, i.remove(), document.body.style.overflow = a);
|
|
@@ -7477,8 +7613,8 @@ class jn {
|
|
|
7477
7613
|
(() => {
|
|
7478
7614
|
i.querySelectorAll(".__crossx-wallet-item").forEach((y) => {
|
|
7479
7615
|
y.addEventListener("click", () => {
|
|
7480
|
-
const S = y.dataset.walletAddress ?? "",
|
|
7481
|
-
d({ address: S, index:
|
|
7616
|
+
const S = y.dataset.walletAddress ?? "", C = parseInt(y.dataset.walletIndex ?? "0", 10);
|
|
7617
|
+
d({ address: S, index: C });
|
|
7482
7618
|
});
|
|
7483
7619
|
});
|
|
7484
7620
|
})();
|
|
@@ -7490,8 +7626,8 @@ class jn {
|
|
|
7490
7626
|
o.push(y);
|
|
7491
7627
|
const S = i.querySelector("#__crossx-wallet-list");
|
|
7492
7628
|
if (S) {
|
|
7493
|
-
const
|
|
7494
|
-
|
|
7629
|
+
const C = document.createElement("button");
|
|
7630
|
+
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" });
|
|
7495
7631
|
}
|
|
7496
7632
|
} catch {
|
|
7497
7633
|
} finally {
|
|
@@ -7514,9 +7650,9 @@ class jn {
|
|
|
7514
7650
|
showLoginSelector() {
|
|
7515
7651
|
return new Promise((e) => {
|
|
7516
7652
|
var a, c, l;
|
|
7517
|
-
|
|
7518
|
-
const s =
|
|
7519
|
-
|
|
7653
|
+
he();
|
|
7654
|
+
const s = Hn(this.tokens);
|
|
7655
|
+
pe(s);
|
|
7520
7656
|
const t = () => s.remove(), n = (d) => {
|
|
7521
7657
|
t(), e(d);
|
|
7522
7658
|
}, o = () => {
|
|
@@ -7540,9 +7676,9 @@ class jn {
|
|
|
7540
7676
|
showMigrationFoundPrompt() {
|
|
7541
7677
|
return new Promise((e) => {
|
|
7542
7678
|
var a, c, l;
|
|
7543
|
-
|
|
7544
|
-
const s =
|
|
7545
|
-
|
|
7679
|
+
he();
|
|
7680
|
+
const s = Fn(this.tokens);
|
|
7681
|
+
pe(s);
|
|
7546
7682
|
const t = () => s.remove(), n = () => {
|
|
7547
7683
|
t(), e("recover");
|
|
7548
7684
|
}, o = () => {
|
|
@@ -7566,7 +7702,7 @@ class jn {
|
|
|
7566
7702
|
*/
|
|
7567
7703
|
showPinSetupPrompt(e) {
|
|
7568
7704
|
return new Promise((s) => {
|
|
7569
|
-
|
|
7705
|
+
he();
|
|
7570
7706
|
const t = this.messages, n = {
|
|
7571
7707
|
title: (t == null ? void 0 : t.pinSetup_title) ?? "Create PIN",
|
|
7572
7708
|
headerSubtitle: (t == null ? void 0 : t.pinNotice_headerSubtitle) ?? "Required for transactions, PK/mnemonic export & account deletion.",
|
|
@@ -7584,13 +7720,13 @@ class jn {
|
|
|
7584
7720
|
}, i = {
|
|
7585
7721
|
title: (t == null ? void 0 : t.pinSetup_confirmTitle) ?? "Confirm PIN",
|
|
7586
7722
|
headerSubtitle: (t == null ? void 0 : t.pinSetup_confirmSubtitle) ?? "Enter your PIN again to confirm."
|
|
7587
|
-
}, a =
|
|
7588
|
-
document.body.style.overflow = "hidden",
|
|
7723
|
+
}, a = Xt(this.tokens, Kn(n)), c = document.body.style.overflow;
|
|
7724
|
+
document.body.style.overflow = "hidden", pe(a);
|
|
7589
7725
|
let l = !1;
|
|
7590
7726
|
const d = () => {
|
|
7591
7727
|
l || (l = !0, a.remove(), document.body.style.overflow = c);
|
|
7592
|
-
}, h = (
|
|
7593
|
-
d(), s(
|
|
7728
|
+
}, h = (C) => {
|
|
7729
|
+
d(), s(C);
|
|
7594
7730
|
}, m = () => {
|
|
7595
7731
|
d(), s(null);
|
|
7596
7732
|
}, x = a.querySelector(".__crossx-card"), w = {
|
|
@@ -7599,66 +7735,66 @@ class jn {
|
|
|
7599
7735
|
repeatingDigit: (t == null ? void 0 : t.pinValidation_repeatingDigit) ?? "Cannot use the same number 3+ times in a row.",
|
|
7600
7736
|
sequential: (t == null ? void 0 : t.pinValidation_sequential) ?? "Sequential numbers (e.g., 123456) are not allowed.",
|
|
7601
7737
|
alternatingPattern: (t == null ? void 0 : t.pinValidation_alternatingPattern) ?? "Repeating patterns (e.g., 121212) are not allowed."
|
|
7602
|
-
}, E = (
|
|
7738
|
+
}, E = (C) => {
|
|
7603
7739
|
var B;
|
|
7604
7740
|
x.innerHTML = nt({
|
|
7605
7741
|
title: i.title,
|
|
7606
7742
|
headerSubtitle: i.headerSubtitle
|
|
7607
7743
|
}), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), ot(x, (b) => {
|
|
7608
|
-
b ===
|
|
7744
|
+
b === C ? h(C) : y(o.mismatchError);
|
|
7609
7745
|
}, m);
|
|
7610
|
-
}, y = (
|
|
7746
|
+
}, y = (C) => {
|
|
7611
7747
|
var B;
|
|
7612
7748
|
x.innerHTML = nt({
|
|
7613
7749
|
title: o.title,
|
|
7614
7750
|
headerSubtitle: o.headerSubtitle,
|
|
7615
7751
|
subtitle: o.subtitle,
|
|
7616
|
-
errorMessage:
|
|
7752
|
+
errorMessage: C
|
|
7617
7753
|
}), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), ot(x, (b) => {
|
|
7618
|
-
const
|
|
7619
|
-
|
|
7754
|
+
const k = Vn(b, w);
|
|
7755
|
+
k ? y(k) : E(b);
|
|
7620
7756
|
}, m);
|
|
7621
7757
|
};
|
|
7622
7758
|
(() => {
|
|
7623
7759
|
var q;
|
|
7624
|
-
const
|
|
7760
|
+
const C = Array.from(x.querySelectorAll(".__crossx-pw-notice-item")), B = x.querySelector("#__crossx-pin-notice-next"), b = /* @__PURE__ */ new Set();
|
|
7625
7761
|
B.removeAttribute("disabled");
|
|
7626
|
-
const
|
|
7627
|
-
const D = b.size ===
|
|
7628
|
-
B.classList.toggle("--disabled", !D), B.textContent = D ?
|
|
7629
|
-
},
|
|
7630
|
-
if (b.has(
|
|
7631
|
-
const
|
|
7632
|
-
b.add(
|
|
7633
|
-
}, W = (D,
|
|
7634
|
-
if (!b.has(
|
|
7635
|
-
const
|
|
7636
|
-
b.delete(
|
|
7762
|
+
const k = B.dataset.nextLabel ?? "Next", P = B.dataset.submitLabel ?? "I Understand", G = () => {
|
|
7763
|
+
const D = b.size === C.length;
|
|
7764
|
+
B.classList.toggle("--disabled", !D), B.textContent = D ? P : k;
|
|
7765
|
+
}, z = (D, R) => {
|
|
7766
|
+
if (b.has(R)) return;
|
|
7767
|
+
const N = D.querySelector(`#__crossx-notice-check-${R}`);
|
|
7768
|
+
b.add(R), N.classList.add("--checked"), D.setAttribute("aria-checked", "true"), G();
|
|
7769
|
+
}, W = (D, R) => {
|
|
7770
|
+
if (!b.has(R)) return;
|
|
7771
|
+
const N = D.querySelector(`#__crossx-notice-check-${R}`);
|
|
7772
|
+
b.delete(R), N.classList.remove("--checked"), D.setAttribute("aria-checked", "false"), G();
|
|
7637
7773
|
};
|
|
7638
|
-
|
|
7639
|
-
const
|
|
7774
|
+
C.forEach((D) => {
|
|
7775
|
+
const R = parseInt(D.dataset.checkIndex ?? "0", 10);
|
|
7640
7776
|
D.addEventListener("click", () => {
|
|
7641
|
-
b.has(
|
|
7642
|
-
}), D.addEventListener("keydown", (
|
|
7643
|
-
(
|
|
7777
|
+
b.has(R) ? W(D, R) : z(D, R);
|
|
7778
|
+
}), D.addEventListener("keydown", (N) => {
|
|
7779
|
+
(N.key === " " || N.key === "Enter") && (N.preventDefault(), b.has(R) ? W(D, R) : z(D, R));
|
|
7644
7780
|
});
|
|
7645
7781
|
}), B.addEventListener("click", () => {
|
|
7646
|
-
if (b.size ===
|
|
7782
|
+
if (b.size === C.length) {
|
|
7647
7783
|
y(e == null ? void 0 : e.errorMessage);
|
|
7648
7784
|
return;
|
|
7649
7785
|
}
|
|
7650
|
-
const D =
|
|
7651
|
-
const f = parseInt(
|
|
7786
|
+
const D = C.find((N) => {
|
|
7787
|
+
const f = parseInt(N.dataset.checkIndex ?? "0", 10);
|
|
7652
7788
|
return !b.has(f);
|
|
7653
7789
|
});
|
|
7654
7790
|
if (!D) return;
|
|
7655
|
-
const
|
|
7791
|
+
const R = parseInt(D.dataset.checkIndex ?? "0", 10);
|
|
7656
7792
|
D.scrollIntoView({ behavior: "smooth", block: "nearest" }), D.classList.add("--highlight"), setTimeout(() => {
|
|
7657
|
-
D.classList.remove("--highlight"),
|
|
7793
|
+
D.classList.remove("--highlight"), z(D, R);
|
|
7658
7794
|
}, 400);
|
|
7659
7795
|
}), (q = x.querySelector("#__crossx-close-btn")) == null || q.addEventListener("click", m);
|
|
7660
|
-
})(), a.addEventListener("click", (
|
|
7661
|
-
|
|
7796
|
+
})(), a.addEventListener("click", (C) => {
|
|
7797
|
+
C.target === a && m();
|
|
7662
7798
|
});
|
|
7663
7799
|
});
|
|
7664
7800
|
}
|
|
@@ -7670,8 +7806,8 @@ class jn {
|
|
|
7670
7806
|
showPinInputPrompt(e) {
|
|
7671
7807
|
return new Promise((s, t) => {
|
|
7672
7808
|
var y;
|
|
7673
|
-
|
|
7674
|
-
const n = this.messages, o = (e == null ? void 0 : e.verifyMode) === !0, i = o ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = o ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c =
|
|
7809
|
+
he();
|
|
7810
|
+
const n = this.messages, o = (e == null ? void 0 : e.verifyMode) === !0, i = o ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = o ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c = Xt(
|
|
7675
7811
|
this.tokens,
|
|
7676
7812
|
nt({
|
|
7677
7813
|
title: i,
|
|
@@ -7680,7 +7816,7 @@ class jn {
|
|
|
7680
7816
|
lockExpiresAt: e == null ? void 0 : e.lockExpiresAt
|
|
7681
7817
|
})
|
|
7682
7818
|
), l = document.body.style.overflow;
|
|
7683
|
-
document.body.style.overflow = "hidden",
|
|
7819
|
+
document.body.style.overflow = "hidden", pe(c);
|
|
7684
7820
|
let d = !1;
|
|
7685
7821
|
const h = () => {
|
|
7686
7822
|
d || (d = !0, c.remove(), document.body.style.overflow = l);
|
|
@@ -7706,15 +7842,15 @@ class jn {
|
|
|
7706
7842
|
showRecoveryPinInputPrompt(e) {
|
|
7707
7843
|
return new Promise((s) => {
|
|
7708
7844
|
var a;
|
|
7709
|
-
|
|
7710
|
-
const t =
|
|
7711
|
-
|
|
7845
|
+
he();
|
|
7846
|
+
const t = Gn(this.tokens, e);
|
|
7847
|
+
pe(t);
|
|
7712
7848
|
const n = () => t.remove(), o = (c) => {
|
|
7713
7849
|
n(), s(c);
|
|
7714
7850
|
}, i = () => {
|
|
7715
7851
|
n(), s(null);
|
|
7716
7852
|
};
|
|
7717
|
-
|
|
7853
|
+
Jn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
|
|
7718
7854
|
c.target === t && i();
|
|
7719
7855
|
});
|
|
7720
7856
|
});
|
|
@@ -7728,9 +7864,9 @@ class jn {
|
|
|
7728
7864
|
showRecoveryPinLockedPrompt(e, s) {
|
|
7729
7865
|
return new Promise((t) => {
|
|
7730
7866
|
var l;
|
|
7731
|
-
|
|
7732
|
-
const { overlay: n, startCountdown: o } =
|
|
7733
|
-
|
|
7867
|
+
he();
|
|
7868
|
+
const { overlay: n, startCountdown: o } = qn(this.tokens, e, s);
|
|
7869
|
+
pe(n);
|
|
7734
7870
|
const i = () => {
|
|
7735
7871
|
c(), n.remove();
|
|
7736
7872
|
}, a = () => {
|
|
@@ -7748,9 +7884,9 @@ class jn {
|
|
|
7748
7884
|
showTransactionComplete(e) {
|
|
7749
7885
|
return new Promise((s) => {
|
|
7750
7886
|
var a, c;
|
|
7751
|
-
|
|
7752
|
-
const t =
|
|
7753
|
-
|
|
7887
|
+
he();
|
|
7888
|
+
const t = Nn(e, this.tokens);
|
|
7889
|
+
pe(t);
|
|
7754
7890
|
const n = () => t.remove(), o = () => {
|
|
7755
7891
|
n(), s();
|
|
7756
7892
|
};
|
|
@@ -7777,9 +7913,9 @@ class jn {
|
|
|
7777
7913
|
*/
|
|
7778
7914
|
showTransactionProgress(e, s) {
|
|
7779
7915
|
return new Promise((t) => {
|
|
7780
|
-
|
|
7781
|
-
const n =
|
|
7782
|
-
|
|
7916
|
+
he();
|
|
7917
|
+
const n = On(e, this.tokens);
|
|
7918
|
+
pe(n);
|
|
7783
7919
|
const o = () => n.remove();
|
|
7784
7920
|
let i = !1;
|
|
7785
7921
|
const a = () => {
|
|
@@ -7795,16 +7931,16 @@ class jn {
|
|
|
7795
7931
|
document.addEventListener("keydown", l);
|
|
7796
7932
|
};
|
|
7797
7933
|
s.then((l) => {
|
|
7798
|
-
i || (
|
|
7934
|
+
i || (Cn(n, l, this.tokens), c());
|
|
7799
7935
|
});
|
|
7800
7936
|
});
|
|
7801
7937
|
}
|
|
7802
7938
|
requestConfirmation(e) {
|
|
7803
7939
|
return new Promise((s) => {
|
|
7804
7940
|
var c, l, d;
|
|
7805
|
-
|
|
7941
|
+
he();
|
|
7806
7942
|
let t;
|
|
7807
|
-
e.type === "sign-message" ? t =
|
|
7943
|
+
e.type === "sign-message" ? t = Ln(e, this.tokens) : e.type === "sign-typed-data" ? t = Dn(e, this.tokens) : e.type === "sign" ? t = An(e, this.tokens) : t = Rn(e, this.tokens), pe(t);
|
|
7808
7944
|
const n = () => t.remove(), o = () => {
|
|
7809
7945
|
n(), s(!0);
|
|
7810
7946
|
}, i = () => {
|
|
@@ -7828,26 +7964,32 @@ class jn {
|
|
|
7828
7964
|
});
|
|
7829
7965
|
}
|
|
7830
7966
|
}
|
|
7831
|
-
class
|
|
7967
|
+
class Xn {
|
|
7832
7968
|
constructor() {
|
|
7833
|
-
this._accessToken = null;
|
|
7969
|
+
this._accessToken = null, this._expiresAt = 0;
|
|
7834
7970
|
}
|
|
7835
7971
|
set(e) {
|
|
7836
7972
|
this._accessToken = e;
|
|
7973
|
+
try {
|
|
7974
|
+
const s = JSON.parse(atob(e.split(".")[1]));
|
|
7975
|
+
this._expiresAt = typeof s.exp == "number" ? s.exp * 1e3 : 0;
|
|
7976
|
+
} catch {
|
|
7977
|
+
this._expiresAt = 0;
|
|
7978
|
+
}
|
|
7837
7979
|
}
|
|
7838
7980
|
get() {
|
|
7839
|
-
return this._accessToken;
|
|
7981
|
+
return this._accessToken && this._expiresAt > 0 && Date.now() >= this._expiresAt ? (this.clear(), null) : this._accessToken;
|
|
7840
7982
|
}
|
|
7841
7983
|
clear() {
|
|
7842
|
-
this._accessToken = null;
|
|
7984
|
+
this._accessToken = null, this._expiresAt = 0;
|
|
7843
7985
|
}
|
|
7844
7986
|
has() {
|
|
7845
|
-
return this.
|
|
7987
|
+
return this.get() !== null;
|
|
7846
7988
|
}
|
|
7847
7989
|
}
|
|
7848
|
-
function
|
|
7990
|
+
function so(r, e) {
|
|
7849
7991
|
r.debug;
|
|
7850
|
-
const s =
|
|
7992
|
+
const s = Ge.production, t = {
|
|
7851
7993
|
...r,
|
|
7852
7994
|
oauthServiceUrl: s.oauthServiceUrl,
|
|
7853
7995
|
authApiUrl: s.authApiUrl,
|
|
@@ -7855,16 +7997,22 @@ function Qn(r, e) {
|
|
|
7855
7997
|
}, n = {
|
|
7856
7998
|
gatewayUrl: s.walletGatewayUrl,
|
|
7857
7999
|
projectId: r.projectId
|
|
7858
|
-
},
|
|
8000
|
+
}, o = t.authMode !== "cookie" && Ot.isAvailable();
|
|
8001
|
+
!o && t.authMode !== "cookie" && u.warn(
|
|
8002
|
+
"[CROSSx] IndexedDB 사용 불가 — LocalStorage fallback 사용 중.",
|
|
8003
|
+
"refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
|
|
8004
|
+
"IndexedDB를 지원하는 브라우저 사용을 권장합니다."
|
|
8005
|
+
), t.secureStorageAvailable = o;
|
|
8006
|
+
const i = o ? new Ot(r.projectId) : new rr(), a = new hn(), c = new xn(), l = new be(), d = new Xn(), h = new es();
|
|
7859
8007
|
let m;
|
|
7860
|
-
r.useMockWallet ? (u.log("[CROSSx] Mock Wallet Provider 사용"), m = new
|
|
8008
|
+
r.useMockWallet ? (u.log("[CROSSx] Mock Wallet Provider 사용"), m = new mn(i, h)) : (u.log("[CROSSx] Remote Wallet Provider 사용"), m = new Le(
|
|
7861
8009
|
n,
|
|
7862
8010
|
i,
|
|
7863
8011
|
c,
|
|
7864
8012
|
d,
|
|
7865
8013
|
h
|
|
7866
8014
|
));
|
|
7867
|
-
const x = new De(n, c), w = new
|
|
8015
|
+
const x = new De(n, c), w = new Zn(r.theme ?? "light", r.themeTokens), E = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w;
|
|
7868
8016
|
return new it(
|
|
7869
8017
|
t,
|
|
7870
8018
|
n,
|
|
@@ -7881,9 +8029,9 @@ function Qn(r, e) {
|
|
|
7881
8029
|
}
|
|
7882
8030
|
export {
|
|
7883
8031
|
g as CROSSxError,
|
|
7884
|
-
|
|
8032
|
+
Fs as CROSSxEthereumProvider,
|
|
7885
8033
|
it as CROSSxSDK,
|
|
7886
|
-
|
|
8034
|
+
to as ChainId,
|
|
7887
8035
|
p as ErrorCode,
|
|
7888
|
-
|
|
8036
|
+
so as createCROSSxSDK
|
|
7889
8037
|
};
|