@nexus-cross/crossx-sdk-core 1.0.2 → 1.0.4
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/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var v = (r, e, s) =>
|
|
1
|
+
var Is = Object.defineProperty;
|
|
2
|
+
var Ts = (r, e, s) => e in r ? Is(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
|
|
3
|
+
var v = (r, e, s) => Ts(r, typeof e != "symbol" ? e + "" : e, s);
|
|
4
4
|
import { decodeJwt as As } from "jose";
|
|
5
|
-
var
|
|
5
|
+
var g = /* @__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.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.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", 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.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(g || {});
|
|
6
6
|
class _ extends Error {
|
|
7
7
|
constructor(e, s, t) {
|
|
8
8
|
super(s), this.code = e, this.details = t, this.name = "CROSSxError", Object.setPrototypeOf(this, _.prototype);
|
|
@@ -107,7 +107,7 @@ class Cs {
|
|
|
107
107
|
case "personal_sign":
|
|
108
108
|
case "eth_sign":
|
|
109
109
|
throw new _(
|
|
110
|
-
|
|
110
|
+
g.NOT_IMPLEMENTED,
|
|
111
111
|
`${e} is not yet supported. Use sdk.signMessage() directly.`
|
|
112
112
|
);
|
|
113
113
|
case "eth_signTypedData":
|
|
@@ -115,7 +115,7 @@ class Cs {
|
|
|
115
115
|
case "eth_signTypedData_v3":
|
|
116
116
|
case "eth_signTypedData_v4":
|
|
117
117
|
throw new _(
|
|
118
|
-
|
|
118
|
+
g.NOT_IMPLEMENTED,
|
|
119
119
|
`${e} is not yet supported. Use sdk.signTypedData() or sdk.signTypedDataOffchain() directly.`
|
|
120
120
|
);
|
|
121
121
|
default:
|
|
@@ -203,7 +203,7 @@ class ks {
|
|
|
203
203
|
checkResponseError(e, s) {
|
|
204
204
|
if (e != null && e.code && e.code !== 200 && e.code > 0)
|
|
205
205
|
throw new _(
|
|
206
|
-
|
|
206
|
+
g.AUTH_FAILED,
|
|
207
207
|
`${s} failed (code ${e.code}): ${e.message}`
|
|
208
208
|
);
|
|
209
209
|
const t = e == null ? void 0 : e.data;
|
|
@@ -211,7 +211,7 @@ class ks {
|
|
|
211
211
|
const n = t;
|
|
212
212
|
if (n.code && n.code !== 200 && n.code > 0)
|
|
213
213
|
throw new _(
|
|
214
|
-
|
|
214
|
+
g.AUTH_FAILED,
|
|
215
215
|
`${s} failed (code ${n.code}): ${n.message}`
|
|
216
216
|
);
|
|
217
217
|
}
|
|
@@ -223,14 +223,14 @@ class ks {
|
|
|
223
223
|
const c = e == null ? void 0 : e.provider;
|
|
224
224
|
let l = "/login";
|
|
225
225
|
c === "google" ? l = "/google" : c === "apple" && (l = "/apple");
|
|
226
|
-
const { oauthServiceUrl: d, authApiUrl:
|
|
226
|
+
const { oauthServiceUrl: d, authApiUrl: p } = this.config, m = `${d}${l}`;
|
|
227
227
|
f.log(`[CROSSx] OAuth 팝업 열기 (${c || "일반"} 로그인):`, m);
|
|
228
228
|
const x = await this.oauth.openAuth({
|
|
229
229
|
authUrl: m,
|
|
230
230
|
expectedOrigin: new URL(d).origin
|
|
231
231
|
});
|
|
232
232
|
f.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", x.length, ")");
|
|
233
|
-
const { accessToken: w, refreshToken: b } = await this.exchangeFirebaseToken(x,
|
|
233
|
+
const { accessToken: w, refreshToken: b } = await this.exchangeFirebaseToken(x, p);
|
|
234
234
|
let S, E;
|
|
235
235
|
try {
|
|
236
236
|
const B = this.crypto.decodeJWT(x);
|
|
@@ -296,7 +296,7 @@ class ks {
|
|
|
296
296
|
return f.log("[CROSSx] Cookie 모드 — 로그인 성공 (JWT는 HttpOnly 쿠키)"), {};
|
|
297
297
|
if (!a)
|
|
298
298
|
throw new _(
|
|
299
|
-
|
|
299
|
+
g.AUTH_FAILED,
|
|
300
300
|
"access_token not found in exchange response"
|
|
301
301
|
);
|
|
302
302
|
f.log("[CROSSx] access_token 교환 성공");
|
|
@@ -427,7 +427,7 @@ class ks {
|
|
|
427
427
|
return;
|
|
428
428
|
}
|
|
429
429
|
if (!c)
|
|
430
|
-
throw new _(
|
|
430
|
+
throw new _(g.AUTH_FAILED, "Silent refresh failed: no token in response");
|
|
431
431
|
if (this.tokenStore.set(c), !t) {
|
|
432
432
|
await this.storage.set(Ye, c);
|
|
433
433
|
const l = this.extractRefreshToken(a);
|
|
@@ -440,10 +440,10 @@ class ks {
|
|
|
440
440
|
try {
|
|
441
441
|
f.log("[CROSSx][Migration Phase 2] POST /mnemonic/create 호출 — userId:", e.id), t = (await this.walletProvider.getOrCreateWallet(e.id)).address, f.log("[CROSSx][Migration Phase 2] 지갑 로드 완료 (기존 백업 없음) — address:", t);
|
|
442
442
|
} catch (o) {
|
|
443
|
-
if (o instanceof _ && o.code ===
|
|
443
|
+
if (o instanceof _ && o.code === g.MIGRATION_BACKUP_EXISTS)
|
|
444
444
|
f.log("[CROSSx][Migration Phase 2] Gateway -10012 감지 → needsMigration = true"), n = !0;
|
|
445
445
|
else {
|
|
446
|
-
if (o instanceof _ && (o.code ===
|
|
446
|
+
if (o instanceof _ && (o.code === g.PROJECT_NOT_REGISTERED || o.code === g.PROJECT_ID_MISSING || o.code === g.ORIGIN_NOT_ALLOWED))
|
|
447
447
|
throw f.error("[CROSSx][Migration Phase 2] 프로젝트 설정 에러:", o.message), o;
|
|
448
448
|
f.warn("[CROSSx][Migration Phase 2] 지갑 로드 실패 (로그인은 유지):", o);
|
|
449
449
|
}
|
|
@@ -467,7 +467,7 @@ class $s {
|
|
|
467
467
|
async execute(e, s) {
|
|
468
468
|
if (!this.walletProvider.migrateWallet)
|
|
469
469
|
throw new _(
|
|
470
|
-
|
|
470
|
+
g.NOT_IMPLEMENTED,
|
|
471
471
|
"Migration is not supported in the current environment"
|
|
472
472
|
);
|
|
473
473
|
f.log("[CROSSx][Migration Phase 4] MigrateWalletUseCase.execute() — pin 길이:", e.length, "sub:", s);
|
|
@@ -503,7 +503,7 @@ class Ms {
|
|
|
503
503
|
})).data;
|
|
504
504
|
if (a != null && a.error)
|
|
505
505
|
throw new _(
|
|
506
|
-
|
|
506
|
+
g.UNKNOWN_ERROR,
|
|
507
507
|
`RPC error [${e}] (${t}): ${a.error.message} (code: ${a.error.code})`
|
|
508
508
|
);
|
|
509
509
|
return a == null ? void 0 : a.result;
|
|
@@ -571,7 +571,7 @@ async function Fs() {
|
|
|
571
571
|
}
|
|
572
572
|
return Ue.production;
|
|
573
573
|
}
|
|
574
|
-
const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA00", St = 130, Et = 6,
|
|
574
|
+
const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA00", St = 130, Et = 6, It = 18, js = 0, Vs = 30 * 1e3, X = class X extends Bs {
|
|
575
575
|
constructor(e, s, t, n, o, i, a, c, l, d) {
|
|
576
576
|
super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this.authenticated = !1, this.userId = null, this.address = null, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && wt(e.logger), this.confirmation = l, this.chainRegistry = d, this.jsonRpc = new Ms(d, o), this.signInUseCase = new ks(
|
|
577
577
|
this.internalConfig,
|
|
@@ -609,7 +609,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
609
609
|
const s = await this.signInUseCase.restoreSession();
|
|
610
610
|
return s != null && s.success && this.applyAuthResult(s), this.initialized = !0, this.emit("initialized", { restored: !!(s != null && s.success) }), s ?? null;
|
|
611
611
|
} catch (e) {
|
|
612
|
-
throw new _(
|
|
612
|
+
throw new _(g.AUTH_NOT_INITIALIZED, "SDK initialization failed", e);
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
async signIn(e) {
|
|
@@ -625,7 +625,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
625
625
|
const t = await this.signInUseCase.execute(s);
|
|
626
626
|
return t.success && this.applyAuthResult(t), t;
|
|
627
627
|
} catch (t) {
|
|
628
|
-
throw new _(
|
|
628
|
+
throw new _(g.AUTH_FAILED, "Sign in failed", t);
|
|
629
629
|
}
|
|
630
630
|
}
|
|
631
631
|
/**
|
|
@@ -649,18 +649,18 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
649
649
|
const s = await this.signIn(e);
|
|
650
650
|
if (!s.success) return { ...s, addresses: [] };
|
|
651
651
|
if (s.needsMigration || !s.address) {
|
|
652
|
-
const { address:
|
|
653
|
-
return { ...s, address:
|
|
652
|
+
const { address: o } = await this.createWallet(), i = await this.getAddresses(), a = await this.selectWalletIfMultiple(i);
|
|
653
|
+
return { ...s, address: (a == null ? void 0 : a.address) ?? o, needsMigration: !1, addresses: i };
|
|
654
654
|
}
|
|
655
|
-
const t = await this.getAddresses();
|
|
656
|
-
return { ...s, addresses: t };
|
|
655
|
+
const t = await this.getAddresses(), n = await this.selectWalletIfMultiple(t);
|
|
656
|
+
return { ...s, address: (n == null ? void 0 : n.address) ?? s.address, addresses: t };
|
|
657
657
|
}
|
|
658
658
|
async signOut() {
|
|
659
659
|
this.ensureInitialized();
|
|
660
660
|
try {
|
|
661
661
|
await this.signOutUseCase.execute(), this.clearAuthState();
|
|
662
662
|
} catch (e) {
|
|
663
|
-
throw new _(
|
|
663
|
+
throw new _(g.UNKNOWN_ERROR, "Sign out failed", e);
|
|
664
664
|
}
|
|
665
665
|
}
|
|
666
666
|
isAuthenticated() {
|
|
@@ -736,13 +736,13 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
736
736
|
*/
|
|
737
737
|
async migrateWallet(e) {
|
|
738
738
|
if (this.ensureAuthenticated(), !this.userId)
|
|
739
|
-
throw new _(
|
|
739
|
+
throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
|
|
740
740
|
try {
|
|
741
741
|
const s = await this.migrateWalletUseCase.execute(e, this.userId);
|
|
742
742
|
return this.address = s.address, this.emit("addressChanged", { address: s.address, index: 0 }), f.log("[CROSSx] migrateWallet 완료 — address:", s.address), s;
|
|
743
743
|
} catch (s) {
|
|
744
744
|
throw s instanceof _ ? s : new _(
|
|
745
|
-
|
|
745
|
+
g.MIGRATION_FAILED,
|
|
746
746
|
"Wallet migration failed",
|
|
747
747
|
s
|
|
748
748
|
);
|
|
@@ -763,7 +763,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
763
763
|
async getAddress(e) {
|
|
764
764
|
if (e !== void 0) {
|
|
765
765
|
if (this.ensureAuthenticated(), !this.userId)
|
|
766
|
-
throw new _(
|
|
766
|
+
throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
|
|
767
767
|
return { address: (await this.walletProvider.getAddress(this.userId, e)).address, index: e };
|
|
768
768
|
}
|
|
769
769
|
return !this.authenticated || !this.address ? null : { address: this.address, index: 0 };
|
|
@@ -797,7 +797,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
797
797
|
*/
|
|
798
798
|
async selectWallet() {
|
|
799
799
|
if (this.ensureAuthenticated(), !this.userId)
|
|
800
|
-
throw new _(
|
|
800
|
+
throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
|
|
801
801
|
const e = await this.walletProvider.getAddresses(this.userId);
|
|
802
802
|
return this.confirmation.showWalletSelector(
|
|
803
803
|
e,
|
|
@@ -807,6 +807,15 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
807
807
|
}
|
|
808
808
|
);
|
|
809
809
|
}
|
|
810
|
+
/**
|
|
811
|
+
* 지갑이 2개 이상이면 selectWallet()을 호출하고, 선택 결과를 내부 상태에 반영합니다.
|
|
812
|
+
* 지갑이 1개 이하이거나 사용자가 취소하면 null을 반환합니다.
|
|
813
|
+
*/
|
|
814
|
+
async selectWalletIfMultiple(e) {
|
|
815
|
+
if (e.length < 2) return null;
|
|
816
|
+
const s = await this.selectWallet();
|
|
817
|
+
return s && (this.address = s.address, this.emit("addressChanged", { address: s.address, index: s.index })), s;
|
|
818
|
+
}
|
|
810
819
|
// ============================================================================
|
|
811
820
|
// 체인 조회
|
|
812
821
|
// ============================================================================
|
|
@@ -827,7 +836,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
827
836
|
try {
|
|
828
837
|
return await this.chainRegistry.getChains();
|
|
829
838
|
} catch (e) {
|
|
830
|
-
throw e instanceof _ ? e : new _(
|
|
839
|
+
throw e instanceof _ ? e : new _(g.UNKNOWN_ERROR, "Failed to fetch chains", e);
|
|
831
840
|
}
|
|
832
841
|
}
|
|
833
842
|
/**
|
|
@@ -846,7 +855,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
846
855
|
try {
|
|
847
856
|
return await this.chainRegistry.getChain(e);
|
|
848
857
|
} catch (s) {
|
|
849
|
-
throw s instanceof _ ? s : new _(
|
|
858
|
+
throw s instanceof _ ? s : new _(g.CHAIN_NOT_SUPPORTED, `Failed to fetch chain: ${e}`, s);
|
|
850
859
|
}
|
|
851
860
|
}
|
|
852
861
|
// ============================================================================
|
|
@@ -872,20 +881,20 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
872
881
|
*/
|
|
873
882
|
async createWallet() {
|
|
874
883
|
if (this.ensureAuthenticated(), !this.userId)
|
|
875
|
-
throw new _(
|
|
884
|
+
throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
|
|
876
885
|
f.log("[CROSSx] 지갑 생성 시작");
|
|
877
886
|
try {
|
|
878
887
|
const e = await this.walletProvider.getOrCreateWallet(this.userId);
|
|
879
888
|
return this.address = e.address, this.emit("addressChanged", { address: e.address, index: 0 }), f.log("[CROSSx] 지갑 생성 완료:", e.address), { address: e.address };
|
|
880
889
|
} catch (e) {
|
|
881
|
-
if (e instanceof _ && e.code ===
|
|
890
|
+
if (e instanceof _ && e.code === g.MIGRATION_BACKUP_EXISTS) {
|
|
882
891
|
const s = this.providerSub ?? this.userId;
|
|
883
892
|
f.log("[CROSSx][Migration Phase 3] createWallet() — Gateway -10012 감지, 마이그레이션 UI 시작 — migrationSub:", s);
|
|
884
893
|
const t = await this.handleMigrationFlow(s);
|
|
885
894
|
if (t)
|
|
886
895
|
return this.address = t.address, this.emit("addressChanged", { address: t.address, index: 0 }), { address: t.address };
|
|
887
896
|
throw new _(
|
|
888
|
-
|
|
897
|
+
g.MIGRATION_FAILED,
|
|
889
898
|
"Migration skipped by user"
|
|
890
899
|
);
|
|
891
900
|
}
|
|
@@ -904,7 +913,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
904
913
|
*/
|
|
905
914
|
async signMessage(e, s, t) {
|
|
906
915
|
if (this.ensureAuthenticated(), !this.userId)
|
|
907
|
-
throw new _(
|
|
916
|
+
throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
|
|
908
917
|
const n = t == null ? void 0 : t.index, o = await this.walletProvider.getAddress(this.userId, n ?? 0);
|
|
909
918
|
let i;
|
|
910
919
|
if (this.walletProvider.prepare && (i = (await this.walletProvider.prepare("sign-message", { message: s, from: o.address })).uuid), !await this.confirmation.requestConfirmation({
|
|
@@ -915,7 +924,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
915
924
|
dappName: t == null ? void 0 : t.dappName,
|
|
916
925
|
accountName: t == null ? void 0 : t.accountName
|
|
917
926
|
}))
|
|
918
|
-
throw new _(
|
|
927
|
+
throw new _(g.USER_REJECTED, "User rejected message signing");
|
|
919
928
|
try {
|
|
920
929
|
const c = await this.walletProvider.signMessage(
|
|
921
930
|
this.userId,
|
|
@@ -932,7 +941,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
932
941
|
address: o.address
|
|
933
942
|
};
|
|
934
943
|
} catch (c) {
|
|
935
|
-
throw c instanceof _ ? c : new _(
|
|
944
|
+
throw c instanceof _ ? c : new _(g.SIGNATURE_FAILED, `Message signing failed (${e})`, c);
|
|
936
945
|
}
|
|
937
946
|
}
|
|
938
947
|
/**
|
|
@@ -958,9 +967,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
958
967
|
*/
|
|
959
968
|
async signTypedData(e, s, t) {
|
|
960
969
|
if (this.ensureAuthenticated(), !this.userId)
|
|
961
|
-
throw new _(
|
|
970
|
+
throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
|
|
962
971
|
if (!this.walletProvider.signTypedData)
|
|
963
|
-
throw new _(
|
|
972
|
+
throw new _(g.NOT_IMPLEMENTED, "signTypedData is not implemented");
|
|
964
973
|
X.validateTypedDataChainId(e, s);
|
|
965
974
|
const n = await this.walletProvider.getAddress(this.userId, (t == null ? void 0 : t.index) ?? 0);
|
|
966
975
|
let o;
|
|
@@ -972,7 +981,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
972
981
|
dappName: t == null ? void 0 : t.dappName,
|
|
973
982
|
accountName: t == null ? void 0 : t.accountName
|
|
974
983
|
}))
|
|
975
|
-
throw new _(
|
|
984
|
+
throw new _(g.USER_REJECTED, "User rejected typed data signing");
|
|
976
985
|
try {
|
|
977
986
|
const a = await this.walletProvider.signTypedData(
|
|
978
987
|
this.userId,
|
|
@@ -988,7 +997,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
988
997
|
address: n.address
|
|
989
998
|
};
|
|
990
999
|
} catch (a) {
|
|
991
|
-
throw a instanceof _ ? a : new _(
|
|
1000
|
+
throw a instanceof _ ? a : new _(g.SIGNATURE_FAILED, `Typed data signing failed (${e})`, a);
|
|
992
1001
|
}
|
|
993
1002
|
}
|
|
994
1003
|
/**
|
|
@@ -1024,7 +1033,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1024
1033
|
*/
|
|
1025
1034
|
async signTransaction(e, s, t) {
|
|
1026
1035
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1027
|
-
throw new _(
|
|
1036
|
+
throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
|
|
1028
1037
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
1029
1038
|
let o;
|
|
1030
1039
|
this.walletProvider.prepare && (o = (await this.walletProvider.prepare("sign", { tx: n })).uuid);
|
|
@@ -1045,7 +1054,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1045
1054
|
dappName: t == null ? void 0 : t.dappName,
|
|
1046
1055
|
accountName: t == null ? void 0 : t.accountName
|
|
1047
1056
|
}))
|
|
1048
|
-
throw new _(
|
|
1057
|
+
throw new _(g.USER_REJECTED, "User rejected transaction signing");
|
|
1049
1058
|
try {
|
|
1050
1059
|
const c = await this.walletProvider.signTransaction(
|
|
1051
1060
|
this.userId,
|
|
@@ -1063,7 +1072,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1063
1072
|
if (c instanceof _) throw c;
|
|
1064
1073
|
const l = c instanceof Error ? c.message : String(c);
|
|
1065
1074
|
throw new _(
|
|
1066
|
-
|
|
1075
|
+
g.SIGNATURE_FAILED,
|
|
1067
1076
|
`Transaction signing failed (${e}): ${l}`,
|
|
1068
1077
|
c
|
|
1069
1078
|
);
|
|
@@ -1077,7 +1086,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1077
1086
|
*/
|
|
1078
1087
|
async sendTransaction(e, s, t) {
|
|
1079
1088
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1080
|
-
throw new _(
|
|
1089
|
+
throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
|
|
1081
1090
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
1082
1091
|
let o;
|
|
1083
1092
|
this.walletProvider.prepare && (o = (await this.walletProvider.prepare("send", { tx: n })).uuid);
|
|
@@ -1098,7 +1107,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1098
1107
|
dappName: t == null ? void 0 : t.dappName,
|
|
1099
1108
|
accountName: t == null ? void 0 : t.accountName
|
|
1100
1109
|
}))
|
|
1101
|
-
throw new _(
|
|
1110
|
+
throw new _(g.USER_REJECTED, "User rejected transaction");
|
|
1102
1111
|
try {
|
|
1103
1112
|
let c;
|
|
1104
1113
|
if (this.walletProvider.sendTransaction)
|
|
@@ -1122,7 +1131,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1122
1131
|
} catch (c) {
|
|
1123
1132
|
const l = c instanceof Error ? c.message : String(c);
|
|
1124
1133
|
throw new _(
|
|
1125
|
-
|
|
1134
|
+
g.TRANSACTION_FAILED,
|
|
1126
1135
|
`Transaction failed (${e}): ${l}`,
|
|
1127
1136
|
c
|
|
1128
1137
|
);
|
|
@@ -1155,7 +1164,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1155
1164
|
await new Promise((d) => setTimeout(d, c)), c = Math.min(c * 2, o);
|
|
1156
1165
|
}
|
|
1157
1166
|
throw new _(
|
|
1158
|
-
|
|
1167
|
+
g.UNKNOWN_ERROR,
|
|
1159
1168
|
`Transaction receipt timeout (${e})`
|
|
1160
1169
|
);
|
|
1161
1170
|
}
|
|
@@ -1176,7 +1185,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1176
1185
|
*/
|
|
1177
1186
|
async sendTransactionWithWaitForReceipt(e, s, t = {}) {
|
|
1178
1187
|
var b, S;
|
|
1179
|
-
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((b = this._config.receiptPolling) == null ? void 0 : b.intervalMs) ?? Hs, l = o ?? ((S = this._config.receiptPolling) == null ? void 0 : S.timeoutMs) ?? bt, d = ze(e),
|
|
1188
|
+
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((b = this._config.receiptPolling) == null ? void 0 : b.intervalMs) ?? Hs, l = o ?? ((S = this._config.receiptPolling) == null ? void 0 : S.timeoutMs) ?? bt, d = ze(e), p = s.from ?? "";
|
|
1180
1189
|
let m, x;
|
|
1181
1190
|
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((E) => {
|
|
1182
1191
|
m = E;
|
|
@@ -1195,14 +1204,14 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1195
1204
|
}).catch((E) => (x = E instanceof Error ? E : new Error(String(E)), {
|
|
1196
1205
|
chainId: e,
|
|
1197
1206
|
txHash: a,
|
|
1198
|
-
from:
|
|
1207
|
+
from: p,
|
|
1199
1208
|
to: s.to,
|
|
1200
1209
|
amount: X.formatTxAmount(s.value, d.symbol, d.decimals),
|
|
1201
1210
|
nativeSymbol: d.symbol,
|
|
1202
1211
|
status: "timeout"
|
|
1203
1212
|
}));
|
|
1204
1213
|
if (await this.confirmation.showTransactionProgress(
|
|
1205
|
-
{ chainId: e, txHash: a, from:
|
|
1214
|
+
{ chainId: e, txHash: a, from: p, to: s.to },
|
|
1206
1215
|
w
|
|
1207
1216
|
), x) throw x;
|
|
1208
1217
|
return { chainId: e, txHash: a, receipt: m };
|
|
@@ -1225,7 +1234,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1225
1234
|
return await this.walletRpc("eth_gasPrice", [], e);
|
|
1226
1235
|
} catch (s) {
|
|
1227
1236
|
const t = s instanceof Error ? s.message : String(s);
|
|
1228
|
-
throw new _(
|
|
1237
|
+
throw new _(g.GAS_ESTIMATION_FAILED, `Failed to get gas price (${e}): ${t}`, s);
|
|
1229
1238
|
}
|
|
1230
1239
|
}
|
|
1231
1240
|
/**
|
|
@@ -1246,7 +1255,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1246
1255
|
return await this.walletRpc("eth_estimateGas", [t], s);
|
|
1247
1256
|
} catch (n) {
|
|
1248
1257
|
const o = n instanceof Error ? n.message : String(n);
|
|
1249
|
-
throw new _(
|
|
1258
|
+
throw new _(g.GAS_ESTIMATION_FAILED, `Failed to estimate gas (${s}): ${o}`, n);
|
|
1250
1259
|
}
|
|
1251
1260
|
}
|
|
1252
1261
|
/**
|
|
@@ -1267,7 +1276,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1267
1276
|
return (s == null ? void 0 : s.baseFeePerGas) ?? null;
|
|
1268
1277
|
} catch (s) {
|
|
1269
1278
|
const t = s instanceof Error ? s.message : String(s);
|
|
1270
|
-
throw new _(
|
|
1279
|
+
throw new _(g.GAS_ESTIMATION_FAILED, `Failed to get baseFeePerGas (${e}): ${t}`, s);
|
|
1271
1280
|
}
|
|
1272
1281
|
}
|
|
1273
1282
|
/**
|
|
@@ -1286,7 +1295,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1286
1295
|
return await this.walletRpc("eth_maxPriorityFeePerGas", [], e);
|
|
1287
1296
|
} catch (s) {
|
|
1288
1297
|
const t = s instanceof Error ? s.message : String(s);
|
|
1289
|
-
throw new _(
|
|
1298
|
+
throw new _(g.GAS_ESTIMATION_FAILED, `Failed to get maxPriorityFeePerGas (${e}): ${t}`, s);
|
|
1290
1299
|
}
|
|
1291
1300
|
}
|
|
1292
1301
|
// ============================================================================
|
|
@@ -1306,7 +1315,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1306
1315
|
} catch (t) {
|
|
1307
1316
|
if (t instanceof _) throw t;
|
|
1308
1317
|
const n = t instanceof Error ? t.message : String(t);
|
|
1309
|
-
throw new _(
|
|
1318
|
+
throw new _(g.UNKNOWN_ERROR, `Failed to get nonce: ${n}`, t);
|
|
1310
1319
|
}
|
|
1311
1320
|
}
|
|
1312
1321
|
/**
|
|
@@ -1325,7 +1334,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1325
1334
|
} catch (t) {
|
|
1326
1335
|
if (t instanceof _) throw t;
|
|
1327
1336
|
const n = t instanceof Error ? t.message : String(t);
|
|
1328
|
-
throw new _(
|
|
1337
|
+
throw new _(g.UNKNOWN_ERROR, `Failed to get balance (${e}): ${n}`, t);
|
|
1329
1338
|
}
|
|
1330
1339
|
}
|
|
1331
1340
|
static formatWei(e) {
|
|
@@ -1333,7 +1342,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1333
1342
|
try {
|
|
1334
1343
|
const s = BigInt(e);
|
|
1335
1344
|
if (s === 0n) return "0";
|
|
1336
|
-
const t = 10n ** BigInt(
|
|
1345
|
+
const t = 10n ** BigInt(It), n = s / t, i = (s % t).toString().padStart(It, "0").replace(/0+$/, "").slice(0, Et);
|
|
1337
1346
|
return i ? `${n}.${i}` : `${n}`;
|
|
1338
1347
|
} catch {
|
|
1339
1348
|
return "?";
|
|
@@ -1376,7 +1385,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1376
1385
|
} catch (n) {
|
|
1377
1386
|
if (n instanceof _) throw n;
|
|
1378
1387
|
const o = n instanceof Error ? n.message : String(n);
|
|
1379
|
-
throw new _(
|
|
1388
|
+
throw new _(g.UNKNOWN_ERROR, `walletRpc failed [${e}] (${t}): ${o}`, n);
|
|
1380
1389
|
}
|
|
1381
1390
|
}
|
|
1382
1391
|
// ============================================================================
|
|
@@ -1419,7 +1428,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1419
1428
|
const i = await this.migrateWalletUseCase.execute(o, e);
|
|
1420
1429
|
return f.log("[CROSSx][Migration Phase 5] 마이그레이션 성공 — address:", i.address), i;
|
|
1421
1430
|
} catch (i) {
|
|
1422
|
-
if (i instanceof _ && i.code ===
|
|
1431
|
+
if (i instanceof _ && i.code === g.MIGRATION_FAILED) {
|
|
1423
1432
|
f.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 #${n}) — 재시도 요청`), t = "Incorrect PIN. Please try again.";
|
|
1424
1433
|
continue;
|
|
1425
1434
|
}
|
|
@@ -1465,7 +1474,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1465
1474
|
if (e === "0") {
|
|
1466
1475
|
if (t !== void 0 && t !== 0)
|
|
1467
1476
|
throw new _(
|
|
1468
|
-
|
|
1477
|
+
g.TYPED_DATA_CHAIN_ID_MISMATCH,
|
|
1469
1478
|
`Off-chain signing (chainId=0) requires typedData.domain.chainId to be absent or 0, got ${t}`
|
|
1470
1479
|
);
|
|
1471
1480
|
return;
|
|
@@ -1475,12 +1484,12 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1475
1484
|
const o = Number(n[1]);
|
|
1476
1485
|
if (t === void 0)
|
|
1477
1486
|
throw new _(
|
|
1478
|
-
|
|
1487
|
+
g.TYPED_DATA_CHAIN_ID_MISMATCH,
|
|
1479
1488
|
`On-chain signing (${e}) requires typedData.domain.chainId to be present`
|
|
1480
1489
|
);
|
|
1481
1490
|
if (t !== o)
|
|
1482
1491
|
throw new _(
|
|
1483
|
-
|
|
1492
|
+
g.TYPED_DATA_CHAIN_ID_MISMATCH,
|
|
1484
1493
|
`typedData.domain.chainId (${t}) does not match chainId (${e}, expected ${o})`
|
|
1485
1494
|
);
|
|
1486
1495
|
}
|
|
@@ -1498,10 +1507,10 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1498
1507
|
static validateSignatureFormat(e) {
|
|
1499
1508
|
const s = e.startsWith("0x") ? e.slice(2) : e;
|
|
1500
1509
|
if (!/^[0-9a-fA-F]+$/.test(s))
|
|
1501
|
-
throw new _(
|
|
1510
|
+
throw new _(g.SIGNATURE_FAILED, "Invalid signature: not a valid hex string");
|
|
1502
1511
|
if (s.length !== St)
|
|
1503
1512
|
throw new _(
|
|
1504
|
-
|
|
1513
|
+
g.SIGNATURE_FAILED,
|
|
1505
1514
|
`Invalid signature length: expected ${St} hex chars (65 bytes), got ${s.length}`
|
|
1506
1515
|
);
|
|
1507
1516
|
}
|
|
@@ -1509,9 +1518,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1509
1518
|
static validateSignedTxFormat(e) {
|
|
1510
1519
|
const s = e.startsWith("0x") ? e.slice(2) : e;
|
|
1511
1520
|
if (!/^[0-9a-fA-F]+$/.test(s))
|
|
1512
|
-
throw new _(
|
|
1521
|
+
throw new _(g.SIGNATURE_FAILED, "Invalid signedTx: not a valid hex string");
|
|
1513
1522
|
if (s.length < 2)
|
|
1514
|
-
throw new _(
|
|
1523
|
+
throw new _(g.SIGNATURE_FAILED, "Invalid signedTx: too short");
|
|
1515
1524
|
}
|
|
1516
1525
|
/**
|
|
1517
1526
|
* Gateway 서명 응답의 ecrecover 검증 (XF-036)
|
|
@@ -1528,7 +1537,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1528
1537
|
expected: t,
|
|
1529
1538
|
recovered: n
|
|
1530
1539
|
}), new _(
|
|
1531
|
-
|
|
1540
|
+
g.SIGNATURE_SIGNER_MISMATCH,
|
|
1532
1541
|
`Signature signer mismatch: expected ${t}, recovered ${n}`
|
|
1533
1542
|
);
|
|
1534
1543
|
f.log("[CROSSx] 서명 ecrecover 검증 성공");
|
|
@@ -1564,14 +1573,14 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1564
1573
|
ensureInitialized() {
|
|
1565
1574
|
if (!this.initialized)
|
|
1566
1575
|
throw new _(
|
|
1567
|
-
|
|
1576
|
+
g.AUTH_NOT_INITIALIZED,
|
|
1568
1577
|
"SDK is not initialized. Call initialize() first."
|
|
1569
1578
|
);
|
|
1570
1579
|
}
|
|
1571
1580
|
ensureAuthenticated() {
|
|
1572
1581
|
if (this.ensureInitialized(), !this.authenticated)
|
|
1573
1582
|
throw new _(
|
|
1574
|
-
|
|
1583
|
+
g.AUTH_NOT_AUTHENTICATED,
|
|
1575
1584
|
"Not authenticated. Call signIn() first."
|
|
1576
1585
|
);
|
|
1577
1586
|
}
|
|
@@ -1624,7 +1633,7 @@ class Ks {
|
|
|
1624
1633
|
}
|
|
1625
1634
|
}
|
|
1626
1635
|
}
|
|
1627
|
-
const zs = "crossx-sdk", Ys = 1, Se = "data", Le = "keys",
|
|
1636
|
+
const zs = "crossx-sdk", Ys = 1, Se = "data", Le = "keys", Tt = "aes-primary", Zs = 12;
|
|
1628
1637
|
class At {
|
|
1629
1638
|
constructor() {
|
|
1630
1639
|
this.db = null, this.cryptoKey = null, this.initPromise = null;
|
|
@@ -1667,7 +1676,7 @@ class At {
|
|
|
1667
1676
|
}
|
|
1668
1677
|
async init() {
|
|
1669
1678
|
this.db = await this.openDB();
|
|
1670
|
-
const e = await this.idbGet(Le,
|
|
1679
|
+
const e = await this.idbGet(Le, Tt);
|
|
1671
1680
|
if (e) {
|
|
1672
1681
|
this.cryptoKey = e;
|
|
1673
1682
|
return;
|
|
@@ -1676,7 +1685,7 @@ class At {
|
|
|
1676
1685
|
{ name: "AES-GCM", length: 256 },
|
|
1677
1686
|
!1,
|
|
1678
1687
|
["encrypt", "decrypt"]
|
|
1679
|
-
), await this.idbPut(Le,
|
|
1688
|
+
), await this.idbPut(Le, Tt, this.cryptoKey);
|
|
1680
1689
|
}
|
|
1681
1690
|
async encrypt(e) {
|
|
1682
1691
|
const s = new Uint8Array(Zs);
|
|
@@ -1760,7 +1769,7 @@ function Kt(r) {
|
|
|
1760
1769
|
throw new Error("Hash must wrapped by utils.createHasher");
|
|
1761
1770
|
ue(r.outputLen), ue(r.blockLen);
|
|
1762
1771
|
}
|
|
1763
|
-
function
|
|
1772
|
+
function Ie(r, e = !0) {
|
|
1764
1773
|
if (r.destroyed)
|
|
1765
1774
|
throw new Error("Hash instance has been destroyed");
|
|
1766
1775
|
if (e && r.finished)
|
|
@@ -1775,7 +1784,7 @@ function zt(r, e) {
|
|
|
1775
1784
|
function Xs(r) {
|
|
1776
1785
|
return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
|
|
1777
1786
|
}
|
|
1778
|
-
function
|
|
1787
|
+
function Te(...r) {
|
|
1779
1788
|
for (let e = 0; e < r.length; e++)
|
|
1780
1789
|
r[e].fill(0);
|
|
1781
1790
|
}
|
|
@@ -1879,7 +1888,7 @@ class or {
|
|
|
1879
1888
|
this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Ze(this.buffer);
|
|
1880
1889
|
}
|
|
1881
1890
|
update(e) {
|
|
1882
|
-
|
|
1891
|
+
Ie(this), F(e);
|
|
1883
1892
|
const { view: s, buffer: t, blockLen: n } = this, o = e.length;
|
|
1884
1893
|
for (let i = 0; i < o; ) {
|
|
1885
1894
|
const a = Math.min(n - this.pos, o - i);
|
|
@@ -1894,12 +1903,12 @@ class or {
|
|
|
1894
1903
|
return this.length += e.length, this.roundClean(), this;
|
|
1895
1904
|
}
|
|
1896
1905
|
digestInto(e) {
|
|
1897
|
-
|
|
1906
|
+
Ie(this), zt(e, this), this.finished = !0;
|
|
1898
1907
|
const { buffer: s, view: t, blockLen: n, isLE: o } = this;
|
|
1899
1908
|
let { pos: i } = this;
|
|
1900
|
-
s[i++] = 128,
|
|
1901
|
-
for (let
|
|
1902
|
-
s[
|
|
1909
|
+
s[i++] = 128, Te(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
|
|
1910
|
+
for (let p = i; p < n; p++)
|
|
1911
|
+
s[p] = 0;
|
|
1903
1912
|
t.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(t, 0);
|
|
1904
1913
|
const a = Ze(e), c = this.outputLen;
|
|
1905
1914
|
if (c % 4)
|
|
@@ -1907,8 +1916,8 @@ class or {
|
|
|
1907
1916
|
const l = c / 4, d = this.get();
|
|
1908
1917
|
if (l > d.length)
|
|
1909
1918
|
throw new Error("_sha2: outputLen bigger than state");
|
|
1910
|
-
for (let
|
|
1911
|
-
a.setUint32(4 *
|
|
1919
|
+
for (let p = 0; p < l; p++)
|
|
1920
|
+
a.setUint32(4 * p, d[p], o);
|
|
1912
1921
|
}
|
|
1913
1922
|
digest() {
|
|
1914
1923
|
const { buffer: e, outputLen: s } = this;
|
|
@@ -2012,7 +2021,7 @@ const cr = (r, e, s) => r << s | e >>> 32 - s, lr = (r, e, s) => e << s | r >>>
|
|
|
2012
2021
|
2756734187,
|
|
2013
2022
|
3204031479,
|
|
2014
2023
|
3329325298
|
|
2015
|
-
]),
|
|
2024
|
+
]), pe = /* @__PURE__ */ new Uint32Array(64);
|
|
2016
2025
|
class fr extends or {
|
|
2017
2026
|
constructor(e) {
|
|
2018
2027
|
super(64, e, 8, !1);
|
|
@@ -2026,27 +2035,27 @@ class fr extends or {
|
|
|
2026
2035
|
this.A = e | 0, this.B = s | 0, this.C = t | 0, this.D = n | 0, this.E = o | 0, this.F = i | 0, this.G = a | 0, this.H = c | 0;
|
|
2027
2036
|
}
|
|
2028
2037
|
process(e, s) {
|
|
2029
|
-
for (let
|
|
2030
|
-
|
|
2031
|
-
for (let
|
|
2032
|
-
const m =
|
|
2033
|
-
|
|
2038
|
+
for (let p = 0; p < 16; p++, s += 4)
|
|
2039
|
+
pe[p] = e.getUint32(s, !1);
|
|
2040
|
+
for (let p = 16; p < 64; p++) {
|
|
2041
|
+
const m = pe[p - 15], x = pe[p - 2], w = oe(m, 7) ^ oe(m, 18) ^ m >>> 3, b = oe(x, 17) ^ oe(x, 19) ^ x >>> 10;
|
|
2042
|
+
pe[p] = b + pe[p - 7] + w + pe[p - 16] | 0;
|
|
2034
2043
|
}
|
|
2035
2044
|
let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: d } = this;
|
|
2036
|
-
for (let
|
|
2037
|
-
const m = oe(a, 6) ^ oe(a, 11) ^ oe(a, 25), x = d + m + rr(a, c, l) + hr[
|
|
2045
|
+
for (let p = 0; p < 64; p++) {
|
|
2046
|
+
const m = oe(a, 6) ^ oe(a, 11) ^ oe(a, 25), x = d + m + rr(a, c, l) + hr[p] + pe[p] | 0, b = (oe(t, 2) ^ oe(t, 13) ^ oe(t, 22)) + nr(t, n, o) | 0;
|
|
2038
2047
|
d = l, l = c, c = a, a = i + x | 0, i = o, o = n, n = t, t = x + b | 0;
|
|
2039
2048
|
}
|
|
2040
2049
|
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);
|
|
2041
2050
|
}
|
|
2042
2051
|
roundClean() {
|
|
2043
|
-
|
|
2052
|
+
Te(pe);
|
|
2044
2053
|
}
|
|
2045
2054
|
destroy() {
|
|
2046
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0),
|
|
2055
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0), Te(this.buffer);
|
|
2047
2056
|
}
|
|
2048
2057
|
}
|
|
2049
|
-
class
|
|
2058
|
+
class pr extends fr {
|
|
2050
2059
|
constructor() {
|
|
2051
2060
|
super(32);
|
|
2052
2061
|
// We cannot use array here since array allows indexing by variable
|
|
@@ -2061,8 +2070,8 @@ class gr extends fr {
|
|
|
2061
2070
|
v(this, "H", fe[7] | 0);
|
|
2062
2071
|
}
|
|
2063
2072
|
}
|
|
2064
|
-
const
|
|
2065
|
-
() => new
|
|
2073
|
+
const gr = /* @__PURE__ */ Zt(
|
|
2074
|
+
() => new pr(),
|
|
2066
2075
|
/* @__PURE__ */ sr(1)
|
|
2067
2076
|
);
|
|
2068
2077
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
@@ -2130,7 +2139,7 @@ function yr(r, e, s) {
|
|
|
2130
2139
|
throw new Error("hmacFn must be a function");
|
|
2131
2140
|
const t = (S) => new Uint8Array(S), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
|
|
2132
2141
|
let c = t(r), l = t(r), d = 0;
|
|
2133
|
-
const
|
|
2142
|
+
const p = () => {
|
|
2134
2143
|
c.fill(1), l.fill(0), d = 0;
|
|
2135
2144
|
}, m = (...S) => s(l, _e(c, ...S)), x = (S = n) => {
|
|
2136
2145
|
l = m(o, S), c = m(), S.length !== 0 && (l = m(i, S), c = m());
|
|
@@ -2147,11 +2156,11 @@ function yr(r, e, s) {
|
|
|
2147
2156
|
return _e(...E);
|
|
2148
2157
|
};
|
|
2149
2158
|
return (S, E) => {
|
|
2150
|
-
|
|
2159
|
+
p(), x(S);
|
|
2151
2160
|
let q;
|
|
2152
2161
|
for (; !(q = E(w())); )
|
|
2153
2162
|
x();
|
|
2154
|
-
return
|
|
2163
|
+
return p(), q;
|
|
2155
2164
|
};
|
|
2156
2165
|
}
|
|
2157
2166
|
function ut(r, e = {}, s = {}) {
|
|
@@ -2220,8 +2229,8 @@ function Er(r) {
|
|
|
2220
2229
|
const e = Ve(r), s = cs(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + br) / is;
|
|
2221
2230
|
return (a, c) => {
|
|
2222
2231
|
let l = a.pow(c, i), d = a.mul(l, t);
|
|
2223
|
-
const
|
|
2224
|
-
l = a.cmov(l, d, x), d = a.cmov(m,
|
|
2232
|
+
const p = a.mul(l, n), m = a.mul(l, o), x = a.eql(a.sqr(d), c), w = a.eql(a.sqr(p), c);
|
|
2233
|
+
l = a.cmov(l, d, x), d = a.cmov(m, p, w);
|
|
2225
2234
|
const b = a.eql(a.sqr(d), c), S = a.cmov(l, d, b);
|
|
2226
2235
|
return ht(a, S, c), S;
|
|
2227
2236
|
};
|
|
@@ -2246,7 +2255,7 @@ function cs(r) {
|
|
|
2246
2255
|
return l;
|
|
2247
2256
|
if (Pt(c, l) !== 1)
|
|
2248
2257
|
throw new Error("Cannot find square root");
|
|
2249
|
-
let d = s,
|
|
2258
|
+
let d = s, p = c.mul(c.ONE, o), m = c.pow(l, e), x = c.pow(l, i);
|
|
2250
2259
|
for (; !c.eql(m, c.ONE); ) {
|
|
2251
2260
|
if (c.is0(m))
|
|
2252
2261
|
return c.ZERO;
|
|
@@ -2254,16 +2263,16 @@ function cs(r) {
|
|
|
2254
2263
|
for (; !c.eql(b, c.ONE); )
|
|
2255
2264
|
if (w++, b = c.sqr(b), w === d)
|
|
2256
2265
|
throw new Error("Cannot find square root");
|
|
2257
|
-
const S = z << BigInt(d - w - 1), E = c.pow(
|
|
2258
|
-
d = w,
|
|
2266
|
+
const S = z << BigInt(d - w - 1), E = c.pow(p, S);
|
|
2267
|
+
d = w, p = c.sqr(E), m = c.mul(m, p), x = c.mul(x, E);
|
|
2259
2268
|
}
|
|
2260
2269
|
return x;
|
|
2261
2270
|
};
|
|
2262
2271
|
}
|
|
2263
|
-
function
|
|
2272
|
+
function Ir(r) {
|
|
2264
2273
|
return r % rs === ss ? as : r % os === ns ? Sr : r % is === vr ? Er(r) : cs(r);
|
|
2265
2274
|
}
|
|
2266
|
-
const
|
|
2275
|
+
const Tr = [
|
|
2267
2276
|
"create",
|
|
2268
2277
|
"isValid",
|
|
2269
2278
|
"is0",
|
|
@@ -2287,7 +2296,7 @@ function Ar(r) {
|
|
|
2287
2296
|
ORDER: "bigint",
|
|
2288
2297
|
BYTES: "number",
|
|
2289
2298
|
BITS: "number"
|
|
2290
|
-
}, s =
|
|
2299
|
+
}, s = Tr.reduce((t, n) => (t[n] = "function", t), e);
|
|
2291
2300
|
return ut(r, s), r;
|
|
2292
2301
|
}
|
|
2293
2302
|
function Rr(r, e, s) {
|
|
@@ -2398,7 +2407,7 @@ class Cr {
|
|
|
2398
2407
|
return Nt(e, this.ORDER);
|
|
2399
2408
|
}
|
|
2400
2409
|
sqrt(e) {
|
|
2401
|
-
return this._sqrt || (this._sqrt =
|
|
2410
|
+
return this._sqrt || (this._sqrt = Ir(this.ORDER)), this._sqrt(this, e);
|
|
2402
2411
|
}
|
|
2403
2412
|
toBytes(e) {
|
|
2404
2413
|
return this.isLE ? ts(e, this.BYTES) : lt(e, this.BYTES);
|
|
@@ -2473,8 +2482,8 @@ function Dt(r, e, s) {
|
|
|
2473
2482
|
const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
|
|
2474
2483
|
let a = Number(r & n), c = r >> i;
|
|
2475
2484
|
a > t && (a -= o, c += be);
|
|
2476
|
-
const l = e * t, d = l + Math.abs(a) - 1,
|
|
2477
|
-
return { nextN: c, offset: d, isZero:
|
|
2485
|
+
const l = e * t, d = l + Math.abs(a) - 1, p = a === 0, m = a < 0, x = e % 2 !== 0;
|
|
2486
|
+
return { nextN: c, offset: d, isZero: p, isNeg: m, isNegF: x, offsetF: l };
|
|
2478
2487
|
}
|
|
2479
2488
|
const Je = /* @__PURE__ */ new WeakMap(), fs = /* @__PURE__ */ new WeakMap();
|
|
2480
2489
|
function Qe(r) {
|
|
@@ -2535,8 +2544,8 @@ class Nr {
|
|
|
2535
2544
|
let n = this.ZERO, o = this.BASE;
|
|
2536
2545
|
const i = Xe(e, this.bits);
|
|
2537
2546
|
for (let a = 0; a < i.windows; a++) {
|
|
2538
|
-
const { nextN: c, offset: l, isZero: d, isNeg:
|
|
2539
|
-
t = c, d ? o = o.add(Ge(m, s[x])) : n = n.add(Ge(
|
|
2547
|
+
const { nextN: c, offset: l, isZero: d, isNeg: p, isNegF: m, offsetF: x } = Dt(t, a, i);
|
|
2548
|
+
t = c, d ? o = o.add(Ge(m, s[x])) : n = n.add(Ge(p, s[l]));
|
|
2540
2549
|
}
|
|
2541
2550
|
return $t(t), { p: n, f: o };
|
|
2542
2551
|
}
|
|
@@ -2550,8 +2559,8 @@ class Nr {
|
|
|
2550
2559
|
for (let i = 0; i < o.windows && t !== Ae; i++) {
|
|
2551
2560
|
const { nextN: a, offset: c, isZero: l, isNeg: d } = Dt(t, i, o);
|
|
2552
2561
|
if (t = a, !l) {
|
|
2553
|
-
const
|
|
2554
|
-
n = n.add(d ?
|
|
2562
|
+
const p = s[c];
|
|
2563
|
+
n = n.add(d ? p.negate() : p);
|
|
2555
2564
|
}
|
|
2556
2565
|
}
|
|
2557
2566
|
return $t(t), n;
|
|
@@ -2612,7 +2621,7 @@ function Dr(r, e) {
|
|
|
2612
2621
|
return { secretKey: n, publicKey: e(n) };
|
|
2613
2622
|
};
|
|
2614
2623
|
}
|
|
2615
|
-
class
|
|
2624
|
+
class ps {
|
|
2616
2625
|
constructor(e, s) {
|
|
2617
2626
|
v(this, "oHash");
|
|
2618
2627
|
v(this, "iHash");
|
|
@@ -2630,13 +2639,13 @@ class gs {
|
|
|
2630
2639
|
this.iHash.update(n), this.oHash = e.create();
|
|
2631
2640
|
for (let o = 0; o < n.length; o++)
|
|
2632
2641
|
n[o] ^= 106;
|
|
2633
|
-
this.oHash.update(n),
|
|
2642
|
+
this.oHash.update(n), Te(n);
|
|
2634
2643
|
}
|
|
2635
2644
|
update(e) {
|
|
2636
|
-
return
|
|
2645
|
+
return Ie(this), this.iHash.update(e), this;
|
|
2637
2646
|
}
|
|
2638
2647
|
digestInto(e) {
|
|
2639
|
-
|
|
2648
|
+
Ie(this), F(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
|
|
2640
2649
|
}
|
|
2641
2650
|
digest() {
|
|
2642
2651
|
const e = new Uint8Array(this.oHash.outputLen);
|
|
@@ -2654,19 +2663,19 @@ class gs {
|
|
|
2654
2663
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
2655
2664
|
}
|
|
2656
2665
|
}
|
|
2657
|
-
const
|
|
2658
|
-
|
|
2666
|
+
const gs = (r, e, s) => new ps(r, e).update(s).digest();
|
|
2667
|
+
gs.create = (r, e) => new ps(r, e);
|
|
2659
2668
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2660
2669
|
const Bt = (r, e) => (r + (r >= 0 ? e : -e) / _s) / e;
|
|
2661
2670
|
function $r(r, e, s) {
|
|
2662
2671
|
const [[t, n], [o, i]] = e, a = Bt(i * r, s), c = Bt(-n * r, s);
|
|
2663
2672
|
let l = r - a * t - c * o, d = -a * n - c * i;
|
|
2664
|
-
const
|
|
2665
|
-
|
|
2673
|
+
const p = l < le, m = d < le;
|
|
2674
|
+
p && (l = -l), m && (d = -d);
|
|
2666
2675
|
const x = dt(Math.ceil(wr(s) / 2)) + Ee;
|
|
2667
2676
|
if (l < le || l >= x || d < le || d >= x)
|
|
2668
2677
|
throw new Error("splitScalar (endomorphism): failed, k=" + r);
|
|
2669
|
-
return { k1neg:
|
|
2678
|
+
return { k1neg: p, k1: l, k2neg: m, k2: d };
|
|
2670
2679
|
}
|
|
2671
2680
|
function nt(r) {
|
|
2672
2681
|
if (!["compact", "recovered", "der"].includes(r))
|
|
@@ -2684,13 +2693,13 @@ class Mr extends Error {
|
|
|
2684
2693
|
super(e);
|
|
2685
2694
|
}
|
|
2686
2695
|
}
|
|
2687
|
-
const
|
|
2696
|
+
const ge = {
|
|
2688
2697
|
// asn.1 DER encoding utils
|
|
2689
2698
|
Err: Mr,
|
|
2690
2699
|
// Basic building block is TLV (Tag-Length-Value)
|
|
2691
2700
|
_tlv: {
|
|
2692
2701
|
encode: (r, e) => {
|
|
2693
|
-
const { Err: s } =
|
|
2702
|
+
const { Err: s } = ge;
|
|
2694
2703
|
if (r < 0 || r > 256)
|
|
2695
2704
|
throw new s("tlv.encode: wrong tag");
|
|
2696
2705
|
if (e.length & 1)
|
|
@@ -2703,7 +2712,7 @@ const pe = {
|
|
|
2703
2712
|
},
|
|
2704
2713
|
// v - value, l - left bytes (unparsed)
|
|
2705
2714
|
decode(r, e) {
|
|
2706
|
-
const { Err: s } =
|
|
2715
|
+
const { Err: s } = ge;
|
|
2707
2716
|
let t = 0;
|
|
2708
2717
|
if (r < 0 || r > 256)
|
|
2709
2718
|
throw new s("tlv.encode: wrong tag");
|
|
@@ -2741,7 +2750,7 @@ const pe = {
|
|
|
2741
2750
|
// - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
|
|
2742
2751
|
_int: {
|
|
2743
2752
|
encode(r) {
|
|
2744
|
-
const { Err: e } =
|
|
2753
|
+
const { Err: e } = ge;
|
|
2745
2754
|
if (r < le)
|
|
2746
2755
|
throw new e("integer: negative integers are not allowed");
|
|
2747
2756
|
let s = $e(r);
|
|
@@ -2750,7 +2759,7 @@ const pe = {
|
|
|
2750
2759
|
return s;
|
|
2751
2760
|
},
|
|
2752
2761
|
decode(r) {
|
|
2753
|
-
const { Err: e } =
|
|
2762
|
+
const { Err: e } = ge;
|
|
2754
2763
|
if (r[0] & 128)
|
|
2755
2764
|
throw new e("invalid signature integer: negative");
|
|
2756
2765
|
if (r[0] === 0 && !(r[1] & 128))
|
|
@@ -2759,7 +2768,7 @@ const pe = {
|
|
|
2759
2768
|
}
|
|
2760
2769
|
},
|
|
2761
2770
|
toSig(r) {
|
|
2762
|
-
const { Err: e, _int: s, _tlv: t } =
|
|
2771
|
+
const { Err: e, _int: s, _tlv: t } = ge, n = F(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
|
|
2763
2772
|
if (i.length)
|
|
2764
2773
|
throw new e("invalid signature: left bytes after parsing");
|
|
2765
2774
|
const { v: a, l: c } = t.decode(2, o), { v: l, l: d } = t.decode(2, c);
|
|
@@ -2768,7 +2777,7 @@ const pe = {
|
|
|
2768
2777
|
return { r: s.decode(a), s: s.decode(l) };
|
|
2769
2778
|
},
|
|
2770
2779
|
hexFromSig(r) {
|
|
2771
|
-
const { _tlv: e, _int: s } =
|
|
2780
|
+
const { _tlv: e, _int: s } = ge, t = e.encode(2, s.encode(r.r)), n = e.encode(2, s.encode(r.s)), o = t + n;
|
|
2772
2781
|
return e.encode(48, o);
|
|
2773
2782
|
}
|
|
2774
2783
|
}, le = BigInt(0), Ee = BigInt(1), _s = BigInt(2), Me = BigInt(3), Br = BigInt(4);
|
|
@@ -2792,42 +2801,42 @@ function Ur(r, e = {}) {
|
|
|
2792
2801
|
if (!t.isOdd)
|
|
2793
2802
|
throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
2794
2803
|
}
|
|
2795
|
-
function
|
|
2796
|
-
const { x: y, y:
|
|
2804
|
+
function p(P, u, h) {
|
|
2805
|
+
const { x: y, y: T } = u.toAffine(), R = t.toBytes(y);
|
|
2797
2806
|
if (He(h, "isCompressed"), h) {
|
|
2798
2807
|
d();
|
|
2799
|
-
const A = !t.isOdd(
|
|
2808
|
+
const A = !t.isOdd(T);
|
|
2800
2809
|
return _e(xs(A), R);
|
|
2801
2810
|
} else
|
|
2802
|
-
return _e(Uint8Array.of(4), R, t.toBytes(
|
|
2811
|
+
return _e(Uint8Array.of(4), R, t.toBytes(T));
|
|
2803
2812
|
}
|
|
2804
2813
|
function m(P) {
|
|
2805
2814
|
F(P, void 0, "Point");
|
|
2806
|
-
const { publicKey: u, publicKeyUncompressed: h } = l, y = P.length,
|
|
2807
|
-
if (y === u && (
|
|
2815
|
+
const { publicKey: u, publicKeyUncompressed: h } = l, y = P.length, T = P[0], R = P.subarray(1);
|
|
2816
|
+
if (y === u && (T === 2 || T === 3)) {
|
|
2808
2817
|
const A = t.fromBytes(R);
|
|
2809
2818
|
if (!t.isValid(A))
|
|
2810
2819
|
throw new Error("bad point: is not on curve, wrong x");
|
|
2811
2820
|
const O = b(A);
|
|
2812
|
-
let
|
|
2821
|
+
let I;
|
|
2813
2822
|
try {
|
|
2814
|
-
|
|
2823
|
+
I = t.sqrt(O);
|
|
2815
2824
|
} catch (W) {
|
|
2816
2825
|
const U = W instanceof Error ? ": " + W.message : "";
|
|
2817
2826
|
throw new Error("bad point: is not on curve, sqrt error" + U);
|
|
2818
2827
|
}
|
|
2819
2828
|
d();
|
|
2820
|
-
const C = t.isOdd(
|
|
2821
|
-
return (
|
|
2822
|
-
} else if (y === h &&
|
|
2823
|
-
const A = t.BYTES, O = t.fromBytes(R.subarray(0, A)),
|
|
2824
|
-
if (!S(O,
|
|
2829
|
+
const C = t.isOdd(I);
|
|
2830
|
+
return (T & 1) === 1 !== C && (I = t.neg(I)), { x: A, y: I };
|
|
2831
|
+
} else if (y === h && T === 4) {
|
|
2832
|
+
const A = t.BYTES, O = t.fromBytes(R.subarray(0, A)), I = t.fromBytes(R.subarray(A, A * 2));
|
|
2833
|
+
if (!S(O, I))
|
|
2825
2834
|
throw new Error("bad point: is not on curve");
|
|
2826
|
-
return { x: O, y:
|
|
2835
|
+
return { x: O, y: I };
|
|
2827
2836
|
} else
|
|
2828
2837
|
throw new Error(`bad point: got length ${y}, expected compressed=${u} or uncompressed=${h}`);
|
|
2829
2838
|
}
|
|
2830
|
-
const x = e.toBytes ||
|
|
2839
|
+
const x = e.toBytes || p, w = e.fromBytes || m;
|
|
2831
2840
|
function b(P) {
|
|
2832
2841
|
const u = t.sqr(P), h = t.mul(u, P);
|
|
2833
2842
|
return t.add(t.add(h, t.mul(P, o.a)), o.b);
|
|
@@ -2856,15 +2865,15 @@ function Ur(r, e = {}) {
|
|
|
2856
2865
|
return $r(P, c.basises, n.ORDER);
|
|
2857
2866
|
}
|
|
2858
2867
|
const Q = kt((P, u) => {
|
|
2859
|
-
const { X: h, Y: y, Z:
|
|
2860
|
-
if (t.eql(
|
|
2868
|
+
const { X: h, Y: y, Z: T } = P;
|
|
2869
|
+
if (t.eql(T, t.ONE))
|
|
2861
2870
|
return { x: h, y };
|
|
2862
2871
|
const R = P.is0();
|
|
2863
|
-
u == null && (u = R ? t.ONE : t.inv(
|
|
2864
|
-
const A = t.mul(h, u), O = t.mul(y, u),
|
|
2872
|
+
u == null && (u = R ? t.ONE : t.inv(T));
|
|
2873
|
+
const A = t.mul(h, u), O = t.mul(y, u), I = t.mul(T, u);
|
|
2865
2874
|
if (R)
|
|
2866
2875
|
return { x: t.ZERO, y: t.ZERO };
|
|
2867
|
-
if (!t.eql(
|
|
2876
|
+
if (!t.eql(I, t.ONE))
|
|
2868
2877
|
throw new Error("invZ was invalid");
|
|
2869
2878
|
return { x: A, y: O };
|
|
2870
2879
|
}), ve = kt((P) => {
|
|
@@ -2882,8 +2891,8 @@ function Ur(r, e = {}) {
|
|
|
2882
2891
|
throw new Error("bad point: not in prime-order subgroup");
|
|
2883
2892
|
return !0;
|
|
2884
2893
|
});
|
|
2885
|
-
function he(P, u, h, y,
|
|
2886
|
-
return h = new Z(t.mul(h.X, P), h.Y, h.Z), u = Ge(y, u), h = Ge(
|
|
2894
|
+
function he(P, u, h, y, T) {
|
|
2895
|
+
return h = new Z(t.mul(h.X, P), h.Y, h.Z), u = Ge(y, u), h = Ge(T, h), u.add(h);
|
|
2887
2896
|
}
|
|
2888
2897
|
const L = class L {
|
|
2889
2898
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
@@ -2941,8 +2950,8 @@ function Ur(r, e = {}) {
|
|
|
2941
2950
|
/** Compare one point to another. */
|
|
2942
2951
|
equals(u) {
|
|
2943
2952
|
D(u);
|
|
2944
|
-
const { X: h, Y: y, Z:
|
|
2945
|
-
return
|
|
2953
|
+
const { X: h, Y: y, Z: T } = this, { X: R, Y: A, Z: O } = u, I = t.eql(t.mul(h, O), t.mul(R, T)), C = t.eql(t.mul(y, O), t.mul(A, T));
|
|
2954
|
+
return I && C;
|
|
2946
2955
|
}
|
|
2947
2956
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
2948
2957
|
negate() {
|
|
@@ -2953,9 +2962,9 @@ function Ur(r, e = {}) {
|
|
|
2953
2962
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
2954
2963
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
2955
2964
|
double() {
|
|
2956
|
-
const { a: u, b: h } = o, y = t.mul(h, Me), { X:
|
|
2957
|
-
let O = t.ZERO,
|
|
2958
|
-
return k = t.add(k, k), C = t.mul(
|
|
2965
|
+
const { a: u, b: h } = o, y = t.mul(h, Me), { X: T, Y: R, Z: A } = this;
|
|
2966
|
+
let O = t.ZERO, I = t.ZERO, C = t.ZERO, N = t.mul(T, T), W = t.mul(R, R), U = t.mul(A, A), k = t.mul(T, R);
|
|
2967
|
+
return k = t.add(k, k), C = t.mul(T, A), C = t.add(C, C), O = t.mul(u, C), I = t.mul(y, U), I = t.add(O, I), O = t.sub(W, I), I = t.add(W, I), I = t.mul(O, I), O = t.mul(k, O), C = t.mul(y, C), U = t.mul(u, U), k = t.sub(N, U), k = t.mul(u, k), k = t.add(k, C), C = t.add(N, N), N = t.add(C, N), N = t.add(N, U), N = t.mul(N, k), I = t.add(I, N), U = t.mul(R, A), U = t.add(U, U), N = t.mul(U, k), O = t.sub(O, N), C = t.mul(U, W), C = t.add(C, C), C = t.add(C, C), new L(O, I, C);
|
|
2959
2968
|
}
|
|
2960
2969
|
// Renes-Costello-Batina exception-free addition formula.
|
|
2961
2970
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
@@ -2963,13 +2972,13 @@ function Ur(r, e = {}) {
|
|
|
2963
2972
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
2964
2973
|
add(u) {
|
|
2965
2974
|
D(u);
|
|
2966
|
-
const { X: h, Y: y, Z:
|
|
2967
|
-
let
|
|
2975
|
+
const { X: h, Y: y, Z: T } = this, { X: R, Y: A, Z: O } = u;
|
|
2976
|
+
let I = t.ZERO, C = t.ZERO, N = t.ZERO;
|
|
2968
2977
|
const W = o.a, U = t.mul(o.b, Me);
|
|
2969
|
-
let k = t.mul(h, R), j = t.mul(y, A), V = t.mul(
|
|
2970
|
-
ee = t.mul(ee, H), H = t.add(k, j), ee = t.sub(ee, H), H = t.add(h,
|
|
2978
|
+
let k = t.mul(h, R), j = t.mul(y, A), V = t.mul(T, O), ee = t.add(h, y), H = t.add(R, A);
|
|
2979
|
+
ee = t.mul(ee, H), H = t.add(k, j), ee = t.sub(ee, H), H = t.add(h, T);
|
|
2971
2980
|
let K = t.add(R, O);
|
|
2972
|
-
return H = t.mul(H, K), K = t.add(k, V), H = t.sub(H, K), K = t.add(y,
|
|
2981
|
+
return H = t.mul(H, K), K = t.add(k, V), H = t.sub(H, K), K = t.add(y, T), I = t.add(A, O), K = t.mul(K, I), I = t.add(j, V), K = t.sub(K, I), N = t.mul(W, H), I = t.mul(U, V), N = t.add(I, N), I = t.sub(j, N), N = t.add(j, N), C = t.mul(I, N), j = t.add(k, k), j = t.add(j, k), V = t.mul(W, V), H = t.mul(U, H), j = t.add(j, V), V = t.sub(k, V), V = t.mul(W, V), H = t.add(H, V), k = t.mul(j, H), C = t.add(C, k), k = t.mul(K, H), I = t.mul(ee, I), I = t.sub(I, k), k = t.mul(ee, j), N = t.mul(K, N), N = t.add(N, k), new L(I, C, N);
|
|
2973
2982
|
}
|
|
2974
2983
|
subtract(u) {
|
|
2975
2984
|
return this.add(u.negate());
|
|
@@ -2990,16 +2999,16 @@ function Ur(r, e = {}) {
|
|
|
2990
2999
|
const { endo: h } = e;
|
|
2991
3000
|
if (!n.isValidNot0(u))
|
|
2992
3001
|
throw new Error("invalid scalar: out of range");
|
|
2993
|
-
let y,
|
|
3002
|
+
let y, T;
|
|
2994
3003
|
const R = (A) => ne.cached(this, A, (O) => Lt(L, O));
|
|
2995
3004
|
if (h) {
|
|
2996
|
-
const { k1neg: A, k1: O, k2neg:
|
|
2997
|
-
|
|
3005
|
+
const { k1neg: A, k1: O, k2neg: I, k2: C } = M(u), { p: N, f: W } = R(O), { p: U, f: k } = R(C);
|
|
3006
|
+
T = W.add(k), y = he(h.beta, N, U, A, I);
|
|
2998
3007
|
} else {
|
|
2999
3008
|
const { p: A, f: O } = R(u);
|
|
3000
|
-
y = A,
|
|
3009
|
+
y = A, T = O;
|
|
3001
3010
|
}
|
|
3002
|
-
return Lt(L, [y,
|
|
3011
|
+
return Lt(L, [y, T])[0];
|
|
3003
3012
|
}
|
|
3004
3013
|
/**
|
|
3005
3014
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -3017,8 +3026,8 @@ function Ur(r, e = {}) {
|
|
|
3017
3026
|
if (ne.hasCache(this))
|
|
3018
3027
|
return this.multiply(u);
|
|
3019
3028
|
if (h) {
|
|
3020
|
-
const { k1neg:
|
|
3021
|
-
return he(h.beta,
|
|
3029
|
+
const { k1neg: T, k1: R, k2neg: A, k2: O } = M(u), { p1: I, p2: C } = Pr(L, y, R, O);
|
|
3030
|
+
return he(h.beta, I, C, T, A);
|
|
3022
3031
|
} else
|
|
3023
3032
|
return ne.unsafe(y, u);
|
|
3024
3033
|
}
|
|
@@ -3116,12 +3125,12 @@ function Fr(r, e = {}) {
|
|
|
3116
3125
|
const S = s.fromBytes(x);
|
|
3117
3126
|
return r.fromBytes(w).multiply(S).toBytes(b);
|
|
3118
3127
|
}
|
|
3119
|
-
const
|
|
3128
|
+
const p = {
|
|
3120
3129
|
isValidSecretKey: o,
|
|
3121
3130
|
isValidPublicKey: i,
|
|
3122
3131
|
randomSecretKey: a
|
|
3123
3132
|
}, m = Dr(a, c);
|
|
3124
|
-
return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: m, Point: r, utils:
|
|
3133
|
+
return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: m, Point: r, utils: p, lengths: n });
|
|
3125
3134
|
}
|
|
3126
3135
|
function Hr(r, e, s = {}) {
|
|
3127
3136
|
Kt(e), ut(s, {}, {
|
|
@@ -3131,7 +3140,7 @@ function Hr(r, e, s = {}) {
|
|
|
3131
3140
|
bits2int: "function",
|
|
3132
3141
|
bits2int_modN: "function"
|
|
3133
3142
|
}), s = Object.assign({}, s);
|
|
3134
|
-
const t = s.randomBytes || Xt, n = s.hmac || ((u, h) =>
|
|
3143
|
+
const t = s.randomBytes || Xt, n = s.hmac || ((u, h) => gs(e, u, h)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: d, getSharedSecret: p, utils: m, lengths: x } = Fr(r, s), w = {
|
|
3135
3144
|
prehash: !0,
|
|
3136
3145
|
lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
|
|
3137
3146
|
format: "compact",
|
|
@@ -3152,31 +3161,31 @@ function Hr(r, e, s = {}) {
|
|
|
3152
3161
|
}
|
|
3153
3162
|
function B(u, h) {
|
|
3154
3163
|
nt(h);
|
|
3155
|
-
const y = x.signature,
|
|
3156
|
-
return F(u,
|
|
3164
|
+
const y = x.signature, T = h === "compact" ? y : h === "recovered" ? y + 1 : void 0;
|
|
3165
|
+
return F(u, T);
|
|
3157
3166
|
}
|
|
3158
3167
|
class D {
|
|
3159
|
-
constructor(h, y,
|
|
3168
|
+
constructor(h, y, T) {
|
|
3160
3169
|
v(this, "r");
|
|
3161
3170
|
v(this, "s");
|
|
3162
3171
|
v(this, "recovery");
|
|
3163
|
-
if (this.r = E("r", h), this.s = E("s", y),
|
|
3164
|
-
if (q(), ![0, 1, 2, 3].includes(
|
|
3172
|
+
if (this.r = E("r", h), this.s = E("s", y), T != null) {
|
|
3173
|
+
if (q(), ![0, 1, 2, 3].includes(T))
|
|
3165
3174
|
throw new Error("invalid recovery id");
|
|
3166
|
-
this.recovery =
|
|
3175
|
+
this.recovery = T;
|
|
3167
3176
|
}
|
|
3168
3177
|
Object.freeze(this);
|
|
3169
3178
|
}
|
|
3170
3179
|
static fromBytes(h, y = w.format) {
|
|
3171
3180
|
B(h, y);
|
|
3172
|
-
let
|
|
3181
|
+
let T;
|
|
3173
3182
|
if (y === "der") {
|
|
3174
|
-
const { r:
|
|
3175
|
-
return new D(
|
|
3183
|
+
const { r: I, s: C } = ge.toSig(F(h));
|
|
3184
|
+
return new D(I, C);
|
|
3176
3185
|
}
|
|
3177
|
-
y === "recovered" && (
|
|
3186
|
+
y === "recovered" && (T = h[0], y = "compact", h = h.subarray(1));
|
|
3178
3187
|
const R = x.signature / 2, A = h.subarray(0, R), O = h.subarray(R, R * 2);
|
|
3179
|
-
return new D(i.fromBytes(A), i.fromBytes(O),
|
|
3188
|
+
return new D(i.fromBytes(A), i.fromBytes(O), T);
|
|
3180
3189
|
}
|
|
3181
3190
|
static fromHex(h, y) {
|
|
3182
3191
|
return this.fromBytes(Fe(h), y);
|
|
@@ -3191,10 +3200,10 @@ function Hr(r, e, s = {}) {
|
|
|
3191
3200
|
return new D(this.r, this.s, h);
|
|
3192
3201
|
}
|
|
3193
3202
|
recoverPublicKey(h) {
|
|
3194
|
-
const { r: y, s:
|
|
3203
|
+
const { r: y, s: T } = this, R = this.assertRecovery(), A = R === 2 || R === 3 ? y + a : y;
|
|
3195
3204
|
if (!o.isValid(A))
|
|
3196
3205
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
3197
|
-
const O = o.toBytes(A),
|
|
3206
|
+
const O = o.toBytes(A), I = r.fromBytes(_e(xs((R & 1) === 0), O)), C = i.inv(A), N = Q(F(h, void 0, "msgHash")), W = i.create(-N * C), U = i.create(T * C), k = r.BASE.multiplyUnsafe(W).add(I.multiplyUnsafe(U));
|
|
3198
3207
|
if (k.is0())
|
|
3199
3208
|
throw new Error("invalid recovery: point at infinify");
|
|
3200
3209
|
return k.assertValidity(), k;
|
|
@@ -3205,8 +3214,8 @@ function Hr(r, e, s = {}) {
|
|
|
3205
3214
|
}
|
|
3206
3215
|
toBytes(h = w.format) {
|
|
3207
3216
|
if (nt(h), h === "der")
|
|
3208
|
-
return Fe(
|
|
3209
|
-
const { r: y, s:
|
|
3217
|
+
return Fe(ge.hexFromSig(this));
|
|
3218
|
+
const { r: y, s: T } = this, R = i.toBytes(y), A = i.toBytes(T);
|
|
3210
3219
|
return h === "recovered" ? (q(), _e(Uint8Array.of(this.assertRecovery()), R, A)) : _e(R, A);
|
|
3211
3220
|
}
|
|
3212
3221
|
toHex(h) {
|
|
@@ -3216,8 +3225,8 @@ function Hr(r, e, s = {}) {
|
|
|
3216
3225
|
const M = s.bits2int || function(h) {
|
|
3217
3226
|
if (h.length > 8192)
|
|
3218
3227
|
throw new Error("input is too large");
|
|
3219
|
-
const y = je(h),
|
|
3220
|
-
return
|
|
3228
|
+
const y = je(h), T = h.length * 8 - c;
|
|
3229
|
+
return T > 0 ? y >> BigInt(T) : y;
|
|
3221
3230
|
}, Q = s.bits2int_modN || function(h) {
|
|
3222
3231
|
return i.create(M(h));
|
|
3223
3232
|
}, ve = dt(c);
|
|
@@ -3228,12 +3237,12 @@ function Hr(r, e, s = {}) {
|
|
|
3228
3237
|
return F(u, void 0, "message"), h ? F(e(u), void 0, "prehashed message") : u;
|
|
3229
3238
|
}
|
|
3230
3239
|
function xe(u, h, y) {
|
|
3231
|
-
const { lowS:
|
|
3240
|
+
const { lowS: T, prehash: R, extraEntropy: A } = et(y, w);
|
|
3232
3241
|
u = Z(u, R);
|
|
3233
|
-
const O = Q(u),
|
|
3234
|
-
if (!i.isValidNot0(
|
|
3242
|
+
const O = Q(u), I = i.fromBytes(h);
|
|
3243
|
+
if (!i.isValidNot0(I))
|
|
3235
3244
|
throw new Error("invalid private key");
|
|
3236
|
-
const C = [he(
|
|
3245
|
+
const C = [he(I), he(O)];
|
|
3237
3246
|
if (A != null && A !== !1) {
|
|
3238
3247
|
const k = A === !0 ? t(x.secretKey) : A;
|
|
3239
3248
|
C.push(F(k, void 0, "extraEntropy"));
|
|
@@ -3246,43 +3255,43 @@ function Hr(r, e, s = {}) {
|
|
|
3246
3255
|
const V = i.inv(j), ee = r.BASE.multiply(j).toAffine(), H = i.create(ee.x);
|
|
3247
3256
|
if (H === le)
|
|
3248
3257
|
return;
|
|
3249
|
-
const K = i.create(V * i.create(W + H *
|
|
3258
|
+
const K = i.create(V * i.create(W + H * I));
|
|
3250
3259
|
if (K === le)
|
|
3251
3260
|
return;
|
|
3252
3261
|
let xt = (ee.x === H ? 0 : 2) | Number(ee.y & Ee), mt = K;
|
|
3253
|
-
return
|
|
3262
|
+
return T && S(K) && (mt = i.neg(K), xt ^= 1), new D(H, mt, b ? void 0 : xt);
|
|
3254
3263
|
}
|
|
3255
3264
|
return { seed: N, k2sig: U };
|
|
3256
3265
|
}
|
|
3257
3266
|
function ne(u, h, y = {}) {
|
|
3258
|
-
const { seed:
|
|
3259
|
-
return yr(e.outputLen, i.BYTES, n)(
|
|
3267
|
+
const { seed: T, k2sig: R } = xe(u, h, y);
|
|
3268
|
+
return yr(e.outputLen, i.BYTES, n)(T, R).toBytes(y.format);
|
|
3260
3269
|
}
|
|
3261
|
-
function L(u, h, y,
|
|
3262
|
-
const { lowS: R, prehash: A, format: O } = et(
|
|
3270
|
+
function L(u, h, y, T = {}) {
|
|
3271
|
+
const { lowS: R, prehash: A, format: O } = et(T, w);
|
|
3263
3272
|
if (y = F(y, void 0, "publicKey"), h = Z(h, A), !at(u)) {
|
|
3264
|
-
const
|
|
3265
|
-
throw new Error("verify expects Uint8Array signature" +
|
|
3273
|
+
const I = u instanceof D ? ", use sig.toBytes()" : "";
|
|
3274
|
+
throw new Error("verify expects Uint8Array signature" + I);
|
|
3266
3275
|
}
|
|
3267
3276
|
B(u, O);
|
|
3268
3277
|
try {
|
|
3269
|
-
const
|
|
3270
|
-
if (R &&
|
|
3278
|
+
const I = D.fromBytes(u, O), C = r.fromBytes(y);
|
|
3279
|
+
if (R && I.hasHighS())
|
|
3271
3280
|
return !1;
|
|
3272
|
-
const { r: N, s: W } =
|
|
3281
|
+
const { r: N, s: W } = I, U = Q(h), k = i.inv(W), j = i.create(U * k), V = i.create(N * k), ee = r.BASE.multiplyUnsafe(j).add(C.multiplyUnsafe(V));
|
|
3273
3282
|
return ee.is0() ? !1 : i.create(ee.x) === N;
|
|
3274
3283
|
} catch {
|
|
3275
3284
|
return !1;
|
|
3276
3285
|
}
|
|
3277
3286
|
}
|
|
3278
3287
|
function P(u, h, y = {}) {
|
|
3279
|
-
const { prehash:
|
|
3280
|
-
return h = Z(h,
|
|
3288
|
+
const { prehash: T } = et(y, w);
|
|
3289
|
+
return h = Z(h, T), D.fromBytes(u, "recovered").recoverPublicKey(h).toBytes();
|
|
3281
3290
|
}
|
|
3282
3291
|
return Object.freeze({
|
|
3283
3292
|
keygen: l,
|
|
3284
3293
|
getPublicKey: d,
|
|
3285
|
-
getSharedSecret:
|
|
3294
|
+
getSharedSecret: p,
|
|
3286
3295
|
utils: m,
|
|
3287
3296
|
lengths: x,
|
|
3288
3297
|
Point: r,
|
|
@@ -3310,7 +3319,7 @@ const ft = {
|
|
|
3310
3319
|
]
|
|
3311
3320
|
}, Ut = /* @__PURE__ */ BigInt(2);
|
|
3312
3321
|
function qr(r) {
|
|
3313
|
-
const e = ft.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,
|
|
3322
|
+
const e = ft.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, p = se(d, s, e) * d % e, m = se(p, s, e) * d % e, x = se(m, Ut, e) * l % e, w = se(x, n, e) * x % e, b = se(w, o, e) * w % e, S = se(b, a, e) * b % e, E = se(S, c, e) * S % e, q = se(E, a, e) * b % e, B = se(q, s, e) * d % e, D = se(B, i, e) * w % e, M = se(D, t, e) * l % e, Q = se(M, Ut, e);
|
|
3314
3323
|
if (!ot.eql(ot.sqr(Q), r))
|
|
3315
3324
|
throw new Error("Cannot find square root");
|
|
3316
3325
|
return Q;
|
|
@@ -3318,7 +3327,7 @@ function qr(r) {
|
|
|
3318
3327
|
const ot = Ve(ft.p, { sqrt: qr }), Wr = /* @__PURE__ */ Ur(ft, {
|
|
3319
3328
|
Fp: ot,
|
|
3320
3329
|
endo: Gr
|
|
3321
|
-
}), jr = /* @__PURE__ */ Hr(Wr,
|
|
3330
|
+
}), jr = /* @__PURE__ */ Hr(Wr, gr), Vr = BigInt(0), Re = BigInt(1), Kr = BigInt(2), zr = BigInt(7), Yr = BigInt(256), Zr = BigInt(113), ws = [], ys = [], bs = [];
|
|
3322
3331
|
for (let r = 0, e = Re, s = 1, t = 0; r < 24; r++) {
|
|
3323
3332
|
[s, t] = [t, (2 * s + 3 * t) % 5], ws.push(2 * (5 * t + s)), ys.push((r + 1) * (r + 2) / 2 % 64);
|
|
3324
3333
|
let n = Vr;
|
|
@@ -3333,9 +3342,9 @@ function Qr(r, e = 24) {
|
|
|
3333
3342
|
for (let i = 0; i < 10; i++)
|
|
3334
3343
|
s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
|
|
3335
3344
|
for (let i = 0; i < 10; i += 2) {
|
|
3336
|
-
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1],
|
|
3345
|
+
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], p = Ft(l, d, 1) ^ s[a], m = Ht(l, d, 1) ^ s[a + 1];
|
|
3337
3346
|
for (let x = 0; x < 50; x += 10)
|
|
3338
|
-
r[i + x] ^=
|
|
3347
|
+
r[i + x] ^= p, r[i + x + 1] ^= m;
|
|
3339
3348
|
}
|
|
3340
3349
|
let n = r[2], o = r[3];
|
|
3341
3350
|
for (let i = 0; i < 24; i++) {
|
|
@@ -3350,9 +3359,9 @@ function Qr(r, e = 24) {
|
|
|
3350
3359
|
}
|
|
3351
3360
|
r[0] ^= Xr[t], r[1] ^= Jr[t];
|
|
3352
3361
|
}
|
|
3353
|
-
|
|
3362
|
+
Te(s);
|
|
3354
3363
|
}
|
|
3355
|
-
class
|
|
3364
|
+
class pt {
|
|
3356
3365
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
3357
3366
|
constructor(e, s, t, n = !1, o = 24) {
|
|
3358
3367
|
v(this, "state");
|
|
@@ -3377,7 +3386,7 @@ class gt {
|
|
|
3377
3386
|
Rt(this.state32), Qr(this.state32, this.rounds), Rt(this.state32), this.posOut = 0, this.pos = 0;
|
|
3378
3387
|
}
|
|
3379
3388
|
update(e) {
|
|
3380
|
-
|
|
3389
|
+
Ie(this), F(e);
|
|
3381
3390
|
const { blockLen: s, state: t } = this, n = e.length;
|
|
3382
3391
|
for (let o = 0; o < n; ) {
|
|
3383
3392
|
const i = Math.min(s - this.pos, n - o);
|
|
@@ -3395,7 +3404,7 @@ class gt {
|
|
|
3395
3404
|
e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
|
|
3396
3405
|
}
|
|
3397
3406
|
writeInto(e) {
|
|
3398
|
-
|
|
3407
|
+
Ie(this, !1), F(e), this.finish();
|
|
3399
3408
|
const s = this.state, { blockLen: t } = this;
|
|
3400
3409
|
for (let n = 0, o = e.length; n < o; ) {
|
|
3401
3410
|
this.posOut >= t && this.keccak();
|
|
@@ -3421,14 +3430,14 @@ class gt {
|
|
|
3421
3430
|
return this.digestInto(new Uint8Array(this.outputLen));
|
|
3422
3431
|
}
|
|
3423
3432
|
destroy() {
|
|
3424
|
-
this.destroyed = !0,
|
|
3433
|
+
this.destroyed = !0, Te(this.state);
|
|
3425
3434
|
}
|
|
3426
3435
|
_cloneInto(e) {
|
|
3427
3436
|
const { blockLen: s, suffix: t, outputLen: n, rounds: o, enableXOF: i } = this;
|
|
3428
|
-
return e || (e = new
|
|
3437
|
+
return e || (e = new pt(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;
|
|
3429
3438
|
}
|
|
3430
3439
|
}
|
|
3431
|
-
const en = (r, e, s, t = {}) => Zt(() => new
|
|
3440
|
+
const en = (r, e, s, t = {}) => Zt(() => new pt(e, r, s), t), Gt = /* @__PURE__ */ en(1, 136, 32);
|
|
3432
3441
|
class tn {
|
|
3433
3442
|
async verifyJWT(e, s) {
|
|
3434
3443
|
try {
|
|
@@ -3468,7 +3477,7 @@ ${t.length}`
|
|
|
3468
3477
|
const i = Gt(o), a = s.startsWith("0x") ? s.slice(2) : s;
|
|
3469
3478
|
if (a.length !== 130)
|
|
3470
3479
|
throw new Error(`Invalid signature length: expected 130 hex chars, got ${a.length}`);
|
|
3471
|
-
const c = sn(a), l = c.slice(0, 32), d = c.slice(32, 64),
|
|
3480
|
+
const c = sn(a), l = c.slice(0, 32), d = c.slice(32, 64), p = c[64], m = p >= 27 ? p - 27 : p, b = new jr.Signature(
|
|
3472
3481
|
qt(l),
|
|
3473
3482
|
qt(d)
|
|
3474
3483
|
).addRecoveryBit(m).recoverPublicKey(i).toBytes(!1).slice(1), S = Gt(b);
|
|
@@ -3518,19 +3527,19 @@ class nn {
|
|
|
3518
3527
|
}
|
|
3519
3528
|
}
|
|
3520
3529
|
}
|
|
3521
|
-
class
|
|
3530
|
+
class gt {
|
|
3522
3531
|
static generateState() {
|
|
3523
3532
|
const e = new Uint8Array(16);
|
|
3524
3533
|
return crypto.getRandomValues(e), Array.from(e, (s) => s.toString(16).padStart(2, "0")).join("");
|
|
3525
3534
|
}
|
|
3526
3535
|
openAuth(e) {
|
|
3527
3536
|
return new Promise((s, t) => {
|
|
3528
|
-
const n = e.width ?? 500, o = e.height ?? 600, i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c =
|
|
3537
|
+
const n = e.width ?? 500, o = e.height ?? 600, i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = gt.generateState(), l = e.authUrl.includes("?") ? "&" : "?", d = `${e.authUrl}${l}state=${c}`, p = window.open(
|
|
3529
3538
|
d,
|
|
3530
3539
|
"CROSSx OAuth",
|
|
3531
3540
|
`width=${n},height=${o},left=${i},top=${a}`
|
|
3532
3541
|
);
|
|
3533
|
-
if (!
|
|
3542
|
+
if (!p) {
|
|
3534
3543
|
t(new Error("팝업 창을 열 수 없습니다. 팝업 차단을 해제해 주세요."));
|
|
3535
3544
|
return;
|
|
3536
3545
|
}
|
|
@@ -3547,7 +3556,7 @@ class pt {
|
|
|
3547
3556
|
}, q = setInterval(() => {
|
|
3548
3557
|
b++;
|
|
3549
3558
|
try {
|
|
3550
|
-
|
|
3559
|
+
p.closed && (b <= x ? E() : (B(), t(new Error("로그인이 취소되었습니다"))));
|
|
3551
3560
|
} catch {
|
|
3552
3561
|
E();
|
|
3553
3562
|
}
|
|
@@ -3592,7 +3601,7 @@ class on {
|
|
|
3592
3601
|
};
|
|
3593
3602
|
return await this.storage.set(Oe, t), t;
|
|
3594
3603
|
} catch (s) {
|
|
3595
|
-
throw new _(
|
|
3604
|
+
throw new _(g.WALLET_CREATION_FAILED, "Wallet creation failed", s);
|
|
3596
3605
|
}
|
|
3597
3606
|
}
|
|
3598
3607
|
async getAddresses(e) {
|
|
@@ -3665,7 +3674,7 @@ class qe {
|
|
|
3665
3674
|
const e = this.tokenStore.get();
|
|
3666
3675
|
if (!e)
|
|
3667
3676
|
throw new _(
|
|
3668
|
-
|
|
3677
|
+
g.AUTH_NOT_AUTHENTICATED,
|
|
3669
3678
|
"No auth token found. Please sign in first."
|
|
3670
3679
|
);
|
|
3671
3680
|
return e;
|
|
@@ -3686,16 +3695,16 @@ class qe {
|
|
|
3686
3695
|
})).data;
|
|
3687
3696
|
if (d && typeof d.code == "number") {
|
|
3688
3697
|
if (d.code < 0 || d.code >= 400) {
|
|
3689
|
-
const
|
|
3698
|
+
const p = d.message || d.data || "API request failed";
|
|
3690
3699
|
f.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
|
|
3691
3700
|
code: d.code,
|
|
3692
|
-
message:
|
|
3701
|
+
message: p,
|
|
3693
3702
|
url: o,
|
|
3694
3703
|
method: e,
|
|
3695
3704
|
fullResponse: d
|
|
3696
3705
|
});
|
|
3697
|
-
const m = qe.mapGatewayError(d.code), x = qe.getGatewayErrorMessage(d.code,
|
|
3698
|
-
throw w.gatewayCode = d.code, w.gatewayMessage =
|
|
3706
|
+
const m = qe.mapGatewayError(d.code), x = qe.getGatewayErrorMessage(d.code, p), w = new _(m, x);
|
|
3707
|
+
throw w.gatewayCode = d.code, w.gatewayMessage = p, w;
|
|
3699
3708
|
}
|
|
3700
3709
|
return f.log("[CROSSx] Wallet Gateway API 성공:", { code: d.code, url: o, method: e }), d.data ?? d;
|
|
3701
3710
|
}
|
|
@@ -3703,16 +3712,16 @@ class qe {
|
|
|
3703
3712
|
} catch (l) {
|
|
3704
3713
|
if (l instanceof _) throw l;
|
|
3705
3714
|
if ((a = l.response) != null && a.data) {
|
|
3706
|
-
const d = l.response.data,
|
|
3715
|
+
const d = l.response.data, p = d.message || d.data || "API request failed", m = d.code || "UNKNOWN";
|
|
3707
3716
|
throw f.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
|
|
3708
3717
|
code: m,
|
|
3709
|
-
message:
|
|
3718
|
+
message: p,
|
|
3710
3719
|
url: o,
|
|
3711
3720
|
method: e,
|
|
3712
3721
|
status: (c = l.response) == null ? void 0 : c.status
|
|
3713
3722
|
}), new _(
|
|
3714
|
-
|
|
3715
|
-
`Wallet Gateway error (${m}): ${
|
|
3723
|
+
g.UNKNOWN_ERROR,
|
|
3724
|
+
`Wallet Gateway error (${m}): ${p}`
|
|
3716
3725
|
);
|
|
3717
3726
|
}
|
|
3718
3727
|
throw l;
|
|
@@ -3786,15 +3795,15 @@ class qe {
|
|
|
3786
3795
|
switch (e) {
|
|
3787
3796
|
case "sign":
|
|
3788
3797
|
case "send":
|
|
3789
|
-
if (!s.tx) throw new _(
|
|
3798
|
+
if (!s.tx) throw new _(g.TX_INVALID_PARAMS, "prepare: tx is required");
|
|
3790
3799
|
t = { unsignedTx: this.buildUnsignedTx(s.tx) };
|
|
3791
3800
|
break;
|
|
3792
3801
|
case "sign-message":
|
|
3793
|
-
if (!s.message) throw new _(
|
|
3802
|
+
if (!s.message) throw new _(g.TX_INVALID_PARAMS, "prepare: message is required");
|
|
3794
3803
|
t = { message: s.message }, s.from && (t.from = s.from);
|
|
3795
3804
|
break;
|
|
3796
3805
|
case "sign-typed-data":
|
|
3797
|
-
if (!s.typedData) throw new _(
|
|
3806
|
+
if (!s.typedData) throw new _(g.TX_INVALID_PARAMS, "prepare: typedData is required");
|
|
3798
3807
|
t = { typedData: s.typedData }, s.from && (t.from = s.from);
|
|
3799
3808
|
break;
|
|
3800
3809
|
}
|
|
@@ -3882,37 +3891,37 @@ class qe {
|
|
|
3882
3891
|
static mapGatewayError(e) {
|
|
3883
3892
|
switch (e) {
|
|
3884
3893
|
case -10002:
|
|
3885
|
-
return
|
|
3894
|
+
return g.AUTH_NOT_AUTHENTICATED;
|
|
3886
3895
|
case -10001:
|
|
3887
3896
|
case -10009:
|
|
3888
|
-
return
|
|
3897
|
+
return g.UNKNOWN_ERROR;
|
|
3889
3898
|
case -10006:
|
|
3890
|
-
return
|
|
3899
|
+
return g.GATEWAY_INTERNAL_ERROR;
|
|
3891
3900
|
case -10008:
|
|
3892
|
-
return
|
|
3901
|
+
return g.GATEWAY_LOCK_CONFLICT;
|
|
3893
3902
|
case -10010:
|
|
3894
|
-
return
|
|
3903
|
+
return g.MIGRATION_FAILED;
|
|
3895
3904
|
case -10012:
|
|
3896
|
-
return
|
|
3905
|
+
return g.MIGRATION_BACKUP_EXISTS;
|
|
3897
3906
|
case -10022:
|
|
3898
|
-
return
|
|
3907
|
+
return g.PROJECT_NOT_REGISTERED;
|
|
3899
3908
|
case -10023:
|
|
3900
|
-
return
|
|
3909
|
+
return g.PROJECT_ID_MISSING;
|
|
3901
3910
|
case -10024:
|
|
3902
|
-
return
|
|
3911
|
+
return g.ORIGIN_NOT_ALLOWED;
|
|
3903
3912
|
case -10026:
|
|
3904
|
-
return
|
|
3913
|
+
return g.TYPED_DATA_CHAIN_ID_MISMATCH;
|
|
3905
3914
|
case -10014:
|
|
3906
3915
|
case -10015:
|
|
3907
3916
|
case -10019:
|
|
3908
|
-
return
|
|
3917
|
+
return g.PREPARE_FAILED;
|
|
3909
3918
|
case -10016:
|
|
3910
|
-
return
|
|
3919
|
+
return g.PREPARE_EXPIRED;
|
|
3911
3920
|
case -10017:
|
|
3912
3921
|
case -10018:
|
|
3913
|
-
return
|
|
3922
|
+
return g.PREPARE_MISMATCH;
|
|
3914
3923
|
default:
|
|
3915
|
-
return
|
|
3924
|
+
return g.UNKNOWN_ERROR;
|
|
3916
3925
|
}
|
|
3917
3926
|
}
|
|
3918
3927
|
static getGatewayErrorMessage(e, s) {
|
|
@@ -4001,7 +4010,7 @@ class Ce {
|
|
|
4001
4010
|
);
|
|
4002
4011
|
if (s) return s;
|
|
4003
4012
|
throw new _(
|
|
4004
|
-
|
|
4013
|
+
g.CHAIN_NOT_SUPPORTED,
|
|
4005
4014
|
`Unsupported chain: ${e}`
|
|
4006
4015
|
);
|
|
4007
4016
|
}
|
|
@@ -4014,19 +4023,19 @@ class Ce {
|
|
|
4014
4023
|
static mapErrorCode(e) {
|
|
4015
4024
|
switch (e) {
|
|
4016
4025
|
case -10020:
|
|
4017
|
-
return
|
|
4026
|
+
return g.CHAIN_NOT_SUPPORTED;
|
|
4018
4027
|
case -10021:
|
|
4019
|
-
return
|
|
4028
|
+
return g.INVALID_CHAIN;
|
|
4020
4029
|
case -10022:
|
|
4021
|
-
return
|
|
4030
|
+
return g.PROJECT_NOT_REGISTERED;
|
|
4022
4031
|
case -10023:
|
|
4023
|
-
return
|
|
4032
|
+
return g.PROJECT_ID_MISSING;
|
|
4024
4033
|
case -10024:
|
|
4025
|
-
return
|
|
4034
|
+
return g.APP_IDENTIFIER_MISSING;
|
|
4026
4035
|
case -10025:
|
|
4027
|
-
return
|
|
4036
|
+
return g.INVALID_APP_TYPE;
|
|
4028
4037
|
default:
|
|
4029
|
-
return
|
|
4038
|
+
return g.UNKNOWN_ERROR;
|
|
4030
4039
|
}
|
|
4031
4040
|
}
|
|
4032
4041
|
}
|
|
@@ -4181,12 +4190,14 @@ const cn = `
|
|
|
4181
4190
|
outline: none;
|
|
4182
4191
|
}
|
|
4183
4192
|
.__crossx-close:hover,
|
|
4184
|
-
.__crossx-close:focus
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4193
|
+
.__crossx-close:focus,
|
|
4194
|
+
.__crossx-close:active {
|
|
4195
|
+
background: none !important;
|
|
4196
|
+
box-shadow: none !important;
|
|
4197
|
+
outline: none !important;
|
|
4198
|
+
filter: none !important;
|
|
4199
|
+
transform: none !important;
|
|
4200
|
+
opacity: 1 !important;
|
|
4190
4201
|
}
|
|
4191
4202
|
.__crossx-close svg { display: block; }
|
|
4192
4203
|
|
|
@@ -4253,9 +4264,17 @@ const cn = `
|
|
|
4253
4264
|
align-items: center;
|
|
4254
4265
|
flex-shrink: 0;
|
|
4255
4266
|
opacity: 0.7;
|
|
4256
|
-
transition: opacity 0.12s;
|
|
4257
4267
|
}
|
|
4258
|
-
.__crossx-copy-btn:hover
|
|
4268
|
+
.__crossx-copy-btn:hover,
|
|
4269
|
+
.__crossx-copy-btn:focus,
|
|
4270
|
+
.__crossx-copy-btn:active {
|
|
4271
|
+
opacity: 0.7 !important;
|
|
4272
|
+
box-shadow: none !important;
|
|
4273
|
+
outline: none !important;
|
|
4274
|
+
filter: none !important;
|
|
4275
|
+
transform: none !important;
|
|
4276
|
+
background: none !important;
|
|
4277
|
+
}
|
|
4259
4278
|
|
|
4260
4279
|
/* Amount pill */
|
|
4261
4280
|
.__crossx-pill {
|
|
@@ -4355,14 +4374,15 @@ const cn = `
|
|
|
4355
4374
|
outline: none;
|
|
4356
4375
|
}
|
|
4357
4376
|
.__crossx-recover-btn:hover,
|
|
4358
|
-
.__crossx-recover-btn:focus
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4377
|
+
.__crossx-recover-btn:focus,
|
|
4378
|
+
.__crossx-recover-btn:active {
|
|
4379
|
+
background: var(--cx-pill-bg) !important;
|
|
4380
|
+
border-color: var(--cx-pill-bg) !important;
|
|
4381
|
+
opacity: 1 !important;
|
|
4382
|
+
box-shadow: none !important;
|
|
4383
|
+
outline: none !important;
|
|
4384
|
+
filter: none !important;
|
|
4385
|
+
transform: none !important;
|
|
4366
4386
|
}
|
|
4367
4387
|
.__crossx-recover-label {
|
|
4368
4388
|
font-size: 18px;
|
|
@@ -4392,15 +4412,16 @@ const cn = `
|
|
|
4392
4412
|
outline: none;
|
|
4393
4413
|
}
|
|
4394
4414
|
.__crossx-skip-btn:hover,
|
|
4395
|
-
.__crossx-skip-btn:focus
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4415
|
+
.__crossx-skip-btn:focus,
|
|
4416
|
+
.__crossx-skip-btn:active {
|
|
4417
|
+
background: none !important;
|
|
4418
|
+
color: var(--cx-subtitle) !important;
|
|
4419
|
+
opacity: 1 !important;
|
|
4420
|
+
box-shadow: none !important;
|
|
4421
|
+
outline: none !important;
|
|
4422
|
+
filter: none !important;
|
|
4423
|
+
transform: none !important;
|
|
4424
|
+
text-decoration: underline !important;
|
|
4404
4425
|
}
|
|
4405
4426
|
|
|
4406
4427
|
/* ── PIN Input Modal ───────────────────────────────────────────── */
|
|
@@ -4571,10 +4592,18 @@ const cn = `
|
|
|
4571
4592
|
font-weight: 700;
|
|
4572
4593
|
line-height: 1.3;
|
|
4573
4594
|
cursor: pointer;
|
|
4574
|
-
transition: opacity 0.12s, transform 0.1s;
|
|
4575
4595
|
}
|
|
4576
|
-
.__crossx-approve-btn:hover
|
|
4577
|
-
.__crossx-approve-btn:
|
|
4596
|
+
.__crossx-approve-btn:hover,
|
|
4597
|
+
.__crossx-approve-btn:focus,
|
|
4598
|
+
.__crossx-approve-btn:active {
|
|
4599
|
+
opacity: 1 !important;
|
|
4600
|
+
box-shadow: none !important;
|
|
4601
|
+
outline: none !important;
|
|
4602
|
+
filter: none !important;
|
|
4603
|
+
transform: none !important;
|
|
4604
|
+
background: var(--cx-primary) !important;
|
|
4605
|
+
color: var(--cx-on-primary) !important;
|
|
4606
|
+
}
|
|
4578
4607
|
.__crossx-btn-row {
|
|
4579
4608
|
display: flex;
|
|
4580
4609
|
gap: 8px;
|
|
@@ -4592,9 +4621,18 @@ const cn = `
|
|
|
4592
4621
|
font-weight: 700;
|
|
4593
4622
|
line-height: 1.3;
|
|
4594
4623
|
cursor: pointer;
|
|
4595
|
-
transition: opacity 0.12s;
|
|
4596
4624
|
}
|
|
4597
|
-
.__crossx-cancel-btn:hover
|
|
4625
|
+
.__crossx-cancel-btn:hover,
|
|
4626
|
+
.__crossx-cancel-btn:focus,
|
|
4627
|
+
.__crossx-cancel-btn:active {
|
|
4628
|
+
opacity: 1 !important;
|
|
4629
|
+
box-shadow: none !important;
|
|
4630
|
+
outline: none !important;
|
|
4631
|
+
filter: none !important;
|
|
4632
|
+
transform: none !important;
|
|
4633
|
+
background: none !important;
|
|
4634
|
+
color: var(--cx-primary) !important;
|
|
4635
|
+
}
|
|
4598
4636
|
.__crossx-confirm-btn {
|
|
4599
4637
|
flex: 1;
|
|
4600
4638
|
padding: 16px;
|
|
@@ -4607,10 +4645,18 @@ const cn = `
|
|
|
4607
4645
|
font-weight: 700;
|
|
4608
4646
|
line-height: 1.3;
|
|
4609
4647
|
cursor: pointer;
|
|
4610
|
-
transition: opacity 0.12s, transform 0.1s;
|
|
4611
4648
|
}
|
|
4612
|
-
.__crossx-confirm-btn:hover
|
|
4613
|
-
.__crossx-confirm-btn:
|
|
4649
|
+
.__crossx-confirm-btn:hover,
|
|
4650
|
+
.__crossx-confirm-btn:focus,
|
|
4651
|
+
.__crossx-confirm-btn:active {
|
|
4652
|
+
opacity: 1 !important;
|
|
4653
|
+
box-shadow: none !important;
|
|
4654
|
+
outline: none !important;
|
|
4655
|
+
filter: none !important;
|
|
4656
|
+
transform: none !important;
|
|
4657
|
+
background: var(--cx-primary) !important;
|
|
4658
|
+
color: var(--cx-on-primary) !important;
|
|
4659
|
+
}
|
|
4614
4660
|
|
|
4615
4661
|
/* ── Transaction Progress / Complete Modal ─────────────────── */
|
|
4616
4662
|
@keyframes __crossx-spinner {
|
|
@@ -4691,13 +4737,17 @@ const cn = `
|
|
|
4691
4737
|
-webkit-tap-highlight-color: transparent;
|
|
4692
4738
|
box-shadow: none;
|
|
4693
4739
|
outline: none;
|
|
4694
|
-
transition: opacity 0.12s;
|
|
4695
4740
|
min-width: 0;
|
|
4696
4741
|
}
|
|
4697
|
-
.__crossx-login-btn:hover
|
|
4698
|
-
.__crossx-login-btn:focus
|
|
4699
|
-
|
|
4700
|
-
|
|
4742
|
+
.__crossx-login-btn:hover,
|
|
4743
|
+
.__crossx-login-btn:focus,
|
|
4744
|
+
.__crossx-login-btn:active {
|
|
4745
|
+
opacity: 1 !important;
|
|
4746
|
+
box-shadow: none !important;
|
|
4747
|
+
outline: none !important;
|
|
4748
|
+
filter: none !important;
|
|
4749
|
+
transform: none !important;
|
|
4750
|
+
background: var(--cx-pill-bg) !important;
|
|
4701
4751
|
}
|
|
4702
4752
|
.__crossx-login-btn-label {
|
|
4703
4753
|
font-size: 18px;
|
|
@@ -4731,14 +4781,16 @@ const cn = `
|
|
|
4731
4781
|
text-decoration: none;
|
|
4732
4782
|
}
|
|
4733
4783
|
.__crossx-login-terms-link:hover,
|
|
4734
|
-
.__crossx-login-terms-link:focus
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4784
|
+
.__crossx-login-terms-link:focus,
|
|
4785
|
+
.__crossx-login-terms-link:active {
|
|
4786
|
+
color: var(--cx-primary) !important;
|
|
4787
|
+
text-decoration: none !important;
|
|
4788
|
+
opacity: 1 !important;
|
|
4789
|
+
background: none !important;
|
|
4790
|
+
box-shadow: none !important;
|
|
4791
|
+
outline: none !important;
|
|
4792
|
+
filter: none !important;
|
|
4793
|
+
transform: none !important;
|
|
4742
4794
|
}
|
|
4743
4795
|
|
|
4744
4796
|
/* ── Wallet Selector Modal ─────────────────────────────────── */
|
|
@@ -4773,11 +4825,18 @@ const cn = `
|
|
|
4773
4825
|
box-shadow: none;
|
|
4774
4826
|
outline: none;
|
|
4775
4827
|
width: 100%;
|
|
4776
|
-
transition: opacity 0.12s;
|
|
4777
4828
|
font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
4778
4829
|
}
|
|
4779
|
-
.__crossx-wallet-item:hover
|
|
4780
|
-
.__crossx-wallet-item:focus
|
|
4830
|
+
.__crossx-wallet-item:hover,
|
|
4831
|
+
.__crossx-wallet-item:focus,
|
|
4832
|
+
.__crossx-wallet-item:active {
|
|
4833
|
+
opacity: 1 !important;
|
|
4834
|
+
box-shadow: none !important;
|
|
4835
|
+
outline: none !important;
|
|
4836
|
+
filter: none !important;
|
|
4837
|
+
transform: none !important;
|
|
4838
|
+
background: var(--cx-pill-bg) !important;
|
|
4839
|
+
}
|
|
4781
4840
|
.__crossx-wallet-addr {
|
|
4782
4841
|
font-size: 16px;
|
|
4783
4842
|
font-weight: 600;
|
|
@@ -4801,12 +4860,19 @@ const cn = `
|
|
|
4801
4860
|
outline: none;
|
|
4802
4861
|
background: none;
|
|
4803
4862
|
width: 100%;
|
|
4804
|
-
transition: opacity 0.12s;
|
|
4805
4863
|
flex-shrink: 0;
|
|
4806
4864
|
font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
4807
4865
|
}
|
|
4808
|
-
.__crossx-wallet-add:hover
|
|
4809
|
-
.__crossx-wallet-add:focus
|
|
4866
|
+
.__crossx-wallet-add:hover,
|
|
4867
|
+
.__crossx-wallet-add:focus,
|
|
4868
|
+
.__crossx-wallet-add:active {
|
|
4869
|
+
opacity: 1 !important;
|
|
4870
|
+
box-shadow: none !important;
|
|
4871
|
+
outline: none !important;
|
|
4872
|
+
filter: none !important;
|
|
4873
|
+
transform: none !important;
|
|
4874
|
+
background: none !important;
|
|
4875
|
+
}
|
|
4810
4876
|
.__crossx-wallet-add:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
4811
4877
|
.__crossx-wallet-add-icon {
|
|
4812
4878
|
width: 24px;
|
|
@@ -5072,7 +5138,7 @@ const _t = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
|
5072
5138
|
<rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
|
|
5073
5139
|
</svg>`, fn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
5074
5140
|
<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-secondary)"/>
|
|
5075
|
-
</svg>`,
|
|
5141
|
+
</svg>`, pn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
5076
5142
|
<circle cx="12" cy="12" r="12" fill="var(--cx-secondary)"/>
|
|
5077
5143
|
<circle cx="12" cy="12" r="5.5" stroke="white" stroke-width="1.5"/>
|
|
5078
5144
|
<path d="M12 9.5v3l2 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
|
|
@@ -5108,7 +5174,7 @@ function G(r, e) {
|
|
|
5108
5174
|
<div class="__crossx-row-value">${e}</div>
|
|
5109
5175
|
</div>`;
|
|
5110
5176
|
}
|
|
5111
|
-
function
|
|
5177
|
+
function gn(r, e) {
|
|
5112
5178
|
const s = e, t = Ke(), n = r.to ? `<span class="__crossx-addr-text">${Y(r.to)}</span>
|
|
5113
5179
|
<button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", o = Es(r), i = r.data && r.data !== "0x" ? r.data : "0x", a = document.createElement("div");
|
|
5114
5180
|
return a.id = te, a.innerHTML = `
|
|
@@ -5251,7 +5317,7 @@ function yn(r, e) {
|
|
|
5251
5317
|
function bn(r, e, s) {
|
|
5252
5318
|
const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
|
|
5253
5319
|
if (o) {
|
|
5254
|
-
const w = n ?
|
|
5320
|
+
const w = n ? pn : t ? "" : fn, b = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
|
|
5255
5321
|
w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${b}</span>`) : o.textContent = b;
|
|
5256
5322
|
}
|
|
5257
5323
|
if (i && !r.querySelector("#__crossx-close-btn")) {
|
|
@@ -5262,7 +5328,7 @@ function bn(r, e, s) {
|
|
|
5262
5328
|
if (!a) return;
|
|
5263
5329
|
const c = e.from ? G("From", `<span class="__crossx-addr-text">${Y(e.from)}</span>
|
|
5264
5330
|
<button class="__crossx-copy-btn" data-copy="${$(e.from)}" title="Copy address">${de}</button>`) : "", l = e.to ? G("To", `<span class="__crossx-addr-text">${Y(e.to)}</span>
|
|
5265
|
-
<button class="__crossx-copy-btn" data-copy="${$(e.to)}" title="Copy address">${de}</button>`) : "", d = e.amount ? G("Transfer", `<span>${$(e.amount)}</span>`) : "",
|
|
5331
|
+
<button class="__crossx-copy-btn" data-copy="${$(e.to)}" title="Copy address">${de}</button>`) : "", d = e.amount ? G("Transfer", `<span>${$(e.amount)}</span>`) : "", p = e.fees ? G("Tx Fee", `<span>${$(e.fees)}</span>`) : "", m = e.txHash ? G("Tx Hash", `<span class="__crossx-addr-text">${Y(e.txHash)}</span>
|
|
5266
5332
|
<button class="__crossx-copy-btn" data-copy="${$(e.txHash)}" title="Copy hash">${de}</button>`) : "", x = e.total ? `<div class="__crossx-total-pill">
|
|
5267
5333
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
5268
5334
|
<span class="__crossx-total-amount">${$(e.total)}</span>
|
|
@@ -5272,7 +5338,7 @@ function bn(r, e, s) {
|
|
|
5272
5338
|
${c}
|
|
5273
5339
|
${l}
|
|
5274
5340
|
${d}
|
|
5275
|
-
${
|
|
5341
|
+
${p}
|
|
5276
5342
|
${m}
|
|
5277
5343
|
</div>
|
|
5278
5344
|
${x}
|
|
@@ -5335,8 +5401,8 @@ function Sn(r, e) {
|
|
|
5335
5401
|
<span class="__crossx-td-value">${$(o)}</span>
|
|
5336
5402
|
</div>`;
|
|
5337
5403
|
for (const [l, d] of Object.entries(i)) {
|
|
5338
|
-
const
|
|
5339
|
-
<button class="__crossx-copy-btn" data-copy="${$(String(d))}" title="Copy">${de}</button>` : `<span>${
|
|
5404
|
+
const p = mn(d), x = xn(d) ? `<span class="__crossx-addr-text">${Y(d)}</span>
|
|
5405
|
+
<button class="__crossx-copy-btn" data-copy="${$(String(d))}" title="Copy">${de}</button>` : `<span>${p}</span>`;
|
|
5340
5406
|
a += `
|
|
5341
5407
|
<div class="__crossx-td-row">
|
|
5342
5408
|
<span class="__crossx-td-label">${$(l)}</span>
|
|
@@ -5378,7 +5444,7 @@ const En = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="
|
|
|
5378
5444
|
<line x1="12" y1="5" x2="12" y2="19"/>
|
|
5379
5445
|
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
5380
5446
|
</svg>`;
|
|
5381
|
-
function
|
|
5447
|
+
function In(r, e) {
|
|
5382
5448
|
const s = r.map(
|
|
5383
5449
|
(n) => `<button class="__crossx-wallet-item" data-wallet-index="${n.index}" data-wallet-address="${$(n.address)}">
|
|
5384
5450
|
<span class="__crossx-wallet-addr">${Y(n.address)}</span>
|
|
@@ -5417,7 +5483,7 @@ function Tn(r, e) {
|
|
|
5417
5483
|
</div>
|
|
5418
5484
|
`, t;
|
|
5419
5485
|
}
|
|
5420
|
-
const
|
|
5486
|
+
const Tn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
5421
5487
|
<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"/>
|
|
5422
5488
|
<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"/>
|
|
5423
5489
|
</svg>`, An = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -5441,7 +5507,7 @@ function Rn(r) {
|
|
|
5441
5507
|
<div class="__crossx-body">
|
|
5442
5508
|
<div class="__crossx-login-btn-row">
|
|
5443
5509
|
<button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
|
|
5444
|
-
<span class="__crossx-login-icon" style="color:var(--cx-value);">${
|
|
5510
|
+
<span class="__crossx-login-icon" style="color:var(--cx-value);">${Tn}</span>
|
|
5445
5511
|
<span class="__crossx-login-btn-label">Sign in with Apple</span>
|
|
5446
5512
|
</button>
|
|
5447
5513
|
<button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
|
|
@@ -5521,8 +5587,8 @@ function kn(r, e, s) {
|
|
|
5521
5587
|
a.preventDefault();
|
|
5522
5588
|
const c = (((d = a.clipboardData) == null ? void 0 : d.getData("text")) ?? "").replace(/\D/g, "").slice(0, 4);
|
|
5523
5589
|
if (!c) return;
|
|
5524
|
-
c.split("").forEach((
|
|
5525
|
-
t[m] && (t[m].value =
|
|
5590
|
+
c.split("").forEach((p, m) => {
|
|
5591
|
+
t[m] && (t[m].value = p);
|
|
5526
5592
|
});
|
|
5527
5593
|
const l = Math.min(c.length, 3);
|
|
5528
5594
|
t[l].focus(), c.length === 4 && setTimeout(() => e(c), 200);
|
|
@@ -5548,7 +5614,7 @@ class Nn {
|
|
|
5548
5614
|
return new Promise((t) => {
|
|
5549
5615
|
var w;
|
|
5550
5616
|
me();
|
|
5551
|
-
const n = [...e], o =
|
|
5617
|
+
const n = [...e], o = In(n, this.tokens), i = document.body.style.overflow;
|
|
5552
5618
|
document.body.style.overflow = "hidden", document.body.appendChild(o);
|
|
5553
5619
|
let a = !1;
|
|
5554
5620
|
const c = () => {
|
|
@@ -5609,7 +5675,7 @@ class Nn {
|
|
|
5609
5675
|
(a = s.querySelector("#__crossx-apple-btn")) == null || a.addEventListener("click", () => n("apple")), (c = s.querySelector("#__crossx-google-btn")) == null || c.addEventListener("click", () => n("google")), (l = s.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", o), s.addEventListener("click", (d) => {
|
|
5610
5676
|
d.target === s && o();
|
|
5611
5677
|
}), s.querySelectorAll(".__crossx-login-terms-link").forEach((d) => {
|
|
5612
|
-
d.addEventListener("click", (
|
|
5678
|
+
d.addEventListener("click", (p) => p.stopPropagation());
|
|
5613
5679
|
});
|
|
5614
5680
|
const i = (d) => {
|
|
5615
5681
|
d.key === "Escape" && (document.removeEventListener("keydown", i), o());
|
|
@@ -5679,8 +5745,8 @@ class Nn {
|
|
|
5679
5745
|
l.addEventListener("click", (d) => {
|
|
5680
5746
|
var m;
|
|
5681
5747
|
d.stopPropagation();
|
|
5682
|
-
const
|
|
5683
|
-
|
|
5748
|
+
const p = l.dataset.copy;
|
|
5749
|
+
p && ((m = navigator.clipboard) == null || m.writeText(p).catch(() => {
|
|
5684
5750
|
}));
|
|
5685
5751
|
});
|
|
5686
5752
|
}), t.addEventListener("click", (l) => {
|
|
@@ -5706,8 +5772,8 @@ class Nn {
|
|
|
5706
5772
|
const a = () => {
|
|
5707
5773
|
i || (i = !0, o(), t());
|
|
5708
5774
|
}, c = () => {
|
|
5709
|
-
var d,
|
|
5710
|
-
(d = n.querySelector("#__crossx-done-btn")) == null || d.addEventListener("click", a), (
|
|
5775
|
+
var d, p;
|
|
5776
|
+
(d = n.querySelector("#__crossx-done-btn")) == null || d.addEventListener("click", a), (p = n.querySelector("#__crossx-close-btn")) == null || p.addEventListener("click", a), n.addEventListener("click", (m) => {
|
|
5711
5777
|
m.target === n && a();
|
|
5712
5778
|
});
|
|
5713
5779
|
const l = (m) => {
|
|
@@ -5725,25 +5791,25 @@ class Nn {
|
|
|
5725
5791
|
var c, l, d;
|
|
5726
5792
|
me();
|
|
5727
5793
|
let t;
|
|
5728
|
-
e.type === "sign-message" ? t = vn(e, this.tokens) : e.type === "sign-typed-data" ? t = Sn(e, this.tokens) : e.type === "sign" ? t =
|
|
5794
|
+
e.type === "sign-message" ? t = vn(e, this.tokens) : e.type === "sign-typed-data" ? t = Sn(e, this.tokens) : e.type === "sign" ? t = gn(e, this.tokens) : t = _n(e, this.tokens), document.body.appendChild(t);
|
|
5729
5795
|
const n = () => t.remove(), o = () => {
|
|
5730
5796
|
n(), s(!0);
|
|
5731
5797
|
}, i = () => {
|
|
5732
5798
|
n(), s(!1);
|
|
5733
5799
|
};
|
|
5734
|
-
(c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (d = t.querySelector("#__crossx-close-btn")) == null || d.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((
|
|
5735
|
-
|
|
5800
|
+
(c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (d = t.querySelector("#__crossx-close-btn")) == null || d.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((p) => {
|
|
5801
|
+
p.addEventListener("click", (m) => {
|
|
5736
5802
|
var w;
|
|
5737
5803
|
m.stopPropagation();
|
|
5738
|
-
const x =
|
|
5804
|
+
const x = p.dataset.copy;
|
|
5739
5805
|
x && ((w = navigator.clipboard) == null || w.writeText(x).catch(() => {
|
|
5740
5806
|
}));
|
|
5741
5807
|
});
|
|
5742
|
-
}), t.addEventListener("click", (
|
|
5743
|
-
|
|
5808
|
+
}), t.addEventListener("click", (p) => {
|
|
5809
|
+
p.target === t && i();
|
|
5744
5810
|
});
|
|
5745
|
-
const a = (
|
|
5746
|
-
|
|
5811
|
+
const a = (p) => {
|
|
5812
|
+
p.key === "Escape" && (document.removeEventListener("keydown", a), i());
|
|
5747
5813
|
};
|
|
5748
5814
|
document.addEventListener("keydown", a);
|
|
5749
5815
|
});
|
|
@@ -5776,7 +5842,7 @@ function Mn(r) {
|
|
|
5776
5842
|
}, t = {
|
|
5777
5843
|
gatewayUrl: e.walletGatewayUrl,
|
|
5778
5844
|
projectId: r.projectId
|
|
5779
|
-
}, o = s.authMode !== "cookie" && At.isAvailable() ? new At() : new Ks(), i = new tn(), a = new nn(), c = new
|
|
5845
|
+
}, o = s.authMode !== "cookie" && At.isAvailable() ? new At() : new Ks(), i = new tn(), a = new nn(), c = new gt(), l = new Pn();
|
|
5780
5846
|
let d;
|
|
5781
5847
|
r.useMockWallet ? (f.log("[CROSSx] Mock Wallet Provider 사용"), d = new on(o)) : (f.log("[CROSSx] Remote Wallet Provider 사용"), d = new qe(
|
|
5782
5848
|
t,
|
|
@@ -5784,7 +5850,7 @@ function Mn(r) {
|
|
|
5784
5850
|
a,
|
|
5785
5851
|
l
|
|
5786
5852
|
));
|
|
5787
|
-
const
|
|
5853
|
+
const p = new Ce(t, a), m = new Nn(r.theme ?? "light", r.themeTokens);
|
|
5788
5854
|
return new st(
|
|
5789
5855
|
s,
|
|
5790
5856
|
t,
|
|
@@ -5795,7 +5861,7 @@ function Mn(r) {
|
|
|
5795
5861
|
d,
|
|
5796
5862
|
l,
|
|
5797
5863
|
m,
|
|
5798
|
-
|
|
5864
|
+
p
|
|
5799
5865
|
);
|
|
5800
5866
|
}
|
|
5801
5867
|
export {
|
|
@@ -5803,6 +5869,6 @@ export {
|
|
|
5803
5869
|
Cs as CROSSxEthereumProvider,
|
|
5804
5870
|
st as CROSSxSDK,
|
|
5805
5871
|
$n as ChainId,
|
|
5806
|
-
|
|
5872
|
+
g as ErrorCode,
|
|
5807
5873
|
Mn as createCROSSxSDK
|
|
5808
5874
|
};
|