@nexus-cross/crossx-sdk-core 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/utils/parseOAuthDeeplink.test.d.ts +17 -0
- package/dist/__tests__/utils/parseOAuthDeeplink.test.d.ts.map +1 -0
- package/dist/adapters/oauth/BrowserOAuthAdapter.d.ts.map +1 -1
- package/dist/core/usecases/SignInUseCase.d.ts +15 -0
- package/dist/core/usecases/SignInUseCase.d.ts.map +1 -1
- package/dist/core/utils/parseOAuthDeeplink.d.ts +63 -0
- package/dist/core/utils/parseOAuthDeeplink.d.ts.map +1 -0
- package/dist/crossx.global +20 -20
- package/dist/index.cjs +37 -37
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +803 -685
- package/dist/sdk/CROSSxSDK.d.ts +18 -0
- package/dist/sdk/CROSSxSDK.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var Ls = Object.defineProperty;
|
|
2
2
|
var Ds = (r, e, s) => e in r ? Ls(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
|
|
3
|
-
var
|
|
3
|
+
var E = (r, e, s) => Ds(r, typeof e != "symbol" ? e + "" : e, s);
|
|
4
4
|
import { createRemoteJWKSet as Ms, jwtVerify as $s, decodeJwt as Bs } from "jose";
|
|
5
5
|
var p = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.ALREADY_AUTHENTICATED = "ALREADY_AUTHENTICATED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.WALLET_ALREADY_EXISTS = "WALLET_ALREADY_EXISTS", r.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", r.BROADCAST_FAILED = "BROADCAST_FAILED", r.USER_REJECTED = "USER_REJECTED", r.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", r.NETWORK_ERROR = "NETWORK_ERROR", r.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", r.INVALID_CHAIN = "INVALID_CHAIN", r.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", r.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.SIGNATURE_FAILED = "SIGNATURE_FAILED", r.TRANSACTION_FAILED = "TRANSACTION_FAILED", r.PREPARE_FAILED = "PREPARE_FAILED", r.PREPARE_EXPIRED = "PREPARE_EXPIRED", r.PREPARE_MISMATCH = "PREPARE_MISMATCH", r.MIGRATION_FAILED = "MIGRATION_FAILED", r.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", r.MIGRATION_PIN_LOCKED = "MIGRATION_PIN_LOCKED", r.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", r.WALLET_INCONSISTENT_STATE = "WALLET_INCONSISTENT_STATE", r.PROJECT_ID_MISSING = "PROJECT_ID_MISSING", r.ORIGIN_NOT_ALLOWED = "ORIGIN_NOT_ALLOWED", r.APP_IDENTIFIER_MISSING = "APP_IDENTIFIER_MISSING", r.INVALID_APP_TYPE = "INVALID_APP_TYPE", r.PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED", r.SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH", r.GAS_ESTIMATION_FAILED = "GAS_ESTIMATION_FAILED", r.TYPED_DATA_CHAIN_ID_MISMATCH = "TYPED_DATA_CHAIN_ID_MISMATCH", r.PIN_NOT_SET = "PIN_NOT_SET", r.PIN_WRONG = "PIN_WRONG", r.PIN_INVALID = "PIN_INVALID", r.PIN_REPEATED_PATTERN = "PIN_REPEATED_PATTERN", r.PIN_CANCELLED = "PIN_CANCELLED", r.EXTERNAL_WALLET_REQUESTED = "EXTERNAL_WALLET_REQUESTED", r.PIN_LOCKED = "PIN_LOCKED", r.HMAC_REQUIRED = "HMAC_REQUIRED", r.HMAC_VERIFICATION_FAILED = "HMAC_VERIFICATION_FAILED", r.WITHDRAW_FAILED = "WITHDRAW_FAILED", r.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(p || {});
|
|
6
6
|
class m extends Error {
|
|
@@ -65,7 +65,7 @@ const Ve = {
|
|
|
65
65
|
rpcUrl: "https://saigon-testnet.roninchain.com/rpc",
|
|
66
66
|
testnet: !0
|
|
67
67
|
}
|
|
68
|
-
},
|
|
68
|
+
}, oo = Object.fromEntries(
|
|
69
69
|
Object.entries(Ve).map(([r, e]) => [r, e.caipId])
|
|
70
70
|
), Us = new Map(
|
|
71
71
|
Object.values(Ve).map((r) => [r.caipId, r])
|
|
@@ -167,26 +167,26 @@ class Fs {
|
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
let
|
|
170
|
+
let Se = null;
|
|
171
171
|
function vt(r) {
|
|
172
|
-
|
|
172
|
+
Se = r;
|
|
173
173
|
}
|
|
174
174
|
const d = {
|
|
175
175
|
log(...r) {
|
|
176
|
-
if (
|
|
177
|
-
|
|
176
|
+
if (Se) {
|
|
177
|
+
Se.log(...r);
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
180
180
|
},
|
|
181
181
|
warn(...r) {
|
|
182
|
-
if (
|
|
183
|
-
|
|
182
|
+
if (Se) {
|
|
183
|
+
Se.warn(...r);
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
error(...r) {
|
|
188
|
-
if (
|
|
189
|
-
|
|
188
|
+
if (Se) {
|
|
189
|
+
Se.error(...r);
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -363,61 +363,86 @@ class qs {
|
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
365
|
async execute(e) {
|
|
366
|
+
let s;
|
|
367
|
+
try {
|
|
368
|
+
const t = e == null ? void 0 : e.provider;
|
|
369
|
+
let n = "/login";
|
|
370
|
+
t === "google" ? n = "/google" : t === "apple" && (n = "/apple");
|
|
371
|
+
const { oauthServiceUrl: o } = this.config, i = `${o}${n}`;
|
|
372
|
+
d.log(`[CROSSx] OAuth 팝업 열기 (${t || "일반"} 로그인)`), s = await this.oauth.openAuth({
|
|
373
|
+
authUrl: i,
|
|
374
|
+
expectedOrigin: new URL(o).origin
|
|
375
|
+
}), d.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", s.length, ")");
|
|
376
|
+
} catch (t) {
|
|
377
|
+
return d.error("[CROSSx] SignIn 에러 (OAuth 단계):", t), {
|
|
378
|
+
success: !1,
|
|
379
|
+
error: t instanceof Error ? t.message : "Sign in failed"
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
return this.processFirebaseToken(s);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* RN WebView 등 외부 환경에서 deeplink로 수신한 Firebase(OAuth) 토큰을
|
|
386
|
+
* 직접 주입하여 로그인합니다.
|
|
387
|
+
*
|
|
388
|
+
* OAuth 팝업 없이 이미 확보된 Firebase 토큰으로
|
|
389
|
+
* CROSSx 인증 교환 → 사용자 정보 추출 → 지갑 로드를 수행합니다.
|
|
390
|
+
*
|
|
391
|
+
* @param firebaseToken OAuth 서비스에서 발급받은 Firebase JWT
|
|
392
|
+
*/
|
|
393
|
+
async executeWithOAuthToken(e) {
|
|
394
|
+
return d.log("[CROSSx] signInWithOAuthToken — Firebase 토큰 주입 (length:", e.length, ")"), this.processFirebaseToken(e);
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Firebase 토큰 → CROSSx 인증 교환 → 사용자 정보 추출 → 토큰 저장 → 지갑 로드.
|
|
398
|
+
* execute()와 executeWithOAuthToken()에서 공유합니다.
|
|
399
|
+
*/
|
|
400
|
+
async processFirebaseToken(e) {
|
|
366
401
|
var n, o, i, a;
|
|
367
402
|
let s, t = !1;
|
|
368
403
|
try {
|
|
369
|
-
const c =
|
|
370
|
-
let
|
|
371
|
-
c === "google" ? l = "/google" : c === "apple" && (l = "/apple");
|
|
372
|
-
const { oauthServiceUrl: u, authApiUrl: h } = this.config, g = `${u}${l}`;
|
|
373
|
-
d.log(`[CROSSx] OAuth 팝업 열기 (${c || "일반"} 로그인)`);
|
|
374
|
-
const f = await this.oauth.openAuth({
|
|
375
|
-
authUrl: g,
|
|
376
|
-
expectedOrigin: new URL(u).origin
|
|
377
|
-
});
|
|
378
|
-
d.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", f.length, ")");
|
|
379
|
-
const { accessToken: w, refreshToken: v } = await this.exchangeFirebaseToken(f, h);
|
|
380
|
-
let y, S;
|
|
404
|
+
const { authApiUrl: c } = this.config, { accessToken: l, refreshToken: u } = await this.exchangeFirebaseToken(e, c);
|
|
405
|
+
let h, x;
|
|
381
406
|
try {
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
const
|
|
385
|
-
|
|
407
|
+
const w = this.crypto.decodeJWT(e);
|
|
408
|
+
x = (n = w.firebase) == null ? void 0 : n.sign_in_provider;
|
|
409
|
+
const b = ((o = w.firebase) == null ? void 0 : o.identities) ?? {};
|
|
410
|
+
x === "google.com" ? h = (i = b["google.com"]) == null ? void 0 : i[0] : x === "apple.com" && (h = (a = b["apple.com"]) == null ? void 0 : a[0]), d.log("[CROSSx] OAuth provider sub 추출 — provider:", x, "hasProviderSub:", !!h);
|
|
386
411
|
} catch {
|
|
387
412
|
d.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
|
|
388
413
|
}
|
|
389
|
-
if (
|
|
390
|
-
const
|
|
391
|
-
d.log("[CROSSx] access_token 디코딩 — sub:",
|
|
392
|
-
const
|
|
393
|
-
if (t =
|
|
414
|
+
if (l) {
|
|
415
|
+
const w = this.crypto.decodeJWT(l);
|
|
416
|
+
d.log("[CROSSx] access_token 디코딩 — sub:", w.sub, "exp:", w.exp);
|
|
417
|
+
const b = await this.crypto.verifyJWT(l);
|
|
418
|
+
if (t = b.signatureVerified ?? !1, !b.valid)
|
|
394
419
|
throw d.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
|
|
395
|
-
const
|
|
420
|
+
const y = b.payload;
|
|
396
421
|
s = {
|
|
397
|
-
id:
|
|
398
|
-
email:
|
|
399
|
-
signInProvider:
|
|
400
|
-
providerSub:
|
|
401
|
-
}, this.tokenStore.set(
|
|
422
|
+
id: y.sub,
|
|
423
|
+
email: y.email,
|
|
424
|
+
signInProvider: x,
|
|
425
|
+
providerSub: h
|
|
426
|
+
}, this.tokenStore.set(l), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, l), u && this.config.secureStorageAvailable !== !1 ? await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, u) : u && d.warn("[CROSSx] 안전한 스토리지 미사용 — refresh_token 영속 저장을 건너뜁니다"));
|
|
402
427
|
} else {
|
|
403
|
-
const
|
|
428
|
+
const w = this.crypto.decodeJWT(e);
|
|
404
429
|
s = {
|
|
405
|
-
id:
|
|
406
|
-
email:
|
|
407
|
-
signInProvider:
|
|
408
|
-
providerSub:
|
|
430
|
+
id: w.sub,
|
|
431
|
+
email: w.email,
|
|
432
|
+
signInProvider: x,
|
|
433
|
+
providerSub: h
|
|
409
434
|
}, d.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
|
|
410
435
|
}
|
|
411
436
|
d.log("[CROSSx] 사용자 정보 — id:", s.id);
|
|
412
|
-
const
|
|
413
|
-
await this.storage.set(this.STORAGE_KEY_USER,
|
|
437
|
+
const f = this.useCookieAuth ? { id: s.id, signInProvider: s.signInProvider, providerSub: s.providerSub } : s;
|
|
438
|
+
await this.storage.set(this.STORAGE_KEY_USER, f), d.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
|
|
414
439
|
} catch (c) {
|
|
415
|
-
return d.error("[CROSSx] SignIn 에러 (
|
|
440
|
+
return d.error("[CROSSx] SignIn 에러 (토큰 교환 단계):", c), {
|
|
416
441
|
success: !1,
|
|
417
442
|
error: c instanceof Error ? c.message : "Sign in failed"
|
|
418
443
|
};
|
|
419
444
|
}
|
|
420
|
-
return d.log("[CROSSx][Migration Phase 1]
|
|
445
|
+
return d.log("[CROSSx][Migration Phase 1] 로그인 완료, 지갑 로드 시작 — userId:", s.id), this.loadWallet(s, t);
|
|
421
446
|
}
|
|
422
447
|
/**
|
|
423
448
|
* Firebase 토큰 → CROSSx 인증 교환
|
|
@@ -823,9 +848,9 @@ function Js() {
|
|
|
823
848
|
}
|
|
824
849
|
return Ge.production;
|
|
825
850
|
}
|
|
826
|
-
const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA00", kt = 130, Pt = 6,
|
|
851
|
+
const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA00", kt = 130, Pt = 6, Ot = 18, tr = 5 * 60 * 1e3, sr = 30 * 1e3, re = class re extends js {
|
|
827
852
|
constructor(e, s, t, n, o, i, a, c, l, u, h) {
|
|
828
|
-
var
|
|
853
|
+
var x;
|
|
829
854
|
super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this._initPromise = null, this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._verifyPinMutex = null, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && vt(e.logger), this.confirmation = l, this.pinStore = h ?? new es(), this.chainRegistry = u, this.jsonRpc = new zs(u, o), this.signInUseCase = new qs(
|
|
830
855
|
this.internalConfig,
|
|
831
856
|
t,
|
|
@@ -834,7 +859,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
834
859
|
o,
|
|
835
860
|
a,
|
|
836
861
|
c
|
|
837
|
-
), this.signOutUseCase = new Ks(this.internalConfig, t, c), this.migrateWalletUseCase = new Vs(t, a), (
|
|
862
|
+
), this.signOutUseCase = new Ks(this.internalConfig, t, c), this.migrateWalletUseCase = new Vs(t, a), (x = a.setOnUnauthorized) == null || x.call(a, () => this.forceLogout());
|
|
838
863
|
}
|
|
839
864
|
get config() {
|
|
840
865
|
return this._config;
|
|
@@ -860,7 +885,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
860
885
|
}
|
|
861
886
|
async _doInitialize(e) {
|
|
862
887
|
var s, t;
|
|
863
|
-
d.log("[CROSSx SDK] v1.3.
|
|
888
|
+
d.log("[CROSSx SDK] v1.3.5 초기화 중..."), this.confirmation.setMessages(St(this._config.locale));
|
|
864
889
|
try {
|
|
865
890
|
const n = Js();
|
|
866
891
|
this.internalConfig.oauthServiceUrl = n.oauthServiceUrl, this.internalConfig.authApiUrl = n.authApiUrl, this.internalConfig.walletGatewayUrl = n.walletGatewayUrl, this.adapterConfig.gatewayUrl = n.walletGatewayUrl, (t = (s = this.crypto).setJWKSEndpoint) == null || t.call(s, `${n.authApiUrl}/.well-known/jwks.json`);
|
|
@@ -940,6 +965,36 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
940
965
|
)), t;
|
|
941
966
|
}
|
|
942
967
|
}
|
|
968
|
+
/**
|
|
969
|
+
* OAuth deeplink로 수신한 Firebase 토큰을 직접 주입하여 로그인합니다.
|
|
970
|
+
*
|
|
971
|
+
* RN WebView 등 팝업이 불가능한 환경에서, 네이티브 앱이 OAuth deeplink로
|
|
972
|
+
* 수신한 Firebase 토큰을 JS injection으로 SDK에 전달할 때 사용합니다.
|
|
973
|
+
*
|
|
974
|
+
* 내부적으로 Firebase 토큰 → CROSSx 인증 교환 → 지갑 로드를 수행합니다.
|
|
975
|
+
*
|
|
976
|
+
* @param firebaseToken OAuth 서비스에서 발급받은 Firebase JWT
|
|
977
|
+
*
|
|
978
|
+
* @example
|
|
979
|
+
* // RN WebView에서 JS injection으로 호출
|
|
980
|
+
* const result = await sdk.signInWithOAuthToken(firebaseTokenFromDeeplink);
|
|
981
|
+
* if (result.success) {
|
|
982
|
+
* console.log(result.address); // '0x...'
|
|
983
|
+
* }
|
|
984
|
+
*/
|
|
985
|
+
async signInWithOAuthToken(e) {
|
|
986
|
+
if (this.ensureInitialized(), this.authenticated)
|
|
987
|
+
throw new m(
|
|
988
|
+
p.ALREADY_AUTHENTICATED,
|
|
989
|
+
"이미 로그인된 상태입니다. signOut()을 먼저 호출하세요."
|
|
990
|
+
);
|
|
991
|
+
try {
|
|
992
|
+
const s = await this.signInUseCase.executeWithOAuthToken(e);
|
|
993
|
+
return s.success && this.applyAuthResult(s), s;
|
|
994
|
+
} catch (s) {
|
|
995
|
+
throw new m(p.AUTH_FAILED, "OAuth 토큰 로그인에 실패했습니다", s);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
943
998
|
/**
|
|
944
999
|
* 외부에서 발급된 CROSSx JWT로 직접 로그인합니다.
|
|
945
1000
|
*
|
|
@@ -1603,24 +1658,24 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1603
1658
|
* logger.log(receipt.status); // '0x1' | '0x0'
|
|
1604
1659
|
*/
|
|
1605
1660
|
async sendTransactionWithWaitForReceipt(e, s, t = {}) {
|
|
1606
|
-
var
|
|
1607
|
-
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((
|
|
1608
|
-
let
|
|
1609
|
-
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((
|
|
1610
|
-
|
|
1611
|
-
const C = BigInt(
|
|
1661
|
+
var b, y;
|
|
1662
|
+
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((b = this._config.receiptPolling) == null ? void 0 : b.intervalMs) ?? Xs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? Tt, u = Je(e), h = s.from ?? "";
|
|
1663
|
+
let x, f;
|
|
1664
|
+
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((k) => {
|
|
1665
|
+
x = k;
|
|
1666
|
+
const C = BigInt(k.gasUsed) * BigInt(k.effectiveGasPrice), W = s.value ? BigInt(s.value) : 0n, B = re.formatTxAmount(s.value, u.symbol, u.decimals), j = re.formatTxAmount("0x" + C.toString(16), u.symbol, u.decimals), q = re.formatTxAmount("0x" + (W + C).toString(16), u.symbol, u.decimals);
|
|
1612
1667
|
return {
|
|
1613
1668
|
chainId: e,
|
|
1614
1669
|
txHash: a,
|
|
1615
|
-
from:
|
|
1616
|
-
to:
|
|
1617
|
-
amount:
|
|
1618
|
-
fees:
|
|
1619
|
-
total:
|
|
1670
|
+
from: k.from,
|
|
1671
|
+
to: k.to ?? s.to,
|
|
1672
|
+
amount: B,
|
|
1673
|
+
fees: j,
|
|
1674
|
+
total: q,
|
|
1620
1675
|
nativeSymbol: u.symbol,
|
|
1621
|
-
status:
|
|
1676
|
+
status: k.status === "0x1" ? "success" : "reverted"
|
|
1622
1677
|
};
|
|
1623
|
-
}).catch((
|
|
1678
|
+
}).catch((k) => (f = k instanceof Error ? k : new Error(String(k)), {
|
|
1624
1679
|
chainId: e,
|
|
1625
1680
|
txHash: a,
|
|
1626
1681
|
from: h,
|
|
@@ -1633,7 +1688,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1633
1688
|
{ chainId: e, txHash: a, from: h, to: s.to },
|
|
1634
1689
|
w
|
|
1635
1690
|
), f) throw f;
|
|
1636
|
-
return { chainId: e, txHash: a, receipt:
|
|
1691
|
+
return { chainId: e, txHash: a, receipt: x };
|
|
1637
1692
|
}
|
|
1638
1693
|
// ============================================================================
|
|
1639
1694
|
// PIN 관리 (공개 API)
|
|
@@ -1815,7 +1870,7 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1815
1870
|
try {
|
|
1816
1871
|
const s = BigInt(e);
|
|
1817
1872
|
if (s === 0n) return "0";
|
|
1818
|
-
const t = 10n ** BigInt(
|
|
1873
|
+
const t = 10n ** BigInt(Ot), n = s / t, i = (s % t).toString().padStart(Ot, "0").replace(/0+$/, "").slice(0, Pt);
|
|
1819
1874
|
return i ? `${n}.${i}` : `${n}`;
|
|
1820
1875
|
} catch {
|
|
1821
1876
|
return "?";
|
|
@@ -1908,31 +1963,31 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1908
1963
|
return d.log("[CROSSx][Migration Phase 4] 사용자가 PIN 입력을 취소함 → 종료"), null;
|
|
1909
1964
|
d.log("[CROSSx][Migration Phase 4] PIN 입력 완료 — verify-recovery-pin API 호출"), n = void 0;
|
|
1910
1965
|
try {
|
|
1911
|
-
const
|
|
1912
|
-
if (!
|
|
1966
|
+
const x = await ((u = (l = this.walletProvider).verifyRecoveryPin) == null ? void 0 : u.call(l, h, e));
|
|
1967
|
+
if (!x) {
|
|
1913
1968
|
d.log("[CROSSx][Migration Phase 4] verifyRecoveryPin 미지원 — PIN 검증 생략"), a = h;
|
|
1914
1969
|
break;
|
|
1915
1970
|
}
|
|
1916
|
-
if (
|
|
1971
|
+
if (x.valid) {
|
|
1917
1972
|
d.log("[CROSSx][Migration Phase 4] PIN 검증 성공"), a = h;
|
|
1918
1973
|
break;
|
|
1919
1974
|
}
|
|
1920
|
-
const f =
|
|
1975
|
+
const f = x.pinStatus;
|
|
1921
1976
|
if (i = f.maxAttempts, o = i - f.remainingAttempts, f.remainingAttempts === 0 && f.lockExpiresAt) {
|
|
1922
|
-
const w = f.lockExpiresAt * 1e3,
|
|
1923
|
-
d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${
|
|
1977
|
+
const w = f.lockExpiresAt * 1e3, b = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = b <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
|
|
1978
|
+
d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${b}초, 메시지: ${y}`), await this.confirmation.showRecoveryPinLockedPrompt(b, y), o = 0, n = "Your account lock has been lifted. You may try again.";
|
|
1924
1979
|
} else
|
|
1925
1980
|
d.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 ${o}/${i})`), n = "Incorrect PIN.";
|
|
1926
|
-
} catch (
|
|
1927
|
-
if (!(
|
|
1928
|
-
if (
|
|
1929
|
-
const f =
|
|
1981
|
+
} catch (x) {
|
|
1982
|
+
if (!(x instanceof m)) throw x;
|
|
1983
|
+
if (x.code === p.MIGRATION_PIN_LOCKED) {
|
|
1984
|
+
const f = x.details;
|
|
1930
1985
|
if (i = (f == null ? void 0 : f.maxAttempts) ?? 5, (f == null ? void 0 : f.permanent) === !0)
|
|
1931
1986
|
return d.warn("[CROSSx][Migration Phase 4] PIN 영구 잠금 (verify-recovery-pin)"), await this.confirmation.showRecoveryPinLockedPrompt(0, "Your account has been permanently locked due to too many failed attempts."), null;
|
|
1932
|
-
const w = ((f == null ? void 0 : f.lockExpiresAt) ?? 0) * 1e3,
|
|
1933
|
-
d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${
|
|
1987
|
+
const w = ((f == null ? void 0 : f.lockExpiresAt) ?? 0) * 1e3, b = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = b <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
|
|
1988
|
+
d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${b}초`), await this.confirmation.showRecoveryPinLockedPrompt(b, y), o = 0, n = "Your account lock has been lifted. You may try again.";
|
|
1934
1989
|
} else
|
|
1935
|
-
throw d.error("[CROSSx][Migration Phase 4] verify-recovery-pin 실패 (복구 불가):",
|
|
1990
|
+
throw d.error("[CROSSx][Migration Phase 4] verify-recovery-pin 실패 (복구 불가):", x), x;
|
|
1936
1991
|
}
|
|
1937
1992
|
}
|
|
1938
1993
|
d.log("[CROSSx][Migration Phase 5] PIN 검증 완료 — 비밀번호 설정 및 마이그레이션 진행");
|
|
@@ -1963,13 +2018,13 @@ const Xs = 2e3, Tt = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1963
2018
|
if (!n && !o && !i && !a) return e;
|
|
1964
2019
|
const c = { ...e }, l = n ? c.from ?? this.address : void 0;
|
|
1965
2020
|
l && d.log("[CROSSx] nonce 비어있음 → eth_getTransactionCount 호출 (from:", l, ")"), o && d.log("[CROSSx] gasLimit 비어있음 → eth_estimateGas 호출"), i && d.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
|
|
1966
|
-
const [u, h,
|
|
2021
|
+
const [u, h, x] = await Promise.all([
|
|
1967
2022
|
l ? this.jsonRpc.call("eth_getTransactionCount", [l, "pending"], s) : null,
|
|
1968
2023
|
o ? this.estimateGas(e, s) : null,
|
|
1969
2024
|
i ? this.getBaseFeePerGas(s) : null
|
|
1970
2025
|
]);
|
|
1971
2026
|
if (l && (c.nonce = parseInt(u ?? "0x0", 16), d.log("[CROSSx] nonce 결과:", c.nonce)), o && (c.gasLimit = h, d.log("[CROSSx] estimateGas 결과:", c.gasLimit)), i) {
|
|
1972
|
-
const f =
|
|
2027
|
+
const f = x;
|
|
1973
2028
|
if (f) {
|
|
1974
2029
|
const w = Rt;
|
|
1975
2030
|
c.maxFeePerGas = "0x" + (BigInt(f) + BigInt(w)).toString(16), c.maxPriorityFeePerGas = w, d.log("[CROSSx] Dynamic 체인 감지 — baseFee:", f, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
|
|
@@ -2357,8 +2412,8 @@ class rr {
|
|
|
2357
2412
|
}
|
|
2358
2413
|
}
|
|
2359
2414
|
}
|
|
2360
|
-
const Xe = "crossx-sdk", nr = 1, de = "data",
|
|
2361
|
-
class
|
|
2415
|
+
const Xe = "crossx-sdk", nr = 1, de = "data", ve = "keys", $e = "aes-primary", or = 12;
|
|
2416
|
+
class Nt {
|
|
2362
2417
|
constructor(e) {
|
|
2363
2418
|
this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
|
|
2364
2419
|
}
|
|
@@ -2370,7 +2425,7 @@ class Ot {
|
|
|
2370
2425
|
const n = indexedDB.open(e, nr);
|
|
2371
2426
|
n.onupgradeneeded = () => {
|
|
2372
2427
|
const o = n.result;
|
|
2373
|
-
o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(
|
|
2428
|
+
o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(ve) || o.createObjectStore(ve);
|
|
2374
2429
|
}, n.onsuccess = () => s(n.result), n.onerror = () => t(n.error);
|
|
2375
2430
|
});
|
|
2376
2431
|
}
|
|
@@ -2400,7 +2455,7 @@ class Ot {
|
|
|
2400
2455
|
}
|
|
2401
2456
|
async init() {
|
|
2402
2457
|
this.db = await this.openDB();
|
|
2403
|
-
const e = await this.idbGet(
|
|
2458
|
+
const e = await this.idbGet(ve, $e);
|
|
2404
2459
|
if (e) {
|
|
2405
2460
|
this.cryptoKey = e;
|
|
2406
2461
|
return;
|
|
@@ -2414,7 +2469,7 @@ class Ot {
|
|
|
2414
2469
|
{ name: "AES-GCM", length: 256 },
|
|
2415
2470
|
!1,
|
|
2416
2471
|
["encrypt", "decrypt"]
|
|
2417
|
-
), await this.idbPut(
|
|
2472
|
+
), await this.idbPut(ve, $e, this.cryptoKey);
|
|
2418
2473
|
}
|
|
2419
2474
|
/**
|
|
2420
2475
|
* 레거시 DB('crossx-sdk')에서 projectId 스코프 DB로 암호키·데이터 마이그레이션.
|
|
@@ -2423,7 +2478,7 @@ class Ot {
|
|
|
2423
2478
|
async migrateFromLegacyDB() {
|
|
2424
2479
|
if (this.dbName === Xe) return null;
|
|
2425
2480
|
try {
|
|
2426
|
-
const e = await this.openDB(Xe), s = e.transaction([
|
|
2481
|
+
const e = await this.openDB(Xe), s = e.transaction([ve, de], "readonly"), t = s.objectStore(ve).get($e), n = await new Promise((l, u) => {
|
|
2427
2482
|
t.onsuccess = () => l(t.result), t.onerror = () => u(t.error);
|
|
2428
2483
|
});
|
|
2429
2484
|
if (!n)
|
|
@@ -2436,7 +2491,7 @@ class Ot {
|
|
|
2436
2491
|
i.onsuccess = () => l(i.result), i.onerror = () => u(i.error);
|
|
2437
2492
|
})
|
|
2438
2493
|
]);
|
|
2439
|
-
e.close(), await this.idbPut(
|
|
2494
|
+
e.close(), await this.idbPut(ve, $e, n);
|
|
2440
2495
|
for (let l = 0; l < c.length; l++)
|
|
2441
2496
|
await this.idbPut(de, String(c[l]), a[l]);
|
|
2442
2497
|
return indexedDB.deleteDatabase(Xe), d.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), n;
|
|
@@ -2513,7 +2568,7 @@ function ge(r, e = "") {
|
|
|
2513
2568
|
throw new Error(`${s}expected integer >= 0, got ${r}`);
|
|
2514
2569
|
}
|
|
2515
2570
|
}
|
|
2516
|
-
function
|
|
2571
|
+
function V(r, e, s = "") {
|
|
2517
2572
|
const t = ut(r), n = r == null ? void 0 : r.length, o = e !== void 0;
|
|
2518
2573
|
if (!t || o && n !== e) {
|
|
2519
2574
|
const i = s && `"${s}" `, a = o ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
|
|
@@ -2533,7 +2588,7 @@ function ke(r, e = !0) {
|
|
|
2533
2588
|
throw new Error("Hash#digest() has already been called");
|
|
2534
2589
|
}
|
|
2535
2590
|
function ss(r, e) {
|
|
2536
|
-
|
|
2591
|
+
V(r, void 0, "digestInto() output");
|
|
2537
2592
|
const s = e.outputLen;
|
|
2538
2593
|
if (r.length < s)
|
|
2539
2594
|
throw new Error('"digestInto() output" expected to be of length >=' + s);
|
|
@@ -2562,7 +2617,7 @@ function lr(r) {
|
|
|
2562
2617
|
}
|
|
2563
2618
|
const Ct = ar ? (r) => r : lr, rs = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", dr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
|
|
2564
2619
|
function Me(r) {
|
|
2565
|
-
if (
|
|
2620
|
+
if (V(r), rs)
|
|
2566
2621
|
return r.toHex();
|
|
2567
2622
|
let e = "";
|
|
2568
2623
|
for (let s = 0; s < r.length; s++)
|
|
@@ -2597,11 +2652,11 @@ function We(r) {
|
|
|
2597
2652
|
}
|
|
2598
2653
|
return t;
|
|
2599
2654
|
}
|
|
2600
|
-
function
|
|
2655
|
+
function be(...r) {
|
|
2601
2656
|
let e = 0;
|
|
2602
2657
|
for (let t = 0; t < r.length; t++) {
|
|
2603
2658
|
const n = r[t];
|
|
2604
|
-
|
|
2659
|
+
V(n), e += n.length;
|
|
2605
2660
|
}
|
|
2606
2661
|
const s = new Uint8Array(e);
|
|
2607
2662
|
for (let t = 0, n = 0; t < r.length; t++) {
|
|
@@ -2631,21 +2686,21 @@ function pr(r, e, s) {
|
|
|
2631
2686
|
}
|
|
2632
2687
|
class fr {
|
|
2633
2688
|
constructor(e, s, t, n) {
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2689
|
+
E(this, "blockLen");
|
|
2690
|
+
E(this, "outputLen");
|
|
2691
|
+
E(this, "padOffset");
|
|
2692
|
+
E(this, "isLE");
|
|
2638
2693
|
// For partial updates less than block size
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2694
|
+
E(this, "buffer");
|
|
2695
|
+
E(this, "view");
|
|
2696
|
+
E(this, "finished", !1);
|
|
2697
|
+
E(this, "length", 0);
|
|
2698
|
+
E(this, "pos", 0);
|
|
2699
|
+
E(this, "destroyed", !1);
|
|
2645
2700
|
this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Ze(this.buffer);
|
|
2646
2701
|
}
|
|
2647
2702
|
update(e) {
|
|
2648
|
-
ke(this),
|
|
2703
|
+
ke(this), V(e);
|
|
2649
2704
|
const { view: s, buffer: t, blockLen: n } = this, o = e.length;
|
|
2650
2705
|
for (let i = 0; i < o; ) {
|
|
2651
2706
|
const a = Math.min(n - this.pos, o - i);
|
|
@@ -2795,13 +2850,13 @@ class vr extends fr {
|
|
|
2795
2850
|
for (let h = 0; h < 16; h++, s += 4)
|
|
2796
2851
|
we[h] = e.getUint32(s, !1);
|
|
2797
2852
|
for (let h = 16; h < 64; h++) {
|
|
2798
|
-
const
|
|
2799
|
-
we[h] =
|
|
2853
|
+
const x = we[h - 15], f = we[h - 2], w = ue(x, 7) ^ ue(x, 18) ^ x >>> 3, b = ue(f, 17) ^ ue(f, 19) ^ f >>> 10;
|
|
2854
|
+
we[h] = b + we[h - 7] + w + we[h - 16] | 0;
|
|
2800
2855
|
}
|
|
2801
2856
|
let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: u } = this;
|
|
2802
2857
|
for (let h = 0; h < 64; h++) {
|
|
2803
|
-
const
|
|
2804
|
-
u = l, l = c, c = a, a = i + f | 0, i = o, o = n, n = t, t = f +
|
|
2858
|
+
const x = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), f = u + x + hr(a, c, l) + br[h] + we[h] | 0, b = (ue(t, 2) ^ ue(t, 13) ^ ue(t, 22)) + pr(t, n, o) | 0;
|
|
2859
|
+
u = l, l = c, c = a, a = i + f | 0, i = o, o = n, n = t, t = f + b | 0;
|
|
2805
2860
|
}
|
|
2806
2861
|
t = t + this.A | 0, n = n + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, u = u + this.H | 0, this.set(t, n, o, i, a, c, l, u);
|
|
2807
2862
|
}
|
|
@@ -2817,14 +2872,14 @@ class Sr extends vr {
|
|
|
2817
2872
|
super(32);
|
|
2818
2873
|
// We cannot use array here since array allows indexing by variable
|
|
2819
2874
|
// which means optimizer/compiler cannot use registers.
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2875
|
+
E(this, "A", me[0] | 0);
|
|
2876
|
+
E(this, "B", me[1] | 0);
|
|
2877
|
+
E(this, "C", me[2] | 0);
|
|
2878
|
+
E(this, "D", me[3] | 0);
|
|
2879
|
+
E(this, "E", me[4] | 0);
|
|
2880
|
+
E(this, "F", me[5] | 0);
|
|
2881
|
+
E(this, "G", me[6] | 0);
|
|
2882
|
+
E(this, "H", me[7] | 0);
|
|
2828
2883
|
}
|
|
2829
2884
|
}
|
|
2830
2885
|
const Er = /* @__PURE__ */ ns(
|
|
@@ -2861,7 +2916,7 @@ function ze(r) {
|
|
|
2861
2916
|
return as(Me(r));
|
|
2862
2917
|
}
|
|
2863
2918
|
function cs(r) {
|
|
2864
|
-
return as(Me(Ir(
|
|
2919
|
+
return as(Me(Ir(V(r)).reverse()));
|
|
2865
2920
|
}
|
|
2866
2921
|
function pt(r, e) {
|
|
2867
2922
|
ge(e), r = is(r);
|
|
@@ -2898,24 +2953,24 @@ function kr(r, e, s) {
|
|
|
2898
2953
|
let c = t(r), l = t(r), u = 0;
|
|
2899
2954
|
const h = () => {
|
|
2900
2955
|
c.fill(1), l.fill(0), u = 0;
|
|
2901
|
-
},
|
|
2902
|
-
l =
|
|
2956
|
+
}, x = (...y) => s(l, be(c, ...y)), f = (y = n) => {
|
|
2957
|
+
l = x(o, y), c = x(), y.length !== 0 && (l = x(i, y), c = x());
|
|
2903
2958
|
}, w = () => {
|
|
2904
2959
|
if (u++ >= a)
|
|
2905
2960
|
throw new Error("drbg: tried max amount of iterations");
|
|
2906
2961
|
let y = 0;
|
|
2907
|
-
const
|
|
2962
|
+
const k = [];
|
|
2908
2963
|
for (; y < e; ) {
|
|
2909
|
-
c =
|
|
2964
|
+
c = x();
|
|
2910
2965
|
const C = c.slice();
|
|
2911
|
-
|
|
2966
|
+
k.push(C), y += c.length;
|
|
2912
2967
|
}
|
|
2913
|
-
return
|
|
2968
|
+
return be(...k);
|
|
2914
2969
|
};
|
|
2915
|
-
return (y,
|
|
2970
|
+
return (y, k) => {
|
|
2916
2971
|
h(), f(y);
|
|
2917
2972
|
let C;
|
|
2918
|
-
for (; !(C =
|
|
2973
|
+
for (; !(C = k(w())); )
|
|
2919
2974
|
f();
|
|
2920
2975
|
return h(), C;
|
|
2921
2976
|
};
|
|
@@ -2945,7 +3000,7 @@ function Mt(r) {
|
|
|
2945
3000
|
};
|
|
2946
3001
|
}
|
|
2947
3002
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2948
|
-
const ne = /* @__PURE__ */ BigInt(0), ee = /* @__PURE__ */ BigInt(1), Ie = /* @__PURE__ */ BigInt(2), ds = /* @__PURE__ */ BigInt(3), us = /* @__PURE__ */ BigInt(4), hs = /* @__PURE__ */ BigInt(5), Pr = /* @__PURE__ */ BigInt(7), ps = /* @__PURE__ */ BigInt(8),
|
|
3003
|
+
const ne = /* @__PURE__ */ BigInt(0), ee = /* @__PURE__ */ BigInt(1), Ie = /* @__PURE__ */ BigInt(2), ds = /* @__PURE__ */ BigInt(3), us = /* @__PURE__ */ BigInt(4), hs = /* @__PURE__ */ BigInt(5), Pr = /* @__PURE__ */ BigInt(7), ps = /* @__PURE__ */ BigInt(8), Or = /* @__PURE__ */ BigInt(9), fs = /* @__PURE__ */ BigInt(16);
|
|
2949
3004
|
function le(r, e) {
|
|
2950
3005
|
const s = r % e;
|
|
2951
3006
|
return s >= ne ? s : e + s;
|
|
@@ -2978,7 +3033,7 @@ function _s(r, e) {
|
|
|
2978
3033
|
const s = (r.ORDER + ee) / us, t = r.pow(e, s);
|
|
2979
3034
|
return xt(r, t, e), t;
|
|
2980
3035
|
}
|
|
2981
|
-
function
|
|
3036
|
+
function Nr(r, e) {
|
|
2982
3037
|
const s = (r.ORDER - hs) / ps, t = r.mul(e, Ie), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, Ie), n), a = r.mul(o, r.sub(i, r.ONE));
|
|
2983
3038
|
return xt(r, a, e), a;
|
|
2984
3039
|
}
|
|
@@ -2986,9 +3041,9 @@ function Cr(r) {
|
|
|
2986
3041
|
const e = je(r), s = xs(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + Pr) / fs;
|
|
2987
3042
|
return (a, c) => {
|
|
2988
3043
|
let l = a.pow(c, i), u = a.mul(l, t);
|
|
2989
|
-
const h = a.mul(l, n),
|
|
2990
|
-
l = a.cmov(l, u, f), u = a.cmov(
|
|
2991
|
-
const
|
|
3044
|
+
const h = a.mul(l, n), x = a.mul(l, o), f = a.eql(a.sqr(u), c), w = a.eql(a.sqr(h), c);
|
|
3045
|
+
l = a.cmov(l, u, f), u = a.cmov(x, h, w);
|
|
3046
|
+
const b = a.eql(a.sqr(u), c), y = a.cmov(l, u, b);
|
|
2992
3047
|
return xt(a, y, c), y;
|
|
2993
3048
|
};
|
|
2994
3049
|
}
|
|
@@ -3012,22 +3067,22 @@ function xs(r) {
|
|
|
3012
3067
|
return l;
|
|
3013
3068
|
if (Bt(c, l) !== 1)
|
|
3014
3069
|
throw new Error("Cannot find square root");
|
|
3015
|
-
let u = s, h = c.mul(c.ONE, o),
|
|
3016
|
-
for (; !c.eql(
|
|
3017
|
-
if (c.is0(
|
|
3070
|
+
let u = s, h = c.mul(c.ONE, o), x = c.pow(l, e), f = c.pow(l, i);
|
|
3071
|
+
for (; !c.eql(x, c.ONE); ) {
|
|
3072
|
+
if (c.is0(x))
|
|
3018
3073
|
return c.ZERO;
|
|
3019
|
-
let w = 1,
|
|
3020
|
-
for (; !c.eql(
|
|
3021
|
-
if (w++,
|
|
3074
|
+
let w = 1, b = c.sqr(x);
|
|
3075
|
+
for (; !c.eql(b, c.ONE); )
|
|
3076
|
+
if (w++, b = c.sqr(b), w === u)
|
|
3022
3077
|
throw new Error("Cannot find square root");
|
|
3023
|
-
const y = ee << BigInt(u - w - 1),
|
|
3024
|
-
u = w, h = c.sqr(
|
|
3078
|
+
const y = ee << BigInt(u - w - 1), k = c.pow(h, y);
|
|
3079
|
+
u = w, h = c.sqr(k), x = c.mul(x, h), f = c.mul(f, k);
|
|
3025
3080
|
}
|
|
3026
3081
|
return f;
|
|
3027
3082
|
};
|
|
3028
3083
|
}
|
|
3029
3084
|
function Lr(r) {
|
|
3030
|
-
return r % us === ds ? _s : r % ps === hs ?
|
|
3085
|
+
return r % us === ds ? _s : r % ps === hs ? Nr : r % fs === Or ? Cr(r) : xs(r);
|
|
3031
3086
|
}
|
|
3032
3087
|
const Dr = [
|
|
3033
3088
|
"create",
|
|
@@ -3085,16 +3140,16 @@ function Br(r, e) {
|
|
|
3085
3140
|
}
|
|
3086
3141
|
class Ur {
|
|
3087
3142
|
constructor(e, s = {}) {
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3143
|
+
E(this, "ORDER");
|
|
3144
|
+
E(this, "BITS");
|
|
3145
|
+
E(this, "BYTES");
|
|
3146
|
+
E(this, "isLE");
|
|
3147
|
+
E(this, "ZERO", ne);
|
|
3148
|
+
E(this, "ONE", ee);
|
|
3149
|
+
E(this, "_lengths");
|
|
3150
|
+
E(this, "_sqrt");
|
|
3096
3151
|
// cached sqrt
|
|
3097
|
-
|
|
3152
|
+
E(this, "_mod");
|
|
3098
3153
|
var i;
|
|
3099
3154
|
if (e <= ne)
|
|
3100
3155
|
throw new Error("invalid field: expected ORDER > 0, got " + e);
|
|
@@ -3170,7 +3225,7 @@ class Ur {
|
|
|
3170
3225
|
return this.isLE ? ls(e, this.BYTES) : pt(e, this.BYTES);
|
|
3171
3226
|
}
|
|
3172
3227
|
fromBytes(e, s = !1) {
|
|
3173
|
-
|
|
3228
|
+
V(e);
|
|
3174
3229
|
const { _lengths: t, BYTES: n, isLE: o, ORDER: i, _mod: a } = this;
|
|
3175
3230
|
if (t) {
|
|
3176
3231
|
if (!t.includes(e.length) || e.length > n)
|
|
@@ -3209,7 +3264,7 @@ function ws(r) {
|
|
|
3209
3264
|
return e + Math.ceil(e / 2);
|
|
3210
3265
|
}
|
|
3211
3266
|
function Hr(r, e, s = !1) {
|
|
3212
|
-
|
|
3267
|
+
V(r);
|
|
3213
3268
|
const t = r.length, n = ms(e), o = ws(e);
|
|
3214
3269
|
if (t < 16 || t < o || t > 1024)
|
|
3215
3270
|
throw new Error("expected " + o + "-1024 bytes of input, got " + t);
|
|
@@ -3217,7 +3272,7 @@ function Hr(r, e, s = !1) {
|
|
|
3217
3272
|
return s ? ls(a, n) : pt(a, n);
|
|
3218
3273
|
}
|
|
3219
3274
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3220
|
-
const
|
|
3275
|
+
const Oe = /* @__PURE__ */ BigInt(0), Ae = /* @__PURE__ */ BigInt(1);
|
|
3221
3276
|
function Ke(r, e) {
|
|
3222
3277
|
const s = e.negate();
|
|
3223
3278
|
return r ? s : e;
|
|
@@ -3239,30 +3294,30 @@ function Ht(r, e, s) {
|
|
|
3239
3294
|
const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
|
|
3240
3295
|
let a = Number(r & n), c = r >> i;
|
|
3241
3296
|
a > t && (a -= o, c += Ae);
|
|
3242
|
-
const l = e * t, u = l + Math.abs(a) - 1, h = a === 0,
|
|
3243
|
-
return { nextN: c, offset: u, isZero: h, isNeg:
|
|
3297
|
+
const l = e * t, u = l + Math.abs(a) - 1, h = a === 0, x = a < 0, f = e % 2 !== 0;
|
|
3298
|
+
return { nextN: c, offset: u, isZero: h, isNeg: x, isNegF: f, offsetF: l };
|
|
3244
3299
|
}
|
|
3245
3300
|
const et = /* @__PURE__ */ new WeakMap(), bs = /* @__PURE__ */ new WeakMap();
|
|
3246
3301
|
function tt(r) {
|
|
3247
3302
|
return bs.get(r) || 1;
|
|
3248
3303
|
}
|
|
3249
3304
|
function Ft(r) {
|
|
3250
|
-
if (r !==
|
|
3305
|
+
if (r !== Oe)
|
|
3251
3306
|
throw new Error("invalid wNAF");
|
|
3252
3307
|
}
|
|
3253
3308
|
class Fr {
|
|
3254
3309
|
// Parametrized with a given Point class (not individual point)
|
|
3255
3310
|
constructor(e, s) {
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3311
|
+
E(this, "BASE");
|
|
3312
|
+
E(this, "ZERO");
|
|
3313
|
+
E(this, "Fn");
|
|
3314
|
+
E(this, "bits");
|
|
3260
3315
|
this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = s;
|
|
3261
3316
|
}
|
|
3262
3317
|
// non-const time multiplication ladder
|
|
3263
3318
|
_unsafeLadder(e, s, t = this.ZERO) {
|
|
3264
3319
|
let n = e;
|
|
3265
|
-
for (; s >
|
|
3320
|
+
for (; s > Oe; )
|
|
3266
3321
|
s & Ae && (t = t.add(n)), n = n.double(), s >>= Ae;
|
|
3267
3322
|
return t;
|
|
3268
3323
|
}
|
|
@@ -3301,8 +3356,8 @@ class Fr {
|
|
|
3301
3356
|
let n = this.ZERO, o = this.BASE;
|
|
3302
3357
|
const i = Qe(e, this.bits);
|
|
3303
3358
|
for (let a = 0; a < i.windows; a++) {
|
|
3304
|
-
const { nextN: c, offset: l, isZero: u, isNeg: h, isNegF:
|
|
3305
|
-
t = c, u ? o = o.add(Ke(
|
|
3359
|
+
const { nextN: c, offset: l, isZero: u, isNeg: h, isNegF: x, offsetF: f } = Ht(t, a, i);
|
|
3360
|
+
t = c, u ? o = o.add(Ke(x, s[f])) : n = n.add(Ke(h, s[l]));
|
|
3306
3361
|
}
|
|
3307
3362
|
return Ft(t), { p: n, f: o };
|
|
3308
3363
|
}
|
|
@@ -3313,7 +3368,7 @@ class Fr {
|
|
|
3313
3368
|
*/
|
|
3314
3369
|
wNAFUnsafe(e, s, t, n = this.ZERO) {
|
|
3315
3370
|
const o = Qe(e, this.bits);
|
|
3316
|
-
for (let i = 0; i < o.windows && t !==
|
|
3371
|
+
for (let i = 0; i < o.windows && t !== Oe; i++) {
|
|
3317
3372
|
const { nextN: a, offset: c, isZero: l, isNeg: u } = Ht(t, i, o);
|
|
3318
3373
|
if (t = a, !l) {
|
|
3319
3374
|
const h = s[c];
|
|
@@ -3346,7 +3401,7 @@ class Fr {
|
|
|
3346
3401
|
}
|
|
3347
3402
|
function Gr(r, e, s, t) {
|
|
3348
3403
|
let n = e, o = r.ZERO, i = r.ZERO;
|
|
3349
|
-
for (; s >
|
|
3404
|
+
for (; s > Oe || t > Oe; )
|
|
3350
3405
|
s & Ae && (o = o.add(n)), t & Ae && (i = i.add(n)), n = n.double(), s >>= Ae, t >>= Ae;
|
|
3351
3406
|
return { p1: o, p2: i };
|
|
3352
3407
|
}
|
|
@@ -3363,7 +3418,7 @@ function Wr(r, e, s = {}, t) {
|
|
|
3363
3418
|
throw new Error(`expected valid ${r} CURVE object`);
|
|
3364
3419
|
for (const c of ["p", "n", "h"]) {
|
|
3365
3420
|
const l = e[c];
|
|
3366
|
-
if (!(typeof l == "bigint" && l >
|
|
3421
|
+
if (!(typeof l == "bigint" && l > Oe))
|
|
3367
3422
|
throw new Error(`CURVE.${c} must be positive bigint`);
|
|
3368
3423
|
}
|
|
3369
3424
|
const n = Gt(e.p, s.Fp, t), o = Gt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
|
|
@@ -3380,13 +3435,13 @@ function qr(r, e) {
|
|
|
3380
3435
|
}
|
|
3381
3436
|
class vs {
|
|
3382
3437
|
constructor(e, s) {
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
if (ts(e),
|
|
3438
|
+
E(this, "oHash");
|
|
3439
|
+
E(this, "iHash");
|
|
3440
|
+
E(this, "blockLen");
|
|
3441
|
+
E(this, "outputLen");
|
|
3442
|
+
E(this, "finished", !1);
|
|
3443
|
+
E(this, "destroyed", !1);
|
|
3444
|
+
if (ts(e), V(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
|
|
3390
3445
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
3391
3446
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
3392
3447
|
const t = this.blockLen, n = new Uint8Array(t);
|
|
@@ -3402,7 +3457,7 @@ class vs {
|
|
|
3402
3457
|
return ke(this), this.iHash.update(e), this;
|
|
3403
3458
|
}
|
|
3404
3459
|
digestInto(e) {
|
|
3405
|
-
ke(this),
|
|
3460
|
+
ke(this), V(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
|
|
3406
3461
|
}
|
|
3407
3462
|
digest() {
|
|
3408
3463
|
const e = new Uint8Array(this.oHash.outputLen);
|
|
@@ -3427,12 +3482,12 @@ const Wt = (r, e) => (r + (r >= 0 ? e : -e) / Es) / e;
|
|
|
3427
3482
|
function Kr(r, e, s) {
|
|
3428
3483
|
const [[t, n], [o, i]] = e, a = Wt(i * r, s), c = Wt(-n * r, s);
|
|
3429
3484
|
let l = r - a * t - c * o, u = -a * n - c * i;
|
|
3430
|
-
const h = l < _e,
|
|
3431
|
-
h && (l = -l),
|
|
3485
|
+
const h = l < _e, x = u < _e;
|
|
3486
|
+
h && (l = -l), x && (u = -u);
|
|
3432
3487
|
const f = ft(Math.ceil(Rr(s) / 2)) + Re;
|
|
3433
3488
|
if (l < _e || l >= f || u < _e || u >= f)
|
|
3434
3489
|
throw new Error("splitScalar (endomorphism): failed, k=" + r);
|
|
3435
|
-
return { k1neg: h, k1: l, k2neg:
|
|
3490
|
+
return { k1neg: h, k1: l, k2neg: x, k2: u };
|
|
3436
3491
|
}
|
|
3437
3492
|
function ct(r) {
|
|
3438
3493
|
if (!["compact", "recovered", "der"].includes(r))
|
|
@@ -3525,7 +3580,7 @@ const ye = {
|
|
|
3525
3580
|
}
|
|
3526
3581
|
},
|
|
3527
3582
|
toSig(r) {
|
|
3528
|
-
const { Err: e, _int: s, _tlv: t } = ye, n =
|
|
3583
|
+
const { Err: e, _int: s, _tlv: t } = ye, n = V(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
|
|
3529
3584
|
if (i.length)
|
|
3530
3585
|
throw new e("invalid signature: left bytes after parsing");
|
|
3531
3586
|
const { v: a, l: c } = t.decode(2, o), { v: l, l: u } = t.decode(2, c);
|
|
@@ -3558,125 +3613,125 @@ function jr(r, e = {}) {
|
|
|
3558
3613
|
if (!t.isOdd)
|
|
3559
3614
|
throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
3560
3615
|
}
|
|
3561
|
-
function h(
|
|
3562
|
-
const { x:
|
|
3563
|
-
if (qe(
|
|
3616
|
+
function h(I, _, g) {
|
|
3617
|
+
const { x: v, y: R } = _.toAffine(), D = t.toBytes(v);
|
|
3618
|
+
if (qe(g, "isCompressed"), g) {
|
|
3564
3619
|
u();
|
|
3565
|
-
const
|
|
3566
|
-
return
|
|
3620
|
+
const N = !t.isOdd(R);
|
|
3621
|
+
return be(Is(N), D);
|
|
3567
3622
|
} else
|
|
3568
|
-
return
|
|
3569
|
-
}
|
|
3570
|
-
function
|
|
3571
|
-
|
|
3572
|
-
const { publicKey: _, publicKeyUncompressed:
|
|
3573
|
-
if (
|
|
3574
|
-
const
|
|
3575
|
-
if (!t.isValid(
|
|
3623
|
+
return be(Uint8Array.of(4), D, t.toBytes(R));
|
|
3624
|
+
}
|
|
3625
|
+
function x(I) {
|
|
3626
|
+
V(I, void 0, "Point");
|
|
3627
|
+
const { publicKey: _, publicKeyUncompressed: g } = l, v = I.length, R = I[0], D = I.subarray(1);
|
|
3628
|
+
if (v === _ && (R === 2 || R === 3)) {
|
|
3629
|
+
const N = t.fromBytes(D);
|
|
3630
|
+
if (!t.isValid(N))
|
|
3576
3631
|
throw new Error("bad point: is not on curve, wrong x");
|
|
3577
|
-
const
|
|
3632
|
+
const M = b(N);
|
|
3578
3633
|
let T;
|
|
3579
3634
|
try {
|
|
3580
|
-
T = t.sqrt(
|
|
3635
|
+
T = t.sqrt(M);
|
|
3581
3636
|
} catch (J) {
|
|
3582
3637
|
const K = J instanceof Error ? ": " + J.message : "";
|
|
3583
3638
|
throw new Error("bad point: is not on curve, sqrt error" + K);
|
|
3584
3639
|
}
|
|
3585
3640
|
u();
|
|
3586
|
-
const
|
|
3587
|
-
return (
|
|
3588
|
-
} else if (
|
|
3589
|
-
const
|
|
3590
|
-
if (!y(
|
|
3641
|
+
const $ = t.isOdd(T);
|
|
3642
|
+
return (R & 1) === 1 !== $ && (T = t.neg(T)), { x: N, y: T };
|
|
3643
|
+
} else if (v === g && R === 4) {
|
|
3644
|
+
const N = t.BYTES, M = t.fromBytes(D.subarray(0, N)), T = t.fromBytes(D.subarray(N, N * 2));
|
|
3645
|
+
if (!y(M, T))
|
|
3591
3646
|
throw new Error("bad point: is not on curve");
|
|
3592
|
-
return { x:
|
|
3647
|
+
return { x: M, y: T };
|
|
3593
3648
|
} else
|
|
3594
|
-
throw new Error(`bad point: got length ${
|
|
3649
|
+
throw new Error(`bad point: got length ${v}, expected compressed=${_} or uncompressed=${g}`);
|
|
3595
3650
|
}
|
|
3596
|
-
const f = e.toBytes || h, w = e.fromBytes ||
|
|
3597
|
-
function
|
|
3598
|
-
const _ = t.sqr(
|
|
3599
|
-
return t.add(t.add(
|
|
3651
|
+
const f = e.toBytes || h, w = e.fromBytes || x;
|
|
3652
|
+
function b(I) {
|
|
3653
|
+
const _ = t.sqr(I), g = t.mul(_, I);
|
|
3654
|
+
return t.add(t.add(g, t.mul(I, o.a)), o.b);
|
|
3600
3655
|
}
|
|
3601
|
-
function y(
|
|
3602
|
-
const
|
|
3603
|
-
return t.eql(
|
|
3656
|
+
function y(I, _) {
|
|
3657
|
+
const g = t.sqr(_), v = b(I);
|
|
3658
|
+
return t.eql(g, v);
|
|
3604
3659
|
}
|
|
3605
3660
|
if (!y(o.Gx, o.Gy))
|
|
3606
3661
|
throw new Error("bad curve params: generator point");
|
|
3607
|
-
const
|
|
3608
|
-
if (t.is0(t.add(
|
|
3662
|
+
const k = t.mul(t.pow(o.a, He), zr), C = t.mul(t.sqr(o.b), BigInt(27));
|
|
3663
|
+
if (t.is0(t.add(k, C)))
|
|
3609
3664
|
throw new Error("bad curve params: a or b");
|
|
3610
|
-
function
|
|
3611
|
-
if (!t.isValid(_) ||
|
|
3612
|
-
throw new Error(`bad point coordinate ${
|
|
3665
|
+
function W(I, _, g = !1) {
|
|
3666
|
+
if (!t.isValid(_) || g && t.is0(_))
|
|
3667
|
+
throw new Error(`bad point coordinate ${I}`);
|
|
3613
3668
|
return _;
|
|
3614
3669
|
}
|
|
3615
|
-
function
|
|
3616
|
-
if (!(
|
|
3670
|
+
function B(I) {
|
|
3671
|
+
if (!(I instanceof L))
|
|
3617
3672
|
throw new Error("Weierstrass Point expected");
|
|
3618
3673
|
}
|
|
3619
|
-
function
|
|
3674
|
+
function j(I) {
|
|
3620
3675
|
if (!c || !c.basises)
|
|
3621
3676
|
throw new Error("no endo");
|
|
3622
|
-
return Kr(
|
|
3623
|
-
}
|
|
3624
|
-
const
|
|
3625
|
-
const { X:
|
|
3626
|
-
if (t.eql(
|
|
3627
|
-
return { x, y:
|
|
3628
|
-
const
|
|
3629
|
-
_ == null && (_ =
|
|
3630
|
-
const
|
|
3631
|
-
if (
|
|
3677
|
+
return Kr(I, c.basises, n.ORDER);
|
|
3678
|
+
}
|
|
3679
|
+
const q = Mt((I, _) => {
|
|
3680
|
+
const { X: g, Y: v, Z: R } = I;
|
|
3681
|
+
if (t.eql(R, t.ONE))
|
|
3682
|
+
return { x: g, y: v };
|
|
3683
|
+
const D = I.is0();
|
|
3684
|
+
_ == null && (_ = D ? t.ONE : t.inv(R));
|
|
3685
|
+
const N = t.mul(g, _), M = t.mul(v, _), T = t.mul(R, _);
|
|
3686
|
+
if (D)
|
|
3632
3687
|
return { x: t.ZERO, y: t.ZERO };
|
|
3633
3688
|
if (!t.eql(T, t.ONE))
|
|
3634
3689
|
throw new Error("invZ was invalid");
|
|
3635
|
-
return { x:
|
|
3636
|
-
}), P = Mt((
|
|
3637
|
-
if (
|
|
3638
|
-
if (e.allowInfinityPoint && !t.is0(
|
|
3690
|
+
return { x: N, y: M };
|
|
3691
|
+
}), P = Mt((I) => {
|
|
3692
|
+
if (I.is0()) {
|
|
3693
|
+
if (e.allowInfinityPoint && !t.is0(I.Y))
|
|
3639
3694
|
return;
|
|
3640
3695
|
throw new Error("bad point: ZERO");
|
|
3641
3696
|
}
|
|
3642
|
-
const { x: _, y:
|
|
3643
|
-
if (!t.isValid(_) || !t.isValid(
|
|
3697
|
+
const { x: _, y: g } = I.toAffine();
|
|
3698
|
+
if (!t.isValid(_) || !t.isValid(g))
|
|
3644
3699
|
throw new Error("bad point: x or y not field elements");
|
|
3645
|
-
if (!y(_,
|
|
3700
|
+
if (!y(_, g))
|
|
3646
3701
|
throw new Error("bad point: equation left != right");
|
|
3647
|
-
if (!
|
|
3702
|
+
if (!I.isTorsionFree())
|
|
3648
3703
|
throw new Error("bad point: not in prime-order subgroup");
|
|
3649
3704
|
return !0;
|
|
3650
3705
|
});
|
|
3651
|
-
function
|
|
3652
|
-
return
|
|
3706
|
+
function S(I, _, g, v, R) {
|
|
3707
|
+
return g = new L(t.mul(g.X, I), g.Y, g.Z), _ = Ke(v, _), g = Ke(R, g), _.add(g);
|
|
3653
3708
|
}
|
|
3654
|
-
const
|
|
3709
|
+
const A = class A {
|
|
3655
3710
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
3656
|
-
constructor(_,
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
this.X =
|
|
3711
|
+
constructor(_, g, v) {
|
|
3712
|
+
E(this, "X");
|
|
3713
|
+
E(this, "Y");
|
|
3714
|
+
E(this, "Z");
|
|
3715
|
+
this.X = W("x", _), this.Y = W("y", g, !0), this.Z = W("z", v), Object.freeze(this);
|
|
3661
3716
|
}
|
|
3662
3717
|
static CURVE() {
|
|
3663
3718
|
return o;
|
|
3664
3719
|
}
|
|
3665
3720
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
3666
3721
|
static fromAffine(_) {
|
|
3667
|
-
const { x, y:
|
|
3668
|
-
if (!_ || !t.isValid(
|
|
3722
|
+
const { x: g, y: v } = _ || {};
|
|
3723
|
+
if (!_ || !t.isValid(g) || !t.isValid(v))
|
|
3669
3724
|
throw new Error("invalid affine point");
|
|
3670
|
-
if (_ instanceof
|
|
3725
|
+
if (_ instanceof A)
|
|
3671
3726
|
throw new Error("projective point not allowed");
|
|
3672
|
-
return t.is0(
|
|
3727
|
+
return t.is0(g) && t.is0(v) ? A.ZERO : new A(g, v, t.ONE);
|
|
3673
3728
|
}
|
|
3674
3729
|
static fromBytes(_) {
|
|
3675
|
-
const
|
|
3676
|
-
return
|
|
3730
|
+
const g = A.fromAffine(w(V(_, void 0, "point")));
|
|
3731
|
+
return g.assertValidity(), g;
|
|
3677
3732
|
}
|
|
3678
3733
|
static fromHex(_) {
|
|
3679
|
-
return
|
|
3734
|
+
return A.fromBytes(We(_));
|
|
3680
3735
|
}
|
|
3681
3736
|
get x() {
|
|
3682
3737
|
return this.toAffine().x;
|
|
@@ -3690,8 +3745,8 @@ function jr(r, e = {}) {
|
|
|
3690
3745
|
* @param isLazy true will defer table computation until the first multiplication
|
|
3691
3746
|
* @returns
|
|
3692
3747
|
*/
|
|
3693
|
-
precompute(_ = 8,
|
|
3694
|
-
return
|
|
3748
|
+
precompute(_ = 8, g = !0) {
|
|
3749
|
+
return O.createCache(this, _), g || this.multiply(He), this;
|
|
3695
3750
|
}
|
|
3696
3751
|
// TODO: return `this`
|
|
3697
3752
|
/** A point on curve is valid if it conforms to equation. */
|
|
@@ -3706,42 +3761,42 @@ function jr(r, e = {}) {
|
|
|
3706
3761
|
}
|
|
3707
3762
|
/** Compare one point to another. */
|
|
3708
3763
|
equals(_) {
|
|
3709
|
-
|
|
3710
|
-
const { X:
|
|
3711
|
-
return T &&
|
|
3764
|
+
B(_);
|
|
3765
|
+
const { X: g, Y: v, Z: R } = this, { X: D, Y: N, Z: M } = _, T = t.eql(t.mul(g, M), t.mul(D, R)), $ = t.eql(t.mul(v, M), t.mul(N, R));
|
|
3766
|
+
return T && $;
|
|
3712
3767
|
}
|
|
3713
3768
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
3714
3769
|
negate() {
|
|
3715
|
-
return new
|
|
3770
|
+
return new A(this.X, t.neg(this.Y), this.Z);
|
|
3716
3771
|
}
|
|
3717
3772
|
// Renes-Costello-Batina exception-free doubling formula.
|
|
3718
3773
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
3719
3774
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
3720
3775
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
3721
3776
|
double() {
|
|
3722
|
-
const { a: _, b:
|
|
3723
|
-
let
|
|
3724
|
-
return
|
|
3777
|
+
const { a: _, b: g } = o, v = t.mul(g, He), { X: R, Y: D, Z: N } = this;
|
|
3778
|
+
let M = t.ZERO, T = t.ZERO, $ = t.ZERO, F = t.mul(R, R), J = t.mul(D, D), K = t.mul(N, N), H = t.mul(R, D);
|
|
3779
|
+
return H = t.add(H, H), $ = t.mul(R, N), $ = t.add($, $), M = t.mul(_, $), T = t.mul(v, K), T = t.add(M, T), M = t.sub(J, T), T = t.add(J, T), T = t.mul(M, T), M = t.mul(H, M), $ = t.mul(v, $), K = t.mul(_, K), H = t.sub(F, K), H = t.mul(_, H), H = t.add(H, $), $ = t.add(F, F), F = t.add($, F), F = t.add(F, K), F = t.mul(F, H), T = t.add(T, F), K = t.mul(D, N), K = t.add(K, K), F = t.mul(K, H), M = t.sub(M, F), $ = t.mul(K, J), $ = t.add($, $), $ = t.add($, $), new A(M, T, $);
|
|
3725
3780
|
}
|
|
3726
3781
|
// Renes-Costello-Batina exception-free addition formula.
|
|
3727
3782
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
3728
3783
|
// https://eprint.iacr.org/2015/1060, algorithm 1
|
|
3729
3784
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
3730
3785
|
add(_) {
|
|
3731
|
-
|
|
3732
|
-
const { X:
|
|
3733
|
-
let T = t.ZERO,
|
|
3786
|
+
B(_);
|
|
3787
|
+
const { X: g, Y: v, Z: R } = this, { X: D, Y: N, Z: M } = _;
|
|
3788
|
+
let T = t.ZERO, $ = t.ZERO, F = t.ZERO;
|
|
3734
3789
|
const J = o.a, K = t.mul(o.b, He);
|
|
3735
|
-
let
|
|
3736
|
-
oe = t.mul(oe,
|
|
3737
|
-
let Q = t.add(
|
|
3738
|
-
return
|
|
3790
|
+
let H = t.mul(g, D), X = t.mul(v, N), Z = t.mul(R, M), oe = t.add(g, v), z = t.add(D, N);
|
|
3791
|
+
oe = t.mul(oe, z), z = t.add(H, X), oe = t.sub(oe, z), z = t.add(g, R);
|
|
3792
|
+
let Q = t.add(D, M);
|
|
3793
|
+
return z = t.mul(z, Q), Q = t.add(H, Z), z = t.sub(z, Q), Q = t.add(v, R), T = t.add(N, M), Q = t.mul(Q, T), T = t.add(X, Z), Q = t.sub(Q, T), F = t.mul(J, z), T = t.mul(K, Z), F = t.add(T, F), T = t.sub(X, F), F = t.add(X, F), $ = t.mul(T, F), X = t.add(H, H), X = t.add(X, H), Z = t.mul(J, Z), z = t.mul(K, z), X = t.add(X, Z), Z = t.sub(H, Z), Z = t.mul(J, Z), z = t.add(z, Z), H = t.mul(X, z), $ = t.add($, H), H = t.mul(Q, z), T = t.mul(oe, T), T = t.sub(T, H), H = t.mul(oe, X), F = t.mul(Q, F), F = t.add(F, H), new A(T, $, F);
|
|
3739
3794
|
}
|
|
3740
3795
|
subtract(_) {
|
|
3741
3796
|
return this.add(_.negate());
|
|
3742
3797
|
}
|
|
3743
3798
|
is0() {
|
|
3744
|
-
return this.equals(
|
|
3799
|
+
return this.equals(A.ZERO);
|
|
3745
3800
|
}
|
|
3746
3801
|
/**
|
|
3747
3802
|
* Constant time multiplication.
|
|
@@ -3753,19 +3808,19 @@ function jr(r, e = {}) {
|
|
|
3753
3808
|
* @returns New point
|
|
3754
3809
|
*/
|
|
3755
3810
|
multiply(_) {
|
|
3756
|
-
const { endo:
|
|
3811
|
+
const { endo: g } = e;
|
|
3757
3812
|
if (!n.isValidNot0(_))
|
|
3758
3813
|
throw new Error("invalid scalar: out of range");
|
|
3759
|
-
let
|
|
3760
|
-
const
|
|
3761
|
-
if (
|
|
3762
|
-
const { k1neg:
|
|
3763
|
-
|
|
3814
|
+
let v, R;
|
|
3815
|
+
const D = (N) => O.cached(this, N, (M) => Ut(A, M));
|
|
3816
|
+
if (g) {
|
|
3817
|
+
const { k1neg: N, k1: M, k2neg: T, k2: $ } = j(_), { p: F, f: J } = D(M), { p: K, f: H } = D($);
|
|
3818
|
+
R = J.add(H), v = S(g.beta, F, K, N, T);
|
|
3764
3819
|
} else {
|
|
3765
|
-
const { p:
|
|
3766
|
-
|
|
3820
|
+
const { p: N, f: M } = D(_);
|
|
3821
|
+
v = N, R = M;
|
|
3767
3822
|
}
|
|
3768
|
-
return Ut(
|
|
3823
|
+
return Ut(A, [v, R])[0];
|
|
3769
3824
|
}
|
|
3770
3825
|
/**
|
|
3771
3826
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -3773,27 +3828,27 @@ function jr(r, e = {}) {
|
|
|
3773
3828
|
* an exposed secret key e.g. sig verification, which works over *public* keys.
|
|
3774
3829
|
*/
|
|
3775
3830
|
multiplyUnsafe(_) {
|
|
3776
|
-
const { endo:
|
|
3831
|
+
const { endo: g } = e, v = this;
|
|
3777
3832
|
if (!n.isValid(_))
|
|
3778
3833
|
throw new Error("invalid scalar: out of range");
|
|
3779
|
-
if (_ === _e ||
|
|
3780
|
-
return
|
|
3834
|
+
if (_ === _e || v.is0())
|
|
3835
|
+
return A.ZERO;
|
|
3781
3836
|
if (_ === Re)
|
|
3782
|
-
return
|
|
3783
|
-
if (
|
|
3837
|
+
return v;
|
|
3838
|
+
if (O.hasCache(this))
|
|
3784
3839
|
return this.multiply(_);
|
|
3785
|
-
if (
|
|
3786
|
-
const { k1neg:
|
|
3787
|
-
return
|
|
3840
|
+
if (g) {
|
|
3841
|
+
const { k1neg: R, k1: D, k2neg: N, k2: M } = j(_), { p1: T, p2: $ } = Gr(A, v, D, M);
|
|
3842
|
+
return S(g.beta, T, $, R, N);
|
|
3788
3843
|
} else
|
|
3789
|
-
return
|
|
3844
|
+
return O.unsafe(v, _);
|
|
3790
3845
|
}
|
|
3791
3846
|
/**
|
|
3792
3847
|
* Converts Projective point to affine (x, y) coordinates.
|
|
3793
3848
|
* @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
|
|
3794
3849
|
*/
|
|
3795
3850
|
toAffine(_) {
|
|
3796
|
-
return
|
|
3851
|
+
return q(this, _);
|
|
3797
3852
|
}
|
|
3798
3853
|
/**
|
|
3799
3854
|
* Checks whether Point is free of torsion elements (is in prime subgroup).
|
|
@@ -3801,17 +3856,17 @@ function jr(r, e = {}) {
|
|
|
3801
3856
|
*/
|
|
3802
3857
|
isTorsionFree() {
|
|
3803
3858
|
const { isTorsionFree: _ } = e;
|
|
3804
|
-
return i === Re ? !0 : _ ? _(
|
|
3859
|
+
return i === Re ? !0 : _ ? _(A, this) : O.unsafe(this, a).is0();
|
|
3805
3860
|
}
|
|
3806
3861
|
clearCofactor() {
|
|
3807
3862
|
const { clearCofactor: _ } = e;
|
|
3808
|
-
return i === Re ? this : _ ? _(
|
|
3863
|
+
return i === Re ? this : _ ? _(A, this) : this.multiplyUnsafe(i);
|
|
3809
3864
|
}
|
|
3810
3865
|
isSmallOrder() {
|
|
3811
3866
|
return this.multiplyUnsafe(i).is0();
|
|
3812
3867
|
}
|
|
3813
3868
|
toBytes(_ = !0) {
|
|
3814
|
-
return qe(_, "isCompressed"), this.assertValidity(), f(
|
|
3869
|
+
return qe(_, "isCompressed"), this.assertValidity(), f(A, this, _);
|
|
3815
3870
|
}
|
|
3816
3871
|
toHex(_ = !0) {
|
|
3817
3872
|
return Me(this.toBytes(_));
|
|
@@ -3821,14 +3876,14 @@ function jr(r, e = {}) {
|
|
|
3821
3876
|
}
|
|
3822
3877
|
};
|
|
3823
3878
|
// base / generator point
|
|
3824
|
-
|
|
3825
|
-
|
|
3879
|
+
E(A, "BASE", new A(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
|
|
3880
|
+
E(A, "ZERO", new A(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
|
|
3826
3881
|
// math field
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
let
|
|
3830
|
-
const
|
|
3831
|
-
return
|
|
3882
|
+
E(A, "Fp", t), // scalar field
|
|
3883
|
+
E(A, "Fn", n);
|
|
3884
|
+
let L = A;
|
|
3885
|
+
const G = n.BITS, O = new Fr(L, e.endo ? Math.ceil(G / 2) : G);
|
|
3886
|
+
return L.BASE.precompute(8), L;
|
|
3832
3887
|
}
|
|
3833
3888
|
function Is(r) {
|
|
3834
3889
|
return Uint8Array.of(r ? 2 : 3);
|
|
@@ -3853,41 +3908,41 @@ function Yr(r, e = {}) {
|
|
|
3853
3908
|
}
|
|
3854
3909
|
}
|
|
3855
3910
|
function i(f, w) {
|
|
3856
|
-
const { publicKey:
|
|
3911
|
+
const { publicKey: b, publicKeyUncompressed: y } = n;
|
|
3857
3912
|
try {
|
|
3858
|
-
const
|
|
3859
|
-
return w === !0 &&
|
|
3913
|
+
const k = f.length;
|
|
3914
|
+
return w === !0 && k !== b || w === !1 && k !== y ? !1 : !!r.fromBytes(f);
|
|
3860
3915
|
} catch {
|
|
3861
3916
|
return !1;
|
|
3862
3917
|
}
|
|
3863
3918
|
}
|
|
3864
3919
|
function a(f = t(n.seed)) {
|
|
3865
|
-
return Hr(
|
|
3920
|
+
return Hr(V(f, n.seed, "seed"), s.ORDER);
|
|
3866
3921
|
}
|
|
3867
3922
|
function c(f, w = !0) {
|
|
3868
3923
|
return r.BASE.multiply(s.fromBytes(f)).toBytes(w);
|
|
3869
3924
|
}
|
|
3870
3925
|
function l(f) {
|
|
3871
|
-
const { secretKey: w, publicKey:
|
|
3872
|
-
if (!ut(f) || "_lengths" in s && s._lengths || w ===
|
|
3926
|
+
const { secretKey: w, publicKey: b, publicKeyUncompressed: y } = n;
|
|
3927
|
+
if (!ut(f) || "_lengths" in s && s._lengths || w === b)
|
|
3873
3928
|
return;
|
|
3874
|
-
const
|
|
3875
|
-
return
|
|
3929
|
+
const k = V(f, void 0, "key").length;
|
|
3930
|
+
return k === b || k === y;
|
|
3876
3931
|
}
|
|
3877
|
-
function u(f, w,
|
|
3932
|
+
function u(f, w, b = !0) {
|
|
3878
3933
|
if (l(f) === !0)
|
|
3879
3934
|
throw new Error("first arg must be private key");
|
|
3880
3935
|
if (l(w) === !1)
|
|
3881
3936
|
throw new Error("second arg must be public key");
|
|
3882
3937
|
const y = s.fromBytes(f);
|
|
3883
|
-
return r.fromBytes(w).multiply(y).toBytes(
|
|
3938
|
+
return r.fromBytes(w).multiply(y).toBytes(b);
|
|
3884
3939
|
}
|
|
3885
3940
|
const h = {
|
|
3886
3941
|
isValidSecretKey: o,
|
|
3887
3942
|
isValidPublicKey: i,
|
|
3888
3943
|
randomSecretKey: a
|
|
3889
|
-
},
|
|
3890
|
-
return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen:
|
|
3944
|
+
}, x = qr(a, c);
|
|
3945
|
+
return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen: x, Point: r, utils: h, lengths: n });
|
|
3891
3946
|
}
|
|
3892
3947
|
function Jr(r, e, s = {}) {
|
|
3893
3948
|
ts(e), _t(s, {}, {
|
|
@@ -3897,165 +3952,165 @@ function Jr(r, e, s = {}) {
|
|
|
3897
3952
|
bits2int: "function",
|
|
3898
3953
|
bits2int_modN: "function"
|
|
3899
3954
|
}), s = Object.assign({}, s);
|
|
3900
|
-
const t = s.randomBytes || os, n = s.hmac || ((_,
|
|
3955
|
+
const t = s.randomBytes || os, n = s.hmac || ((_, g) => Ss(e, _, g)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: u, getSharedSecret: h, utils: x, lengths: f } = Yr(r, s), w = {
|
|
3901
3956
|
prehash: !0,
|
|
3902
3957
|
lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
|
|
3903
3958
|
format: "compact",
|
|
3904
3959
|
extraEntropy: !1
|
|
3905
|
-
},
|
|
3960
|
+
}, b = a * Es < o.ORDER;
|
|
3906
3961
|
function y(_) {
|
|
3907
|
-
const
|
|
3908
|
-
return _ >
|
|
3962
|
+
const g = a >> Re;
|
|
3963
|
+
return _ > g;
|
|
3909
3964
|
}
|
|
3910
|
-
function
|
|
3911
|
-
if (!i.isValidNot0(
|
|
3965
|
+
function k(_, g) {
|
|
3966
|
+
if (!i.isValidNot0(g))
|
|
3912
3967
|
throw new Error(`invalid signature ${_}: out of range 1..Point.Fn.ORDER`);
|
|
3913
|
-
return
|
|
3968
|
+
return g;
|
|
3914
3969
|
}
|
|
3915
3970
|
function C() {
|
|
3916
|
-
if (
|
|
3971
|
+
if (b)
|
|
3917
3972
|
throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
3918
3973
|
}
|
|
3919
|
-
function
|
|
3920
|
-
ct(
|
|
3921
|
-
const
|
|
3922
|
-
return
|
|
3923
|
-
}
|
|
3924
|
-
class
|
|
3925
|
-
constructor(
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
if (this.r =
|
|
3930
|
-
if (C(), ![0, 1, 2, 3].includes(
|
|
3974
|
+
function W(_, g) {
|
|
3975
|
+
ct(g);
|
|
3976
|
+
const v = f.signature, R = g === "compact" ? v : g === "recovered" ? v + 1 : void 0;
|
|
3977
|
+
return V(_, R);
|
|
3978
|
+
}
|
|
3979
|
+
class B {
|
|
3980
|
+
constructor(g, v, R) {
|
|
3981
|
+
E(this, "r");
|
|
3982
|
+
E(this, "s");
|
|
3983
|
+
E(this, "recovery");
|
|
3984
|
+
if (this.r = k("r", g), this.s = k("s", v), R != null) {
|
|
3985
|
+
if (C(), ![0, 1, 2, 3].includes(R))
|
|
3931
3986
|
throw new Error("invalid recovery id");
|
|
3932
|
-
this.recovery =
|
|
3987
|
+
this.recovery = R;
|
|
3933
3988
|
}
|
|
3934
3989
|
Object.freeze(this);
|
|
3935
3990
|
}
|
|
3936
|
-
static fromBytes(
|
|
3937
|
-
|
|
3938
|
-
let
|
|
3939
|
-
if (
|
|
3940
|
-
const { r: T, s:
|
|
3941
|
-
return new
|
|
3991
|
+
static fromBytes(g, v = w.format) {
|
|
3992
|
+
W(g, v);
|
|
3993
|
+
let R;
|
|
3994
|
+
if (v === "der") {
|
|
3995
|
+
const { r: T, s: $ } = ye.toSig(V(g));
|
|
3996
|
+
return new B(T, $);
|
|
3942
3997
|
}
|
|
3943
|
-
|
|
3944
|
-
const
|
|
3945
|
-
return new
|
|
3998
|
+
v === "recovered" && (R = g[0], v = "compact", g = g.subarray(1));
|
|
3999
|
+
const D = f.signature / 2, N = g.subarray(0, D), M = g.subarray(D, D * 2);
|
|
4000
|
+
return new B(i.fromBytes(N), i.fromBytes(M), R);
|
|
3946
4001
|
}
|
|
3947
|
-
static fromHex(
|
|
3948
|
-
return this.fromBytes(We(
|
|
4002
|
+
static fromHex(g, v) {
|
|
4003
|
+
return this.fromBytes(We(g), v);
|
|
3949
4004
|
}
|
|
3950
4005
|
assertRecovery() {
|
|
3951
|
-
const { recovery:
|
|
3952
|
-
if (
|
|
4006
|
+
const { recovery: g } = this;
|
|
4007
|
+
if (g == null)
|
|
3953
4008
|
throw new Error("invalid recovery id: must be present");
|
|
3954
|
-
return
|
|
4009
|
+
return g;
|
|
3955
4010
|
}
|
|
3956
|
-
addRecoveryBit(
|
|
3957
|
-
return new
|
|
4011
|
+
addRecoveryBit(g) {
|
|
4012
|
+
return new B(this.r, this.s, g);
|
|
3958
4013
|
}
|
|
3959
|
-
recoverPublicKey(
|
|
3960
|
-
const { r:
|
|
3961
|
-
if (!o.isValid(
|
|
4014
|
+
recoverPublicKey(g) {
|
|
4015
|
+
const { r: v, s: R } = this, D = this.assertRecovery(), N = D === 2 || D === 3 ? v + a : v;
|
|
4016
|
+
if (!o.isValid(N))
|
|
3962
4017
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
3963
|
-
const
|
|
3964
|
-
if (
|
|
4018
|
+
const M = o.toBytes(N), T = r.fromBytes(be(Is((D & 1) === 0), M)), $ = i.inv(N), F = q(V(g, void 0, "msgHash")), J = i.create(-F * $), K = i.create(R * $), H = r.BASE.multiplyUnsafe(J).add(T.multiplyUnsafe(K));
|
|
4019
|
+
if (H.is0())
|
|
3965
4020
|
throw new Error("invalid recovery: point at infinify");
|
|
3966
|
-
return
|
|
4021
|
+
return H.assertValidity(), H;
|
|
3967
4022
|
}
|
|
3968
4023
|
// Signatures should be low-s, to prevent malleability.
|
|
3969
4024
|
hasHighS() {
|
|
3970
4025
|
return y(this.s);
|
|
3971
4026
|
}
|
|
3972
|
-
toBytes(
|
|
3973
|
-
if (ct(
|
|
4027
|
+
toBytes(g = w.format) {
|
|
4028
|
+
if (ct(g), g === "der")
|
|
3974
4029
|
return We(ye.hexFromSig(this));
|
|
3975
|
-
const { r:
|
|
3976
|
-
return
|
|
4030
|
+
const { r: v, s: R } = this, D = i.toBytes(v), N = i.toBytes(R);
|
|
4031
|
+
return g === "recovered" ? (C(), be(Uint8Array.of(this.assertRecovery()), D, N)) : be(D, N);
|
|
3977
4032
|
}
|
|
3978
|
-
toHex(
|
|
3979
|
-
return Me(this.toBytes(
|
|
4033
|
+
toHex(g) {
|
|
4034
|
+
return Me(this.toBytes(g));
|
|
3980
4035
|
}
|
|
3981
4036
|
}
|
|
3982
|
-
const
|
|
3983
|
-
if (
|
|
4037
|
+
const j = s.bits2int || function(g) {
|
|
4038
|
+
if (g.length > 8192)
|
|
3984
4039
|
throw new Error("input is too large");
|
|
3985
|
-
const
|
|
3986
|
-
return
|
|
3987
|
-
},
|
|
3988
|
-
return i.create(
|
|
4040
|
+
const v = ze(g), R = g.length * 8 - c;
|
|
4041
|
+
return R > 0 ? v >> BigInt(R) : v;
|
|
4042
|
+
}, q = s.bits2int_modN || function(g) {
|
|
4043
|
+
return i.create(j(g));
|
|
3989
4044
|
}, P = ft(c);
|
|
3990
|
-
function
|
|
4045
|
+
function S(_) {
|
|
3991
4046
|
return Tr("num < 2^" + c, _, _e, P), i.toBytes(_);
|
|
3992
4047
|
}
|
|
3993
|
-
function
|
|
3994
|
-
return
|
|
4048
|
+
function L(_, g) {
|
|
4049
|
+
return V(_, void 0, "message"), g ? V(e(_), void 0, "prehashed message") : _;
|
|
3995
4050
|
}
|
|
3996
|
-
function
|
|
3997
|
-
const { lowS:
|
|
3998
|
-
_ =
|
|
3999
|
-
const
|
|
4051
|
+
function G(_, g, v) {
|
|
4052
|
+
const { lowS: R, prehash: D, extraEntropy: N } = st(v, w);
|
|
4053
|
+
_ = L(_, D);
|
|
4054
|
+
const M = q(_), T = i.fromBytes(g);
|
|
4000
4055
|
if (!i.isValidNot0(T))
|
|
4001
4056
|
throw new Error("invalid private key");
|
|
4002
|
-
const
|
|
4003
|
-
if (
|
|
4004
|
-
const
|
|
4005
|
-
|
|
4006
|
-
}
|
|
4007
|
-
const
|
|
4008
|
-
function K(
|
|
4009
|
-
const X =
|
|
4057
|
+
const $ = [S(T), S(M)];
|
|
4058
|
+
if (N != null && N !== !1) {
|
|
4059
|
+
const H = N === !0 ? t(f.secretKey) : N;
|
|
4060
|
+
$.push(V(H, void 0, "extraEntropy"));
|
|
4061
|
+
}
|
|
4062
|
+
const F = be(...$), J = M;
|
|
4063
|
+
function K(H) {
|
|
4064
|
+
const X = j(H);
|
|
4010
4065
|
if (!i.isValidNot0(X))
|
|
4011
4066
|
return;
|
|
4012
|
-
const Z = i.inv(X), oe = r.BASE.multiply(X).toAffine(),
|
|
4013
|
-
if (
|
|
4067
|
+
const Z = i.inv(X), oe = r.BASE.multiply(X).toAffine(), z = i.create(oe.x);
|
|
4068
|
+
if (z === _e)
|
|
4014
4069
|
return;
|
|
4015
|
-
const Q = i.create(Z * i.create(J +
|
|
4070
|
+
const Q = i.create(Z * i.create(J + z * T));
|
|
4016
4071
|
if (Q === _e)
|
|
4017
4072
|
return;
|
|
4018
|
-
let yt = (oe.x ===
|
|
4019
|
-
return
|
|
4073
|
+
let yt = (oe.x === z ? 0 : 2) | Number(oe.y & Re), bt = Q;
|
|
4074
|
+
return R && y(Q) && (bt = i.neg(Q), yt ^= 1), new B(z, bt, b ? void 0 : yt);
|
|
4020
4075
|
}
|
|
4021
|
-
return { seed:
|
|
4076
|
+
return { seed: F, k2sig: K };
|
|
4022
4077
|
}
|
|
4023
|
-
function
|
|
4024
|
-
const { seed:
|
|
4025
|
-
return kr(e.outputLen, i.BYTES, n)(
|
|
4078
|
+
function O(_, g, v = {}) {
|
|
4079
|
+
const { seed: R, k2sig: D } = G(_, g, v);
|
|
4080
|
+
return kr(e.outputLen, i.BYTES, n)(R, D).toBytes(v.format);
|
|
4026
4081
|
}
|
|
4027
|
-
function
|
|
4028
|
-
const { lowS:
|
|
4029
|
-
if (
|
|
4030
|
-
const T = _ instanceof
|
|
4082
|
+
function A(_, g, v, R = {}) {
|
|
4083
|
+
const { lowS: D, prehash: N, format: M } = st(R, w);
|
|
4084
|
+
if (v = V(v, void 0, "publicKey"), g = L(g, N), !ut(_)) {
|
|
4085
|
+
const T = _ instanceof B ? ", use sig.toBytes()" : "";
|
|
4031
4086
|
throw new Error("verify expects Uint8Array signature" + T);
|
|
4032
4087
|
}
|
|
4033
|
-
|
|
4088
|
+
W(_, M);
|
|
4034
4089
|
try {
|
|
4035
|
-
const T =
|
|
4036
|
-
if (
|
|
4090
|
+
const T = B.fromBytes(_, M), $ = r.fromBytes(v);
|
|
4091
|
+
if (D && T.hasHighS())
|
|
4037
4092
|
return !1;
|
|
4038
|
-
const { r:
|
|
4039
|
-
return oe.is0() ? !1 : i.create(oe.x) ===
|
|
4093
|
+
const { r: F, s: J } = T, K = q(g), H = i.inv(J), X = i.create(K * H), Z = i.create(F * H), oe = r.BASE.multiplyUnsafe(X).add($.multiplyUnsafe(Z));
|
|
4094
|
+
return oe.is0() ? !1 : i.create(oe.x) === F;
|
|
4040
4095
|
} catch {
|
|
4041
4096
|
return !1;
|
|
4042
4097
|
}
|
|
4043
4098
|
}
|
|
4044
|
-
function
|
|
4045
|
-
const { prehash:
|
|
4046
|
-
return
|
|
4099
|
+
function I(_, g, v = {}) {
|
|
4100
|
+
const { prehash: R } = st(v, w);
|
|
4101
|
+
return g = L(g, R), B.fromBytes(_, "recovered").recoverPublicKey(g).toBytes();
|
|
4047
4102
|
}
|
|
4048
4103
|
return Object.freeze({
|
|
4049
4104
|
keygen: l,
|
|
4050
4105
|
getPublicKey: u,
|
|
4051
4106
|
getSharedSecret: h,
|
|
4052
|
-
utils:
|
|
4107
|
+
utils: x,
|
|
4053
4108
|
lengths: f,
|
|
4054
4109
|
Point: r,
|
|
4055
|
-
sign:
|
|
4056
|
-
verify:
|
|
4057
|
-
recoverPublicKey:
|
|
4058
|
-
Signature:
|
|
4110
|
+
sign: O,
|
|
4111
|
+
verify: A,
|
|
4112
|
+
recoverPublicKey: I,
|
|
4113
|
+
Signature: B,
|
|
4059
4114
|
hash: e
|
|
4060
4115
|
});
|
|
4061
4116
|
}
|
|
@@ -4076,20 +4131,20 @@ const gt = {
|
|
|
4076
4131
|
]
|
|
4077
4132
|
}, qt = /* @__PURE__ */ BigInt(2);
|
|
4078
4133
|
function Zr(r) {
|
|
4079
|
-
const e = gt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, u = l * l * r % e, h = ae(u, s, e) * u % e,
|
|
4080
|
-
if (!lt.eql(lt.sqr(
|
|
4134
|
+
const e = gt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, u = l * l * r % e, h = ae(u, s, e) * u % e, x = ae(h, s, e) * u % e, f = ae(x, qt, e) * l % e, w = ae(f, n, e) * f % e, b = ae(w, o, e) * w % e, y = ae(b, a, e) * b % e, k = ae(y, c, e) * y % e, C = ae(k, a, e) * b % e, W = ae(C, s, e) * u % e, B = ae(W, i, e) * w % e, j = ae(B, t, e) * l % e, q = ae(j, qt, e);
|
|
4135
|
+
if (!lt.eql(lt.sqr(q), r))
|
|
4081
4136
|
throw new Error("Cannot find square root");
|
|
4082
|
-
return
|
|
4137
|
+
return q;
|
|
4083
4138
|
}
|
|
4084
4139
|
const lt = je(gt.p, { sqrt: Zr }), Qr = /* @__PURE__ */ jr(gt, {
|
|
4085
4140
|
Fp: lt,
|
|
4086
4141
|
endo: Xr
|
|
4087
|
-
}), en = /* @__PURE__ */ Jr(Qr, Er), tn = BigInt(0),
|
|
4088
|
-
for (let r = 0, e =
|
|
4142
|
+
}), en = /* @__PURE__ */ Jr(Qr, Er), tn = BigInt(0), Ne = BigInt(1), sn = BigInt(2), rn = BigInt(7), nn = BigInt(256), on = BigInt(113), Ts = [], Rs = [], ks = [];
|
|
4143
|
+
for (let r = 0, e = Ne, s = 1, t = 0; r < 24; r++) {
|
|
4089
4144
|
[s, t] = [t, (2 * s + 3 * t) % 5], Ts.push(2 * (5 * t + s)), Rs.push((r + 1) * (r + 2) / 2 % 64);
|
|
4090
4145
|
let n = tn;
|
|
4091
4146
|
for (let o = 0; o < 7; o++)
|
|
4092
|
-
e = (e <<
|
|
4147
|
+
e = (e << Ne ^ (e >> rn) * on) % nn, e & sn && (n ^= Ne << (Ne << BigInt(o)) - Ne);
|
|
4093
4148
|
ks.push(n);
|
|
4094
4149
|
}
|
|
4095
4150
|
const Ps = xr(ks, !0), an = Ps[0], cn = Ps[1], Kt = (r, e, s) => s > 32 ? wr(r, e, s) : gr(r, e, s), Vt = (r, e, s) => s > 32 ? yr(r, e, s) : mr(r, e, s);
|
|
@@ -4099,9 +4154,9 @@ function ln(r, e = 24) {
|
|
|
4099
4154
|
for (let i = 0; i < 10; i++)
|
|
4100
4155
|
s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
|
|
4101
4156
|
for (let i = 0; i < 10; i += 2) {
|
|
4102
|
-
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], u = s[c + 1], h = Kt(l, u, 1) ^ s[a],
|
|
4157
|
+
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], u = s[c + 1], h = Kt(l, u, 1) ^ s[a], x = Vt(l, u, 1) ^ s[a + 1];
|
|
4103
4158
|
for (let f = 0; f < 50; f += 10)
|
|
4104
|
-
r[i + f] ^= h, r[i + f + 1] ^=
|
|
4159
|
+
r[i + f] ^= h, r[i + f + 1] ^= x;
|
|
4105
4160
|
}
|
|
4106
4161
|
let n = r[2], o = r[3];
|
|
4107
4162
|
for (let i = 0; i < 24; i++) {
|
|
@@ -4121,17 +4176,17 @@ function ln(r, e = 24) {
|
|
|
4121
4176
|
class mt {
|
|
4122
4177
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
4123
4178
|
constructor(e, s, t, n = !1, o = 24) {
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4179
|
+
E(this, "state");
|
|
4180
|
+
E(this, "pos", 0);
|
|
4181
|
+
E(this, "posOut", 0);
|
|
4182
|
+
E(this, "finished", !1);
|
|
4183
|
+
E(this, "state32");
|
|
4184
|
+
E(this, "destroyed", !1);
|
|
4185
|
+
E(this, "blockLen");
|
|
4186
|
+
E(this, "suffix");
|
|
4187
|
+
E(this, "outputLen");
|
|
4188
|
+
E(this, "enableXOF", !1);
|
|
4189
|
+
E(this, "rounds");
|
|
4135
4190
|
if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, ge(t, "outputLen"), !(0 < e && e < 200))
|
|
4136
4191
|
throw new Error("only keccak-f1600 function is supported");
|
|
4137
4192
|
this.state = new Uint8Array(200), this.state32 = ir(this.state);
|
|
@@ -4143,7 +4198,7 @@ class mt {
|
|
|
4143
4198
|
Ct(this.state32), ln(this.state32, this.rounds), Ct(this.state32), this.posOut = 0, this.pos = 0;
|
|
4144
4199
|
}
|
|
4145
4200
|
update(e) {
|
|
4146
|
-
ke(this),
|
|
4201
|
+
ke(this), V(e);
|
|
4147
4202
|
const { blockLen: s, state: t } = this, n = e.length;
|
|
4148
4203
|
for (let o = 0; o < n; ) {
|
|
4149
4204
|
const i = Math.min(s - this.pos, n - o);
|
|
@@ -4161,7 +4216,7 @@ class mt {
|
|
|
4161
4216
|
e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
|
|
4162
4217
|
}
|
|
4163
4218
|
writeInto(e) {
|
|
4164
|
-
ke(this, !1),
|
|
4219
|
+
ke(this, !1), V(e), this.finish();
|
|
4165
4220
|
const s = this.state, { blockLen: t } = this;
|
|
4166
4221
|
for (let n = 0, o = e.length; n < o; ) {
|
|
4167
4222
|
this.posOut >= t && this.keccak();
|
|
@@ -4262,10 +4317,10 @@ ${t.length}`
|
|
|
4262
4317
|
const i = zt(o), a = s.startsWith("0x") ? s.slice(2) : s;
|
|
4263
4318
|
if (a.length !== 130)
|
|
4264
4319
|
throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
|
|
4265
|
-
const c = pn(a), l = c.slice(0, 32), u = c.slice(32, 64), h = c[64],
|
|
4320
|
+
const c = pn(a), l = c.slice(0, 32), u = c.slice(32, 64), h = c[64], x = h >= 27 ? h - 27 : h, b = new en.Signature(
|
|
4266
4321
|
jt(l),
|
|
4267
4322
|
jt(u)
|
|
4268
|
-
).addRecoveryBit(
|
|
4323
|
+
).addRecoveryBit(x).recoverPublicKey(i).toBytes(!1).slice(1), y = zt(b);
|
|
4269
4324
|
return "0x" + Me(y.slice(12));
|
|
4270
4325
|
}
|
|
4271
4326
|
}
|
|
@@ -4332,7 +4387,7 @@ const gn = /* @__PURE__ */ new Set([
|
|
|
4332
4387
|
"https://stg-cross-wallet-oauth.crosstoken.io",
|
|
4333
4388
|
"https://dev-cross-wallet-oauth.crosstoken.io"
|
|
4334
4389
|
]);
|
|
4335
|
-
class
|
|
4390
|
+
class Ee {
|
|
4336
4391
|
static generateRandom16Hex() {
|
|
4337
4392
|
const e = new Uint8Array(16);
|
|
4338
4393
|
return crypto.getRandomValues(e), Array.from(e, (s) => s.toString(16).padStart(2, "0")).join("");
|
|
@@ -4356,7 +4411,7 @@ class be {
|
|
|
4356
4411
|
* - Google 및 기타: originalNonce === jwt.nonce
|
|
4357
4412
|
*/
|
|
4358
4413
|
static async verifyIdTokenNonce(e, s) {
|
|
4359
|
-
const t =
|
|
4414
|
+
const t = Ee.parseJwtPayload(e), n = t.nonce, o = typeof t.iss == "string" ? t.iss : "(unknown)";
|
|
4360
4415
|
if (d.log("[CROSSx] nonce 검증 시작 —", {
|
|
4361
4416
|
iss: o,
|
|
4362
4417
|
nonceClaimType: typeof n,
|
|
@@ -4370,15 +4425,15 @@ class be {
|
|
|
4370
4425
|
);
|
|
4371
4426
|
return;
|
|
4372
4427
|
}
|
|
4373
|
-
if (typeof n != "string" || n === "")
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
)
|
|
4378
|
-
|
|
4379
|
-
|
|
4428
|
+
if (typeof n != "string" || n === "") {
|
|
4429
|
+
d.warn("[CROSSx] nonce claim 누락 — nonce 검증 skip.", {
|
|
4430
|
+
iss: o,
|
|
4431
|
+
keys: Object.keys(t)
|
|
4432
|
+
});
|
|
4433
|
+
return;
|
|
4434
|
+
}
|
|
4380
4435
|
if (o.includes("appleid.apple.com")) {
|
|
4381
|
-
const i = await
|
|
4436
|
+
const i = await Ee.sha256Hex(s);
|
|
4382
4437
|
if (d.log("[CROSSx] Apple nonce 검증 —", {
|
|
4383
4438
|
expectedHashLength: i.length,
|
|
4384
4439
|
receivedHashLength: n.length,
|
|
@@ -4395,74 +4450,84 @@ class be {
|
|
|
4395
4450
|
}
|
|
4396
4451
|
openAuth(e) {
|
|
4397
4452
|
return new Promise((s, t) => {
|
|
4398
|
-
const n = Math.max(e.width ?? 500, 500), o = Math.max(e.height ?? 700, 700), i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c =
|
|
4453
|
+
const n = Math.max(e.width ?? 500, 500), o = Math.max(e.height ?? 700, 700), i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = Ee.generateRandom16Hex(), l = Ee.generateRandom16Hex(), u = e.authUrl.includes("?") ? "&" : "?", h = `${e.authUrl}${u}state=${c}&nonce=${l}`;
|
|
4399
4454
|
d.log("[CROSSx] OAuth 팝업 열기 — state, nonce 생성 완료:", {
|
|
4400
4455
|
stateLength: c.length,
|
|
4401
4456
|
nonceLength: l.length,
|
|
4402
4457
|
authUrlBase: e.authUrl
|
|
4403
4458
|
});
|
|
4404
|
-
const
|
|
4459
|
+
const x = window.open(
|
|
4405
4460
|
h,
|
|
4406
4461
|
"CROSSx OAuth",
|
|
4407
4462
|
`width=${n},height=${o},left=${i},top=${a}`
|
|
4408
4463
|
);
|
|
4409
|
-
if (!
|
|
4464
|
+
if (!x) {
|
|
4410
4465
|
t(new Error("팝업 창을 열 수 없습니다. 팝업 차단을 해제해 주세요."));
|
|
4411
4466
|
return;
|
|
4412
4467
|
}
|
|
4413
4468
|
const f = setTimeout(() => {
|
|
4414
|
-
d.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"),
|
|
4415
|
-
}, 5 * 60 * 1e3), w = 10,
|
|
4416
|
-
let y = 0,
|
|
4469
|
+
d.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), B(), t(new Error("Authentication timeout"));
|
|
4470
|
+
}, 5 * 60 * 1e3), w = 10, b = 30;
|
|
4471
|
+
let y = 0, k = null;
|
|
4417
4472
|
const C = () => {
|
|
4418
|
-
clearInterval(
|
|
4419
|
-
|
|
4473
|
+
clearInterval(W), d.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + b + "초간 대기합니다"), k = setTimeout(() => {
|
|
4474
|
+
B(), t(new Error(
|
|
4420
4475
|
"OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
|
|
4421
4476
|
));
|
|
4422
|
-
},
|
|
4423
|
-
},
|
|
4477
|
+
}, b * 1e3);
|
|
4478
|
+
}, W = setInterval(() => {
|
|
4424
4479
|
y++;
|
|
4425
4480
|
try {
|
|
4426
|
-
|
|
4481
|
+
x.closed && (y <= w ? C() : (B(), t(new Error("로그인이 취소되었습니다"))));
|
|
4427
4482
|
} catch {
|
|
4428
4483
|
C();
|
|
4429
4484
|
}
|
|
4430
|
-
}, 1e3),
|
|
4431
|
-
clearTimeout(f), clearInterval(
|
|
4432
|
-
},
|
|
4433
|
-
|
|
4434
|
-
if (
|
|
4435
|
-
|
|
4436
|
-
d.error("[CROSSx] postMessage origin이 허용 목록에 없음:", W.origin), N(), t(new Error("Unauthorized OAuth origin"));
|
|
4485
|
+
}, 1e3), B = () => {
|
|
4486
|
+
clearTimeout(f), clearInterval(W), k && clearTimeout(k), window.removeEventListener("message", j);
|
|
4487
|
+
}, j = (q) => {
|
|
4488
|
+
if (q.origin !== e.expectedOrigin) return;
|
|
4489
|
+
if (!gn.has(q.origin)) {
|
|
4490
|
+
d.error("[CROSSx] postMessage origin이 허용 목록에 없음:", q.origin), B(), t(new Error("Unauthorized OAuth origin"));
|
|
4437
4491
|
return;
|
|
4438
4492
|
}
|
|
4439
|
-
|
|
4440
|
-
const P =
|
|
4441
|
-
|
|
4493
|
+
B();
|
|
4494
|
+
const P = typeof q.data.status == "string", S = P ? q.data.data ?? {} : q.data;
|
|
4495
|
+
d.log("[CROSSx] OAuth postMessage 수신 —", {
|
|
4496
|
+
format: P ? "wrapped" : "flat",
|
|
4497
|
+
status: P ? q.data.status : "(flat)"
|
|
4498
|
+
});
|
|
4499
|
+
const L = (S == null ? void 0 : S.state) ?? q.data.state;
|
|
4500
|
+
if (!L || L !== c) {
|
|
4442
4501
|
t(new Error("OAuth state mismatch — possible CSRF attack"));
|
|
4443
4502
|
return;
|
|
4444
4503
|
}
|
|
4445
|
-
if (
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4504
|
+
if (P && q.data.status !== "success") {
|
|
4505
|
+
d.error("[CROSSx] OAuth 실패:", S == null ? void 0 : S.error), t(new Error((S == null ? void 0 : S.error) || "Authentication failed"));
|
|
4506
|
+
return;
|
|
4507
|
+
}
|
|
4508
|
+
if (!P && (S != null && S.error)) {
|
|
4509
|
+
d.error("[CROSSx] OAuth 실패:", S.error), t(new Error(S.error || "Authentication failed"));
|
|
4510
|
+
return;
|
|
4511
|
+
}
|
|
4512
|
+
const G = S == null ? void 0 : S.idToken, O = S == null ? void 0 : S.accessToken, A = O ?? G;
|
|
4513
|
+
if (d.log("[CROSSx] OAuth 토큰 수신:", {
|
|
4514
|
+
hasAccessToken: !!O,
|
|
4515
|
+
hasIdToken: !!G
|
|
4516
|
+
}), !A) {
|
|
4517
|
+
d.error("[CROSSx] 토큰을 찾을 수 없음:", q.data), t(new Error("Token not found in response"));
|
|
4518
|
+
return;
|
|
4519
|
+
}
|
|
4520
|
+
const I = (_) => {
|
|
4521
|
+
Ee.verifyIdTokenNonce(_, l).then(() => s(A)).catch((g) => {
|
|
4522
|
+
d.error("[CROSSx] nonce 검증 실패:", g), t(g instanceof Error ? g : new Error("nonce verification failed"));
|
|
4523
|
+
});
|
|
4524
|
+
};
|
|
4525
|
+
O ? O.split(".").length === 3 ? I(O) : G ? I(G) : (d.warn(
|
|
4526
|
+
"[CROSSx] opaque accessToken만 수신 (idToken 없음) — nonce 검증 불가.",
|
|
4527
|
+
"서버 측 nonce 검증이 필요합니다."
|
|
4528
|
+
), s(A)) : G ? I(G) : t(new Error("Token not found in response"));
|
|
4464
4529
|
};
|
|
4465
|
-
window.addEventListener("message",
|
|
4530
|
+
window.addEventListener("message", j);
|
|
4466
4531
|
});
|
|
4467
4532
|
}
|
|
4468
4533
|
}
|
|
@@ -4658,8 +4723,8 @@ class Le {
|
|
|
4658
4723
|
url: o,
|
|
4659
4724
|
method: e
|
|
4660
4725
|
});
|
|
4661
|
-
const
|
|
4662
|
-
throw
|
|
4726
|
+
const x = Le.mapGatewayError(u.code, u.data), f = Le.getGatewayErrorMessage(u.code, h), w = u.data, b = x === p.PIN_LOCKED ? Le.extractLockDetails(w) : w ?? void 0, y = new m(x, f, b);
|
|
4727
|
+
throw x === p.AUTH_NOT_AUTHENTICATED && this._onUnauthorized && (d.warn("[CROSSx] Gateway -10002 감지 — 강제 로그아웃 실행"), this._onUnauthorized()), y;
|
|
4663
4728
|
}
|
|
4664
4729
|
return d.log("[CROSSx] Wallet Gateway API 성공:", { code: u.code, url: o, method: e }), u.data ?? u;
|
|
4665
4730
|
}
|
|
@@ -4667,16 +4732,16 @@ class Le {
|
|
|
4667
4732
|
} catch (l) {
|
|
4668
4733
|
if (l instanceof m) throw l;
|
|
4669
4734
|
if ((a = l.response) != null && a.data) {
|
|
4670
|
-
const u = l.response.data, h = u.message || u.data || "API 요청에 실패했습니다",
|
|
4735
|
+
const u = l.response.data, h = u.message || u.data || "API 요청에 실패했습니다", x = u.code || "UNKNOWN";
|
|
4671
4736
|
throw d.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
|
|
4672
|
-
code:
|
|
4737
|
+
code: x,
|
|
4673
4738
|
message: h,
|
|
4674
4739
|
url: o,
|
|
4675
4740
|
method: e,
|
|
4676
4741
|
status: (c = l.response) == null ? void 0 : c.status
|
|
4677
4742
|
}), new m(
|
|
4678
4743
|
p.UNKNOWN_ERROR,
|
|
4679
|
-
`Wallet Gateway 오류 (${
|
|
4744
|
+
`Wallet Gateway 오류 (${x}): ${h}`
|
|
4680
4745
|
);
|
|
4681
4746
|
}
|
|
4682
4747
|
throw l;
|
|
@@ -6955,7 +7020,7 @@ const Xt = {
|
|
|
6955
7020
|
612044: "CROSS Testnet",
|
|
6956
7021
|
612055: "CROSS Mainnet"
|
|
6957
7022
|
};
|
|
6958
|
-
function
|
|
7023
|
+
function Os(r) {
|
|
6959
7024
|
const e = parseInt(r.split(":")[1] ?? "", 10);
|
|
6960
7025
|
return !isNaN(e) && Xt[e] ? Xt[e] : r;
|
|
6961
7026
|
}
|
|
@@ -7008,7 +7073,7 @@ function Sn(r) {
|
|
|
7008
7073
|
return null;
|
|
7009
7074
|
}
|
|
7010
7075
|
}
|
|
7011
|
-
function
|
|
7076
|
+
function Ns(r) {
|
|
7012
7077
|
const e = Sn(r);
|
|
7013
7078
|
if (!e) return Y("Estimated fee", "<span>—</span>");
|
|
7014
7079
|
let s = Y("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
|
|
@@ -7069,7 +7134,7 @@ function Y(r, e) {
|
|
|
7069
7134
|
}
|
|
7070
7135
|
function Tn(r, e) {
|
|
7071
7136
|
const s = e, t = Ye(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
7072
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7137
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", o = Ns(r), i = r.data ?? "0x", a = document.createElement("div");
|
|
7073
7138
|
return a.id = te, a.innerHTML = `
|
|
7074
7139
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7075
7140
|
<div class="__crossx-header">
|
|
@@ -7081,7 +7146,7 @@ function Tn(r, e) {
|
|
|
7081
7146
|
<div class="__crossx-body-cols">
|
|
7082
7147
|
<div class="__crossx-col-left">
|
|
7083
7148
|
<p class="__crossx-sig-subtitle">
|
|
7084
|
-
<span class="__crossx-sig-origin">${
|
|
7149
|
+
<span class="__crossx-sig-origin">${U(t)} </span>is requesting a Signature
|
|
7085
7150
|
</p>
|
|
7086
7151
|
<div class="__crossx-addr-pill">
|
|
7087
7152
|
${wt}
|
|
@@ -7093,10 +7158,10 @@ function Tn(r, e) {
|
|
|
7093
7158
|
<div class="__crossx-col-right-sign">
|
|
7094
7159
|
<div class="__crossx-rows">
|
|
7095
7160
|
${Y("To", n)}
|
|
7096
|
-
${Y("Network", `<span>${
|
|
7161
|
+
${Y("Network", `<span>${Os(r.chainId)}</span>`)}
|
|
7097
7162
|
${o}
|
|
7098
7163
|
</div>
|
|
7099
|
-
<pre class="__crossx-raw-tx">${
|
|
7164
|
+
<pre class="__crossx-raw-tx">${U(i)}</pre>
|
|
7100
7165
|
</div>
|
|
7101
7166
|
</div>
|
|
7102
7167
|
<div class="__crossx-btn-row">
|
|
@@ -7109,7 +7174,7 @@ function Tn(r, e) {
|
|
|
7109
7174
|
}
|
|
7110
7175
|
function Rn(r, e) {
|
|
7111
7176
|
const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Ye(r.dappName), i = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
7112
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7177
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>` : "<span>—</span>", a = Ns(r), l = bn(r.value, t, n) ?? "—", u = document.createElement("div");
|
|
7113
7178
|
return u.id = te, u.innerHTML = `
|
|
7114
7179
|
<div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7115
7180
|
<div class="__crossx-header">
|
|
@@ -7119,12 +7184,12 @@ function Rn(r, e) {
|
|
|
7119
7184
|
<hr class="__crossx-divider">
|
|
7120
7185
|
<div class="__crossx-body">
|
|
7121
7186
|
<p class="__crossx-tx-subtitle">
|
|
7122
|
-
<span class="__crossx-sig-origin">${
|
|
7187
|
+
<span class="__crossx-sig-origin">${U(o)}</span> wants your permission to approve the following transaction.
|
|
7123
7188
|
</p>
|
|
7124
7189
|
<div class="__crossx-body-cols">
|
|
7125
7190
|
<div class="__crossx-rows">
|
|
7126
7191
|
${Y("To", i)}
|
|
7127
|
-
${Y("Network", `<span>${
|
|
7192
|
+
${Y("Network", `<span>${Os(r.chainId)}</span>`)}
|
|
7128
7193
|
${a}
|
|
7129
7194
|
</div>
|
|
7130
7195
|
<div class="__crossx-pill">
|
|
@@ -7146,31 +7211,31 @@ function Ye(r) {
|
|
|
7146
7211
|
return "This site";
|
|
7147
7212
|
}
|
|
7148
7213
|
}
|
|
7149
|
-
function
|
|
7214
|
+
function U(r) {
|
|
7150
7215
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7151
7216
|
}
|
|
7152
7217
|
function kn(r) {
|
|
7153
7218
|
return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
|
|
7154
7219
|
}
|
|
7155
7220
|
function Pn(r) {
|
|
7156
|
-
if (typeof r == "string") return
|
|
7221
|
+
if (typeof r == "string") return U(r);
|
|
7157
7222
|
if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
|
|
7158
7223
|
try {
|
|
7159
|
-
return
|
|
7224
|
+
return U(JSON.stringify(r));
|
|
7160
7225
|
} catch {
|
|
7161
7226
|
return String(r);
|
|
7162
7227
|
}
|
|
7163
7228
|
}
|
|
7164
|
-
function
|
|
7229
|
+
function On(r, e) {
|
|
7165
7230
|
const s = Y(
|
|
7166
7231
|
"From",
|
|
7167
7232
|
`<span class="__crossx-addr-text">${se(r.from)}</span>
|
|
7168
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7233
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.from)}" title="Copy address">${xe}</button>`
|
|
7169
7234
|
), t = r.to ? Y("To", `<span class="__crossx-addr-text">${se(r.to)}</span>
|
|
7170
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7171
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7235
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.to)}" title="Copy address">${xe}</button>`) : "", n = r.amount ? Y("Transfer", `<span>${U(r.amount)}</span>`) : "", o = r.fees ? Y("Tx Fee", `<span>${U(r.fees)}</span>`) : "", i = r.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(r.txHash)}</span>
|
|
7236
|
+
<button class="__crossx-copy-btn" data-copy="${U(r.txHash)}" title="Copy hash">${xe}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
|
|
7172
7237
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
7173
|
-
<span class="__crossx-total-amount">${
|
|
7238
|
+
<span class="__crossx-total-amount">${U(r.total)}</span>
|
|
7174
7239
|
</div>` : "", c = document.createElement("div");
|
|
7175
7240
|
return c.id = te, c.innerHTML = `
|
|
7176
7241
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7193,7 +7258,7 @@ function Nn(r, e) {
|
|
|
7193
7258
|
</div>
|
|
7194
7259
|
`, c;
|
|
7195
7260
|
}
|
|
7196
|
-
function
|
|
7261
|
+
function Nn(r, e) {
|
|
7197
7262
|
const s = document.createElement("div");
|
|
7198
7263
|
return s.id = te, s.innerHTML = `
|
|
7199
7264
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -7213,8 +7278,8 @@ function On(r, e) {
|
|
|
7213
7278
|
function Cn(r, e, s) {
|
|
7214
7279
|
const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
|
|
7215
7280
|
if (o) {
|
|
7216
|
-
const w = n ? An : t ? "" : In,
|
|
7217
|
-
w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${
|
|
7281
|
+
const w = n ? An : t ? "" : In, b = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
|
|
7282
|
+
w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${b}</span>`) : o.textContent = b;
|
|
7218
7283
|
}
|
|
7219
7284
|
if (i && !r.querySelector("#__crossx-close-btn")) {
|
|
7220
7285
|
const w = document.createElement("button");
|
|
@@ -7223,11 +7288,11 @@ function Cn(r, e, s) {
|
|
|
7223
7288
|
const a = r.querySelector("#__crossx-progress-body");
|
|
7224
7289
|
if (!a) return;
|
|
7225
7290
|
const c = e.from ? Y("From", `<span class="__crossx-addr-text">${se(e.from)}</span>
|
|
7226
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7227
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7228
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7291
|
+
<button class="__crossx-copy-btn" data-copy="${U(e.from)}" title="Copy address">${xe}</button>`) : "", l = e.to ? Y("To", `<span class="__crossx-addr-text">${se(e.to)}</span>
|
|
7292
|
+
<button class="__crossx-copy-btn" data-copy="${U(e.to)}" title="Copy address">${xe}</button>`) : "", u = e.amount ? Y("Transfer", `<span>${U(e.amount)}</span>`) : "", h = e.fees ? Y("Tx Fee", `<span>${U(e.fees)}</span>`) : "", x = e.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${se(e.txHash)}</span>
|
|
7293
|
+
<button class="__crossx-copy-btn" data-copy="${U(e.txHash)}" title="Copy hash">${xe}</button>`) : "", f = e.total ? `<div class="__crossx-total-pill">
|
|
7229
7294
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
7230
|
-
<span class="__crossx-total-amount">${
|
|
7295
|
+
<span class="__crossx-total-amount">${U(e.total)}</span>
|
|
7231
7296
|
</div>` : "";
|
|
7232
7297
|
a.innerHTML = `
|
|
7233
7298
|
<div class="__crossx-rows">
|
|
@@ -7235,22 +7300,22 @@ function Cn(r, e, s) {
|
|
|
7235
7300
|
${l}
|
|
7236
7301
|
${u}
|
|
7237
7302
|
${h}
|
|
7238
|
-
${
|
|
7303
|
+
${x}
|
|
7239
7304
|
</div>
|
|
7240
7305
|
${f}
|
|
7241
7306
|
<button class="__crossx-approve-btn" id="__crossx-done-btn">${t ? "All Done" : "Done"}</button>
|
|
7242
7307
|
`, a.querySelectorAll(".__crossx-copy-btn").forEach((w) => {
|
|
7243
|
-
w.addEventListener("click", (
|
|
7244
|
-
var
|
|
7245
|
-
|
|
7308
|
+
w.addEventListener("click", (b) => {
|
|
7309
|
+
var k;
|
|
7310
|
+
b.stopPropagation();
|
|
7246
7311
|
const y = w.dataset.copy;
|
|
7247
|
-
y && ((
|
|
7312
|
+
y && ((k = navigator.clipboard) == null || k.writeText(y).catch(() => {
|
|
7248
7313
|
}));
|
|
7249
7314
|
});
|
|
7250
7315
|
});
|
|
7251
7316
|
}
|
|
7252
7317
|
function Ln(r, e) {
|
|
7253
|
-
const s = e, t = Ye(r.dappName), n =
|
|
7318
|
+
const s = e, t = Ye(r.dappName), n = U(r.message), o = document.createElement("div");
|
|
7254
7319
|
return o.id = te, o.innerHTML = `
|
|
7255
7320
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7256
7321
|
<div class="__crossx-header">
|
|
@@ -7262,7 +7327,7 @@ function Ln(r, e) {
|
|
|
7262
7327
|
<div class="__crossx-body-cols">
|
|
7263
7328
|
<div class="__crossx-col-left">
|
|
7264
7329
|
<p class="__crossx-sig-subtitle">
|
|
7265
|
-
<span class="__crossx-sig-origin">${
|
|
7330
|
+
<span class="__crossx-sig-origin">${U(t)} </span>is requesting a Signature
|
|
7266
7331
|
</p>
|
|
7267
7332
|
<div class="__crossx-addr-pill">
|
|
7268
7333
|
${wt}
|
|
@@ -7294,14 +7359,14 @@ function Dn(r, e) {
|
|
|
7294
7359
|
let a = `
|
|
7295
7360
|
<div class="__crossx-td-row">
|
|
7296
7361
|
<span class="__crossx-td-label">Primary Type</span>
|
|
7297
|
-
<span class="__crossx-td-value">${
|
|
7362
|
+
<span class="__crossx-td-value">${U(o)}</span>
|
|
7298
7363
|
</div>`;
|
|
7299
7364
|
for (const [l, u] of Object.entries(i)) {
|
|
7300
7365
|
const h = Pn(u), f = kn(u) ? `<span class="__crossx-addr-text">${se(u)}</span>
|
|
7301
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7366
|
+
<button class="__crossx-copy-btn" data-copy="${U(String(u))}" title="Copy">${xe}</button>` : `<span>${h}</span>`;
|
|
7302
7367
|
a += `
|
|
7303
7368
|
<div class="__crossx-td-row">
|
|
7304
|
-
<span class="__crossx-td-label">${
|
|
7369
|
+
<span class="__crossx-td-label">${U(l)}</span>
|
|
7305
7370
|
<div class="__crossx-td-value">${f}</div>
|
|
7306
7371
|
</div>`;
|
|
7307
7372
|
}
|
|
@@ -7317,7 +7382,7 @@ function Dn(r, e) {
|
|
|
7317
7382
|
<div class="__crossx-body-cols">
|
|
7318
7383
|
<div class="__crossx-col-left">
|
|
7319
7384
|
<p class="__crossx-sig-subtitle">
|
|
7320
|
-
<span class="__crossx-sig-origin">${
|
|
7385
|
+
<span class="__crossx-sig-origin">${U(t)} </span>is requesting a Signature
|
|
7321
7386
|
</p>
|
|
7322
7387
|
<div class="__crossx-addr-pill">
|
|
7323
7388
|
${wt}
|
|
@@ -7343,7 +7408,7 @@ const Mn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="
|
|
|
7343
7408
|
function $n(r, e, s) {
|
|
7344
7409
|
const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
|
|
7345
7410
|
const a = t && i.address.toLowerCase() === t;
|
|
7346
|
-
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${
|
|
7411
|
+
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${U(i.address)}">
|
|
7347
7412
|
<span class="__crossx-wallet-addr">${se(i.address)}</span>${a ? '<span class="__crossx-wallet-selected">selected</span>' : ""}
|
|
7348
7413
|
</button>`;
|
|
7349
7414
|
}).join(""), o = document.createElement("div");
|
|
@@ -7515,13 +7580,13 @@ function Kn(r) {
|
|
|
7515
7580
|
const s = [r.check1, r.check2].map((t, n) => `
|
|
7516
7581
|
<div class="__crossx-pw-notice-item" data-check-index="${n}" role="checkbox" aria-checked="false" tabindex="0">
|
|
7517
7582
|
<div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${jn}</div>
|
|
7518
|
-
<span class="__crossx-pw-notice-item-text">${
|
|
7583
|
+
<span class="__crossx-pw-notice-item-text">${U(t)}</span>
|
|
7519
7584
|
</div>
|
|
7520
7585
|
`).join("");
|
|
7521
7586
|
return `
|
|
7522
7587
|
<div class="__crossx-header">
|
|
7523
|
-
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${
|
|
7524
|
-
<p class="__crossx-pw-subtitle">${
|
|
7588
|
+
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${U(r.title)}</p>
|
|
7589
|
+
<p class="__crossx-pw-subtitle">${U(r.headerSubtitle)}</p>
|
|
7525
7590
|
<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
|
|
7526
7591
|
</div>
|
|
7527
7592
|
<hr class="__crossx-divider">
|
|
@@ -7530,25 +7595,25 @@ function Kn(r) {
|
|
|
7530
7595
|
<div class="__crossx-pw-notice-header">
|
|
7531
7596
|
<div class="__crossx-pw-notice-title-row">
|
|
7532
7597
|
<span class="__crossx-pw-notice-icon">${Yn}</span>
|
|
7533
|
-
<p class="__crossx-pw-notice-title">${
|
|
7598
|
+
<p class="__crossx-pw-notice-title">${U(r.noticeTitle)}</p>
|
|
7534
7599
|
</div>
|
|
7535
|
-
<p class="__crossx-pw-notice-desc">${
|
|
7600
|
+
<p class="__crossx-pw-notice-desc">${U(r.noticeDesc)}</p>
|
|
7536
7601
|
</div>
|
|
7537
7602
|
<div class="__crossx-pw-notice-checks" id="__crossx-notice-checks">
|
|
7538
7603
|
${s}
|
|
7539
7604
|
</div>
|
|
7540
7605
|
</div>
|
|
7541
7606
|
<button class="__crossx-pw-btn --disabled" id="__crossx-pin-notice-next"
|
|
7542
|
-
data-next-label="${
|
|
7543
|
-
data-submit-label="${
|
|
7544
|
-
${
|
|
7607
|
+
data-next-label="${U(r.nextButton)}"
|
|
7608
|
+
data-submit-label="${U(r.submitButton)}">
|
|
7609
|
+
${U(r.nextButton)}
|
|
7545
7610
|
</button>
|
|
7546
7611
|
</div>
|
|
7547
7612
|
<div class="__crossx-home-indicator"></div>
|
|
7548
7613
|
`;
|
|
7549
7614
|
}
|
|
7550
7615
|
function nt(r) {
|
|
7551
|
-
const e = !!r.lockExpiresAt && r.lockExpiresAt > Date.now(), s = r.lockExpiresAt ? ` data-lock-expires="${r.lockExpiresAt}"` : "", t = r.headerSubtitle ? `<p class="__crossx-pin6-header-sub">${
|
|
7616
|
+
const e = !!r.lockExpiresAt && r.lockExpiresAt > Date.now(), s = r.lockExpiresAt ? ` data-lock-expires="${r.lockExpiresAt}"` : "", t = r.headerSubtitle ? `<p class="__crossx-pin6-header-sub">${U(r.headerSubtitle)}</p>` : "", n = r.subtitle ? `<p class="__crossx-pin6-subtitle">${U(r.subtitle)}</p>` : "", o = r.errorMessage ? `<p class="__crossx-pin6-error" id="__crossx-pin6-error">${U(r.errorMessage)}</p>` : '<p class="__crossx-pin6-error" id="__crossx-pin6-error"></p>', i = e ? `<p class="__crossx-pin6-lock-msg" id="__crossx-pin6-lock-msg">
|
|
7552
7617
|
${Cs}
|
|
7553
7618
|
<span id="__crossx-pin6-lock-countdown"></span>
|
|
7554
7619
|
</p>` : "", a = e ? " --locked" : "", c = Array.from(
|
|
@@ -7557,7 +7622,7 @@ function nt(r) {
|
|
|
7557
7622
|
).join("");
|
|
7558
7623
|
return `
|
|
7559
7624
|
<div class="__crossx-header">
|
|
7560
|
-
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${
|
|
7625
|
+
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${U(r.title)}</p>
|
|
7561
7626
|
${t}
|
|
7562
7627
|
<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
|
|
7563
7628
|
</div>
|
|
@@ -7593,68 +7658,68 @@ function zn(r) {
|
|
|
7593
7658
|
return s > 0 ? `${s}h ${String(t).padStart(2, "0")}m` : `${String(t).padStart(2, "0")}:${String(n).padStart(2, "0")}`;
|
|
7594
7659
|
}
|
|
7595
7660
|
function ot(r, e, s, t, n, o) {
|
|
7596
|
-
var
|
|
7661
|
+
var j, q;
|
|
7597
7662
|
let i = !!(o && o > Date.now()), a = !1;
|
|
7598
|
-
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), u = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"),
|
|
7599
|
-
i = P, c().forEach((
|
|
7600
|
-
|
|
7663
|
+
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), u = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), x = () => r.querySelector("#__crossx-pin6-lock-countdown"), f = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((P) => P.value).join(""), b = (P) => {
|
|
7664
|
+
i = P, c().forEach((S) => {
|
|
7665
|
+
S.disabled = P, S.classList.toggle("--locked", P);
|
|
7601
7666
|
});
|
|
7602
7667
|
}, y = () => {
|
|
7603
7668
|
const P = u();
|
|
7604
7669
|
P && (P.textContent = "");
|
|
7605
|
-
},
|
|
7606
|
-
const
|
|
7607
|
-
|
|
7608
|
-
const
|
|
7609
|
-
|
|
7610
|
-
|
|
7670
|
+
}, k = (P) => {
|
|
7671
|
+
const S = u();
|
|
7672
|
+
S && (S.textContent = P);
|
|
7673
|
+
const L = l();
|
|
7674
|
+
L == null || L.classList.add("--shake"), setTimeout(() => L == null ? void 0 : L.classList.remove("--shake"), 500), c().forEach((G) => {
|
|
7675
|
+
G.value = "";
|
|
7611
7676
|
}), setTimeout(() => {
|
|
7612
|
-
var
|
|
7613
|
-
return (
|
|
7677
|
+
var G;
|
|
7678
|
+
return (G = c()[0]) == null ? void 0 : G.focus();
|
|
7614
7679
|
}, 50);
|
|
7615
7680
|
}, C = (P) => {
|
|
7616
|
-
var
|
|
7617
|
-
|
|
7618
|
-
|
|
7681
|
+
var A;
|
|
7682
|
+
b(!0), c().forEach((I) => {
|
|
7683
|
+
I.value = "";
|
|
7619
7684
|
});
|
|
7620
|
-
const
|
|
7621
|
-
if (
|
|
7622
|
-
const
|
|
7623
|
-
|
|
7685
|
+
const S = u();
|
|
7686
|
+
if (S && (S.textContent = "Too many failed attempts. Please wait."), !h()) {
|
|
7687
|
+
const I = document.createElement("p");
|
|
7688
|
+
I.className = "__crossx-pin6-lock-msg", I.id = "__crossx-pin6-lock-msg", I.innerHTML = `${Cs}<span id="__crossx-pin6-lock-countdown"></span>`;
|
|
7624
7689
|
const _ = u();
|
|
7625
|
-
_ ? _.insertAdjacentElement("afterend",
|
|
7626
|
-
}
|
|
7627
|
-
const
|
|
7628
|
-
var
|
|
7629
|
-
const
|
|
7630
|
-
|
|
7631
|
-
var
|
|
7632
|
-
return (
|
|
7633
|
-
}, 50)) : _ && (_.textContent = ` ${zn(
|
|
7634
|
-
},
|
|
7635
|
-
|
|
7636
|
-
const
|
|
7637
|
-
document.contains(r) || (clearInterval(
|
|
7690
|
+
_ ? _.insertAdjacentElement("afterend", I) : (A = f()) == null || A.appendChild(I);
|
|
7691
|
+
}
|
|
7692
|
+
const L = () => {
|
|
7693
|
+
var g;
|
|
7694
|
+
const I = P - Date.now(), _ = x();
|
|
7695
|
+
I <= 0 ? (clearInterval(G), b(!1), (g = h()) == null || g.remove(), S && (S.textContent = ""), setTimeout(() => {
|
|
7696
|
+
var v;
|
|
7697
|
+
return (v = c()[0]) == null ? void 0 : v.focus();
|
|
7698
|
+
}, 50)) : _ && (_.textContent = ` ${zn(I)}`);
|
|
7699
|
+
}, G = setInterval(L, 1e3);
|
|
7700
|
+
L();
|
|
7701
|
+
const O = new MutationObserver(() => {
|
|
7702
|
+
document.contains(r) || (clearInterval(G), O.disconnect());
|
|
7638
7703
|
});
|
|
7639
|
-
|
|
7640
|
-
},
|
|
7704
|
+
O.observe(document.body, { childList: !0, subtree: !1 });
|
|
7705
|
+
}, W = async () => {
|
|
7641
7706
|
if (i || a) return;
|
|
7642
7707
|
const P = w();
|
|
7643
7708
|
if (P.length === 6) {
|
|
7644
|
-
a = !0, c().forEach((
|
|
7645
|
-
|
|
7709
|
+
a = !0, c().forEach((S) => {
|
|
7710
|
+
S.disabled = !0;
|
|
7646
7711
|
});
|
|
7647
7712
|
try {
|
|
7648
7713
|
if (n) {
|
|
7649
|
-
const
|
|
7650
|
-
|
|
7714
|
+
const S = await n(P);
|
|
7715
|
+
S.ok ? e(P) : S.lockExpiresAt ? C(S.lockExpiresAt) : k(S.error ?? "Incorrect PIN. Please try again.");
|
|
7651
7716
|
} else
|
|
7652
7717
|
e(P);
|
|
7653
|
-
} catch (
|
|
7654
|
-
t && t(
|
|
7718
|
+
} catch (S) {
|
|
7719
|
+
t && t(S);
|
|
7655
7720
|
} finally {
|
|
7656
|
-
a = !1, i || c().forEach((
|
|
7657
|
-
|
|
7721
|
+
a = !1, i || c().forEach((S) => {
|
|
7722
|
+
S.disabled = !1;
|
|
7658
7723
|
});
|
|
7659
7724
|
}
|
|
7660
7725
|
}
|
|
@@ -7663,40 +7728,40 @@ function ot(r, e, s, t, n, o) {
|
|
|
7663
7728
|
var P;
|
|
7664
7729
|
return (P = c()[0]) == null ? void 0 : P.focus();
|
|
7665
7730
|
}, 100);
|
|
7666
|
-
const
|
|
7731
|
+
const B = () => {
|
|
7667
7732
|
if (i || a) return;
|
|
7668
|
-
const P = c(),
|
|
7669
|
-
|
|
7733
|
+
const P = c(), S = P.find((L) => !L.value) ?? P[P.length - 1];
|
|
7734
|
+
S == null || S.focus();
|
|
7670
7735
|
};
|
|
7671
|
-
(
|
|
7672
|
-
P.target.classList.contains("__crossx-pin6-box") ||
|
|
7673
|
-
}), (
|
|
7674
|
-
const
|
|
7675
|
-
|
|
7676
|
-
}), c().forEach((P,
|
|
7736
|
+
(j = l()) == null || j.addEventListener("click", (P) => {
|
|
7737
|
+
P.target.classList.contains("__crossx-pin6-box") || B();
|
|
7738
|
+
}), (q = f()) == null || q.addEventListener("click", (P) => {
|
|
7739
|
+
const S = P.target;
|
|
7740
|
+
S.classList.contains("__crossx-pin6-box") || S.closest("button") || B();
|
|
7741
|
+
}), c().forEach((P, S) => {
|
|
7677
7742
|
P.addEventListener("input", () => {
|
|
7678
|
-
var
|
|
7679
|
-
const
|
|
7680
|
-
P.value =
|
|
7681
|
-
}), P.addEventListener("keydown", (
|
|
7682
|
-
var
|
|
7683
|
-
if (
|
|
7684
|
-
if (
|
|
7743
|
+
var G;
|
|
7744
|
+
const L = P.value.replace(/\D/g, "").slice(-1);
|
|
7745
|
+
P.value = L, y(), L && S < 5 && ((G = c()[S + 1]) == null || G.focus()), w().length === 6 && setTimeout(W, 80);
|
|
7746
|
+
}), P.addEventListener("keydown", (L) => {
|
|
7747
|
+
var G, O;
|
|
7748
|
+
if (L.key === "Backspace") {
|
|
7749
|
+
if (L.preventDefault(), P.value)
|
|
7685
7750
|
P.value = "";
|
|
7686
|
-
else if (
|
|
7687
|
-
const
|
|
7688
|
-
|
|
7751
|
+
else if (S > 0) {
|
|
7752
|
+
const A = c()[S - 1];
|
|
7753
|
+
A.value = "", A.focus();
|
|
7689
7754
|
}
|
|
7690
|
-
} else
|
|
7691
|
-
}), P.addEventListener("paste", (
|
|
7692
|
-
var
|
|
7693
|
-
|
|
7694
|
-
const
|
|
7695
|
-
if (!
|
|
7696
|
-
const
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
}), (
|
|
7755
|
+
} else L.key === "ArrowLeft" && S > 0 ? (L.preventDefault(), (G = c()[S - 1]) == null || G.focus()) : L.key === "ArrowRight" && S < 5 ? (L.preventDefault(), (O = c()[S + 1]) == null || O.focus()) : L.key === "Escape" && s();
|
|
7756
|
+
}), P.addEventListener("paste", (L) => {
|
|
7757
|
+
var A, I;
|
|
7758
|
+
L.preventDefault();
|
|
7759
|
+
const G = (((A = L.clipboardData) == null ? void 0 : A.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
|
|
7760
|
+
if (!G) return;
|
|
7761
|
+
const O = c();
|
|
7762
|
+
G.split("").forEach((_, g) => {
|
|
7763
|
+
O[g] && (O[g].value = _);
|
|
7764
|
+
}), (I = O[Math.min(G.length - 1, 5)]) == null || I.focus(), y(), w().length === 6 && setTimeout(W, 80);
|
|
7700
7765
|
}), P.addEventListener("focus", () => P.select());
|
|
7701
7766
|
});
|
|
7702
7767
|
}
|
|
@@ -7725,8 +7790,8 @@ function Jn(r, e, s) {
|
|
|
7725
7790
|
c.preventDefault();
|
|
7726
7791
|
const l = (((h = c.clipboardData) == null ? void 0 : h.getData("text")) ?? "").replace(/\D/g, "").slice(0, 4);
|
|
7727
7792
|
if (!l) return;
|
|
7728
|
-
l.split("").forEach((
|
|
7729
|
-
t[f] && (t[f].value =
|
|
7793
|
+
l.split("").forEach((x, f) => {
|
|
7794
|
+
t[f] && (t[f].value = x);
|
|
7730
7795
|
});
|
|
7731
7796
|
const u = Math.min(l.length, 3);
|
|
7732
7797
|
t[u].focus(), l.length === 4 && setTimeout(() => e(l), 200);
|
|
@@ -7760,7 +7825,7 @@ class Xn {
|
|
|
7760
7825
|
*/
|
|
7761
7826
|
showWalletSelector(e, s, t) {
|
|
7762
7827
|
return new Promise((n) => {
|
|
7763
|
-
var
|
|
7828
|
+
var b;
|
|
7764
7829
|
he();
|
|
7765
7830
|
const o = [...e], i = $n(o, this.tokens, t), a = document.body.style.overflow;
|
|
7766
7831
|
document.body.style.overflow = "hidden", pe(i);
|
|
@@ -7775,8 +7840,8 @@ class Xn {
|
|
|
7775
7840
|
(() => {
|
|
7776
7841
|
i.querySelectorAll(".__crossx-wallet-item").forEach((y) => {
|
|
7777
7842
|
y.addEventListener("click", () => {
|
|
7778
|
-
const
|
|
7779
|
-
u({ address:
|
|
7843
|
+
const k = y.dataset.walletAddress ?? "", C = parseInt(y.dataset.walletIndex ?? "0", 10);
|
|
7844
|
+
u({ address: k, index: C });
|
|
7780
7845
|
});
|
|
7781
7846
|
});
|
|
7782
7847
|
})();
|
|
@@ -7786,16 +7851,16 @@ class Xn {
|
|
|
7786
7851
|
try {
|
|
7787
7852
|
const y = await s();
|
|
7788
7853
|
o.push(y);
|
|
7789
|
-
const
|
|
7790
|
-
if (
|
|
7854
|
+
const k = i.querySelector("#__crossx-wallet-list");
|
|
7855
|
+
if (k) {
|
|
7791
7856
|
const C = document.createElement("button");
|
|
7792
|
-
C.className = "__crossx-wallet-item", C.dataset.walletIndex = String(y.index), C.dataset.walletAddress = y.address, C.innerHTML = `<span class="__crossx-wallet-addr">${se(y.address)}</span>`, C.addEventListener("click", () => u(y)),
|
|
7857
|
+
C.className = "__crossx-wallet-item", C.dataset.walletIndex = String(y.index), C.dataset.walletAddress = y.address, C.innerHTML = `<span class="__crossx-wallet-addr">${se(y.address)}</span>`, C.addEventListener("click", () => u(y)), k.appendChild(C), C.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
7793
7858
|
}
|
|
7794
7859
|
} catch {
|
|
7795
7860
|
} finally {
|
|
7796
7861
|
f.disabled = !1;
|
|
7797
7862
|
}
|
|
7798
|
-
}), (
|
|
7863
|
+
}), (b = i.querySelector("#__crossx-close-btn")) == null || b.addEventListener("click", h), i.addEventListener("click", (y) => {
|
|
7799
7864
|
y.target === i && h();
|
|
7800
7865
|
});
|
|
7801
7866
|
const w = (y) => {
|
|
@@ -7816,18 +7881,18 @@ class Xn {
|
|
|
7816
7881
|
he();
|
|
7817
7882
|
const t = Hn(this.tokens, e == null ? void 0 : e.showConnectOtherWallets);
|
|
7818
7883
|
pe(t);
|
|
7819
|
-
const n = () => t.remove(), o = (
|
|
7820
|
-
n(), s(
|
|
7884
|
+
const n = () => t.remove(), o = (x) => {
|
|
7885
|
+
n(), s(x);
|
|
7821
7886
|
}, i = () => {
|
|
7822
7887
|
n(), s(null);
|
|
7823
7888
|
};
|
|
7824
|
-
(c = t.querySelector("#__crossx-apple-btn")) == null || c.addEventListener("click", () => o("apple")), (l = t.querySelector("#__crossx-google-btn")) == null || l.addEventListener("click", () => o("google")), (u = t.querySelector("#__crossx-connect-btn")) == null || u.addEventListener("click", () => o("external")), (h = t.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", i), t.addEventListener("click", (
|
|
7825
|
-
|
|
7826
|
-
}), t.querySelectorAll(".__crossx-login-terms-link").forEach((
|
|
7827
|
-
|
|
7889
|
+
(c = t.querySelector("#__crossx-apple-btn")) == null || c.addEventListener("click", () => o("apple")), (l = t.querySelector("#__crossx-google-btn")) == null || l.addEventListener("click", () => o("google")), (u = t.querySelector("#__crossx-connect-btn")) == null || u.addEventListener("click", () => o("external")), (h = t.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", i), t.addEventListener("click", (x) => {
|
|
7890
|
+
x.target === t && i();
|
|
7891
|
+
}), t.querySelectorAll(".__crossx-login-terms-link").forEach((x) => {
|
|
7892
|
+
x.addEventListener("click", (f) => f.stopPropagation());
|
|
7828
7893
|
});
|
|
7829
|
-
const a = (
|
|
7830
|
-
|
|
7894
|
+
const a = (x) => {
|
|
7895
|
+
x.key === "Escape" && (document.removeEventListener("keydown", a), i());
|
|
7831
7896
|
};
|
|
7832
7897
|
document.addEventListener("keydown", a);
|
|
7833
7898
|
});
|
|
@@ -7851,11 +7916,11 @@ class Xn {
|
|
|
7851
7916
|
const u = () => {
|
|
7852
7917
|
o(), t("skip");
|
|
7853
7918
|
};
|
|
7854
|
-
(c = n.querySelector("#__crossx-skip-btn")) == null || c.addEventListener("click", u), (l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", u), n.addEventListener("click", (
|
|
7855
|
-
|
|
7919
|
+
(c = n.querySelector("#__crossx-skip-btn")) == null || c.addEventListener("click", u), (l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", u), n.addEventListener("click", (x) => {
|
|
7920
|
+
x.target === n && u();
|
|
7856
7921
|
});
|
|
7857
|
-
const h = (
|
|
7858
|
-
|
|
7922
|
+
const h = (x) => {
|
|
7923
|
+
x.key === "Escape" && (document.removeEventListener("keydown", h), u());
|
|
7859
7924
|
};
|
|
7860
7925
|
document.addEventListener("keydown", h);
|
|
7861
7926
|
}
|
|
@@ -7895,7 +7960,7 @@ class Xn {
|
|
|
7895
7960
|
l || (l = !0, a.remove(), document.body.style.overflow = c);
|
|
7896
7961
|
}, h = (C) => {
|
|
7897
7962
|
u(), s(C);
|
|
7898
|
-
},
|
|
7963
|
+
}, x = () => {
|
|
7899
7964
|
u(), s(null);
|
|
7900
7965
|
}, f = a.querySelector(".__crossx-card"), w = {
|
|
7901
7966
|
tooShort: (t == null ? void 0 : t.pinValidation_tooShort) ?? "Please enter a 6-digit PIN.",
|
|
@@ -7903,66 +7968,66 @@ class Xn {
|
|
|
7903
7968
|
repeatingDigit: (t == null ? void 0 : t.pinValidation_repeatingDigit) ?? "Cannot use the same number 3+ times in a row.",
|
|
7904
7969
|
sequential: (t == null ? void 0 : t.pinValidation_sequential) ?? "Sequential numbers (e.g., 123456) are not allowed.",
|
|
7905
7970
|
alternatingPattern: (t == null ? void 0 : t.pinValidation_alternatingPattern) ?? "Repeating patterns (e.g., 121212) are not allowed."
|
|
7906
|
-
},
|
|
7907
|
-
var
|
|
7971
|
+
}, b = (C) => {
|
|
7972
|
+
var W;
|
|
7908
7973
|
f.innerHTML = nt({
|
|
7909
7974
|
title: i.title,
|
|
7910
7975
|
headerSubtitle: i.headerSubtitle
|
|
7911
|
-
}), (
|
|
7912
|
-
|
|
7913
|
-
},
|
|
7976
|
+
}), (W = f.querySelector("#__crossx-close-btn")) == null || W.addEventListener("click", x), ot(f, (B) => {
|
|
7977
|
+
B === C ? h(C) : y(o.mismatchError);
|
|
7978
|
+
}, x);
|
|
7914
7979
|
}, y = (C) => {
|
|
7915
|
-
var
|
|
7980
|
+
var W;
|
|
7916
7981
|
f.innerHTML = nt({
|
|
7917
7982
|
title: o.title,
|
|
7918
7983
|
headerSubtitle: o.headerSubtitle,
|
|
7919
7984
|
subtitle: o.subtitle,
|
|
7920
7985
|
errorMessage: C
|
|
7921
|
-
}), (
|
|
7922
|
-
const
|
|
7923
|
-
|
|
7924
|
-
},
|
|
7986
|
+
}), (W = f.querySelector("#__crossx-close-btn")) == null || W.addEventListener("click", x), ot(f, (B) => {
|
|
7987
|
+
const j = Vn(B, w);
|
|
7988
|
+
j ? y(j) : b(B);
|
|
7989
|
+
}, x);
|
|
7925
7990
|
};
|
|
7926
7991
|
(() => {
|
|
7927
|
-
var
|
|
7928
|
-
const C = Array.from(f.querySelectorAll(".__crossx-pw-notice-item")),
|
|
7929
|
-
|
|
7930
|
-
const
|
|
7931
|
-
const
|
|
7932
|
-
|
|
7933
|
-
},
|
|
7934
|
-
if (
|
|
7935
|
-
const
|
|
7936
|
-
|
|
7937
|
-
},
|
|
7938
|
-
if (!
|
|
7939
|
-
const
|
|
7940
|
-
|
|
7992
|
+
var G;
|
|
7993
|
+
const C = Array.from(f.querySelectorAll(".__crossx-pw-notice-item")), W = f.querySelector("#__crossx-pin-notice-next"), B = /* @__PURE__ */ new Set();
|
|
7994
|
+
W.removeAttribute("disabled");
|
|
7995
|
+
const j = W.dataset.nextLabel ?? "Next", q = W.dataset.submitLabel ?? "I Understand", P = () => {
|
|
7996
|
+
const O = B.size === C.length;
|
|
7997
|
+
W.classList.toggle("--disabled", !O), W.textContent = O ? q : j;
|
|
7998
|
+
}, S = (O, A) => {
|
|
7999
|
+
if (B.has(A)) return;
|
|
8000
|
+
const I = O.querySelector(`#__crossx-notice-check-${A}`);
|
|
8001
|
+
B.add(A), I.classList.add("--checked"), O.setAttribute("aria-checked", "true"), P();
|
|
8002
|
+
}, L = (O, A) => {
|
|
8003
|
+
if (!B.has(A)) return;
|
|
8004
|
+
const I = O.querySelector(`#__crossx-notice-check-${A}`);
|
|
8005
|
+
B.delete(A), I.classList.remove("--checked"), O.setAttribute("aria-checked", "false"), P();
|
|
7941
8006
|
};
|
|
7942
|
-
C.forEach((
|
|
7943
|
-
const
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
}),
|
|
7947
|
-
(
|
|
8007
|
+
C.forEach((O) => {
|
|
8008
|
+
const A = parseInt(O.dataset.checkIndex ?? "0", 10);
|
|
8009
|
+
O.addEventListener("click", () => {
|
|
8010
|
+
B.has(A) ? L(O, A) : S(O, A);
|
|
8011
|
+
}), O.addEventListener("keydown", (I) => {
|
|
8012
|
+
(I.key === " " || I.key === "Enter") && (I.preventDefault(), B.has(A) ? L(O, A) : S(O, A));
|
|
7948
8013
|
});
|
|
7949
|
-
}),
|
|
7950
|
-
if (
|
|
8014
|
+
}), W.addEventListener("click", () => {
|
|
8015
|
+
if (B.size === C.length) {
|
|
7951
8016
|
y(e == null ? void 0 : e.errorMessage);
|
|
7952
8017
|
return;
|
|
7953
8018
|
}
|
|
7954
|
-
const
|
|
7955
|
-
const _ = parseInt(
|
|
7956
|
-
return !
|
|
8019
|
+
const O = C.find((I) => {
|
|
8020
|
+
const _ = parseInt(I.dataset.checkIndex ?? "0", 10);
|
|
8021
|
+
return !B.has(_);
|
|
7957
8022
|
});
|
|
7958
|
-
if (!
|
|
7959
|
-
const
|
|
7960
|
-
|
|
7961
|
-
|
|
8023
|
+
if (!O) return;
|
|
8024
|
+
const A = parseInt(O.dataset.checkIndex ?? "0", 10);
|
|
8025
|
+
O.scrollIntoView({ behavior: "smooth", block: "nearest" }), O.classList.add("--highlight"), setTimeout(() => {
|
|
8026
|
+
O.classList.remove("--highlight"), S(O, A);
|
|
7962
8027
|
}, 400);
|
|
7963
|
-
}), (
|
|
8028
|
+
}), (G = f.querySelector("#__crossx-close-btn")) == null || G.addEventListener("click", x);
|
|
7964
8029
|
})(), a.addEventListener("click", (C) => {
|
|
7965
|
-
C.target === a &&
|
|
8030
|
+
C.target === a && x();
|
|
7966
8031
|
});
|
|
7967
8032
|
});
|
|
7968
8033
|
}
|
|
@@ -7988,15 +8053,15 @@ class Xn {
|
|
|
7988
8053
|
let u = !1;
|
|
7989
8054
|
const h = () => {
|
|
7990
8055
|
u || (u = !0, c.remove(), document.body.style.overflow = l);
|
|
7991
|
-
},
|
|
7992
|
-
h(), s(
|
|
8056
|
+
}, x = (k) => {
|
|
8057
|
+
h(), s(k);
|
|
7993
8058
|
}, f = () => {
|
|
7994
8059
|
h(), s(null);
|
|
7995
|
-
}, w = (
|
|
7996
|
-
h(), t(
|
|
7997
|
-
},
|
|
7998
|
-
(y =
|
|
7999
|
-
|
|
8060
|
+
}, w = (k) => {
|
|
8061
|
+
h(), t(k);
|
|
8062
|
+
}, b = c.querySelector(".__crossx-card");
|
|
8063
|
+
(y = b.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", f), ot(b, x, f, w, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt), c.addEventListener("click", (k) => {
|
|
8064
|
+
k.target === c && f();
|
|
8000
8065
|
});
|
|
8001
8066
|
});
|
|
8002
8067
|
}
|
|
@@ -8053,17 +8118,17 @@ class Xn {
|
|
|
8053
8118
|
return new Promise((s) => {
|
|
8054
8119
|
var a, c;
|
|
8055
8120
|
he();
|
|
8056
|
-
const t =
|
|
8121
|
+
const t = On(e, this.tokens);
|
|
8057
8122
|
pe(t);
|
|
8058
8123
|
const n = () => t.remove(), o = () => {
|
|
8059
8124
|
n(), s();
|
|
8060
8125
|
};
|
|
8061
8126
|
(a = t.querySelector("#__crossx-done-btn")) == null || a.addEventListener("click", o), (c = t.querySelector("#__crossx-close-btn")) == null || c.addEventListener("click", o), t.querySelectorAll(".__crossx-copy-btn").forEach((l) => {
|
|
8062
8127
|
l.addEventListener("click", (u) => {
|
|
8063
|
-
var
|
|
8128
|
+
var x;
|
|
8064
8129
|
u.stopPropagation();
|
|
8065
8130
|
const h = l.dataset.copy;
|
|
8066
|
-
h && ((
|
|
8131
|
+
h && ((x = navigator.clipboard) == null || x.writeText(h).catch(() => {
|
|
8067
8132
|
}));
|
|
8068
8133
|
});
|
|
8069
8134
|
}), t.addEventListener("click", (l) => {
|
|
@@ -8082,7 +8147,7 @@ class Xn {
|
|
|
8082
8147
|
showTransactionProgress(e, s) {
|
|
8083
8148
|
return new Promise((t) => {
|
|
8084
8149
|
he();
|
|
8085
|
-
const n =
|
|
8150
|
+
const n = Nn(e, this.tokens);
|
|
8086
8151
|
pe(n);
|
|
8087
8152
|
const o = () => n.remove();
|
|
8088
8153
|
let i = !1;
|
|
@@ -8090,11 +8155,11 @@ class Xn {
|
|
|
8090
8155
|
i || (i = !0, o(), t());
|
|
8091
8156
|
}, c = () => {
|
|
8092
8157
|
var u, h;
|
|
8093
|
-
(u = n.querySelector("#__crossx-done-btn")) == null || u.addEventListener("click", a), (h = n.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", a), n.addEventListener("click", (
|
|
8094
|
-
|
|
8158
|
+
(u = n.querySelector("#__crossx-done-btn")) == null || u.addEventListener("click", a), (h = n.querySelector("#__crossx-close-btn")) == null || h.addEventListener("click", a), n.addEventListener("click", (x) => {
|
|
8159
|
+
x.target === n && a();
|
|
8095
8160
|
});
|
|
8096
|
-
const l = (
|
|
8097
|
-
|
|
8161
|
+
const l = (x) => {
|
|
8162
|
+
x.key === "Escape" && (document.removeEventListener("keydown", l), a());
|
|
8098
8163
|
};
|
|
8099
8164
|
document.addEventListener("keydown", l);
|
|
8100
8165
|
};
|
|
@@ -8115,9 +8180,9 @@ class Xn {
|
|
|
8115
8180
|
n(), s(!1);
|
|
8116
8181
|
};
|
|
8117
8182
|
(c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (u = t.querySelector("#__crossx-close-btn")) == null || u.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((h) => {
|
|
8118
|
-
h.addEventListener("click", (
|
|
8183
|
+
h.addEventListener("click", (x) => {
|
|
8119
8184
|
var w;
|
|
8120
|
-
|
|
8185
|
+
x.stopPropagation();
|
|
8121
8186
|
const f = h.dataset.copy;
|
|
8122
8187
|
f && ((w = navigator.clipboard) == null || w.writeText(f).catch(() => {
|
|
8123
8188
|
}));
|
|
@@ -8155,7 +8220,7 @@ class Zn {
|
|
|
8155
8220
|
return this.get() !== null;
|
|
8156
8221
|
}
|
|
8157
8222
|
}
|
|
8158
|
-
function
|
|
8223
|
+
function io(r, e) {
|
|
8159
8224
|
r.debug;
|
|
8160
8225
|
const s = Ge.production, t = {
|
|
8161
8226
|
...r,
|
|
@@ -8165,22 +8230,22 @@ function so(r, e) {
|
|
|
8165
8230
|
}, n = {
|
|
8166
8231
|
gatewayUrl: s.walletGatewayUrl,
|
|
8167
8232
|
projectId: r.projectId
|
|
8168
|
-
}, o = t.authMode !== "cookie" &&
|
|
8233
|
+
}, o = t.authMode !== "cookie" && Nt.isAvailable();
|
|
8169
8234
|
!o && t.authMode !== "cookie" && d.warn(
|
|
8170
8235
|
"[CROSSx] IndexedDB 사용 불가 — LocalStorage fallback 사용 중.",
|
|
8171
8236
|
"refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
|
|
8172
8237
|
"IndexedDB를 지원하는 브라우저 사용을 권장합니다."
|
|
8173
8238
|
), t.secureStorageAvailable = o;
|
|
8174
|
-
const i = o ? new
|
|
8175
|
-
let
|
|
8176
|
-
r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"),
|
|
8239
|
+
const i = o ? new Nt(r.projectId) : new rr(), a = new hn(), c = new xn(), l = new Ee(), u = new Zn(), h = new es();
|
|
8240
|
+
let x;
|
|
8241
|
+
r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), x = new mn(i, h)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), x = new Le(
|
|
8177
8242
|
n,
|
|
8178
8243
|
i,
|
|
8179
8244
|
c,
|
|
8180
8245
|
u,
|
|
8181
8246
|
h
|
|
8182
8247
|
));
|
|
8183
|
-
const f = new De(n, c), w = new Xn(r.theme ?? "light", r.themeTokens),
|
|
8248
|
+
const f = new De(n, c), w = new Xn(r.theme ?? "light", r.themeTokens), b = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w;
|
|
8184
8249
|
return new it(
|
|
8185
8250
|
t,
|
|
8186
8251
|
n,
|
|
@@ -8188,20 +8253,73 @@ function so(r, e) {
|
|
|
8188
8253
|
a,
|
|
8189
8254
|
c,
|
|
8190
8255
|
l,
|
|
8191
|
-
|
|
8256
|
+
x,
|
|
8192
8257
|
u,
|
|
8193
|
-
|
|
8258
|
+
b,
|
|
8194
8259
|
f,
|
|
8195
8260
|
h
|
|
8196
8261
|
);
|
|
8197
8262
|
}
|
|
8263
|
+
function ao(r) {
|
|
8264
|
+
const e = Qn(r), s = eo(e), t = JSON.parse(s);
|
|
8265
|
+
so(t);
|
|
8266
|
+
const { data: n } = t;
|
|
8267
|
+
return {
|
|
8268
|
+
status: t.status,
|
|
8269
|
+
state: t.state,
|
|
8270
|
+
firebaseToken: n.accessToken,
|
|
8271
|
+
provider: n.provider,
|
|
8272
|
+
email: n.email,
|
|
8273
|
+
providerSub: n.sub,
|
|
8274
|
+
tokenType: n.tokenType,
|
|
8275
|
+
expiresIn: n.expiresIn,
|
|
8276
|
+
raw: t
|
|
8277
|
+
};
|
|
8278
|
+
}
|
|
8279
|
+
function Qn(r) {
|
|
8280
|
+
if (r.includes("://") && r.includes("?")) {
|
|
8281
|
+
const s = new URL(r).searchParams.get("data");
|
|
8282
|
+
if (!s)
|
|
8283
|
+
throw new Error("Deeplink URL에 data 파라미터가 없습니다");
|
|
8284
|
+
return s;
|
|
8285
|
+
}
|
|
8286
|
+
return r;
|
|
8287
|
+
}
|
|
8288
|
+
function eo(r) {
|
|
8289
|
+
const e = to(r);
|
|
8290
|
+
return decodeURIComponent(e);
|
|
8291
|
+
}
|
|
8292
|
+
function to(r) {
|
|
8293
|
+
if (typeof atob == "function")
|
|
8294
|
+
return atob(r);
|
|
8295
|
+
if (typeof Buffer < "u")
|
|
8296
|
+
return Buffer.from(r, "base64").toString("utf-8");
|
|
8297
|
+
throw new Error("Base64 디코딩을 지원하는 환경이 아닙니다");
|
|
8298
|
+
}
|
|
8299
|
+
function so(r) {
|
|
8300
|
+
if (typeof r != "object" || r === null)
|
|
8301
|
+
throw new Error("Deeplink payload가 유효한 객체가 아닙니다");
|
|
8302
|
+
const e = r;
|
|
8303
|
+
if (typeof e.status != "string")
|
|
8304
|
+
throw new Error("Deeplink payload에 status 필드가 없습니다");
|
|
8305
|
+
if (typeof e.state != "string")
|
|
8306
|
+
throw new Error("Deeplink payload에 state 필드가 없습니다");
|
|
8307
|
+
if (typeof e.data != "object" || e.data === null)
|
|
8308
|
+
throw new Error("Deeplink payload에 data 필드가 없습니다");
|
|
8309
|
+
const s = e.data;
|
|
8310
|
+
if (typeof s.provider != "string")
|
|
8311
|
+
throw new Error("Deeplink data에 provider 필드가 없습니다");
|
|
8312
|
+
if (typeof s.accessToken != "string")
|
|
8313
|
+
throw new Error("Deeplink data에 accessToken 필드가 없습니다");
|
|
8314
|
+
}
|
|
8198
8315
|
export {
|
|
8199
8316
|
m as CROSSxError,
|
|
8200
8317
|
Fs as CROSSxEthereumProvider,
|
|
8201
8318
|
it as CROSSxSDK,
|
|
8202
|
-
|
|
8319
|
+
oo as ChainId,
|
|
8203
8320
|
p as ErrorCode,
|
|
8204
8321
|
es as PinMemoryStore,
|
|
8205
8322
|
Zn as TokenMemoryStore,
|
|
8206
|
-
|
|
8323
|
+
io as createCROSSxSDK,
|
|
8324
|
+
ao as parseOAuthDeeplink
|
|
8207
8325
|
};
|