@nexus-cross/crossx-sdk-core 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts.map +1 -1
- package/dist/crossx.global +50 -49
- package/dist/index.cjs +52 -51
- package/dist/index.js +678 -671
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var T = (r, e, s) =>
|
|
4
|
-
import { createRemoteJWKSet as
|
|
1
|
+
var Ls = Object.defineProperty;
|
|
2
|
+
var Ds = (r, e, s) => e in r ? Ls(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
|
|
3
|
+
var T = (r, e, s) => Ds(r, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
import { createRemoteJWKSet as Ms, jwtVerify as $s, decodeJwt as Bs } from "jose";
|
|
5
5
|
var p = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.ALREADY_AUTHENTICATED = "ALREADY_AUTHENTICATED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", r.USER_REJECTED = "USER_REJECTED", r.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", r.NETWORK_ERROR = "NETWORK_ERROR", r.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", r.INVALID_CHAIN = "INVALID_CHAIN", r.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", r.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.SIGNATURE_FAILED = "SIGNATURE_FAILED", r.TRANSACTION_FAILED = "TRANSACTION_FAILED", r.PREPARE_FAILED = "PREPARE_FAILED", r.PREPARE_EXPIRED = "PREPARE_EXPIRED", r.PREPARE_MISMATCH = "PREPARE_MISMATCH", r.MIGRATION_FAILED = "MIGRATION_FAILED", r.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", r.MIGRATION_PIN_LOCKED = "MIGRATION_PIN_LOCKED", r.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", r.WALLET_INCONSISTENT_STATE = "WALLET_INCONSISTENT_STATE", r.PROJECT_ID_MISSING = "PROJECT_ID_MISSING", r.ORIGIN_NOT_ALLOWED = "ORIGIN_NOT_ALLOWED", r.APP_IDENTIFIER_MISSING = "APP_IDENTIFIER_MISSING", r.INVALID_APP_TYPE = "INVALID_APP_TYPE", r.PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED", r.SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH", r.GAS_ESTIMATION_FAILED = "GAS_ESTIMATION_FAILED", r.TYPED_DATA_CHAIN_ID_MISMATCH = "TYPED_DATA_CHAIN_ID_MISMATCH", r.PIN_NOT_SET = "PIN_NOT_SET", r.PIN_WRONG = "PIN_WRONG", r.PIN_INVALID = "PIN_INVALID", r.PIN_CANCELLED = "PIN_CANCELLED", r.PIN_LOCKED = "PIN_LOCKED", r.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(p || {});
|
|
6
6
|
class g extends Error {
|
|
7
7
|
constructor(e, s, t) {
|
|
@@ -16,7 +16,7 @@ class g extends Error {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const Ve = {
|
|
20
20
|
// ─── CROSS ────────────────────────────────────────────
|
|
21
21
|
CROSS_MAINNET: {
|
|
22
22
|
caipId: "eip155:612055",
|
|
@@ -65,20 +65,20 @@ const Ke = {
|
|
|
65
65
|
rpcUrl: "https://saigon-testnet.roninchain.com/rpc",
|
|
66
66
|
testnet: !0
|
|
67
67
|
}
|
|
68
|
-
},
|
|
69
|
-
Object.entries(
|
|
70
|
-
),
|
|
71
|
-
Object.values(
|
|
68
|
+
}, to = Object.fromEntries(
|
|
69
|
+
Object.entries(Ve).map(([r, e]) => [r, e.caipId])
|
|
70
|
+
), Us = new Map(
|
|
71
|
+
Object.values(Ve).map((r) => [r.caipId, r])
|
|
72
72
|
);
|
|
73
73
|
new Map(
|
|
74
|
-
Object.values(
|
|
74
|
+
Object.values(Ve).map((r) => [r.chainId, r])
|
|
75
75
|
);
|
|
76
|
-
const
|
|
77
|
-
function
|
|
76
|
+
const Hs = { symbol: "", decimals: 18 };
|
|
77
|
+
function Je(r) {
|
|
78
78
|
var e;
|
|
79
|
-
return ((e =
|
|
79
|
+
return ((e = Us.get(r)) == null ? void 0 : e.nativeCurrency) ?? Hs;
|
|
80
80
|
}
|
|
81
|
-
class
|
|
81
|
+
class Fs {
|
|
82
82
|
constructor(e, s) {
|
|
83
83
|
this.sdk = e, this.chainId = s, this._listeners = /* @__PURE__ */ new Map();
|
|
84
84
|
}
|
|
@@ -167,30 +167,30 @@ class Hs {
|
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
let
|
|
171
|
-
function
|
|
172
|
-
|
|
170
|
+
let Ee = null;
|
|
171
|
+
function vt(r) {
|
|
172
|
+
Ee = r;
|
|
173
173
|
}
|
|
174
174
|
const u = {
|
|
175
175
|
log(...r) {
|
|
176
|
-
if (
|
|
177
|
-
|
|
176
|
+
if (Ee) {
|
|
177
|
+
Ee.log(...r);
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
180
180
|
},
|
|
181
181
|
warn(...r) {
|
|
182
|
-
if (
|
|
183
|
-
|
|
182
|
+
if (Ee) {
|
|
183
|
+
Ee.warn(...r);
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
error(...r) {
|
|
188
|
-
if (
|
|
189
|
-
|
|
188
|
+
if (Ee) {
|
|
189
|
+
Ee.error(...r);
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
},
|
|
193
|
+
}, Gs = {
|
|
194
194
|
// ── 공통 버튼 ────────────────────────────────────────────────
|
|
195
195
|
confirm: "확인",
|
|
196
196
|
cancel: "취소",
|
|
@@ -255,7 +255,7 @@ const u = {
|
|
|
255
255
|
// ── PIN 잠금 안내 ─────────────────────────────────────────────
|
|
256
256
|
pinLocked_message: "잠금이 해제된 후 다시 시도해 주세요.",
|
|
257
257
|
pinLocked_availableFrom: "이용 가능 시간"
|
|
258
|
-
},
|
|
258
|
+
}, Qt = {
|
|
259
259
|
// ── Common buttons ───────────────────────────────────────────
|
|
260
260
|
confirm: "Confirm",
|
|
261
261
|
cancel: "Cancel",
|
|
@@ -320,15 +320,15 @@ const u = {
|
|
|
320
320
|
// ── PIN lock message ─────────────────────────────────────────
|
|
321
321
|
pinLocked_message: "Please try again after the lock expires.",
|
|
322
322
|
pinLocked_availableFrom: "Available from"
|
|
323
|
-
},
|
|
324
|
-
ko:
|
|
325
|
-
en:
|
|
323
|
+
}, Ws = {
|
|
324
|
+
ko: Gs,
|
|
325
|
+
en: Qt
|
|
326
326
|
};
|
|
327
|
-
function
|
|
328
|
-
return
|
|
327
|
+
function St(r = "en", e) {
|
|
328
|
+
return Ws[r] ?? Qt;
|
|
329
329
|
}
|
|
330
|
-
const
|
|
331
|
-
class
|
|
330
|
+
const Et = "crossx_access_token", It = "crossx_refresh_token", Tt = "crossx_user_info";
|
|
331
|
+
class qs {
|
|
332
332
|
constructor(e, s, t, n, o, i, a) {
|
|
333
333
|
this.config = e, this.storage = s, this.crypto = t, this.oauth = n, this.transport = o, this.walletProvider = i, this.tokenStore = a, this._refreshPromise = null, this._migrated = !1;
|
|
334
334
|
const c = e.projectId;
|
|
@@ -405,8 +405,8 @@ class Ws {
|
|
|
405
405
|
}, u.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
|
|
406
406
|
}
|
|
407
407
|
u.log("[CROSSx] 사용자 정보 — id:", s.id);
|
|
408
|
-
const
|
|
409
|
-
await this.storage.set(this.STORAGE_KEY_USER,
|
|
408
|
+
const C = this.useCookieAuth ? { id: s.id, signInProvider: s.signInProvider, providerSub: s.providerSub } : s;
|
|
409
|
+
await this.storage.set(this.STORAGE_KEY_USER, C), u.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
|
|
410
410
|
} catch (c) {
|
|
411
411
|
return u.error("[CROSSx] SignIn 에러 (OAuth/토큰 교환 단계):", c), {
|
|
412
412
|
success: !1,
|
|
@@ -618,13 +618,13 @@ class Ws {
|
|
|
618
618
|
if (!this._migrated) {
|
|
619
619
|
this._migrated = !0;
|
|
620
620
|
try {
|
|
621
|
-
const e = await this.storage.get(
|
|
621
|
+
const e = await this.storage.get(Tt);
|
|
622
622
|
if (!e || await this.storage.get(this.STORAGE_KEY_USER)) return;
|
|
623
623
|
await this.storage.set(this.STORAGE_KEY_USER, e);
|
|
624
|
-
const t = await this.storage.get(
|
|
624
|
+
const t = await this.storage.get(Et);
|
|
625
625
|
t && await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, t);
|
|
626
|
-
const n = await this.storage.get(
|
|
627
|
-
n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(
|
|
626
|
+
const n = await this.storage.get(It);
|
|
627
|
+
n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(Tt), await this.storage.remove(Et), await this.storage.remove(It), u.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
|
|
628
628
|
} catch (e) {
|
|
629
629
|
u.warn("[CROSSx] 스토리지 키 마이그레이션 실패:", e);
|
|
630
630
|
}
|
|
@@ -659,7 +659,7 @@ class Ws {
|
|
|
659
659
|
return u.log("[CROSSx] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
|
|
660
660
|
}
|
|
661
661
|
}
|
|
662
|
-
class
|
|
662
|
+
class Ks {
|
|
663
663
|
constructor(e, s, t) {
|
|
664
664
|
this.config = e, this.storage = s, this.tokenStore = t;
|
|
665
665
|
const n = e.projectId;
|
|
@@ -669,7 +669,7 @@ class qs {
|
|
|
669
669
|
this.tokenStore.clear(), this.config.authMode !== "cookie" && (await this.storage.remove(this.STORAGE_KEY_ACCESS_TOKEN), await this.storage.remove(this.STORAGE_KEY_REFRESH_TOKEN)), await this.storage.remove(this.STORAGE_KEY_USER), await this.storage.clear();
|
|
670
670
|
}
|
|
671
671
|
}
|
|
672
|
-
class
|
|
672
|
+
class Vs {
|
|
673
673
|
constructor(e, s) {
|
|
674
674
|
this.storage = e, this.walletProvider = s;
|
|
675
675
|
}
|
|
@@ -686,7 +686,7 @@ class Ks {
|
|
|
686
686
|
};
|
|
687
687
|
}
|
|
688
688
|
}
|
|
689
|
-
class
|
|
689
|
+
class es {
|
|
690
690
|
constructor() {
|
|
691
691
|
this.encryptedBytes = null, this.xorKey = null;
|
|
692
692
|
}
|
|
@@ -727,7 +727,7 @@ class Qt {
|
|
|
727
727
|
return this.encryptedBytes !== null;
|
|
728
728
|
}
|
|
729
729
|
}
|
|
730
|
-
class
|
|
730
|
+
class zs {
|
|
731
731
|
constructor(e, s) {
|
|
732
732
|
this.chainRegistry = e, this.transport = s, this._nextId = 1;
|
|
733
733
|
}
|
|
@@ -759,7 +759,7 @@ class Vs {
|
|
|
759
759
|
return a == null ? void 0 : a.result;
|
|
760
760
|
}
|
|
761
761
|
}
|
|
762
|
-
class
|
|
762
|
+
class js {
|
|
763
763
|
constructor() {
|
|
764
764
|
this.listeners = /* @__PURE__ */ new Map();
|
|
765
765
|
}
|
|
@@ -782,7 +782,7 @@ class zs {
|
|
|
782
782
|
this.listeners.clear();
|
|
783
783
|
}
|
|
784
784
|
}
|
|
785
|
-
const
|
|
785
|
+
const Ge = {
|
|
786
786
|
// TODO(v2.0.0-BEFORE-RELEASE): 아래 블록으로 교체
|
|
787
787
|
// production: {
|
|
788
788
|
// oauthServiceUrl: 'https://cross-wallet-oauth.crosstoken.io',
|
|
@@ -805,24 +805,24 @@ const Fe = {
|
|
|
805
805
|
walletGatewayUrl: "https://dev-embedded-wallet-gateway.crosstoken.io/api/v1"
|
|
806
806
|
}
|
|
807
807
|
};
|
|
808
|
-
function
|
|
808
|
+
function Ys(r) {
|
|
809
809
|
const e = r.environment;
|
|
810
|
-
return e && e in
|
|
810
|
+
return e && e in Ge ? Ge[e] : null;
|
|
811
811
|
}
|
|
812
|
-
function
|
|
812
|
+
function Js() {
|
|
813
813
|
try {
|
|
814
814
|
if (typeof __CROSSX_CONFIG__ < "u") {
|
|
815
|
-
const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e =
|
|
815
|
+
const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e = Ys(r);
|
|
816
816
|
if (e) return e;
|
|
817
817
|
}
|
|
818
818
|
} catch {
|
|
819
819
|
}
|
|
820
|
-
return
|
|
820
|
+
return Ge.production;
|
|
821
821
|
}
|
|
822
|
-
const
|
|
822
|
+
const Zs = 2e3, At = 6e4, Xs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA00", kt = 130, Pt = 6, Nt = 18, tr = 5 * 60 * 1e3, sr = 30 * 1e3, re = class re extends js {
|
|
823
823
|
constructor(e, s, t, n, o, i, a, c, l, d, h) {
|
|
824
824
|
var m;
|
|
825
|
-
super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this._initPromise = null, this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._verifyPinMutex = null, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger &&
|
|
825
|
+
super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this._initPromise = null, this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._verifyPinMutex = null, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && vt(e.logger), this.confirmation = l, this.pinStore = h ?? new es(), this.chainRegistry = d, this.jsonRpc = new zs(d, o), this.signInUseCase = new qs(
|
|
826
826
|
this.internalConfig,
|
|
827
827
|
t,
|
|
828
828
|
n,
|
|
@@ -830,7 +830,7 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
830
830
|
o,
|
|
831
831
|
a,
|
|
832
832
|
c
|
|
833
|
-
), this.signOutUseCase = new
|
|
833
|
+
), this.signOutUseCase = new Ks(this.internalConfig, t, c), this.migrateWalletUseCase = new Vs(t, a), (m = a.setOnUnauthorized) == null || m.call(a, () => this.forceLogout());
|
|
834
834
|
}
|
|
835
835
|
get config() {
|
|
836
836
|
return this._config;
|
|
@@ -856,9 +856,9 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
856
856
|
}
|
|
857
857
|
async _doInitialize(e) {
|
|
858
858
|
var s, t;
|
|
859
|
-
u.log("[CROSSx SDK] v1.2.
|
|
859
|
+
u.log("[CROSSx SDK] v1.2.6 초기화 중..."), this.confirmation.setMessages(St(this._config.locale));
|
|
860
860
|
try {
|
|
861
|
-
const n =
|
|
861
|
+
const n = Js();
|
|
862
862
|
this.internalConfig.oauthServiceUrl = n.oauthServiceUrl, this.internalConfig.authApiUrl = n.authApiUrl, this.internalConfig.walletGatewayUrl = n.walletGatewayUrl, this.adapterConfig.gatewayUrl = n.walletGatewayUrl, (t = (s = this.crypto).setJWKSEndpoint) == null || t.call(s, `${n.authApiUrl}/.well-known/jwks.json`);
|
|
863
863
|
const o = await this.signInUseCase.restoreSession();
|
|
864
864
|
if (o != null && o.success) {
|
|
@@ -1228,7 +1228,7 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
1228
1228
|
* sdk.applyLocale('ko');
|
|
1229
1229
|
*/
|
|
1230
1230
|
applyLocale(e = this._config.locale ?? "en") {
|
|
1231
|
-
this._config = Object.freeze({ ...this._config, locale: e }), this.confirmation.setMessages(
|
|
1231
|
+
this._config = Object.freeze({ ...this._config, locale: e }), this.confirmation.setMessages(St(e));
|
|
1232
1232
|
}
|
|
1233
1233
|
/**
|
|
1234
1234
|
* 지갑 생성/로드 (로그인 후 address가 없는 경우)
|
|
@@ -1442,7 +1442,7 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
1442
1442
|
throw new g(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1443
1443
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
1444
1444
|
n.from || (n.from = (await this.resolveAddress(t == null ? void 0 : t.index)).address);
|
|
1445
|
-
const o =
|
|
1445
|
+
const o = Je(e);
|
|
1446
1446
|
if (!await this.confirmation.requestConfirmation({
|
|
1447
1447
|
type: "sign",
|
|
1448
1448
|
chainId: e,
|
|
@@ -1497,7 +1497,7 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
1497
1497
|
throw new g(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1498
1498
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
1499
1499
|
n.from || (n.from = (await this.resolveAddress(t == null ? void 0 : t.index)).address);
|
|
1500
|
-
const o =
|
|
1500
|
+
const o = Je(e);
|
|
1501
1501
|
if (!await this.confirmation.requestConfirmation({
|
|
1502
1502
|
type: "send",
|
|
1503
1503
|
chainId: e,
|
|
@@ -1564,7 +1564,7 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
1564
1564
|
* @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
|
|
1565
1565
|
*/
|
|
1566
1566
|
async waitForTxAndGetReceipt(e, s, t = {}) {
|
|
1567
|
-
const n = t.intervalMs ??
|
|
1567
|
+
const n = t.intervalMs ?? Xs, o = Qs, i = t.timeoutMs ?? At, a = Date.now() + i;
|
|
1568
1568
|
let c = n;
|
|
1569
1569
|
for (; Date.now() < a; ) {
|
|
1570
1570
|
const l = await this.getTransactionReceipt(e, s);
|
|
@@ -1593,11 +1593,11 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
1593
1593
|
*/
|
|
1594
1594
|
async sendTransactionWithWaitForReceipt(e, s, t = {}) {
|
|
1595
1595
|
var E, y;
|
|
1596
|
-
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((E = this._config.receiptPolling) == null ? void 0 : E.intervalMs) ??
|
|
1596
|
+
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((E = this._config.receiptPolling) == null ? void 0 : E.intervalMs) ?? Zs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? At, d = Je(e), h = s.from ?? "";
|
|
1597
1597
|
let m, x;
|
|
1598
1598
|
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((S) => {
|
|
1599
1599
|
m = S;
|
|
1600
|
-
const
|
|
1600
|
+
const C = BigInt(S.gasUsed) * BigInt(S.effectiveGasPrice), B = s.value ? BigInt(s.value) : 0n, b = re.formatTxAmount(s.value, d.symbol, d.decimals), k = re.formatTxAmount("0x" + C.toString(16), d.symbol, d.decimals), P = re.formatTxAmount("0x" + (B + C).toString(16), d.symbol, d.decimals);
|
|
1601
1601
|
return {
|
|
1602
1602
|
chainId: e,
|
|
1603
1603
|
txHash: a,
|
|
@@ -1804,7 +1804,7 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
1804
1804
|
try {
|
|
1805
1805
|
const s = BigInt(e);
|
|
1806
1806
|
if (s === 0n) return "0";
|
|
1807
|
-
const t = 10n ** BigInt(
|
|
1807
|
+
const t = 10n ** BigInt(Nt), n = s / t, i = (s % t).toString().padStart(Nt, "0").replace(/0+$/, "").slice(0, Pt);
|
|
1808
1808
|
return i ? `${n}.${i}` : `${n}`;
|
|
1809
1809
|
} catch {
|
|
1810
1810
|
return "?";
|
|
@@ -1829,7 +1829,7 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
1829
1829
|
* const client = createWalletClient({ transport: custom(provider) });
|
|
1830
1830
|
*/
|
|
1831
1831
|
getProvider(e) {
|
|
1832
|
-
return this.ensureAuthenticated(), new
|
|
1832
|
+
return this.ensureAuthenticated(), new Fs(this, e);
|
|
1833
1833
|
}
|
|
1834
1834
|
/**
|
|
1835
1835
|
* 범용 JSON-RPC 요청 — 노드에 직접 연결.
|
|
@@ -1863,7 +1863,7 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
1863
1863
|
try {
|
|
1864
1864
|
const n = BigInt(e);
|
|
1865
1865
|
if (n === 0n) return;
|
|
1866
|
-
const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0,
|
|
1866
|
+
const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0, Pt).replace(/0+$/, "");
|
|
1867
1867
|
return `${c ? `${i}.${c}` : `${i}`} ${s}`;
|
|
1868
1868
|
} catch {
|
|
1869
1869
|
return;
|
|
@@ -1963,12 +1963,12 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
1963
1963
|
u.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
|
|
1964
1964
|
const l = await this.getBaseFeePerGas(s);
|
|
1965
1965
|
if (l) {
|
|
1966
|
-
const d =
|
|
1966
|
+
const d = Rt;
|
|
1967
1967
|
c.maxFeePerGas = "0x" + (BigInt(l) + BigInt(d)).toString(16), c.maxPriorityFeePerGas = d, u.log("[CROSSx] Dynamic 체인 감지 — baseFee:", l, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
|
|
1968
1968
|
} else
|
|
1969
|
-
c.gasPrice =
|
|
1969
|
+
c.gasPrice = er, u.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
|
|
1970
1970
|
}
|
|
1971
|
-
return !i && a && (c.maxPriorityFeePerGas =
|
|
1971
|
+
return !i && a && (c.maxPriorityFeePerGas = Rt, u.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
|
|
1972
1972
|
}
|
|
1973
1973
|
/**
|
|
1974
1974
|
* EIP-712 signTypedData 호출 시 chainId와 typedData.domain.chainId 정합성 검증.
|
|
@@ -2015,10 +2015,10 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
2015
2015
|
const s = e.startsWith("0x") ? e.slice(2) : e;
|
|
2016
2016
|
if (!/^[0-9a-fA-F]+$/.test(s))
|
|
2017
2017
|
throw new g(p.SIGNATURE_FAILED, "유효하지 않은 서명: 올바른 hex 문자열이 아닙니다");
|
|
2018
|
-
if (s.length !==
|
|
2018
|
+
if (s.length !== kt)
|
|
2019
2019
|
throw new g(
|
|
2020
2020
|
p.SIGNATURE_FAILED,
|
|
2021
|
-
`서명 길이가 유효하지 않습니다: ${
|
|
2021
|
+
`서명 길이가 유효하지 않습니다: ${kt} hex 문자(65 바이트) 예상, 현재 ${s.length}`
|
|
2022
2022
|
);
|
|
2023
2023
|
}
|
|
2024
2024
|
/** RLP-encoded signed transaction 형식 검증 */
|
|
@@ -2290,12 +2290,12 @@ const Js = 2e3, Tt = 6e4, Zs = 1e3, Xs = 1e4, Qs = "0x77359400", At = "0x3B9ACA0
|
|
|
2290
2290
|
* dispose 후 SDK 인스턴스는 더 이상 사용할 수 없습니다.
|
|
2291
2291
|
*/
|
|
2292
2292
|
dispose() {
|
|
2293
|
-
this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(),
|
|
2293
|
+
this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), vt(null);
|
|
2294
2294
|
}
|
|
2295
2295
|
};
|
|
2296
2296
|
re.OFFCHAIN_CHAIN_ID = "0";
|
|
2297
|
-
let
|
|
2298
|
-
class
|
|
2297
|
+
let it = re;
|
|
2298
|
+
class rr {
|
|
2299
2299
|
constructor() {
|
|
2300
2300
|
this.prefix = "crossx_";
|
|
2301
2301
|
}
|
|
@@ -2332,8 +2332,8 @@ class sr {
|
|
|
2332
2332
|
}
|
|
2333
2333
|
}
|
|
2334
2334
|
}
|
|
2335
|
-
const
|
|
2336
|
-
class
|
|
2335
|
+
const Ze = "crossx-sdk", nr = 1, de = "data", Se = "keys", $e = "aes-primary", or = 12;
|
|
2336
|
+
class Ot {
|
|
2337
2337
|
constructor(e) {
|
|
2338
2338
|
this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
|
|
2339
2339
|
}
|
|
@@ -2342,10 +2342,10 @@ class Ct {
|
|
|
2342
2342
|
}
|
|
2343
2343
|
openDB(e = this.dbName) {
|
|
2344
2344
|
return new Promise((s, t) => {
|
|
2345
|
-
const n = indexedDB.open(e,
|
|
2345
|
+
const n = indexedDB.open(e, nr);
|
|
2346
2346
|
n.onupgradeneeded = () => {
|
|
2347
2347
|
const o = n.result;
|
|
2348
|
-
o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(
|
|
2348
|
+
o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(Se) || o.createObjectStore(Se);
|
|
2349
2349
|
}, n.onsuccess = () => s(n.result), n.onerror = () => t(n.error);
|
|
2350
2350
|
});
|
|
2351
2351
|
}
|
|
@@ -2375,7 +2375,7 @@ class Ct {
|
|
|
2375
2375
|
}
|
|
2376
2376
|
async init() {
|
|
2377
2377
|
this.db = await this.openDB();
|
|
2378
|
-
const e = await this.idbGet(
|
|
2378
|
+
const e = await this.idbGet(Se, $e);
|
|
2379
2379
|
if (e) {
|
|
2380
2380
|
this.cryptoKey = e;
|
|
2381
2381
|
return;
|
|
@@ -2389,16 +2389,16 @@ class Ct {
|
|
|
2389
2389
|
{ name: "AES-GCM", length: 256 },
|
|
2390
2390
|
!1,
|
|
2391
2391
|
["encrypt", "decrypt"]
|
|
2392
|
-
), await this.idbPut(
|
|
2392
|
+
), await this.idbPut(Se, $e, this.cryptoKey);
|
|
2393
2393
|
}
|
|
2394
2394
|
/**
|
|
2395
2395
|
* 레거시 DB('crossx-sdk')에서 projectId 스코프 DB로 암호키·데이터 마이그레이션.
|
|
2396
2396
|
* 마이그레이션 성공 시 레거시 DB 삭제.
|
|
2397
2397
|
*/
|
|
2398
2398
|
async migrateFromLegacyDB() {
|
|
2399
|
-
if (this.dbName ===
|
|
2399
|
+
if (this.dbName === Ze) return null;
|
|
2400
2400
|
try {
|
|
2401
|
-
const e = await this.openDB(
|
|
2401
|
+
const e = await this.openDB(Ze), s = e.transaction([Se, de], "readonly"), t = s.objectStore(Se).get($e), n = await new Promise((l, d) => {
|
|
2402
2402
|
t.onsuccess = () => l(t.result), t.onerror = () => d(t.error);
|
|
2403
2403
|
});
|
|
2404
2404
|
if (!n)
|
|
@@ -2411,16 +2411,16 @@ class Ct {
|
|
|
2411
2411
|
i.onsuccess = () => l(i.result), i.onerror = () => d(i.error);
|
|
2412
2412
|
})
|
|
2413
2413
|
]);
|
|
2414
|
-
e.close(), await this.idbPut(
|
|
2414
|
+
e.close(), await this.idbPut(Se, $e, n);
|
|
2415
2415
|
for (let l = 0; l < c.length; l++)
|
|
2416
2416
|
await this.idbPut(de, String(c[l]), a[l]);
|
|
2417
|
-
return indexedDB.deleteDatabase(
|
|
2417
|
+
return indexedDB.deleteDatabase(Ze), u.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), n;
|
|
2418
2418
|
} catch (e) {
|
|
2419
2419
|
return u.warn("[CROSSx] IndexedDB 레거시 DB 마이그레이션 실패:", e), null;
|
|
2420
2420
|
}
|
|
2421
2421
|
}
|
|
2422
2422
|
async encrypt(e) {
|
|
2423
|
-
const s = new Uint8Array(
|
|
2423
|
+
const s = new Uint8Array(or);
|
|
2424
2424
|
crypto.getRandomValues(s);
|
|
2425
2425
|
const t = new TextEncoder().encode(e), n = await crypto.subtle.encrypt(
|
|
2426
2426
|
{ name: "AES-GCM", iv: s },
|
|
@@ -2479,91 +2479,91 @@ class Ct {
|
|
|
2479
2479
|
}
|
|
2480
2480
|
}
|
|
2481
2481
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2482
|
-
function
|
|
2482
|
+
function ut(r) {
|
|
2483
2483
|
return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
|
|
2484
2484
|
}
|
|
2485
|
-
function
|
|
2485
|
+
function ge(r, e = "") {
|
|
2486
2486
|
if (!Number.isSafeInteger(r) || r < 0) {
|
|
2487
2487
|
const s = e && `"${e}" `;
|
|
2488
2488
|
throw new Error(`${s}expected integer >= 0, got ${r}`);
|
|
2489
2489
|
}
|
|
2490
2490
|
}
|
|
2491
2491
|
function V(r, e, s = "") {
|
|
2492
|
-
const t =
|
|
2492
|
+
const t = ut(r), n = r == null ? void 0 : r.length, o = e !== void 0;
|
|
2493
2493
|
if (!t || o && n !== e) {
|
|
2494
2494
|
const i = s && `"${s}" `, a = o ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
|
|
2495
2495
|
throw new Error(i + "expected Uint8Array" + a + ", got " + c);
|
|
2496
2496
|
}
|
|
2497
2497
|
return r;
|
|
2498
2498
|
}
|
|
2499
|
-
function
|
|
2499
|
+
function ts(r) {
|
|
2500
2500
|
if (typeof r != "function" || typeof r.create != "function")
|
|
2501
2501
|
throw new Error("Hash must wrapped by utils.createHasher");
|
|
2502
|
-
|
|
2502
|
+
ge(r.outputLen), ge(r.blockLen);
|
|
2503
2503
|
}
|
|
2504
|
-
function
|
|
2504
|
+
function ke(r, e = !0) {
|
|
2505
2505
|
if (r.destroyed)
|
|
2506
2506
|
throw new Error("Hash instance has been destroyed");
|
|
2507
2507
|
if (e && r.finished)
|
|
2508
2508
|
throw new Error("Hash#digest() has already been called");
|
|
2509
2509
|
}
|
|
2510
|
-
function
|
|
2510
|
+
function ss(r, e) {
|
|
2511
2511
|
V(r, void 0, "digestInto() output");
|
|
2512
2512
|
const s = e.outputLen;
|
|
2513
2513
|
if (r.length < s)
|
|
2514
2514
|
throw new Error('"digestInto() output" expected to be of length >=' + s);
|
|
2515
2515
|
}
|
|
2516
|
-
function
|
|
2516
|
+
function ir(r) {
|
|
2517
2517
|
return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
|
|
2518
2518
|
}
|
|
2519
|
-
function
|
|
2519
|
+
function Pe(...r) {
|
|
2520
2520
|
for (let e = 0; e < r.length; e++)
|
|
2521
2521
|
r[e].fill(0);
|
|
2522
2522
|
}
|
|
2523
|
-
function
|
|
2523
|
+
function Xe(r) {
|
|
2524
2524
|
return new DataView(r.buffer, r.byteOffset, r.byteLength);
|
|
2525
2525
|
}
|
|
2526
2526
|
function ue(r, e) {
|
|
2527
2527
|
return r << 32 - e | r >>> e;
|
|
2528
2528
|
}
|
|
2529
|
-
const
|
|
2530
|
-
function
|
|
2529
|
+
const ar = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
2530
|
+
function cr(r) {
|
|
2531
2531
|
return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
|
|
2532
2532
|
}
|
|
2533
|
-
function
|
|
2533
|
+
function lr(r) {
|
|
2534
2534
|
for (let e = 0; e < r.length; e++)
|
|
2535
|
-
r[e] =
|
|
2535
|
+
r[e] = cr(r[e]);
|
|
2536
2536
|
return r;
|
|
2537
2537
|
}
|
|
2538
|
-
const
|
|
2539
|
-
function
|
|
2540
|
-
if (V(r),
|
|
2538
|
+
const Ct = ar ? (r) => r : lr, rs = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", dr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
|
|
2539
|
+
function Me(r) {
|
|
2540
|
+
if (V(r), rs)
|
|
2541
2541
|
return r.toHex();
|
|
2542
2542
|
let e = "";
|
|
2543
2543
|
for (let s = 0; s < r.length; s++)
|
|
2544
|
-
e +=
|
|
2544
|
+
e += dr[r[s]];
|
|
2545
2545
|
return e;
|
|
2546
2546
|
}
|
|
2547
|
-
const
|
|
2548
|
-
function
|
|
2549
|
-
if (r >=
|
|
2550
|
-
return r -
|
|
2551
|
-
if (r >=
|
|
2552
|
-
return r - (
|
|
2553
|
-
if (r >=
|
|
2554
|
-
return r - (
|
|
2547
|
+
const fe = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
2548
|
+
function Lt(r) {
|
|
2549
|
+
if (r >= fe._0 && r <= fe._9)
|
|
2550
|
+
return r - fe._0;
|
|
2551
|
+
if (r >= fe.A && r <= fe.F)
|
|
2552
|
+
return r - (fe.A - 10);
|
|
2553
|
+
if (r >= fe.a && r <= fe.f)
|
|
2554
|
+
return r - (fe.a - 10);
|
|
2555
2555
|
}
|
|
2556
|
-
function
|
|
2556
|
+
function We(r) {
|
|
2557
2557
|
if (typeof r != "string")
|
|
2558
2558
|
throw new Error("hex string expected, got " + typeof r);
|
|
2559
|
-
if (
|
|
2559
|
+
if (rs)
|
|
2560
2560
|
return Uint8Array.fromHex(r);
|
|
2561
2561
|
const e = r.length, s = e / 2;
|
|
2562
2562
|
if (e % 2)
|
|
2563
2563
|
throw new Error("hex string expected, got unpadded hex of length " + e);
|
|
2564
2564
|
const t = new Uint8Array(s);
|
|
2565
2565
|
for (let n = 0, o = 0; n < s; n++, o += 2) {
|
|
2566
|
-
const i =
|
|
2566
|
+
const i = Lt(r.charCodeAt(o)), a = Lt(r.charCodeAt(o + 1));
|
|
2567
2567
|
if (i === void 0 || a === void 0) {
|
|
2568
2568
|
const c = r[o] + r[o + 1];
|
|
2569
2569
|
throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + o);
|
|
@@ -2572,7 +2572,7 @@ function Ge(r) {
|
|
|
2572
2572
|
}
|
|
2573
2573
|
return t;
|
|
2574
2574
|
}
|
|
2575
|
-
function
|
|
2575
|
+
function ve(...r) {
|
|
2576
2576
|
let e = 0;
|
|
2577
2577
|
for (let t = 0; t < r.length; t++) {
|
|
2578
2578
|
const n = r[t];
|
|
@@ -2585,26 +2585,26 @@ function be(...r) {
|
|
|
2585
2585
|
}
|
|
2586
2586
|
return s;
|
|
2587
2587
|
}
|
|
2588
|
-
function
|
|
2588
|
+
function ns(r, e = {}) {
|
|
2589
2589
|
const s = (n, o) => r(o).update(n).digest(), t = r(void 0);
|
|
2590
2590
|
return s.outputLen = t.outputLen, s.blockLen = t.blockLen, s.create = (n) => r(n), Object.assign(s, e), Object.freeze(s);
|
|
2591
2591
|
}
|
|
2592
|
-
function
|
|
2592
|
+
function os(r = 32) {
|
|
2593
2593
|
const e = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
2594
2594
|
if (typeof (e == null ? void 0 : e.getRandomValues) != "function")
|
|
2595
2595
|
throw new Error("crypto.getRandomValues must be defined");
|
|
2596
2596
|
return e.getRandomValues(new Uint8Array(r));
|
|
2597
2597
|
}
|
|
2598
|
-
const
|
|
2598
|
+
const ur = (r) => ({
|
|
2599
2599
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, r])
|
|
2600
2600
|
});
|
|
2601
|
-
function
|
|
2601
|
+
function hr(r, e, s) {
|
|
2602
2602
|
return r & e ^ ~r & s;
|
|
2603
2603
|
}
|
|
2604
|
-
function
|
|
2604
|
+
function pr(r, e, s) {
|
|
2605
2605
|
return r & e ^ r & s ^ e & s;
|
|
2606
2606
|
}
|
|
2607
|
-
class
|
|
2607
|
+
class fr {
|
|
2608
2608
|
constructor(e, s, t, n) {
|
|
2609
2609
|
T(this, "blockLen");
|
|
2610
2610
|
T(this, "outputLen");
|
|
@@ -2617,15 +2617,15 @@ class pr {
|
|
|
2617
2617
|
T(this, "length", 0);
|
|
2618
2618
|
T(this, "pos", 0);
|
|
2619
2619
|
T(this, "destroyed", !1);
|
|
2620
|
-
this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view =
|
|
2620
|
+
this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Xe(this.buffer);
|
|
2621
2621
|
}
|
|
2622
2622
|
update(e) {
|
|
2623
|
-
|
|
2623
|
+
ke(this), V(e);
|
|
2624
2624
|
const { view: s, buffer: t, blockLen: n } = this, o = e.length;
|
|
2625
2625
|
for (let i = 0; i < o; ) {
|
|
2626
2626
|
const a = Math.min(n - this.pos, o - i);
|
|
2627
2627
|
if (a === n) {
|
|
2628
|
-
const c =
|
|
2628
|
+
const c = Xe(e);
|
|
2629
2629
|
for (; n <= o - i; i += n)
|
|
2630
2630
|
this.process(c, i);
|
|
2631
2631
|
continue;
|
|
@@ -2635,14 +2635,14 @@ class pr {
|
|
|
2635
2635
|
return this.length += e.length, this.roundClean(), this;
|
|
2636
2636
|
}
|
|
2637
2637
|
digestInto(e) {
|
|
2638
|
-
|
|
2638
|
+
ke(this), ss(e, this), this.finished = !0;
|
|
2639
2639
|
const { buffer: s, view: t, blockLen: n, isLE: o } = this;
|
|
2640
2640
|
let { pos: i } = this;
|
|
2641
|
-
s[i++] = 128,
|
|
2641
|
+
s[i++] = 128, Pe(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
|
|
2642
2642
|
for (let h = i; h < n; h++)
|
|
2643
2643
|
s[h] = 0;
|
|
2644
2644
|
t.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(t, 0);
|
|
2645
|
-
const a =
|
|
2645
|
+
const a = Xe(e), c = this.outputLen;
|
|
2646
2646
|
if (c % 4)
|
|
2647
2647
|
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
2648
2648
|
const l = c / 4, d = this.get();
|
|
@@ -2666,7 +2666,7 @@ class pr {
|
|
|
2666
2666
|
return this._cloneInto();
|
|
2667
2667
|
}
|
|
2668
2668
|
}
|
|
2669
|
-
const
|
|
2669
|
+
const me = /* @__PURE__ */ Uint32Array.from([
|
|
2670
2670
|
1779033703,
|
|
2671
2671
|
3144134277,
|
|
2672
2672
|
1013904242,
|
|
@@ -2675,20 +2675,20 @@ const ge = /* @__PURE__ */ Uint32Array.from([
|
|
|
2675
2675
|
2600822924,
|
|
2676
2676
|
528734635,
|
|
2677
2677
|
1541459225
|
|
2678
|
-
]),
|
|
2679
|
-
function fr(r, e = !1) {
|
|
2680
|
-
return e ? { h: Number(r & $e), l: Number(r >> Lt & $e) } : { h: Number(r >> Lt & $e) | 0, l: Number(r & $e) | 0 };
|
|
2681
|
-
}
|
|
2678
|
+
]), Be = /* @__PURE__ */ BigInt(2 ** 32 - 1), Dt = /* @__PURE__ */ BigInt(32);
|
|
2682
2679
|
function _r(r, e = !1) {
|
|
2680
|
+
return e ? { h: Number(r & Be), l: Number(r >> Dt & Be) } : { h: Number(r >> Dt & Be) | 0, l: Number(r & Be) | 0 };
|
|
2681
|
+
}
|
|
2682
|
+
function xr(r, e = !1) {
|
|
2683
2683
|
const s = r.length;
|
|
2684
2684
|
let t = new Uint32Array(s), n = new Uint32Array(s);
|
|
2685
2685
|
for (let o = 0; o < s; o++) {
|
|
2686
|
-
const { h: i, l: a } =
|
|
2686
|
+
const { h: i, l: a } = _r(r[o], e);
|
|
2687
2687
|
[t[o], n[o]] = [i, a];
|
|
2688
2688
|
}
|
|
2689
2689
|
return [t, n];
|
|
2690
2690
|
}
|
|
2691
|
-
const
|
|
2691
|
+
const gr = (r, e, s) => r << s | e >>> 32 - s, mr = (r, e, s) => e << s | r >>> 32 - s, wr = (r, e, s) => e << s - 32 | r >>> 64 - s, yr = (r, e, s) => r << s - 32 | e >>> 64 - s, br = /* @__PURE__ */ Uint32Array.from([
|
|
2692
2692
|
1116352408,
|
|
2693
2693
|
1899447441,
|
|
2694
2694
|
3049323471,
|
|
@@ -2753,8 +2753,8 @@ const xr = (r, e, s) => r << s | e >>> 32 - s, gr = (r, e, s) => e << s | r >>>
|
|
|
2753
2753
|
2756734187,
|
|
2754
2754
|
3204031479,
|
|
2755
2755
|
3329325298
|
|
2756
|
-
]),
|
|
2757
|
-
class
|
|
2756
|
+
]), we = /* @__PURE__ */ new Uint32Array(64);
|
|
2757
|
+
class vr extends fr {
|
|
2758
2758
|
constructor(e) {
|
|
2759
2759
|
super(64, e, 8, !1);
|
|
2760
2760
|
}
|
|
@@ -2768,112 +2768,112 @@ class br extends pr {
|
|
|
2768
2768
|
}
|
|
2769
2769
|
process(e, s) {
|
|
2770
2770
|
for (let h = 0; h < 16; h++, s += 4)
|
|
2771
|
-
|
|
2771
|
+
we[h] = e.getUint32(s, !1);
|
|
2772
2772
|
for (let h = 16; h < 64; h++) {
|
|
2773
|
-
const m =
|
|
2774
|
-
|
|
2773
|
+
const m = we[h - 15], x = we[h - 2], w = ue(m, 7) ^ ue(m, 18) ^ m >>> 3, E = ue(x, 17) ^ ue(x, 19) ^ x >>> 10;
|
|
2774
|
+
we[h] = E + we[h - 7] + w + we[h - 16] | 0;
|
|
2775
2775
|
}
|
|
2776
2776
|
let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: d } = this;
|
|
2777
2777
|
for (let h = 0; h < 64; h++) {
|
|
2778
|
-
const m = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), x = d + m +
|
|
2778
|
+
const m = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), x = d + m + hr(a, c, l) + br[h] + we[h] | 0, E = (ue(t, 2) ^ ue(t, 13) ^ ue(t, 22)) + pr(t, n, o) | 0;
|
|
2779
2779
|
d = l, l = c, c = a, a = i + x | 0, i = o, o = n, n = t, t = x + E | 0;
|
|
2780
2780
|
}
|
|
2781
2781
|
t = t + this.A | 0, n = n + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, d = d + this.H | 0, this.set(t, n, o, i, a, c, l, d);
|
|
2782
2782
|
}
|
|
2783
2783
|
roundClean() {
|
|
2784
|
-
|
|
2784
|
+
Pe(we);
|
|
2785
2785
|
}
|
|
2786
2786
|
destroy() {
|
|
2787
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0),
|
|
2787
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0), Pe(this.buffer);
|
|
2788
2788
|
}
|
|
2789
2789
|
}
|
|
2790
|
-
class
|
|
2790
|
+
class Sr extends vr {
|
|
2791
2791
|
constructor() {
|
|
2792
2792
|
super(32);
|
|
2793
2793
|
// We cannot use array here since array allows indexing by variable
|
|
2794
2794
|
// which means optimizer/compiler cannot use registers.
|
|
2795
|
-
T(this, "A",
|
|
2796
|
-
T(this, "B",
|
|
2797
|
-
T(this, "C",
|
|
2798
|
-
T(this, "D",
|
|
2799
|
-
T(this, "E",
|
|
2800
|
-
T(this, "F",
|
|
2801
|
-
T(this, "G",
|
|
2802
|
-
T(this, "H",
|
|
2803
|
-
}
|
|
2804
|
-
}
|
|
2805
|
-
const
|
|
2806
|
-
() => new
|
|
2807
|
-
/* @__PURE__ */
|
|
2795
|
+
T(this, "A", me[0] | 0);
|
|
2796
|
+
T(this, "B", me[1] | 0);
|
|
2797
|
+
T(this, "C", me[2] | 0);
|
|
2798
|
+
T(this, "D", me[3] | 0);
|
|
2799
|
+
T(this, "E", me[4] | 0);
|
|
2800
|
+
T(this, "F", me[5] | 0);
|
|
2801
|
+
T(this, "G", me[6] | 0);
|
|
2802
|
+
T(this, "H", me[7] | 0);
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
const Er = /* @__PURE__ */ ns(
|
|
2806
|
+
() => new Sr(),
|
|
2807
|
+
/* @__PURE__ */ ur(1)
|
|
2808
2808
|
);
|
|
2809
2809
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2810
|
-
const
|
|
2811
|
-
function
|
|
2810
|
+
const ht = /* @__PURE__ */ BigInt(0), at = /* @__PURE__ */ BigInt(1);
|
|
2811
|
+
function qe(r, e = "") {
|
|
2812
2812
|
if (typeof r != "boolean") {
|
|
2813
2813
|
const s = e && `"${e}" `;
|
|
2814
2814
|
throw new Error(s + "expected boolean, got type=" + typeof r);
|
|
2815
2815
|
}
|
|
2816
2816
|
return r;
|
|
2817
2817
|
}
|
|
2818
|
-
function
|
|
2818
|
+
function is(r) {
|
|
2819
2819
|
if (typeof r == "bigint") {
|
|
2820
|
-
if (!
|
|
2820
|
+
if (!Fe(r))
|
|
2821
2821
|
throw new Error("positive bigint expected, got " + r);
|
|
2822
2822
|
} else
|
|
2823
|
-
|
|
2823
|
+
ge(r);
|
|
2824
2824
|
return r;
|
|
2825
2825
|
}
|
|
2826
|
-
function
|
|
2827
|
-
const e =
|
|
2826
|
+
function Ue(r) {
|
|
2827
|
+
const e = is(r).toString(16);
|
|
2828
2828
|
return e.length & 1 ? "0" + e : e;
|
|
2829
2829
|
}
|
|
2830
|
-
function
|
|
2830
|
+
function as(r) {
|
|
2831
2831
|
if (typeof r != "string")
|
|
2832
2832
|
throw new Error("hex string expected, got " + typeof r);
|
|
2833
|
-
return r === "" ?
|
|
2833
|
+
return r === "" ? ht : BigInt("0x" + r);
|
|
2834
2834
|
}
|
|
2835
|
-
function
|
|
2836
|
-
return
|
|
2835
|
+
function ze(r) {
|
|
2836
|
+
return as(Me(r));
|
|
2837
2837
|
}
|
|
2838
|
-
function
|
|
2839
|
-
return
|
|
2838
|
+
function cs(r) {
|
|
2839
|
+
return as(Me(Ir(V(r)).reverse()));
|
|
2840
2840
|
}
|
|
2841
|
-
function
|
|
2842
|
-
|
|
2843
|
-
const s =
|
|
2841
|
+
function pt(r, e) {
|
|
2842
|
+
ge(e), r = is(r);
|
|
2843
|
+
const s = We(r.toString(16).padStart(e * 2, "0"));
|
|
2844
2844
|
if (s.length !== e)
|
|
2845
2845
|
throw new Error("number too large");
|
|
2846
2846
|
return s;
|
|
2847
2847
|
}
|
|
2848
|
-
function
|
|
2849
|
-
return
|
|
2848
|
+
function ls(r, e) {
|
|
2849
|
+
return pt(r, e).reverse();
|
|
2850
2850
|
}
|
|
2851
|
-
function
|
|
2851
|
+
function Ir(r) {
|
|
2852
2852
|
return Uint8Array.from(r);
|
|
2853
2853
|
}
|
|
2854
|
-
const
|
|
2855
|
-
function
|
|
2856
|
-
return
|
|
2854
|
+
const Fe = (r) => typeof r == "bigint" && ht <= r;
|
|
2855
|
+
function Tr(r, e, s) {
|
|
2856
|
+
return Fe(r) && Fe(e) && Fe(s) && e <= r && r < s;
|
|
2857
2857
|
}
|
|
2858
|
-
function
|
|
2859
|
-
if (!
|
|
2858
|
+
function Ar(r, e, s, t) {
|
|
2859
|
+
if (!Tr(e, s, t))
|
|
2860
2860
|
throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
|
|
2861
2861
|
}
|
|
2862
|
-
function
|
|
2862
|
+
function Rr(r) {
|
|
2863
2863
|
let e;
|
|
2864
|
-
for (e = 0; r >
|
|
2864
|
+
for (e = 0; r > ht; r >>= at, e += 1)
|
|
2865
2865
|
;
|
|
2866
2866
|
return e;
|
|
2867
2867
|
}
|
|
2868
|
-
const
|
|
2869
|
-
function
|
|
2870
|
-
if (
|
|
2868
|
+
const ft = (r) => (at << BigInt(r)) - at;
|
|
2869
|
+
function kr(r, e, s) {
|
|
2870
|
+
if (ge(r, "hashLen"), ge(e, "qByteLen"), typeof s != "function")
|
|
2871
2871
|
throw new Error("hmacFn must be a function");
|
|
2872
2872
|
const t = (y) => new Uint8Array(y), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
|
|
2873
2873
|
let c = t(r), l = t(r), d = 0;
|
|
2874
2874
|
const h = () => {
|
|
2875
2875
|
c.fill(1), l.fill(0), d = 0;
|
|
2876
|
-
}, m = (...y) => s(l,
|
|
2876
|
+
}, m = (...y) => s(l, ve(c, ...y)), x = (y = n) => {
|
|
2877
2877
|
l = m(o, y), c = m(), y.length !== 0 && (l = m(i, y), c = m());
|
|
2878
2878
|
}, w = () => {
|
|
2879
2879
|
if (d++ >= a)
|
|
@@ -2882,20 +2882,20 @@ function Rr(r, e, s) {
|
|
|
2882
2882
|
const S = [];
|
|
2883
2883
|
for (; y < e; ) {
|
|
2884
2884
|
c = m();
|
|
2885
|
-
const
|
|
2886
|
-
S.push(
|
|
2885
|
+
const C = c.slice();
|
|
2886
|
+
S.push(C), y += c.length;
|
|
2887
2887
|
}
|
|
2888
|
-
return
|
|
2888
|
+
return ve(...S);
|
|
2889
2889
|
};
|
|
2890
2890
|
return (y, S) => {
|
|
2891
2891
|
h(), x(y);
|
|
2892
|
-
let
|
|
2893
|
-
for (; !(
|
|
2892
|
+
let C;
|
|
2893
|
+
for (; !(C = S(w())); )
|
|
2894
2894
|
x();
|
|
2895
|
-
return h(),
|
|
2895
|
+
return h(), C;
|
|
2896
2896
|
};
|
|
2897
2897
|
}
|
|
2898
|
-
function
|
|
2898
|
+
function _t(r, e = {}, s = {}) {
|
|
2899
2899
|
if (!r || typeof r != "object")
|
|
2900
2900
|
throw new Error("expected valid options object");
|
|
2901
2901
|
function t(o, i, a) {
|
|
@@ -2909,7 +2909,7 @@ function ft(r, e = {}, s = {}) {
|
|
|
2909
2909
|
const n = (o, i) => Object.entries(o).forEach(([a, c]) => t(a, c, i));
|
|
2910
2910
|
n(e, !1), n(s, !0);
|
|
2911
2911
|
}
|
|
2912
|
-
function
|
|
2912
|
+
function Mt(r) {
|
|
2913
2913
|
const e = /* @__PURE__ */ new WeakMap();
|
|
2914
2914
|
return (s, ...t) => {
|
|
2915
2915
|
const n = e.get(s);
|
|
@@ -2920,7 +2920,7 @@ function Dt(r) {
|
|
|
2920
2920
|
};
|
|
2921
2921
|
}
|
|
2922
2922
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2923
|
-
const ne = /* @__PURE__ */ BigInt(0), ee = /* @__PURE__ */ BigInt(1),
|
|
2923
|
+
const ne = /* @__PURE__ */ BigInt(0), ee = /* @__PURE__ */ BigInt(1), Ie = /* @__PURE__ */ BigInt(2), ds = /* @__PURE__ */ BigInt(3), us = /* @__PURE__ */ BigInt(4), hs = /* @__PURE__ */ BigInt(5), Pr = /* @__PURE__ */ BigInt(7), ps = /* @__PURE__ */ BigInt(8), Nr = /* @__PURE__ */ BigInt(9), fs = /* @__PURE__ */ BigInt(16);
|
|
2924
2924
|
function le(r, e) {
|
|
2925
2925
|
const s = r % e;
|
|
2926
2926
|
return s >= ne ? s : e + s;
|
|
@@ -2931,7 +2931,7 @@ function ae(r, e, s) {
|
|
|
2931
2931
|
t *= t, t %= s;
|
|
2932
2932
|
return t;
|
|
2933
2933
|
}
|
|
2934
|
-
function
|
|
2934
|
+
function $t(r, e) {
|
|
2935
2935
|
if (r === ne)
|
|
2936
2936
|
throw new Error("invert: expected non-zero number");
|
|
2937
2937
|
if (e <= ne)
|
|
@@ -2945,47 +2945,47 @@ function Mt(r, e) {
|
|
|
2945
2945
|
throw new Error("invert: does not exist");
|
|
2946
2946
|
return le(n, e);
|
|
2947
2947
|
}
|
|
2948
|
-
function
|
|
2948
|
+
function xt(r, e, s) {
|
|
2949
2949
|
if (!r.eql(r.sqr(e), s))
|
|
2950
2950
|
throw new Error("Cannot find square root");
|
|
2951
2951
|
}
|
|
2952
|
-
function
|
|
2953
|
-
const s = (r.ORDER + ee) /
|
|
2954
|
-
return
|
|
2952
|
+
function _s(r, e) {
|
|
2953
|
+
const s = (r.ORDER + ee) / us, t = r.pow(e, s);
|
|
2954
|
+
return xt(r, t, e), t;
|
|
2955
2955
|
}
|
|
2956
|
-
function
|
|
2957
|
-
const s = (r.ORDER -
|
|
2958
|
-
return
|
|
2956
|
+
function Or(r, e) {
|
|
2957
|
+
const s = (r.ORDER - hs) / ps, t = r.mul(e, Ie), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, Ie), n), a = r.mul(o, r.sub(i, r.ONE));
|
|
2958
|
+
return xt(r, a, e), a;
|
|
2959
2959
|
}
|
|
2960
|
-
function
|
|
2961
|
-
const e =
|
|
2960
|
+
function Cr(r) {
|
|
2961
|
+
const e = je(r), s = xs(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + Pr) / fs;
|
|
2962
2962
|
return (a, c) => {
|
|
2963
2963
|
let l = a.pow(c, i), d = a.mul(l, t);
|
|
2964
2964
|
const h = a.mul(l, n), m = a.mul(l, o), x = a.eql(a.sqr(d), c), w = a.eql(a.sqr(h), c);
|
|
2965
2965
|
l = a.cmov(l, d, x), d = a.cmov(m, h, w);
|
|
2966
2966
|
const E = a.eql(a.sqr(d), c), y = a.cmov(l, d, E);
|
|
2967
|
-
return
|
|
2967
|
+
return xt(a, y, c), y;
|
|
2968
2968
|
};
|
|
2969
2969
|
}
|
|
2970
|
-
function
|
|
2971
|
-
if (r <
|
|
2970
|
+
function xs(r) {
|
|
2971
|
+
if (r < ds)
|
|
2972
2972
|
throw new Error("sqrt is not defined for small field");
|
|
2973
2973
|
let e = r - ee, s = 0;
|
|
2974
|
-
for (; e %
|
|
2975
|
-
e /=
|
|
2976
|
-
let t =
|
|
2977
|
-
const n =
|
|
2978
|
-
for (;
|
|
2974
|
+
for (; e % Ie === ne; )
|
|
2975
|
+
e /= Ie, s++;
|
|
2976
|
+
let t = Ie;
|
|
2977
|
+
const n = je(r);
|
|
2978
|
+
for (; Bt(n, t) === 1; )
|
|
2979
2979
|
if (t++ > 1e3)
|
|
2980
2980
|
throw new Error("Cannot find square root: probably non-prime P");
|
|
2981
2981
|
if (s === 1)
|
|
2982
|
-
return
|
|
2982
|
+
return _s;
|
|
2983
2983
|
let o = n.pow(t, e);
|
|
2984
|
-
const i = (e + ee) /
|
|
2984
|
+
const i = (e + ee) / Ie;
|
|
2985
2985
|
return function(c, l) {
|
|
2986
2986
|
if (c.is0(l))
|
|
2987
2987
|
return l;
|
|
2988
|
-
if (
|
|
2988
|
+
if (Bt(c, l) !== 1)
|
|
2989
2989
|
throw new Error("Cannot find square root");
|
|
2990
2990
|
let d = s, h = c.mul(c.ONE, o), m = c.pow(l, e), x = c.pow(l, i);
|
|
2991
2991
|
for (; !c.eql(m, c.ONE); ) {
|
|
@@ -3001,10 +3001,10 @@ function _s(r) {
|
|
|
3001
3001
|
return x;
|
|
3002
3002
|
};
|
|
3003
3003
|
}
|
|
3004
|
-
function
|
|
3005
|
-
return r %
|
|
3004
|
+
function Lr(r) {
|
|
3005
|
+
return r % us === ds ? _s : r % ps === hs ? Or : r % fs === Nr ? Cr(r) : xs(r);
|
|
3006
3006
|
}
|
|
3007
|
-
const
|
|
3007
|
+
const Dr = [
|
|
3008
3008
|
"create",
|
|
3009
3009
|
"isValid",
|
|
3010
3010
|
"is0",
|
|
@@ -3023,15 +3023,15 @@ const Lr = [
|
|
|
3023
3023
|
"mulN",
|
|
3024
3024
|
"sqrN"
|
|
3025
3025
|
];
|
|
3026
|
-
function
|
|
3026
|
+
function Mr(r) {
|
|
3027
3027
|
const e = {
|
|
3028
3028
|
ORDER: "bigint",
|
|
3029
3029
|
BYTES: "number",
|
|
3030
3030
|
BITS: "number"
|
|
3031
|
-
}, s =
|
|
3032
|
-
return
|
|
3031
|
+
}, s = Dr.reduce((t, n) => (t[n] = "function", t), e);
|
|
3032
|
+
return _t(r, s), r;
|
|
3033
3033
|
}
|
|
3034
|
-
function
|
|
3034
|
+
function $r(r, e, s) {
|
|
3035
3035
|
if (s < ne)
|
|
3036
3036
|
throw new Error("invalid exponent, negatives unsupported");
|
|
3037
3037
|
if (s === ne)
|
|
@@ -3043,22 +3043,22 @@ function Mr(r, e, s) {
|
|
|
3043
3043
|
s & ee && (t = r.mul(t, n)), n = r.sqr(n), s >>= ee;
|
|
3044
3044
|
return t;
|
|
3045
3045
|
}
|
|
3046
|
-
function
|
|
3046
|
+
function gs(r, e, s = !1) {
|
|
3047
3047
|
const t = new Array(e.length).fill(s ? r.ZERO : void 0), n = e.reduce((i, a, c) => r.is0(a) ? i : (t[c] = i, r.mul(i, a)), r.ONE), o = r.inv(n);
|
|
3048
3048
|
return e.reduceRight((i, a, c) => r.is0(a) ? i : (t[c] = r.mul(i, t[c]), r.mul(i, a)), o), t;
|
|
3049
3049
|
}
|
|
3050
|
-
function
|
|
3051
|
-
const s = (r.ORDER - ee) /
|
|
3050
|
+
function Bt(r, e) {
|
|
3051
|
+
const s = (r.ORDER - ee) / Ie, t = r.pow(e, s), n = r.eql(t, r.ONE), o = r.eql(t, r.ZERO), i = r.eql(t, r.neg(r.ONE));
|
|
3052
3052
|
if (!n && !o && !i)
|
|
3053
3053
|
throw new Error("invalid Legendre symbol result");
|
|
3054
3054
|
return n ? 1 : o ? 0 : -1;
|
|
3055
3055
|
}
|
|
3056
|
-
function
|
|
3057
|
-
e !== void 0 &&
|
|
3056
|
+
function Br(r, e) {
|
|
3057
|
+
e !== void 0 && ge(e);
|
|
3058
3058
|
const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
|
|
3059
3059
|
return { nBitLength: s, nByteLength: t };
|
|
3060
3060
|
}
|
|
3061
|
-
class
|
|
3061
|
+
class Ur {
|
|
3062
3062
|
constructor(e, s = {}) {
|
|
3063
3063
|
T(this, "ORDER");
|
|
3064
3064
|
T(this, "BITS");
|
|
@@ -3075,7 +3075,7 @@ class Br {
|
|
|
3075
3075
|
throw new Error("invalid field: expected ORDER > 0, got " + e);
|
|
3076
3076
|
let t;
|
|
3077
3077
|
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));
|
|
3078
|
-
const { nBitLength: n, nByteLength: o } =
|
|
3078
|
+
const { nBitLength: n, nByteLength: o } = Br(e, t);
|
|
3079
3079
|
if (o > 2048)
|
|
3080
3080
|
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
3081
3081
|
this.ORDER = e, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
|
|
@@ -3117,10 +3117,10 @@ class Br {
|
|
|
3117
3117
|
return le(e * s, this.ORDER);
|
|
3118
3118
|
}
|
|
3119
3119
|
pow(e, s) {
|
|
3120
|
-
return
|
|
3120
|
+
return $r(this, e, s);
|
|
3121
3121
|
}
|
|
3122
3122
|
div(e, s) {
|
|
3123
|
-
return le(e *
|
|
3123
|
+
return le(e * $t(s, this.ORDER), this.ORDER);
|
|
3124
3124
|
}
|
|
3125
3125
|
// Same as above, but doesn't normalize
|
|
3126
3126
|
sqrN(e) {
|
|
@@ -3136,13 +3136,13 @@ class Br {
|
|
|
3136
3136
|
return e * s;
|
|
3137
3137
|
}
|
|
3138
3138
|
inv(e) {
|
|
3139
|
-
return
|
|
3139
|
+
return $t(e, this.ORDER);
|
|
3140
3140
|
}
|
|
3141
3141
|
sqrt(e) {
|
|
3142
|
-
return this._sqrt || (this._sqrt =
|
|
3142
|
+
return this._sqrt || (this._sqrt = Lr(this.ORDER)), this._sqrt(this, e);
|
|
3143
3143
|
}
|
|
3144
3144
|
toBytes(e) {
|
|
3145
|
-
return this.isLE ?
|
|
3145
|
+
return this.isLE ? ls(e, this.BYTES) : pt(e, this.BYTES);
|
|
3146
3146
|
}
|
|
3147
3147
|
fromBytes(e, s = !1) {
|
|
3148
3148
|
V(e);
|
|
@@ -3155,14 +3155,14 @@ class Br {
|
|
|
3155
3155
|
}
|
|
3156
3156
|
if (e.length !== n)
|
|
3157
3157
|
throw new Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
|
|
3158
|
-
let c = o ?
|
|
3158
|
+
let c = o ? cs(e) : ze(e);
|
|
3159
3159
|
if (a && (c = le(c, i)), !s && !this.isValid(c))
|
|
3160
3160
|
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
3161
3161
|
return c;
|
|
3162
3162
|
}
|
|
3163
3163
|
// TODO: we don't need it here, move out to separate fn
|
|
3164
3164
|
invertBatch(e) {
|
|
3165
|
-
return
|
|
3165
|
+
return gs(this, e);
|
|
3166
3166
|
}
|
|
3167
3167
|
// We can't move this out because Fp6, Fp12 implement it
|
|
3168
3168
|
// and it's unclear what to return in there.
|
|
@@ -3170,62 +3170,62 @@ class Br {
|
|
|
3170
3170
|
return t ? s : e;
|
|
3171
3171
|
}
|
|
3172
3172
|
}
|
|
3173
|
-
function
|
|
3174
|
-
return new
|
|
3173
|
+
function je(r, e = {}) {
|
|
3174
|
+
return new Ur(r, e);
|
|
3175
3175
|
}
|
|
3176
|
-
function
|
|
3176
|
+
function ms(r) {
|
|
3177
3177
|
if (typeof r != "bigint")
|
|
3178
3178
|
throw new Error("field order must be bigint");
|
|
3179
3179
|
const e = r.toString(2).length;
|
|
3180
3180
|
return Math.ceil(e / 8);
|
|
3181
3181
|
}
|
|
3182
|
-
function
|
|
3183
|
-
const e =
|
|
3182
|
+
function ws(r) {
|
|
3183
|
+
const e = ms(r);
|
|
3184
3184
|
return e + Math.ceil(e / 2);
|
|
3185
3185
|
}
|
|
3186
|
-
function
|
|
3186
|
+
function Hr(r, e, s = !1) {
|
|
3187
3187
|
V(r);
|
|
3188
|
-
const t = r.length, n =
|
|
3188
|
+
const t = r.length, n = ms(e), o = ws(e);
|
|
3189
3189
|
if (t < 16 || t < o || t > 1024)
|
|
3190
3190
|
throw new Error("expected " + o + "-1024 bytes of input, got " + t);
|
|
3191
|
-
const i = s ?
|
|
3192
|
-
return s ?
|
|
3191
|
+
const i = s ? cs(r) : ze(r), a = le(i, e - ee) + ee;
|
|
3192
|
+
return s ? ls(a, n) : pt(a, n);
|
|
3193
3193
|
}
|
|
3194
3194
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3195
|
-
const
|
|
3196
|
-
function
|
|
3195
|
+
const Ne = /* @__PURE__ */ BigInt(0), Te = /* @__PURE__ */ BigInt(1);
|
|
3196
|
+
function Ke(r, e) {
|
|
3197
3197
|
const s = e.negate();
|
|
3198
3198
|
return r ? s : e;
|
|
3199
3199
|
}
|
|
3200
|
-
function
|
|
3201
|
-
const s =
|
|
3200
|
+
function Ut(r, e) {
|
|
3201
|
+
const s = gs(r.Fp, e.map((t) => t.Z));
|
|
3202
3202
|
return e.map((t, n) => r.fromAffine(t.toAffine(s[n])));
|
|
3203
3203
|
}
|
|
3204
|
-
function
|
|
3204
|
+
function ys(r, e) {
|
|
3205
3205
|
if (!Number.isSafeInteger(r) || r <= 0 || r > e)
|
|
3206
3206
|
throw new Error("invalid window size, expected [1.." + e + "], got W=" + r);
|
|
3207
3207
|
}
|
|
3208
|
-
function
|
|
3209
|
-
|
|
3210
|
-
const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o =
|
|
3208
|
+
function Qe(r, e) {
|
|
3209
|
+
ys(r, e);
|
|
3210
|
+
const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = ft(r), i = BigInt(r);
|
|
3211
3211
|
return { windows: s, windowSize: t, mask: o, maxNumber: n, shiftBy: i };
|
|
3212
3212
|
}
|
|
3213
|
-
function
|
|
3213
|
+
function Ht(r, e, s) {
|
|
3214
3214
|
const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
|
|
3215
3215
|
let a = Number(r & n), c = r >> i;
|
|
3216
|
-
a > t && (a -= o, c +=
|
|
3216
|
+
a > t && (a -= o, c += Te);
|
|
3217
3217
|
const l = e * t, d = l + Math.abs(a) - 1, h = a === 0, m = a < 0, x = e % 2 !== 0;
|
|
3218
3218
|
return { nextN: c, offset: d, isZero: h, isNeg: m, isNegF: x, offsetF: l };
|
|
3219
3219
|
}
|
|
3220
|
-
const
|
|
3221
|
-
function
|
|
3222
|
-
return
|
|
3220
|
+
const et = /* @__PURE__ */ new WeakMap(), bs = /* @__PURE__ */ new WeakMap();
|
|
3221
|
+
function tt(r) {
|
|
3222
|
+
return bs.get(r) || 1;
|
|
3223
3223
|
}
|
|
3224
|
-
function
|
|
3225
|
-
if (r !==
|
|
3224
|
+
function Ft(r) {
|
|
3225
|
+
if (r !== Ne)
|
|
3226
3226
|
throw new Error("invalid wNAF");
|
|
3227
3227
|
}
|
|
3228
|
-
class
|
|
3228
|
+
class Fr {
|
|
3229
3229
|
// Parametrized with a given Point class (not individual point)
|
|
3230
3230
|
constructor(e, s) {
|
|
3231
3231
|
T(this, "BASE");
|
|
@@ -3237,8 +3237,8 @@ class Hr {
|
|
|
3237
3237
|
// non-const time multiplication ladder
|
|
3238
3238
|
_unsafeLadder(e, s, t = this.ZERO) {
|
|
3239
3239
|
let n = e;
|
|
3240
|
-
for (; s >
|
|
3241
|
-
s &
|
|
3240
|
+
for (; s > Ne; )
|
|
3241
|
+
s & Te && (t = t.add(n)), n = n.double(), s >>= Te;
|
|
3242
3242
|
return t;
|
|
3243
3243
|
}
|
|
3244
3244
|
/**
|
|
@@ -3254,7 +3254,7 @@ class Hr {
|
|
|
3254
3254
|
* @returns precomputed point tables flattened to a single array
|
|
3255
3255
|
*/
|
|
3256
3256
|
precomputeWindow(e, s) {
|
|
3257
|
-
const { windows: t, windowSize: n } =
|
|
3257
|
+
const { windows: t, windowSize: n } = Qe(s, this.bits), o = [];
|
|
3258
3258
|
let i = e, a = i;
|
|
3259
3259
|
for (let c = 0; c < t; c++) {
|
|
3260
3260
|
a = i, o.push(a);
|
|
@@ -3274,12 +3274,12 @@ class Hr {
|
|
|
3274
3274
|
if (!this.Fn.isValid(t))
|
|
3275
3275
|
throw new Error("invalid scalar");
|
|
3276
3276
|
let n = this.ZERO, o = this.BASE;
|
|
3277
|
-
const i =
|
|
3277
|
+
const i = Qe(e, this.bits);
|
|
3278
3278
|
for (let a = 0; a < i.windows; a++) {
|
|
3279
|
-
const { nextN: c, offset: l, isZero: d, isNeg: h, isNegF: m, offsetF: x } =
|
|
3280
|
-
t = c, d ? o = o.add(
|
|
3279
|
+
const { nextN: c, offset: l, isZero: d, isNeg: h, isNegF: m, offsetF: x } = Ht(t, a, i);
|
|
3280
|
+
t = c, d ? o = o.add(Ke(m, s[x])) : n = n.add(Ke(h, s[l]));
|
|
3281
3281
|
}
|
|
3282
|
-
return
|
|
3282
|
+
return Ft(t), { p: n, f: o };
|
|
3283
3283
|
}
|
|
3284
3284
|
/**
|
|
3285
3285
|
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
@@ -3287,73 +3287,73 @@ class Hr {
|
|
|
3287
3287
|
* @returns point
|
|
3288
3288
|
*/
|
|
3289
3289
|
wNAFUnsafe(e, s, t, n = this.ZERO) {
|
|
3290
|
-
const o =
|
|
3291
|
-
for (let i = 0; i < o.windows && t !==
|
|
3292
|
-
const { nextN: a, offset: c, isZero: l, isNeg: d } =
|
|
3290
|
+
const o = Qe(e, this.bits);
|
|
3291
|
+
for (let i = 0; i < o.windows && t !== Ne; i++) {
|
|
3292
|
+
const { nextN: a, offset: c, isZero: l, isNeg: d } = Ht(t, i, o);
|
|
3293
3293
|
if (t = a, !l) {
|
|
3294
3294
|
const h = s[c];
|
|
3295
3295
|
n = n.add(d ? h.negate() : h);
|
|
3296
3296
|
}
|
|
3297
3297
|
}
|
|
3298
|
-
return
|
|
3298
|
+
return Ft(t), n;
|
|
3299
3299
|
}
|
|
3300
3300
|
getPrecomputes(e, s, t) {
|
|
3301
|
-
let n =
|
|
3302
|
-
return n || (n = this.precomputeWindow(s, e), e !== 1 && (typeof t == "function" && (n = t(n)),
|
|
3301
|
+
let n = et.get(s);
|
|
3302
|
+
return n || (n = this.precomputeWindow(s, e), e !== 1 && (typeof t == "function" && (n = t(n)), et.set(s, n))), n;
|
|
3303
3303
|
}
|
|
3304
3304
|
cached(e, s, t) {
|
|
3305
|
-
const n =
|
|
3305
|
+
const n = tt(e);
|
|
3306
3306
|
return this.wNAF(n, this.getPrecomputes(n, e, t), s);
|
|
3307
3307
|
}
|
|
3308
3308
|
unsafe(e, s, t, n) {
|
|
3309
|
-
const o =
|
|
3309
|
+
const o = tt(e);
|
|
3310
3310
|
return o === 1 ? this._unsafeLadder(e, s, n) : this.wNAFUnsafe(o, this.getPrecomputes(o, e, t), s, n);
|
|
3311
3311
|
}
|
|
3312
3312
|
// We calculate precomputes for elliptic curve point multiplication
|
|
3313
3313
|
// using windowed method. This specifies window size and
|
|
3314
3314
|
// stores precomputed values. Usually only base point would be precomputed.
|
|
3315
3315
|
createCache(e, s) {
|
|
3316
|
-
|
|
3316
|
+
ys(s, this.bits), bs.set(e, s), et.delete(e);
|
|
3317
3317
|
}
|
|
3318
3318
|
hasCache(e) {
|
|
3319
|
-
return
|
|
3319
|
+
return tt(e) !== 1;
|
|
3320
3320
|
}
|
|
3321
3321
|
}
|
|
3322
|
-
function
|
|
3322
|
+
function Gr(r, e, s, t) {
|
|
3323
3323
|
let n = e, o = r.ZERO, i = r.ZERO;
|
|
3324
|
-
for (; s >
|
|
3325
|
-
s &
|
|
3324
|
+
for (; s > Ne || t > Ne; )
|
|
3325
|
+
s & Te && (o = o.add(n)), t & Te && (i = i.add(n)), n = n.double(), s >>= Te, t >>= Te;
|
|
3326
3326
|
return { p1: o, p2: i };
|
|
3327
3327
|
}
|
|
3328
|
-
function
|
|
3328
|
+
function Gt(r, e, s) {
|
|
3329
3329
|
if (e) {
|
|
3330
3330
|
if (e.ORDER !== r)
|
|
3331
3331
|
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
3332
|
-
return
|
|
3332
|
+
return Mr(e), e;
|
|
3333
3333
|
} else
|
|
3334
|
-
return
|
|
3334
|
+
return je(r, { isLE: s });
|
|
3335
3335
|
}
|
|
3336
|
-
function
|
|
3336
|
+
function Wr(r, e, s = {}, t) {
|
|
3337
3337
|
if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
|
|
3338
3338
|
throw new Error(`expected valid ${r} CURVE object`);
|
|
3339
3339
|
for (const c of ["p", "n", "h"]) {
|
|
3340
3340
|
const l = e[c];
|
|
3341
|
-
if (!(typeof l == "bigint" && l >
|
|
3341
|
+
if (!(typeof l == "bigint" && l > Ne))
|
|
3342
3342
|
throw new Error(`CURVE.${c} must be positive bigint`);
|
|
3343
3343
|
}
|
|
3344
|
-
const n =
|
|
3344
|
+
const n = Gt(e.p, s.Fp, t), o = Gt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
|
|
3345
3345
|
for (const c of a)
|
|
3346
3346
|
if (!n.isValid(e[c]))
|
|
3347
3347
|
throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
|
|
3348
3348
|
return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: n, Fn: o };
|
|
3349
3349
|
}
|
|
3350
|
-
function
|
|
3350
|
+
function qr(r, e) {
|
|
3351
3351
|
return function(t) {
|
|
3352
3352
|
const n = r(t);
|
|
3353
3353
|
return { secretKey: n, publicKey: e(n) };
|
|
3354
3354
|
};
|
|
3355
3355
|
}
|
|
3356
|
-
class
|
|
3356
|
+
class vs {
|
|
3357
3357
|
constructor(e, s) {
|
|
3358
3358
|
T(this, "oHash");
|
|
3359
3359
|
T(this, "iHash");
|
|
@@ -3361,7 +3361,7 @@ class bs {
|
|
|
3361
3361
|
T(this, "outputLen");
|
|
3362
3362
|
T(this, "finished", !1);
|
|
3363
3363
|
T(this, "destroyed", !1);
|
|
3364
|
-
if (
|
|
3364
|
+
if (ts(e), V(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
|
|
3365
3365
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
3366
3366
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
3367
3367
|
const t = this.blockLen, n = new Uint8Array(t);
|
|
@@ -3371,13 +3371,13 @@ class bs {
|
|
|
3371
3371
|
this.iHash.update(n), this.oHash = e.create();
|
|
3372
3372
|
for (let o = 0; o < n.length; o++)
|
|
3373
3373
|
n[o] ^= 106;
|
|
3374
|
-
this.oHash.update(n),
|
|
3374
|
+
this.oHash.update(n), Pe(n);
|
|
3375
3375
|
}
|
|
3376
3376
|
update(e) {
|
|
3377
|
-
return
|
|
3377
|
+
return ke(this), this.iHash.update(e), this;
|
|
3378
3378
|
}
|
|
3379
3379
|
digestInto(e) {
|
|
3380
|
-
|
|
3380
|
+
ke(this), V(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
|
|
3381
3381
|
}
|
|
3382
3382
|
digest() {
|
|
3383
3383
|
const e = new Uint8Array(this.oHash.outputLen);
|
|
@@ -3395,56 +3395,56 @@ class bs {
|
|
|
3395
3395
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
3396
3396
|
}
|
|
3397
3397
|
}
|
|
3398
|
-
const
|
|
3399
|
-
|
|
3398
|
+
const Ss = (r, e, s) => new vs(r, e).update(s).digest();
|
|
3399
|
+
Ss.create = (r, e) => new vs(r, e);
|
|
3400
3400
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3401
|
-
const
|
|
3402
|
-
function
|
|
3403
|
-
const [[t, n], [o, i]] = e, a =
|
|
3401
|
+
const Wt = (r, e) => (r + (r >= 0 ? e : -e) / Es) / e;
|
|
3402
|
+
function Kr(r, e, s) {
|
|
3403
|
+
const [[t, n], [o, i]] = e, a = Wt(i * r, s), c = Wt(-n * r, s);
|
|
3404
3404
|
let l = r - a * t - c * o, d = -a * n - c * i;
|
|
3405
|
-
const h = l <
|
|
3405
|
+
const h = l < _e, m = d < _e;
|
|
3406
3406
|
h && (l = -l), m && (d = -d);
|
|
3407
|
-
const x =
|
|
3408
|
-
if (l <
|
|
3407
|
+
const x = ft(Math.ceil(Rr(s) / 2)) + Re;
|
|
3408
|
+
if (l < _e || l >= x || d < _e || d >= x)
|
|
3409
3409
|
throw new Error("splitScalar (endomorphism): failed, k=" + r);
|
|
3410
3410
|
return { k1neg: h, k1: l, k2neg: m, k2: d };
|
|
3411
3411
|
}
|
|
3412
|
-
function
|
|
3412
|
+
function ct(r) {
|
|
3413
3413
|
if (!["compact", "recovered", "der"].includes(r))
|
|
3414
3414
|
throw new Error('Signature format must be "compact", "recovered", or "der"');
|
|
3415
3415
|
return r;
|
|
3416
3416
|
}
|
|
3417
|
-
function
|
|
3417
|
+
function st(r, e) {
|
|
3418
3418
|
const s = {};
|
|
3419
3419
|
for (let t of Object.keys(e))
|
|
3420
3420
|
s[t] = r[t] === void 0 ? e[t] : r[t];
|
|
3421
|
-
return
|
|
3421
|
+
return qe(s.lowS, "lowS"), qe(s.prehash, "prehash"), s.format !== void 0 && ct(s.format), s;
|
|
3422
3422
|
}
|
|
3423
|
-
class
|
|
3423
|
+
class Vr extends Error {
|
|
3424
3424
|
constructor(e = "") {
|
|
3425
3425
|
super(e);
|
|
3426
3426
|
}
|
|
3427
3427
|
}
|
|
3428
|
-
const
|
|
3428
|
+
const ye = {
|
|
3429
3429
|
// asn.1 DER encoding utils
|
|
3430
|
-
Err:
|
|
3430
|
+
Err: Vr,
|
|
3431
3431
|
// Basic building block is TLV (Tag-Length-Value)
|
|
3432
3432
|
_tlv: {
|
|
3433
3433
|
encode: (r, e) => {
|
|
3434
|
-
const { Err: s } =
|
|
3434
|
+
const { Err: s } = ye;
|
|
3435
3435
|
if (r < 0 || r > 256)
|
|
3436
3436
|
throw new s("tlv.encode: wrong tag");
|
|
3437
3437
|
if (e.length & 1)
|
|
3438
3438
|
throw new s("tlv.encode: unpadded data");
|
|
3439
|
-
const t = e.length / 2, n =
|
|
3439
|
+
const t = e.length / 2, n = Ue(t);
|
|
3440
3440
|
if (n.length / 2 & 128)
|
|
3441
3441
|
throw new s("tlv.encode: long form length too big");
|
|
3442
|
-
const o = t > 127 ?
|
|
3443
|
-
return
|
|
3442
|
+
const o = t > 127 ? Ue(n.length / 2 | 128) : "";
|
|
3443
|
+
return Ue(r) + o + n + e;
|
|
3444
3444
|
},
|
|
3445
3445
|
// v - value, l - left bytes (unparsed)
|
|
3446
3446
|
decode(r, e) {
|
|
3447
|
-
const { Err: s } =
|
|
3447
|
+
const { Err: s } = ye;
|
|
3448
3448
|
let t = 0;
|
|
3449
3449
|
if (r < 0 || r > 256)
|
|
3450
3450
|
throw new s("tlv.encode: wrong tag");
|
|
@@ -3482,25 +3482,25 @@ const we = {
|
|
|
3482
3482
|
// - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
|
|
3483
3483
|
_int: {
|
|
3484
3484
|
encode(r) {
|
|
3485
|
-
const { Err: e } =
|
|
3486
|
-
if (r <
|
|
3485
|
+
const { Err: e } = ye;
|
|
3486
|
+
if (r < _e)
|
|
3487
3487
|
throw new e("integer: negative integers are not allowed");
|
|
3488
|
-
let s =
|
|
3488
|
+
let s = Ue(r);
|
|
3489
3489
|
if (Number.parseInt(s[0], 16) & 8 && (s = "00" + s), s.length & 1)
|
|
3490
3490
|
throw new e("unexpected DER parsing assertion: unpadded hex");
|
|
3491
3491
|
return s;
|
|
3492
3492
|
},
|
|
3493
3493
|
decode(r) {
|
|
3494
|
-
const { Err: e } =
|
|
3494
|
+
const { Err: e } = ye;
|
|
3495
3495
|
if (r[0] & 128)
|
|
3496
3496
|
throw new e("invalid signature integer: negative");
|
|
3497
3497
|
if (r[0] === 0 && !(r[1] & 128))
|
|
3498
3498
|
throw new e("invalid signature integer: unnecessary leading zero");
|
|
3499
|
-
return
|
|
3499
|
+
return ze(r);
|
|
3500
3500
|
}
|
|
3501
3501
|
},
|
|
3502
3502
|
toSig(r) {
|
|
3503
|
-
const { Err: e, _int: s, _tlv: t } =
|
|
3503
|
+
const { Err: e, _int: s, _tlv: t } = ye, n = V(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
|
|
3504
3504
|
if (i.length)
|
|
3505
3505
|
throw new e("invalid signature: left bytes after parsing");
|
|
3506
3506
|
const { v: a, l: c } = t.decode(2, o), { v: l, l: d } = t.decode(2, c);
|
|
@@ -3509,15 +3509,15 @@ const we = {
|
|
|
3509
3509
|
return { r: s.decode(a), s: s.decode(l) };
|
|
3510
3510
|
},
|
|
3511
3511
|
hexFromSig(r) {
|
|
3512
|
-
const { _tlv: e, _int: s } =
|
|
3512
|
+
const { _tlv: e, _int: s } = ye, t = e.encode(2, s.encode(r.r)), n = e.encode(2, s.encode(r.s)), o = t + n;
|
|
3513
3513
|
return e.encode(48, o);
|
|
3514
3514
|
}
|
|
3515
|
-
},
|
|
3516
|
-
function
|
|
3517
|
-
const s =
|
|
3515
|
+
}, _e = BigInt(0), Re = BigInt(1), Es = BigInt(2), He = BigInt(3), zr = BigInt(4);
|
|
3516
|
+
function jr(r, e = {}) {
|
|
3517
|
+
const s = Wr("weierstrass", r, e), { Fp: t, Fn: n } = s;
|
|
3518
3518
|
let o = s.CURVE;
|
|
3519
3519
|
const { h: i, n: a } = o;
|
|
3520
|
-
|
|
3520
|
+
_t(e, {}, {
|
|
3521
3521
|
allowInfinityPoint: "boolean",
|
|
3522
3522
|
clearCofactor: "function",
|
|
3523
3523
|
isTorsionFree: "function",
|
|
@@ -3528,28 +3528,28 @@ function zr(r, e = {}) {
|
|
|
3528
3528
|
const { endo: c } = e;
|
|
3529
3529
|
if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
|
|
3530
3530
|
throw new Error('invalid endo: expected "beta": bigint and "basises": array');
|
|
3531
|
-
const l =
|
|
3531
|
+
const l = Ts(t, n);
|
|
3532
3532
|
function d() {
|
|
3533
3533
|
if (!t.isOdd)
|
|
3534
3534
|
throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
3535
3535
|
}
|
|
3536
|
-
function h(
|
|
3536
|
+
function h(N, f, _) {
|
|
3537
3537
|
const { x: v, y: I } = f.toAffine(), L = t.toBytes(v);
|
|
3538
|
-
if (
|
|
3538
|
+
if (qe(_, "isCompressed"), _) {
|
|
3539
3539
|
d();
|
|
3540
|
-
const
|
|
3541
|
-
return
|
|
3540
|
+
const O = !t.isOdd(I);
|
|
3541
|
+
return ve(Is(O), L);
|
|
3542
3542
|
} else
|
|
3543
|
-
return
|
|
3543
|
+
return ve(Uint8Array.of(4), L, t.toBytes(I));
|
|
3544
3544
|
}
|
|
3545
|
-
function m(
|
|
3546
|
-
V(
|
|
3547
|
-
const { publicKey: f, publicKeyUncompressed: _ } = l, v =
|
|
3545
|
+
function m(N) {
|
|
3546
|
+
V(N, void 0, "Point");
|
|
3547
|
+
const { publicKey: f, publicKeyUncompressed: _ } = l, v = N.length, I = N[0], L = N.subarray(1);
|
|
3548
3548
|
if (v === f && (I === 2 || I === 3)) {
|
|
3549
|
-
const
|
|
3550
|
-
if (!t.isValid(
|
|
3549
|
+
const O = t.fromBytes(L);
|
|
3550
|
+
if (!t.isValid(O))
|
|
3551
3551
|
throw new Error("bad point: is not on curve, wrong x");
|
|
3552
|
-
const M = E(
|
|
3552
|
+
const M = E(O);
|
|
3553
3553
|
let A;
|
|
3554
3554
|
try {
|
|
3555
3555
|
A = t.sqrt(M);
|
|
@@ -3559,9 +3559,9 @@ function zr(r, e = {}) {
|
|
|
3559
3559
|
}
|
|
3560
3560
|
d();
|
|
3561
3561
|
const $ = t.isOdd(A);
|
|
3562
|
-
return (I & 1) === 1 !== $ && (A = t.neg(A)), { x:
|
|
3562
|
+
return (I & 1) === 1 !== $ && (A = t.neg(A)), { x: O, y: A };
|
|
3563
3563
|
} else if (v === _ && I === 4) {
|
|
3564
|
-
const
|
|
3564
|
+
const O = t.BYTES, M = t.fromBytes(L.subarray(0, O)), A = t.fromBytes(L.subarray(O, O * 2));
|
|
3565
3565
|
if (!y(M, A))
|
|
3566
3566
|
throw new Error("bad point: is not on curve");
|
|
3567
3567
|
return { x: M, y: A };
|
|
@@ -3569,62 +3569,62 @@ function zr(r, e = {}) {
|
|
|
3569
3569
|
throw new Error(`bad point: got length ${v}, expected compressed=${f} or uncompressed=${_}`);
|
|
3570
3570
|
}
|
|
3571
3571
|
const x = e.toBytes || h, w = e.fromBytes || m;
|
|
3572
|
-
function E(
|
|
3573
|
-
const f = t.sqr(
|
|
3574
|
-
return t.add(t.add(_, t.mul(
|
|
3572
|
+
function E(N) {
|
|
3573
|
+
const f = t.sqr(N), _ = t.mul(f, N);
|
|
3574
|
+
return t.add(t.add(_, t.mul(N, o.a)), o.b);
|
|
3575
3575
|
}
|
|
3576
|
-
function y(
|
|
3577
|
-
const _ = t.sqr(f), v = E(
|
|
3576
|
+
function y(N, f) {
|
|
3577
|
+
const _ = t.sqr(f), v = E(N);
|
|
3578
3578
|
return t.eql(_, v);
|
|
3579
3579
|
}
|
|
3580
3580
|
if (!y(o.Gx, o.Gy))
|
|
3581
3581
|
throw new Error("bad curve params: generator point");
|
|
3582
|
-
const S = t.mul(t.pow(o.a,
|
|
3583
|
-
if (t.is0(t.add(S,
|
|
3582
|
+
const S = t.mul(t.pow(o.a, He), zr), C = t.mul(t.sqr(o.b), BigInt(27));
|
|
3583
|
+
if (t.is0(t.add(S, C)))
|
|
3584
3584
|
throw new Error("bad curve params: a or b");
|
|
3585
|
-
function B(
|
|
3585
|
+
function B(N, f, _ = !1) {
|
|
3586
3586
|
if (!t.isValid(f) || _ && t.is0(f))
|
|
3587
|
-
throw new Error(`bad point coordinate ${
|
|
3587
|
+
throw new Error(`bad point coordinate ${N}`);
|
|
3588
3588
|
return f;
|
|
3589
3589
|
}
|
|
3590
|
-
function b(
|
|
3591
|
-
if (!(
|
|
3590
|
+
function b(N) {
|
|
3591
|
+
if (!(N instanceof W))
|
|
3592
3592
|
throw new Error("Weierstrass Point expected");
|
|
3593
3593
|
}
|
|
3594
|
-
function k(
|
|
3594
|
+
function k(N) {
|
|
3595
3595
|
if (!c || !c.basises)
|
|
3596
3596
|
throw new Error("no endo");
|
|
3597
|
-
return
|
|
3597
|
+
return Kr(N, c.basises, n.ORDER);
|
|
3598
3598
|
}
|
|
3599
|
-
const P =
|
|
3600
|
-
const { X: _, Y: v, Z: I } =
|
|
3599
|
+
const P = Mt((N, f) => {
|
|
3600
|
+
const { X: _, Y: v, Z: I } = N;
|
|
3601
3601
|
if (t.eql(I, t.ONE))
|
|
3602
3602
|
return { x: _, y: v };
|
|
3603
|
-
const L =
|
|
3603
|
+
const L = N.is0();
|
|
3604
3604
|
f == null && (f = L ? t.ONE : t.inv(I));
|
|
3605
|
-
const
|
|
3605
|
+
const O = t.mul(_, f), M = t.mul(v, f), A = t.mul(I, f);
|
|
3606
3606
|
if (L)
|
|
3607
3607
|
return { x: t.ZERO, y: t.ZERO };
|
|
3608
3608
|
if (!t.eql(A, t.ONE))
|
|
3609
3609
|
throw new Error("invZ was invalid");
|
|
3610
|
-
return { x:
|
|
3611
|
-
}), G =
|
|
3612
|
-
if (
|
|
3613
|
-
if (e.allowInfinityPoint && !t.is0(
|
|
3610
|
+
return { x: O, y: M };
|
|
3611
|
+
}), G = Mt((N) => {
|
|
3612
|
+
if (N.is0()) {
|
|
3613
|
+
if (e.allowInfinityPoint && !t.is0(N.Y))
|
|
3614
3614
|
return;
|
|
3615
3615
|
throw new Error("bad point: ZERO");
|
|
3616
3616
|
}
|
|
3617
|
-
const { x: f, y: _ } =
|
|
3617
|
+
const { x: f, y: _ } = N.toAffine();
|
|
3618
3618
|
if (!t.isValid(f) || !t.isValid(_))
|
|
3619
3619
|
throw new Error("bad point: x or y not field elements");
|
|
3620
3620
|
if (!y(f, _))
|
|
3621
3621
|
throw new Error("bad point: equation left != right");
|
|
3622
|
-
if (!
|
|
3622
|
+
if (!N.isTorsionFree())
|
|
3623
3623
|
throw new Error("bad point: not in prime-order subgroup");
|
|
3624
3624
|
return !0;
|
|
3625
3625
|
});
|
|
3626
|
-
function z(
|
|
3627
|
-
return _ = new W(t.mul(_.X,
|
|
3626
|
+
function z(N, f, _, v, I) {
|
|
3627
|
+
return _ = new W(t.mul(_.X, N), _.Y, _.Z), f = Ke(v, f), _ = Ke(I, _), f.add(_);
|
|
3628
3628
|
}
|
|
3629
3629
|
const R = class R {
|
|
3630
3630
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
@@ -3651,7 +3651,7 @@ function zr(r, e = {}) {
|
|
|
3651
3651
|
return _.assertValidity(), _;
|
|
3652
3652
|
}
|
|
3653
3653
|
static fromHex(f) {
|
|
3654
|
-
return R.fromBytes(
|
|
3654
|
+
return R.fromBytes(We(f));
|
|
3655
3655
|
}
|
|
3656
3656
|
get x() {
|
|
3657
3657
|
return this.toAffine().x;
|
|
@@ -3666,7 +3666,7 @@ function zr(r, e = {}) {
|
|
|
3666
3666
|
* @returns
|
|
3667
3667
|
*/
|
|
3668
3668
|
precompute(f = 8, _ = !0) {
|
|
3669
|
-
return D.createCache(this, f), _ || this.multiply(
|
|
3669
|
+
return D.createCache(this, f), _ || this.multiply(He), this;
|
|
3670
3670
|
}
|
|
3671
3671
|
// TODO: return `this`
|
|
3672
3672
|
/** A point on curve is valid if it conforms to equation. */
|
|
@@ -3682,7 +3682,7 @@ function zr(r, e = {}) {
|
|
|
3682
3682
|
/** Compare one point to another. */
|
|
3683
3683
|
equals(f) {
|
|
3684
3684
|
b(f);
|
|
3685
|
-
const { X: _, Y: v, Z: I } = this, { X: L, Y:
|
|
3685
|
+
const { X: _, Y: v, Z: I } = this, { X: L, Y: O, Z: M } = f, A = t.eql(t.mul(_, M), t.mul(L, I)), $ = t.eql(t.mul(v, M), t.mul(O, I));
|
|
3686
3686
|
return A && $;
|
|
3687
3687
|
}
|
|
3688
3688
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
@@ -3694,9 +3694,9 @@ function zr(r, e = {}) {
|
|
|
3694
3694
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
3695
3695
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
3696
3696
|
double() {
|
|
3697
|
-
const { a: f, b: _ } = o, v = t.mul(_,
|
|
3698
|
-
let M = t.ZERO, A = t.ZERO, $ = t.ZERO, F = t.mul(I, I), J = t.mul(L, L), K = t.mul(
|
|
3699
|
-
return H = t.add(H, H), $ = t.mul(I,
|
|
3697
|
+
const { a: f, b: _ } = o, v = t.mul(_, He), { X: I, Y: L, Z: O } = this;
|
|
3698
|
+
let M = t.ZERO, A = t.ZERO, $ = t.ZERO, F = t.mul(I, I), J = t.mul(L, L), K = t.mul(O, O), H = t.mul(I, L);
|
|
3699
|
+
return H = t.add(H, H), $ = t.mul(I, O), $ = t.add($, $), M = t.mul(f, $), A = t.mul(v, K), A = t.add(M, A), M = t.sub(J, A), A = t.add(J, A), A = t.mul(M, A), M = t.mul(H, M), $ = t.mul(v, $), K = t.mul(f, K), H = t.sub(F, K), H = t.mul(f, H), H = t.add(H, $), $ = t.add(F, F), F = t.add($, F), F = t.add(F, K), F = t.mul(F, H), A = t.add(A, F), K = t.mul(L, O), K = t.add(K, K), F = t.mul(K, H), M = t.sub(M, F), $ = t.mul(K, J), $ = t.add($, $), $ = t.add($, $), new R(M, A, $);
|
|
3700
3700
|
}
|
|
3701
3701
|
// Renes-Costello-Batina exception-free addition formula.
|
|
3702
3702
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
@@ -3704,13 +3704,13 @@ function zr(r, e = {}) {
|
|
|
3704
3704
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
3705
3705
|
add(f) {
|
|
3706
3706
|
b(f);
|
|
3707
|
-
const { X: _, Y: v, Z: I } = this, { X: L, Y:
|
|
3707
|
+
const { X: _, Y: v, Z: I } = this, { X: L, Y: O, Z: M } = f;
|
|
3708
3708
|
let A = t.ZERO, $ = t.ZERO, F = t.ZERO;
|
|
3709
|
-
const J = o.a, K = t.mul(o.b,
|
|
3710
|
-
let H = t.mul(_, L), Z = t.mul(v,
|
|
3709
|
+
const J = o.a, K = t.mul(o.b, He);
|
|
3710
|
+
let H = t.mul(_, L), Z = t.mul(v, O), X = t.mul(I, M), oe = t.add(_, v), j = t.add(L, O);
|
|
3711
3711
|
oe = t.mul(oe, j), j = t.add(H, Z), oe = t.sub(oe, j), j = t.add(_, I);
|
|
3712
3712
|
let Q = t.add(L, M);
|
|
3713
|
-
return j = t.mul(j, Q), Q = t.add(H, X), j = t.sub(j, Q), Q = t.add(v, I), A = t.add(
|
|
3713
|
+
return j = t.mul(j, Q), Q = t.add(H, X), j = t.sub(j, Q), Q = t.add(v, I), A = t.add(O, M), Q = t.mul(Q, A), A = t.add(Z, X), Q = t.sub(Q, A), F = t.mul(J, j), A = t.mul(K, X), F = t.add(A, F), A = t.sub(Z, F), F = t.add(Z, F), $ = t.mul(A, F), Z = t.add(H, H), Z = t.add(Z, H), X = t.mul(J, X), j = t.mul(K, j), Z = t.add(Z, X), X = t.sub(H, X), X = t.mul(J, X), j = t.add(j, X), H = t.mul(Z, j), $ = t.add($, H), H = t.mul(Q, j), A = t.mul(oe, A), A = t.sub(A, H), H = t.mul(oe, Z), F = t.mul(Q, F), F = t.add(F, H), new R(A, $, F);
|
|
3714
3714
|
}
|
|
3715
3715
|
subtract(f) {
|
|
3716
3716
|
return this.add(f.negate());
|
|
@@ -3732,15 +3732,15 @@ function zr(r, e = {}) {
|
|
|
3732
3732
|
if (!n.isValidNot0(f))
|
|
3733
3733
|
throw new Error("invalid scalar: out of range");
|
|
3734
3734
|
let v, I;
|
|
3735
|
-
const L = (
|
|
3735
|
+
const L = (O) => D.cached(this, O, (M) => Ut(R, M));
|
|
3736
3736
|
if (_) {
|
|
3737
|
-
const { k1neg:
|
|
3738
|
-
I = J.add(H), v = z(_.beta, F, K,
|
|
3737
|
+
const { k1neg: O, k1: M, k2neg: A, k2: $ } = k(f), { p: F, f: J } = L(M), { p: K, f: H } = L($);
|
|
3738
|
+
I = J.add(H), v = z(_.beta, F, K, O, A);
|
|
3739
3739
|
} else {
|
|
3740
|
-
const { p:
|
|
3741
|
-
v =
|
|
3740
|
+
const { p: O, f: M } = L(f);
|
|
3741
|
+
v = O, I = M;
|
|
3742
3742
|
}
|
|
3743
|
-
return
|
|
3743
|
+
return Ut(R, [v, I])[0];
|
|
3744
3744
|
}
|
|
3745
3745
|
/**
|
|
3746
3746
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -3751,15 +3751,15 @@ function zr(r, e = {}) {
|
|
|
3751
3751
|
const { endo: _ } = e, v = this;
|
|
3752
3752
|
if (!n.isValid(f))
|
|
3753
3753
|
throw new Error("invalid scalar: out of range");
|
|
3754
|
-
if (f ===
|
|
3754
|
+
if (f === _e || v.is0())
|
|
3755
3755
|
return R.ZERO;
|
|
3756
|
-
if (f ===
|
|
3756
|
+
if (f === Re)
|
|
3757
3757
|
return v;
|
|
3758
3758
|
if (D.hasCache(this))
|
|
3759
3759
|
return this.multiply(f);
|
|
3760
3760
|
if (_) {
|
|
3761
|
-
const { k1neg: I, k1: L, k2neg:
|
|
3762
|
-
return z(_.beta, A, $, I,
|
|
3761
|
+
const { k1neg: I, k1: L, k2neg: O, k2: M } = k(f), { p1: A, p2: $ } = Gr(R, v, L, M);
|
|
3762
|
+
return z(_.beta, A, $, I, O);
|
|
3763
3763
|
} else
|
|
3764
3764
|
return D.unsafe(v, f);
|
|
3765
3765
|
}
|
|
@@ -3776,20 +3776,20 @@ function zr(r, e = {}) {
|
|
|
3776
3776
|
*/
|
|
3777
3777
|
isTorsionFree() {
|
|
3778
3778
|
const { isTorsionFree: f } = e;
|
|
3779
|
-
return i ===
|
|
3779
|
+
return i === Re ? !0 : f ? f(R, this) : D.unsafe(this, a).is0();
|
|
3780
3780
|
}
|
|
3781
3781
|
clearCofactor() {
|
|
3782
3782
|
const { clearCofactor: f } = e;
|
|
3783
|
-
return i ===
|
|
3783
|
+
return i === Re ? this : f ? f(R, this) : this.multiplyUnsafe(i);
|
|
3784
3784
|
}
|
|
3785
3785
|
isSmallOrder() {
|
|
3786
3786
|
return this.multiplyUnsafe(i).is0();
|
|
3787
3787
|
}
|
|
3788
3788
|
toBytes(f = !0) {
|
|
3789
|
-
return
|
|
3789
|
+
return qe(f, "isCompressed"), this.assertValidity(), x(R, this, f);
|
|
3790
3790
|
}
|
|
3791
3791
|
toHex(f = !0) {
|
|
3792
|
-
return
|
|
3792
|
+
return Me(this.toBytes(f));
|
|
3793
3793
|
}
|
|
3794
3794
|
toString() {
|
|
3795
3795
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
@@ -3802,13 +3802,13 @@ function zr(r, e = {}) {
|
|
|
3802
3802
|
T(R, "Fp", t), // scalar field
|
|
3803
3803
|
T(R, "Fn", n);
|
|
3804
3804
|
let W = R;
|
|
3805
|
-
const q = n.BITS, D = new
|
|
3805
|
+
const q = n.BITS, D = new Fr(W, e.endo ? Math.ceil(q / 2) : q);
|
|
3806
3806
|
return W.BASE.precompute(8), W;
|
|
3807
3807
|
}
|
|
3808
|
-
function
|
|
3808
|
+
function Is(r) {
|
|
3809
3809
|
return Uint8Array.of(r ? 2 : 3);
|
|
3810
3810
|
}
|
|
3811
|
-
function
|
|
3811
|
+
function Ts(r, e) {
|
|
3812
3812
|
return {
|
|
3813
3813
|
secretKey: e.BYTES,
|
|
3814
3814
|
publicKey: 1 + r.BYTES,
|
|
@@ -3817,8 +3817,8 @@ function Is(r, e) {
|
|
|
3817
3817
|
signature: 2 * e.BYTES
|
|
3818
3818
|
};
|
|
3819
3819
|
}
|
|
3820
|
-
function
|
|
3821
|
-
const { Fn: s } = r, t = e.randomBytes ||
|
|
3820
|
+
function Yr(r, e = {}) {
|
|
3821
|
+
const { Fn: s } = r, t = e.randomBytes || os, n = Object.assign(Ts(r.Fp, s), { seed: ws(s.ORDER) });
|
|
3822
3822
|
function o(x) {
|
|
3823
3823
|
try {
|
|
3824
3824
|
const w = s.fromBytes(x);
|
|
@@ -3837,14 +3837,14 @@ function jr(r, e = {}) {
|
|
|
3837
3837
|
}
|
|
3838
3838
|
}
|
|
3839
3839
|
function a(x = t(n.seed)) {
|
|
3840
|
-
return
|
|
3840
|
+
return Hr(V(x, n.seed, "seed"), s.ORDER);
|
|
3841
3841
|
}
|
|
3842
3842
|
function c(x, w = !0) {
|
|
3843
3843
|
return r.BASE.multiply(s.fromBytes(x)).toBytes(w);
|
|
3844
3844
|
}
|
|
3845
3845
|
function l(x) {
|
|
3846
3846
|
const { secretKey: w, publicKey: E, publicKeyUncompressed: y } = n;
|
|
3847
|
-
if (!
|
|
3847
|
+
if (!ut(x) || "_lengths" in s && s._lengths || w === E)
|
|
3848
3848
|
return;
|
|
3849
3849
|
const S = V(x, void 0, "key").length;
|
|
3850
3850
|
return S === E || S === y;
|
|
@@ -3861,25 +3861,25 @@ function jr(r, e = {}) {
|
|
|
3861
3861
|
isValidSecretKey: o,
|
|
3862
3862
|
isValidPublicKey: i,
|
|
3863
3863
|
randomSecretKey: a
|
|
3864
|
-
}, m =
|
|
3864
|
+
}, m = qr(a, c);
|
|
3865
3865
|
return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: m, Point: r, utils: h, lengths: n });
|
|
3866
3866
|
}
|
|
3867
|
-
function
|
|
3868
|
-
|
|
3867
|
+
function Jr(r, e, s = {}) {
|
|
3868
|
+
ts(e), _t(s, {}, {
|
|
3869
3869
|
hmac: "function",
|
|
3870
3870
|
lowS: "boolean",
|
|
3871
3871
|
randomBytes: "function",
|
|
3872
3872
|
bits2int: "function",
|
|
3873
3873
|
bits2int_modN: "function"
|
|
3874
3874
|
}), s = Object.assign({}, s);
|
|
3875
|
-
const t = s.randomBytes ||
|
|
3875
|
+
const t = s.randomBytes || os, n = s.hmac || ((f, _) => Ss(e, f, _)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: d, getSharedSecret: h, utils: m, lengths: x } = Yr(r, s), w = {
|
|
3876
3876
|
prehash: !0,
|
|
3877
3877
|
lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
|
|
3878
3878
|
format: "compact",
|
|
3879
3879
|
extraEntropy: !1
|
|
3880
|
-
}, E = a *
|
|
3880
|
+
}, E = a * Es < o.ORDER;
|
|
3881
3881
|
function y(f) {
|
|
3882
|
-
const _ = a >>
|
|
3882
|
+
const _ = a >> Re;
|
|
3883
3883
|
return f > _;
|
|
3884
3884
|
}
|
|
3885
3885
|
function S(f, _) {
|
|
@@ -3887,12 +3887,12 @@ function Yr(r, e, s = {}) {
|
|
|
3887
3887
|
throw new Error(`invalid signature ${f}: out of range 1..Point.Fn.ORDER`);
|
|
3888
3888
|
return _;
|
|
3889
3889
|
}
|
|
3890
|
-
function
|
|
3890
|
+
function C() {
|
|
3891
3891
|
if (E)
|
|
3892
3892
|
throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
3893
3893
|
}
|
|
3894
3894
|
function B(f, _) {
|
|
3895
|
-
|
|
3895
|
+
ct(_);
|
|
3896
3896
|
const v = x.signature, I = _ === "compact" ? v : _ === "recovered" ? v + 1 : void 0;
|
|
3897
3897
|
return V(f, I);
|
|
3898
3898
|
}
|
|
@@ -3902,7 +3902,7 @@ function Yr(r, e, s = {}) {
|
|
|
3902
3902
|
T(this, "s");
|
|
3903
3903
|
T(this, "recovery");
|
|
3904
3904
|
if (this.r = S("r", _), this.s = S("s", v), I != null) {
|
|
3905
|
-
if (
|
|
3905
|
+
if (C(), ![0, 1, 2, 3].includes(I))
|
|
3906
3906
|
throw new Error("invalid recovery id");
|
|
3907
3907
|
this.recovery = I;
|
|
3908
3908
|
}
|
|
@@ -3912,15 +3912,15 @@ function Yr(r, e, s = {}) {
|
|
|
3912
3912
|
B(_, v);
|
|
3913
3913
|
let I;
|
|
3914
3914
|
if (v === "der") {
|
|
3915
|
-
const { r: A, s: $ } =
|
|
3915
|
+
const { r: A, s: $ } = ye.toSig(V(_));
|
|
3916
3916
|
return new b(A, $);
|
|
3917
3917
|
}
|
|
3918
3918
|
v === "recovered" && (I = _[0], v = "compact", _ = _.subarray(1));
|
|
3919
|
-
const L = x.signature / 2,
|
|
3920
|
-
return new b(i.fromBytes(
|
|
3919
|
+
const L = x.signature / 2, O = _.subarray(0, L), M = _.subarray(L, L * 2);
|
|
3920
|
+
return new b(i.fromBytes(O), i.fromBytes(M), I);
|
|
3921
3921
|
}
|
|
3922
3922
|
static fromHex(_, v) {
|
|
3923
|
-
return this.fromBytes(
|
|
3923
|
+
return this.fromBytes(We(_), v);
|
|
3924
3924
|
}
|
|
3925
3925
|
assertRecovery() {
|
|
3926
3926
|
const { recovery: _ } = this;
|
|
@@ -3932,10 +3932,10 @@ function Yr(r, e, s = {}) {
|
|
|
3932
3932
|
return new b(this.r, this.s, _);
|
|
3933
3933
|
}
|
|
3934
3934
|
recoverPublicKey(_) {
|
|
3935
|
-
const { r: v, s: I } = this, L = this.assertRecovery(),
|
|
3936
|
-
if (!o.isValid(
|
|
3935
|
+
const { r: v, s: I } = this, L = this.assertRecovery(), O = L === 2 || L === 3 ? v + a : v;
|
|
3936
|
+
if (!o.isValid(O))
|
|
3937
3937
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
3938
|
-
const M = o.toBytes(
|
|
3938
|
+
const M = o.toBytes(O), A = r.fromBytes(ve(Is((L & 1) === 0), M)), $ = i.inv(O), F = P(V(_, void 0, "msgHash")), J = i.create(-F * $), K = i.create(I * $), H = r.BASE.multiplyUnsafe(J).add(A.multiplyUnsafe(K));
|
|
3939
3939
|
if (H.is0())
|
|
3940
3940
|
throw new Error("invalid recovery: point at infinify");
|
|
3941
3941
|
return H.assertValidity(), H;
|
|
@@ -3945,63 +3945,63 @@ function Yr(r, e, s = {}) {
|
|
|
3945
3945
|
return y(this.s);
|
|
3946
3946
|
}
|
|
3947
3947
|
toBytes(_ = w.format) {
|
|
3948
|
-
if (
|
|
3949
|
-
return
|
|
3950
|
-
const { r: v, s: I } = this, L = i.toBytes(v),
|
|
3951
|
-
return _ === "recovered" ? (
|
|
3948
|
+
if (ct(_), _ === "der")
|
|
3949
|
+
return We(ye.hexFromSig(this));
|
|
3950
|
+
const { r: v, s: I } = this, L = i.toBytes(v), O = i.toBytes(I);
|
|
3951
|
+
return _ === "recovered" ? (C(), ve(Uint8Array.of(this.assertRecovery()), L, O)) : ve(L, O);
|
|
3952
3952
|
}
|
|
3953
3953
|
toHex(_) {
|
|
3954
|
-
return
|
|
3954
|
+
return Me(this.toBytes(_));
|
|
3955
3955
|
}
|
|
3956
3956
|
}
|
|
3957
3957
|
const k = s.bits2int || function(_) {
|
|
3958
3958
|
if (_.length > 8192)
|
|
3959
3959
|
throw new Error("input is too large");
|
|
3960
|
-
const v =
|
|
3960
|
+
const v = ze(_), I = _.length * 8 - c;
|
|
3961
3961
|
return I > 0 ? v >> BigInt(I) : v;
|
|
3962
3962
|
}, P = s.bits2int_modN || function(_) {
|
|
3963
3963
|
return i.create(k(_));
|
|
3964
|
-
}, G =
|
|
3964
|
+
}, G = ft(c);
|
|
3965
3965
|
function z(f) {
|
|
3966
|
-
return
|
|
3966
|
+
return Ar("num < 2^" + c, f, _e, G), i.toBytes(f);
|
|
3967
3967
|
}
|
|
3968
3968
|
function W(f, _) {
|
|
3969
3969
|
return V(f, void 0, "message"), _ ? V(e(f), void 0, "prehashed message") : f;
|
|
3970
3970
|
}
|
|
3971
3971
|
function q(f, _, v) {
|
|
3972
|
-
const { lowS: I, prehash: L, extraEntropy:
|
|
3972
|
+
const { lowS: I, prehash: L, extraEntropy: O } = st(v, w);
|
|
3973
3973
|
f = W(f, L);
|
|
3974
3974
|
const M = P(f), A = i.fromBytes(_);
|
|
3975
3975
|
if (!i.isValidNot0(A))
|
|
3976
3976
|
throw new Error("invalid private key");
|
|
3977
3977
|
const $ = [z(A), z(M)];
|
|
3978
|
-
if (
|
|
3979
|
-
const H =
|
|
3978
|
+
if (O != null && O !== !1) {
|
|
3979
|
+
const H = O === !0 ? t(x.secretKey) : O;
|
|
3980
3980
|
$.push(V(H, void 0, "extraEntropy"));
|
|
3981
3981
|
}
|
|
3982
|
-
const F =
|
|
3982
|
+
const F = ve(...$), J = M;
|
|
3983
3983
|
function K(H) {
|
|
3984
3984
|
const Z = k(H);
|
|
3985
3985
|
if (!i.isValidNot0(Z))
|
|
3986
3986
|
return;
|
|
3987
3987
|
const X = i.inv(Z), oe = r.BASE.multiply(Z).toAffine(), j = i.create(oe.x);
|
|
3988
|
-
if (j ===
|
|
3988
|
+
if (j === _e)
|
|
3989
3989
|
return;
|
|
3990
3990
|
const Q = i.create(X * i.create(J + j * A));
|
|
3991
|
-
if (Q ===
|
|
3991
|
+
if (Q === _e)
|
|
3992
3992
|
return;
|
|
3993
|
-
let
|
|
3994
|
-
return I && y(Q) && (
|
|
3993
|
+
let yt = (oe.x === j ? 0 : 2) | Number(oe.y & Re), bt = Q;
|
|
3994
|
+
return I && y(Q) && (bt = i.neg(Q), yt ^= 1), new b(j, bt, E ? void 0 : yt);
|
|
3995
3995
|
}
|
|
3996
3996
|
return { seed: F, k2sig: K };
|
|
3997
3997
|
}
|
|
3998
3998
|
function D(f, _, v = {}) {
|
|
3999
3999
|
const { seed: I, k2sig: L } = q(f, _, v);
|
|
4000
|
-
return
|
|
4000
|
+
return kr(e.outputLen, i.BYTES, n)(I, L).toBytes(v.format);
|
|
4001
4001
|
}
|
|
4002
4002
|
function R(f, _, v, I = {}) {
|
|
4003
|
-
const { lowS: L, prehash:
|
|
4004
|
-
if (v = V(v, void 0, "publicKey"), _ = W(_,
|
|
4003
|
+
const { lowS: L, prehash: O, format: M } = st(I, w);
|
|
4004
|
+
if (v = V(v, void 0, "publicKey"), _ = W(_, O), !ut(f)) {
|
|
4005
4005
|
const A = f instanceof b ? ", use sig.toBytes()" : "";
|
|
4006
4006
|
throw new Error("verify expects Uint8Array signature" + A);
|
|
4007
4007
|
}
|
|
@@ -4016,8 +4016,8 @@ function Yr(r, e, s = {}) {
|
|
|
4016
4016
|
return !1;
|
|
4017
4017
|
}
|
|
4018
4018
|
}
|
|
4019
|
-
function
|
|
4020
|
-
const { prehash: I } =
|
|
4019
|
+
function N(f, _, v = {}) {
|
|
4020
|
+
const { prehash: I } = st(v, w);
|
|
4021
4021
|
return _ = W(_, I), b.fromBytes(f, "recovered").recoverPublicKey(_).toBytes();
|
|
4022
4022
|
}
|
|
4023
4023
|
return Object.freeze({
|
|
@@ -4029,13 +4029,13 @@ function Yr(r, e, s = {}) {
|
|
|
4029
4029
|
Point: r,
|
|
4030
4030
|
sign: D,
|
|
4031
4031
|
verify: R,
|
|
4032
|
-
recoverPublicKey:
|
|
4032
|
+
recoverPublicKey: N,
|
|
4033
4033
|
Signature: b,
|
|
4034
4034
|
hash: e
|
|
4035
4035
|
});
|
|
4036
4036
|
}
|
|
4037
4037
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
4038
|
-
const
|
|
4038
|
+
const gt = {
|
|
4039
4039
|
p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
|
|
4040
4040
|
n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
|
|
4041
4041
|
h: BigInt(1),
|
|
@@ -4043,44 +4043,44 @@ const xt = {
|
|
|
4043
4043
|
b: BigInt(7),
|
|
4044
4044
|
Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
4045
4045
|
Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
|
|
4046
|
-
},
|
|
4046
|
+
}, Zr = {
|
|
4047
4047
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
4048
4048
|
basises: [
|
|
4049
4049
|
[BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
|
|
4050
4050
|
[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
|
|
4051
4051
|
]
|
|
4052
|
-
},
|
|
4053
|
-
function
|
|
4054
|
-
const e =
|
|
4055
|
-
if (!
|
|
4052
|
+
}, qt = /* @__PURE__ */ BigInt(2);
|
|
4053
|
+
function Xr(r) {
|
|
4054
|
+
const e = gt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, h = ae(d, s, e) * d % e, m = ae(h, s, e) * d % e, x = ae(m, qt, e) * l % e, w = ae(x, n, e) * x % e, E = ae(w, o, e) * w % e, y = ae(E, a, e) * E % e, S = ae(y, c, e) * y % e, C = ae(S, a, e) * E % e, B = ae(C, s, e) * d % e, b = ae(B, i, e) * w % e, k = ae(b, t, e) * l % e, P = ae(k, qt, e);
|
|
4055
|
+
if (!lt.eql(lt.sqr(P), r))
|
|
4056
4056
|
throw new Error("Cannot find square root");
|
|
4057
4057
|
return P;
|
|
4058
4058
|
}
|
|
4059
|
-
const
|
|
4060
|
-
Fp:
|
|
4061
|
-
endo:
|
|
4062
|
-
}),
|
|
4063
|
-
for (let r = 0, e =
|
|
4064
|
-
[s, t] = [t, (2 * s + 3 * t) % 5],
|
|
4065
|
-
let n =
|
|
4059
|
+
const lt = je(gt.p, { sqrt: Xr }), Qr = /* @__PURE__ */ jr(gt, {
|
|
4060
|
+
Fp: lt,
|
|
4061
|
+
endo: Zr
|
|
4062
|
+
}), en = /* @__PURE__ */ Jr(Qr, Er), tn = BigInt(0), Oe = BigInt(1), sn = BigInt(2), rn = BigInt(7), nn = BigInt(256), on = BigInt(113), As = [], Rs = [], ks = [];
|
|
4063
|
+
for (let r = 0, e = Oe, s = 1, t = 0; r < 24; r++) {
|
|
4064
|
+
[s, t] = [t, (2 * s + 3 * t) % 5], As.push(2 * (5 * t + s)), Rs.push((r + 1) * (r + 2) / 2 % 64);
|
|
4065
|
+
let n = tn;
|
|
4066
4066
|
for (let o = 0; o < 7; o++)
|
|
4067
|
-
e = (e <<
|
|
4068
|
-
|
|
4067
|
+
e = (e << Oe ^ (e >> rn) * on) % nn, e & sn && (n ^= Oe << (Oe << BigInt(o)) - Oe);
|
|
4068
|
+
ks.push(n);
|
|
4069
4069
|
}
|
|
4070
|
-
const
|
|
4071
|
-
function
|
|
4070
|
+
const Ps = xr(ks, !0), an = Ps[0], cn = Ps[1], Kt = (r, e, s) => s > 32 ? wr(r, e, s) : gr(r, e, s), Vt = (r, e, s) => s > 32 ? yr(r, e, s) : mr(r, e, s);
|
|
4071
|
+
function ln(r, e = 24) {
|
|
4072
4072
|
const s = new Uint32Array(10);
|
|
4073
4073
|
for (let t = 24 - e; t < 24; t++) {
|
|
4074
4074
|
for (let i = 0; i < 10; i++)
|
|
4075
4075
|
s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
|
|
4076
4076
|
for (let i = 0; i < 10; i += 2) {
|
|
4077
|
-
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], h =
|
|
4077
|
+
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], h = Kt(l, d, 1) ^ s[a], m = Vt(l, d, 1) ^ s[a + 1];
|
|
4078
4078
|
for (let x = 0; x < 50; x += 10)
|
|
4079
4079
|
r[i + x] ^= h, r[i + x + 1] ^= m;
|
|
4080
4080
|
}
|
|
4081
4081
|
let n = r[2], o = r[3];
|
|
4082
4082
|
for (let i = 0; i < 24; i++) {
|
|
4083
|
-
const a =
|
|
4083
|
+
const a = Rs[i], c = Kt(n, o, a), l = Vt(n, o, a), d = As[i];
|
|
4084
4084
|
n = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
|
|
4085
4085
|
}
|
|
4086
4086
|
for (let i = 0; i < 50; i += 10) {
|
|
@@ -4089,11 +4089,11 @@ function cn(r, e = 24) {
|
|
|
4089
4089
|
for (let a = 0; a < 10; a++)
|
|
4090
4090
|
r[i + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
|
|
4091
4091
|
}
|
|
4092
|
-
r[0] ^=
|
|
4092
|
+
r[0] ^= an[t], r[1] ^= cn[t];
|
|
4093
4093
|
}
|
|
4094
|
-
|
|
4094
|
+
Pe(s);
|
|
4095
4095
|
}
|
|
4096
|
-
class
|
|
4096
|
+
class mt {
|
|
4097
4097
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
4098
4098
|
constructor(e, s, t, n = !1, o = 24) {
|
|
4099
4099
|
T(this, "state");
|
|
@@ -4107,18 +4107,18 @@ class gt {
|
|
|
4107
4107
|
T(this, "outputLen");
|
|
4108
4108
|
T(this, "enableXOF", !1);
|
|
4109
4109
|
T(this, "rounds");
|
|
4110
|
-
if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o,
|
|
4110
|
+
if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, ge(t, "outputLen"), !(0 < e && e < 200))
|
|
4111
4111
|
throw new Error("only keccak-f1600 function is supported");
|
|
4112
|
-
this.state = new Uint8Array(200), this.state32 =
|
|
4112
|
+
this.state = new Uint8Array(200), this.state32 = ir(this.state);
|
|
4113
4113
|
}
|
|
4114
4114
|
clone() {
|
|
4115
4115
|
return this._cloneInto();
|
|
4116
4116
|
}
|
|
4117
4117
|
keccak() {
|
|
4118
|
-
|
|
4118
|
+
Ct(this.state32), ln(this.state32, this.rounds), Ct(this.state32), this.posOut = 0, this.pos = 0;
|
|
4119
4119
|
}
|
|
4120
4120
|
update(e) {
|
|
4121
|
-
|
|
4121
|
+
ke(this), V(e);
|
|
4122
4122
|
const { blockLen: s, state: t } = this, n = e.length;
|
|
4123
4123
|
for (let o = 0; o < n; ) {
|
|
4124
4124
|
const i = Math.min(s - this.pos, n - o);
|
|
@@ -4136,7 +4136,7 @@ class gt {
|
|
|
4136
4136
|
e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
|
|
4137
4137
|
}
|
|
4138
4138
|
writeInto(e) {
|
|
4139
|
-
|
|
4139
|
+
ke(this, !1), V(e), this.finish();
|
|
4140
4140
|
const s = this.state, { blockLen: t } = this;
|
|
4141
4141
|
for (let n = 0, o = e.length; n < o; ) {
|
|
4142
4142
|
this.posOut >= t && this.keccak();
|
|
@@ -4151,10 +4151,10 @@ class gt {
|
|
|
4151
4151
|
return this.writeInto(e);
|
|
4152
4152
|
}
|
|
4153
4153
|
xof(e) {
|
|
4154
|
-
return
|
|
4154
|
+
return ge(e), this.xofInto(new Uint8Array(e));
|
|
4155
4155
|
}
|
|
4156
4156
|
digestInto(e) {
|
|
4157
|
-
if (
|
|
4157
|
+
if (ss(e, this), this.finished)
|
|
4158
4158
|
throw new Error("digest() was already called");
|
|
4159
4159
|
return this.writeInto(e), this.destroy(), e;
|
|
4160
4160
|
}
|
|
@@ -4162,21 +4162,21 @@ class gt {
|
|
|
4162
4162
|
return this.digestInto(new Uint8Array(this.outputLen));
|
|
4163
4163
|
}
|
|
4164
4164
|
destroy() {
|
|
4165
|
-
this.destroyed = !0,
|
|
4165
|
+
this.destroyed = !0, Pe(this.state);
|
|
4166
4166
|
}
|
|
4167
4167
|
_cloneInto(e) {
|
|
4168
4168
|
const { blockLen: s, suffix: t, outputLen: n, rounds: o, enableXOF: i } = this;
|
|
4169
|
-
return e || (e = new
|
|
4169
|
+
return e || (e = new mt(s, t, n, i, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = t, e.outputLen = n, e.enableXOF = i, e.destroyed = this.destroyed, e;
|
|
4170
4170
|
}
|
|
4171
4171
|
}
|
|
4172
|
-
const
|
|
4173
|
-
class
|
|
4172
|
+
const dn = (r, e, s, t = {}) => ns(() => new mt(e, r, s), t), zt = /* @__PURE__ */ dn(1, 136, 32), un = 60;
|
|
4173
|
+
class hn {
|
|
4174
4174
|
constructor() {
|
|
4175
4175
|
this.jwks = null;
|
|
4176
4176
|
}
|
|
4177
4177
|
setJWKSEndpoint(e) {
|
|
4178
4178
|
try {
|
|
4179
|
-
this.jwks =
|
|
4179
|
+
this.jwks = Ms(new URL(e)), u.log("[CROSSx] JWKS 엔드포인트 설정:", e);
|
|
4180
4180
|
} catch (s) {
|
|
4181
4181
|
u.warn("[CROSSx] JWKS 엔드포인트 URL 파싱 실패:", s);
|
|
4182
4182
|
}
|
|
@@ -4190,7 +4190,7 @@ class un {
|
|
|
4190
4190
|
iat: t.iat
|
|
4191
4191
|
});
|
|
4192
4192
|
const n = Math.floor(Date.now() / 1e3);
|
|
4193
|
-
if (t.exp && t.exp +
|
|
4193
|
+
if (t.exp && t.exp + un < n)
|
|
4194
4194
|
return u.warn("[CROSSx] 토큰 만료:", {
|
|
4195
4195
|
exp: t.exp,
|
|
4196
4196
|
now: n,
|
|
@@ -4200,7 +4200,7 @@ class un {
|
|
|
4200
4200
|
return u.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 };
|
|
4201
4201
|
if (this.jwks)
|
|
4202
4202
|
try {
|
|
4203
|
-
const { payload: o } = await
|
|
4203
|
+
const { payload: o } = await $s(e, this.jwks, {
|
|
4204
4204
|
algorithms: ["RS256", "ES256"]
|
|
4205
4205
|
});
|
|
4206
4206
|
return u.log("[CROSSx] JWT 서명 검증 성공"), {
|
|
@@ -4219,7 +4219,7 @@ class un {
|
|
|
4219
4219
|
}
|
|
4220
4220
|
}
|
|
4221
4221
|
decodeJWT(e) {
|
|
4222
|
-
return
|
|
4222
|
+
return Bs(e);
|
|
4223
4223
|
}
|
|
4224
4224
|
/**
|
|
4225
4225
|
* EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
|
|
@@ -4234,29 +4234,29 @@ class un {
|
|
|
4234
4234
|
${t.length}`
|
|
4235
4235
|
), o = new Uint8Array(n.length + t.length);
|
|
4236
4236
|
o.set(n, 0), o.set(t, n.length);
|
|
4237
|
-
const i =
|
|
4237
|
+
const i = zt(o), a = s.startsWith("0x") ? s.slice(2) : s;
|
|
4238
4238
|
if (a.length !== 130)
|
|
4239
4239
|
throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
|
|
4240
|
-
const c =
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
).addRecoveryBit(m).recoverPublicKey(i).toBytes(!1).slice(1), y =
|
|
4244
|
-
return "0x" +
|
|
4240
|
+
const c = pn(a), l = c.slice(0, 32), d = c.slice(32, 64), h = c[64], m = h >= 27 ? h - 27 : h, E = new en.Signature(
|
|
4241
|
+
jt(l),
|
|
4242
|
+
jt(d)
|
|
4243
|
+
).addRecoveryBit(m).recoverPublicKey(i).toBytes(!1).slice(1), y = zt(E);
|
|
4244
|
+
return "0x" + Me(y.slice(12));
|
|
4245
4245
|
}
|
|
4246
4246
|
}
|
|
4247
|
-
function
|
|
4247
|
+
function pn(r) {
|
|
4248
4248
|
const e = new Uint8Array(r.length / 2);
|
|
4249
4249
|
for (let s = 0; s < e.length; s++)
|
|
4250
4250
|
e[s] = parseInt(r.substring(s * 2, s * 2 + 2), 16);
|
|
4251
4251
|
return e;
|
|
4252
4252
|
}
|
|
4253
|
-
function
|
|
4253
|
+
function jt(r) {
|
|
4254
4254
|
let e = "0x";
|
|
4255
4255
|
for (const s of r) e += s.toString(16).padStart(2, "0");
|
|
4256
4256
|
return BigInt(e);
|
|
4257
4257
|
}
|
|
4258
|
-
const
|
|
4259
|
-
class
|
|
4258
|
+
const fn = 3e4, _n = 1e3;
|
|
4259
|
+
class xn {
|
|
4260
4260
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4261
4261
|
async request(e) {
|
|
4262
4262
|
const s = e.retries ?? 0;
|
|
@@ -4267,7 +4267,7 @@ class _n {
|
|
|
4267
4267
|
} catch (n) {
|
|
4268
4268
|
if (t === s) throw n;
|
|
4269
4269
|
}
|
|
4270
|
-
await new Promise((n) => setTimeout(n,
|
|
4270
|
+
await new Promise((n) => setTimeout(n, _n * 2 ** t));
|
|
4271
4271
|
}
|
|
4272
4272
|
throw new Error("Unexpected: retry loop exited without result");
|
|
4273
4273
|
}
|
|
@@ -4275,7 +4275,7 @@ class _n {
|
|
|
4275
4275
|
async _doRequest(e) {
|
|
4276
4276
|
const s = new AbortController(), t = setTimeout(
|
|
4277
4277
|
() => s.abort(),
|
|
4278
|
-
e.timeoutMs ??
|
|
4278
|
+
e.timeoutMs ?? fn
|
|
4279
4279
|
);
|
|
4280
4280
|
try {
|
|
4281
4281
|
const n = await fetch(e.url, {
|
|
@@ -4302,12 +4302,12 @@ class _n {
|
|
|
4302
4302
|
}
|
|
4303
4303
|
}
|
|
4304
4304
|
}
|
|
4305
|
-
const
|
|
4305
|
+
const gn = /* @__PURE__ */ new Set([
|
|
4306
4306
|
"https://cross-wallet-oauth.crosstoken.io",
|
|
4307
4307
|
"https://stg-cross-wallet-oauth.crosstoken.io",
|
|
4308
4308
|
"https://dev-cross-wallet-oauth.crosstoken.io"
|
|
4309
4309
|
]);
|
|
4310
|
-
class
|
|
4310
|
+
class be {
|
|
4311
4311
|
static generateRandom16Hex() {
|
|
4312
4312
|
const e = new Uint8Array(16);
|
|
4313
4313
|
return crypto.getRandomValues(e), Array.from(e, (s) => s.toString(16).padStart(2, "0")).join("");
|
|
@@ -4331,7 +4331,7 @@ class ye {
|
|
|
4331
4331
|
* - Google 및 기타: originalNonce === jwt.nonce
|
|
4332
4332
|
*/
|
|
4333
4333
|
static async verifyIdTokenNonce(e, s) {
|
|
4334
|
-
const t =
|
|
4334
|
+
const t = be.parseJwtPayload(e), n = t.nonce, o = typeof t.iss == "string" ? t.iss : "(unknown)";
|
|
4335
4335
|
if (u.log("[CROSSx] nonce 검증 시작 —", {
|
|
4336
4336
|
iss: o,
|
|
4337
4337
|
nonceClaimType: typeof n,
|
|
@@ -4353,7 +4353,7 @@ class ye {
|
|
|
4353
4353
|
"ID Token에 nonce claim이 없습니다 — OAuth 서버 설정을 확인해 주세요"
|
|
4354
4354
|
);
|
|
4355
4355
|
if (o.includes("appleid.apple.com")) {
|
|
4356
|
-
const i = await
|
|
4356
|
+
const i = await be.sha256Hex(s);
|
|
4357
4357
|
if (u.log("[CROSSx] Apple nonce 검증 —", {
|
|
4358
4358
|
expectedHashLength: i.length,
|
|
4359
4359
|
receivedHashLength: n.length,
|
|
@@ -4370,7 +4370,7 @@ class ye {
|
|
|
4370
4370
|
}
|
|
4371
4371
|
openAuth(e) {
|
|
4372
4372
|
return new Promise((s, t) => {
|
|
4373
|
-
const n = Math.max(e.width ?? 500, 500), o = Math.max(e.height ?? 700, 700), i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c =
|
|
4373
|
+
const n = Math.max(e.width ?? 500, 500), o = Math.max(e.height ?? 700, 700), i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = be.generateRandom16Hex(), l = be.generateRandom16Hex(), d = e.authUrl.includes("?") ? "&" : "?", h = `${e.authUrl}${d}state=${c}&nonce=${l}`;
|
|
4374
4374
|
u.log("[CROSSx] OAuth 팝업 열기 — state, nonce 생성 완료:", {
|
|
4375
4375
|
stateLength: c.length,
|
|
4376
4376
|
nonceLength: l.length,
|
|
@@ -4389,7 +4389,7 @@ class ye {
|
|
|
4389
4389
|
u.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), b(), t(new Error("Authentication timeout"));
|
|
4390
4390
|
}, 5 * 60 * 1e3), w = 10, E = 30;
|
|
4391
4391
|
let y = 0, S = null;
|
|
4392
|
-
const
|
|
4392
|
+
const C = () => {
|
|
4393
4393
|
clearInterval(B), u.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + E + "초간 대기합니다"), S = setTimeout(() => {
|
|
4394
4394
|
b(), t(new Error(
|
|
4395
4395
|
"OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
|
|
@@ -4398,16 +4398,16 @@ class ye {
|
|
|
4398
4398
|
}, B = setInterval(() => {
|
|
4399
4399
|
y++;
|
|
4400
4400
|
try {
|
|
4401
|
-
m.closed && (y <= w ?
|
|
4401
|
+
m.closed && (y <= w ? C() : (b(), t(new Error("로그인이 취소되었습니다"))));
|
|
4402
4402
|
} catch {
|
|
4403
|
-
|
|
4403
|
+
C();
|
|
4404
4404
|
}
|
|
4405
4405
|
}, 1e3), b = () => {
|
|
4406
4406
|
clearTimeout(x), clearInterval(B), S && clearTimeout(S), window.removeEventListener("message", k);
|
|
4407
4407
|
}, k = (P) => {
|
|
4408
4408
|
var z, W, q, D, R;
|
|
4409
4409
|
if (P.origin !== e.expectedOrigin) return;
|
|
4410
|
-
if (!
|
|
4410
|
+
if (!gn.has(P.origin)) {
|
|
4411
4411
|
u.error("[CROSSx] postMessage origin이 허용 목록에 없음:", P.origin), b(), t(new Error("Unauthorized OAuth origin"));
|
|
4412
4412
|
return;
|
|
4413
4413
|
}
|
|
@@ -4418,17 +4418,17 @@ class ye {
|
|
|
4418
4418
|
return;
|
|
4419
4419
|
}
|
|
4420
4420
|
if (P.data.status === "success") {
|
|
4421
|
-
const
|
|
4421
|
+
const N = (W = P.data.data) == null ? void 0 : W.idToken, f = (q = P.data.data) == null ? void 0 : q.accessToken, _ = f ?? N;
|
|
4422
4422
|
if (u.log("[CROSSx] OAuth 토큰 수신:", {
|
|
4423
4423
|
hasAccessToken: !!f,
|
|
4424
|
-
hasIdToken: !!
|
|
4424
|
+
hasIdToken: !!N
|
|
4425
4425
|
}), !_) {
|
|
4426
4426
|
u.error("[CROSSx] 토큰을 찾을 수 없음:", P.data), t(new Error("Token not found in response"));
|
|
4427
4427
|
return;
|
|
4428
4428
|
}
|
|
4429
|
-
|
|
4429
|
+
N ? be.verifyIdTokenNonce(N, l).then(() => s(_)).catch((v) => {
|
|
4430
4430
|
u.error("[CROSSx] nonce 검증 실패:", v), t(v instanceof Error ? v : new Error("nonce verification failed"));
|
|
4431
|
-
}) : f ? f.split(".").length === 3 ?
|
|
4431
|
+
}) : f ? f.split(".").length === 3 ? be.verifyIdTokenNonce(f, l).then(() => s(_)).catch((I) => {
|
|
4432
4432
|
u.error("[CROSSx] accessToken nonce 검증 실패:", I), t(I instanceof Error ? I : new Error("nonce verification failed"));
|
|
4433
4433
|
}) : (u.warn(
|
|
4434
4434
|
"[CROSSx] opaque accessToken만 수신 (idToken 없음) — nonce 검증 불가.",
|
|
@@ -4441,8 +4441,8 @@ class ye {
|
|
|
4441
4441
|
});
|
|
4442
4442
|
}
|
|
4443
4443
|
}
|
|
4444
|
-
const
|
|
4445
|
-
class
|
|
4444
|
+
const Ce = "crossx_wallet_data", Ae = "crossx_mock_pin_hash";
|
|
4445
|
+
class mn {
|
|
4446
4446
|
constructor(e, s) {
|
|
4447
4447
|
this.storage = e, this.pinStore = s ?? null;
|
|
4448
4448
|
}
|
|
@@ -4455,13 +4455,13 @@ class gn {
|
|
|
4455
4455
|
async checkWallet() {
|
|
4456
4456
|
if (this.migrateScenario !== void 0)
|
|
4457
4457
|
return u.log("[Mock] checkWallet → migration_required"), "migration_required";
|
|
4458
|
-
const s = await this.storage.get(
|
|
4458
|
+
const s = await this.storage.get(Ce) ? "exists" : "not_found";
|
|
4459
4459
|
return u.log(`[Mock] checkWallet → ${s}`), s;
|
|
4460
4460
|
}
|
|
4461
4461
|
async getOrCreateWallet(e) {
|
|
4462
4462
|
var s;
|
|
4463
4463
|
try {
|
|
4464
|
-
const t = await this.storage.get(
|
|
4464
|
+
const t = await this.storage.get(Ce);
|
|
4465
4465
|
if (t) return t;
|
|
4466
4466
|
const n = {
|
|
4467
4467
|
id: e,
|
|
@@ -4469,16 +4469,16 @@ class gn {
|
|
|
4469
4469
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
4470
4470
|
createdAt: Date.now()
|
|
4471
4471
|
};
|
|
4472
|
-
await this.storage.set(
|
|
4472
|
+
await this.storage.set(Ce, n);
|
|
4473
4473
|
const o = (s = this.pinStore) == null ? void 0 : s.get();
|
|
4474
|
-
return o && (await this.storage.set(
|
|
4474
|
+
return o && (await this.storage.set(Ae, o), u.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
|
|
4475
4475
|
} catch (t) {
|
|
4476
4476
|
throw new g(p.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", t);
|
|
4477
4477
|
}
|
|
4478
4478
|
}
|
|
4479
4479
|
/** GET /mnemonic/addresses 모킹 — PIN 불필요, 캐시된 주소 반환 */
|
|
4480
4480
|
async getAddresses(e) {
|
|
4481
|
-
const s = await this.storage.get(
|
|
4481
|
+
const s = await this.storage.get(Ce);
|
|
4482
4482
|
return s ? [{ address: s.address, index: 0 }] : [];
|
|
4483
4483
|
}
|
|
4484
4484
|
async getAddress(e, s) {
|
|
@@ -4513,8 +4513,8 @@ class gn {
|
|
|
4513
4513
|
var t;
|
|
4514
4514
|
if (u.log("[Mock] verifyPin"), this.pinScenario === "wrong")
|
|
4515
4515
|
return !1;
|
|
4516
|
-
const s = await this.storage.get(
|
|
4517
|
-
return s && s !== e ? !1 : (s || await this.storage.set(
|
|
4516
|
+
const s = await this.storage.get(Ae);
|
|
4517
|
+
return s && s !== e ? !1 : (s || await this.storage.set(Ae, e), (t = this.pinStore) == null || t.set(e), u.log("[Mock] verifyPin → 성공"), !0);
|
|
4518
4518
|
}
|
|
4519
4519
|
/**
|
|
4520
4520
|
* POST /mnemonic/change-password 모킹
|
|
@@ -4524,10 +4524,10 @@ class gn {
|
|
|
4524
4524
|
var o;
|
|
4525
4525
|
if (u.log("[Mock] changePin"), this.pinScenario === "wrong")
|
|
4526
4526
|
throw new g(p.PIN_WRONG, "Incorrect PIN.");
|
|
4527
|
-
const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(
|
|
4527
|
+
const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Ae);
|
|
4528
4528
|
if (n && t && n !== t)
|
|
4529
4529
|
throw new g(p.PIN_WRONG, "Incorrect PIN.");
|
|
4530
|
-
await this.storage.set(
|
|
4530
|
+
await this.storage.set(Ae, s), u.log("[Mock] changePin 완료");
|
|
4531
4531
|
}
|
|
4532
4532
|
async migrateWallet(e, s) {
|
|
4533
4533
|
var o;
|
|
@@ -4558,9 +4558,9 @@ class gn {
|
|
|
4558
4558
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
4559
4559
|
createdAt: Date.now()
|
|
4560
4560
|
};
|
|
4561
|
-
await this.storage.set(
|
|
4561
|
+
await this.storage.set(Ce, t);
|
|
4562
4562
|
const n = (o = this.pinStore) == null ? void 0 : o.get();
|
|
4563
|
-
return n && (await this.storage.set(
|
|
4563
|
+
return n && (await this.storage.set(Ae, n), u.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
|
|
4564
4564
|
}
|
|
4565
4565
|
/**
|
|
4566
4566
|
* POST /mnemonic/share-c 모킹
|
|
@@ -4587,7 +4587,7 @@ class gn {
|
|
|
4587
4587
|
).join("");
|
|
4588
4588
|
}
|
|
4589
4589
|
}
|
|
4590
|
-
class
|
|
4590
|
+
class Le {
|
|
4591
4591
|
constructor(e, s, t, n, o) {
|
|
4592
4592
|
this._walletStatusCache = null, this.adapterConfig = e, this.projectId = e.projectId, this.storage = s, this.transport = t, this.tokenStore = n, this.pinStore = o ?? null;
|
|
4593
4593
|
}
|
|
@@ -4633,7 +4633,7 @@ class Oe {
|
|
|
4633
4633
|
url: o,
|
|
4634
4634
|
method: e
|
|
4635
4635
|
});
|
|
4636
|
-
const m =
|
|
4636
|
+
const m = Le.mapGatewayError(d.code, d.data), x = Le.getGatewayErrorMessage(d.code, h), w = d.data, E = m === p.PIN_LOCKED ? Le.extractLockDetails(w) : w ?? void 0, y = new g(m, x, E);
|
|
4637
4637
|
throw m === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (u.warn("[CROSSx] Gateway -10002 감지 — 강제 로그아웃 실행"), this._onUnauthorized()), y;
|
|
4638
4638
|
}
|
|
4639
4639
|
return u.log("[CROSSx] Wallet Gateway API 성공:", { code: d.code, url: o, method: e }), d.data ?? d;
|
|
@@ -4937,7 +4937,7 @@ class Oe {
|
|
|
4937
4937
|
}
|
|
4938
4938
|
}
|
|
4939
4939
|
}
|
|
4940
|
-
class
|
|
4940
|
+
class De {
|
|
4941
4941
|
constructor(e, s) {
|
|
4942
4942
|
this.cache = /* @__PURE__ */ new Map(), this.loadedAt = 0, this.usingFallback = !1, this.adapterConfig = e, this.projectId = e.projectId, this.transport = s;
|
|
4943
4943
|
}
|
|
@@ -4955,7 +4955,7 @@ class Le {
|
|
|
4955
4955
|
const s = e.data.chains;
|
|
4956
4956
|
return this.populateCache(s, !1), s;
|
|
4957
4957
|
} catch {
|
|
4958
|
-
const e =
|
|
4958
|
+
const e = De.fallbackChains();
|
|
4959
4959
|
return this.populateCache(e, !0), e;
|
|
4960
4960
|
}
|
|
4961
4961
|
}
|
|
@@ -4969,7 +4969,7 @@ class Le {
|
|
|
4969
4969
|
}
|
|
4970
4970
|
isCacheValid() {
|
|
4971
4971
|
if (this.loadedAt === 0) return !1;
|
|
4972
|
-
const e = this.usingFallback ?
|
|
4972
|
+
const e = this.usingFallback ? sr : tr;
|
|
4973
4973
|
return e === 0 ? !0 : Date.now() - this.loadedAt < e;
|
|
4974
4974
|
}
|
|
4975
4975
|
populateCache(e, s) {
|
|
@@ -4991,13 +4991,13 @@ class Le {
|
|
|
4991
4991
|
if (e.code < 0) {
|
|
4992
4992
|
const s = typeof e.data == "string" ? e.data : e.message ?? "체인 레지스트리 요청에 실패했습니다";
|
|
4993
4993
|
throw new g(
|
|
4994
|
-
|
|
4994
|
+
De.mapErrorCode(e.code),
|
|
4995
4995
|
s
|
|
4996
4996
|
);
|
|
4997
4997
|
}
|
|
4998
4998
|
}
|
|
4999
4999
|
fallbackOrThrow(e) {
|
|
5000
|
-
const s =
|
|
5000
|
+
const s = De.fallbackChains().find(
|
|
5001
5001
|
(t) => t.chainId === e
|
|
5002
5002
|
);
|
|
5003
5003
|
if (s) return s;
|
|
@@ -5007,7 +5007,7 @@ class Le {
|
|
|
5007
5007
|
);
|
|
5008
5008
|
}
|
|
5009
5009
|
static fallbackChains() {
|
|
5010
|
-
return Object.values(
|
|
5010
|
+
return Object.values(Ve).map((e) => ({
|
|
5011
5011
|
chainId: e.caipId,
|
|
5012
5012
|
rpcUrl: e.rpcUrl
|
|
5013
5013
|
}));
|
|
@@ -5031,7 +5031,7 @@ class Le {
|
|
|
5031
5031
|
}
|
|
5032
5032
|
}
|
|
5033
5033
|
}
|
|
5034
|
-
const
|
|
5034
|
+
const Yt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", wn = {
|
|
5035
5035
|
light: {
|
|
5036
5036
|
bg: "#FFFFFF",
|
|
5037
5037
|
border: "rgba(18,18,18,0.05)",
|
|
@@ -5087,8 +5087,8 @@ const jt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", mn = {
|
|
|
5087
5087
|
onPrimary: "#FFFFFF"
|
|
5088
5088
|
}
|
|
5089
5089
|
};
|
|
5090
|
-
function
|
|
5091
|
-
const s =
|
|
5090
|
+
function Jt(r, e) {
|
|
5091
|
+
const s = wn[r], t = e == null ? void 0 : e[r];
|
|
5092
5092
|
return t ? {
|
|
5093
5093
|
...s,
|
|
5094
5094
|
// ── Brand
|
|
@@ -5120,7 +5120,7 @@ function Yt(r, e) {
|
|
|
5120
5120
|
...t.error !== void 0 && { errorColor: t.error }
|
|
5121
5121
|
} : s;
|
|
5122
5122
|
}
|
|
5123
|
-
const
|
|
5123
|
+
const yn = `
|
|
5124
5124
|
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
|
|
5125
5125
|
|
|
5126
5126
|
#${te} {
|
|
@@ -5133,6 +5133,7 @@ const wn = `
|
|
|
5133
5133
|
background: rgba(0,0,0,0.55);
|
|
5134
5134
|
font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
5135
5135
|
animation: __crossx-fade-in 0.15s ease;
|
|
5136
|
+
pointer-events: auto;
|
|
5136
5137
|
}
|
|
5137
5138
|
@keyframes __crossx-fade-in {
|
|
5138
5139
|
from { opacity: 0; }
|
|
@@ -6773,24 +6774,30 @@ const wn = `
|
|
|
6773
6774
|
}
|
|
6774
6775
|
`;
|
|
6775
6776
|
function he() {
|
|
6776
|
-
let r = document.getElementById(
|
|
6777
|
-
r || (r = document.createElement("style"), r.id =
|
|
6777
|
+
let r = document.getElementById(Yt);
|
|
6778
|
+
r || (r = document.createElement("style"), r.id = Yt, document.head.appendChild(r)), r.textContent = yn;
|
|
6779
|
+
}
|
|
6780
|
+
function pe(r) {
|
|
6781
|
+
const e = (s) => s.stopPropagation();
|
|
6782
|
+
for (const s of ["pointerdown", "pointerup", "mousedown", "mouseup", "click", "touchstart", "touchend"])
|
|
6783
|
+
r.addEventListener(s, e);
|
|
6784
|
+
document.body.appendChild(r);
|
|
6778
6785
|
}
|
|
6779
6786
|
function se(r) {
|
|
6780
6787
|
return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
|
|
6781
6788
|
}
|
|
6782
|
-
function
|
|
6789
|
+
function bn(r, e = "CROSS", s = 18) {
|
|
6783
6790
|
if (!r || r === "0x" || r === "0x0") return null;
|
|
6784
6791
|
try {
|
|
6785
6792
|
const t = BigInt(r);
|
|
6786
6793
|
if (t === 0n) return null;
|
|
6787
|
-
const n =
|
|
6794
|
+
const n = dt(t, s);
|
|
6788
6795
|
return n === "0" ? null : `${n} ${e}`;
|
|
6789
6796
|
} catch {
|
|
6790
6797
|
return null;
|
|
6791
6798
|
}
|
|
6792
6799
|
}
|
|
6793
|
-
const
|
|
6800
|
+
const Zt = {
|
|
6794
6801
|
1: "Ethereum Mainnet",
|
|
6795
6802
|
5: "Goerli Testnet",
|
|
6796
6803
|
11155111: "Ethereum Sepolia",
|
|
@@ -6813,16 +6820,16 @@ const Jt = {
|
|
|
6813
6820
|
612044: "CROSS Testnet",
|
|
6814
6821
|
612055: "CROSS Mainnet"
|
|
6815
6822
|
};
|
|
6816
|
-
function
|
|
6823
|
+
function Ns(r) {
|
|
6817
6824
|
const e = parseInt(r.split(":")[1] ?? "", 10);
|
|
6818
|
-
return !isNaN(e) &&
|
|
6825
|
+
return !isNaN(e) && Zt[e] ? Zt[e] : r;
|
|
6819
6826
|
}
|
|
6820
|
-
function
|
|
6827
|
+
function dt(r, e) {
|
|
6821
6828
|
if (r === 0n) return "0";
|
|
6822
6829
|
const s = 10n ** BigInt(e), t = r / s, i = (r % s).toString().padStart(e, "0").slice(0, 6).replace(/0+$/, "");
|
|
6823
6830
|
return i ? `${t}.${i}` : `${t}`;
|
|
6824
6831
|
}
|
|
6825
|
-
function
|
|
6832
|
+
function rt(r) {
|
|
6826
6833
|
try {
|
|
6827
6834
|
const e = BigInt(r), s = e / 1000000000n, n = (e % 1000000000n).toString().padStart(9, "0").slice(0, 2).replace(/0+$/, "");
|
|
6828
6835
|
return n ? `${s}.${n}` : `${s}`;
|
|
@@ -6830,25 +6837,25 @@ function st(r) {
|
|
|
6830
6837
|
return r;
|
|
6831
6838
|
}
|
|
6832
6839
|
}
|
|
6833
|
-
function
|
|
6840
|
+
function vn(r) {
|
|
6834
6841
|
try {
|
|
6835
6842
|
return BigInt(r).toLocaleString();
|
|
6836
6843
|
} catch {
|
|
6837
6844
|
return r;
|
|
6838
6845
|
}
|
|
6839
6846
|
}
|
|
6840
|
-
function
|
|
6847
|
+
function Sn(r) {
|
|
6841
6848
|
const { gasLimit: e, gasPrice: s, maxFeePerGas: t, maxPriorityFeePerGas: n, nativeSymbol: o = "ETH", nativeDecimals: i = 18 } = r;
|
|
6842
6849
|
if (!e) return null;
|
|
6843
6850
|
try {
|
|
6844
|
-
const a = BigInt(e), c =
|
|
6851
|
+
const a = BigInt(e), c = vn(e);
|
|
6845
6852
|
if (t) {
|
|
6846
6853
|
const l = a * BigInt(t);
|
|
6847
6854
|
return {
|
|
6848
6855
|
isDynamic: !0,
|
|
6849
|
-
estTxFee: `${
|
|
6850
|
-
maxFeeGwei:
|
|
6851
|
-
maxPriorityFeeGwei: n ?
|
|
6856
|
+
estTxFee: `${dt(l, i)} ${o}`,
|
|
6857
|
+
maxFeeGwei: rt(t),
|
|
6858
|
+
maxPriorityFeeGwei: n ? rt(n) : void 0,
|
|
6852
6859
|
gasLimitFormatted: c
|
|
6853
6860
|
};
|
|
6854
6861
|
}
|
|
@@ -6856,8 +6863,8 @@ function vn(r) {
|
|
|
6856
6863
|
const l = a * BigInt(s);
|
|
6857
6864
|
return {
|
|
6858
6865
|
isDynamic: !1,
|
|
6859
|
-
estTxFee: `${
|
|
6860
|
-
gasPriceGwei:
|
|
6866
|
+
estTxFee: `${dt(l, i)} ${o}`,
|
|
6867
|
+
gasPriceGwei: rt(s),
|
|
6861
6868
|
gasLimitFormatted: c
|
|
6862
6869
|
};
|
|
6863
6870
|
}
|
|
@@ -6866,28 +6873,28 @@ function vn(r) {
|
|
|
6866
6873
|
return null;
|
|
6867
6874
|
}
|
|
6868
6875
|
}
|
|
6869
|
-
function
|
|
6870
|
-
const e =
|
|
6876
|
+
function Os(r) {
|
|
6877
|
+
const e = Sn(r);
|
|
6871
6878
|
if (!e) return Y("Estimated fee", "<span>—</span>");
|
|
6872
6879
|
let s = Y("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
|
|
6873
6880
|
return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s += Y("Max Priority Fee", `<span>${e.maxPriorityFeeGwei} Gwei</span>`)), e.maxFeeGwei !== void 0 && (s += Y("Max Gas Fee", `<span>${e.maxFeeGwei} Gwei</span>`))) : e.gasPriceGwei !== void 0 && (s += Y("Gas Price", `<span>${e.gasPriceGwei} Gwei</span>`)), e.gasLimitFormatted && (s += Y("Gas Limit", `<span>${e.gasLimitFormatted}</span>`)), s;
|
|
6874
6881
|
}
|
|
6875
|
-
const
|
|
6882
|
+
const xe = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
6876
6883
|
<rect x="9" y="9" width="13" height="13" rx="2"/>
|
|
6877
6884
|
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
|
|
6878
6885
|
</svg>`, ie = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
|
|
6879
6886
|
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
6880
6887
|
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
6881
|
-
</svg>`,
|
|
6888
|
+
</svg>`, En = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6882
6889
|
<circle cx="20" cy="20" r="20" fill="#00D5AA"/>
|
|
6883
6890
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.3225 2.85742L23.7249 6.25982V11.8301L28.1175 7.43757L32.9292 12.2493L28.5806 16.5979H20.3225C18.4435 16.5979 16.9201 18.1212 16.9201 20.0003C16.9201 21.8794 18.4434 23.4027 20.3225 23.4027H28.5372L32.9293 27.7948L28.1176 32.6066L23.7249 28.2139V33.7407L20.3225 37.1431L16.9201 33.7407V28.2584L12.5719 32.6066L7.76022 27.7948L12.1524 23.4027H6.58209L3.17969 20.0003L6.58209 16.5979H12.1089L7.76035 12.2493L12.5721 7.43757L16.9201 11.7857V6.25982L20.3225 2.85742Z" fill="#121212"/>
|
|
6884
|
-
</svg>`,
|
|
6891
|
+
</svg>`, wt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
6885
6892
|
<rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
|
|
6886
6893
|
<path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
|
|
6887
6894
|
<rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
|
|
6888
|
-
</svg>`, En = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
6889
|
-
<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)"/>
|
|
6890
6895
|
</svg>`, In = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
6896
|
+
<path d="M12 0C18.6274 0 24 5.37258 24 12C23.9999 18.6273 18.6274 24 12 24C5.37264 24 9.89594e-05 18.6273 0 12C0 5.37258 5.37258 0 12 0ZM10.875 15.127V17.377H13.125V15.127H10.875ZM10.875 6.62207V13.627H13.125V6.62207H10.875Z" fill="var(--cx-error)"/>
|
|
6897
|
+
</svg>`, Tn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
6891
6898
|
<circle cx="12" cy="12" r="12" fill="var(--cx-error)"/>
|
|
6892
6899
|
<circle cx="12" cy="12" r="5.5" stroke="white" stroke-width="1.5"/>
|
|
6893
6900
|
<path d="M12 9.5v3l2 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
|
|
@@ -6925,9 +6932,9 @@ function Y(r, e) {
|
|
|
6925
6932
|
<div class="__crossx-row-value">${e}</div>
|
|
6926
6933
|
</div>`;
|
|
6927
6934
|
}
|
|
6928
|
-
function
|
|
6929
|
-
const s = e, t =
|
|
6930
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${
|
|
6935
|
+
function An(r, e) {
|
|
6936
|
+
const s = e, t = Ye(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
6937
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", o = Os(r), i = r.data ?? "0x", a = document.createElement("div");
|
|
6931
6938
|
return a.id = te, a.innerHTML = `
|
|
6932
6939
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
6933
6940
|
<div class="__crossx-header">
|
|
@@ -6942,7 +6949,7 @@ function Tn(r, e) {
|
|
|
6942
6949
|
<span class="__crossx-sig-origin">${U(t)} </span>is requesting a Signature
|
|
6943
6950
|
</p>
|
|
6944
6951
|
<div class="__crossx-addr-pill">
|
|
6945
|
-
${
|
|
6952
|
+
${wt}
|
|
6946
6953
|
<span class="__crossx-addr-pill-text">${se(r.from)}</span>
|
|
6947
6954
|
</div>
|
|
6948
6955
|
<p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
|
|
@@ -6951,7 +6958,7 @@ function Tn(r, e) {
|
|
|
6951
6958
|
<div class="__crossx-col-right-sign">
|
|
6952
6959
|
<div class="__crossx-rows">
|
|
6953
6960
|
${Y("To", n)}
|
|
6954
|
-
${Y("Network", `<span>${
|
|
6961
|
+
${Y("Network", `<span>${Ns(r.chainId)}</span>`)}
|
|
6955
6962
|
${o}
|
|
6956
6963
|
</div>
|
|
6957
6964
|
<pre class="__crossx-raw-tx">${U(i)}</pre>
|
|
@@ -6965,9 +6972,9 @@ function Tn(r, e) {
|
|
|
6965
6972
|
</div>
|
|
6966
6973
|
`, a;
|
|
6967
6974
|
}
|
|
6968
|
-
function
|
|
6969
|
-
const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o =
|
|
6970
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${
|
|
6975
|
+
function Rn(r, e) {
|
|
6976
|
+
const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Ye(r.dappName), i = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
6977
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", a = Os(r), l = bn(r.value, t, n) ?? "—", d = document.createElement("div");
|
|
6971
6978
|
return d.id = te, d.innerHTML = `
|
|
6972
6979
|
<div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
6973
6980
|
<div class="__crossx-header">
|
|
@@ -6982,7 +6989,7 @@ function An(r, e) {
|
|
|
6982
6989
|
<div class="__crossx-body-cols">
|
|
6983
6990
|
<div class="__crossx-rows">
|
|
6984
6991
|
${Y("To", i)}
|
|
6985
|
-
${Y("Network", `<span>${
|
|
6992
|
+
${Y("Network", `<span>${Ns(r.chainId)}</span>`)}
|
|
6986
6993
|
${a}
|
|
6987
6994
|
</div>
|
|
6988
6995
|
<div class="__crossx-pill">
|
|
@@ -6995,7 +7002,7 @@ function An(r, e) {
|
|
|
6995
7002
|
</div>
|
|
6996
7003
|
`, d;
|
|
6997
7004
|
}
|
|
6998
|
-
function
|
|
7005
|
+
function Ye(r) {
|
|
6999
7006
|
var e;
|
|
7000
7007
|
if (r) return r;
|
|
7001
7008
|
try {
|
|
@@ -7007,10 +7014,10 @@ function je(r) {
|
|
|
7007
7014
|
function U(r) {
|
|
7008
7015
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7009
7016
|
}
|
|
7010
|
-
function
|
|
7017
|
+
function kn(r) {
|
|
7011
7018
|
return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
|
|
7012
7019
|
}
|
|
7013
|
-
function
|
|
7020
|
+
function Pn(r) {
|
|
7014
7021
|
if (typeof r == "string") return U(r);
|
|
7015
7022
|
if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
|
|
7016
7023
|
try {
|
|
@@ -7019,14 +7026,14 @@ function kn(r) {
|
|
|
7019
7026
|
return String(r);
|
|
7020
7027
|
}
|
|
7021
7028
|
}
|
|
7022
|
-
function
|
|
7029
|
+
function Nn(r, e) {
|
|
7023
7030
|
const s = Y(
|
|
7024
7031
|
"From",
|
|
7025
7032
|
`<span class="__crossx-addr-text">${se(r.from)}</span>
|
|
7026
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.from)}" title="Copy address">${
|
|
7033
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.from)}" title="Copy address">${xe}</button>`
|
|
7027
7034
|
), t = r.to ? Y("To", `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
7028
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${
|
|
7029
|
-
<button class="__crossx-copy-btn" data-copy="${U(r.txHash)}" title="Copy hash">${
|
|
7035
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>`) : "", n = r.amount ? Y("Transfer", `<span>${U(r.amount)}</span>`) : "", o = r.fees ? Y("Tx Fee", `<span>${U(r.fees)}</span>`) : "", i = r.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(r.txHash)}</span>
|
|
7036
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.txHash)}" title="Copy hash">${xe}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
|
|
7030
7037
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
7031
7038
|
<span class="__crossx-total-amount">${U(r.total)}</span>
|
|
7032
7039
|
</div>` : "", c = document.createElement("div");
|
|
@@ -7051,7 +7058,7 @@ function Pn(r, e) {
|
|
|
7051
7058
|
</div>
|
|
7052
7059
|
`, c;
|
|
7053
7060
|
}
|
|
7054
|
-
function
|
|
7061
|
+
function On(r, e) {
|
|
7055
7062
|
const s = document.createElement("div");
|
|
7056
7063
|
return s.id = te, s.innerHTML = `
|
|
7057
7064
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7068,10 +7075,10 @@ function Cn(r, e) {
|
|
|
7068
7075
|
</div>
|
|
7069
7076
|
`, s;
|
|
7070
7077
|
}
|
|
7071
|
-
function
|
|
7078
|
+
function Cn(r, e, s) {
|
|
7072
7079
|
const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
|
|
7073
7080
|
if (o) {
|
|
7074
|
-
const w = n ?
|
|
7081
|
+
const w = n ? Tn : t ? "" : In, E = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
|
|
7075
7082
|
w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${E}</span>`) : o.textContent = E;
|
|
7076
7083
|
}
|
|
7077
7084
|
if (i && !r.querySelector("#__crossx-close-btn")) {
|
|
@@ -7081,9 +7088,9 @@ function Nn(r, e, s) {
|
|
|
7081
7088
|
const a = r.querySelector("#__crossx-progress-body");
|
|
7082
7089
|
if (!a) return;
|
|
7083
7090
|
const c = e.from ? Y("From", `<span class="__crossx-addr-text">${se(e.from)}</span>
|
|
7084
|
-
<button class="__crossx-copy-btn" data-copy="${U(e.from)}" title="Copy address">${
|
|
7085
|
-
<button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${
|
|
7086
|
-
<button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${
|
|
7091
|
+
<button class="__crossx-copy-btn" data-copy="${U(e.from)}" title="Copy address">${xe}</button>`) : "", l = e.to ? Y("To", `<span class="__crossx-addr-text">${se(e.to)}</span>
|
|
7092
|
+
<button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${xe}</button>`) : "", d = e.amount ? Y("Transfer", `<span>${U(e.amount)}</span>`) : "", h = e.fees ? Y("Tx Fee", `<span>${U(e.fees)}</span>`) : "", m = e.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(e.txHash)}</span>
|
|
7093
|
+
<button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${xe}</button>`) : "", x = e.total ? `<div class="__crossx-total-pill">
|
|
7087
7094
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
7088
7095
|
<span class="__crossx-total-amount">${U(e.total)}</span>
|
|
7089
7096
|
</div>` : "";
|
|
@@ -7107,8 +7114,8 @@ function Nn(r, e, s) {
|
|
|
7107
7114
|
});
|
|
7108
7115
|
});
|
|
7109
7116
|
}
|
|
7110
|
-
function
|
|
7111
|
-
const s = e, t =
|
|
7117
|
+
function Ln(r, e) {
|
|
7118
|
+
const s = e, t = Ye(r.dappName), n = U(r.message), o = document.createElement("div");
|
|
7112
7119
|
return o.id = te, o.innerHTML = `
|
|
7113
7120
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7114
7121
|
<div class="__crossx-header">
|
|
@@ -7123,7 +7130,7 @@ function On(r, e) {
|
|
|
7123
7130
|
<span class="__crossx-sig-origin">${U(t)} </span>is requesting a Signature
|
|
7124
7131
|
</p>
|
|
7125
7132
|
<div class="__crossx-addr-pill">
|
|
7126
|
-
${
|
|
7133
|
+
${wt}
|
|
7127
7134
|
<span class="__crossx-addr-pill-text">${se(r.from)}</span>
|
|
7128
7135
|
</div>
|
|
7129
7136
|
<p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
|
|
@@ -7139,8 +7146,8 @@ function On(r, e) {
|
|
|
7139
7146
|
</div>
|
|
7140
7147
|
`, o;
|
|
7141
7148
|
}
|
|
7142
|
-
function
|
|
7143
|
-
const s = e, t =
|
|
7149
|
+
function Dn(r, e) {
|
|
7150
|
+
const s = e, t = Ye(r.dappName);
|
|
7144
7151
|
let n = {};
|
|
7145
7152
|
if (typeof r.typedData == "string")
|
|
7146
7153
|
try {
|
|
@@ -7155,8 +7162,8 @@ function Ln(r, e) {
|
|
|
7155
7162
|
<span class="__crossx-td-value">${U(o)}</span>
|
|
7156
7163
|
</div>`;
|
|
7157
7164
|
for (const [l, d] of Object.entries(i)) {
|
|
7158
|
-
const h =
|
|
7159
|
-
<button class="__crossx-copy-btn" data-copy="${U(String(d))}" title="Copy">${
|
|
7165
|
+
const h = Pn(d), x = kn(d) ? `<span class="__crossx-addr-text">${se(d)}</span>
|
|
7166
|
+
<button class="__crossx-copy-btn" data-copy="${U(String(d))}" title="Copy">${xe}</button>` : `<span>${h}</span>`;
|
|
7160
7167
|
a += `
|
|
7161
7168
|
<div class="__crossx-td-row">
|
|
7162
7169
|
<span class="__crossx-td-label">${U(l)}</span>
|
|
@@ -7178,7 +7185,7 @@ function Ln(r, e) {
|
|
|
7178
7185
|
<span class="__crossx-sig-origin">${U(t)} </span>is requesting a Signature
|
|
7179
7186
|
</p>
|
|
7180
7187
|
<div class="__crossx-addr-pill">
|
|
7181
|
-
${
|
|
7188
|
+
${wt}
|
|
7182
7189
|
<span class="__crossx-addr-pill-text">${se(r.from)}</span>
|
|
7183
7190
|
</div>
|
|
7184
7191
|
<p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
|
|
@@ -7194,11 +7201,11 @@ function Ln(r, e) {
|
|
|
7194
7201
|
</div>
|
|
7195
7202
|
`, c;
|
|
7196
7203
|
}
|
|
7197
|
-
const
|
|
7204
|
+
const Mn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
7198
7205
|
<line x1="12" y1="5" x2="12" y2="19"/>
|
|
7199
7206
|
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
7200
7207
|
</svg>`;
|
|
7201
|
-
function
|
|
7208
|
+
function $n(r, e, s) {
|
|
7202
7209
|
const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
|
|
7203
7210
|
const a = t && i.address.toLowerCase() === t;
|
|
7204
7211
|
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${U(i.address)}">
|
|
@@ -7229,7 +7236,7 @@ function Mn(r, e, s) {
|
|
|
7229
7236
|
${n}
|
|
7230
7237
|
</div>
|
|
7231
7238
|
<button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
|
|
7232
|
-
<span class="__crossx-wallet-add-icon">${
|
|
7239
|
+
<span class="__crossx-wallet-add-icon">${Mn}</span>
|
|
7233
7240
|
<span class="__crossx-wallet-add-label">add a wallet</span>
|
|
7234
7241
|
</button>
|
|
7235
7242
|
</div>
|
|
@@ -7238,16 +7245,16 @@ function Mn(r, e, s) {
|
|
|
7238
7245
|
</div>
|
|
7239
7246
|
`, o;
|
|
7240
7247
|
}
|
|
7241
|
-
const
|
|
7248
|
+
const Bn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7242
7249
|
<path d="M26.693 21.193c-.028-3.168 2.587-4.712 2.706-4.786-1.477-2.16-3.77-2.454-4.58-2.484-1.944-.197-3.804 1.148-4.793 1.148-.992 0-2.52-1.12-4.147-1.09-2.13.032-4.1 1.239-5.198 3.133-2.222 3.855-.569 9.562 1.593 12.69 1.061 1.535 2.318 3.258 3.975 3.196 1.6-.064 2.2-1.03 4.133-1.03 1.928 0 2.48 1.03 4.172.997 1.72-.03 2.806-1.56 3.862-3.1 1.211-1.779 1.713-3.495 1.74-3.583-.037-.017-3.427-1.316-3.463-5.09z" fill="currentColor"/>
|
|
7243
7250
|
<path d="M23.527 11.876c.877-1.065 1.471-2.545 1.31-4.024-1.266.053-2.807.845-3.718 1.907-.813.946-1.53 2.468-1.34 3.915 1.41.107 2.852-.716 3.748-1.798z" fill="currentColor"/>
|
|
7244
|
-
</svg>`,
|
|
7251
|
+
</svg>`, Un = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7245
7252
|
<path d="M38.06 20.44c0-1.34-.12-2.63-.34-3.87H20.5v7.32h9.84c-.42 2.28-1.71 4.21-3.65 5.51v4.57h5.91c3.46-3.19 5.46-7.88 5.46-13.53z" fill="#4285F4"/>
|
|
7246
7253
|
<path d="M20.5 38.5c4.94 0 9.09-1.64 12.12-4.44l-5.91-4.57c-1.64 1.1-3.73 1.75-6.21 1.75-4.77 0-8.82-3.22-10.26-7.55H4.16v4.72A18.49 18.49 0 0 0 20.5 38.5z" fill="#34A853"/>
|
|
7247
7254
|
<path d="M10.24 23.69A11.16 11.16 0 0 1 9.66 20c0-1.28.22-2.52.58-3.69v-4.72H4.16A18.49 18.49 0 0 0 2 20c0 2.97.71 5.78 1.97 8.28l6.27-4.59z" fill="#FBBC05"/>
|
|
7248
7255
|
<path d="M20.5 8.76c2.69 0 5.1.92 7 2.73l5.24-5.24C29.58 3.36 25.43 1.5 20.5 1.5A18.49 18.49 0 0 0 4.16 11.59l6.08 4.72C11.68 11.98 15.73 8.76 20.5 8.76z" fill="#EA4335"/>
|
|
7249
7256
|
</svg>`;
|
|
7250
|
-
function
|
|
7257
|
+
function Hn(r) {
|
|
7251
7258
|
const e = r, s = document.createElement("div");
|
|
7252
7259
|
return s.id = te, s.innerHTML = `
|
|
7253
7260
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7262,11 +7269,11 @@ function Un(r) {
|
|
|
7262
7269
|
<div class="__crossx-body">
|
|
7263
7270
|
<div class="__crossx-login-btn-row">
|
|
7264
7271
|
<button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
|
|
7265
|
-
<span class="__crossx-login-icon" style="color:var(--cx-value);">${
|
|
7272
|
+
<span class="__crossx-login-icon" style="color:var(--cx-value);">${Bn}</span>
|
|
7266
7273
|
<span class="__crossx-login-btn-label">Sign in with Apple</span>
|
|
7267
7274
|
</button>
|
|
7268
7275
|
<button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
|
|
7269
|
-
<span class="__crossx-login-icon">${
|
|
7276
|
+
<span class="__crossx-login-icon">${Un}</span>
|
|
7270
7277
|
<span class="__crossx-login-btn-label">Sign in with Google</span>
|
|
7271
7278
|
</button>
|
|
7272
7279
|
</div>
|
|
@@ -7278,7 +7285,7 @@ function Un(r) {
|
|
|
7278
7285
|
</div>
|
|
7279
7286
|
`, s;
|
|
7280
7287
|
}
|
|
7281
|
-
function
|
|
7288
|
+
function Fn(r) {
|
|
7282
7289
|
const e = r, s = document.createElement("div");
|
|
7283
7290
|
return s.id = te, s.innerHTML = `
|
|
7284
7291
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7294,7 +7301,7 @@ function Hn(r) {
|
|
|
7294
7301
|
<p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
|
|
7295
7302
|
</div>
|
|
7296
7303
|
<button class="__crossx-recover-btn" id="__crossx-recover-btn">
|
|
7297
|
-
<span class="__crossx-recover-icon">${
|
|
7304
|
+
<span class="__crossx-recover-icon">${En}</span>
|
|
7298
7305
|
<span class="__crossx-recover-label">Import from Social Backup</span>
|
|
7299
7306
|
</button>
|
|
7300
7307
|
<button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>
|
|
@@ -7302,7 +7309,7 @@ function Hn(r) {
|
|
|
7302
7309
|
</div>
|
|
7303
7310
|
`, s;
|
|
7304
7311
|
}
|
|
7305
|
-
function
|
|
7312
|
+
function Gn(r, e) {
|
|
7306
7313
|
const s = r, { errorMessage: t, attemptCount: n, maxAttempts: o = 5 } = e ?? {}, i = !!t, a = i ? " --error" : "", c = n != null && n > 0 ? `<p class="__crossx-pin-attempt">${n}/${o}</p>` : "", l = n != null && n >= 3 ? '<p class="__crossx-pin-warning">Your account will be locked after further failures.</p>' : "", d = i ? `<p class="__crossx-pin-error-text">${t}</p>` : "", h = document.createElement("div");
|
|
7307
7314
|
return h.id = te, h.innerHTML = `
|
|
7308
7315
|
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7326,12 +7333,12 @@ function Fn(r, e) {
|
|
|
7326
7333
|
</div>
|
|
7327
7334
|
`, h;
|
|
7328
7335
|
}
|
|
7329
|
-
function
|
|
7336
|
+
function Wn(r) {
|
|
7330
7337
|
const e = new Date(r), s = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], t = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], n = s[e.getDay()], o = t[e.getMonth()], i = e.getDate(), a = String(e.getHours()).padStart(2, "0"), c = String(e.getMinutes()).padStart(2, "0");
|
|
7331
7338
|
return `${n}, ${o} ${i} ${a}:${c}`;
|
|
7332
7339
|
}
|
|
7333
|
-
function
|
|
7334
|
-
const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ?
|
|
7340
|
+
function qn(r, e, s) {
|
|
7341
|
+
const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ? Wn(o) : null, a = document.createElement("div");
|
|
7335
7342
|
return a.id = te, a.innerHTML = `
|
|
7336
7343
|
<div class="__crossx-card __crossx-card--migration" style="${ce(t)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7337
7344
|
<div class="__crossx-header">
|
|
@@ -7361,10 +7368,10 @@ function Wn(r, e, s) {
|
|
|
7361
7368
|
return () => clearInterval(h);
|
|
7362
7369
|
} };
|
|
7363
7370
|
}
|
|
7364
|
-
function
|
|
7371
|
+
function Kn(r) {
|
|
7365
7372
|
const s = [r.check1, r.check2].map((t, n) => `
|
|
7366
7373
|
<div class="__crossx-pw-notice-item" data-check-index="${n}" role="checkbox" aria-checked="false" tabindex="0">
|
|
7367
|
-
<div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${
|
|
7374
|
+
<div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${jn}</div>
|
|
7368
7375
|
<span class="__crossx-pw-notice-item-text">${U(t)}</span>
|
|
7369
7376
|
</div>
|
|
7370
7377
|
`).join("");
|
|
@@ -7379,7 +7386,7 @@ function qn(r) {
|
|
|
7379
7386
|
<div class="__crossx-pw-fields __crossx-pw-fields--notice">
|
|
7380
7387
|
<div class="__crossx-pw-notice-header">
|
|
7381
7388
|
<div class="__crossx-pw-notice-title-row">
|
|
7382
|
-
<span class="__crossx-pw-notice-icon">${
|
|
7389
|
+
<span class="__crossx-pw-notice-icon">${Yn}</span>
|
|
7383
7390
|
<p class="__crossx-pw-notice-title">${U(r.noticeTitle)}</p>
|
|
7384
7391
|
</div>
|
|
7385
7392
|
<p class="__crossx-pw-notice-desc">${U(r.noticeDesc)}</p>
|
|
@@ -7397,9 +7404,9 @@ function qn(r) {
|
|
|
7397
7404
|
<div class="__crossx-home-indicator"></div>
|
|
7398
7405
|
`;
|
|
7399
7406
|
}
|
|
7400
|
-
function
|
|
7407
|
+
function nt(r) {
|
|
7401
7408
|
const e = !!r.lockExpiresAt && r.lockExpiresAt > Date.now(), s = r.lockExpiresAt ? ` data-lock-expires="${r.lockExpiresAt}"` : "", t = r.headerSubtitle ? `<p class="__crossx-pin6-header-sub">${U(r.headerSubtitle)}</p>` : "", n = r.subtitle ? `<p class="__crossx-pin6-subtitle">${U(r.subtitle)}</p>` : "", o = r.errorMessage ? `<p class="__crossx-pin6-error" id="__crossx-pin6-error">${U(r.errorMessage)}</p>` : '<p class="__crossx-pin6-error" id="__crossx-pin6-error"></p>', i = e ? `<p class="__crossx-pin6-lock-msg" id="__crossx-pin6-lock-msg">
|
|
7402
|
-
${
|
|
7409
|
+
${Cs}
|
|
7403
7410
|
<span id="__crossx-pin6-lock-countdown"></span>
|
|
7404
7411
|
</p>` : "", a = e ? " --locked" : "", c = Array.from(
|
|
7405
7412
|
{ length: 6 },
|
|
@@ -7423,7 +7430,7 @@ function rt(r) {
|
|
|
7423
7430
|
<div class="__crossx-home-indicator"></div>
|
|
7424
7431
|
`;
|
|
7425
7432
|
}
|
|
7426
|
-
function
|
|
7433
|
+
function Xt(r, e) {
|
|
7427
7434
|
const s = document.createElement("div");
|
|
7428
7435
|
return s.id = te, s.innerHTML = `
|
|
7429
7436
|
<div class="__crossx-card __crossx-card--pin6" style="${ce(r)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7431,18 +7438,18 @@ function Zt(r, e) {
|
|
|
7431
7438
|
</div>
|
|
7432
7439
|
`, s;
|
|
7433
7440
|
}
|
|
7434
|
-
function
|
|
7441
|
+
function Vn(r, e) {
|
|
7435
7442
|
if (r.length !== 6) return e.tooShort;
|
|
7436
7443
|
if (!/^\d+$/.test(r)) return e.numbersOnly;
|
|
7437
7444
|
if (/(.)\1{2}/.test(r)) return e.repeatingDigit;
|
|
7438
7445
|
const s = r.split("").map(Number), t = s.every((o, i) => i === 0 || o === (s[i - 1] + 1) % 10), n = s.every((o, i) => i === 0 || o === (s[i - 1] + 9) % 10);
|
|
7439
7446
|
return t || n ? e.sequential : r[0] !== r[1] && r === r.slice(0, 2).repeat(3) ? e.alternatingPattern : null;
|
|
7440
7447
|
}
|
|
7441
|
-
function
|
|
7448
|
+
function zn(r) {
|
|
7442
7449
|
const e = Math.max(0, Math.ceil(r / 1e3)), s = Math.floor(e / 3600), t = Math.floor(e % 3600 / 60), n = e % 60;
|
|
7443
7450
|
return s > 0 ? `${s}h ${String(t).padStart(2, "0")}m` : `${String(t).padStart(2, "0")}:${String(n).padStart(2, "0")}`;
|
|
7444
7451
|
}
|
|
7445
|
-
function
|
|
7452
|
+
function ot(r, e, s, t, n, o) {
|
|
7446
7453
|
let i = !!(o && o > Date.now()), a = !1;
|
|
7447
7454
|
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), d = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), m = () => r.querySelector("#__crossx-pin6-lock-countdown"), x = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((b) => b.value).join(""), E = (b) => {
|
|
7448
7455
|
i = b, c().forEach((k) => {
|
|
@@ -7461,7 +7468,7 @@ function nt(r, e, s, t, n, o) {
|
|
|
7461
7468
|
var G;
|
|
7462
7469
|
return (G = c()[0]) == null ? void 0 : G.focus();
|
|
7463
7470
|
}, 50);
|
|
7464
|
-
},
|
|
7471
|
+
}, C = (b) => {
|
|
7465
7472
|
var W;
|
|
7466
7473
|
E(!0), c().forEach((q) => {
|
|
7467
7474
|
q.value = "";
|
|
@@ -7469,7 +7476,7 @@ function nt(r, e, s, t, n, o) {
|
|
|
7469
7476
|
const k = d();
|
|
7470
7477
|
if (k && (k.textContent = "Too many failed attempts. Please wait."), !h()) {
|
|
7471
7478
|
const q = document.createElement("p");
|
|
7472
|
-
q.className = "__crossx-pin6-lock-msg", q.id = "__crossx-pin6-lock-msg", q.innerHTML = `${
|
|
7479
|
+
q.className = "__crossx-pin6-lock-msg", q.id = "__crossx-pin6-lock-msg", q.innerHTML = `${Cs}<span id="__crossx-pin6-lock-countdown"></span>`;
|
|
7473
7480
|
const D = d();
|
|
7474
7481
|
D ? D.insertAdjacentElement("afterend", q) : (W = x()) == null || W.appendChild(q);
|
|
7475
7482
|
}
|
|
@@ -7477,9 +7484,9 @@ function nt(r, e, s, t, n, o) {
|
|
|
7477
7484
|
var R;
|
|
7478
7485
|
const q = b - Date.now(), D = m();
|
|
7479
7486
|
q <= 0 ? (clearInterval(G), E(!1), (R = h()) == null || R.remove(), k && (k.textContent = ""), setTimeout(() => {
|
|
7480
|
-
var
|
|
7481
|
-
return (
|
|
7482
|
-
}, 50)) : D && (D.textContent = ` ${
|
|
7487
|
+
var N;
|
|
7488
|
+
return (N = c()[0]) == null ? void 0 : N.focus();
|
|
7489
|
+
}, 50)) : D && (D.textContent = ` ${zn(q)}`);
|
|
7483
7490
|
}, G = setInterval(P, 1e3);
|
|
7484
7491
|
P();
|
|
7485
7492
|
const z = new MutationObserver(() => {
|
|
@@ -7496,7 +7503,7 @@ function nt(r, e, s, t, n, o) {
|
|
|
7496
7503
|
try {
|
|
7497
7504
|
if (n) {
|
|
7498
7505
|
const k = await n(b);
|
|
7499
|
-
k.ok ? e(b) : k.lockExpiresAt ?
|
|
7506
|
+
k.ok ? e(b) : k.lockExpiresAt ? C(k.lockExpiresAt) : S(k.error ?? "Incorrect PIN. Please try again.");
|
|
7500
7507
|
} else
|
|
7501
7508
|
e(b);
|
|
7502
7509
|
} catch (k) {
|
|
@@ -7508,7 +7515,7 @@ function nt(r, e, s, t, n, o) {
|
|
|
7508
7515
|
}
|
|
7509
7516
|
}
|
|
7510
7517
|
};
|
|
7511
|
-
o && o > Date.now() ?
|
|
7518
|
+
o && o > Date.now() ? C(o) : setTimeout(() => {
|
|
7512
7519
|
var b;
|
|
7513
7520
|
return (b = c()[0]) == null ? void 0 : b.focus();
|
|
7514
7521
|
}, 100), c().forEach((b, k) => {
|
|
@@ -7538,14 +7545,14 @@ function nt(r, e, s, t, n, o) {
|
|
|
7538
7545
|
}), b.addEventListener("focus", () => b.select());
|
|
7539
7546
|
});
|
|
7540
7547
|
}
|
|
7541
|
-
const
|
|
7548
|
+
const Cs = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7542
7549
|
<path d="M14.5 8.5H14V6.5C14 4.015 11.985 2 9.5 2C7.015 2 5 4.015 5 6.5V8.5H4.5C3.672 8.5 3 9.172 3 10V16.5C3 17.328 3.672 18 4.5 18H14.5C15.328 18 16 17.328 16 16.5V10C16 9.172 15.328 8.5 14.5 8.5ZM10.5 13.415V15C10.5 15.276 10.276 15.5 10 15.5H9C8.724 15.5 8.5 15.276 8.5 15V13.415C8.187 13.196 8 12.847 8 12.5C8 11.672 8.672 11 9.5 11C10.328 11 11 11.672 11 12.5C11 12.847 10.813 13.196 10.5 13.415ZM12.5 8.5H6.5V6.5C6.5 4.843 7.843 3.5 9.5 3.5C11.157 3.5 12.5 4.843 12.5 6.5V8.5Z" fill="currentColor"/>
|
|
7543
|
-
</svg>`,
|
|
7550
|
+
</svg>`, jn = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7544
7551
|
<path d="M1 4.5L4 7.5L10 1" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
7545
|
-
</svg>`,
|
|
7552
|
+
</svg>`, Yn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7546
7553
|
<path d="M12 0C18.6274 0 24 5.37258 24 12C23.9999 18.6273 18.6274 24 12 24C5.37264 24 9.89594e-05 18.6273 0 12C0 5.37258 5.37258 0 12 0ZM10.875 15.127V17.377H13.125V15.127H10.875ZM10.875 6.62207V13.627H13.125V6.62207H10.875Z" fill="currentColor"/>
|
|
7547
7554
|
</svg>`;
|
|
7548
|
-
function
|
|
7555
|
+
function Jn(r, e, s) {
|
|
7549
7556
|
var n;
|
|
7550
7557
|
const t = r.querySelectorAll(".__crossx-pin-input");
|
|
7551
7558
|
t.forEach((o, i) => {
|
|
@@ -7571,12 +7578,12 @@ function Yn(r, e, s) {
|
|
|
7571
7578
|
});
|
|
7572
7579
|
}), (n = t[0]) == null || n.focus();
|
|
7573
7580
|
}
|
|
7574
|
-
class
|
|
7581
|
+
class Zn {
|
|
7575
7582
|
constructor(e = "light", s) {
|
|
7576
|
-
this.theme = e, this.overrides = s, this.tokens =
|
|
7583
|
+
this.theme = e, this.overrides = s, this.tokens = Jt(e, s);
|
|
7577
7584
|
}
|
|
7578
7585
|
setTheme(e, s) {
|
|
7579
|
-
this.theme = e, s !== void 0 && (this.overrides = s), this.tokens =
|
|
7586
|
+
this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = Jt(e, this.overrides);
|
|
7580
7587
|
}
|
|
7581
7588
|
setMessages(e) {
|
|
7582
7589
|
this.messages = e;
|
|
@@ -7593,8 +7600,8 @@ class Jn {
|
|
|
7593
7600
|
return new Promise((n) => {
|
|
7594
7601
|
var E;
|
|
7595
7602
|
he();
|
|
7596
|
-
const o = [...e], i =
|
|
7597
|
-
document.body.style.overflow = "hidden",
|
|
7603
|
+
const o = [...e], i = $n(o, this.tokens, t), a = document.body.style.overflow;
|
|
7604
|
+
document.body.style.overflow = "hidden", pe(i);
|
|
7598
7605
|
let c = !1;
|
|
7599
7606
|
const l = () => {
|
|
7600
7607
|
c || (c = !0, i.remove(), document.body.style.overflow = a);
|
|
@@ -7606,8 +7613,8 @@ class Jn {
|
|
|
7606
7613
|
(() => {
|
|
7607
7614
|
i.querySelectorAll(".__crossx-wallet-item").forEach((y) => {
|
|
7608
7615
|
y.addEventListener("click", () => {
|
|
7609
|
-
const S = y.dataset.walletAddress ?? "",
|
|
7610
|
-
d({ address: S, index:
|
|
7616
|
+
const S = y.dataset.walletAddress ?? "", C = parseInt(y.dataset.walletIndex ?? "0", 10);
|
|
7617
|
+
d({ address: S, index: C });
|
|
7611
7618
|
});
|
|
7612
7619
|
});
|
|
7613
7620
|
})();
|
|
@@ -7619,8 +7626,8 @@ class Jn {
|
|
|
7619
7626
|
o.push(y);
|
|
7620
7627
|
const S = i.querySelector("#__crossx-wallet-list");
|
|
7621
7628
|
if (S) {
|
|
7622
|
-
const
|
|
7623
|
-
|
|
7629
|
+
const C = document.createElement("button");
|
|
7630
|
+
C.className = "__crossx-wallet-item", C.dataset.walletIndex = String(y.index), C.dataset.walletAddress = y.address, C.innerHTML = `<span class="__crossx-wallet-addr">${se(y.address)}</span>`, C.addEventListener("click", () => d(y)), S.appendChild(C), C.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
7624
7631
|
}
|
|
7625
7632
|
} catch {
|
|
7626
7633
|
} finally {
|
|
@@ -7644,8 +7651,8 @@ class Jn {
|
|
|
7644
7651
|
return new Promise((e) => {
|
|
7645
7652
|
var a, c, l;
|
|
7646
7653
|
he();
|
|
7647
|
-
const s =
|
|
7648
|
-
|
|
7654
|
+
const s = Hn(this.tokens);
|
|
7655
|
+
pe(s);
|
|
7649
7656
|
const t = () => s.remove(), n = (d) => {
|
|
7650
7657
|
t(), e(d);
|
|
7651
7658
|
}, o = () => {
|
|
@@ -7670,8 +7677,8 @@ class Jn {
|
|
|
7670
7677
|
return new Promise((e) => {
|
|
7671
7678
|
var a, c, l;
|
|
7672
7679
|
he();
|
|
7673
|
-
const s =
|
|
7674
|
-
|
|
7680
|
+
const s = Fn(this.tokens);
|
|
7681
|
+
pe(s);
|
|
7675
7682
|
const t = () => s.remove(), n = () => {
|
|
7676
7683
|
t(), e("recover");
|
|
7677
7684
|
}, o = () => {
|
|
@@ -7713,13 +7720,13 @@ class Jn {
|
|
|
7713
7720
|
}, i = {
|
|
7714
7721
|
title: (t == null ? void 0 : t.pinSetup_confirmTitle) ?? "Confirm PIN",
|
|
7715
7722
|
headerSubtitle: (t == null ? void 0 : t.pinSetup_confirmSubtitle) ?? "Enter your PIN again to confirm."
|
|
7716
|
-
}, a =
|
|
7717
|
-
document.body.style.overflow = "hidden",
|
|
7723
|
+
}, a = Xt(this.tokens, Kn(n)), c = document.body.style.overflow;
|
|
7724
|
+
document.body.style.overflow = "hidden", pe(a);
|
|
7718
7725
|
let l = !1;
|
|
7719
7726
|
const d = () => {
|
|
7720
7727
|
l || (l = !0, a.remove(), document.body.style.overflow = c);
|
|
7721
|
-
}, h = (
|
|
7722
|
-
d(), s(
|
|
7728
|
+
}, h = (C) => {
|
|
7729
|
+
d(), s(C);
|
|
7723
7730
|
}, m = () => {
|
|
7724
7731
|
d(), s(null);
|
|
7725
7732
|
}, x = a.querySelector(".__crossx-card"), w = {
|
|
@@ -7728,56 +7735,56 @@ class Jn {
|
|
|
7728
7735
|
repeatingDigit: (t == null ? void 0 : t.pinValidation_repeatingDigit) ?? "Cannot use the same number 3+ times in a row.",
|
|
7729
7736
|
sequential: (t == null ? void 0 : t.pinValidation_sequential) ?? "Sequential numbers (e.g., 123456) are not allowed.",
|
|
7730
7737
|
alternatingPattern: (t == null ? void 0 : t.pinValidation_alternatingPattern) ?? "Repeating patterns (e.g., 121212) are not allowed."
|
|
7731
|
-
}, E = (
|
|
7738
|
+
}, E = (C) => {
|
|
7732
7739
|
var B;
|
|
7733
|
-
x.innerHTML =
|
|
7740
|
+
x.innerHTML = nt({
|
|
7734
7741
|
title: i.title,
|
|
7735
7742
|
headerSubtitle: i.headerSubtitle
|
|
7736
|
-
}), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m),
|
|
7737
|
-
b ===
|
|
7743
|
+
}), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), ot(x, (b) => {
|
|
7744
|
+
b === C ? h(C) : y(o.mismatchError);
|
|
7738
7745
|
}, m);
|
|
7739
|
-
}, y = (
|
|
7746
|
+
}, y = (C) => {
|
|
7740
7747
|
var B;
|
|
7741
|
-
x.innerHTML =
|
|
7748
|
+
x.innerHTML = nt({
|
|
7742
7749
|
title: o.title,
|
|
7743
7750
|
headerSubtitle: o.headerSubtitle,
|
|
7744
7751
|
subtitle: o.subtitle,
|
|
7745
|
-
errorMessage:
|
|
7746
|
-
}), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m),
|
|
7747
|
-
const k =
|
|
7752
|
+
errorMessage: C
|
|
7753
|
+
}), (B = x.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", m), ot(x, (b) => {
|
|
7754
|
+
const k = Vn(b, w);
|
|
7748
7755
|
k ? y(k) : E(b);
|
|
7749
7756
|
}, m);
|
|
7750
7757
|
};
|
|
7751
7758
|
(() => {
|
|
7752
7759
|
var q;
|
|
7753
|
-
const
|
|
7760
|
+
const C = Array.from(x.querySelectorAll(".__crossx-pw-notice-item")), B = x.querySelector("#__crossx-pin-notice-next"), b = /* @__PURE__ */ new Set();
|
|
7754
7761
|
B.removeAttribute("disabled");
|
|
7755
7762
|
const k = B.dataset.nextLabel ?? "Next", P = B.dataset.submitLabel ?? "I Understand", G = () => {
|
|
7756
|
-
const D = b.size ===
|
|
7763
|
+
const D = b.size === C.length;
|
|
7757
7764
|
B.classList.toggle("--disabled", !D), B.textContent = D ? P : k;
|
|
7758
7765
|
}, z = (D, R) => {
|
|
7759
7766
|
if (b.has(R)) return;
|
|
7760
|
-
const
|
|
7761
|
-
b.add(R),
|
|
7767
|
+
const N = D.querySelector(`#__crossx-notice-check-${R}`);
|
|
7768
|
+
b.add(R), N.classList.add("--checked"), D.setAttribute("aria-checked", "true"), G();
|
|
7762
7769
|
}, W = (D, R) => {
|
|
7763
7770
|
if (!b.has(R)) return;
|
|
7764
|
-
const
|
|
7765
|
-
b.delete(R),
|
|
7771
|
+
const N = D.querySelector(`#__crossx-notice-check-${R}`);
|
|
7772
|
+
b.delete(R), N.classList.remove("--checked"), D.setAttribute("aria-checked", "false"), G();
|
|
7766
7773
|
};
|
|
7767
|
-
|
|
7774
|
+
C.forEach((D) => {
|
|
7768
7775
|
const R = parseInt(D.dataset.checkIndex ?? "0", 10);
|
|
7769
7776
|
D.addEventListener("click", () => {
|
|
7770
7777
|
b.has(R) ? W(D, R) : z(D, R);
|
|
7771
|
-
}), D.addEventListener("keydown", (
|
|
7772
|
-
(
|
|
7778
|
+
}), D.addEventListener("keydown", (N) => {
|
|
7779
|
+
(N.key === " " || N.key === "Enter") && (N.preventDefault(), b.has(R) ? W(D, R) : z(D, R));
|
|
7773
7780
|
});
|
|
7774
7781
|
}), B.addEventListener("click", () => {
|
|
7775
|
-
if (b.size ===
|
|
7782
|
+
if (b.size === C.length) {
|
|
7776
7783
|
y(e == null ? void 0 : e.errorMessage);
|
|
7777
7784
|
return;
|
|
7778
7785
|
}
|
|
7779
|
-
const D =
|
|
7780
|
-
const f = parseInt(
|
|
7786
|
+
const D = C.find((N) => {
|
|
7787
|
+
const f = parseInt(N.dataset.checkIndex ?? "0", 10);
|
|
7781
7788
|
return !b.has(f);
|
|
7782
7789
|
});
|
|
7783
7790
|
if (!D) return;
|
|
@@ -7786,8 +7793,8 @@ class Jn {
|
|
|
7786
7793
|
D.classList.remove("--highlight"), z(D, R);
|
|
7787
7794
|
}, 400);
|
|
7788
7795
|
}), (q = x.querySelector("#__crossx-close-btn")) == null || q.addEventListener("click", m);
|
|
7789
|
-
})(), a.addEventListener("click", (
|
|
7790
|
-
|
|
7796
|
+
})(), a.addEventListener("click", (C) => {
|
|
7797
|
+
C.target === a && m();
|
|
7791
7798
|
});
|
|
7792
7799
|
});
|
|
7793
7800
|
}
|
|
@@ -7800,16 +7807,16 @@ class Jn {
|
|
|
7800
7807
|
return new Promise((s, t) => {
|
|
7801
7808
|
var y;
|
|
7802
7809
|
he();
|
|
7803
|
-
const n = this.messages, o = (e == null ? void 0 : e.verifyMode) === !0, i = o ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = o ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c =
|
|
7810
|
+
const n = this.messages, o = (e == null ? void 0 : e.verifyMode) === !0, i = o ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = o ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c = Xt(
|
|
7804
7811
|
this.tokens,
|
|
7805
|
-
|
|
7812
|
+
nt({
|
|
7806
7813
|
title: i,
|
|
7807
7814
|
headerSubtitle: a,
|
|
7808
7815
|
errorMessage: e == null ? void 0 : e.errorMessage,
|
|
7809
7816
|
lockExpiresAt: e == null ? void 0 : e.lockExpiresAt
|
|
7810
7817
|
})
|
|
7811
7818
|
), l = document.body.style.overflow;
|
|
7812
|
-
document.body.style.overflow = "hidden",
|
|
7819
|
+
document.body.style.overflow = "hidden", pe(c);
|
|
7813
7820
|
let d = !1;
|
|
7814
7821
|
const h = () => {
|
|
7815
7822
|
d || (d = !0, c.remove(), document.body.style.overflow = l);
|
|
@@ -7820,7 +7827,7 @@ class Jn {
|
|
|
7820
7827
|
}, w = (S) => {
|
|
7821
7828
|
h(), t(S);
|
|
7822
7829
|
}, E = c.querySelector(".__crossx-card");
|
|
7823
|
-
(y = E.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", x),
|
|
7830
|
+
(y = E.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", x), ot(E, m, x, w, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt), c.addEventListener("click", (S) => {
|
|
7824
7831
|
S.target === c && x();
|
|
7825
7832
|
});
|
|
7826
7833
|
});
|
|
@@ -7836,14 +7843,14 @@ class Jn {
|
|
|
7836
7843
|
return new Promise((s) => {
|
|
7837
7844
|
var a;
|
|
7838
7845
|
he();
|
|
7839
|
-
const t =
|
|
7840
|
-
|
|
7846
|
+
const t = Gn(this.tokens, e);
|
|
7847
|
+
pe(t);
|
|
7841
7848
|
const n = () => t.remove(), o = (c) => {
|
|
7842
7849
|
n(), s(c);
|
|
7843
7850
|
}, i = () => {
|
|
7844
7851
|
n(), s(null);
|
|
7845
7852
|
};
|
|
7846
|
-
|
|
7853
|
+
Jn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
|
|
7847
7854
|
c.target === t && i();
|
|
7848
7855
|
});
|
|
7849
7856
|
});
|
|
@@ -7858,8 +7865,8 @@ class Jn {
|
|
|
7858
7865
|
return new Promise((t) => {
|
|
7859
7866
|
var l;
|
|
7860
7867
|
he();
|
|
7861
|
-
const { overlay: n, startCountdown: o } =
|
|
7862
|
-
|
|
7868
|
+
const { overlay: n, startCountdown: o } = qn(this.tokens, e, s);
|
|
7869
|
+
pe(n);
|
|
7863
7870
|
const i = () => {
|
|
7864
7871
|
c(), n.remove();
|
|
7865
7872
|
}, a = () => {
|
|
@@ -7878,8 +7885,8 @@ class Jn {
|
|
|
7878
7885
|
return new Promise((s) => {
|
|
7879
7886
|
var a, c;
|
|
7880
7887
|
he();
|
|
7881
|
-
const t =
|
|
7882
|
-
|
|
7888
|
+
const t = Nn(e, this.tokens);
|
|
7889
|
+
pe(t);
|
|
7883
7890
|
const n = () => t.remove(), o = () => {
|
|
7884
7891
|
n(), s();
|
|
7885
7892
|
};
|
|
@@ -7907,8 +7914,8 @@ class Jn {
|
|
|
7907
7914
|
showTransactionProgress(e, s) {
|
|
7908
7915
|
return new Promise((t) => {
|
|
7909
7916
|
he();
|
|
7910
|
-
const n =
|
|
7911
|
-
|
|
7917
|
+
const n = On(e, this.tokens);
|
|
7918
|
+
pe(n);
|
|
7912
7919
|
const o = () => n.remove();
|
|
7913
7920
|
let i = !1;
|
|
7914
7921
|
const a = () => {
|
|
@@ -7924,7 +7931,7 @@ class Jn {
|
|
|
7924
7931
|
document.addEventListener("keydown", l);
|
|
7925
7932
|
};
|
|
7926
7933
|
s.then((l) => {
|
|
7927
|
-
i || (
|
|
7934
|
+
i || (Cn(n, l, this.tokens), c());
|
|
7928
7935
|
});
|
|
7929
7936
|
});
|
|
7930
7937
|
}
|
|
@@ -7933,7 +7940,7 @@ class Jn {
|
|
|
7933
7940
|
var c, l, d;
|
|
7934
7941
|
he();
|
|
7935
7942
|
let t;
|
|
7936
|
-
e.type === "sign-message" ? t =
|
|
7943
|
+
e.type === "sign-message" ? t = Ln(e, this.tokens) : e.type === "sign-typed-data" ? t = Dn(e, this.tokens) : e.type === "sign" ? t = An(e, this.tokens) : t = Rn(e, this.tokens), pe(t);
|
|
7937
7944
|
const n = () => t.remove(), o = () => {
|
|
7938
7945
|
n(), s(!0);
|
|
7939
7946
|
}, i = () => {
|
|
@@ -7957,7 +7964,7 @@ class Jn {
|
|
|
7957
7964
|
});
|
|
7958
7965
|
}
|
|
7959
7966
|
}
|
|
7960
|
-
class
|
|
7967
|
+
class Xn {
|
|
7961
7968
|
constructor() {
|
|
7962
7969
|
this._accessToken = null, this._expiresAt = 0;
|
|
7963
7970
|
}
|
|
@@ -7980,9 +7987,9 @@ class Zn {
|
|
|
7980
7987
|
return this.get() !== null;
|
|
7981
7988
|
}
|
|
7982
7989
|
}
|
|
7983
|
-
function
|
|
7990
|
+
function so(r, e) {
|
|
7984
7991
|
r.debug;
|
|
7985
|
-
const s =
|
|
7992
|
+
const s = Ge.production, t = {
|
|
7986
7993
|
...r,
|
|
7987
7994
|
oauthServiceUrl: s.oauthServiceUrl,
|
|
7988
7995
|
authApiUrl: s.authApiUrl,
|
|
@@ -7990,23 +7997,23 @@ function to(r, e) {
|
|
|
7990
7997
|
}, n = {
|
|
7991
7998
|
gatewayUrl: s.walletGatewayUrl,
|
|
7992
7999
|
projectId: r.projectId
|
|
7993
|
-
}, o = t.authMode !== "cookie" &&
|
|
8000
|
+
}, o = t.authMode !== "cookie" && Ot.isAvailable();
|
|
7994
8001
|
!o && t.authMode !== "cookie" && u.warn(
|
|
7995
8002
|
"[CROSSx] IndexedDB 사용 불가 — LocalStorage fallback 사용 중.",
|
|
7996
8003
|
"refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
|
|
7997
8004
|
"IndexedDB를 지원하는 브라우저 사용을 권장합니다."
|
|
7998
8005
|
), t.secureStorageAvailable = o;
|
|
7999
|
-
const i = o ? new
|
|
8006
|
+
const i = o ? new Ot(r.projectId) : new rr(), a = new hn(), c = new xn(), l = new be(), d = new Xn(), h = new es();
|
|
8000
8007
|
let m;
|
|
8001
|
-
r.useMockWallet ? (u.log("[CROSSx] Mock Wallet Provider 사용"), m = new
|
|
8008
|
+
r.useMockWallet ? (u.log("[CROSSx] Mock Wallet Provider 사용"), m = new mn(i, h)) : (u.log("[CROSSx] Remote Wallet Provider 사용"), m = new Le(
|
|
8002
8009
|
n,
|
|
8003
8010
|
i,
|
|
8004
8011
|
c,
|
|
8005
8012
|
d,
|
|
8006
8013
|
h
|
|
8007
8014
|
));
|
|
8008
|
-
const x = new
|
|
8009
|
-
return new
|
|
8015
|
+
const x = new De(n, c), w = new Zn(r.theme ?? "light", r.themeTokens), E = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w;
|
|
8016
|
+
return new it(
|
|
8010
8017
|
t,
|
|
8011
8018
|
n,
|
|
8012
8019
|
i,
|
|
@@ -8022,9 +8029,9 @@ function to(r, e) {
|
|
|
8022
8029
|
}
|
|
8023
8030
|
export {
|
|
8024
8031
|
g as CROSSxError,
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8032
|
+
Fs as CROSSxEthereumProvider,
|
|
8033
|
+
it as CROSSxSDK,
|
|
8034
|
+
to as ChainId,
|
|
8028
8035
|
p as ErrorCode,
|
|
8029
|
-
|
|
8036
|
+
so as createCROSSxSDK
|
|
8030
8037
|
};
|