@nexus-cross/crossx-sdk-core 1.3.5 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/services/TokenMemoryStore.test.d.ts +2 -0
- package/dist/__tests__/services/TokenMemoryStore.test.d.ts.map +1 -0
- package/dist/__tests__/utils/parseOAuthDeeplink.test.d.ts +4 -1
- package/dist/__tests__/utils/parseOAuthDeeplink.test.d.ts.map +1 -1
- package/dist/adapters/wallet/RemoteWalletProviderAdapter.d.ts +16 -1
- package/dist/adapters/wallet/RemoteWalletProviderAdapter.d.ts.map +1 -1
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/ports/WalletProviderPort.d.ts +10 -0
- package/dist/core/ports/WalletProviderPort.d.ts.map +1 -1
- package/dist/core/services/TokenMemoryStore.d.ts +7 -0
- package/dist/core/services/TokenMemoryStore.d.ts.map +1 -1
- package/dist/core/usecases/SignInUseCase.d.ts +9 -0
- package/dist/core/usecases/SignInUseCase.d.ts.map +1 -1
- package/dist/core/utils/parseOAuthDeeplink.d.ts +12 -5
- package/dist/core/utils/parseOAuthDeeplink.d.ts.map +1 -1
- package/dist/crossx.global +37 -37
- package/dist/index.cjs +36 -36
- package/dist/index.js +560 -496
- 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
|
@@ -65,7 +65,7 @@ const Ve = {
|
|
|
65
65
|
rpcUrl: "https://saigon-testnet.roninchain.com/rpc",
|
|
66
66
|
testnet: !0
|
|
67
67
|
}
|
|
68
|
-
},
|
|
68
|
+
}, io = Object.fromEntries(
|
|
69
69
|
Object.entries(Ve).map(([r, e]) => [r, e.caipId])
|
|
70
70
|
), Us = new Map(
|
|
71
71
|
Object.values(Ve).map((r) => [r.caipId, r])
|
|
@@ -331,7 +331,7 @@ const d = {
|
|
|
331
331
|
function St(r = "en", e) {
|
|
332
332
|
return Ws[r] ?? Qt;
|
|
333
333
|
}
|
|
334
|
-
const Et = "crossx_access_token", It = "crossx_refresh_token",
|
|
334
|
+
const Et = "crossx_access_token", It = "crossx_refresh_token", Tt = "crossx_user_info";
|
|
335
335
|
class qs {
|
|
336
336
|
constructor(e, s, t, n, o, i, a) {
|
|
337
337
|
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;
|
|
@@ -402,12 +402,12 @@ class qs {
|
|
|
402
402
|
let s, t = !1;
|
|
403
403
|
try {
|
|
404
404
|
const { authApiUrl: c } = this.config, { accessToken: l, refreshToken: u } = await this.exchangeFirebaseToken(e, c);
|
|
405
|
-
let h,
|
|
405
|
+
let h, _;
|
|
406
406
|
try {
|
|
407
407
|
const w = this.crypto.decodeJWT(e);
|
|
408
|
-
|
|
408
|
+
_ = (n = w.firebase) == null ? void 0 : n.sign_in_provider;
|
|
409
409
|
const b = ((o = w.firebase) == null ? void 0 : o.identities) ?? {};
|
|
410
|
-
|
|
410
|
+
_ === "google.com" ? h = (i = b["google.com"]) == null ? void 0 : i[0] : _ === "apple.com" && (h = (a = b["apple.com"]) == null ? void 0 : a[0]), d.log("[CROSSx] OAuth provider sub 추출 — provider:", _, "hasProviderSub:", !!h);
|
|
411
411
|
} catch {
|
|
412
412
|
d.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
|
|
413
413
|
}
|
|
@@ -421,7 +421,7 @@ class qs {
|
|
|
421
421
|
s = {
|
|
422
422
|
id: y.sub,
|
|
423
423
|
email: y.email,
|
|
424
|
-
signInProvider:
|
|
424
|
+
signInProvider: _,
|
|
425
425
|
providerSub: h
|
|
426
426
|
}, this.tokenStore.set(l), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, l), u && this.config.secureStorageAvailable !== !1 ? await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, u) : u && d.warn("[CROSSx] 안전한 스토리지 미사용 — refresh_token 영속 저장을 건너뜁니다"));
|
|
427
427
|
} else {
|
|
@@ -429,7 +429,7 @@ class qs {
|
|
|
429
429
|
s = {
|
|
430
430
|
id: w.sub,
|
|
431
431
|
email: w.email,
|
|
432
|
-
signInProvider:
|
|
432
|
+
signInProvider: _,
|
|
433
433
|
providerSub: h
|
|
434
434
|
}, d.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
|
|
435
435
|
}
|
|
@@ -602,6 +602,24 @@ class qs {
|
|
|
602
602
|
}
|
|
603
603
|
return d.log("[CROSSx] silentRefresh 성공"), c;
|
|
604
604
|
}
|
|
605
|
+
/**
|
|
606
|
+
* access_token을 자동 갱신합니다.
|
|
607
|
+
*
|
|
608
|
+
* Gateway 요청 전 토큰이 만료되었거나 곧 만료될 때 호출됩니다.
|
|
609
|
+
* 내부적으로 silentRefresh를 실행하고, 새 토큰을 TokenMemoryStore에 저장합니다.
|
|
610
|
+
*
|
|
611
|
+
* @returns 갱신 성공 시 true, 실패 시 false
|
|
612
|
+
*/
|
|
613
|
+
async refreshAccessToken() {
|
|
614
|
+
try {
|
|
615
|
+
if (this.useCookieAuth)
|
|
616
|
+
return !!await this.silentRefresh() || this.tokenStore.has();
|
|
617
|
+
const e = await this.storage.get(this.STORAGE_KEY_REFRESH_TOKEN);
|
|
618
|
+
return e ? !!await this.silentRefresh(e) : (d.warn("[CROSSx] refreshAccessToken: refresh_token 없음 — 갱신 불가"), !1);
|
|
619
|
+
} catch (e) {
|
|
620
|
+
return d.warn("[CROSSx] refreshAccessToken 실패:", e), !1;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
605
623
|
/**
|
|
606
624
|
* 외부에서 발급된 CROSSx JWT를 직접 주입하여 로그인합니다.
|
|
607
625
|
*
|
|
@@ -647,13 +665,13 @@ class qs {
|
|
|
647
665
|
if (!this._migrated) {
|
|
648
666
|
this._migrated = !0;
|
|
649
667
|
try {
|
|
650
|
-
const e = await this.storage.get(
|
|
668
|
+
const e = await this.storage.get(Tt);
|
|
651
669
|
if (!e || await this.storage.get(this.STORAGE_KEY_USER)) return;
|
|
652
670
|
await this.storage.set(this.STORAGE_KEY_USER, e);
|
|
653
671
|
const t = await this.storage.get(Et);
|
|
654
672
|
t && await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, t);
|
|
655
673
|
const n = await this.storage.get(It);
|
|
656
|
-
n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(
|
|
674
|
+
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), d.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
|
|
657
675
|
} catch (e) {
|
|
658
676
|
d.warn("[CROSSx] 스토리지 키 마이그레이션 실패:", e);
|
|
659
677
|
}
|
|
@@ -848,9 +866,9 @@ function Js() {
|
|
|
848
866
|
}
|
|
849
867
|
return Ge.production;
|
|
850
868
|
}
|
|
851
|
-
const Xs = 2e3,
|
|
869
|
+
const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA00", kt = 130, Pt = 6, Ot = 18, tr = 3e4, sr = 5 * 60 * 1e3, rr = 30 * 1e3, re = class re extends js {
|
|
852
870
|
constructor(e, s, t, n, o, i, a, c, l, u, h) {
|
|
853
|
-
var
|
|
871
|
+
var _, f;
|
|
854
872
|
super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this._initPromise = null, this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._verifyPinMutex = null, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && vt(e.logger), this.confirmation = l, this.pinStore = h ?? new es(), this.chainRegistry = u, this.jsonRpc = new zs(u, o), this.signInUseCase = new qs(
|
|
855
873
|
this.internalConfig,
|
|
856
874
|
t,
|
|
@@ -859,7 +877,10 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
859
877
|
o,
|
|
860
878
|
a,
|
|
861
879
|
c
|
|
862
|
-
), this.signOutUseCase = new Ks(this.internalConfig, t, c), this.migrateWalletUseCase = new Vs(t, a), (
|
|
880
|
+
), this.signOutUseCase = new Ks(this.internalConfig, t, c), this.migrateWalletUseCase = new Vs(t, a), (_ = a.setOnUnauthorized) == null || _.call(a, () => this.forceLogout()), (f = a.setTokenRefresher) == null || f.call(
|
|
881
|
+
a,
|
|
882
|
+
() => this.signInUseCase.refreshAccessToken()
|
|
883
|
+
);
|
|
863
884
|
}
|
|
864
885
|
get config() {
|
|
865
886
|
return this._config;
|
|
@@ -885,7 +906,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
885
906
|
}
|
|
886
907
|
async _doInitialize(e) {
|
|
887
908
|
var s, t;
|
|
888
|
-
d.log("[CROSSx SDK] v1.3.
|
|
909
|
+
d.log("[CROSSx SDK] v1.3.7 초기화 중..."), this.confirmation.setMessages(St(this._config.locale));
|
|
889
910
|
try {
|
|
890
911
|
const n = Js();
|
|
891
912
|
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`);
|
|
@@ -1630,7 +1651,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1630
1651
|
* @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
|
|
1631
1652
|
*/
|
|
1632
1653
|
async waitForTxAndGetReceipt(e, s, t = {}) {
|
|
1633
|
-
const n = t.intervalMs ?? Zs, o = Qs, i = t.timeoutMs ??
|
|
1654
|
+
const n = t.intervalMs ?? Zs, o = Qs, i = t.timeoutMs ?? At, a = Date.now() + i;
|
|
1634
1655
|
let c = n;
|
|
1635
1656
|
for (; Date.now() < a; ) {
|
|
1636
1657
|
const l = await this.getTransactionReceipt(e, s);
|
|
@@ -1659,23 +1680,23 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1659
1680
|
*/
|
|
1660
1681
|
async sendTransactionWithWaitForReceipt(e, s, t = {}) {
|
|
1661
1682
|
var b, y;
|
|
1662
|
-
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((b = this._config.receiptPolling) == null ? void 0 : b.intervalMs) ?? Xs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ??
|
|
1663
|
-
let
|
|
1664
|
-
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((
|
|
1665
|
-
|
|
1666
|
-
const C = BigInt(
|
|
1683
|
+
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((b = this._config.receiptPolling) == null ? void 0 : b.intervalMs) ?? Xs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? At, u = Je(e), h = s.from ?? "";
|
|
1684
|
+
let _, f;
|
|
1685
|
+
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((T) => {
|
|
1686
|
+
_ = T;
|
|
1687
|
+
const C = BigInt(T.gasUsed) * BigInt(T.effectiveGasPrice), W = s.value ? BigInt(s.value) : 0n, B = re.formatTxAmount(s.value, u.symbol, u.decimals), j = re.formatTxAmount("0x" + C.toString(16), u.symbol, u.decimals), q = re.formatTxAmount("0x" + (W + C).toString(16), u.symbol, u.decimals);
|
|
1667
1688
|
return {
|
|
1668
1689
|
chainId: e,
|
|
1669
1690
|
txHash: a,
|
|
1670
|
-
from:
|
|
1671
|
-
to:
|
|
1691
|
+
from: T.from,
|
|
1692
|
+
to: T.to ?? s.to,
|
|
1672
1693
|
amount: B,
|
|
1673
1694
|
fees: j,
|
|
1674
1695
|
total: q,
|
|
1675
1696
|
nativeSymbol: u.symbol,
|
|
1676
|
-
status:
|
|
1697
|
+
status: T.status === "0x1" ? "success" : "reverted"
|
|
1677
1698
|
};
|
|
1678
|
-
}).catch((
|
|
1699
|
+
}).catch((T) => (f = T instanceof Error ? T : new Error(String(T)), {
|
|
1679
1700
|
chainId: e,
|
|
1680
1701
|
txHash: a,
|
|
1681
1702
|
from: h,
|
|
@@ -1688,7 +1709,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1688
1709
|
{ chainId: e, txHash: a, from: h, to: s.to },
|
|
1689
1710
|
w
|
|
1690
1711
|
), f) throw f;
|
|
1691
|
-
return { chainId: e, txHash: a, receipt:
|
|
1712
|
+
return { chainId: e, txHash: a, receipt: _ };
|
|
1692
1713
|
}
|
|
1693
1714
|
// ============================================================================
|
|
1694
1715
|
// PIN 관리 (공개 API)
|
|
@@ -1963,31 +1984,31 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1963
1984
|
return d.log("[CROSSx][Migration Phase 4] 사용자가 PIN 입력을 취소함 → 종료"), null;
|
|
1964
1985
|
d.log("[CROSSx][Migration Phase 4] PIN 입력 완료 — verify-recovery-pin API 호출"), n = void 0;
|
|
1965
1986
|
try {
|
|
1966
|
-
const
|
|
1967
|
-
if (!
|
|
1987
|
+
const _ = await ((u = (l = this.walletProvider).verifyRecoveryPin) == null ? void 0 : u.call(l, h, e));
|
|
1988
|
+
if (!_) {
|
|
1968
1989
|
d.log("[CROSSx][Migration Phase 4] verifyRecoveryPin 미지원 — PIN 검증 생략"), a = h;
|
|
1969
1990
|
break;
|
|
1970
1991
|
}
|
|
1971
|
-
if (
|
|
1992
|
+
if (_.valid) {
|
|
1972
1993
|
d.log("[CROSSx][Migration Phase 4] PIN 검증 성공"), a = h;
|
|
1973
1994
|
break;
|
|
1974
1995
|
}
|
|
1975
|
-
const f =
|
|
1996
|
+
const f = _.pinStatus;
|
|
1976
1997
|
if (i = f.maxAttempts, o = i - f.remainingAttempts, f.remainingAttempts === 0 && f.lockExpiresAt) {
|
|
1977
1998
|
const w = f.lockExpiresAt * 1e3, b = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = b <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
|
|
1978
1999
|
d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${b}초, 메시지: ${y}`), await this.confirmation.showRecoveryPinLockedPrompt(b, y), o = 0, n = "Your account lock has been lifted. You may try again.";
|
|
1979
2000
|
} else
|
|
1980
2001
|
d.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 ${o}/${i})`), n = "Incorrect PIN.";
|
|
1981
|
-
} catch (
|
|
1982
|
-
if (!(
|
|
1983
|
-
if (
|
|
1984
|
-
const f =
|
|
2002
|
+
} catch (_) {
|
|
2003
|
+
if (!(_ instanceof m)) throw _;
|
|
2004
|
+
if (_.code === p.MIGRATION_PIN_LOCKED) {
|
|
2005
|
+
const f = _.details;
|
|
1985
2006
|
if (i = (f == null ? void 0 : f.maxAttempts) ?? 5, (f == null ? void 0 : f.permanent) === !0)
|
|
1986
2007
|
return d.warn("[CROSSx][Migration Phase 4] PIN 영구 잠금 (verify-recovery-pin)"), await this.confirmation.showRecoveryPinLockedPrompt(0, "Your account has been permanently locked due to too many failed attempts."), null;
|
|
1987
2008
|
const w = ((f == null ? void 0 : f.lockExpiresAt) ?? 0) * 1e3, b = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = b <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
|
|
1988
2009
|
d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${b}초`), await this.confirmation.showRecoveryPinLockedPrompt(b, y), o = 0, n = "Your account lock has been lifted. You may try again.";
|
|
1989
2010
|
} else
|
|
1990
|
-
throw d.error("[CROSSx][Migration Phase 4] verify-recovery-pin 실패 (복구 불가):",
|
|
2011
|
+
throw d.error("[CROSSx][Migration Phase 4] verify-recovery-pin 실패 (복구 불가):", _), _;
|
|
1991
2012
|
}
|
|
1992
2013
|
}
|
|
1993
2014
|
d.log("[CROSSx][Migration Phase 5] PIN 검증 완료 — 비밀번호 설정 및 마이그레이션 진행");
|
|
@@ -2018,13 +2039,13 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2018
2039
|
if (!n && !o && !i && !a) return e;
|
|
2019
2040
|
const c = { ...e }, l = n ? c.from ?? this.address : void 0;
|
|
2020
2041
|
l && d.log("[CROSSx] nonce 비어있음 → eth_getTransactionCount 호출 (from:", l, ")"), o && d.log("[CROSSx] gasLimit 비어있음 → eth_estimateGas 호출"), i && d.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
|
|
2021
|
-
const [u, h,
|
|
2042
|
+
const [u, h, _] = await Promise.all([
|
|
2022
2043
|
l ? this.jsonRpc.call("eth_getTransactionCount", [l, "pending"], s) : null,
|
|
2023
2044
|
o ? this.estimateGas(e, s) : null,
|
|
2024
2045
|
i ? this.getBaseFeePerGas(s) : null
|
|
2025
2046
|
]);
|
|
2026
2047
|
if (l && (c.nonce = parseInt(u ?? "0x0", 16), d.log("[CROSSx] nonce 결과:", c.nonce)), o && (c.gasLimit = h, d.log("[CROSSx] estimateGas 결과:", c.gasLimit)), i) {
|
|
2027
|
-
const f =
|
|
2048
|
+
const f = _;
|
|
2028
2049
|
if (f) {
|
|
2029
2050
|
const w = Rt;
|
|
2030
2051
|
c.maxFeePerGas = "0x" + (BigInt(f) + BigInt(w)).toString(16), c.maxPriorityFeePerGas = w, d.log("[CROSSx] Dynamic 체인 감지 — baseFee:", f, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
|
|
@@ -2375,7 +2396,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2375
2396
|
};
|
|
2376
2397
|
re.OFFCHAIN_CHAIN_ID = "0";
|
|
2377
2398
|
let it = re;
|
|
2378
|
-
class
|
|
2399
|
+
class nr {
|
|
2379
2400
|
constructor() {
|
|
2380
2401
|
this.prefix = "crossx_";
|
|
2381
2402
|
}
|
|
@@ -2412,7 +2433,7 @@ class rr {
|
|
|
2412
2433
|
}
|
|
2413
2434
|
}
|
|
2414
2435
|
}
|
|
2415
|
-
const Xe = "crossx-sdk",
|
|
2436
|
+
const Xe = "crossx-sdk", or = 1, de = "data", ve = "keys", $e = "aes-primary", ir = 12;
|
|
2416
2437
|
class Nt {
|
|
2417
2438
|
constructor(e) {
|
|
2418
2439
|
this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
|
|
@@ -2422,7 +2443,7 @@ class Nt {
|
|
|
2422
2443
|
}
|
|
2423
2444
|
openDB(e = this.dbName) {
|
|
2424
2445
|
return new Promise((s, t) => {
|
|
2425
|
-
const n = indexedDB.open(e,
|
|
2446
|
+
const n = indexedDB.open(e, or);
|
|
2426
2447
|
n.onupgradeneeded = () => {
|
|
2427
2448
|
const o = n.result;
|
|
2428
2449
|
o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(ve) || o.createObjectStore(ve);
|
|
@@ -2500,7 +2521,7 @@ class Nt {
|
|
|
2500
2521
|
}
|
|
2501
2522
|
}
|
|
2502
2523
|
async encrypt(e) {
|
|
2503
|
-
const s = new Uint8Array(
|
|
2524
|
+
const s = new Uint8Array(ir);
|
|
2504
2525
|
crypto.getRandomValues(s);
|
|
2505
2526
|
const t = new TextEncoder().encode(e), n = await crypto.subtle.encrypt(
|
|
2506
2527
|
{ name: "AES-GCM", iv: s },
|
|
@@ -2593,7 +2614,7 @@ function ss(r, e) {
|
|
|
2593
2614
|
if (r.length < s)
|
|
2594
2615
|
throw new Error('"digestInto() output" expected to be of length >=' + s);
|
|
2595
2616
|
}
|
|
2596
|
-
function
|
|
2617
|
+
function ar(r) {
|
|
2597
2618
|
return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
|
|
2598
2619
|
}
|
|
2599
2620
|
function Pe(...r) {
|
|
@@ -2606,22 +2627,22 @@ function Ze(r) {
|
|
|
2606
2627
|
function ue(r, e) {
|
|
2607
2628
|
return r << 32 - e | r >>> e;
|
|
2608
2629
|
}
|
|
2609
|
-
const
|
|
2610
|
-
function
|
|
2630
|
+
const cr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
2631
|
+
function lr(r) {
|
|
2611
2632
|
return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
|
|
2612
2633
|
}
|
|
2613
|
-
function
|
|
2634
|
+
function dr(r) {
|
|
2614
2635
|
for (let e = 0; e < r.length; e++)
|
|
2615
|
-
r[e] =
|
|
2636
|
+
r[e] = lr(r[e]);
|
|
2616
2637
|
return r;
|
|
2617
2638
|
}
|
|
2618
|
-
const Ct =
|
|
2639
|
+
const Ct = cr ? (r) => r : dr, rs = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", ur = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
|
|
2619
2640
|
function Me(r) {
|
|
2620
2641
|
if (V(r), rs)
|
|
2621
2642
|
return r.toHex();
|
|
2622
2643
|
let e = "";
|
|
2623
2644
|
for (let s = 0; s < r.length; s++)
|
|
2624
|
-
e +=
|
|
2645
|
+
e += ur[r[s]];
|
|
2625
2646
|
return e;
|
|
2626
2647
|
}
|
|
2627
2648
|
const fe = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
@@ -2675,16 +2696,16 @@ function os(r = 32) {
|
|
|
2675
2696
|
throw new Error("crypto.getRandomValues must be defined");
|
|
2676
2697
|
return e.getRandomValues(new Uint8Array(r));
|
|
2677
2698
|
}
|
|
2678
|
-
const
|
|
2699
|
+
const hr = (r) => ({
|
|
2679
2700
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, r])
|
|
2680
2701
|
});
|
|
2681
|
-
function
|
|
2702
|
+
function pr(r, e, s) {
|
|
2682
2703
|
return r & e ^ ~r & s;
|
|
2683
2704
|
}
|
|
2684
|
-
function
|
|
2705
|
+
function fr(r, e, s) {
|
|
2685
2706
|
return r & e ^ r & s ^ e & s;
|
|
2686
2707
|
}
|
|
2687
|
-
class
|
|
2708
|
+
class _r {
|
|
2688
2709
|
constructor(e, s, t, n) {
|
|
2689
2710
|
E(this, "blockLen");
|
|
2690
2711
|
E(this, "outputLen");
|
|
@@ -2756,19 +2777,19 @@ const me = /* @__PURE__ */ Uint32Array.from([
|
|
|
2756
2777
|
528734635,
|
|
2757
2778
|
1541459225
|
|
2758
2779
|
]), Be = /* @__PURE__ */ BigInt(2 ** 32 - 1), Dt = /* @__PURE__ */ BigInt(32);
|
|
2759
|
-
function
|
|
2780
|
+
function xr(r, e = !1) {
|
|
2760
2781
|
return e ? { h: Number(r & Be), l: Number(r >> Dt & Be) } : { h: Number(r >> Dt & Be) | 0, l: Number(r & Be) | 0 };
|
|
2761
2782
|
}
|
|
2762
|
-
function
|
|
2783
|
+
function gr(r, e = !1) {
|
|
2763
2784
|
const s = r.length;
|
|
2764
2785
|
let t = new Uint32Array(s), n = new Uint32Array(s);
|
|
2765
2786
|
for (let o = 0; o < s; o++) {
|
|
2766
|
-
const { h: i, l: a } =
|
|
2787
|
+
const { h: i, l: a } = xr(r[o], e);
|
|
2767
2788
|
[t[o], n[o]] = [i, a];
|
|
2768
2789
|
}
|
|
2769
2790
|
return [t, n];
|
|
2770
2791
|
}
|
|
2771
|
-
const
|
|
2792
|
+
const mr = (r, e, s) => r << s | e >>> 32 - s, wr = (r, e, s) => e << s | r >>> 32 - s, yr = (r, e, s) => e << s - 32 | r >>> 64 - s, br = (r, e, s) => r << s - 32 | e >>> 64 - s, vr = /* @__PURE__ */ Uint32Array.from([
|
|
2772
2793
|
1116352408,
|
|
2773
2794
|
1899447441,
|
|
2774
2795
|
3049323471,
|
|
@@ -2834,7 +2855,7 @@ const gr = (r, e, s) => r << s | e >>> 32 - s, mr = (r, e, s) => e << s | r >>>
|
|
|
2834
2855
|
3204031479,
|
|
2835
2856
|
3329325298
|
|
2836
2857
|
]), we = /* @__PURE__ */ new Uint32Array(64);
|
|
2837
|
-
class
|
|
2858
|
+
class Sr extends _r {
|
|
2838
2859
|
constructor(e) {
|
|
2839
2860
|
super(64, e, 8, !1);
|
|
2840
2861
|
}
|
|
@@ -2850,12 +2871,12 @@ class vr extends fr {
|
|
|
2850
2871
|
for (let h = 0; h < 16; h++, s += 4)
|
|
2851
2872
|
we[h] = e.getUint32(s, !1);
|
|
2852
2873
|
for (let h = 16; h < 64; h++) {
|
|
2853
|
-
const
|
|
2874
|
+
const _ = we[h - 15], f = we[h - 2], w = ue(_, 7) ^ ue(_, 18) ^ _ >>> 3, b = ue(f, 17) ^ ue(f, 19) ^ f >>> 10;
|
|
2854
2875
|
we[h] = b + we[h - 7] + w + we[h - 16] | 0;
|
|
2855
2876
|
}
|
|
2856
2877
|
let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: u } = this;
|
|
2857
2878
|
for (let h = 0; h < 64; h++) {
|
|
2858
|
-
const
|
|
2879
|
+
const _ = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), f = u + _ + pr(a, c, l) + vr[h] + we[h] | 0, b = (ue(t, 2) ^ ue(t, 13) ^ ue(t, 22)) + fr(t, n, o) | 0;
|
|
2859
2880
|
u = l, l = c, c = a, a = i + f | 0, i = o, o = n, n = t, t = f + b | 0;
|
|
2860
2881
|
}
|
|
2861
2882
|
t = t + this.A | 0, n = n + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, u = u + this.H | 0, this.set(t, n, o, i, a, c, l, u);
|
|
@@ -2867,7 +2888,7 @@ class vr extends fr {
|
|
|
2867
2888
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), Pe(this.buffer);
|
|
2868
2889
|
}
|
|
2869
2890
|
}
|
|
2870
|
-
class
|
|
2891
|
+
class Er extends Sr {
|
|
2871
2892
|
constructor() {
|
|
2872
2893
|
super(32);
|
|
2873
2894
|
// We cannot use array here since array allows indexing by variable
|
|
@@ -2882,9 +2903,9 @@ class Sr extends vr {
|
|
|
2882
2903
|
E(this, "H", me[7] | 0);
|
|
2883
2904
|
}
|
|
2884
2905
|
}
|
|
2885
|
-
const
|
|
2886
|
-
() => new
|
|
2887
|
-
/* @__PURE__ */
|
|
2906
|
+
const Ir = /* @__PURE__ */ ns(
|
|
2907
|
+
() => new Er(),
|
|
2908
|
+
/* @__PURE__ */ hr(1)
|
|
2888
2909
|
);
|
|
2889
2910
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2890
2911
|
const ht = /* @__PURE__ */ BigInt(0), at = /* @__PURE__ */ BigInt(1);
|
|
@@ -2916,7 +2937,7 @@ function ze(r) {
|
|
|
2916
2937
|
return as(Me(r));
|
|
2917
2938
|
}
|
|
2918
2939
|
function cs(r) {
|
|
2919
|
-
return as(Me(
|
|
2940
|
+
return as(Me(Tr(V(r)).reverse()));
|
|
2920
2941
|
}
|
|
2921
2942
|
function pt(r, e) {
|
|
2922
2943
|
ge(e), r = is(r);
|
|
@@ -2928,49 +2949,49 @@ function pt(r, e) {
|
|
|
2928
2949
|
function ls(r, e) {
|
|
2929
2950
|
return pt(r, e).reverse();
|
|
2930
2951
|
}
|
|
2931
|
-
function
|
|
2952
|
+
function Tr(r) {
|
|
2932
2953
|
return Uint8Array.from(r);
|
|
2933
2954
|
}
|
|
2934
2955
|
const Fe = (r) => typeof r == "bigint" && ht <= r;
|
|
2935
2956
|
function Ar(r, e, s) {
|
|
2936
2957
|
return Fe(r) && Fe(e) && Fe(s) && e <= r && r < s;
|
|
2937
2958
|
}
|
|
2938
|
-
function
|
|
2959
|
+
function Rr(r, e, s, t) {
|
|
2939
2960
|
if (!Ar(e, s, t))
|
|
2940
2961
|
throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
|
|
2941
2962
|
}
|
|
2942
|
-
function
|
|
2963
|
+
function kr(r) {
|
|
2943
2964
|
let e;
|
|
2944
2965
|
for (e = 0; r > ht; r >>= at, e += 1)
|
|
2945
2966
|
;
|
|
2946
2967
|
return e;
|
|
2947
2968
|
}
|
|
2948
2969
|
const ft = (r) => (at << BigInt(r)) - at;
|
|
2949
|
-
function
|
|
2970
|
+
function Pr(r, e, s) {
|
|
2950
2971
|
if (ge(r, "hashLen"), ge(e, "qByteLen"), typeof s != "function")
|
|
2951
2972
|
throw new Error("hmacFn must be a function");
|
|
2952
2973
|
const t = (y) => new Uint8Array(y), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
|
|
2953
2974
|
let c = t(r), l = t(r), u = 0;
|
|
2954
2975
|
const h = () => {
|
|
2955
2976
|
c.fill(1), l.fill(0), u = 0;
|
|
2956
|
-
},
|
|
2957
|
-
l =
|
|
2977
|
+
}, _ = (...y) => s(l, be(c, ...y)), f = (y = n) => {
|
|
2978
|
+
l = _(o, y), c = _(), y.length !== 0 && (l = _(i, y), c = _());
|
|
2958
2979
|
}, w = () => {
|
|
2959
2980
|
if (u++ >= a)
|
|
2960
2981
|
throw new Error("drbg: tried max amount of iterations");
|
|
2961
2982
|
let y = 0;
|
|
2962
|
-
const
|
|
2983
|
+
const T = [];
|
|
2963
2984
|
for (; y < e; ) {
|
|
2964
|
-
c =
|
|
2985
|
+
c = _();
|
|
2965
2986
|
const C = c.slice();
|
|
2966
|
-
|
|
2987
|
+
T.push(C), y += c.length;
|
|
2967
2988
|
}
|
|
2968
|
-
return be(...
|
|
2989
|
+
return be(...T);
|
|
2969
2990
|
};
|
|
2970
|
-
return (y,
|
|
2991
|
+
return (y, T) => {
|
|
2971
2992
|
h(), f(y);
|
|
2972
2993
|
let C;
|
|
2973
|
-
for (; !(C =
|
|
2994
|
+
for (; !(C = T(w())); )
|
|
2974
2995
|
f();
|
|
2975
2996
|
return h(), C;
|
|
2976
2997
|
};
|
|
@@ -3000,7 +3021,7 @@ function Mt(r) {
|
|
|
3000
3021
|
};
|
|
3001
3022
|
}
|
|
3002
3023
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3003
|
-
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),
|
|
3024
|
+
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), Or = /* @__PURE__ */ BigInt(7), ps = /* @__PURE__ */ BigInt(8), Nr = /* @__PURE__ */ BigInt(9), fs = /* @__PURE__ */ BigInt(16);
|
|
3004
3025
|
function le(r, e) {
|
|
3005
3026
|
const s = r % e;
|
|
3006
3027
|
return s >= ne ? s : e + s;
|
|
@@ -3033,16 +3054,16 @@ function _s(r, e) {
|
|
|
3033
3054
|
const s = (r.ORDER + ee) / us, t = r.pow(e, s);
|
|
3034
3055
|
return xt(r, t, e), t;
|
|
3035
3056
|
}
|
|
3036
|
-
function
|
|
3057
|
+
function Cr(r, e) {
|
|
3037
3058
|
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));
|
|
3038
3059
|
return xt(r, a, e), a;
|
|
3039
3060
|
}
|
|
3040
|
-
function
|
|
3041
|
-
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 +
|
|
3061
|
+
function Lr(r) {
|
|
3062
|
+
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 + Or) / fs;
|
|
3042
3063
|
return (a, c) => {
|
|
3043
3064
|
let l = a.pow(c, i), u = a.mul(l, t);
|
|
3044
|
-
const h = a.mul(l, n),
|
|
3045
|
-
l = a.cmov(l, u, f), u = a.cmov(
|
|
3065
|
+
const h = a.mul(l, n), _ = a.mul(l, o), f = a.eql(a.sqr(u), c), w = a.eql(a.sqr(h), c);
|
|
3066
|
+
l = a.cmov(l, u, f), u = a.cmov(_, h, w);
|
|
3046
3067
|
const b = a.eql(a.sqr(u), c), y = a.cmov(l, u, b);
|
|
3047
3068
|
return xt(a, y, c), y;
|
|
3048
3069
|
};
|
|
@@ -3067,24 +3088,24 @@ function xs(r) {
|
|
|
3067
3088
|
return l;
|
|
3068
3089
|
if (Bt(c, l) !== 1)
|
|
3069
3090
|
throw new Error("Cannot find square root");
|
|
3070
|
-
let u = s, h = c.mul(c.ONE, o),
|
|
3071
|
-
for (; !c.eql(
|
|
3072
|
-
if (c.is0(
|
|
3091
|
+
let u = s, h = c.mul(c.ONE, o), _ = c.pow(l, e), f = c.pow(l, i);
|
|
3092
|
+
for (; !c.eql(_, c.ONE); ) {
|
|
3093
|
+
if (c.is0(_))
|
|
3073
3094
|
return c.ZERO;
|
|
3074
|
-
let w = 1, b = c.sqr(
|
|
3095
|
+
let w = 1, b = c.sqr(_);
|
|
3075
3096
|
for (; !c.eql(b, c.ONE); )
|
|
3076
3097
|
if (w++, b = c.sqr(b), w === u)
|
|
3077
3098
|
throw new Error("Cannot find square root");
|
|
3078
|
-
const y = ee << BigInt(u - w - 1),
|
|
3079
|
-
u = w, h = c.sqr(
|
|
3099
|
+
const y = ee << BigInt(u - w - 1), T = c.pow(h, y);
|
|
3100
|
+
u = w, h = c.sqr(T), _ = c.mul(_, h), f = c.mul(f, T);
|
|
3080
3101
|
}
|
|
3081
3102
|
return f;
|
|
3082
3103
|
};
|
|
3083
3104
|
}
|
|
3084
|
-
function
|
|
3085
|
-
return r % us === ds ? _s : r % ps === hs ?
|
|
3105
|
+
function Dr(r) {
|
|
3106
|
+
return r % us === ds ? _s : r % ps === hs ? Cr : r % fs === Nr ? Lr(r) : xs(r);
|
|
3086
3107
|
}
|
|
3087
|
-
const
|
|
3108
|
+
const Mr = [
|
|
3088
3109
|
"create",
|
|
3089
3110
|
"isValid",
|
|
3090
3111
|
"is0",
|
|
@@ -3103,15 +3124,15 @@ const Dr = [
|
|
|
3103
3124
|
"mulN",
|
|
3104
3125
|
"sqrN"
|
|
3105
3126
|
];
|
|
3106
|
-
function
|
|
3127
|
+
function $r(r) {
|
|
3107
3128
|
const e = {
|
|
3108
3129
|
ORDER: "bigint",
|
|
3109
3130
|
BYTES: "number",
|
|
3110
3131
|
BITS: "number"
|
|
3111
|
-
}, s =
|
|
3132
|
+
}, s = Mr.reduce((t, n) => (t[n] = "function", t), e);
|
|
3112
3133
|
return _t(r, s), r;
|
|
3113
3134
|
}
|
|
3114
|
-
function
|
|
3135
|
+
function Br(r, e, s) {
|
|
3115
3136
|
if (s < ne)
|
|
3116
3137
|
throw new Error("invalid exponent, negatives unsupported");
|
|
3117
3138
|
if (s === ne)
|
|
@@ -3133,12 +3154,12 @@ function Bt(r, e) {
|
|
|
3133
3154
|
throw new Error("invalid Legendre symbol result");
|
|
3134
3155
|
return n ? 1 : o ? 0 : -1;
|
|
3135
3156
|
}
|
|
3136
|
-
function
|
|
3157
|
+
function Ur(r, e) {
|
|
3137
3158
|
e !== void 0 && ge(e);
|
|
3138
3159
|
const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
|
|
3139
3160
|
return { nBitLength: s, nByteLength: t };
|
|
3140
3161
|
}
|
|
3141
|
-
class
|
|
3162
|
+
class Hr {
|
|
3142
3163
|
constructor(e, s = {}) {
|
|
3143
3164
|
E(this, "ORDER");
|
|
3144
3165
|
E(this, "BITS");
|
|
@@ -3155,7 +3176,7 @@ class Ur {
|
|
|
3155
3176
|
throw new Error("invalid field: expected ORDER > 0, got " + e);
|
|
3156
3177
|
let t;
|
|
3157
3178
|
this.isLE = !1, s != null && typeof s == "object" && (typeof s.BITS == "number" && (t = s.BITS), typeof s.sqrt == "function" && (this.sqrt = s.sqrt), typeof s.isLE == "boolean" && (this.isLE = s.isLE), s.allowedLengths && (this._lengths = (i = s.allowedLengths) == null ? void 0 : i.slice()), typeof s.modFromBytes == "boolean" && (this._mod = s.modFromBytes));
|
|
3158
|
-
const { nBitLength: n, nByteLength: o } =
|
|
3179
|
+
const { nBitLength: n, nByteLength: o } = Ur(e, t);
|
|
3159
3180
|
if (o > 2048)
|
|
3160
3181
|
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
3161
3182
|
this.ORDER = e, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
|
|
@@ -3197,7 +3218,7 @@ class Ur {
|
|
|
3197
3218
|
return le(e * s, this.ORDER);
|
|
3198
3219
|
}
|
|
3199
3220
|
pow(e, s) {
|
|
3200
|
-
return
|
|
3221
|
+
return Br(this, e, s);
|
|
3201
3222
|
}
|
|
3202
3223
|
div(e, s) {
|
|
3203
3224
|
return le(e * $t(s, this.ORDER), this.ORDER);
|
|
@@ -3219,7 +3240,7 @@ class Ur {
|
|
|
3219
3240
|
return $t(e, this.ORDER);
|
|
3220
3241
|
}
|
|
3221
3242
|
sqrt(e) {
|
|
3222
|
-
return this._sqrt || (this._sqrt =
|
|
3243
|
+
return this._sqrt || (this._sqrt = Dr(this.ORDER)), this._sqrt(this, e);
|
|
3223
3244
|
}
|
|
3224
3245
|
toBytes(e) {
|
|
3225
3246
|
return this.isLE ? ls(e, this.BYTES) : pt(e, this.BYTES);
|
|
@@ -3251,7 +3272,7 @@ class Ur {
|
|
|
3251
3272
|
}
|
|
3252
3273
|
}
|
|
3253
3274
|
function je(r, e = {}) {
|
|
3254
|
-
return new
|
|
3275
|
+
return new Hr(r, e);
|
|
3255
3276
|
}
|
|
3256
3277
|
function ms(r) {
|
|
3257
3278
|
if (typeof r != "bigint")
|
|
@@ -3263,7 +3284,7 @@ function ws(r) {
|
|
|
3263
3284
|
const e = ms(r);
|
|
3264
3285
|
return e + Math.ceil(e / 2);
|
|
3265
3286
|
}
|
|
3266
|
-
function
|
|
3287
|
+
function Fr(r, e, s = !1) {
|
|
3267
3288
|
V(r);
|
|
3268
3289
|
const t = r.length, n = ms(e), o = ws(e);
|
|
3269
3290
|
if (t < 16 || t < o || t > 1024)
|
|
@@ -3272,7 +3293,7 @@ function Hr(r, e, s = !1) {
|
|
|
3272
3293
|
return s ? ls(a, n) : pt(a, n);
|
|
3273
3294
|
}
|
|
3274
3295
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3275
|
-
const Oe = /* @__PURE__ */ BigInt(0),
|
|
3296
|
+
const Oe = /* @__PURE__ */ BigInt(0), Te = /* @__PURE__ */ BigInt(1);
|
|
3276
3297
|
function Ke(r, e) {
|
|
3277
3298
|
const s = e.negate();
|
|
3278
3299
|
return r ? s : e;
|
|
@@ -3293,9 +3314,9 @@ function Qe(r, e) {
|
|
|
3293
3314
|
function Ht(r, e, s) {
|
|
3294
3315
|
const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
|
|
3295
3316
|
let a = Number(r & n), c = r >> i;
|
|
3296
|
-
a > t && (a -= o, c +=
|
|
3297
|
-
const l = e * t, u = l + Math.abs(a) - 1, h = a === 0,
|
|
3298
|
-
return { nextN: c, offset: u, isZero: h, isNeg:
|
|
3317
|
+
a > t && (a -= o, c += Te);
|
|
3318
|
+
const l = e * t, u = l + Math.abs(a) - 1, h = a === 0, _ = a < 0, f = e % 2 !== 0;
|
|
3319
|
+
return { nextN: c, offset: u, isZero: h, isNeg: _, isNegF: f, offsetF: l };
|
|
3299
3320
|
}
|
|
3300
3321
|
const et = /* @__PURE__ */ new WeakMap(), bs = /* @__PURE__ */ new WeakMap();
|
|
3301
3322
|
function tt(r) {
|
|
@@ -3305,7 +3326,7 @@ function Ft(r) {
|
|
|
3305
3326
|
if (r !== Oe)
|
|
3306
3327
|
throw new Error("invalid wNAF");
|
|
3307
3328
|
}
|
|
3308
|
-
class
|
|
3329
|
+
class Gr {
|
|
3309
3330
|
// Parametrized with a given Point class (not individual point)
|
|
3310
3331
|
constructor(e, s) {
|
|
3311
3332
|
E(this, "BASE");
|
|
@@ -3318,7 +3339,7 @@ class Fr {
|
|
|
3318
3339
|
_unsafeLadder(e, s, t = this.ZERO) {
|
|
3319
3340
|
let n = e;
|
|
3320
3341
|
for (; s > Oe; )
|
|
3321
|
-
s &
|
|
3342
|
+
s & Te && (t = t.add(n)), n = n.double(), s >>= Te;
|
|
3322
3343
|
return t;
|
|
3323
3344
|
}
|
|
3324
3345
|
/**
|
|
@@ -3356,8 +3377,8 @@ class Fr {
|
|
|
3356
3377
|
let n = this.ZERO, o = this.BASE;
|
|
3357
3378
|
const i = Qe(e, this.bits);
|
|
3358
3379
|
for (let a = 0; a < i.windows; a++) {
|
|
3359
|
-
const { nextN: c, offset: l, isZero: u, isNeg: h, isNegF:
|
|
3360
|
-
t = c, u ? o = o.add(Ke(
|
|
3380
|
+
const { nextN: c, offset: l, isZero: u, isNeg: h, isNegF: _, offsetF: f } = Ht(t, a, i);
|
|
3381
|
+
t = c, u ? o = o.add(Ke(_, s[f])) : n = n.add(Ke(h, s[l]));
|
|
3361
3382
|
}
|
|
3362
3383
|
return Ft(t), { p: n, f: o };
|
|
3363
3384
|
}
|
|
@@ -3399,21 +3420,21 @@ class Fr {
|
|
|
3399
3420
|
return tt(e) !== 1;
|
|
3400
3421
|
}
|
|
3401
3422
|
}
|
|
3402
|
-
function
|
|
3423
|
+
function Wr(r, e, s, t) {
|
|
3403
3424
|
let n = e, o = r.ZERO, i = r.ZERO;
|
|
3404
3425
|
for (; s > Oe || t > Oe; )
|
|
3405
|
-
s &
|
|
3426
|
+
s & Te && (o = o.add(n)), t & Te && (i = i.add(n)), n = n.double(), s >>= Te, t >>= Te;
|
|
3406
3427
|
return { p1: o, p2: i };
|
|
3407
3428
|
}
|
|
3408
3429
|
function Gt(r, e, s) {
|
|
3409
3430
|
if (e) {
|
|
3410
3431
|
if (e.ORDER !== r)
|
|
3411
3432
|
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
3412
|
-
return
|
|
3433
|
+
return $r(e), e;
|
|
3413
3434
|
} else
|
|
3414
3435
|
return je(r, { isLE: s });
|
|
3415
3436
|
}
|
|
3416
|
-
function
|
|
3437
|
+
function qr(r, e, s = {}, t) {
|
|
3417
3438
|
if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
|
|
3418
3439
|
throw new Error(`expected valid ${r} CURVE object`);
|
|
3419
3440
|
for (const c of ["p", "n", "h"]) {
|
|
@@ -3427,7 +3448,7 @@ function Wr(r, e, s = {}, t) {
|
|
|
3427
3448
|
throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
|
|
3428
3449
|
return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: n, Fn: o };
|
|
3429
3450
|
}
|
|
3430
|
-
function
|
|
3451
|
+
function Kr(r, e) {
|
|
3431
3452
|
return function(t) {
|
|
3432
3453
|
const n = r(t);
|
|
3433
3454
|
return { secretKey: n, publicKey: e(n) };
|
|
@@ -3479,15 +3500,15 @@ const Ss = (r, e, s) => new vs(r, e).update(s).digest();
|
|
|
3479
3500
|
Ss.create = (r, e) => new vs(r, e);
|
|
3480
3501
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3481
3502
|
const Wt = (r, e) => (r + (r >= 0 ? e : -e) / Es) / e;
|
|
3482
|
-
function
|
|
3503
|
+
function Vr(r, e, s) {
|
|
3483
3504
|
const [[t, n], [o, i]] = e, a = Wt(i * r, s), c = Wt(-n * r, s);
|
|
3484
3505
|
let l = r - a * t - c * o, u = -a * n - c * i;
|
|
3485
|
-
const h = l < _e,
|
|
3486
|
-
h && (l = -l),
|
|
3487
|
-
const f = ft(Math.ceil(
|
|
3506
|
+
const h = l < _e, _ = u < _e;
|
|
3507
|
+
h && (l = -l), _ && (u = -u);
|
|
3508
|
+
const f = ft(Math.ceil(kr(s) / 2)) + Re;
|
|
3488
3509
|
if (l < _e || l >= f || u < _e || u >= f)
|
|
3489
3510
|
throw new Error("splitScalar (endomorphism): failed, k=" + r);
|
|
3490
|
-
return { k1neg: h, k1: l, k2neg:
|
|
3511
|
+
return { k1neg: h, k1: l, k2neg: _, k2: u };
|
|
3491
3512
|
}
|
|
3492
3513
|
function ct(r) {
|
|
3493
3514
|
if (!["compact", "recovered", "der"].includes(r))
|
|
@@ -3500,14 +3521,14 @@ function st(r, e) {
|
|
|
3500
3521
|
s[t] = r[t] === void 0 ? e[t] : r[t];
|
|
3501
3522
|
return qe(s.lowS, "lowS"), qe(s.prehash, "prehash"), s.format !== void 0 && ct(s.format), s;
|
|
3502
3523
|
}
|
|
3503
|
-
class
|
|
3524
|
+
class zr extends Error {
|
|
3504
3525
|
constructor(e = "") {
|
|
3505
3526
|
super(e);
|
|
3506
3527
|
}
|
|
3507
3528
|
}
|
|
3508
3529
|
const ye = {
|
|
3509
3530
|
// asn.1 DER encoding utils
|
|
3510
|
-
Err:
|
|
3531
|
+
Err: zr,
|
|
3511
3532
|
// Basic building block is TLV (Tag-Length-Value)
|
|
3512
3533
|
_tlv: {
|
|
3513
3534
|
encode: (r, e) => {
|
|
@@ -3592,9 +3613,9 @@ const ye = {
|
|
|
3592
3613
|
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;
|
|
3593
3614
|
return e.encode(48, o);
|
|
3594
3615
|
}
|
|
3595
|
-
}, _e = BigInt(0), Re = BigInt(1), Es = BigInt(2), He = BigInt(3),
|
|
3596
|
-
function
|
|
3597
|
-
const s =
|
|
3616
|
+
}, _e = BigInt(0), Re = BigInt(1), Es = BigInt(2), He = BigInt(3), jr = BigInt(4);
|
|
3617
|
+
function Yr(r, e = {}) {
|
|
3618
|
+
const s = qr("weierstrass", r, e), { Fp: t, Fn: n } = s;
|
|
3598
3619
|
let o = s.CURVE;
|
|
3599
3620
|
const { h: i, n: a } = o;
|
|
3600
3621
|
_t(e, {}, {
|
|
@@ -3608,64 +3629,64 @@ function jr(r, e = {}) {
|
|
|
3608
3629
|
const { endo: c } = e;
|
|
3609
3630
|
if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
|
|
3610
3631
|
throw new Error('invalid endo: expected "beta": bigint and "basises": array');
|
|
3611
|
-
const l =
|
|
3632
|
+
const l = Ts(t, n);
|
|
3612
3633
|
function u() {
|
|
3613
3634
|
if (!t.isOdd)
|
|
3614
3635
|
throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
3615
3636
|
}
|
|
3616
|
-
function h(I,
|
|
3617
|
-
const { x: v, y:
|
|
3637
|
+
function h(I, x, g) {
|
|
3638
|
+
const { x: v, y: k } = x.toAffine(), D = t.toBytes(v);
|
|
3618
3639
|
if (qe(g, "isCompressed"), g) {
|
|
3619
3640
|
u();
|
|
3620
|
-
const N = !t.isOdd(
|
|
3641
|
+
const N = !t.isOdd(k);
|
|
3621
3642
|
return be(Is(N), D);
|
|
3622
3643
|
} else
|
|
3623
|
-
return be(Uint8Array.of(4), D, t.toBytes(
|
|
3644
|
+
return be(Uint8Array.of(4), D, t.toBytes(k));
|
|
3624
3645
|
}
|
|
3625
|
-
function
|
|
3646
|
+
function _(I) {
|
|
3626
3647
|
V(I, void 0, "Point");
|
|
3627
|
-
const { publicKey:
|
|
3628
|
-
if (v ===
|
|
3648
|
+
const { publicKey: x, publicKeyUncompressed: g } = l, v = I.length, k = I[0], D = I.subarray(1);
|
|
3649
|
+
if (v === x && (k === 2 || k === 3)) {
|
|
3629
3650
|
const N = t.fromBytes(D);
|
|
3630
3651
|
if (!t.isValid(N))
|
|
3631
3652
|
throw new Error("bad point: is not on curve, wrong x");
|
|
3632
3653
|
const M = b(N);
|
|
3633
|
-
let
|
|
3654
|
+
let R;
|
|
3634
3655
|
try {
|
|
3635
|
-
|
|
3656
|
+
R = t.sqrt(M);
|
|
3636
3657
|
} catch (J) {
|
|
3637
3658
|
const K = J instanceof Error ? ": " + J.message : "";
|
|
3638
3659
|
throw new Error("bad point: is not on curve, sqrt error" + K);
|
|
3639
3660
|
}
|
|
3640
3661
|
u();
|
|
3641
|
-
const $ = t.isOdd(
|
|
3642
|
-
return (
|
|
3643
|
-
} else if (v === g &&
|
|
3644
|
-
const N = t.BYTES, M = t.fromBytes(D.subarray(0, N)),
|
|
3645
|
-
if (!y(M,
|
|
3662
|
+
const $ = t.isOdd(R);
|
|
3663
|
+
return (k & 1) === 1 !== $ && (R = t.neg(R)), { x: N, y: R };
|
|
3664
|
+
} else if (v === g && k === 4) {
|
|
3665
|
+
const N = t.BYTES, M = t.fromBytes(D.subarray(0, N)), R = t.fromBytes(D.subarray(N, N * 2));
|
|
3666
|
+
if (!y(M, R))
|
|
3646
3667
|
throw new Error("bad point: is not on curve");
|
|
3647
|
-
return { x: M, y:
|
|
3668
|
+
return { x: M, y: R };
|
|
3648
3669
|
} else
|
|
3649
|
-
throw new Error(`bad point: got length ${v}, expected compressed=${
|
|
3670
|
+
throw new Error(`bad point: got length ${v}, expected compressed=${x} or uncompressed=${g}`);
|
|
3650
3671
|
}
|
|
3651
|
-
const f = e.toBytes || h, w = e.fromBytes ||
|
|
3672
|
+
const f = e.toBytes || h, w = e.fromBytes || _;
|
|
3652
3673
|
function b(I) {
|
|
3653
|
-
const
|
|
3674
|
+
const x = t.sqr(I), g = t.mul(x, I);
|
|
3654
3675
|
return t.add(t.add(g, t.mul(I, o.a)), o.b);
|
|
3655
3676
|
}
|
|
3656
|
-
function y(I,
|
|
3657
|
-
const g = t.sqr(
|
|
3677
|
+
function y(I, x) {
|
|
3678
|
+
const g = t.sqr(x), v = b(I);
|
|
3658
3679
|
return t.eql(g, v);
|
|
3659
3680
|
}
|
|
3660
3681
|
if (!y(o.Gx, o.Gy))
|
|
3661
3682
|
throw new Error("bad curve params: generator point");
|
|
3662
|
-
const
|
|
3663
|
-
if (t.is0(t.add(
|
|
3683
|
+
const T = t.mul(t.pow(o.a, He), jr), C = t.mul(t.sqr(o.b), BigInt(27));
|
|
3684
|
+
if (t.is0(t.add(T, C)))
|
|
3664
3685
|
throw new Error("bad curve params: a or b");
|
|
3665
|
-
function W(I,
|
|
3666
|
-
if (!t.isValid(
|
|
3686
|
+
function W(I, x, g = !1) {
|
|
3687
|
+
if (!t.isValid(x) || g && t.is0(x))
|
|
3667
3688
|
throw new Error(`bad point coordinate ${I}`);
|
|
3668
|
-
return
|
|
3689
|
+
return x;
|
|
3669
3690
|
}
|
|
3670
3691
|
function B(I) {
|
|
3671
3692
|
if (!(I instanceof L))
|
|
@@ -3674,18 +3695,18 @@ function jr(r, e = {}) {
|
|
|
3674
3695
|
function j(I) {
|
|
3675
3696
|
if (!c || !c.basises)
|
|
3676
3697
|
throw new Error("no endo");
|
|
3677
|
-
return
|
|
3698
|
+
return Vr(I, c.basises, n.ORDER);
|
|
3678
3699
|
}
|
|
3679
|
-
const q = Mt((I,
|
|
3680
|
-
const { X: g, Y: v, Z:
|
|
3681
|
-
if (t.eql(
|
|
3700
|
+
const q = Mt((I, x) => {
|
|
3701
|
+
const { X: g, Y: v, Z: k } = I;
|
|
3702
|
+
if (t.eql(k, t.ONE))
|
|
3682
3703
|
return { x: g, y: v };
|
|
3683
3704
|
const D = I.is0();
|
|
3684
|
-
|
|
3685
|
-
const N = t.mul(g,
|
|
3705
|
+
x == null && (x = D ? t.ONE : t.inv(k));
|
|
3706
|
+
const N = t.mul(g, x), M = t.mul(v, x), R = t.mul(k, x);
|
|
3686
3707
|
if (D)
|
|
3687
3708
|
return { x: t.ZERO, y: t.ZERO };
|
|
3688
|
-
if (!t.eql(
|
|
3709
|
+
if (!t.eql(R, t.ONE))
|
|
3689
3710
|
throw new Error("invZ was invalid");
|
|
3690
3711
|
return { x: N, y: M };
|
|
3691
3712
|
}), P = Mt((I) => {
|
|
@@ -3694,44 +3715,44 @@ function jr(r, e = {}) {
|
|
|
3694
3715
|
return;
|
|
3695
3716
|
throw new Error("bad point: ZERO");
|
|
3696
3717
|
}
|
|
3697
|
-
const { x
|
|
3698
|
-
if (!t.isValid(
|
|
3718
|
+
const { x, y: g } = I.toAffine();
|
|
3719
|
+
if (!t.isValid(x) || !t.isValid(g))
|
|
3699
3720
|
throw new Error("bad point: x or y not field elements");
|
|
3700
|
-
if (!y(
|
|
3721
|
+
if (!y(x, g))
|
|
3701
3722
|
throw new Error("bad point: equation left != right");
|
|
3702
3723
|
if (!I.isTorsionFree())
|
|
3703
3724
|
throw new Error("bad point: not in prime-order subgroup");
|
|
3704
3725
|
return !0;
|
|
3705
3726
|
});
|
|
3706
|
-
function S(I,
|
|
3707
|
-
return g = new L(t.mul(g.X, I), g.Y, g.Z),
|
|
3727
|
+
function S(I, x, g, v, k) {
|
|
3728
|
+
return g = new L(t.mul(g.X, I), g.Y, g.Z), x = Ke(v, x), g = Ke(k, g), x.add(g);
|
|
3708
3729
|
}
|
|
3709
3730
|
const A = class A {
|
|
3710
3731
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
3711
|
-
constructor(
|
|
3732
|
+
constructor(x, g, v) {
|
|
3712
3733
|
E(this, "X");
|
|
3713
3734
|
E(this, "Y");
|
|
3714
3735
|
E(this, "Z");
|
|
3715
|
-
this.X = W("x",
|
|
3736
|
+
this.X = W("x", x), this.Y = W("y", g, !0), this.Z = W("z", v), Object.freeze(this);
|
|
3716
3737
|
}
|
|
3717
3738
|
static CURVE() {
|
|
3718
3739
|
return o;
|
|
3719
3740
|
}
|
|
3720
3741
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
3721
|
-
static fromAffine(
|
|
3722
|
-
const { x: g, y: v } =
|
|
3723
|
-
if (!
|
|
3742
|
+
static fromAffine(x) {
|
|
3743
|
+
const { x: g, y: v } = x || {};
|
|
3744
|
+
if (!x || !t.isValid(g) || !t.isValid(v))
|
|
3724
3745
|
throw new Error("invalid affine point");
|
|
3725
|
-
if (
|
|
3746
|
+
if (x instanceof A)
|
|
3726
3747
|
throw new Error("projective point not allowed");
|
|
3727
3748
|
return t.is0(g) && t.is0(v) ? A.ZERO : new A(g, v, t.ONE);
|
|
3728
3749
|
}
|
|
3729
|
-
static fromBytes(
|
|
3730
|
-
const g = A.fromAffine(w(V(
|
|
3750
|
+
static fromBytes(x) {
|
|
3751
|
+
const g = A.fromAffine(w(V(x, void 0, "point")));
|
|
3731
3752
|
return g.assertValidity(), g;
|
|
3732
3753
|
}
|
|
3733
|
-
static fromHex(
|
|
3734
|
-
return A.fromBytes(We(
|
|
3754
|
+
static fromHex(x) {
|
|
3755
|
+
return A.fromBytes(We(x));
|
|
3735
3756
|
}
|
|
3736
3757
|
get x() {
|
|
3737
3758
|
return this.toAffine().x;
|
|
@@ -3745,8 +3766,8 @@ function jr(r, e = {}) {
|
|
|
3745
3766
|
* @param isLazy true will defer table computation until the first multiplication
|
|
3746
3767
|
* @returns
|
|
3747
3768
|
*/
|
|
3748
|
-
precompute(
|
|
3749
|
-
return O.createCache(this,
|
|
3769
|
+
precompute(x = 8, g = !0) {
|
|
3770
|
+
return O.createCache(this, x), g || this.multiply(He), this;
|
|
3750
3771
|
}
|
|
3751
3772
|
// TODO: return `this`
|
|
3752
3773
|
/** A point on curve is valid if it conforms to equation. */
|
|
@@ -3754,16 +3775,16 @@ function jr(r, e = {}) {
|
|
|
3754
3775
|
P(this);
|
|
3755
3776
|
}
|
|
3756
3777
|
hasEvenY() {
|
|
3757
|
-
const { y:
|
|
3778
|
+
const { y: x } = this.toAffine();
|
|
3758
3779
|
if (!t.isOdd)
|
|
3759
3780
|
throw new Error("Field doesn't support isOdd");
|
|
3760
|
-
return !t.isOdd(
|
|
3781
|
+
return !t.isOdd(x);
|
|
3761
3782
|
}
|
|
3762
3783
|
/** Compare one point to another. */
|
|
3763
|
-
equals(
|
|
3764
|
-
B(
|
|
3765
|
-
const { X: g, Y: v, Z:
|
|
3766
|
-
return
|
|
3784
|
+
equals(x) {
|
|
3785
|
+
B(x);
|
|
3786
|
+
const { X: g, Y: v, Z: k } = this, { X: D, Y: N, Z: M } = x, R = t.eql(t.mul(g, M), t.mul(D, k)), $ = t.eql(t.mul(v, M), t.mul(N, k));
|
|
3787
|
+
return R && $;
|
|
3767
3788
|
}
|
|
3768
3789
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
3769
3790
|
negate() {
|
|
@@ -3774,26 +3795,26 @@ function jr(r, e = {}) {
|
|
|
3774
3795
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
3775
3796
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
3776
3797
|
double() {
|
|
3777
|
-
const { a:
|
|
3778
|
-
let M = t.ZERO,
|
|
3779
|
-
return H = t.add(H, H), $ = t.mul(
|
|
3798
|
+
const { a: x, b: g } = o, v = t.mul(g, He), { X: k, Y: D, Z: N } = this;
|
|
3799
|
+
let M = t.ZERO, R = t.ZERO, $ = t.ZERO, F = t.mul(k, k), J = t.mul(D, D), K = t.mul(N, N), H = t.mul(k, D);
|
|
3800
|
+
return H = t.add(H, H), $ = t.mul(k, N), $ = t.add($, $), M = t.mul(x, $), R = t.mul(v, K), R = t.add(M, R), M = t.sub(J, R), R = t.add(J, R), R = t.mul(M, R), M = t.mul(H, M), $ = t.mul(v, $), K = t.mul(x, K), H = t.sub(F, K), H = t.mul(x, H), H = t.add(H, $), $ = t.add(F, F), F = t.add($, F), F = t.add(F, K), F = t.mul(F, H), R = t.add(R, F), K = t.mul(D, N), K = t.add(K, K), F = t.mul(K, H), M = t.sub(M, F), $ = t.mul(K, J), $ = t.add($, $), $ = t.add($, $), new A(M, R, $);
|
|
3780
3801
|
}
|
|
3781
3802
|
// Renes-Costello-Batina exception-free addition formula.
|
|
3782
3803
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
3783
3804
|
// https://eprint.iacr.org/2015/1060, algorithm 1
|
|
3784
3805
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
3785
|
-
add(
|
|
3786
|
-
B(
|
|
3787
|
-
const { X: g, Y: v, Z:
|
|
3788
|
-
let
|
|
3806
|
+
add(x) {
|
|
3807
|
+
B(x);
|
|
3808
|
+
const { X: g, Y: v, Z: k } = this, { X: D, Y: N, Z: M } = x;
|
|
3809
|
+
let R = t.ZERO, $ = t.ZERO, F = t.ZERO;
|
|
3789
3810
|
const J = o.a, K = t.mul(o.b, He);
|
|
3790
|
-
let H = t.mul(g, D), X = t.mul(v, N), Z = t.mul(
|
|
3791
|
-
oe = t.mul(oe, z), z = t.add(H, X), oe = t.sub(oe, z), z = t.add(g,
|
|
3811
|
+
let H = t.mul(g, D), X = t.mul(v, N), Z = t.mul(k, M), oe = t.add(g, v), z = t.add(D, N);
|
|
3812
|
+
oe = t.mul(oe, z), z = t.add(H, X), oe = t.sub(oe, z), z = t.add(g, k);
|
|
3792
3813
|
let Q = t.add(D, M);
|
|
3793
|
-
return z = t.mul(z, Q), Q = t.add(H, Z), z = t.sub(z, Q), Q = t.add(v,
|
|
3814
|
+
return z = t.mul(z, Q), Q = t.add(H, Z), z = t.sub(z, Q), Q = t.add(v, k), R = t.add(N, M), Q = t.mul(Q, R), R = t.add(X, Z), Q = t.sub(Q, R), F = t.mul(J, z), R = t.mul(K, Z), F = t.add(R, F), R = t.sub(X, F), F = t.add(X, F), $ = t.mul(R, F), X = t.add(H, H), X = t.add(X, H), Z = t.mul(J, Z), z = t.mul(K, z), X = t.add(X, Z), Z = t.sub(H, Z), Z = t.mul(J, Z), z = t.add(z, Z), H = t.mul(X, z), $ = t.add($, H), H = t.mul(Q, z), R = t.mul(oe, R), R = t.sub(R, H), H = t.mul(oe, X), F = t.mul(Q, F), F = t.add(F, H), new A(R, $, F);
|
|
3794
3815
|
}
|
|
3795
|
-
subtract(
|
|
3796
|
-
return this.add(
|
|
3816
|
+
subtract(x) {
|
|
3817
|
+
return this.add(x.negate());
|
|
3797
3818
|
}
|
|
3798
3819
|
is0() {
|
|
3799
3820
|
return this.equals(A.ZERO);
|
|
@@ -3807,69 +3828,69 @@ function jr(r, e = {}) {
|
|
|
3807
3828
|
* @param scalar by which the point would be multiplied
|
|
3808
3829
|
* @returns New point
|
|
3809
3830
|
*/
|
|
3810
|
-
multiply(
|
|
3831
|
+
multiply(x) {
|
|
3811
3832
|
const { endo: g } = e;
|
|
3812
|
-
if (!n.isValidNot0(
|
|
3833
|
+
if (!n.isValidNot0(x))
|
|
3813
3834
|
throw new Error("invalid scalar: out of range");
|
|
3814
|
-
let v,
|
|
3835
|
+
let v, k;
|
|
3815
3836
|
const D = (N) => O.cached(this, N, (M) => Ut(A, M));
|
|
3816
3837
|
if (g) {
|
|
3817
|
-
const { k1neg: N, k1: M, k2neg:
|
|
3818
|
-
|
|
3838
|
+
const { k1neg: N, k1: M, k2neg: R, k2: $ } = j(x), { p: F, f: J } = D(M), { p: K, f: H } = D($);
|
|
3839
|
+
k = J.add(H), v = S(g.beta, F, K, N, R);
|
|
3819
3840
|
} else {
|
|
3820
|
-
const { p: N, f: M } = D(
|
|
3821
|
-
v = N,
|
|
3841
|
+
const { p: N, f: M } = D(x);
|
|
3842
|
+
v = N, k = M;
|
|
3822
3843
|
}
|
|
3823
|
-
return Ut(A, [v,
|
|
3844
|
+
return Ut(A, [v, k])[0];
|
|
3824
3845
|
}
|
|
3825
3846
|
/**
|
|
3826
3847
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
3827
3848
|
* It's faster, but should only be used when you don't care about
|
|
3828
3849
|
* an exposed secret key e.g. sig verification, which works over *public* keys.
|
|
3829
3850
|
*/
|
|
3830
|
-
multiplyUnsafe(
|
|
3851
|
+
multiplyUnsafe(x) {
|
|
3831
3852
|
const { endo: g } = e, v = this;
|
|
3832
|
-
if (!n.isValid(
|
|
3853
|
+
if (!n.isValid(x))
|
|
3833
3854
|
throw new Error("invalid scalar: out of range");
|
|
3834
|
-
if (
|
|
3855
|
+
if (x === _e || v.is0())
|
|
3835
3856
|
return A.ZERO;
|
|
3836
|
-
if (
|
|
3857
|
+
if (x === Re)
|
|
3837
3858
|
return v;
|
|
3838
3859
|
if (O.hasCache(this))
|
|
3839
|
-
return this.multiply(
|
|
3860
|
+
return this.multiply(x);
|
|
3840
3861
|
if (g) {
|
|
3841
|
-
const { k1neg:
|
|
3842
|
-
return S(g.beta,
|
|
3862
|
+
const { k1neg: k, k1: D, k2neg: N, k2: M } = j(x), { p1: R, p2: $ } = Wr(A, v, D, M);
|
|
3863
|
+
return S(g.beta, R, $, k, N);
|
|
3843
3864
|
} else
|
|
3844
|
-
return O.unsafe(v,
|
|
3865
|
+
return O.unsafe(v, x);
|
|
3845
3866
|
}
|
|
3846
3867
|
/**
|
|
3847
3868
|
* Converts Projective point to affine (x, y) coordinates.
|
|
3848
3869
|
* @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
|
|
3849
3870
|
*/
|
|
3850
|
-
toAffine(
|
|
3851
|
-
return q(this,
|
|
3871
|
+
toAffine(x) {
|
|
3872
|
+
return q(this, x);
|
|
3852
3873
|
}
|
|
3853
3874
|
/**
|
|
3854
3875
|
* Checks whether Point is free of torsion elements (is in prime subgroup).
|
|
3855
3876
|
* Always torsion-free for cofactor=1 curves.
|
|
3856
3877
|
*/
|
|
3857
3878
|
isTorsionFree() {
|
|
3858
|
-
const { isTorsionFree:
|
|
3859
|
-
return i === Re ? !0 :
|
|
3879
|
+
const { isTorsionFree: x } = e;
|
|
3880
|
+
return i === Re ? !0 : x ? x(A, this) : O.unsafe(this, a).is0();
|
|
3860
3881
|
}
|
|
3861
3882
|
clearCofactor() {
|
|
3862
|
-
const { clearCofactor:
|
|
3863
|
-
return i === Re ? this :
|
|
3883
|
+
const { clearCofactor: x } = e;
|
|
3884
|
+
return i === Re ? this : x ? x(A, this) : this.multiplyUnsafe(i);
|
|
3864
3885
|
}
|
|
3865
3886
|
isSmallOrder() {
|
|
3866
3887
|
return this.multiplyUnsafe(i).is0();
|
|
3867
3888
|
}
|
|
3868
|
-
toBytes(
|
|
3869
|
-
return qe(
|
|
3889
|
+
toBytes(x = !0) {
|
|
3890
|
+
return qe(x, "isCompressed"), this.assertValidity(), f(A, this, x);
|
|
3870
3891
|
}
|
|
3871
|
-
toHex(
|
|
3872
|
-
return Me(this.toBytes(
|
|
3892
|
+
toHex(x = !0) {
|
|
3893
|
+
return Me(this.toBytes(x));
|
|
3873
3894
|
}
|
|
3874
3895
|
toString() {
|
|
3875
3896
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
@@ -3882,13 +3903,13 @@ function jr(r, e = {}) {
|
|
|
3882
3903
|
E(A, "Fp", t), // scalar field
|
|
3883
3904
|
E(A, "Fn", n);
|
|
3884
3905
|
let L = A;
|
|
3885
|
-
const G = n.BITS, O = new
|
|
3906
|
+
const G = n.BITS, O = new Gr(L, e.endo ? Math.ceil(G / 2) : G);
|
|
3886
3907
|
return L.BASE.precompute(8), L;
|
|
3887
3908
|
}
|
|
3888
3909
|
function Is(r) {
|
|
3889
3910
|
return Uint8Array.of(r ? 2 : 3);
|
|
3890
3911
|
}
|
|
3891
|
-
function
|
|
3912
|
+
function Ts(r, e) {
|
|
3892
3913
|
return {
|
|
3893
3914
|
secretKey: e.BYTES,
|
|
3894
3915
|
publicKey: 1 + r.BYTES,
|
|
@@ -3897,8 +3918,8 @@ function As(r, e) {
|
|
|
3897
3918
|
signature: 2 * e.BYTES
|
|
3898
3919
|
};
|
|
3899
3920
|
}
|
|
3900
|
-
function
|
|
3901
|
-
const { Fn: s } = r, t = e.randomBytes || os, n = Object.assign(
|
|
3921
|
+
function Jr(r, e = {}) {
|
|
3922
|
+
const { Fn: s } = r, t = e.randomBytes || os, n = Object.assign(Ts(r.Fp, s), { seed: ws(s.ORDER) });
|
|
3902
3923
|
function o(f) {
|
|
3903
3924
|
try {
|
|
3904
3925
|
const w = s.fromBytes(f);
|
|
@@ -3910,14 +3931,14 @@ function Yr(r, e = {}) {
|
|
|
3910
3931
|
function i(f, w) {
|
|
3911
3932
|
const { publicKey: b, publicKeyUncompressed: y } = n;
|
|
3912
3933
|
try {
|
|
3913
|
-
const
|
|
3914
|
-
return w === !0 &&
|
|
3934
|
+
const T = f.length;
|
|
3935
|
+
return w === !0 && T !== b || w === !1 && T !== y ? !1 : !!r.fromBytes(f);
|
|
3915
3936
|
} catch {
|
|
3916
3937
|
return !1;
|
|
3917
3938
|
}
|
|
3918
3939
|
}
|
|
3919
3940
|
function a(f = t(n.seed)) {
|
|
3920
|
-
return
|
|
3941
|
+
return Fr(V(f, n.seed, "seed"), s.ORDER);
|
|
3921
3942
|
}
|
|
3922
3943
|
function c(f, w = !0) {
|
|
3923
3944
|
return r.BASE.multiply(s.fromBytes(f)).toBytes(w);
|
|
@@ -3926,8 +3947,8 @@ function Yr(r, e = {}) {
|
|
|
3926
3947
|
const { secretKey: w, publicKey: b, publicKeyUncompressed: y } = n;
|
|
3927
3948
|
if (!ut(f) || "_lengths" in s && s._lengths || w === b)
|
|
3928
3949
|
return;
|
|
3929
|
-
const
|
|
3930
|
-
return
|
|
3950
|
+
const T = V(f, void 0, "key").length;
|
|
3951
|
+
return T === b || T === y;
|
|
3931
3952
|
}
|
|
3932
3953
|
function u(f, w, b = !0) {
|
|
3933
3954
|
if (l(f) === !0)
|
|
@@ -3941,10 +3962,10 @@ function Yr(r, e = {}) {
|
|
|
3941
3962
|
isValidSecretKey: o,
|
|
3942
3963
|
isValidPublicKey: i,
|
|
3943
3964
|
randomSecretKey: a
|
|
3944
|
-
},
|
|
3945
|
-
return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen:
|
|
3965
|
+
}, _ = Kr(a, c);
|
|
3966
|
+
return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen: _, Point: r, utils: h, lengths: n });
|
|
3946
3967
|
}
|
|
3947
|
-
function
|
|
3968
|
+
function Xr(r, e, s = {}) {
|
|
3948
3969
|
ts(e), _t(s, {}, {
|
|
3949
3970
|
hmac: "function",
|
|
3950
3971
|
lowS: "boolean",
|
|
@@ -3952,52 +3973,52 @@ function Jr(r, e, s = {}) {
|
|
|
3952
3973
|
bits2int: "function",
|
|
3953
3974
|
bits2int_modN: "function"
|
|
3954
3975
|
}), s = Object.assign({}, s);
|
|
3955
|
-
const t = s.randomBytes || os, n = s.hmac || ((
|
|
3976
|
+
const t = s.randomBytes || os, n = s.hmac || ((x, g) => Ss(e, x, g)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: u, getSharedSecret: h, utils: _, lengths: f } = Jr(r, s), w = {
|
|
3956
3977
|
prehash: !0,
|
|
3957
3978
|
lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
|
|
3958
3979
|
format: "compact",
|
|
3959
3980
|
extraEntropy: !1
|
|
3960
3981
|
}, b = a * Es < o.ORDER;
|
|
3961
|
-
function y(
|
|
3982
|
+
function y(x) {
|
|
3962
3983
|
const g = a >> Re;
|
|
3963
|
-
return
|
|
3984
|
+
return x > g;
|
|
3964
3985
|
}
|
|
3965
|
-
function
|
|
3986
|
+
function T(x, g) {
|
|
3966
3987
|
if (!i.isValidNot0(g))
|
|
3967
|
-
throw new Error(`invalid signature ${
|
|
3988
|
+
throw new Error(`invalid signature ${x}: out of range 1..Point.Fn.ORDER`);
|
|
3968
3989
|
return g;
|
|
3969
3990
|
}
|
|
3970
3991
|
function C() {
|
|
3971
3992
|
if (b)
|
|
3972
3993
|
throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
3973
3994
|
}
|
|
3974
|
-
function W(
|
|
3995
|
+
function W(x, g) {
|
|
3975
3996
|
ct(g);
|
|
3976
|
-
const v = f.signature,
|
|
3977
|
-
return V(
|
|
3997
|
+
const v = f.signature, k = g === "compact" ? v : g === "recovered" ? v + 1 : void 0;
|
|
3998
|
+
return V(x, k);
|
|
3978
3999
|
}
|
|
3979
4000
|
class B {
|
|
3980
|
-
constructor(g, v,
|
|
4001
|
+
constructor(g, v, k) {
|
|
3981
4002
|
E(this, "r");
|
|
3982
4003
|
E(this, "s");
|
|
3983
4004
|
E(this, "recovery");
|
|
3984
|
-
if (this.r =
|
|
3985
|
-
if (C(), ![0, 1, 2, 3].includes(
|
|
4005
|
+
if (this.r = T("r", g), this.s = T("s", v), k != null) {
|
|
4006
|
+
if (C(), ![0, 1, 2, 3].includes(k))
|
|
3986
4007
|
throw new Error("invalid recovery id");
|
|
3987
|
-
this.recovery =
|
|
4008
|
+
this.recovery = k;
|
|
3988
4009
|
}
|
|
3989
4010
|
Object.freeze(this);
|
|
3990
4011
|
}
|
|
3991
4012
|
static fromBytes(g, v = w.format) {
|
|
3992
4013
|
W(g, v);
|
|
3993
|
-
let
|
|
4014
|
+
let k;
|
|
3994
4015
|
if (v === "der") {
|
|
3995
|
-
const { r:
|
|
3996
|
-
return new B(
|
|
4016
|
+
const { r: R, s: $ } = ye.toSig(V(g));
|
|
4017
|
+
return new B(R, $);
|
|
3997
4018
|
}
|
|
3998
|
-
v === "recovered" && (
|
|
4019
|
+
v === "recovered" && (k = g[0], v = "compact", g = g.subarray(1));
|
|
3999
4020
|
const D = f.signature / 2, N = g.subarray(0, D), M = g.subarray(D, D * 2);
|
|
4000
|
-
return new B(i.fromBytes(N), i.fromBytes(M),
|
|
4021
|
+
return new B(i.fromBytes(N), i.fromBytes(M), k);
|
|
4001
4022
|
}
|
|
4002
4023
|
static fromHex(g, v) {
|
|
4003
4024
|
return this.fromBytes(We(g), v);
|
|
@@ -4012,10 +4033,10 @@ function Jr(r, e, s = {}) {
|
|
|
4012
4033
|
return new B(this.r, this.s, g);
|
|
4013
4034
|
}
|
|
4014
4035
|
recoverPublicKey(g) {
|
|
4015
|
-
const { r: v, s:
|
|
4036
|
+
const { r: v, s: k } = this, D = this.assertRecovery(), N = D === 2 || D === 3 ? v + a : v;
|
|
4016
4037
|
if (!o.isValid(N))
|
|
4017
4038
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
4018
|
-
const M = o.toBytes(N),
|
|
4039
|
+
const M = o.toBytes(N), R = r.fromBytes(be(Is((D & 1) === 0), M)), $ = i.inv(N), F = q(V(g, void 0, "msgHash")), J = i.create(-F * $), K = i.create(k * $), H = r.BASE.multiplyUnsafe(J).add(R.multiplyUnsafe(K));
|
|
4019
4040
|
if (H.is0())
|
|
4020
4041
|
throw new Error("invalid recovery: point at infinify");
|
|
4021
4042
|
return H.assertValidity(), H;
|
|
@@ -4027,7 +4048,7 @@ function Jr(r, e, s = {}) {
|
|
|
4027
4048
|
toBytes(g = w.format) {
|
|
4028
4049
|
if (ct(g), g === "der")
|
|
4029
4050
|
return We(ye.hexFromSig(this));
|
|
4030
|
-
const { r: v, s:
|
|
4051
|
+
const { r: v, s: k } = this, D = i.toBytes(v), N = i.toBytes(k);
|
|
4031
4052
|
return g === "recovered" ? (C(), be(Uint8Array.of(this.assertRecovery()), D, N)) : be(D, N);
|
|
4032
4053
|
}
|
|
4033
4054
|
toHex(g) {
|
|
@@ -4037,24 +4058,24 @@ function Jr(r, e, s = {}) {
|
|
|
4037
4058
|
const j = s.bits2int || function(g) {
|
|
4038
4059
|
if (g.length > 8192)
|
|
4039
4060
|
throw new Error("input is too large");
|
|
4040
|
-
const v = ze(g),
|
|
4041
|
-
return
|
|
4061
|
+
const v = ze(g), k = g.length * 8 - c;
|
|
4062
|
+
return k > 0 ? v >> BigInt(k) : v;
|
|
4042
4063
|
}, q = s.bits2int_modN || function(g) {
|
|
4043
4064
|
return i.create(j(g));
|
|
4044
4065
|
}, P = ft(c);
|
|
4045
|
-
function S(
|
|
4046
|
-
return
|
|
4066
|
+
function S(x) {
|
|
4067
|
+
return Rr("num < 2^" + c, x, _e, P), i.toBytes(x);
|
|
4047
4068
|
}
|
|
4048
|
-
function L(
|
|
4049
|
-
return V(
|
|
4069
|
+
function L(x, g) {
|
|
4070
|
+
return V(x, void 0, "message"), g ? V(e(x), void 0, "prehashed message") : x;
|
|
4050
4071
|
}
|
|
4051
|
-
function G(
|
|
4052
|
-
const { lowS:
|
|
4053
|
-
|
|
4054
|
-
const M = q(
|
|
4055
|
-
if (!i.isValidNot0(
|
|
4072
|
+
function G(x, g, v) {
|
|
4073
|
+
const { lowS: k, prehash: D, extraEntropy: N } = st(v, w);
|
|
4074
|
+
x = L(x, D);
|
|
4075
|
+
const M = q(x), R = i.fromBytes(g);
|
|
4076
|
+
if (!i.isValidNot0(R))
|
|
4056
4077
|
throw new Error("invalid private key");
|
|
4057
|
-
const $ = [S(
|
|
4078
|
+
const $ = [S(R), S(M)];
|
|
4058
4079
|
if (N != null && N !== !1) {
|
|
4059
4080
|
const H = N === !0 ? t(f.secretKey) : N;
|
|
4060
4081
|
$.push(V(H, void 0, "extraEntropy"));
|
|
@@ -4067,44 +4088,44 @@ function Jr(r, e, s = {}) {
|
|
|
4067
4088
|
const Z = i.inv(X), oe = r.BASE.multiply(X).toAffine(), z = i.create(oe.x);
|
|
4068
4089
|
if (z === _e)
|
|
4069
4090
|
return;
|
|
4070
|
-
const Q = i.create(Z * i.create(J + z *
|
|
4091
|
+
const Q = i.create(Z * i.create(J + z * R));
|
|
4071
4092
|
if (Q === _e)
|
|
4072
4093
|
return;
|
|
4073
4094
|
let yt = (oe.x === z ? 0 : 2) | Number(oe.y & Re), bt = Q;
|
|
4074
|
-
return
|
|
4095
|
+
return k && y(Q) && (bt = i.neg(Q), yt ^= 1), new B(z, bt, b ? void 0 : yt);
|
|
4075
4096
|
}
|
|
4076
4097
|
return { seed: F, k2sig: K };
|
|
4077
4098
|
}
|
|
4078
|
-
function O(
|
|
4079
|
-
const { seed:
|
|
4080
|
-
return
|
|
4099
|
+
function O(x, g, v = {}) {
|
|
4100
|
+
const { seed: k, k2sig: D } = G(x, g, v);
|
|
4101
|
+
return Pr(e.outputLen, i.BYTES, n)(k, D).toBytes(v.format);
|
|
4081
4102
|
}
|
|
4082
|
-
function A(
|
|
4083
|
-
const { lowS: D, prehash: N, format: M } = st(
|
|
4084
|
-
if (v = V(v, void 0, "publicKey"), g = L(g, N), !ut(
|
|
4085
|
-
const
|
|
4086
|
-
throw new Error("verify expects Uint8Array signature" +
|
|
4103
|
+
function A(x, g, v, k = {}) {
|
|
4104
|
+
const { lowS: D, prehash: N, format: M } = st(k, w);
|
|
4105
|
+
if (v = V(v, void 0, "publicKey"), g = L(g, N), !ut(x)) {
|
|
4106
|
+
const R = x instanceof B ? ", use sig.toBytes()" : "";
|
|
4107
|
+
throw new Error("verify expects Uint8Array signature" + R);
|
|
4087
4108
|
}
|
|
4088
|
-
W(
|
|
4109
|
+
W(x, M);
|
|
4089
4110
|
try {
|
|
4090
|
-
const
|
|
4091
|
-
if (D &&
|
|
4111
|
+
const R = B.fromBytes(x, M), $ = r.fromBytes(v);
|
|
4112
|
+
if (D && R.hasHighS())
|
|
4092
4113
|
return !1;
|
|
4093
|
-
const { r: F, s: J } =
|
|
4114
|
+
const { r: F, s: J } = R, K = q(g), H = i.inv(J), X = i.create(K * H), Z = i.create(F * H), oe = r.BASE.multiplyUnsafe(X).add($.multiplyUnsafe(Z));
|
|
4094
4115
|
return oe.is0() ? !1 : i.create(oe.x) === F;
|
|
4095
4116
|
} catch {
|
|
4096
4117
|
return !1;
|
|
4097
4118
|
}
|
|
4098
4119
|
}
|
|
4099
|
-
function I(
|
|
4100
|
-
const { prehash:
|
|
4101
|
-
return g = L(g,
|
|
4120
|
+
function I(x, g, v = {}) {
|
|
4121
|
+
const { prehash: k } = st(v, w);
|
|
4122
|
+
return g = L(g, k), B.fromBytes(x, "recovered").recoverPublicKey(g).toBytes();
|
|
4102
4123
|
}
|
|
4103
4124
|
return Object.freeze({
|
|
4104
4125
|
keygen: l,
|
|
4105
4126
|
getPublicKey: u,
|
|
4106
4127
|
getSharedSecret: h,
|
|
4107
|
-
utils:
|
|
4128
|
+
utils: _,
|
|
4108
4129
|
lengths: f,
|
|
4109
4130
|
Point: r,
|
|
4110
4131
|
sign: O,
|
|
@@ -4123,44 +4144,44 @@ const gt = {
|
|
|
4123
4144
|
b: BigInt(7),
|
|
4124
4145
|
Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
4125
4146
|
Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
|
|
4126
|
-
},
|
|
4147
|
+
}, Zr = {
|
|
4127
4148
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
4128
4149
|
basises: [
|
|
4129
4150
|
[BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
|
|
4130
4151
|
[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
|
|
4131
4152
|
]
|
|
4132
4153
|
}, qt = /* @__PURE__ */ BigInt(2);
|
|
4133
|
-
function
|
|
4134
|
-
const e = gt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, u = l * l * r % e, h = ae(u, s, e) * u % e,
|
|
4154
|
+
function Qr(r) {
|
|
4155
|
+
const e = gt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, u = l * l * r % e, h = ae(u, s, e) * u % e, _ = ae(h, s, e) * u % e, f = ae(_, qt, e) * l % e, w = ae(f, n, e) * f % e, b = ae(w, o, e) * w % e, y = ae(b, a, e) * b % e, T = ae(y, c, e) * y % e, C = ae(T, a, e) * b % e, W = ae(C, s, e) * u % e, B = ae(W, i, e) * w % e, j = ae(B, t, e) * l % e, q = ae(j, qt, e);
|
|
4135
4156
|
if (!lt.eql(lt.sqr(q), r))
|
|
4136
4157
|
throw new Error("Cannot find square root");
|
|
4137
4158
|
return q;
|
|
4138
4159
|
}
|
|
4139
|
-
const lt = je(gt.p, { sqrt:
|
|
4160
|
+
const lt = je(gt.p, { sqrt: Qr }), en = /* @__PURE__ */ Yr(gt, {
|
|
4140
4161
|
Fp: lt,
|
|
4141
|
-
endo:
|
|
4142
|
-
}),
|
|
4162
|
+
endo: Zr
|
|
4163
|
+
}), tn = /* @__PURE__ */ Xr(en, Ir), sn = BigInt(0), Ne = BigInt(1), rn = BigInt(2), nn = BigInt(7), on = BigInt(256), an = BigInt(113), As = [], Rs = [], ks = [];
|
|
4143
4164
|
for (let r = 0, e = Ne, s = 1, t = 0; r < 24; r++) {
|
|
4144
|
-
[s, t] = [t, (2 * s + 3 * t) % 5],
|
|
4145
|
-
let n =
|
|
4165
|
+
[s, t] = [t, (2 * s + 3 * t) % 5], As.push(2 * (5 * t + s)), Rs.push((r + 1) * (r + 2) / 2 % 64);
|
|
4166
|
+
let n = sn;
|
|
4146
4167
|
for (let o = 0; o < 7; o++)
|
|
4147
|
-
e = (e << Ne ^ (e >>
|
|
4168
|
+
e = (e << Ne ^ (e >> nn) * an) % on, e & rn && (n ^= Ne << (Ne << BigInt(o)) - Ne);
|
|
4148
4169
|
ks.push(n);
|
|
4149
4170
|
}
|
|
4150
|
-
const Ps =
|
|
4151
|
-
function
|
|
4171
|
+
const Ps = gr(ks, !0), cn = Ps[0], ln = Ps[1], Kt = (r, e, s) => s > 32 ? yr(r, e, s) : mr(r, e, s), Vt = (r, e, s) => s > 32 ? br(r, e, s) : wr(r, e, s);
|
|
4172
|
+
function dn(r, e = 24) {
|
|
4152
4173
|
const s = new Uint32Array(10);
|
|
4153
4174
|
for (let t = 24 - e; t < 24; t++) {
|
|
4154
4175
|
for (let i = 0; i < 10; i++)
|
|
4155
4176
|
s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
|
|
4156
4177
|
for (let i = 0; i < 10; i += 2) {
|
|
4157
|
-
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], u = s[c + 1], h = Kt(l, u, 1) ^ s[a],
|
|
4178
|
+
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], u = s[c + 1], h = Kt(l, u, 1) ^ s[a], _ = Vt(l, u, 1) ^ s[a + 1];
|
|
4158
4179
|
for (let f = 0; f < 50; f += 10)
|
|
4159
|
-
r[i + f] ^= h, r[i + f + 1] ^=
|
|
4180
|
+
r[i + f] ^= h, r[i + f + 1] ^= _;
|
|
4160
4181
|
}
|
|
4161
4182
|
let n = r[2], o = r[3];
|
|
4162
4183
|
for (let i = 0; i < 24; i++) {
|
|
4163
|
-
const a = Rs[i], c = Kt(n, o, a), l = Vt(n, o, a), u =
|
|
4184
|
+
const a = Rs[i], c = Kt(n, o, a), l = Vt(n, o, a), u = As[i];
|
|
4164
4185
|
n = r[u], o = r[u + 1], r[u] = c, r[u + 1] = l;
|
|
4165
4186
|
}
|
|
4166
4187
|
for (let i = 0; i < 50; i += 10) {
|
|
@@ -4169,7 +4190,7 @@ function ln(r, e = 24) {
|
|
|
4169
4190
|
for (let a = 0; a < 10; a++)
|
|
4170
4191
|
r[i + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
|
|
4171
4192
|
}
|
|
4172
|
-
r[0] ^=
|
|
4193
|
+
r[0] ^= cn[t], r[1] ^= ln[t];
|
|
4173
4194
|
}
|
|
4174
4195
|
Pe(s);
|
|
4175
4196
|
}
|
|
@@ -4189,13 +4210,13 @@ class mt {
|
|
|
4189
4210
|
E(this, "rounds");
|
|
4190
4211
|
if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, ge(t, "outputLen"), !(0 < e && e < 200))
|
|
4191
4212
|
throw new Error("only keccak-f1600 function is supported");
|
|
4192
|
-
this.state = new Uint8Array(200), this.state32 =
|
|
4213
|
+
this.state = new Uint8Array(200), this.state32 = ar(this.state);
|
|
4193
4214
|
}
|
|
4194
4215
|
clone() {
|
|
4195
4216
|
return this._cloneInto();
|
|
4196
4217
|
}
|
|
4197
4218
|
keccak() {
|
|
4198
|
-
Ct(this.state32),
|
|
4219
|
+
Ct(this.state32), dn(this.state32, this.rounds), Ct(this.state32), this.posOut = 0, this.pos = 0;
|
|
4199
4220
|
}
|
|
4200
4221
|
update(e) {
|
|
4201
4222
|
ke(this), V(e);
|
|
@@ -4249,8 +4270,8 @@ class mt {
|
|
|
4249
4270
|
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;
|
|
4250
4271
|
}
|
|
4251
4272
|
}
|
|
4252
|
-
const
|
|
4253
|
-
class
|
|
4273
|
+
const un = (r, e, s, t = {}) => ns(() => new mt(e, r, s), t), zt = /* @__PURE__ */ un(1, 136, 32), hn = 60;
|
|
4274
|
+
class pn {
|
|
4254
4275
|
constructor() {
|
|
4255
4276
|
this.jwks = null;
|
|
4256
4277
|
}
|
|
@@ -4270,7 +4291,7 @@ class hn {
|
|
|
4270
4291
|
iat: t.iat
|
|
4271
4292
|
});
|
|
4272
4293
|
const n = Math.floor(Date.now() / 1e3);
|
|
4273
|
-
if (t.exp && t.exp +
|
|
4294
|
+
if (t.exp && t.exp + hn < n)
|
|
4274
4295
|
return d.warn("[CROSSx] 토큰 만료:", {
|
|
4275
4296
|
exp: t.exp,
|
|
4276
4297
|
now: n,
|
|
@@ -4317,14 +4338,14 @@ ${t.length}`
|
|
|
4317
4338
|
const i = zt(o), a = s.startsWith("0x") ? s.slice(2) : s;
|
|
4318
4339
|
if (a.length !== 130)
|
|
4319
4340
|
throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
|
|
4320
|
-
const c =
|
|
4341
|
+
const c = fn(a), l = c.slice(0, 32), u = c.slice(32, 64), h = c[64], _ = h >= 27 ? h - 27 : h, b = new tn.Signature(
|
|
4321
4342
|
jt(l),
|
|
4322
4343
|
jt(u)
|
|
4323
|
-
).addRecoveryBit(
|
|
4344
|
+
).addRecoveryBit(_).recoverPublicKey(i).toBytes(!1).slice(1), y = zt(b);
|
|
4324
4345
|
return "0x" + Me(y.slice(12));
|
|
4325
4346
|
}
|
|
4326
4347
|
}
|
|
4327
|
-
function
|
|
4348
|
+
function fn(r) {
|
|
4328
4349
|
const e = new Uint8Array(r.length / 2);
|
|
4329
4350
|
for (let s = 0; s < e.length; s++)
|
|
4330
4351
|
e[s] = parseInt(r.substring(s * 2, s * 2 + 2), 16);
|
|
@@ -4335,8 +4356,8 @@ function jt(r) {
|
|
|
4335
4356
|
for (const s of r) e += s.toString(16).padStart(2, "0");
|
|
4336
4357
|
return BigInt(e);
|
|
4337
4358
|
}
|
|
4338
|
-
const
|
|
4339
|
-
class
|
|
4359
|
+
const _n = 3e4, xn = 1e3;
|
|
4360
|
+
class gn {
|
|
4340
4361
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4341
4362
|
async request(e) {
|
|
4342
4363
|
const s = e.retries ?? 0;
|
|
@@ -4347,7 +4368,7 @@ class xn {
|
|
|
4347
4368
|
} catch (n) {
|
|
4348
4369
|
if (t === s) throw n;
|
|
4349
4370
|
}
|
|
4350
|
-
await new Promise((n) => setTimeout(n,
|
|
4371
|
+
await new Promise((n) => setTimeout(n, xn * 2 ** t));
|
|
4351
4372
|
}
|
|
4352
4373
|
throw new Error("Unexpected: retry loop exited without result");
|
|
4353
4374
|
}
|
|
@@ -4355,7 +4376,7 @@ class xn {
|
|
|
4355
4376
|
async _doRequest(e) {
|
|
4356
4377
|
const s = new AbortController(), t = setTimeout(
|
|
4357
4378
|
() => s.abort(),
|
|
4358
|
-
e.timeoutMs ??
|
|
4379
|
+
e.timeoutMs ?? _n
|
|
4359
4380
|
);
|
|
4360
4381
|
try {
|
|
4361
4382
|
const n = await fetch(e.url, {
|
|
@@ -4382,7 +4403,7 @@ class xn {
|
|
|
4382
4403
|
}
|
|
4383
4404
|
}
|
|
4384
4405
|
}
|
|
4385
|
-
const
|
|
4406
|
+
const mn = /* @__PURE__ */ new Set([
|
|
4386
4407
|
"https://cross-wallet-oauth.crosstoken.io",
|
|
4387
4408
|
"https://stg-cross-wallet-oauth.crosstoken.io",
|
|
4388
4409
|
"https://dev-cross-wallet-oauth.crosstoken.io"
|
|
@@ -4456,21 +4477,21 @@ class Ee {
|
|
|
4456
4477
|
nonceLength: l.length,
|
|
4457
4478
|
authUrlBase: e.authUrl
|
|
4458
4479
|
});
|
|
4459
|
-
const
|
|
4480
|
+
const _ = window.open(
|
|
4460
4481
|
h,
|
|
4461
4482
|
"CROSSx OAuth",
|
|
4462
4483
|
`width=${n},height=${o},left=${i},top=${a}`
|
|
4463
4484
|
);
|
|
4464
|
-
if (!
|
|
4485
|
+
if (!_) {
|
|
4465
4486
|
t(new Error("팝업 창을 열 수 없습니다. 팝업 차단을 해제해 주세요."));
|
|
4466
4487
|
return;
|
|
4467
4488
|
}
|
|
4468
4489
|
const f = setTimeout(() => {
|
|
4469
4490
|
d.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), B(), t(new Error("Authentication timeout"));
|
|
4470
4491
|
}, 5 * 60 * 1e3), w = 10, b = 30;
|
|
4471
|
-
let y = 0,
|
|
4492
|
+
let y = 0, T = null;
|
|
4472
4493
|
const C = () => {
|
|
4473
|
-
clearInterval(W), d.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + b + "초간 대기합니다"),
|
|
4494
|
+
clearInterval(W), d.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + b + "초간 대기합니다"), T = setTimeout(() => {
|
|
4474
4495
|
B(), t(new Error(
|
|
4475
4496
|
"OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
|
|
4476
4497
|
));
|
|
@@ -4478,15 +4499,15 @@ class Ee {
|
|
|
4478
4499
|
}, W = setInterval(() => {
|
|
4479
4500
|
y++;
|
|
4480
4501
|
try {
|
|
4481
|
-
|
|
4502
|
+
_.closed && (y <= w ? C() : (B(), t(new Error("로그인이 취소되었습니다"))));
|
|
4482
4503
|
} catch {
|
|
4483
4504
|
C();
|
|
4484
4505
|
}
|
|
4485
4506
|
}, 1e3), B = () => {
|
|
4486
|
-
clearTimeout(f), clearInterval(W),
|
|
4507
|
+
clearTimeout(f), clearInterval(W), T && clearTimeout(T), window.removeEventListener("message", j);
|
|
4487
4508
|
}, j = (q) => {
|
|
4488
4509
|
if (q.origin !== e.expectedOrigin) return;
|
|
4489
|
-
if (!
|
|
4510
|
+
if (!mn.has(q.origin)) {
|
|
4490
4511
|
d.error("[CROSSx] postMessage origin이 허용 목록에 없음:", q.origin), B(), t(new Error("Unauthorized OAuth origin"));
|
|
4491
4512
|
return;
|
|
4492
4513
|
}
|
|
@@ -4517,8 +4538,8 @@ class Ee {
|
|
|
4517
4538
|
d.error("[CROSSx] 토큰을 찾을 수 없음:", q.data), t(new Error("Token not found in response"));
|
|
4518
4539
|
return;
|
|
4519
4540
|
}
|
|
4520
|
-
const I = (
|
|
4521
|
-
Ee.verifyIdTokenNonce(
|
|
4541
|
+
const I = (x) => {
|
|
4542
|
+
Ee.verifyIdTokenNonce(x, l).then(() => s(A)).catch((g) => {
|
|
4522
4543
|
d.error("[CROSSx] nonce 검증 실패:", g), t(g instanceof Error ? g : new Error("nonce verification failed"));
|
|
4523
4544
|
});
|
|
4524
4545
|
};
|
|
@@ -4531,8 +4552,8 @@ class Ee {
|
|
|
4531
4552
|
});
|
|
4532
4553
|
}
|
|
4533
4554
|
}
|
|
4534
|
-
const Ce = "crossx_wallet_data",
|
|
4535
|
-
class
|
|
4555
|
+
const Ce = "crossx_wallet_data", Ae = "crossx_mock_pin_hash";
|
|
4556
|
+
class wn {
|
|
4536
4557
|
constructor(e, s) {
|
|
4537
4558
|
this.storage = e, this.pinStore = s ?? null;
|
|
4538
4559
|
}
|
|
@@ -4561,7 +4582,7 @@ class mn {
|
|
|
4561
4582
|
};
|
|
4562
4583
|
await this.storage.set(Ce, n);
|
|
4563
4584
|
const o = (s = this.pinStore) == null ? void 0 : s.get();
|
|
4564
|
-
return o && (await this.storage.set(
|
|
4585
|
+
return o && (await this.storage.set(Ae, o), d.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
|
|
4565
4586
|
} catch (t) {
|
|
4566
4587
|
throw new m(p.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", t);
|
|
4567
4588
|
}
|
|
@@ -4603,8 +4624,8 @@ class mn {
|
|
|
4603
4624
|
var t;
|
|
4604
4625
|
if (d.log("[Mock] verifyPin"), this.pinScenario === "wrong")
|
|
4605
4626
|
return !1;
|
|
4606
|
-
const s = await this.storage.get(
|
|
4607
|
-
return s && s !== e ? !1 : (s || await this.storage.set(
|
|
4627
|
+
const s = await this.storage.get(Ae);
|
|
4628
|
+
return s && s !== e ? !1 : (s || await this.storage.set(Ae, e), (t = this.pinStore) == null || t.set(e), d.log("[Mock] verifyPin → 성공"), !0);
|
|
4608
4629
|
}
|
|
4609
4630
|
/**
|
|
4610
4631
|
* POST /mnemonic/change-password 모킹
|
|
@@ -4614,10 +4635,10 @@ class mn {
|
|
|
4614
4635
|
var o;
|
|
4615
4636
|
if (d.log("[Mock] changePin"), this.pinScenario === "wrong")
|
|
4616
4637
|
throw new m(p.PIN_WRONG, "Incorrect PIN.");
|
|
4617
|
-
const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(
|
|
4638
|
+
const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Ae);
|
|
4618
4639
|
if (n && t && n !== t)
|
|
4619
4640
|
throw new m(p.PIN_WRONG, "Incorrect PIN.");
|
|
4620
|
-
await this.storage.set(
|
|
4641
|
+
await this.storage.set(Ae, s), d.log("[Mock] changePin 완료");
|
|
4621
4642
|
}
|
|
4622
4643
|
async migrateWallet(e, s) {
|
|
4623
4644
|
var o;
|
|
@@ -4650,7 +4671,7 @@ class mn {
|
|
|
4650
4671
|
};
|
|
4651
4672
|
await this.storage.set(Ce, t);
|
|
4652
4673
|
const n = (o = this.pinStore) == null ? void 0 : o.get();
|
|
4653
|
-
return n && (await this.storage.set(
|
|
4674
|
+
return n && (await this.storage.set(Ae, n), d.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
|
|
4654
4675
|
}
|
|
4655
4676
|
/**
|
|
4656
4677
|
* POST /mnemonic/share-c 모킹
|
|
@@ -4679,11 +4700,14 @@ class mn {
|
|
|
4679
4700
|
}
|
|
4680
4701
|
class Le {
|
|
4681
4702
|
constructor(e, s, t, n, o) {
|
|
4682
|
-
this._walletStatusCache = null, this.adapterConfig = e, this.projectId = e.projectId, this.storage = s, this.transport = t, this.tokenStore = n, this.pinStore = o ?? null;
|
|
4703
|
+
this._refreshPromise = null, this._walletStatusCache = null, this.adapterConfig = e, this.projectId = e.projectId, this.storage = s, this.transport = t, this.tokenStore = n, this.pinStore = o ?? null;
|
|
4683
4704
|
}
|
|
4684
4705
|
setOnUnauthorized(e) {
|
|
4685
4706
|
this._onUnauthorized = e;
|
|
4686
4707
|
}
|
|
4708
|
+
setTokenRefresher(e) {
|
|
4709
|
+
this._onTokenRefresh = e;
|
|
4710
|
+
}
|
|
4687
4711
|
getPin() {
|
|
4688
4712
|
var e;
|
|
4689
4713
|
return ((e = this.pinStore) == null ? void 0 : e.get()) ?? void 0;
|
|
@@ -4691,60 +4715,86 @@ class Le {
|
|
|
4691
4715
|
get baseUrl() {
|
|
4692
4716
|
return this.adapterConfig.gatewayUrl;
|
|
4693
4717
|
}
|
|
4694
|
-
|
|
4718
|
+
/**
|
|
4719
|
+
* 유효한 access_token을 확보합니다.
|
|
4720
|
+
*
|
|
4721
|
+
* 1. 토큰이 있고 만료 임박하지 않으면 즉시 반환
|
|
4722
|
+
* 2. 만료 임박/만료 시 → 자동 갱신 시도 (동시 호출 deduplicate)
|
|
4723
|
+
* 3. 갱신 실패 시 기존 토큰이라도 있으면 반환 (서버가 최종 판단)
|
|
4724
|
+
* 4. 토큰 자체가 없으면 AUTH_NOT_AUTHENTICATED throw
|
|
4725
|
+
*/
|
|
4726
|
+
async ensureValidToken() {
|
|
4695
4727
|
const e = this.tokenStore.get();
|
|
4696
|
-
if (!
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
);
|
|
4701
|
-
|
|
4728
|
+
if (e && !this.tokenStore.isExpiringSoon(tr))
|
|
4729
|
+
return e;
|
|
4730
|
+
if (this._onTokenRefresh && await this.deduplicatedRefresh()) {
|
|
4731
|
+
const t = this.tokenStore.get();
|
|
4732
|
+
if (t) return t;
|
|
4733
|
+
}
|
|
4734
|
+
if (e)
|
|
4735
|
+
return d.warn("[CROSSx] 토큰 갱신 실패 — 기존 토큰으로 요청 시도"), e;
|
|
4736
|
+
throw new m(
|
|
4737
|
+
p.AUTH_NOT_AUTHENTICATED,
|
|
4738
|
+
"인증 토큰을 찾을 수 없습니다. 먼저 로그인해 주세요."
|
|
4739
|
+
);
|
|
4740
|
+
}
|
|
4741
|
+
/** 동시 갱신 요청을 단일 Promise로 합칩니다. */
|
|
4742
|
+
deduplicatedRefresh() {
|
|
4743
|
+
return this._refreshPromise ? this._refreshPromise : (d.log("[CROSSx] 토큰 만료 임박/만료 — 자동 갱신 시도"), this._refreshPromise = this._onTokenRefresh().finally(() => {
|
|
4744
|
+
this._refreshPromise = null;
|
|
4745
|
+
}), this._refreshPromise);
|
|
4702
4746
|
}
|
|
4703
|
-
async request(e, s, t) {
|
|
4704
|
-
var
|
|
4705
|
-
const
|
|
4706
|
-
Authorization: `Bearer ${
|
|
4747
|
+
async request(e, s, t, n = !1) {
|
|
4748
|
+
var c, l, u;
|
|
4749
|
+
const o = await this.ensureValidToken(), i = `${this.baseUrl}${s}`, a = {
|
|
4750
|
+
Authorization: `Bearer ${o}`,
|
|
4707
4751
|
"Content-Type": "application/json",
|
|
4708
4752
|
"X-Project-Id": this.projectId
|
|
4709
4753
|
};
|
|
4710
4754
|
try {
|
|
4711
|
-
const
|
|
4712
|
-
url:
|
|
4755
|
+
const _ = (await this.transport.request({
|
|
4756
|
+
url: i,
|
|
4713
4757
|
method: e,
|
|
4714
|
-
headers:
|
|
4758
|
+
headers: a,
|
|
4715
4759
|
body: t ?? void 0
|
|
4716
4760
|
})).data;
|
|
4717
|
-
if (
|
|
4718
|
-
if (
|
|
4719
|
-
const
|
|
4761
|
+
if (_ && typeof _.code == "number") {
|
|
4762
|
+
if (_.code < 0 || _.code >= 400) {
|
|
4763
|
+
const f = _.message || _.data || "API 요청에 실패했습니다";
|
|
4720
4764
|
d.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
|
|
4721
|
-
code:
|
|
4722
|
-
message:
|
|
4723
|
-
url:
|
|
4765
|
+
code: _.code,
|
|
4766
|
+
message: f,
|
|
4767
|
+
url: i,
|
|
4724
4768
|
method: e
|
|
4725
4769
|
});
|
|
4726
|
-
const
|
|
4727
|
-
|
|
4770
|
+
const w = Le.mapGatewayError(_.code, _.data);
|
|
4771
|
+
if (w === p.AUTH_NOT_AUTHENTICATED && !n && this._onTokenRefresh && (d.warn("[CROSSx] Gateway -10002 감지 — 토큰 갱신 후 재시도"), await this.deduplicatedRefresh()))
|
|
4772
|
+
return this.request(e, s, t, !0);
|
|
4773
|
+
const b = Le.getGatewayErrorMessage(_.code, f), y = _.data, T = w === p.PIN_LOCKED ? Le.extractLockDetails(y) : y ?? void 0, C = new m(w, b, T);
|
|
4774
|
+
throw w === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (d.warn("[CROSSx] Gateway -10002 갱신 재시도 실패 — 강제 로그아웃 실행"), this._onUnauthorized()), C;
|
|
4728
4775
|
}
|
|
4729
|
-
return d.log("[CROSSx] Wallet Gateway API 성공:", { code:
|
|
4776
|
+
return d.log("[CROSSx] Wallet Gateway API 성공:", { code: _.code, url: i, method: e }), _.data ?? _;
|
|
4730
4777
|
}
|
|
4731
|
-
return
|
|
4732
|
-
} catch (
|
|
4733
|
-
if (
|
|
4734
|
-
|
|
4735
|
-
|
|
4778
|
+
return _;
|
|
4779
|
+
} catch (h) {
|
|
4780
|
+
if (h instanceof m) throw h;
|
|
4781
|
+
const _ = ((c = h.response) == null ? void 0 : c.status) ?? h.status;
|
|
4782
|
+
if ((_ === 401 || _ === 403) && !n && this._onTokenRefresh && (d.warn(`[CROSSx] HTTP ${_} 감지 — 토큰 갱신 후 재시도`), await this.deduplicatedRefresh()))
|
|
4783
|
+
return this.request(e, s, t, !0);
|
|
4784
|
+
if ((l = h.response) != null && l.data) {
|
|
4785
|
+
const f = h.response.data, w = f.message || f.data || "API 요청에 실패했습니다", b = f.code || "UNKNOWN";
|
|
4736
4786
|
throw d.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
|
|
4737
|
-
code:
|
|
4738
|
-
message:
|
|
4739
|
-
url:
|
|
4787
|
+
code: b,
|
|
4788
|
+
message: w,
|
|
4789
|
+
url: i,
|
|
4740
4790
|
method: e,
|
|
4741
|
-
status: (
|
|
4791
|
+
status: (u = h.response) == null ? void 0 : u.status
|
|
4742
4792
|
}), new m(
|
|
4743
4793
|
p.UNKNOWN_ERROR,
|
|
4744
|
-
`Wallet Gateway 오류 (${
|
|
4794
|
+
`Wallet Gateway 오류 (${b}): ${w}`
|
|
4745
4795
|
);
|
|
4746
4796
|
}
|
|
4747
|
-
throw
|
|
4797
|
+
throw h;
|
|
4748
4798
|
}
|
|
4749
4799
|
}
|
|
4750
4800
|
/**
|
|
@@ -5096,7 +5146,7 @@ class De {
|
|
|
5096
5146
|
}
|
|
5097
5147
|
isCacheValid() {
|
|
5098
5148
|
if (this.loadedAt === 0) return !1;
|
|
5099
|
-
const e = this.usingFallback ?
|
|
5149
|
+
const e = this.usingFallback ? rr : sr;
|
|
5100
5150
|
return e === 0 ? !0 : Date.now() - this.loadedAt < e;
|
|
5101
5151
|
}
|
|
5102
5152
|
populateCache(e, s) {
|
|
@@ -5158,7 +5208,7 @@ class De {
|
|
|
5158
5208
|
}
|
|
5159
5209
|
}
|
|
5160
5210
|
}
|
|
5161
|
-
const Yt = "__crossx-confirm-style", te = "__crossx-confirm-overlay",
|
|
5211
|
+
const Yt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", yn = {
|
|
5162
5212
|
light: {
|
|
5163
5213
|
bg: "#FFFFFF",
|
|
5164
5214
|
border: "rgba(18,18,18,0.05)",
|
|
@@ -5215,7 +5265,7 @@ const Yt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", wn = {
|
|
|
5215
5265
|
}
|
|
5216
5266
|
};
|
|
5217
5267
|
function Jt(r, e) {
|
|
5218
|
-
const s =
|
|
5268
|
+
const s = yn[r], t = e == null ? void 0 : e[r];
|
|
5219
5269
|
return t ? {
|
|
5220
5270
|
...s,
|
|
5221
5271
|
// ── Brand
|
|
@@ -5247,7 +5297,7 @@ function Jt(r, e) {
|
|
|
5247
5297
|
...t.error !== void 0 && { errorColor: t.error }
|
|
5248
5298
|
} : s;
|
|
5249
5299
|
}
|
|
5250
|
-
const
|
|
5300
|
+
const bn = `
|
|
5251
5301
|
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
|
|
5252
5302
|
|
|
5253
5303
|
#${te} {
|
|
@@ -6975,7 +7025,7 @@ const yn = `
|
|
|
6975
7025
|
`;
|
|
6976
7026
|
function he() {
|
|
6977
7027
|
let r = document.getElementById(Yt);
|
|
6978
|
-
r || (r = document.createElement("style"), r.id = Yt, document.head.appendChild(r)), r.textContent =
|
|
7028
|
+
r || (r = document.createElement("style"), r.id = Yt, document.head.appendChild(r)), r.textContent = bn;
|
|
6979
7029
|
}
|
|
6980
7030
|
function pe(r) {
|
|
6981
7031
|
const e = (s) => s.stopPropagation();
|
|
@@ -6986,7 +7036,7 @@ function pe(r) {
|
|
|
6986
7036
|
function se(r) {
|
|
6987
7037
|
return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
|
|
6988
7038
|
}
|
|
6989
|
-
function
|
|
7039
|
+
function vn(r, e = "CROSS", s = 18) {
|
|
6990
7040
|
if (!r || r === "0x" || r === "0x0") return null;
|
|
6991
7041
|
try {
|
|
6992
7042
|
const t = BigInt(r);
|
|
@@ -7037,18 +7087,18 @@ function rt(r) {
|
|
|
7037
7087
|
return r;
|
|
7038
7088
|
}
|
|
7039
7089
|
}
|
|
7040
|
-
function
|
|
7090
|
+
function Sn(r) {
|
|
7041
7091
|
try {
|
|
7042
7092
|
return BigInt(r).toLocaleString();
|
|
7043
7093
|
} catch {
|
|
7044
7094
|
return r;
|
|
7045
7095
|
}
|
|
7046
7096
|
}
|
|
7047
|
-
function
|
|
7097
|
+
function En(r) {
|
|
7048
7098
|
const { gasLimit: e, gasPrice: s, maxFeePerGas: t, maxPriorityFeePerGas: n, nativeSymbol: o = "ETH", nativeDecimals: i = 18 } = r;
|
|
7049
7099
|
if (!e) return null;
|
|
7050
7100
|
try {
|
|
7051
|
-
const a = BigInt(e), c =
|
|
7101
|
+
const a = BigInt(e), c = Sn(e);
|
|
7052
7102
|
if (t) {
|
|
7053
7103
|
const l = a * BigInt(t);
|
|
7054
7104
|
return {
|
|
@@ -7074,7 +7124,7 @@ function Sn(r) {
|
|
|
7074
7124
|
}
|
|
7075
7125
|
}
|
|
7076
7126
|
function Ns(r) {
|
|
7077
|
-
const e =
|
|
7127
|
+
const e = En(r);
|
|
7078
7128
|
if (!e) return Y("Estimated fee", "<span>—</span>");
|
|
7079
7129
|
let s = Y("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
|
|
7080
7130
|
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;
|
|
@@ -7085,14 +7135,14 @@ const xe = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="
|
|
|
7085
7135
|
</svg>`, ie = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
|
|
7086
7136
|
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
7087
7137
|
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
7088
|
-
</svg>`,
|
|
7138
|
+
</svg>`, In = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7089
7139
|
<circle cx="20" cy="20" r="20" fill="#00D5AA"/>
|
|
7090
7140
|
<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"/>
|
|
7091
7141
|
</svg>`, wt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
7092
7142
|
<rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
|
|
7093
7143
|
<path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
|
|
7094
7144
|
<rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
|
|
7095
|
-
</svg>`,
|
|
7145
|
+
</svg>`, Tn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
7096
7146
|
<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)"/>
|
|
7097
7147
|
</svg>`, An = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
7098
7148
|
<circle cx="12" cy="12" r="12" fill="var(--cx-error)"/>
|
|
@@ -7132,7 +7182,7 @@ function Y(r, e) {
|
|
|
7132
7182
|
<div class="__crossx-row-value">${e}</div>
|
|
7133
7183
|
</div>`;
|
|
7134
7184
|
}
|
|
7135
|
-
function
|
|
7185
|
+
function Rn(r, e) {
|
|
7136
7186
|
const s = e, t = Ye(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
7137
7187
|
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", o = Ns(r), i = r.data ?? "0x", a = document.createElement("div");
|
|
7138
7188
|
return a.id = te, a.innerHTML = `
|
|
@@ -7172,9 +7222,9 @@ function Tn(r, e) {
|
|
|
7172
7222
|
</div>
|
|
7173
7223
|
`, a;
|
|
7174
7224
|
}
|
|
7175
|
-
function
|
|
7225
|
+
function kn(r, e) {
|
|
7176
7226
|
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>
|
|
7177
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", a = Ns(r), l =
|
|
7227
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", a = Ns(r), l = vn(r.value, t, n) ?? "—", u = document.createElement("div");
|
|
7178
7228
|
return u.id = te, u.innerHTML = `
|
|
7179
7229
|
<div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7180
7230
|
<div class="__crossx-header">
|
|
@@ -7214,10 +7264,10 @@ function Ye(r) {
|
|
|
7214
7264
|
function U(r) {
|
|
7215
7265
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7216
7266
|
}
|
|
7217
|
-
function
|
|
7267
|
+
function Pn(r) {
|
|
7218
7268
|
return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
|
|
7219
7269
|
}
|
|
7220
|
-
function
|
|
7270
|
+
function On(r) {
|
|
7221
7271
|
if (typeof r == "string") return U(r);
|
|
7222
7272
|
if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
|
|
7223
7273
|
try {
|
|
@@ -7226,7 +7276,7 @@ function Pn(r) {
|
|
|
7226
7276
|
return String(r);
|
|
7227
7277
|
}
|
|
7228
7278
|
}
|
|
7229
|
-
function
|
|
7279
|
+
function Nn(r, e) {
|
|
7230
7280
|
const s = Y(
|
|
7231
7281
|
"From",
|
|
7232
7282
|
`<span class="__crossx-addr-text">${se(r.from)}</span>
|
|
@@ -7258,7 +7308,7 @@ function On(r, e) {
|
|
|
7258
7308
|
</div>
|
|
7259
7309
|
`, c;
|
|
7260
7310
|
}
|
|
7261
|
-
function
|
|
7311
|
+
function Cn(r, e) {
|
|
7262
7312
|
const s = document.createElement("div");
|
|
7263
7313
|
return s.id = te, s.innerHTML = `
|
|
7264
7314
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7275,10 +7325,10 @@ function Nn(r, e) {
|
|
|
7275
7325
|
</div>
|
|
7276
7326
|
`, s;
|
|
7277
7327
|
}
|
|
7278
|
-
function
|
|
7328
|
+
function Ln(r, e, s) {
|
|
7279
7329
|
const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
|
|
7280
7330
|
if (o) {
|
|
7281
|
-
const w = n ? An : t ? "" :
|
|
7331
|
+
const w = n ? An : t ? "" : Tn, b = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
|
|
7282
7332
|
w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${b}</span>`) : o.textContent = b;
|
|
7283
7333
|
}
|
|
7284
7334
|
if (i && !r.querySelector("#__crossx-close-btn")) {
|
|
@@ -7289,7 +7339,7 @@ function Cn(r, e, s) {
|
|
|
7289
7339
|
if (!a) return;
|
|
7290
7340
|
const c = e.from ? Y("From", `<span class="__crossx-addr-text">${se(e.from)}</span>
|
|
7291
7341
|
<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>
|
|
7292
|
-
<button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${xe}</button>`) : "", u = e.amount ? Y("Transfer", `<span>${U(e.amount)}</span>`) : "", h = e.fees ? Y("Tx Fee", `<span>${U(e.fees)}</span>`) : "",
|
|
7342
|
+
<button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${xe}</button>`) : "", u = e.amount ? Y("Transfer", `<span>${U(e.amount)}</span>`) : "", h = e.fees ? Y("Tx Fee", `<span>${U(e.fees)}</span>`) : "", _ = e.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(e.txHash)}</span>
|
|
7293
7343
|
<button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${xe}</button>`) : "", f = e.total ? `<div class="__crossx-total-pill">
|
|
7294
7344
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
7295
7345
|
<span class="__crossx-total-amount">${U(e.total)}</span>
|
|
@@ -7300,21 +7350,21 @@ function Cn(r, e, s) {
|
|
|
7300
7350
|
${l}
|
|
7301
7351
|
${u}
|
|
7302
7352
|
${h}
|
|
7303
|
-
${
|
|
7353
|
+
${_}
|
|
7304
7354
|
</div>
|
|
7305
7355
|
${f}
|
|
7306
7356
|
<button class="__crossx-approve-btn" id="__crossx-done-btn">${t ? "All Done" : "Done"}</button>
|
|
7307
7357
|
`, a.querySelectorAll(".__crossx-copy-btn").forEach((w) => {
|
|
7308
7358
|
w.addEventListener("click", (b) => {
|
|
7309
|
-
var
|
|
7359
|
+
var T;
|
|
7310
7360
|
b.stopPropagation();
|
|
7311
7361
|
const y = w.dataset.copy;
|
|
7312
|
-
y && ((
|
|
7362
|
+
y && ((T = navigator.clipboard) == null || T.writeText(y).catch(() => {
|
|
7313
7363
|
}));
|
|
7314
7364
|
});
|
|
7315
7365
|
});
|
|
7316
7366
|
}
|
|
7317
|
-
function
|
|
7367
|
+
function Dn(r, e) {
|
|
7318
7368
|
const s = e, t = Ye(r.dappName), n = U(r.message), o = document.createElement("div");
|
|
7319
7369
|
return o.id = te, o.innerHTML = `
|
|
7320
7370
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7346,7 +7396,7 @@ function Ln(r, e) {
|
|
|
7346
7396
|
</div>
|
|
7347
7397
|
`, o;
|
|
7348
7398
|
}
|
|
7349
|
-
function
|
|
7399
|
+
function Mn(r, e) {
|
|
7350
7400
|
const s = e, t = Ye(r.dappName);
|
|
7351
7401
|
let n = {};
|
|
7352
7402
|
if (typeof r.typedData == "string")
|
|
@@ -7362,7 +7412,7 @@ function Dn(r, e) {
|
|
|
7362
7412
|
<span class="__crossx-td-value">${U(o)}</span>
|
|
7363
7413
|
</div>`;
|
|
7364
7414
|
for (const [l, u] of Object.entries(i)) {
|
|
7365
|
-
const h =
|
|
7415
|
+
const h = On(u), f = Pn(u) ? `<span class="__crossx-addr-text">${se(u)}</span>
|
|
7366
7416
|
<button class="__crossx-copy-btn" data-copy="${U(String(u))}" title="Copy">${xe}</button>` : `<span>${h}</span>`;
|
|
7367
7417
|
a += `
|
|
7368
7418
|
<div class="__crossx-td-row">
|
|
@@ -7401,11 +7451,11 @@ function Dn(r, e) {
|
|
|
7401
7451
|
</div>
|
|
7402
7452
|
`, c;
|
|
7403
7453
|
}
|
|
7404
|
-
const
|
|
7454
|
+
const $n = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
7405
7455
|
<line x1="12" y1="5" x2="12" y2="19"/>
|
|
7406
7456
|
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
7407
7457
|
</svg>`;
|
|
7408
|
-
function
|
|
7458
|
+
function Bn(r, e, s) {
|
|
7409
7459
|
const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
|
|
7410
7460
|
const a = t && i.address.toLowerCase() === t;
|
|
7411
7461
|
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${U(i.address)}">
|
|
@@ -7436,7 +7486,7 @@ function $n(r, e, s) {
|
|
|
7436
7486
|
${n}
|
|
7437
7487
|
</div>
|
|
7438
7488
|
<button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
|
|
7439
|
-
<span class="__crossx-wallet-add-icon">${
|
|
7489
|
+
<span class="__crossx-wallet-add-icon">${$n}</span>
|
|
7440
7490
|
<span class="__crossx-wallet-add-label">add a wallet</span>
|
|
7441
7491
|
</button>
|
|
7442
7492
|
</div>
|
|
@@ -7445,16 +7495,16 @@ function $n(r, e, s) {
|
|
|
7445
7495
|
</div>
|
|
7446
7496
|
`, o;
|
|
7447
7497
|
}
|
|
7448
|
-
const
|
|
7498
|
+
const Un = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7449
7499
|
<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"/>
|
|
7450
7500
|
<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"/>
|
|
7451
|
-
</svg>`,
|
|
7501
|
+
</svg>`, Hn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7452
7502
|
<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"/>
|
|
7453
7503
|
<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"/>
|
|
7454
7504
|
<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"/>
|
|
7455
7505
|
<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"/>
|
|
7456
7506
|
</svg>`;
|
|
7457
|
-
function
|
|
7507
|
+
function Fn(r, e = !1) {
|
|
7458
7508
|
const s = r, t = e ? `
|
|
7459
7509
|
<div class="__crossx-login-or-divider">
|
|
7460
7510
|
<hr><span>or</span><hr>
|
|
@@ -7478,11 +7528,11 @@ function Hn(r, e = !1) {
|
|
|
7478
7528
|
<div class="__crossx-body">
|
|
7479
7529
|
<div class="__crossx-login-btn-row">
|
|
7480
7530
|
<button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
|
|
7481
|
-
<span class="__crossx-login-icon" style="color:var(--cx-value);">${
|
|
7531
|
+
<span class="__crossx-login-icon" style="color:var(--cx-value);">${Un}</span>
|
|
7482
7532
|
<span class="__crossx-login-btn-label">Sign in with Apple</span>
|
|
7483
7533
|
</button>
|
|
7484
7534
|
<button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
|
|
7485
|
-
<span class="__crossx-login-icon">${
|
|
7535
|
+
<span class="__crossx-login-icon">${Hn}</span>
|
|
7486
7536
|
<span class="__crossx-login-btn-label">Sign in with Google</span>
|
|
7487
7537
|
</button>
|
|
7488
7538
|
</div>${t}
|
|
@@ -7493,7 +7543,7 @@ function Hn(r, e = !1) {
|
|
|
7493
7543
|
</div>
|
|
7494
7544
|
`, n;
|
|
7495
7545
|
}
|
|
7496
|
-
function
|
|
7546
|
+
function Gn(r, e = !0) {
|
|
7497
7547
|
const s = r, t = e ? `<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>` : "", n = e ? '<button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>' : "", o = document.createElement("div");
|
|
7498
7548
|
return o.id = te, o.innerHTML = `
|
|
7499
7549
|
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7509,7 +7559,7 @@ function Fn(r, e = !0) {
|
|
|
7509
7559
|
<p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
|
|
7510
7560
|
</div>
|
|
7511
7561
|
<button class="__crossx-recover-btn" id="__crossx-recover-btn">
|
|
7512
|
-
<span class="__crossx-recover-icon">${
|
|
7562
|
+
<span class="__crossx-recover-icon">${In}</span>
|
|
7513
7563
|
<span class="__crossx-recover-label">Import from Social Backup</span>
|
|
7514
7564
|
</button>
|
|
7515
7565
|
${n}
|
|
@@ -7517,7 +7567,7 @@ function Fn(r, e = !0) {
|
|
|
7517
7567
|
</div>
|
|
7518
7568
|
`, o;
|
|
7519
7569
|
}
|
|
7520
|
-
function
|
|
7570
|
+
function Wn(r, e) {
|
|
7521
7571
|
const s = r, { errorMessage: t, attemptCount: n, maxAttempts: o = 5 } = e ?? {}, i = !!t, a = i ? " --error" : "", c = n != null && n > 0 ? `<p class="__crossx-pin-attempt">${n}/${o}</p>` : "", l = n != null && n >= 3 ? '<p class="__crossx-pin-warning">Your account will be locked after further failures.</p>' : "", u = i ? `<p class="__crossx-pin-error-text">${t}</p>` : "", h = document.createElement("div");
|
|
7522
7572
|
return h.id = te, h.innerHTML = `
|
|
7523
7573
|
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7541,12 +7591,12 @@ function Gn(r, e) {
|
|
|
7541
7591
|
</div>
|
|
7542
7592
|
`, h;
|
|
7543
7593
|
}
|
|
7544
|
-
function
|
|
7594
|
+
function qn(r) {
|
|
7545
7595
|
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");
|
|
7546
7596
|
return `${n}, ${o} ${i} ${a}:${c}`;
|
|
7547
7597
|
}
|
|
7548
|
-
function
|
|
7549
|
-
const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ?
|
|
7598
|
+
function Kn(r, e, s) {
|
|
7599
|
+
const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ? qn(o) : null, a = document.createElement("div");
|
|
7550
7600
|
return a.id = te, a.innerHTML = `
|
|
7551
7601
|
<div class="__crossx-card __crossx-card--migration" style="${ce(t)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7552
7602
|
<div class="__crossx-header">
|
|
@@ -7576,10 +7626,10 @@ function qn(r, e, s) {
|
|
|
7576
7626
|
return () => clearInterval(h);
|
|
7577
7627
|
} };
|
|
7578
7628
|
}
|
|
7579
|
-
function
|
|
7629
|
+
function Vn(r) {
|
|
7580
7630
|
const s = [r.check1, r.check2].map((t, n) => `
|
|
7581
7631
|
<div class="__crossx-pw-notice-item" data-check-index="${n}" role="checkbox" aria-checked="false" tabindex="0">
|
|
7582
|
-
<div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${
|
|
7632
|
+
<div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${Yn}</div>
|
|
7583
7633
|
<span class="__crossx-pw-notice-item-text">${U(t)}</span>
|
|
7584
7634
|
</div>
|
|
7585
7635
|
`).join("");
|
|
@@ -7594,7 +7644,7 @@ function Kn(r) {
|
|
|
7594
7644
|
<div class="__crossx-pw-fields __crossx-pw-fields--notice">
|
|
7595
7645
|
<div class="__crossx-pw-notice-header">
|
|
7596
7646
|
<div class="__crossx-pw-notice-title-row">
|
|
7597
|
-
<span class="__crossx-pw-notice-icon">${
|
|
7647
|
+
<span class="__crossx-pw-notice-icon">${Jn}</span>
|
|
7598
7648
|
<p class="__crossx-pw-notice-title">${U(r.noticeTitle)}</p>
|
|
7599
7649
|
</div>
|
|
7600
7650
|
<p class="__crossx-pw-notice-desc">${U(r.noticeDesc)}</p>
|
|
@@ -7646,28 +7696,28 @@ function Zt(r, e) {
|
|
|
7646
7696
|
</div>
|
|
7647
7697
|
`, s;
|
|
7648
7698
|
}
|
|
7649
|
-
function
|
|
7699
|
+
function zn(r, e) {
|
|
7650
7700
|
if (r.length !== 6) return e.tooShort;
|
|
7651
7701
|
if (!/^\d+$/.test(r)) return e.numbersOnly;
|
|
7652
7702
|
if (/(.)\1{2}/.test(r)) return e.repeatingDigit;
|
|
7653
7703
|
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);
|
|
7654
7704
|
return t || n ? e.sequential : r[0] !== r[1] && r === r.slice(0, 2).repeat(3) ? e.alternatingPattern : null;
|
|
7655
7705
|
}
|
|
7656
|
-
function
|
|
7706
|
+
function jn(r) {
|
|
7657
7707
|
const e = Math.max(0, Math.ceil(r / 1e3)), s = Math.floor(e / 3600), t = Math.floor(e % 3600 / 60), n = e % 60;
|
|
7658
7708
|
return s > 0 ? `${s}h ${String(t).padStart(2, "0")}m` : `${String(t).padStart(2, "0")}:${String(n).padStart(2, "0")}`;
|
|
7659
7709
|
}
|
|
7660
7710
|
function ot(r, e, s, t, n, o) {
|
|
7661
7711
|
var j, q;
|
|
7662
7712
|
let i = !!(o && o > Date.now()), a = !1;
|
|
7663
|
-
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), u = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"),
|
|
7713
|
+
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), u = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), _ = () => r.querySelector("#__crossx-pin6-lock-countdown"), f = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((P) => P.value).join(""), b = (P) => {
|
|
7664
7714
|
i = P, c().forEach((S) => {
|
|
7665
7715
|
S.disabled = P, S.classList.toggle("--locked", P);
|
|
7666
7716
|
});
|
|
7667
7717
|
}, y = () => {
|
|
7668
7718
|
const P = u();
|
|
7669
7719
|
P && (P.textContent = "");
|
|
7670
|
-
},
|
|
7720
|
+
}, T = (P) => {
|
|
7671
7721
|
const S = u();
|
|
7672
7722
|
S && (S.textContent = P);
|
|
7673
7723
|
const L = l();
|
|
@@ -7686,16 +7736,16 @@ function ot(r, e, s, t, n, o) {
|
|
|
7686
7736
|
if (S && (S.textContent = "Too many failed attempts. Please wait."), !h()) {
|
|
7687
7737
|
const I = document.createElement("p");
|
|
7688
7738
|
I.className = "__crossx-pin6-lock-msg", I.id = "__crossx-pin6-lock-msg", I.innerHTML = `${Cs}<span id="__crossx-pin6-lock-countdown"></span>`;
|
|
7689
|
-
const
|
|
7690
|
-
|
|
7739
|
+
const x = u();
|
|
7740
|
+
x ? x.insertAdjacentElement("afterend", I) : (A = f()) == null || A.appendChild(I);
|
|
7691
7741
|
}
|
|
7692
7742
|
const L = () => {
|
|
7693
7743
|
var g;
|
|
7694
|
-
const I = P - Date.now(),
|
|
7744
|
+
const I = P - Date.now(), x = _();
|
|
7695
7745
|
I <= 0 ? (clearInterval(G), b(!1), (g = h()) == null || g.remove(), S && (S.textContent = ""), setTimeout(() => {
|
|
7696
7746
|
var v;
|
|
7697
7747
|
return (v = c()[0]) == null ? void 0 : v.focus();
|
|
7698
|
-
}, 50)) :
|
|
7748
|
+
}, 50)) : x && (x.textContent = ` ${jn(I)}`);
|
|
7699
7749
|
}, G = setInterval(L, 1e3);
|
|
7700
7750
|
L();
|
|
7701
7751
|
const O = new MutationObserver(() => {
|
|
@@ -7712,7 +7762,7 @@ function ot(r, e, s, t, n, o) {
|
|
|
7712
7762
|
try {
|
|
7713
7763
|
if (n) {
|
|
7714
7764
|
const S = await n(P);
|
|
7715
|
-
S.ok ? e(P) : S.lockExpiresAt ? C(S.lockExpiresAt) :
|
|
7765
|
+
S.ok ? e(P) : S.lockExpiresAt ? C(S.lockExpiresAt) : T(S.error ?? "Incorrect PIN. Please try again.");
|
|
7716
7766
|
} else
|
|
7717
7767
|
e(P);
|
|
7718
7768
|
} catch (S) {
|
|
@@ -7759,20 +7809,20 @@ function ot(r, e, s, t, n, o) {
|
|
|
7759
7809
|
const G = (((A = L.clipboardData) == null ? void 0 : A.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
|
|
7760
7810
|
if (!G) return;
|
|
7761
7811
|
const O = c();
|
|
7762
|
-
G.split("").forEach((
|
|
7763
|
-
O[g] && (O[g].value =
|
|
7812
|
+
G.split("").forEach((x, g) => {
|
|
7813
|
+
O[g] && (O[g].value = x);
|
|
7764
7814
|
}), (I = O[Math.min(G.length - 1, 5)]) == null || I.focus(), y(), w().length === 6 && setTimeout(W, 80);
|
|
7765
7815
|
}), P.addEventListener("focus", () => P.select());
|
|
7766
7816
|
});
|
|
7767
7817
|
}
|
|
7768
7818
|
const Cs = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7769
7819
|
<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"/>
|
|
7770
|
-
</svg>`,
|
|
7820
|
+
</svg>`, Yn = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7771
7821
|
<path d="M1 4.5L4 7.5L10 1" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
7772
|
-
</svg>`,
|
|
7822
|
+
</svg>`, Jn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7773
7823
|
<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"/>
|
|
7774
7824
|
</svg>`;
|
|
7775
|
-
function
|
|
7825
|
+
function Xn(r, e, s) {
|
|
7776
7826
|
var o;
|
|
7777
7827
|
const t = r.querySelectorAll(".__crossx-pin-input");
|
|
7778
7828
|
t.forEach((i, a) => {
|
|
@@ -7790,8 +7840,8 @@ function Jn(r, e, s) {
|
|
|
7790
7840
|
c.preventDefault();
|
|
7791
7841
|
const l = (((h = c.clipboardData) == null ? void 0 : h.getData("text")) ?? "").replace(/\D/g, "").slice(0, 4);
|
|
7792
7842
|
if (!l) return;
|
|
7793
|
-
l.split("").forEach((
|
|
7794
|
-
t[f] && (t[f].value =
|
|
7843
|
+
l.split("").forEach((_, f) => {
|
|
7844
|
+
t[f] && (t[f].value = _);
|
|
7795
7845
|
});
|
|
7796
7846
|
const u = Math.min(l.length, 3);
|
|
7797
7847
|
t[u].focus(), l.length === 4 && setTimeout(() => e(l), 200);
|
|
@@ -7805,7 +7855,7 @@ function Jn(r, e, s) {
|
|
|
7805
7855
|
}
|
|
7806
7856
|
}), (o = t[0]) == null || o.focus();
|
|
7807
7857
|
}
|
|
7808
|
-
class
|
|
7858
|
+
class Zn {
|
|
7809
7859
|
constructor(e = "light", s) {
|
|
7810
7860
|
this.theme = e, this.overrides = s, this.tokens = Jt(e, s);
|
|
7811
7861
|
}
|
|
@@ -7827,7 +7877,7 @@ class Xn {
|
|
|
7827
7877
|
return new Promise((n) => {
|
|
7828
7878
|
var b;
|
|
7829
7879
|
he();
|
|
7830
|
-
const o = [...e], i =
|
|
7880
|
+
const o = [...e], i = Bn(o, this.tokens, t), a = document.body.style.overflow;
|
|
7831
7881
|
document.body.style.overflow = "hidden", pe(i);
|
|
7832
7882
|
let c = !1;
|
|
7833
7883
|
const l = () => {
|
|
@@ -7840,8 +7890,8 @@ class Xn {
|
|
|
7840
7890
|
(() => {
|
|
7841
7891
|
i.querySelectorAll(".__crossx-wallet-item").forEach((y) => {
|
|
7842
7892
|
y.addEventListener("click", () => {
|
|
7843
|
-
const
|
|
7844
|
-
u({ address:
|
|
7893
|
+
const T = y.dataset.walletAddress ?? "", C = parseInt(y.dataset.walletIndex ?? "0", 10);
|
|
7894
|
+
u({ address: T, index: C });
|
|
7845
7895
|
});
|
|
7846
7896
|
});
|
|
7847
7897
|
})();
|
|
@@ -7851,10 +7901,10 @@ class Xn {
|
|
|
7851
7901
|
try {
|
|
7852
7902
|
const y = await s();
|
|
7853
7903
|
o.push(y);
|
|
7854
|
-
const
|
|
7855
|
-
if (
|
|
7904
|
+
const T = i.querySelector("#__crossx-wallet-list");
|
|
7905
|
+
if (T) {
|
|
7856
7906
|
const C = document.createElement("button");
|
|
7857
|
-
C.className = "__crossx-wallet-item", C.dataset.walletIndex = String(y.index), C.dataset.walletAddress = y.address, C.innerHTML = `<span class="__crossx-wallet-addr">${se(y.address)}</span>`, C.addEventListener("click", () => u(y)),
|
|
7907
|
+
C.className = "__crossx-wallet-item", C.dataset.walletIndex = String(y.index), C.dataset.walletAddress = y.address, C.innerHTML = `<span class="__crossx-wallet-addr">${se(y.address)}</span>`, C.addEventListener("click", () => u(y)), T.appendChild(C), C.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
7858
7908
|
}
|
|
7859
7909
|
} catch {
|
|
7860
7910
|
} finally {
|
|
@@ -7879,20 +7929,20 @@ class Xn {
|
|
|
7879
7929
|
return new Promise((s) => {
|
|
7880
7930
|
var c, l, u, h;
|
|
7881
7931
|
he();
|
|
7882
|
-
const t =
|
|
7932
|
+
const t = Fn(this.tokens, e == null ? void 0 : e.showConnectOtherWallets);
|
|
7883
7933
|
pe(t);
|
|
7884
|
-
const n = () => t.remove(), o = (
|
|
7885
|
-
n(), s(
|
|
7934
|
+
const n = () => t.remove(), o = (_) => {
|
|
7935
|
+
n(), s(_);
|
|
7886
7936
|
}, i = () => {
|
|
7887
7937
|
n(), s(null);
|
|
7888
7938
|
};
|
|
7889
|
-
(c = t.querySelector("#__crossx-apple-btn")) == null || c.addEventListener("click", () => o("apple")), (l = t.querySelector("#__crossx-google-btn")) == null || l.addEventListener("click", () => o("google")), (u = t.querySelector("#__crossx-connect-btn")) == null || u.addEventListener("click", () => o("external")), (h = t.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", i), t.addEventListener("click", (
|
|
7890
|
-
|
|
7891
|
-
}), t.querySelectorAll(".__crossx-login-terms-link").forEach((
|
|
7892
|
-
|
|
7939
|
+
(c = t.querySelector("#__crossx-apple-btn")) == null || c.addEventListener("click", () => o("apple")), (l = t.querySelector("#__crossx-google-btn")) == null || l.addEventListener("click", () => o("google")), (u = t.querySelector("#__crossx-connect-btn")) == null || u.addEventListener("click", () => o("external")), (h = t.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", i), t.addEventListener("click", (_) => {
|
|
7940
|
+
_.target === t && i();
|
|
7941
|
+
}), t.querySelectorAll(".__crossx-login-terms-link").forEach((_) => {
|
|
7942
|
+
_.addEventListener("click", (f) => f.stopPropagation());
|
|
7893
7943
|
});
|
|
7894
|
-
const a = (
|
|
7895
|
-
|
|
7944
|
+
const a = (_) => {
|
|
7945
|
+
_.key === "Escape" && (document.removeEventListener("keydown", a), i());
|
|
7896
7946
|
};
|
|
7897
7947
|
document.addEventListener("keydown", a);
|
|
7898
7948
|
});
|
|
@@ -7907,7 +7957,7 @@ class Xn {
|
|
|
7907
7957
|
return new Promise((t) => {
|
|
7908
7958
|
var a, c, l;
|
|
7909
7959
|
he();
|
|
7910
|
-
const n =
|
|
7960
|
+
const n = Gn(this.tokens, s);
|
|
7911
7961
|
pe(n);
|
|
7912
7962
|
const o = () => n.remove(), i = () => {
|
|
7913
7963
|
o(), t("recover");
|
|
@@ -7916,11 +7966,11 @@ class Xn {
|
|
|
7916
7966
|
const u = () => {
|
|
7917
7967
|
o(), t("skip");
|
|
7918
7968
|
};
|
|
7919
|
-
(c = n.querySelector("#__crossx-skip-btn")) == null || c.addEventListener("click", u), (l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", u), n.addEventListener("click", (
|
|
7920
|
-
|
|
7969
|
+
(c = n.querySelector("#__crossx-skip-btn")) == null || c.addEventListener("click", u), (l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", u), n.addEventListener("click", (_) => {
|
|
7970
|
+
_.target === n && u();
|
|
7921
7971
|
});
|
|
7922
|
-
const h = (
|
|
7923
|
-
|
|
7972
|
+
const h = (_) => {
|
|
7973
|
+
_.key === "Escape" && (document.removeEventListener("keydown", h), u());
|
|
7924
7974
|
};
|
|
7925
7975
|
document.addEventListener("keydown", h);
|
|
7926
7976
|
}
|
|
@@ -7953,14 +8003,14 @@ class Xn {
|
|
|
7953
8003
|
}, i = {
|
|
7954
8004
|
title: (t == null ? void 0 : t.pinSetup_confirmTitle) ?? "Confirm PIN",
|
|
7955
8005
|
headerSubtitle: (t == null ? void 0 : t.pinSetup_confirmSubtitle) ?? "Enter your PIN again to confirm."
|
|
7956
|
-
}, a = Zt(this.tokens,
|
|
8006
|
+
}, a = Zt(this.tokens, Vn(n)), c = document.body.style.overflow;
|
|
7957
8007
|
document.body.style.overflow = "hidden", pe(a);
|
|
7958
8008
|
let l = !1;
|
|
7959
8009
|
const u = () => {
|
|
7960
8010
|
l || (l = !0, a.remove(), document.body.style.overflow = c);
|
|
7961
8011
|
}, h = (C) => {
|
|
7962
8012
|
u(), s(C);
|
|
7963
|
-
},
|
|
8013
|
+
}, _ = () => {
|
|
7964
8014
|
u(), s(null);
|
|
7965
8015
|
}, f = a.querySelector(".__crossx-card"), w = {
|
|
7966
8016
|
tooShort: (t == null ? void 0 : t.pinValidation_tooShort) ?? "Please enter a 6-digit PIN.",
|
|
@@ -7973,9 +8023,9 @@ class Xn {
|
|
|
7973
8023
|
f.innerHTML = nt({
|
|
7974
8024
|
title: i.title,
|
|
7975
8025
|
headerSubtitle: i.headerSubtitle
|
|
7976
|
-
}), (W = f.querySelector("#__crossx-close-btn")) == null || W.addEventListener("click",
|
|
8026
|
+
}), (W = f.querySelector("#__crossx-close-btn")) == null || W.addEventListener("click", _), ot(f, (B) => {
|
|
7977
8027
|
B === C ? h(C) : y(o.mismatchError);
|
|
7978
|
-
},
|
|
8028
|
+
}, _);
|
|
7979
8029
|
}, y = (C) => {
|
|
7980
8030
|
var W;
|
|
7981
8031
|
f.innerHTML = nt({
|
|
@@ -7983,10 +8033,10 @@ class Xn {
|
|
|
7983
8033
|
headerSubtitle: o.headerSubtitle,
|
|
7984
8034
|
subtitle: o.subtitle,
|
|
7985
8035
|
errorMessage: C
|
|
7986
|
-
}), (W = f.querySelector("#__crossx-close-btn")) == null || W.addEventListener("click",
|
|
7987
|
-
const j =
|
|
8036
|
+
}), (W = f.querySelector("#__crossx-close-btn")) == null || W.addEventListener("click", _), ot(f, (B) => {
|
|
8037
|
+
const j = zn(B, w);
|
|
7988
8038
|
j ? y(j) : b(B);
|
|
7989
|
-
},
|
|
8039
|
+
}, _);
|
|
7990
8040
|
};
|
|
7991
8041
|
(() => {
|
|
7992
8042
|
var G;
|
|
@@ -8017,17 +8067,17 @@ class Xn {
|
|
|
8017
8067
|
return;
|
|
8018
8068
|
}
|
|
8019
8069
|
const O = C.find((I) => {
|
|
8020
|
-
const
|
|
8021
|
-
return !B.has(
|
|
8070
|
+
const x = parseInt(I.dataset.checkIndex ?? "0", 10);
|
|
8071
|
+
return !B.has(x);
|
|
8022
8072
|
});
|
|
8023
8073
|
if (!O) return;
|
|
8024
8074
|
const A = parseInt(O.dataset.checkIndex ?? "0", 10);
|
|
8025
8075
|
O.scrollIntoView({ behavior: "smooth", block: "nearest" }), O.classList.add("--highlight"), setTimeout(() => {
|
|
8026
8076
|
O.classList.remove("--highlight"), S(O, A);
|
|
8027
8077
|
}, 400);
|
|
8028
|
-
}), (G = f.querySelector("#__crossx-close-btn")) == null || G.addEventListener("click",
|
|
8078
|
+
}), (G = f.querySelector("#__crossx-close-btn")) == null || G.addEventListener("click", _);
|
|
8029
8079
|
})(), a.addEventListener("click", (C) => {
|
|
8030
|
-
C.target === a &&
|
|
8080
|
+
C.target === a && _();
|
|
8031
8081
|
});
|
|
8032
8082
|
});
|
|
8033
8083
|
}
|
|
@@ -8053,15 +8103,15 @@ class Xn {
|
|
|
8053
8103
|
let u = !1;
|
|
8054
8104
|
const h = () => {
|
|
8055
8105
|
u || (u = !0, c.remove(), document.body.style.overflow = l);
|
|
8056
|
-
},
|
|
8057
|
-
h(), s(
|
|
8106
|
+
}, _ = (T) => {
|
|
8107
|
+
h(), s(T);
|
|
8058
8108
|
}, f = () => {
|
|
8059
8109
|
h(), s(null);
|
|
8060
|
-
}, w = (
|
|
8061
|
-
h(), t(
|
|
8110
|
+
}, w = (T) => {
|
|
8111
|
+
h(), t(T);
|
|
8062
8112
|
}, b = c.querySelector(".__crossx-card");
|
|
8063
|
-
(y = b.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", f), ot(b,
|
|
8064
|
-
|
|
8113
|
+
(y = b.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", f), ot(b, _, f, w, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt), c.addEventListener("click", (T) => {
|
|
8114
|
+
T.target === c && f();
|
|
8065
8115
|
});
|
|
8066
8116
|
});
|
|
8067
8117
|
}
|
|
@@ -8076,14 +8126,14 @@ class Xn {
|
|
|
8076
8126
|
return new Promise((s) => {
|
|
8077
8127
|
var a;
|
|
8078
8128
|
he();
|
|
8079
|
-
const t =
|
|
8129
|
+
const t = Wn(this.tokens, e);
|
|
8080
8130
|
pe(t);
|
|
8081
8131
|
const n = () => t.remove(), o = (c) => {
|
|
8082
8132
|
n(), s(c);
|
|
8083
8133
|
}, i = () => {
|
|
8084
8134
|
n(), s(null);
|
|
8085
8135
|
};
|
|
8086
|
-
|
|
8136
|
+
Xn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
|
|
8087
8137
|
c.target === t && i();
|
|
8088
8138
|
});
|
|
8089
8139
|
});
|
|
@@ -8098,7 +8148,7 @@ class Xn {
|
|
|
8098
8148
|
return new Promise((t) => {
|
|
8099
8149
|
var l;
|
|
8100
8150
|
he();
|
|
8101
|
-
const { overlay: n, startCountdown: o } =
|
|
8151
|
+
const { overlay: n, startCountdown: o } = Kn(this.tokens, e, s);
|
|
8102
8152
|
pe(n);
|
|
8103
8153
|
const i = () => {
|
|
8104
8154
|
c(), n.remove();
|
|
@@ -8118,17 +8168,17 @@ class Xn {
|
|
|
8118
8168
|
return new Promise((s) => {
|
|
8119
8169
|
var a, c;
|
|
8120
8170
|
he();
|
|
8121
|
-
const t =
|
|
8171
|
+
const t = Nn(e, this.tokens);
|
|
8122
8172
|
pe(t);
|
|
8123
8173
|
const n = () => t.remove(), o = () => {
|
|
8124
8174
|
n(), s();
|
|
8125
8175
|
};
|
|
8126
8176
|
(a = t.querySelector("#__crossx-done-btn")) == null || a.addEventListener("click", o), (c = t.querySelector("#__crossx-close-btn")) == null || c.addEventListener("click", o), t.querySelectorAll(".__crossx-copy-btn").forEach((l) => {
|
|
8127
8177
|
l.addEventListener("click", (u) => {
|
|
8128
|
-
var
|
|
8178
|
+
var _;
|
|
8129
8179
|
u.stopPropagation();
|
|
8130
8180
|
const h = l.dataset.copy;
|
|
8131
|
-
h && ((
|
|
8181
|
+
h && ((_ = navigator.clipboard) == null || _.writeText(h).catch(() => {
|
|
8132
8182
|
}));
|
|
8133
8183
|
});
|
|
8134
8184
|
}), t.addEventListener("click", (l) => {
|
|
@@ -8147,7 +8197,7 @@ class Xn {
|
|
|
8147
8197
|
showTransactionProgress(e, s) {
|
|
8148
8198
|
return new Promise((t) => {
|
|
8149
8199
|
he();
|
|
8150
|
-
const n =
|
|
8200
|
+
const n = Cn(e, this.tokens);
|
|
8151
8201
|
pe(n);
|
|
8152
8202
|
const o = () => n.remove();
|
|
8153
8203
|
let i = !1;
|
|
@@ -8155,16 +8205,16 @@ class Xn {
|
|
|
8155
8205
|
i || (i = !0, o(), t());
|
|
8156
8206
|
}, c = () => {
|
|
8157
8207
|
var u, h;
|
|
8158
|
-
(u = n.querySelector("#__crossx-done-btn")) == null || u.addEventListener("click", a), (h = n.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", a), n.addEventListener("click", (
|
|
8159
|
-
|
|
8208
|
+
(u = n.querySelector("#__crossx-done-btn")) == null || u.addEventListener("click", a), (h = n.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", a), n.addEventListener("click", (_) => {
|
|
8209
|
+
_.target === n && a();
|
|
8160
8210
|
});
|
|
8161
|
-
const l = (
|
|
8162
|
-
|
|
8211
|
+
const l = (_) => {
|
|
8212
|
+
_.key === "Escape" && (document.removeEventListener("keydown", l), a());
|
|
8163
8213
|
};
|
|
8164
8214
|
document.addEventListener("keydown", l);
|
|
8165
8215
|
};
|
|
8166
8216
|
s.then((l) => {
|
|
8167
|
-
i || (
|
|
8217
|
+
i || (Ln(n, l, this.tokens), c());
|
|
8168
8218
|
});
|
|
8169
8219
|
});
|
|
8170
8220
|
}
|
|
@@ -8173,16 +8223,16 @@ class Xn {
|
|
|
8173
8223
|
var c, l, u;
|
|
8174
8224
|
he();
|
|
8175
8225
|
let t;
|
|
8176
|
-
e.type === "sign-message" ? t =
|
|
8226
|
+
e.type === "sign-message" ? t = Dn(e, this.tokens) : e.type === "sign-typed-data" ? t = Mn(e, this.tokens) : e.type === "sign" ? t = Rn(e, this.tokens) : t = kn(e, this.tokens), pe(t);
|
|
8177
8227
|
const n = () => t.remove(), o = () => {
|
|
8178
8228
|
n(), s(!0);
|
|
8179
8229
|
}, i = () => {
|
|
8180
8230
|
n(), s(!1);
|
|
8181
8231
|
};
|
|
8182
8232
|
(c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (u = t.querySelector("#__crossx-close-btn")) == null || u.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((h) => {
|
|
8183
|
-
h.addEventListener("click", (
|
|
8233
|
+
h.addEventListener("click", (_) => {
|
|
8184
8234
|
var w;
|
|
8185
|
-
|
|
8235
|
+
_.stopPropagation();
|
|
8186
8236
|
const f = h.dataset.copy;
|
|
8187
8237
|
f && ((w = navigator.clipboard) == null || w.writeText(f).catch(() => {
|
|
8188
8238
|
}));
|
|
@@ -8197,7 +8247,7 @@ class Xn {
|
|
|
8197
8247
|
});
|
|
8198
8248
|
}
|
|
8199
8249
|
}
|
|
8200
|
-
class
|
|
8250
|
+
class Qn {
|
|
8201
8251
|
constructor() {
|
|
8202
8252
|
this._accessToken = null, this._expiresAt = 0;
|
|
8203
8253
|
}
|
|
@@ -8219,8 +8269,17 @@ class Zn {
|
|
|
8219
8269
|
has() {
|
|
8220
8270
|
return this.get() !== null;
|
|
8221
8271
|
}
|
|
8272
|
+
/**
|
|
8273
|
+
* 토큰이 곧 만료되는지 확인합니다.
|
|
8274
|
+
* 토큰이 없거나 `exp`가 설정되지 않은 경우에도 true를 반환합니다.
|
|
8275
|
+
*
|
|
8276
|
+
* @param bufferMs 만료 전 여유 시간 (ms). 기본 30초.
|
|
8277
|
+
*/
|
|
8278
|
+
isExpiringSoon(e = 3e4) {
|
|
8279
|
+
return !this._accessToken || this._expiresAt <= 0 ? !0 : Date.now() >= this._expiresAt - e;
|
|
8280
|
+
}
|
|
8222
8281
|
}
|
|
8223
|
-
function
|
|
8282
|
+
function ao(r, e) {
|
|
8224
8283
|
r.debug;
|
|
8225
8284
|
const s = Ge.production, t = {
|
|
8226
8285
|
...r,
|
|
@@ -8236,33 +8295,33 @@ function io(r, e) {
|
|
|
8236
8295
|
"refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
|
|
8237
8296
|
"IndexedDB를 지원하는 브라우저 사용을 권장합니다."
|
|
8238
8297
|
), t.secureStorageAvailable = o;
|
|
8239
|
-
const i = o ? new Nt(r.projectId) : new
|
|
8240
|
-
let
|
|
8241
|
-
r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"),
|
|
8298
|
+
const i = o ? new Nt(r.projectId) : new nr(), a = new pn(), c = new gn(), l = new Ee(), u = new Qn(), h = new es();
|
|
8299
|
+
let _;
|
|
8300
|
+
r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), _ = new wn(i, h)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), _ = new Le(
|
|
8242
8301
|
n,
|
|
8243
8302
|
i,
|
|
8244
8303
|
c,
|
|
8245
8304
|
u,
|
|
8246
8305
|
h
|
|
8247
8306
|
));
|
|
8248
|
-
const f = new De(n, c), w = new
|
|
8249
|
-
return new it(
|
|
8307
|
+
const f = new De(n, c), w = new Zn(r.theme ?? "light", r.themeTokens), b = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w, y = new it(
|
|
8250
8308
|
t,
|
|
8251
8309
|
n,
|
|
8252
8310
|
i,
|
|
8253
8311
|
a,
|
|
8254
8312
|
c,
|
|
8255
8313
|
l,
|
|
8256
|
-
|
|
8314
|
+
_,
|
|
8257
8315
|
u,
|
|
8258
8316
|
b,
|
|
8259
8317
|
f,
|
|
8260
8318
|
h
|
|
8261
8319
|
);
|
|
8320
|
+
return typeof window < "u" && (window.__crossxSDK = y), y;
|
|
8262
8321
|
}
|
|
8263
|
-
function
|
|
8264
|
-
const e =
|
|
8265
|
-
|
|
8322
|
+
function co(r) {
|
|
8323
|
+
const e = eo(r), s = to(e), t = JSON.parse(s);
|
|
8324
|
+
ro(t);
|
|
8266
8325
|
const { data: n } = t;
|
|
8267
8326
|
return {
|
|
8268
8327
|
status: t.status,
|
|
@@ -8276,27 +8335,32 @@ function ao(r) {
|
|
|
8276
8335
|
raw: t
|
|
8277
8336
|
};
|
|
8278
8337
|
}
|
|
8279
|
-
function
|
|
8338
|
+
function eo(r) {
|
|
8280
8339
|
if (r.includes("://") && r.includes("?")) {
|
|
8281
|
-
const
|
|
8282
|
-
if (
|
|
8283
|
-
|
|
8284
|
-
return
|
|
8340
|
+
const e = new URL(r), s = e.searchParams.get("crossx_oauth_result");
|
|
8341
|
+
if (s) return s;
|
|
8342
|
+
const t = e.searchParams.get("data");
|
|
8343
|
+
if (t) return t;
|
|
8344
|
+
throw new Error("Deeplink URL에 crossx_oauth_result 또는 data 파라미터가 없습니다");
|
|
8285
8345
|
}
|
|
8286
8346
|
return r;
|
|
8287
8347
|
}
|
|
8288
|
-
function
|
|
8289
|
-
|
|
8348
|
+
function to(r) {
|
|
8349
|
+
if (r.startsWith("{"))
|
|
8350
|
+
return r;
|
|
8351
|
+
if (r.startsWith("%7B") || r.startsWith("%7b"))
|
|
8352
|
+
return decodeURIComponent(r);
|
|
8353
|
+
const e = so(r);
|
|
8290
8354
|
return decodeURIComponent(e);
|
|
8291
8355
|
}
|
|
8292
|
-
function
|
|
8356
|
+
function so(r) {
|
|
8293
8357
|
if (typeof atob == "function")
|
|
8294
8358
|
return atob(r);
|
|
8295
8359
|
if (typeof Buffer < "u")
|
|
8296
8360
|
return Buffer.from(r, "base64").toString("utf-8");
|
|
8297
8361
|
throw new Error("Base64 디코딩을 지원하는 환경이 아닙니다");
|
|
8298
8362
|
}
|
|
8299
|
-
function
|
|
8363
|
+
function ro(r) {
|
|
8300
8364
|
if (typeof r != "object" || r === null)
|
|
8301
8365
|
throw new Error("Deeplink payload가 유효한 객체가 아닙니다");
|
|
8302
8366
|
const e = r;
|
|
@@ -8316,10 +8380,10 @@ export {
|
|
|
8316
8380
|
m as CROSSxError,
|
|
8317
8381
|
Fs as CROSSxEthereumProvider,
|
|
8318
8382
|
it as CROSSxSDK,
|
|
8319
|
-
|
|
8383
|
+
io as ChainId,
|
|
8320
8384
|
p as ErrorCode,
|
|
8321
8385
|
es as PinMemoryStore,
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8386
|
+
Qn as TokenMemoryStore,
|
|
8387
|
+
ao as createCROSSxSDK,
|
|
8388
|
+
co as parseOAuthDeeplink
|
|
8325
8389
|
};
|